Plugin Directory

Changeset 3130949


Ignore:
Timestamp:
08/05/2024 10:30:00 AM (20 months ago)
Author:
shindhl
Message:

Release 2.1.6

  • Added a button to dismiss the Gutenberg block notification forever
Location:
dhlpwc
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • dhlpwc/tags/2.1.6/README.md

    r3123181 r3130949  
    11# DHL eCommerce (Benelux) for WooCommerce
     2 
     3v2.1.6
     4## Changes
     5- Added a button to dismiss the Gutenberg block notification forever
    26 
    37v2.1.5
  • dhlpwc/tags/2.1.6/assets/js/dhlpwc.notices.js

    r2688414 r3130949  
    1212
    1313        $.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
    1426    });
    1527
  • dhlpwc/tags/2.1.6/dhlpwoocommerce.php

    r3123181 r3130949  
    55 * Description:          This is the official DHL eCommerce (Benelux) for WooCommerce plugin.
    66 * Author:               DHL eCommerce
    7  * Version:              2.1.5
     7 * Version:              2.1.6
    88 * Requires at least:    4.7.16
    99 * Tested up to:         6.3
     
    5252
    5353        // Set constants
    54         $this->define('DHLPWC_PLUGIN_VERSION', '2.1.5');
     54        $this->define('DHLPWC_PLUGIN_VERSION', '2.1.6');
    5555        $this->define('DHLPWC_PLUGIN_FILE', __FILE__);
    5656        $this->define('DHLPWC_PLUGIN_BASENAME', plugin_basename(__FILE__));
  • dhlpwc/tags/2.1.6/includes/controller/admin/class-dhlpwc-controller-admin-settings.php

    r3093985 r3130949  
    1313    const NOTICE_TAG_API_SETTINGS = self::NOTICE_TAG_PREFIX . 'api_settings';
    1414    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';
    1516
    1617    public function __construct()
     
    4041
    4142        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'));
    4244        add_action('wp_ajax_dhlpwc_test_connection', array($this, 'test_connection'));
    4345        add_action('wp_ajax_dhlpwc_search_printers', array($this, 'search_printers'));
     
    8082
    8183        // 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();
    82120        wp_send_json($json_response->to_array(), 200);
    83121    }
     
    328366        $id = get_option('woocommerce_checkout_page_id');
    329367        $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) {
    331374            $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.'));
    332375
    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)
    338381    {
    339382        // Add prefix if missing
     
    345388        $view->render(array(
    346389            'notice_tag' => $notice_tag,
     390            'notice_tag_forever' => $notice_tag_forever,
    347391            'messages'   => $messages,
    348392            '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; } ?>
    22<p class="form-field <?php echo esc_attr($id) ?>_field">
    33    <label for="<?php echo esc_attr($id) ?>"></label>
  • dhlpwc/tags/2.1.6/includes/view/admin/notice.php

    r2688414 r3130949  
    3939        </span>
    4040        <?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 ?>
    4148    </p>
    4249</div>
  • dhlpwc/tags/2.1.6/readme.txt

    r3123181 r3130949  
    55Requires PHP:         5.6
    66Tested up to:         6.6.0
    7 Stable tag:           2.1.5
     7Stable tag:           2.1.6
    88WC requires at least: 3.0.0
    99WC tested up to:      9.0.2
     
    5656
    5757== Changelog ==
     58 
     59= 2.1.6 =
     60- Added a button to dismiss the Gutenberg block notification forever
    5861 
    5962= 2.1.5 =
  • dhlpwc/trunk/README.md

    r3123181 r3130949  
    11# DHL eCommerce (Benelux) for WooCommerce
     2 
     3v2.1.6
     4## Changes
     5- Added a button to dismiss the Gutenberg block notification forever
    26 
    37v2.1.5
  • dhlpwc/trunk/assets/js/dhlpwc.notices.js

    r2688414 r3130949  
    1212
    1313        $.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
    1426    });
    1527
  • dhlpwc/trunk/dhlpwoocommerce.php

    r3123181 r3130949  
    55 * Description:          This is the official DHL eCommerce (Benelux) for WooCommerce plugin.
    66 * Author:               DHL eCommerce
    7  * Version:              2.1.5
     7 * Version:              2.1.6
    88 * Requires at least:    4.7.16
    99 * Tested up to:         6.3
     
    5252
    5353        // Set constants
    54         $this->define('DHLPWC_PLUGIN_VERSION', '2.1.5');
     54        $this->define('DHLPWC_PLUGIN_VERSION', '2.1.6');
    5555        $this->define('DHLPWC_PLUGIN_FILE', __FILE__);
    5656        $this->define('DHLPWC_PLUGIN_BASENAME', plugin_basename(__FILE__));
  • dhlpwc/trunk/includes/controller/admin/class-dhlpwc-controller-admin-settings.php

    r3093985 r3130949  
    1313    const NOTICE_TAG_API_SETTINGS = self::NOTICE_TAG_PREFIX . 'api_settings';
    1414    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';
    1516
    1617    public function __construct()
     
    4041
    4142        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'));
    4244        add_action('wp_ajax_dhlpwc_test_connection', array($this, 'test_connection'));
    4345        add_action('wp_ajax_dhlpwc_search_printers', array($this, 'search_printers'));
     
    8082
    8183        // 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();
    82120        wp_send_json($json_response->to_array(), 200);
    83121    }
     
    328366        $id = get_option('woocommerce_checkout_page_id');
    329367        $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) {
    331374            $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.'));
    332375
    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)
    338381    {
    339382        // Add prefix if missing
     
    345388        $view->render(array(
    346389            'notice_tag' => $notice_tag,
     390            'notice_tag_forever' => $notice_tag_forever,
    347391            'messages'   => $messages,
    348392            'admin_link' => $admin_link,
  • dhlpwc/trunk/includes/view/admin/multi-select.php

    r2688414 r3130949  
    1 <?php ?>
     1<?php if (!defined('ABSPATH')) { exit; } ?>
    22<p class="form-field <?php echo esc_attr($id) ?>_field">
    33    <label for="<?php echo esc_attr($id) ?>"></label>
  • dhlpwc/trunk/includes/view/admin/notice.php

    r2688414 r3130949  
    3939        </span>
    4040        <?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 ?>
    4148    </p>
    4249</div>
  • dhlpwc/trunk/readme.txt

    r3123181 r3130949  
    55Requires PHP:         5.6
    66Tested up to:         6.6.0
    7 Stable tag:           2.1.5
     7Stable tag:           2.1.6
    88WC requires at least: 3.0.0
    99WC tested up to:      9.0.2
     
    5656
    5757== Changelog ==
     58 
     59= 2.1.6 =
     60- Added a button to dismiss the Gutenberg block notification forever
    5861 
    5962= 2.1.5 =
Note: See TracChangeset for help on using the changeset viewer.