Plugin Directory

Changeset 2951571


Ignore:
Timestamp:
08/10/2023 01:56:13 PM (2 years ago)
Author:
sitewit
Message:

Release version 1.3.0

  • Added hook for declaring compatibility with HPOS
  • Fix REST endpoints date range issues
  • Use WooCommerce REST v3, and increase minimum version of WooCommerce required to 5.5 which is released 2 years ago. Previously we required 3.0 which was released back in 2017.
  • Test compatibility with WooCommerce 8.0 just released
Location:
kliken-marketing-for-google
Files:
63 added
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • kliken-marketing-for-google/trunk/changelog.txt

    r2949566 r2951571  
    11*** AI Powered Marketing Changelog ***
     2
     32023-08-08 - version 1.3.0
     4* Enable WooCommerce HPOS compatibility.
     5* Fix REST endpoints date range issues.
     6* Use WooCommerce REST v3.
    27
    382023-08-04 - version 1.2.1
  • kliken-marketing-for-google/trunk/classes/class-plugin.php

    r2949566 r2951571  
    5353
    5454            if ( $this->_bootstrapped ) {
    55                 throw new \Exception( sprintf( 
     55                throw new \Exception( sprintf(
    5656                        /* translators: %s: Plugin name. Do not translate. */
    57                         __( '%s plugin can only be called once.', 'kliken-marketing-for-google' ), 
    58                         __( 'AI Powered Marketing' ) 
     57                        __( '%s plugin can only be called once.', 'kliken-marketing-for-google' ),
     58                        __( 'AI Powered Marketing' )
    5959                    ),
    60                     self::ALREADY_BOOTSTRAPED 
     60                    self::ALREADY_BOOTSTRAPED
    6161                );
    6262            }
     
    277277    private function check_dependencies() {
    278278        if ( ! function_exists( 'wc' ) ) {
    279             throw new \Exception( sprintf( 
     279            throw new \Exception( sprintf(
    280280                    /* translators: %s: Plugin name. Do not translate. */
    281                     __( '%s requires WooCommerce to be activated.', 'kliken-marketing-for-google' ), 
     281                    __( '%s requires WooCommerce to be activated.', 'kliken-marketing-for-google' ),
    282282                    __( 'AI Powered Marketing' )
    283283                ),
     
    286286        }
    287287
    288         $required_woo_version = '3.0';
     288        $required_woo_version = '5.5';
    289289        if ( version_compare( wc()->version, $required_woo_version, '<' ) ) {
    290290            throw new \Exception( sprintf(
    291291                    /* translators: %s: Plugin name. %s: Version number of WooCommerce required to run plugin. Do not translate. */
    292                     __( '%s requires WooCommerce version %s or greater.', 'kliken-marketing-for-google' ), 
     292                    __( '%s requires WooCommerce version %s or greater.', 'kliken-marketing-for-google' ),
    293293                    __( 'AI Powered Marketing' ),
    294                     $required_woo_version 
     294                    $required_woo_version
    295295                ),
    296296                self::DEPENDENCIES_UNSATISFIED
     
    309309        add_action( 'admin_notices', [ $this, 'show_onboarding_message' ] );
    310310
     311        // Declare compatibility with HPOS.
     312        add_action( 'before_woocommerce_init', function() {
     313            if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
     314                \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', KK_WC_PLUGIN_FILE, true );
     315            }
     316        } );
     317
    311318        // Additional admin actions registered for handling requests.
    312319        if ( is_admin() ) {
  • kliken-marketing-for-google/trunk/classes/class-rest-orders-controller.php

    r2261878 r2951571  
    1414 * REST API Orders controller class.
    1515 *
    16  * @extends WC_REST_Orders_Controller
     16 * @extends \WC_REST_Orders_Controller
    1717 */
    18 class REST_Orders_Controller extends WC_REST_Orders_Controller_Compat {
     18class REST_Orders_Controller extends \WC_REST_Orders_Controller {
    1919    /**
    2020     * Endpoint namespace.
     
    3434                    'callback'            => [ $this, 'get_items' ],
    3535                    'permission_callback' => [ $this, 'get_items_permissions_check' ],
     36                    'args'                => $this->get_collection_params(),
    3637                ],
    3738            ]
     
    4748     */
    4849    protected function prepare_objects_query( $request ) {
    49         // To fix some notice messages in header of REST response
    50         if ( empty( $request['page'] ) ) {
    51             $request['page'] = 1;
    52         }
    53 
    54         if ( empty( $request['orderby'] ) ) {
    55             $request['orderby'] = 'modified';
    56         }
    57 
    58         if ( empty( $request['status'] ) ) {
    59             $request['status'] = 'any';
    60         }
    61 
    6250        $args = parent::prepare_objects_query( $request );
    6351
    6452        // Reset the date query to look up post_modified column instead.
    6553        if ( ! empty( $args['date_query'] ) ) {
    66             $args['date_query'][0]['column'] = 'post_modified';
     54            foreach ( $args['date_query'] as $key => $query ) {
     55                if ( ! isset( $args['date_query'][$key]['column'] ) ) continue;
     56
     57                $args['date_query'][$key]['column'] = $request['dates_are_gmt']
     58                    ? 'post_modified_gmt'
     59                    : 'post_modified';
     60            }
    6761        }
    6862
  • kliken-marketing-for-google/trunk/classes/class-rest-products-controller.php

    r2261878 r2951571  
    1414 * REST API Products controller class.
    1515 *
    16  * @extends WC_REST_Products_Controller_Compat
     16 * @extends \WC_REST_Products_Controller
    1717 */
    18 class REST_Products_Controller extends WC_REST_Products_Controller_Compat {
     18class REST_Products_Controller extends \WC_REST_Products_Controller {
    1919    /**
    2020     * Endpoint namespace.
     
    3434                    'callback'            => [ $this, 'get_items' ],
    3535                    'permission_callback' => [ $this, 'get_items_permissions_check' ],
     36                    'args'                => $this->get_collection_params(),
    3637                ],
    3738            ]
     
    5859        $page     = intval( $request['page'] );
    5960        $per_page = intval( $request['per_page'] );
     61        $use_gmt  = $request['dates_are_gmt'];
    6062
    6163        $query_args = [
     
    6668            'paged'               => 0 === $page ? 1 : $page,
    6769            'posts_per_page'      => 0 === $per_page ? 100 : $per_page,
    68             'orderby'             => 'modified',
     70            'orderby'             => 'date ID',
    6971            'order'               => 'ASC',
    7072        ];
    7173
    7274        $query_args['date_query'] = [];
     75
    7376        // Set before into date query. Date query must be specified as an array of an array.
    7477        if ( isset( $request['before'] ) ) {
    75             $query_args['date_query'][0]['column'] = 'post_modified';
    76             $query_args['date_query'][0]['before'] = $request['before'];
     78            $query_args['date_query'][] = [
     79                'column' => $use_gmt ? 'post_modified_gmt' : 'post_modified',
     80                'before' => $request['before'],
     81            ];
    7782        }
    7883
    7984        // Set after into date query. Date query must be specified as an array of an array.
    8085        if ( isset( $request['after'] ) ) {
    81             $query_args['date_query'][0]['column'] = 'post_modified';
    82             $query_args['date_query'][0]['after']  = $request['after'];
     86            $query_args['date_query'][] = [
     87                'column' => $use_gmt ? 'post_modified_gmt' : 'post_modified',
     88                'after'  => $request['after'],
     89            ];
    8390        }
    8491
     
    110117     */
    111118    protected function prepare_objects_query( $request ) {
    112         // To fix some notice messages in header of REST response
    113         if ( empty( $request['page'] ) ) {
    114             $request['page'] = 1;
    115         }
    116 
    117         if ( empty( $request['orderby'] ) ) {
    118             $request['orderby'] = 'modified';
    119         }
    120 
    121119        $args = parent::prepare_objects_query( $request );
    122120
    123121        // Reset the date query to look up post_modified column instead.
    124122        if ( ! empty( $args['date_query'] ) ) {
    125             $args['date_query'][0]['column'] = 'post_modified';
     123            foreach ( $args['date_query'] as $key => $query ) {
     124                if ( ! isset( $args['date_query'][$key]['column'] ) ) continue;
     125
     126                $args['date_query'][$key]['column'] = $request['dates_are_gmt']
     127                    ? 'post_modified_gmt'
     128                    : 'post_modified';
     129            }
    126130        }
    127131
  • kliken-marketing-for-google/trunk/kliken-marketing-for-google.php

    r2949566 r2951571  
    44Plugin URI: https://woo.kliken.com/
    55Description: Kliken's all-in-one marketing platform helps business owners reach high-intent customers, surpass your competition and realize significant growth in sales, while decreasing conversion costs.
    6 Version: 1.2.1
     6Version: 1.3.0
    77Author: Kliken
    88Author URI: http://kliken.com/
     
    1212Domain path: /languages
    1313
    14 WC requires at least: 3.0
    15 WC tested up to: 7.9
     14WC requires at least: 5.5
     15WC tested up to: 8.0
    1616
    1717License: GNU General Public License v3.0
  • kliken-marketing-for-google/trunk/readme.txt

    r2949566 r2951571  
    55Tested up to: 6.3
    66Requires PHP: 5.6
    7 Stable tag: 1.2.1
    8 WC requires at least: 3.0
    9 WC tested up to: 7.9
     7Stable tag: 1.3.0
     8WC requires at least: 5.5
     9WC tested up to: 8.0
    1010License: GPLv3 or later License
    1111URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    139139== Changelog ==
    140140
     141= 1.3.0 =
     142* Enable WooCommerce HPOS compatibility.
     143* Fix REST endpoints date range issues.
     144* Use WooCommerce REST v3.
     145
    141146= 1.2.1 =
    142147* Fix links.
  • kliken-marketing-for-google/trunk/vendor/autoload.php

    r2463804 r2951571  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit3189846b77ba157bf806f2ea8cf80c49::getLoader();
     7return ComposerAutoloaderInitab4d7ed8498b17e5db5a30f4153069b4::getLoader();
  • kliken-marketing-for-google/trunk/vendor/composer/ClassLoader.php

    r2463804 r2951571  
    3838 * @author Fabien Potencier <[email protected]>
    3939 * @author Jordi Boggiano <[email protected]>
    40  * @see    http://www.php-fig.org/psr/psr-0/
    41  * @see    http://www.php-fig.org/psr/psr-4/
     40 * @see    https://www.php-fig.org/psr/psr-0/
     41 * @see    https://www.php-fig.org/psr/psr-4/
    4242 */
    4343class ClassLoader
    4444{
     45    /** @var ?string */
     46    private $vendorDir;
     47
    4548    // PSR-4
     49    /**
     50     * @var array[]
     51     * @psalm-var array<string, array<string, int>>
     52     */
    4653    private $prefixLengthsPsr4 = array();
     54    /**
     55     * @var array[]
     56     * @psalm-var array<string, array<int, string>>
     57     */
    4758    private $prefixDirsPsr4 = array();
     59    /**
     60     * @var array[]
     61     * @psalm-var array<string, string>
     62     */
    4863    private $fallbackDirsPsr4 = array();
    4964
    5065    // PSR-0
     66    /**
     67     * @var array[]
     68     * @psalm-var array<string, array<string, string[]>>
     69     */
    5170    private $prefixesPsr0 = array();
     71    /**
     72     * @var array[]
     73     * @psalm-var array<string, string>
     74     */
    5275    private $fallbackDirsPsr0 = array();
    5376
     77    /** @var bool */
    5478    private $useIncludePath = false;
     79
     80    /**
     81     * @var string[]
     82     * @psalm-var array<string, string>
     83     */
    5584    private $classMap = array();
     85
     86    /** @var bool */
    5687    private $classMapAuthoritative = false;
     88
     89    /**
     90     * @var bool[]
     91     * @psalm-var array<string, bool>
     92     */
    5793    private $missingClasses = array();
     94
     95    /** @var ?string */
    5896    private $apcuPrefix;
    5997
     98    /**
     99     * @var self[]
     100     */
     101    private static $registeredLoaders = array();
     102
     103    /**
     104     * @param ?string $vendorDir
     105     */
     106    public function __construct($vendorDir = null)
     107    {
     108        $this->vendorDir = $vendorDir;
     109    }
     110
     111    /**
     112     * @return string[]
     113     */
    60114    public function getPrefixes()
    61115    {
    62116        if (!empty($this->prefixesPsr0)) {
    63             return call_user_func_array('array_merge', $this->prefixesPsr0);
     117            return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
    64118        }
    65119
     
    67121    }
    68122
     123    /**
     124     * @return array[]
     125     * @psalm-return array<string, array<int, string>>
     126     */
    69127    public function getPrefixesPsr4()
    70128    {
     
    72130    }
    73131
     132    /**
     133     * @return array[]
     134     * @psalm-return array<string, string>
     135     */
    74136    public function getFallbackDirs()
    75137    {
     
    77139    }
    78140
     141    /**
     142     * @return array[]
     143     * @psalm-return array<string, string>
     144     */
    79145    public function getFallbackDirsPsr4()
    80146    {
     
    82148    }
    83149
     150    /**
     151     * @return string[] Array of classname => path
     152     * @psalm-return array<string, string>
     153     */
    84154    public function getClassMap()
    85155    {
     
    88158
    89159    /**
    90      * @param array $classMap Class to filename map
     160     * @param string[] $classMap Class to filename map
     161     * @psalm-param array<string, string> $classMap
     162     *
     163     * @return void
    91164     */
    92165    public function addClassMap(array $classMap)
     
    103176     * appending or prepending to the ones previously set for this prefix.
    104177     *
    105      * @param string       $prefix  The prefix
    106      * @param array|string $paths   The PSR-0 root directories
    107      * @param bool         $prepend Whether to prepend the directories
     178     * @param string          $prefix  The prefix
     179     * @param string[]|string $paths   The PSR-0 root directories
     180     * @param bool            $prepend Whether to prepend the directories
     181     *
     182     * @return void
    108183     */
    109184    public function add($prefix, $paths, $prepend = false)
     
    148223     * appending or prepending to the ones previously set for this namespace.
    149224     *
    150      * @param string       $prefix  The prefix/namespace, with trailing '\\'
    151      * @param array|string $paths   The PSR-4 base directories
    152      * @param bool         $prepend Whether to prepend the directories
     225     * @param string          $prefix  The prefix/namespace, with trailing '\\'
     226     * @param string[]|string $paths   The PSR-4 base directories
     227     * @param bool            $prepend Whether to prepend the directories
    153228     *
    154229     * @throws \InvalidArgumentException
     230     *
     231     * @return void
    155232     */
    156233    public function addPsr4($prefix, $paths, $prepend = false)
     
    196273     * replacing any others previously set for this prefix.
    197274     *
    198      * @param string       $prefix The prefix
    199      * @param array|string $paths  The PSR-0 base directories
     275     * @param string          $prefix The prefix
     276     * @param string[]|string $paths  The PSR-0 base directories
     277     *
     278     * @return void
    200279     */
    201280    public function set($prefix, $paths)
     
    212291     * replacing any others previously set for this namespace.
    213292     *
    214      * @param string       $prefix The prefix/namespace, with trailing '\\'
    215      * @param array|string $paths  The PSR-4 base directories
     293     * @param string          $prefix The prefix/namespace, with trailing '\\'
     294     * @param string[]|string $paths  The PSR-4 base directories
    216295     *
    217296     * @throws \InvalidArgumentException
     297     *
     298     * @return void
    218299     */
    219300    public function setPsr4($prefix, $paths)
     
    235316     *
    236317     * @param bool $useIncludePath
     318     *
     319     * @return void
    237320     */
    238321    public function setUseIncludePath($useIncludePath)
     
    257340     *
    258341     * @param bool $classMapAuthoritative
     342     *
     343     * @return void
    259344     */
    260345    public function setClassMapAuthoritative($classMapAuthoritative)
     
    277362     *
    278363     * @param string|null $apcuPrefix
     364     *
     365     * @return void
    279366     */
    280367    public function setApcuPrefix($apcuPrefix)
    281368    {
    282         $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
     369        $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
    283370    }
    284371
     
    297384     *
    298385     * @param bool $prepend Whether to prepend the autoloader or not
     386     *
     387     * @return void
    299388     */
    300389    public function register($prepend = false)
    301390    {
    302391        spl_autoload_register(array($this, 'loadClass'), true, $prepend);
     392
     393        if (null === $this->vendorDir) {
     394            return;
     395        }
     396
     397        if ($prepend) {
     398            self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
     399        } else {
     400            unset(self::$registeredLoaders[$this->vendorDir]);
     401            self::$registeredLoaders[$this->vendorDir] = $this;
     402        }
    303403    }
    304404
    305405    /**
    306406     * Unregisters this instance as an autoloader.
     407     *
     408     * @return void
    307409     */
    308410    public function unregister()
    309411    {
    310412        spl_autoload_unregister(array($this, 'loadClass'));
     413
     414        if (null !== $this->vendorDir) {
     415            unset(self::$registeredLoaders[$this->vendorDir]);
     416        }
    311417    }
    312418
     
    315421     *
    316422     * @param  string    $class The name of the class
    317      * @return bool|null True if loaded, null otherwise
     423     * @return true|null True if loaded, null otherwise
    318424     */
    319425    public function loadClass($class)
     
    324430            return true;
    325431        }
     432
     433        return null;
    326434    }
    327435
     
    368476    }
    369477
     478    /**
     479     * Returns the currently registered loaders indexed by their corresponding vendor directories.
     480     *
     481     * @return self[]
     482     */
     483    public static function getRegisteredLoaders()
     484    {
     485        return self::$registeredLoaders;
     486    }
     487
     488    /**
     489     * @param  string       $class
     490     * @param  string       $ext
     491     * @return string|false
     492     */
    370493    private function findFileWithExtension($class, $ext)
    371494    {
     
    439562 *
    440563 * Prevents access to $this/self from included files.
     564 *
     565 * @param  string $file
     566 * @return void
     567 * @private
    441568 */
    442569function includeFile($file)
  • kliken-marketing-for-google/trunk/vendor/composer/autoload_classmap.php

    r2261878 r2951571  
    77
    88return array(
     9    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
    910    'Kliken\\WcPlugin\\Helper' => $baseDir . '/classes/class-helper.php',
    1011    'Kliken\\WcPlugin\\Message' => $baseDir . '/classes/class-message.php',
     
    1415    'Kliken\\WcPlugin\\REST_Products_Controller' => $baseDir . '/classes/class-rest-products-controller.php',
    1516    'Kliken\\WcPlugin\\WC_Integration' => $baseDir . '/classes/class-wc-integration.php',
    16     'Kliken\\WcPlugin\\WC_REST_Orders_Controller_Compat' => $baseDir . '/classes/class-wc-rest-orders-controller-compat.php',
    17     'Kliken\\WcPlugin\\WC_REST_Products_Controller_Compat' => $baseDir . '/classes/class-wc-rest-products-controller-compat.php',
    1817);
  • kliken-marketing-for-google/trunk/vendor/composer/autoload_real.php

    r2463804 r2951571  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit3189846b77ba157bf806f2ea8cf80c49
     5class ComposerAutoloaderInitab4d7ed8498b17e5db5a30f4153069b4
    66{
    77    private static $loader;
     
    1414    }
    1515
     16    /**
     17     * @return \Composer\Autoload\ClassLoader
     18     */
    1619    public static function getLoader()
    1720    {
     
    2023        }
    2124
    22         spl_autoload_register(array('ComposerAutoloaderInit3189846b77ba157bf806f2ea8cf80c49', 'loadClassLoader'), true, true);
    23         self::$loader = $loader = new \Composer\Autoload\ClassLoader();
    24         spl_autoload_unregister(array('ComposerAutoloaderInit3189846b77ba157bf806f2ea8cf80c49', 'loadClassLoader'));
     25        require __DIR__ . '/platform_check.php';
     26
     27        spl_autoload_register(array('ComposerAutoloaderInitab4d7ed8498b17e5db5a30f4153069b4', 'loadClassLoader'), true, true);
     28        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitab4d7ed8498b17e5db5a30f4153069b4', 'loadClassLoader'));
    2530
    2631        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
    2732        if ($useStaticLoader) {
    28             require_once __DIR__ . '/autoload_static.php';
     33            require __DIR__ . '/autoload_static.php';
    2934
    30             call_user_func(\Composer\Autoload\ComposerStaticInit3189846b77ba157bf806f2ea8cf80c49::getInitializer($loader));
     35            call_user_func(\Composer\Autoload\ComposerStaticInitab4d7ed8498b17e5db5a30f4153069b4::getInitializer($loader));
    3136        } else {
    3237            $map = require __DIR__ . '/autoload_namespaces.php';
  • kliken-marketing-for-google/trunk/vendor/composer/autoload_static.php

    r2463804 r2951571  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit3189846b77ba157bf806f2ea8cf80c49
     7class ComposerStaticInitab4d7ed8498b17e5db5a30f4153069b4
    88{
    99    public static $classMap = array (
     10        'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
    1011        'Kliken\\WcPlugin\\Helper' => __DIR__ . '/../..' . '/classes/class-helper.php',
    1112        'Kliken\\WcPlugin\\Message' => __DIR__ . '/../..' . '/classes/class-message.php',
     
    1516        'Kliken\\WcPlugin\\REST_Products_Controller' => __DIR__ . '/../..' . '/classes/class-rest-products-controller.php',
    1617        'Kliken\\WcPlugin\\WC_Integration' => __DIR__ . '/../..' . '/classes/class-wc-integration.php',
    17         'Kliken\\WcPlugin\\WC_REST_Orders_Controller_Compat' => __DIR__ . '/../..' . '/classes/class-wc-rest-orders-controller-compat.php',
    18         'Kliken\\WcPlugin\\WC_REST_Products_Controller_Compat' => __DIR__ . '/../..' . '/classes/class-wc-rest-products-controller-compat.php',
    1918    );
    2019
     
    2221    {
    2322        return \Closure::bind(function () use ($loader) {
    24             $loader->classMap = ComposerStaticInit3189846b77ba157bf806f2ea8cf80c49::$classMap;
     23            $loader->classMap = ComposerStaticInitab4d7ed8498b17e5db5a30f4153069b4::$classMap;
    2524
    2625        }, null, ClassLoader::class);
  • kliken-marketing-for-google/trunk/vendor/composer/installed.json

    r2246875 r2951571  
    1 []
     1{
     2    "packages": [],
     3    "dev": false,
     4    "dev-package-names": []
     5}
Note: See TracChangeset for help on using the changeset viewer.