| @@ -38,19 +38,13 @@ | ||
| 38 | 38 | * Get settings tabs |
| 39 | 39 | */ |
| 40 | 40 | private static function get_settings_tabs() { |
| 41 | 41 | $tabs = array( |
| 42 | - 'general' => 'General', | |
| 43 | - 'woocommerce' => 'WooCommerce', | |
| 44 | - 'whatsapp_chat_button' => 'WhatsApp Chat Button', | |
| 45 | - 'api' => 'API', | |
| 46 | - 'advanced' => 'Advanced', | |
| 42 | + 'general' => 'General', | |
| 43 | + 'click_to_chat' => 'Click to Chat', | |
| 44 | + 'api' => 'API', | |
| 45 | + 'advanced' => 'Advanced' | |
| 47 | 46 | ); |
| 48 | - | |
| 49 | - if ( ! class_exists( 'WooCommerce' ) ) { | |
| 50 | - unset($tabs['woocommerce']); | |
| 51 | - } | |
| 52 | - | |
| 53 | 47 | return $tabs; |
| 54 | 48 | } |
| 55 | 49 | |
| 56 | 50 | /** |
| @@ -80,9 +74,8 @@ | ||
| 80 | 74 | $settings = array( |
| 81 | 75 | array( |
| 82 | 76 | 'title' => 'General', |
| 83 | 77 | 'type' => 'title', |
| 84 | - 'description' => '' | |
| 85 | 78 | ), |
| 86 | 79 | array( |
| 87 | 80 | 'id' => 'default_country_code', |
| 88 | 81 | 'title' => 'Default Country Code (Optional)', |
| @@ -91,15 +84,14 @@ | ||
| 91 | 84 | 'description' => 'Enter default country code that will be added to all recipient phone number fields before sending to WANotifier that do not start with a + sign.', |
| 92 | 85 | 'default' => '' |
| 93 | 86 | ), |
| 94 | 87 | ); |
| 95 | - | |
| 96 | 88 | break; |
| 97 | - case 'whatsapp_chat_button': | |
| 89 | + case 'click_to_chat': | |
| 98 | 90 | $settings = array( |
| 99 | 91 | array( |
| 100 | - 'title' => 'WhatsApp Chat Button', | |
| 101 | - 'description' => 'Add a WhatsApp chat button to your website to let your visitors start chat with you on WhatsApp.', | |
| 92 | + 'title' => 'Click to Chat', | |
| 93 | + 'description' => 'Show click to chat button on your website to let your visitors start WhatsApp chat with you.', | |
| 102 | 94 | 'type' => 'title', |
| 103 | 95 | ), |
| 104 | 96 | array( |
| 105 | 97 | 'id' => 'ctc_enable', |
| @@ -130,9 +122,16 @@ | ||
| 130 | 122 | 'name' => 'ctc_button_style', |
| 131 | 123 | 'class' => 'chat-button-style', |
| 132 | 124 | 'type' => 'select', |
| 133 | 125 | 'default' => '', |
| 134 | - 'options' => self::get_button_styles(), | |
| 126 | + 'options' => array( | |
| 127 | + 'default' => 'Select button style', | |
| 128 | + 'btn-style-1' => 'Style 1' , | |
| 129 | + 'btn-style-2' => 'Style 2', | |
| 130 | + 'btn-style-3' => 'Style 3', | |
| 131 | + 'btn-style-4' => 'Style 4', | |
| 132 | + 'btn-custom-image' => 'Add your own image' | |
| 133 | + ), | |
| 135 | 134 | 'description' => 'Select a button style. Preview will be shown on bottom right of this screen. You can update button style by writing custom CSS in your theme.', |
| 136 | 135 | ), |
| 137 | 136 | array( |
| 138 | 137 | 'id' => 'ctc_custom_button_image_url', |
| @@ -171,85 +170,23 @@ | ||
| 171 | 170 | 'type' => 'title', |
| 172 | 171 | ), |
| 173 | 172 | array( |
| 174 | 173 | 'id' => 'hidden_custom_keys', |
| 175 | - 'title' => 'Hidden custom meta keys', | |
| 174 | + 'title' => 'Enable hidden custom meta keys', | |
| 176 | 175 | 'type' => 'checkbox', |
| 177 | - 'label' => 'Enable', | |
| 178 | 176 | 'description' => 'Enable hidden custom meta keys that start with underscores (e.g. _field_name) to be avaialbe in Data and Recipient Fields. Note that enabling this might impact your website performance slightly.', |
| 179 | 177 | 'default' => '' |
| 180 | 178 | ), |
| 181 | 179 | array( |
| 182 | 180 | 'id' => 'enable_async_triggers', |
| 183 | - 'title' => 'Async triggers', | |
| 181 | + 'title' => 'Enable async triggers', | |
| 184 | 182 | 'type' => 'checkbox', |
| 185 | 183 | 'default' => '', |
| 186 | - 'label' => 'Enable', | |
| 187 | 184 | 'name' => 'enable_async_triggers', |
| 188 | 185 | 'description' => 'Plugin slowing down checkout or form submission? Enable this option to send triggers asynchronously using Action Scheduler. Note that if you have a site with strong caching, this might not work as expected.' , |
| 189 | 186 | ), |
| 190 | - array( | |
| 191 | - 'id' => 'enable_activity_log', | |
| 192 | - 'title' => 'Activity log', | |
| 193 | - 'type' => 'checkbox', | |
| 194 | - 'default' => '', | |
| 195 | - 'label' => 'Enable', | |
| 196 | - 'name' => 'enable_activity_log', | |
| 197 | - 'description' => 'Enabling this option will activate the activity logging feature. You can view activity logs <a href="/wp-admin/admin.php?page=notifier-tools">here</a>.' , | |
| 198 | - ), | |
| 199 | 187 | ); |
| 200 | 188 | break; |
| 201 | - case 'woocommerce': | |
| 202 | - if ( class_exists( 'WooCommerce' ) ) { | |
| 203 | - $settings = array( | |
| 204 | - array( | |
| 205 | - 'title' => 'Checkout', | |
| 206 | - 'description' => '', | |
| 207 | - 'type' => 'title', | |
| 208 | - ), | |
| 209 | - array( | |
| 210 | - 'id' => 'enable_opt_in_checkbox_checkout', | |
| 211 | - 'title' => 'Opt-in Consent on Checkout', | |
| 212 | - 'type' => 'checkbox', | |
| 213 | - 'default' => '', | |
| 214 | - 'label' => 'Enable', | |
| 215 | - 'name' => 'enable_opt_in_checkbox_checkout', | |
| 216 | - 'description' => 'Add an opt-in checkbox to WooCommerce checkout form. Once enabled, WhatsApp notification will be sent only to customers who opt-in during checkout.' | |
| 217 | - ), | |
| 218 | - array( | |
| 219 | - 'id' => 'checkout_opt_in_checkbox_text', | |
| 220 | - 'title' => 'Opt-in Checkbox Text', | |
| 221 | - 'type' => 'textarea', | |
| 222 | - 'placeholder' => 'Enter text for the opt-in checkbox', | |
| 223 | - 'default' => 'Receive updates on WhatsApp', | |
| 224 | - 'name' => 'checkout_opt_in_checkbox_text', | |
| 225 | - ), | |
| 226 | - array( | |
| 227 | - 'title' => 'Abandoned Cart', | |
| 228 | - 'description' => '', | |
| 229 | - 'type' => 'title', | |
| 230 | - ), | |
| 231 | - array( | |
| 232 | - 'id' => 'enable_abandonment_cart_tracking', | |
| 233 | - 'title' => 'Abandoned cart tracking', | |
| 234 | - 'type' => 'checkbox', | |
| 235 | - 'default' => '', | |
| 236 | - 'label' => 'Start capturing abandoned carts', | |
| 237 | - 'name' => 'enable_abandonment_cart_tracking', | |
| 238 | - 'description' => 'Enable this to start capturing abandoned carts in database. Carts will be considered as abandoned if order is not placed by the user after adding items in the cart within cart abandoned cut-off time set below.' | |
| 239 | - ), | |
| 240 | - array( | |
| 241 | - 'id' => 'abandonment_cart_cron_run_time', | |
| 242 | - 'title' => 'Cart abandoned cut-off time', | |
| 243 | - 'type' => 'number', | |
| 244 | - 'placeholder' => 'Enter time in minutes. Eg. 20', | |
| 245 | - 'description' => 'Enter time in minutes after which the cart will be considered as abandoned. This is the time from when items are added / updated in cart.', | |
| 246 | - 'default' => '20', | |
| 247 | - 'custom_attributes' => array('min' => 20), | |
| 248 | - ), | |
| 249 | - ); | |
| 250 | - } | |
| 251 | - break; | |
| 252 | 189 | } |
| 253 | 190 | $settings = apply_filters( 'notifier_$tab_settings_fields', $settings ); |
| 254 | 191 | return $settings; |
| 255 | 192 | } |
| @@ -257,14 +194,8 @@ | ||
| 257 | 194 | /** |
| 258 | 195 | * Generate HTML for displaying individual fields |
| 259 | 196 | */ |
| 260 | 197 | public static function display_field( $field ) { |
| 261 | - $field = wp_parse_args($field, array( | |
| 262 | - 'title' => '', | |
| 263 | - 'description' => '', | |
| 264 | - 'label' => '' | |
| 265 | - )); | |
| 266 | - | |
| 267 | 198 | $html = ''; |
| 268 | 199 | |
| 269 | 200 | if (isset($field['id'])) { |
| 270 | 201 | $option_name = NOTIFIER_PREFIX . $field['id']; |
| @@ -270,9 +201,9 @@ | ||
| 270 | 201 | $option_name = NOTIFIER_PREFIX . $field['id']; |
| 271 | 202 | $option = get_option( $option_name ); |
| 272 | 203 | } |
| 273 | 204 | |
| 274 | - $data = isset($option) ? $option : ''; | |
| 205 | + $data = $option; | |
| 275 | 206 | if ( isset( $field['default'] ) && empty($option) ) { |
| 276 | 207 | $data = $field['default']; |
| 277 | 208 | } |
| 278 | 209 | |
| @@ -596,35 +527,12 @@ | ||
| 596 | 527 | } |
| 597 | 528 | } |
| 598 | 529 | |
| 599 | 530 | /** |
| 600 | - * Get button styles | |
| 601 | - */ | |
| 602 | - public static function get_button_styles(){ | |
| 603 | - return array( | |
| 604 | - 'default' => 'Select button style', | |
| 605 | - 'btn-style-1' => 'Style 1' , | |
| 606 | - 'btn-style-2' => 'Style 2', | |
| 607 | - 'btn-style-3' => 'Style 3', | |
| 608 | - 'btn-style-4' => 'Style 4', | |
| 609 | - 'btn-custom-image' => 'Add your own image' | |
| 610 | - ); | |
| 611 | - } | |
| 612 | - | |
| 613 | - /** | |
| 614 | 531 | * Show Chat Button Preview |
| 615 | 532 | */ |
| 616 | 533 | public static function preview_btn_style(){ |
| 617 | 534 | $btn_style = isset($_POST['btn_style']) ? sanitize_text_field($_POST['btn_style']) : ''; |
| 618 | - | |
| 619 | - $button_styles = self::get_button_styles(); | |
| 620 | - $button_style_keys = array_keys($button_styles); | |
| 621 | - | |
| 622 | - if(! in_array($btn_style, $button_style_keys)){ | |
| 623 | - wp_send_json( array( | |
| 624 | - 'preview' => 'Invalid request' | |
| 625 | - ) ); | |
| 626 | - } | |
| 627 | 535 | |
| 628 | 536 | ob_start(); |
| 629 | 537 | include_once NOTIFIER_PATH.'templates/buttons/'.$btn_style.'.php'; |
| 630 | 538 | $btn_output = ob_get_clean(); |