Recommended
2 years ago
Support
2 years ago
Cross.php
2 years ago
Fallback.php
2 years ago
Fields.php
2 years ago
Helper.php
2 years ago
I18n.php
2 years ago
Plugin.php
2 years ago
Popup.php
2 years ago
PostType.php
2 years ago
Review.php
2 years ago
Settings.php
2 years ago
Shortcode.php
2 years ago
Upgrade.php
2 years ago
Shortcode.php
51 lines
| 1 | <?php |
| 2 | namespace NTA_WhatsApp; |
| 3 | |
| 4 | use NTA_WhatsApp\Fields; |
| 5 | |
| 6 | defined('ABSPATH') || exit; |
| 7 | class Shortcode |
| 8 | { |
| 9 | protected static $instance = null; |
| 10 | protected $accountID; |
| 11 | |
| 12 | public static function getInstance() |
| 13 | { |
| 14 | if (null == self::$instance) { |
| 15 | self::$instance = new self; |
| 16 | self::$instance->doHooks(); |
| 17 | } |
| 18 | return self::$instance; |
| 19 | } |
| 20 | |
| 21 | private function doHooks(){ |
| 22 | add_shortcode('njwa_button', [$this, 'button_shortcode']); |
| 23 | } |
| 24 | |
| 25 | public function button_shortcode($id) |
| 26 | { |
| 27 | extract($id); |
| 28 | $displayOption = Fields::getWidgetDisplay(); |
| 29 | $stylesOption = Fields::getWidgetStyles(); |
| 30 | $analyticsOption = Fields::getAnalyticsSetting(); |
| 31 | |
| 32 | $script = array( |
| 33 | 'name' => get_the_title($id), |
| 34 | 'info' => get_post_meta($id, 'nta_wa_account_info', true), |
| 35 | 'styles' => Fields::getButtonStyles($id), |
| 36 | 'avatar' => get_the_post_thumbnail_url($id), |
| 37 | 'options' => [ |
| 38 | 'display' => $displayOption, |
| 39 | 'styles' => $stylesOption, |
| 40 | 'analytics' => $analyticsOption |
| 41 | ], |
| 42 | 'gdprStatus' => Helper::checkGDPR($stylesOption), |
| 43 | 'defaultAvatar' => NTA_WHATSAPP_PLUGIN_URL . 'assets/img/whatsapp_logo.svg' |
| 44 | ); |
| 45 | |
| 46 | $content = '<div class="nta_wa_button" data-id="' . esc_attr($id) . '" data-info="' . esc_attr(json_encode($script)) . '"></div>'; |
| 47 | |
| 48 | return $content; |
| 49 | } |
| 50 | } |
| 51 |