Recommended
3 years ago
Support
3 years ago
Cross.php
3 years ago
Fallback.php
3 years ago
Fields.php
3 years ago
Helper.php
3 years ago
I18n.php
3 years ago
Plugin.php
3 years ago
Popup.php
3 years ago
PostType.php
3 years ago
Review.php
3 years ago
Settings.php
3 years ago
Shortcode.php
3 years ago
Upgrade.php
3 years ago
Fields.php
141 lines
| 1 | <?php |
| 2 | |
| 3 | namespace NTA_WhatsApp; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | class Fields |
| 8 | { |
| 9 | protected static $instance = null; |
| 10 | |
| 11 | public static function getInstance() |
| 12 | { |
| 13 | if (null == self::$instance) { |
| 14 | self::$instance = new self; |
| 15 | } |
| 16 | return self::$instance; |
| 17 | } |
| 18 | |
| 19 | public function __construct() |
| 20 | { |
| 21 | } |
| 22 | |
| 23 | public static function getButtonStyles($postId) |
| 24 | { |
| 25 | $meta = get_post_meta($postId, 'nta_wa_button_styles', true); |
| 26 | return wp_parse_args( |
| 27 | $meta === false ? array() : $meta, |
| 28 | array( |
| 29 | 'type' => "round", |
| 30 | 'backgroundColor' => "#2DB742", |
| 31 | 'textColor' => "#fff", |
| 32 | 'label' => __("Need Help? Chat with us", "ninjateam-whatsapp"), |
| 33 | 'width' => 300, |
| 34 | 'height' => 64, |
| 35 | ) |
| 36 | ); |
| 37 | } |
| 38 | |
| 39 | |
| 40 | public static function getWidgetDisplay() |
| 41 | { |
| 42 | return wp_parse_args( |
| 43 | get_option('nta_wa_widget_display', array()), |
| 44 | array( |
| 45 | 'displayCondition' => 'showAllPage', |
| 46 | 'includePages' => [], |
| 47 | 'excludePages' => [], |
| 48 | 'includePosts' => [], |
| 49 | 'showOnDesktop' => 'ON', |
| 50 | 'showOnMobile' => 'ON', |
| 51 | 'time_symbols' => 'h:m', |
| 52 | ) |
| 53 | ); |
| 54 | } |
| 55 | |
| 56 | public static function getURLSettings() |
| 57 | { |
| 58 | return wp_parse_args( |
| 59 | get_option('nta_wa_url', array()), |
| 60 | array( |
| 61 | 'onDesktop' => 'api', |
| 62 | 'onMobile' => 'api', |
| 63 | 'openInNewTab' => 'ON' |
| 64 | ) |
| 65 | ); |
| 66 | } |
| 67 | |
| 68 | public static function getWidgetStyles() |
| 69 | { |
| 70 | return wp_parse_args( |
| 71 | get_option('nta_wa_widget_styles', array()), |
| 72 | array( |
| 73 | 'title' => __("Start a Conversation", "ninjateam-whatsapp"), |
| 74 | "responseText" => __("The team typically replies in a few minutes.", "ninjateam-whatsapp"), |
| 75 | 'description' => __("Hi! Click one of our member below to chat on <strong>WhatsApp</strong>", "ninjateam-whatsapp"), |
| 76 | 'backgroundColor' => "#2db742", |
| 77 | 'textColor' => "#fff", |
| 78 | 'scrollHeight' => 500, |
| 79 | 'isShowScroll' => 'OFF', |
| 80 | 'isShowResponseText' => 'ON', |
| 81 | 'isShowPoweredBy' => 'ON', |
| 82 | |
| 83 | "btnLabel" => __("Need Help? <strong>Chat with us</strong>", "ninjateam-whatsapp"), |
| 84 | 'btnLabelWidth' => 156, |
| 85 | 'btnPosition' => 'right', |
| 86 | 'btnLeftDistance' => 30, |
| 87 | 'btnRightDistance' => 30, |
| 88 | 'btnBottomDistance' => 30, |
| 89 | 'isShowBtnLabel' => 'ON', |
| 90 | |
| 91 | 'isShowGDPR' => 'OFF', |
| 92 | "gdprContent" => __('Please accept our <a href="https://ninjateam.org/privacy-policy/">privacy policy</a> first to start a conversation.', "ninjateam-whatsapp"), |
| 93 | ) |
| 94 | ); |
| 95 | } |
| 96 | |
| 97 | public static function getWoocommerceSetting() |
| 98 | { |
| 99 | $option = get_option('nta_wa_woocommerce', array()); |
| 100 | return wp_parse_args($option, array( |
| 101 | 'position' => 'after_atc', |
| 102 | 'isShow' => 'OFF' |
| 103 | )); |
| 104 | } |
| 105 | |
| 106 | public static function getAnalyticsSetting(){ |
| 107 | $option = get_option('nta_wa_analytics', array()); |
| 108 | return wp_parse_args($option, array( |
| 109 | 'enabledGoogle' => 'OFF', |
| 110 | 'enabledFacebook' => 'OFF', |
| 111 | 'enabledGoogleGA4' => 'OFF' |
| 112 | )); |
| 113 | } |
| 114 | |
| 115 | public static function getDefaultMetaAccount($daysOfWeek) |
| 116 | { |
| 117 | $meta = array( |
| 118 | 'number' => '', |
| 119 | 'title' => '', |
| 120 | 'predefinedText' => '', |
| 121 | 'willBeBackText' => __('I will be back in [njwa_time_work]', 'ninjateam-whatsapp'), |
| 122 | 'dayOffsText' => __('I will be back soon', 'ninjateam-whatsapp'), |
| 123 | 'isAlwaysAvailable' => 'ON', |
| 124 | ); |
| 125 | |
| 126 | foreach ($daysOfWeek as $dayKey) { |
| 127 | $meta['daysOfWeekWorking'][$dayKey] = [ |
| 128 | 'isWorkingOnDay' => 'OFF', |
| 129 | 'workHours' => [ |
| 130 | [ |
| 131 | 'startTime' => '08:00', |
| 132 | 'endTime' => '17:30' |
| 133 | ] |
| 134 | ] |
| 135 | ]; |
| 136 | } |
| 137 | |
| 138 | return $meta; |
| 139 | } |
| 140 | } |
| 141 |