Plugin Directory

Changeset 3158764


Ignore:
Timestamp:
09/27/2024 12:24:26 PM (18 months ago)
Author:
tabbyai
Message:

Tagging version 5.0.9

Location:
tabby-checkout
Files:
6 edited
34 copied

Legend:

Unmodified
Added
Removed
  • tabby-checkout/tags/5.0.9/includes/class-wc-tabby-api-feed.php

    r3157667 r3158764  
    55    const TABBY_CHECKOUT_FEED_TOKEN_OPTION = 'tabby_checkout_feed_token';
    66    const TABBY_CHECKOUT_FEED_CRED_OPTION = 'tabby_checkout_feed_cred';
     7    const TABBY_CHECKOUT_FEED_REG_ATTEMPT = 'tabby_checkout_feed_reg_attempt';
    78
    89    public static function isRegistered() {
     
    1819        delete_option(self::TABBY_CHECKOUT_FEED_TOKEN_OPTION);
    1920        delete_option(self::TABBY_CHECKOUT_FEED_CRED_OPTION);
     21        delete_option(self::TABBY_CHECKOUT_FEED_REG_ATTEMPT);
    2022
    2123        return true;
     
    2628
    2729        // check if there is previous registration attempt
    28         $reg_tr = "tabby_feed_reg_attempt";
    29         if (get_transient($reg_tr) !== false) {
     30        $reg_attempt_name = self::TABBY_CHECKOUT_FEED_REG_ATTEMPT;
     31        if (time() < (int)get_option($reg_attempt_name, 0)) {
    3032            // bypass request
    3133            return false;
     
    4446        } else {
    4547            // registration failed - set transient to 4 hours
    46             set_transient($reg_tr, true, 4 * HOUR_IN_SECONDS);
     48            update_option($reg_attempt_name, time() + 4 * HOUR_IN_SECONDS);
    4749
    4850            // log site logo for failed registrations
  • tabby-checkout/tags/5.0.9/includes/class-wc-tabby-api.php

    r3157667 r3158764  
    99        }
    1010        return true;
     11    }
     12
     13    public static function isSecretKeyProduction() {
     14        $secret_key = self::get_api_option('secret_key', "");
     15        return preg_match("#^sk_[\da-f]{8}\-[\da-f]{4}\-[\da-f]{4}\-[\da-f]{4}\-[\da-f]{12}$#", $secret_key);
    1116    }
    1217
  • tabby-checkout/tags/5.0.9/includes/class-wc-tabby-feed-product.php

    r3157667 r3158764  
    4141            if (is_null($image)) unset($data['images'][$index]);
    4242        }
    43 
     43        // images and price check
    4444        if (empty($data['images']) || empty($data['price'])) {
    4545            throw new \WC_Tabby_Feed_Product_Exception('No images for product');
     
    4848        if (!empty($data['salePrice'])) {
    4949            $data['salePrice'] = get_woocommerce_currency() . ' ' . $data['salePrice'];
     50        }
     51        // empty categories array
     52        if (empty($data[$tabby_lang]['categories'])) {
     53            throw new \WC_Tabby_Feed_Product_Exception('No categories for product');
     54        }
     55        // check for empty attributes values
     56        foreach ($data[$tabby_lang]['attributes'] as $index => $attribute) {
     57            if (empty($attribute['values'])) {
     58                throw new \WC_Tabby_Feed_Product_Exception('Empty values array for attribute');
     59            }
    5060        }
    5161        return $data;
     
    8292    public static function getTabbyCategoryPath($product) {
    8393        $categories = [];
    84         foreach (get_the_terms($product->get_id(), 'product_cat') as $term) {
    85             $categories[] = [
    86                 'path'          => self::getCategoryPath($term),
    87                 // Tabby category ID, may be later add categories mapping
    88                 //'categoryId'    => (string)$term->term_id
    89             ];
     94        $terms = get_the_terms($product->get_id(), 'product_cat');
     95        if (is_array($terms)) {
     96            foreach ($terms as $term) {
     97                $categories[] = [
     98                    'path'  => self::getCategoryPath($term)
     99                ];
     100            }
     101        }
     102        if (empty($categories)) {
     103            $categories[] = ['path' => ['Uncategorized']];
    90104        }
    91105        return $categories;
     
    105119        foreach ($product->get_attributes() as $code => $attribute) {
    106120            if (is_object($attribute)) {
    107                 $result[] = [
    108                     'name'      => $attribute->get_name(),
    109                     'values'    => array_map(function ($item) {return (string)$item;}, array_values($attribute->get_options()))
    110                 ];
     121                $values = array_map(function ($item) {return (string)$item;}, array_values($attribute->get_options()));
     122                if (!empty($values)) {
     123                    $result[] = [
     124                        'name'      => $attribute->get_name(),
     125                        'values'    => $values
     126                    ];
     127                }
    111128            } else {
    112129                $result[] = [
  • tabby-checkout/tags/5.0.9/includes/class-wc-tabby-feed-sharing.php

    r3157667 r3158764  
    99
    1010    public static function init() {
     11        if (!WC_Tabby_Api::isSecretKeyProduction()) return false;
    1112        add_filter( 'cron_schedules', array(__CLASS__, 'add_every_five_minutes') );
    1213        add_action(self::CRON_JOB_NAME, array(__CLASS__, 'cron_service'));
  • tabby-checkout/tags/5.0.9/readme.txt

    r3157668 r3158764  
    44Requires at least: 5.7
    55Tested up to: 6.5
    6 Stable tag: 5.0.8
     6Stable tag: 5.0.9
    77Requires PHP: 7.0
    88License: GPLv3
     
    2929== Changelog ==
    3030
    31 = 5.0.8 =
     31= 5.0.9 =
    3232
    3333* Minor fixes
  • tabby-checkout/tags/5.0.9/tabby-checkout.php

    r3157667 r3158764  
    44 * Plugin URI: https://tabby.ai/
    55 * Description: Tabby Checkout
    6  * Version: 5.0.8
     6 * Version: 5.0.9
    77 * Author: Tabby
    88 * Author URI: https://tabby.ai
     
    1414defined( 'ABSPATH' ) || exit;
    1515
    16 define ('MODULE_TABBY_CHECKOUT_VERSION', '5.0.8');
     16define ('MODULE_TABBY_CHECKOUT_VERSION', '5.0.9');
    1717define ('TABBY_CHECKOUT_DOMAIN', 'checkout.tabby.ai');
    1818define ('TABBY_CHECKOUT_API_DOMAIN', 'api.tabby.ai');
  • tabby-checkout/trunk/includes/class-wc-tabby-api-feed.php

    r3157667 r3158764  
    55    const TABBY_CHECKOUT_FEED_TOKEN_OPTION = 'tabby_checkout_feed_token';
    66    const TABBY_CHECKOUT_FEED_CRED_OPTION = 'tabby_checkout_feed_cred';
     7    const TABBY_CHECKOUT_FEED_REG_ATTEMPT = 'tabby_checkout_feed_reg_attempt';
    78
    89    public static function isRegistered() {
     
    1819        delete_option(self::TABBY_CHECKOUT_FEED_TOKEN_OPTION);
    1920        delete_option(self::TABBY_CHECKOUT_FEED_CRED_OPTION);
     21        delete_option(self::TABBY_CHECKOUT_FEED_REG_ATTEMPT);
    2022
    2123        return true;
     
    2628
    2729        // check if there is previous registration attempt
    28         $reg_tr = "tabby_feed_reg_attempt";
    29         if (get_transient($reg_tr) !== false) {
     30        $reg_attempt_name = self::TABBY_CHECKOUT_FEED_REG_ATTEMPT;
     31        if (time() < (int)get_option($reg_attempt_name, 0)) {
    3032            // bypass request
    3133            return false;
     
    4446        } else {
    4547            // registration failed - set transient to 4 hours
    46             set_transient($reg_tr, true, 4 * HOUR_IN_SECONDS);
     48            update_option($reg_attempt_name, time() + 4 * HOUR_IN_SECONDS);
    4749
    4850            // log site logo for failed registrations
  • tabby-checkout/trunk/includes/class-wc-tabby-api.php

    r3157667 r3158764  
    99        }
    1010        return true;
     11    }
     12
     13    public static function isSecretKeyProduction() {
     14        $secret_key = self::get_api_option('secret_key', "");
     15        return preg_match("#^sk_[\da-f]{8}\-[\da-f]{4}\-[\da-f]{4}\-[\da-f]{4}\-[\da-f]{12}$#", $secret_key);
    1116    }
    1217
  • tabby-checkout/trunk/includes/class-wc-tabby-feed-product.php

    r3157667 r3158764  
    4141            if (is_null($image)) unset($data['images'][$index]);
    4242        }
    43 
     43        // images and price check
    4444        if (empty($data['images']) || empty($data['price'])) {
    4545            throw new \WC_Tabby_Feed_Product_Exception('No images for product');
     
    4848        if (!empty($data['salePrice'])) {
    4949            $data['salePrice'] = get_woocommerce_currency() . ' ' . $data['salePrice'];
     50        }
     51        // empty categories array
     52        if (empty($data[$tabby_lang]['categories'])) {
     53            throw new \WC_Tabby_Feed_Product_Exception('No categories for product');
     54        }
     55        // check for empty attributes values
     56        foreach ($data[$tabby_lang]['attributes'] as $index => $attribute) {
     57            if (empty($attribute['values'])) {
     58                throw new \WC_Tabby_Feed_Product_Exception('Empty values array for attribute');
     59            }
    5060        }
    5161        return $data;
     
    8292    public static function getTabbyCategoryPath($product) {
    8393        $categories = [];
    84         foreach (get_the_terms($product->get_id(), 'product_cat') as $term) {
    85             $categories[] = [
    86                 'path'          => self::getCategoryPath($term),
    87                 // Tabby category ID, may be later add categories mapping
    88                 //'categoryId'    => (string)$term->term_id
    89             ];
     94        $terms = get_the_terms($product->get_id(), 'product_cat');
     95        if (is_array($terms)) {
     96            foreach ($terms as $term) {
     97                $categories[] = [
     98                    'path'  => self::getCategoryPath($term)
     99                ];
     100            }
     101        }
     102        if (empty($categories)) {
     103            $categories[] = ['path' => ['Uncategorized']];
    90104        }
    91105        return $categories;
     
    105119        foreach ($product->get_attributes() as $code => $attribute) {
    106120            if (is_object($attribute)) {
    107                 $result[] = [
    108                     'name'      => $attribute->get_name(),
    109                     'values'    => array_map(function ($item) {return (string)$item;}, array_values($attribute->get_options()))
    110                 ];
     121                $values = array_map(function ($item) {return (string)$item;}, array_values($attribute->get_options()));
     122                if (!empty($values)) {
     123                    $result[] = [
     124                        'name'      => $attribute->get_name(),
     125                        'values'    => $values
     126                    ];
     127                }
    111128            } else {
    112129                $result[] = [
  • tabby-checkout/trunk/includes/class-wc-tabby-feed-sharing.php

    r3157667 r3158764  
    99
    1010    public static function init() {
     11        if (!WC_Tabby_Api::isSecretKeyProduction()) return false;
    1112        add_filter( 'cron_schedules', array(__CLASS__, 'add_every_five_minutes') );
    1213        add_action(self::CRON_JOB_NAME, array(__CLASS__, 'cron_service'));
  • tabby-checkout/trunk/readme.txt

    r3157668 r3158764  
    44Requires at least: 5.7
    55Tested up to: 6.5
    6 Stable tag: 5.0.8
     6Stable tag: 5.0.9
    77Requires PHP: 7.0
    88License: GPLv3
     
    2929== Changelog ==
    3030
    31 = 5.0.8 =
     31= 5.0.9 =
    3232
    3333* Minor fixes
  • tabby-checkout/trunk/tabby-checkout.php

    r3157667 r3158764  
    44 * Plugin URI: https://tabby.ai/
    55 * Description: Tabby Checkout
    6  * Version: 5.0.8
     6 * Version: 5.0.9
    77 * Author: Tabby
    88 * Author URI: https://tabby.ai
     
    1414defined( 'ABSPATH' ) || exit;
    1515
    16 define ('MODULE_TABBY_CHECKOUT_VERSION', '5.0.8');
     16define ('MODULE_TABBY_CHECKOUT_VERSION', '5.0.9');
    1717define ('TABBY_CHECKOUT_DOMAIN', 'checkout.tabby.ai');
    1818define ('TABBY_CHECKOUT_API_DOMAIN', 'api.tabby.ai');
Note: See TracChangeset for help on using the changeset viewer.