Plugin Directory

Changeset 2690633


Ignore:
Timestamp:
03/08/2022 08:49:35 AM (4 years ago)
Author:
avitrop
Message:

Update to version 2.0.9 from GitHub

Location:
storeman
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • storeman/tags/2.0.9/README.txt

    r2680802 r2690633  
    44Requires at lest: 3.0.1
    55Tested up to: 5.9
    6 Stable tag: 2.0.8
     6Stable tag: 2.0.9
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3333
    3434== Changelog ==
     35= 2.0.9 =
     36* prevent topic variation updating while not from storeman and or not current element id.
    3537= 2.0.7 =
    3638* prevent topic variation updating while rest.
  • storeman/tags/2.0.9/admin/class-storeman-admin.php

    r2680802 r2690633  
    4545    private $removeTopic;
    4646
     47
     48    private $removeElementId;
     49
     50
    4751    /**
    4852     * Initialize the class and set its properties.
     
    113117        return 10000;
    114118    }
    115     public function woocommerce_webhook_status($status, $id)
    116     {
    117         $webhook = new \WC_Webhook($id);
     119    public function woocommerce_webhook_status($status, $webhook, $id)
     120    {
     121        // $webhook = new \WC_Webhook($id);
    118122        if (
    119123            in_array($webhook->get_topic(), $this->removeTopic)
     
    124128                strpos($webhook->get_delivery_url(), 'stores.com') !== false
    125129                ||
    126                 strpos($webhook->get_delivery_url(), 'sharpen') !== false
     130                strpos($webhook->get_delivery_url(), 'crm.sharpen') !== false
    127131                )
    128                
     132                && $this->removeElementId === $id
    129133        ) {
    130             return "disabled";
     134            return false;
    131135        }
    132136        return $status;
    133137    }
     138    protected function checkFromStoreman($request)
     139    {
     140        $h = $request->get_header('user_agent');
     141        // return true;
     142        return strpos($request->get_header('user_agent'), 'StoreMan') !== false;
     143    }
    134144    public function remove_order_webhook_action($object)
    135145    {
    136         $this->removeTopic = ['order.updated','order.created'];
    137         // remove_action( 'shutdown', 'wc_webhook_execute_queue' );
     146        if ($this->checkFromStoreman($request)) {
     147            $this->removeTopic = ['order.updated','order.created'];
     148            $this->removeElementId = $object->get_id();
     149        }
    138150        return $object;
    139151    }
    140     public function remove_product_webhook_action($object)
    141     {
    142         $this->removeTopic = ['product.updated','product.created'
    143         // ,'product.update_variation'
    144         ];
     152    public function remove_product_webhook_action($object, $request)
     153    {
     154        if ($this->checkFromStoreman($request)) {
     155            $this->removeTopic = ['product.updated','product.created'
     156                // ,'product.update_variation'
     157                ];
     158            $this->removeElementId = $object->get_id();
     159        }
     160
    145161        return $object;
    146162    }
     
    247263        do_action('update_variation_hook', $order_id, $posted_data, $order);
    248264    }
    249     public function action_woocommerce_update_product_variation( $id)
    250     {
    251         $product = wc_get_product($id);
    252         do_action('update_variation_hook',$id,[],$product);
    253 
    254     }
     265    public function action_woocommerce_update_product_variation($id)
     266    {
     267        $product = wc_get_product($id);
     268        do_action('update_variation_hook', $id, [], $product);
     269    }
    255270    public function add_new_topic_hooks($topic_hooks)
    256271    {
  • storeman/tags/2.0.9/includes/class-storeman.php

    r2678446 r2690633  
    171171        $this->loader->add_action( 'woocommerce_rest_pre_insert_product_variation_object', $plugin_admin, 'fix_hebrew_taxonomy_bug' , 10 ,2);
    172172        $this->loader->add_filter( 'woocommerce_rest_batch_items_limit', $plugin_admin, 'set_limit_to_very_very_math' );
    173         $this->loader->add_filter( 'woocommerce_webhook_status', $plugin_admin, 'woocommerce_webhook_status',1,2 );
     173        $this->loader->add_filter( 'woocommerce_webhook_should_deliver', $plugin_admin, 'woocommerce_webhook_status',1,3 );
    174174
    175175        $this->loader->add_action( 'save_post_product', $plugin_admin, 'polylang_add_product_lang_to_meta',1,2 );
     
    181181        $this->loader->add_filter( 'rest_product_variation_collection_params',$plugin_admin, 'fix_bath_pp' );
    182182        foreach ($post_types as $post_type) {
    183             $this->loader->add_action("woocommerce_rest_pre_insert_{$post_type}_object", $plugin_admin, 'remove_product_webhook_action',1,1);
    184             $this->loader->add_action("woocommerce_rest_insert_{$post_type}_object", $plugin_admin, 'remove_product_webhook_action',999,1);
     183            $this->loader->add_action("woocommerce_rest_pre_insert_{$post_type}_object", $plugin_admin, 'remove_product_webhook_action',1,3);
     184            $this->loader->add_action("woocommerce_rest_insert_{$post_type}_object", $plugin_admin, 'remove_product_webhook_action',999,3);
    185185        }
    186186
  • storeman/tags/2.0.9/storeman.php

    r2680802 r2690633  
    1717 * Plugin URI:        https://storeman.co.il
    1818 * Description:       add storeman to your WordPress site.
    19  * Version:           2.0.8
     19 * Version:           2.0.9
    2020 * Author:            avitrop
    2121 * Author URI:        https://profiles.wordpress.org/avitrop/
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'STOREMAN_VERSION', '2.0.8' );
     38define( 'STOREMAN_VERSION', '2.0.9' );
    3939
    4040/**
  • storeman/trunk/README.txt

    r2680802 r2690633  
    44Requires at lest: 3.0.1
    55Tested up to: 5.9
    6 Stable tag: 2.0.8
     6Stable tag: 2.0.9
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3333
    3434== Changelog ==
     35= 2.0.9 =
     36* prevent topic variation updating while not from storeman and or not current element id.
    3537= 2.0.7 =
    3638* prevent topic variation updating while rest.
  • storeman/trunk/admin/class-storeman-admin.php

    r2680802 r2690633  
    4545    private $removeTopic;
    4646
     47
     48    private $removeElementId;
     49
     50
    4751    /**
    4852     * Initialize the class and set its properties.
     
    113117        return 10000;
    114118    }
    115     public function woocommerce_webhook_status($status, $id)
    116     {
    117         $webhook = new \WC_Webhook($id);
     119    public function woocommerce_webhook_status($status, $webhook, $id)
     120    {
     121        // $webhook = new \WC_Webhook($id);
    118122        if (
    119123            in_array($webhook->get_topic(), $this->removeTopic)
     
    124128                strpos($webhook->get_delivery_url(), 'stores.com') !== false
    125129                ||
    126                 strpos($webhook->get_delivery_url(), 'sharpen') !== false
     130                strpos($webhook->get_delivery_url(), 'crm.sharpen') !== false
    127131                )
    128                
     132                && $this->removeElementId === $id
    129133        ) {
    130             return "disabled";
     134            return false;
    131135        }
    132136        return $status;
    133137    }
     138    protected function checkFromStoreman($request)
     139    {
     140        $h = $request->get_header('user_agent');
     141        // return true;
     142        return strpos($request->get_header('user_agent'), 'StoreMan') !== false;
     143    }
    134144    public function remove_order_webhook_action($object)
    135145    {
    136         $this->removeTopic = ['order.updated','order.created'];
    137         // remove_action( 'shutdown', 'wc_webhook_execute_queue' );
     146        if ($this->checkFromStoreman($request)) {
     147            $this->removeTopic = ['order.updated','order.created'];
     148            $this->removeElementId = $object->get_id();
     149        }
    138150        return $object;
    139151    }
    140     public function remove_product_webhook_action($object)
    141     {
    142         $this->removeTopic = ['product.updated','product.created'
    143         // ,'product.update_variation'
    144         ];
     152    public function remove_product_webhook_action($object, $request)
     153    {
     154        if ($this->checkFromStoreman($request)) {
     155            $this->removeTopic = ['product.updated','product.created'
     156                // ,'product.update_variation'
     157                ];
     158            $this->removeElementId = $object->get_id();
     159        }
     160
    145161        return $object;
    146162    }
     
    247263        do_action('update_variation_hook', $order_id, $posted_data, $order);
    248264    }
    249     public function action_woocommerce_update_product_variation( $id)
    250     {
    251         $product = wc_get_product($id);
    252         do_action('update_variation_hook',$id,[],$product);
    253 
    254     }
     265    public function action_woocommerce_update_product_variation($id)
     266    {
     267        $product = wc_get_product($id);
     268        do_action('update_variation_hook', $id, [], $product);
     269    }
    255270    public function add_new_topic_hooks($topic_hooks)
    256271    {
  • storeman/trunk/includes/class-storeman.php

    r2678446 r2690633  
    171171        $this->loader->add_action( 'woocommerce_rest_pre_insert_product_variation_object', $plugin_admin, 'fix_hebrew_taxonomy_bug' , 10 ,2);
    172172        $this->loader->add_filter( 'woocommerce_rest_batch_items_limit', $plugin_admin, 'set_limit_to_very_very_math' );
    173         $this->loader->add_filter( 'woocommerce_webhook_status', $plugin_admin, 'woocommerce_webhook_status',1,2 );
     173        $this->loader->add_filter( 'woocommerce_webhook_should_deliver', $plugin_admin, 'woocommerce_webhook_status',1,3 );
    174174
    175175        $this->loader->add_action( 'save_post_product', $plugin_admin, 'polylang_add_product_lang_to_meta',1,2 );
     
    181181        $this->loader->add_filter( 'rest_product_variation_collection_params',$plugin_admin, 'fix_bath_pp' );
    182182        foreach ($post_types as $post_type) {
    183             $this->loader->add_action("woocommerce_rest_pre_insert_{$post_type}_object", $plugin_admin, 'remove_product_webhook_action',1,1);
    184             $this->loader->add_action("woocommerce_rest_insert_{$post_type}_object", $plugin_admin, 'remove_product_webhook_action',999,1);
     183            $this->loader->add_action("woocommerce_rest_pre_insert_{$post_type}_object", $plugin_admin, 'remove_product_webhook_action',1,3);
     184            $this->loader->add_action("woocommerce_rest_insert_{$post_type}_object", $plugin_admin, 'remove_product_webhook_action',999,3);
    185185        }
    186186
  • storeman/trunk/storeman.php

    r2680802 r2690633  
    1717 * Plugin URI:        https://storeman.co.il
    1818 * Description:       add storeman to your WordPress site.
    19  * Version:           2.0.8
     19 * Version:           2.0.9
    2020 * Author:            avitrop
    2121 * Author URI:        https://profiles.wordpress.org/avitrop/
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'STOREMAN_VERSION', '2.0.8' );
     38define( 'STOREMAN_VERSION', '2.0.9' );
    3939
    4040/**
Note: See TracChangeset for help on using the changeset viewer.