Changeset 3130949
- Timestamp:
- 08/05/2024 10:30:00 AM (20 months ago)
- Location:
- dhlpwc
- Files:
-
- 14 edited
- 1 copied
-
tags/2.1.6 (copied) (copied from dhlpwc/trunk)
-
tags/2.1.6/README.md (modified) (1 diff)
-
tags/2.1.6/assets/js/dhlpwc.notices.js (modified) (1 diff)
-
tags/2.1.6/dhlpwoocommerce.php (modified) (2 diffs)
-
tags/2.1.6/includes/controller/admin/class-dhlpwc-controller-admin-settings.php (modified) (5 diffs)
-
tags/2.1.6/includes/view/admin/multi-select.php (modified) (1 diff)
-
tags/2.1.6/includes/view/admin/notice.php (modified) (1 diff)
-
tags/2.1.6/readme.txt (modified) (2 diffs)
-
trunk/README.md (modified) (1 diff)
-
trunk/assets/js/dhlpwc.notices.js (modified) (1 diff)
-
trunk/dhlpwoocommerce.php (modified) (2 diffs)
-
trunk/includes/controller/admin/class-dhlpwc-controller-admin-settings.php (modified) (5 diffs)
-
trunk/includes/view/admin/multi-select.php (modified) (1 diff)
-
trunk/includes/view/admin/notice.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dhlpwc/tags/2.1.6/README.md
r3123181 r3130949 1 1 # DHL eCommerce (Benelux) for WooCommerce 2 3 v2.1.6 4 ## Changes 5 - Added a button to dismiss the Gutenberg block notification forever 2 6 3 7 v2.1.5 -
dhlpwc/tags/2.1.6/assets/js/dhlpwc.notices.js
r2688414 r3130949 12 12 13 13 $.post(ajaxurl, data); 14 }).on('click', 'a#dhlpwc-dismiss-notice-forever', function(e) { 15 e.preventDefault(); 16 17 var data = { 18 'action': 'dhlpwc_dismiss_admin_notice_forever', 19 'notice_tag_forever': $(this).data('notice_tag_forever') 20 }; 21 22 $.post(ajaxurl, data); 23 24 $(this).siblings('.notice-dismiss').trigger('click'); 25 14 26 }); 15 27 -
dhlpwc/tags/2.1.6/dhlpwoocommerce.php
r3123181 r3130949 5 5 * Description: This is the official DHL eCommerce (Benelux) for WooCommerce plugin. 6 6 * Author: DHL eCommerce 7 * Version: 2.1. 57 * Version: 2.1.6 8 8 * Requires at least: 4.7.16 9 9 * Tested up to: 6.3 … … 52 52 53 53 // Set constants 54 $this->define('DHLPWC_PLUGIN_VERSION', '2.1. 5');54 $this->define('DHLPWC_PLUGIN_VERSION', '2.1.6'); 55 55 $this->define('DHLPWC_PLUGIN_FILE', __FILE__); 56 56 $this->define('DHLPWC_PLUGIN_BASENAME', plugin_basename(__FILE__)); -
dhlpwc/tags/2.1.6/includes/controller/admin/class-dhlpwc-controller-admin-settings.php
r3093985 r3130949 13 13 const NOTICE_TAG_API_SETTINGS = self::NOTICE_TAG_PREFIX . 'api_settings'; 14 14 const NOTICE_TAG_GUTENBERG_BLOCKS = self::NOTICE_TAG_PREFIX . 'gutenberg_blocks'; 15 const NOTICE_TAG_GUTENBERG_BLOCKS_FOREVER = self::NOTICE_TAG_PREFIX . 'gutenberg_blocks_forever'; 15 16 16 17 public function __construct() … … 40 41 41 42 add_action('wp_ajax_dhlpwc_dismiss_admin_notice', array($this, 'dismiss_admin_notice')); 43 add_action('wp_ajax_dhlpwc_dismiss_admin_notice_forever', array($this, 'dismiss_admin_notice_forever')); 42 44 add_action('wp_ajax_dhlpwc_test_connection', array($this, 'test_connection')); 43 45 add_action('wp_ajax_dhlpwc_search_printers', array($this, 'search_printers')); … … 80 82 81 83 // Send JSON response 84 wp_send_json($json_response->to_array(), 200); 85 } 86 87 /** 88 * Used to get all notices allowed for permanent dismissal. 89 * 90 * @return array 91 */ 92 public function foreverTags() 93 { 94 $class = new ReflectionClass(get_called_class()); 95 $constants = $class->getConstants(); 96 97 foreach ($constants as $name => $value) { 98 if (strpos($value, self::NOTICE_TAG_PREFIX) !== 0 || !preg_match('/_FOREVER/', $name)) { 99 unset($constants[$name]); 100 } 101 } 102 103 return $constants; 104 } 105 106 public function dismiss_admin_notice_forever() 107 { 108 $notice_tag_forever = wc_clean($_POST['notice_tag_forever']); 109 110 if(!in_array($notice_tag_forever, $this->foreverTags())) { 111 $json_response = new DHLPWC_Model_Response_JSON(); 112 $json_response->set_error(__('Bad request')); 113 wp_send_json($json_response->to_array(), 400); 114 115 return; 116 } 117 118 update_option(wc_clean($_POST['notice_tag_forever']), true); 119 $json_response = new DHLPWC_Model_Response_JSON(); 82 120 wp_send_json($json_response->to_array(), 200); 83 121 } … … 328 366 $id = get_option('woocommerce_checkout_page_id'); 329 367 $checkoutContent = get_post($id); 330 if ($service->plugin_is_enabled() && strpos($checkoutContent->post_content, 'wp:dhlpwc/dhlpwc-block') === false && strpos($checkoutContent->post_content, 'wp:woocommerce/checkout') !== false) { 368 369 if (!get_site_transient(self::NOTICE_TAG_GUTENBERG_BLOCKS) && 370 !get_option(self::NOTICE_TAG_GUTENBERG_BLOCKS_FOREVER) && 371 $service->plugin_is_enabled() && 372 strpos($checkoutContent->post_content, 'wp:dhlpwc/dhlpwc-block') === false && 373 strpos($checkoutContent->post_content, 'wp:woocommerce/checkout') !== false) { 331 374 $messages[] = sprintf(__('You are currently missing DHL shipping elements in your checkout. You can fix this by simply going to the edit page of your checkout page and hit the update button.')); 332 375 333 $this->show_notice(self::NOTICE_TAG_GUTENBERG_BLOCKS, $messages, admin_url('post.php?post=' . $id . '&action=edit') );334 } 335 } 336 337 public function show_notice($notice_tag, $messages, $admin_link = null )376 $this->show_notice(self::NOTICE_TAG_GUTENBERG_BLOCKS, $messages, admin_url('post.php?post=' . $id . '&action=edit'), self::NOTICE_TAG_GUTENBERG_BLOCKS_FOREVER); 377 } 378 } 379 380 public function show_notice($notice_tag, $messages, $admin_link = null, $notice_tag_forever = null) 338 381 { 339 382 // Add prefix if missing … … 345 388 $view->render(array( 346 389 'notice_tag' => $notice_tag, 390 'notice_tag_forever' => $notice_tag_forever, 347 391 'messages' => $messages, 348 392 'admin_link' => $admin_link, -
dhlpwc/tags/2.1.6/includes/view/admin/multi-select.php
r2688414 r3130949 1 <?php ?>1 <?php if (!defined('ABSPATH')) { exit; } ?> 2 2 <p class="form-field <?php echo esc_attr($id) ?>_field"> 3 3 <label for="<?php echo esc_attr($id) ?>"></label> -
dhlpwc/tags/2.1.6/includes/view/admin/notice.php
r2688414 r3130949 39 39 </span> 40 40 <?php endif ?> 41 42 <?php if (!empty($notice_tag_forever)): ?> 43 <br/><br/> 44 <a href="#" id="dhlpwc-dismiss-notice-forever" data-notice_tag_forever="<?php echo esc_attr($notice_tag_forever)?>"> 45 <b><?php _e('Click here to never show this again', 'dhlpwc') ?></b> 46 </a> 47 <?php endif ?> 41 48 </p> 42 49 </div> -
dhlpwc/tags/2.1.6/readme.txt
r3123181 r3130949 5 5 Requires PHP: 5.6 6 6 Tested up to: 6.6.0 7 Stable tag: 2.1. 57 Stable tag: 2.1.6 8 8 WC requires at least: 3.0.0 9 9 WC tested up to: 9.0.2 … … 56 56 57 57 == Changelog == 58 59 = 2.1.6 = 60 - Added a button to dismiss the Gutenberg block notification forever 58 61 59 62 = 2.1.5 = -
dhlpwc/trunk/README.md
r3123181 r3130949 1 1 # DHL eCommerce (Benelux) for WooCommerce 2 3 v2.1.6 4 ## Changes 5 - Added a button to dismiss the Gutenberg block notification forever 2 6 3 7 v2.1.5 -
dhlpwc/trunk/assets/js/dhlpwc.notices.js
r2688414 r3130949 12 12 13 13 $.post(ajaxurl, data); 14 }).on('click', 'a#dhlpwc-dismiss-notice-forever', function(e) { 15 e.preventDefault(); 16 17 var data = { 18 'action': 'dhlpwc_dismiss_admin_notice_forever', 19 'notice_tag_forever': $(this).data('notice_tag_forever') 20 }; 21 22 $.post(ajaxurl, data); 23 24 $(this).siblings('.notice-dismiss').trigger('click'); 25 14 26 }); 15 27 -
dhlpwc/trunk/dhlpwoocommerce.php
r3123181 r3130949 5 5 * Description: This is the official DHL eCommerce (Benelux) for WooCommerce plugin. 6 6 * Author: DHL eCommerce 7 * Version: 2.1. 57 * Version: 2.1.6 8 8 * Requires at least: 4.7.16 9 9 * Tested up to: 6.3 … … 52 52 53 53 // Set constants 54 $this->define('DHLPWC_PLUGIN_VERSION', '2.1. 5');54 $this->define('DHLPWC_PLUGIN_VERSION', '2.1.6'); 55 55 $this->define('DHLPWC_PLUGIN_FILE', __FILE__); 56 56 $this->define('DHLPWC_PLUGIN_BASENAME', plugin_basename(__FILE__)); -
dhlpwc/trunk/includes/controller/admin/class-dhlpwc-controller-admin-settings.php
r3093985 r3130949 13 13 const NOTICE_TAG_API_SETTINGS = self::NOTICE_TAG_PREFIX . 'api_settings'; 14 14 const NOTICE_TAG_GUTENBERG_BLOCKS = self::NOTICE_TAG_PREFIX . 'gutenberg_blocks'; 15 const NOTICE_TAG_GUTENBERG_BLOCKS_FOREVER = self::NOTICE_TAG_PREFIX . 'gutenberg_blocks_forever'; 15 16 16 17 public function __construct() … … 40 41 41 42 add_action('wp_ajax_dhlpwc_dismiss_admin_notice', array($this, 'dismiss_admin_notice')); 43 add_action('wp_ajax_dhlpwc_dismiss_admin_notice_forever', array($this, 'dismiss_admin_notice_forever')); 42 44 add_action('wp_ajax_dhlpwc_test_connection', array($this, 'test_connection')); 43 45 add_action('wp_ajax_dhlpwc_search_printers', array($this, 'search_printers')); … … 80 82 81 83 // Send JSON response 84 wp_send_json($json_response->to_array(), 200); 85 } 86 87 /** 88 * Used to get all notices allowed for permanent dismissal. 89 * 90 * @return array 91 */ 92 public function foreverTags() 93 { 94 $class = new ReflectionClass(get_called_class()); 95 $constants = $class->getConstants(); 96 97 foreach ($constants as $name => $value) { 98 if (strpos($value, self::NOTICE_TAG_PREFIX) !== 0 || !preg_match('/_FOREVER/', $name)) { 99 unset($constants[$name]); 100 } 101 } 102 103 return $constants; 104 } 105 106 public function dismiss_admin_notice_forever() 107 { 108 $notice_tag_forever = wc_clean($_POST['notice_tag_forever']); 109 110 if(!in_array($notice_tag_forever, $this->foreverTags())) { 111 $json_response = new DHLPWC_Model_Response_JSON(); 112 $json_response->set_error(__('Bad request')); 113 wp_send_json($json_response->to_array(), 400); 114 115 return; 116 } 117 118 update_option(wc_clean($_POST['notice_tag_forever']), true); 119 $json_response = new DHLPWC_Model_Response_JSON(); 82 120 wp_send_json($json_response->to_array(), 200); 83 121 } … … 328 366 $id = get_option('woocommerce_checkout_page_id'); 329 367 $checkoutContent = get_post($id); 330 if ($service->plugin_is_enabled() && strpos($checkoutContent->post_content, 'wp:dhlpwc/dhlpwc-block') === false && strpos($checkoutContent->post_content, 'wp:woocommerce/checkout') !== false) { 368 369 if (!get_site_transient(self::NOTICE_TAG_GUTENBERG_BLOCKS) && 370 !get_option(self::NOTICE_TAG_GUTENBERG_BLOCKS_FOREVER) && 371 $service->plugin_is_enabled() && 372 strpos($checkoutContent->post_content, 'wp:dhlpwc/dhlpwc-block') === false && 373 strpos($checkoutContent->post_content, 'wp:woocommerce/checkout') !== false) { 331 374 $messages[] = sprintf(__('You are currently missing DHL shipping elements in your checkout. You can fix this by simply going to the edit page of your checkout page and hit the update button.')); 332 375 333 $this->show_notice(self::NOTICE_TAG_GUTENBERG_BLOCKS, $messages, admin_url('post.php?post=' . $id . '&action=edit') );334 } 335 } 336 337 public function show_notice($notice_tag, $messages, $admin_link = null )376 $this->show_notice(self::NOTICE_TAG_GUTENBERG_BLOCKS, $messages, admin_url('post.php?post=' . $id . '&action=edit'), self::NOTICE_TAG_GUTENBERG_BLOCKS_FOREVER); 377 } 378 } 379 380 public function show_notice($notice_tag, $messages, $admin_link = null, $notice_tag_forever = null) 338 381 { 339 382 // Add prefix if missing … … 345 388 $view->render(array( 346 389 'notice_tag' => $notice_tag, 390 'notice_tag_forever' => $notice_tag_forever, 347 391 'messages' => $messages, 348 392 'admin_link' => $admin_link, -
dhlpwc/trunk/includes/view/admin/multi-select.php
r2688414 r3130949 1 <?php ?>1 <?php if (!defined('ABSPATH')) { exit; } ?> 2 2 <p class="form-field <?php echo esc_attr($id) ?>_field"> 3 3 <label for="<?php echo esc_attr($id) ?>"></label> -
dhlpwc/trunk/includes/view/admin/notice.php
r2688414 r3130949 39 39 </span> 40 40 <?php endif ?> 41 42 <?php if (!empty($notice_tag_forever)): ?> 43 <br/><br/> 44 <a href="#" id="dhlpwc-dismiss-notice-forever" data-notice_tag_forever="<?php echo esc_attr($notice_tag_forever)?>"> 45 <b><?php _e('Click here to never show this again', 'dhlpwc') ?></b> 46 </a> 47 <?php endif ?> 41 48 </p> 42 49 </div> -
dhlpwc/trunk/readme.txt
r3123181 r3130949 5 5 Requires PHP: 5.6 6 6 Tested up to: 6.6.0 7 Stable tag: 2.1. 57 Stable tag: 2.1.6 8 8 WC requires at least: 3.0.0 9 9 WC tested up to: 9.0.2 … … 56 56 57 57 == Changelog == 58 59 = 2.1.6 = 60 - Added a button to dismiss the Gutenberg block notification forever 58 61 59 62 = 2.1.5 =
Note: See TracChangeset
for help on using the changeset viewer.