Plugin Directory

Changeset 3202954


Ignore:
Timestamp:
12/05/2024 10:50:06 AM (16 months ago)
Author:
Ecwid
Message:

Update to version 6.12.23 from GitHub

Location:
ecwid-shopping-cart
Files:
8 added
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • ecwid-shopping-cart/tags/6.12.23/ecwid-shopping-cart.php

    r3183692 r3202954  
    66Text Domain: ecwid-shopping-cart
    77Author: Ecwid Ecommerce
    8 Version: 6.12.22
     8Version: 6.12.23
    99Author URI: https://ecwid.to/ecwid-site
    1010License: GPLv2 or later
     
    5757    add_action( 'wp_ajax_ecwid_hide_message', 'ecwid_ajax_hide_message' );
    5858    add_action( 'wp_ajax_ecwid_reset_categories_cache', 'ecwid_reset_categories_cache' );
    59     add_action( 'wp_ajax_ecwid_create_store', 'ecwid_create_store' );
     59    add_action( 'wp_ajax_ecwid_create_store', 'ecwid_ajax_create_store' );
    6060    add_action( 'wp_ajax_ecwid_sync_products', 'ecwid_sync_products' );
    6161
     
    22002200}
    22012201
    2202 function ecwid_create_store() {
     2202function ecwid_create_store( $params = array() ) {
    22032203    $api = new Ecwid_Api_V3();
    22042204
    2205     $result = $api->create_store();
    2206    
    2207     if ( is_array( $result ) && $result['response']['code'] == 200 ) {
     2205    $result = $api->create_store( $params );
     2206
     2207    $is_store_created = is_array( $result ) && $result['response']['code'] == 200;
     2208   
     2209    if ( $is_store_created ) {
    22082210        $data = json_decode( $result['body'] );
    22092211
    2210         ecwid_update_store_id($data->id);
     2212        ecwid_update_store_id( $data->id );
    22112213
    22122214        $api->save_token( $data->token );
     
    22152217
    22162218        update_option( 'ecwid_oauth_scope', 'read_profile ' . Ecwid_OAuth::SCOPE_READ_CATALOG . ' create_catalog update_catalog allow_sso create_customers public_storefront' );
    2217 
     2219    }
     2220
     2221    return $result;
     2222}
     2223
     2224function ecwid_ajax_create_store() {
     2225    $result = ecwid_create_store();
     2226    $is_store_created = is_array( $result ) && $result['response']['code'] == 200;
     2227
     2228    if( $is_store_created ) {
    22182229        header( 'HTTP/1.1 200 OK' );
    2219 
     2230    } elseif ( is_wp_error( $result ) ) {
     2231        header( 'HTTP/1.1 409 Error' );
    22202232    } else {
    2221 
    2222         if( is_wp_error( $result ) ) {
    2223             header( 'HTTP/1.1 409 Error' );
    2224             die();
    2225         }
    2226 
    22272233        header( 'HTTP/1.1 ' . $result['response']['code'] . ' ' . $result['response']['message'] );
    2228         die();
    2229     }
     2234    }
     2235
     2236    die();
    22302237}
    22312238
  • ecwid-shopping-cart/tags/6.12.23/includes/class-ec-store-wp-cli.php

    r2514476 r3202954  
    6363    }
    6464
     65    /**
     66    * Create a new store. It will automatically connect to the plugin.
     67    * ## OPTIONS
     68    *
     69    * [--email]
     70    * : Client email. Required.
     71    *
     72    * [--name]
     73    * : Client name. Required.
     74    *
     75    * [--password]
     76    * : Client password. Optional, if not set, it will be generated automatically.
     77    *
     78    * [--channel_id]
     79    * : Chanel ID. To bind the client to a channel. Optional.
     80    *
     81    * [--goods=<goods>]
     82    * : Goods. To set the type of demo products. For a list of current options, contact your manager. Optional.
     83    * ---
     84    * default: apparel
     85    * options:
     86    *   - apparel
     87    *   - health
     88    *   - electronics
     89    *   - jewelry
     90    *   - food_ecommerce
     91    *   - food_restaurant
     92    * ---
     93    *
     94    */
     95    function create_store( $args, $assoc_args ) {
     96       
     97        $params = $assoc_args;
     98        $is_set_user = ! empty( WP_CLI::get_config( 'user' ) );
     99
     100        if ( empty( $params['email'] ) && ! $is_set_user ) {
     101            WP_CLI::error( 'Email is required', true );
     102        }
     103
     104        if ( empty( $params['name'] ) && ! $is_set_user ) {
     105            WP_CLI::error( 'Name is required', true );
     106        }
     107
     108        $result = ecwid_create_store( $params );
     109       
     110        $data = json_decode( $result['body'] );
     111        $is_store_created = is_array( $result ) && $result['response']['code'] == 200;
     112       
     113        if( $is_store_created ) {
     114            WP_CLI::success( 'Store created: ' . $data->id );
     115        } else {
     116            WP_CLI::error( 'Store creation failed: [' . $result['response']['code'] . '] ' . $data->errorCode . ' : ' . $data->errorMessage, true );
     117        }
     118    }
     119
    65120}
    66121 
  • ecwid-shopping-cart/tags/6.12.23/includes/importer/class-ecwid-import-page.php

    r3183692 r3202954  
    105105    }
    106106
     107    public function is_ajax_request() {
     108        return ! empty( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REQUESTED_WITH'] ) ) ) == 'xmlhttprequest';
     109    }
     110
    107111    public function do_woo_import() {
    108112        check_ajax_referer( self::AJAX_ACTION_DO_WOO_IMPORT );
     113
     114        if( ! $this->is_ajax_request() ) {
     115            die();
     116        }
    109117
    110118        if ( ! current_user_can( 'manage_options' ) ) {
  • ecwid-shopping-cart/tags/6.12.23/lib/ecwid_api_v3.php

    r3131402 r3202954  
    743743    }
    744744
    745     public function create_store() {
     745    public function create_store( $params = array() ) {
    746746        global $current_user;
    747747        $admin_email = $current_user->user_email;
     
    751751            $admin_first = get_user_meta( $current_user->ID, 'nickname', true );
    752752        }
     753       
    753754        $admin_last = get_user_meta( $current_user->ID, 'last_name', true );
    754755        if ( ! $admin_last ) {
    755756            $admin_last = get_user_meta( $current_user->ID, 'nickname', true );
    756757        }
    757         $admin_name     = "$admin_first $admin_last";
    758         $admin_nickname = $current_user->display_name;
     758
     759        $admin_name     = implode( ' ', array($admin_first, $admin_last) );
    759760        $store_url      = Ecwid_Store_Page::get_store_url();
    760761        $site_name      = get_bloginfo( 'name' );
     
    762763        $timezone       = get_option( 'timezone_string', 'UTC+0' );
    763764
    764         $params = array(
     765        if( !empty( $params['email'] ) ) {
     766            $admin_email = $params['email'];
     767        }
     768
     769        if( !empty( $params['name'] ) ) {
     770            $admin_name = $params['name'];
     771        }
     772
     773        if( !empty( $params['password'] ) ) {
     774            $password = $params['password'];
     775        } else {
     776            $password = wp_generate_password( 8 );
     777        }
     778
     779        $data = array(
    765780            'merchant'         => array(
    766781                'email'    => $admin_email,
    767782                'name'     => $admin_name,
    768                 'password' => wp_generate_password( 8 ),
     783                'password' => $password,
    769784            ),
    770785            'affiliatePartner' => array(
     
    777792                'account'           => array(
    778793                    'accountName'     => $admin_name,
    779                     'accountNickName' => $admin_nickname,
    780794                    'accountEmail'    => $admin_email,
    781795                ),
     
    793807        );
    794808
     809        if( !empty( $params['channel_id'] ) ) {
     810            $data['merchant']['channelId'] = $params['channel_id'];
     811        }
     812
     813        if( !empty( $params['goods'] ) ) {
     814            $data['profile']['registrationAnswers']['goods'] = $params['goods'];
     815        }
     816
    795817        if ( isset( $_SERVER['REMOTE_ADDR'] ) && ! in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1' ) ) ) {
    796             $params['merchant']['ip'] = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
     818            $data['merchant']['ip'] = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
    797819        }
    798820
     
    800822
    801823        if ( $ref ) {
    802             $params['affiliatePartner']['ambassador'] = array(
     824            $data['affiliatePartner']['ambassador'] = array(
    803825                'ref' => $ref,
    804826            );
     
    814836        $result = EcwidPlatform::http_post_request(
    815837            $url,
    816             json_encode( $params ),
     838            json_encode( $data ),
    817839            array(
    818840                'timeout' => 20,
  • ecwid-shopping-cart/tags/6.12.23/lib/ecwid_platform.php

    r3116030 r3202954  
    257257
    258258        if ( is_object( $item ) || is_array( $item ) ) {
    259             array_walk_recursive( $item, 'self::encode_emoji' );
     259            array_walk_recursive( $item, 'EcwidPlatform::encode_emoji' );
    260260        } elseif ( is_string( $item ) ) {
    261261            $item = wp_encode_emoji( $item );
  • ecwid-shopping-cart/tags/6.12.23/readme.txt

    r3183712 r3202954  
    66Requires at least: 4.4
    77Tested up to: 6.7
    8 Stable tag: 6.12.22
     8Stable tag: 6.12.23
    99
    1010Powerful, easy to use ecommerce shopping cart for WordPress. Sell on Facebook and Instagram. iPhone & Android apps. Superb support. Free plan available.
     
    154154
    155155== Changelog ==
     156= 6.12.23 - Dec 5, 2024 =
     157- Fixed a PHP error message ("Deprecated: Use of "self" in callables is deprecated") for PHP versions since 8.2.
     158- Internal improvements and optimizations.
     159
    156160= 6.12.22 - Nov 7, 2024 =
    157161- **WordPress 6.7 and Twenty Twenty Five theme compatibility.** The new WordPress version will be released soon. The Ecwid ecommerce shopping cart plugin is ready for the new release — everything works well in your WordPress admin and storefront pages. Feel free to upgrade your site to WordPress 6.7 and try a new theme.
  • ecwid-shopping-cart/trunk/ecwid-shopping-cart.php

    r3183692 r3202954  
    66Text Domain: ecwid-shopping-cart
    77Author: Ecwid Ecommerce
    8 Version: 6.12.22
     8Version: 6.12.23
    99Author URI: https://ecwid.to/ecwid-site
    1010License: GPLv2 or later
     
    5757    add_action( 'wp_ajax_ecwid_hide_message', 'ecwid_ajax_hide_message' );
    5858    add_action( 'wp_ajax_ecwid_reset_categories_cache', 'ecwid_reset_categories_cache' );
    59     add_action( 'wp_ajax_ecwid_create_store', 'ecwid_create_store' );
     59    add_action( 'wp_ajax_ecwid_create_store', 'ecwid_ajax_create_store' );
    6060    add_action( 'wp_ajax_ecwid_sync_products', 'ecwid_sync_products' );
    6161
     
    22002200}
    22012201
    2202 function ecwid_create_store() {
     2202function ecwid_create_store( $params = array() ) {
    22032203    $api = new Ecwid_Api_V3();
    22042204
    2205     $result = $api->create_store();
    2206    
    2207     if ( is_array( $result ) && $result['response']['code'] == 200 ) {
     2205    $result = $api->create_store( $params );
     2206
     2207    $is_store_created = is_array( $result ) && $result['response']['code'] == 200;
     2208   
     2209    if ( $is_store_created ) {
    22082210        $data = json_decode( $result['body'] );
    22092211
    2210         ecwid_update_store_id($data->id);
     2212        ecwid_update_store_id( $data->id );
    22112213
    22122214        $api->save_token( $data->token );
     
    22152217
    22162218        update_option( 'ecwid_oauth_scope', 'read_profile ' . Ecwid_OAuth::SCOPE_READ_CATALOG . ' create_catalog update_catalog allow_sso create_customers public_storefront' );
    2217 
     2219    }
     2220
     2221    return $result;
     2222}
     2223
     2224function ecwid_ajax_create_store() {
     2225    $result = ecwid_create_store();
     2226    $is_store_created = is_array( $result ) && $result['response']['code'] == 200;
     2227
     2228    if( $is_store_created ) {
    22182229        header( 'HTTP/1.1 200 OK' );
    2219 
     2230    } elseif ( is_wp_error( $result ) ) {
     2231        header( 'HTTP/1.1 409 Error' );
    22202232    } else {
    2221 
    2222         if( is_wp_error( $result ) ) {
    2223             header( 'HTTP/1.1 409 Error' );
    2224             die();
    2225         }
    2226 
    22272233        header( 'HTTP/1.1 ' . $result['response']['code'] . ' ' . $result['response']['message'] );
    2228         die();
    2229     }
     2234    }
     2235
     2236    die();
    22302237}
    22312238
  • ecwid-shopping-cart/trunk/includes/class-ec-store-wp-cli.php

    r2514476 r3202954  
    6363    }
    6464
     65    /**
     66    * Create a new store. It will automatically connect to the plugin.
     67    * ## OPTIONS
     68    *
     69    * [--email]
     70    * : Client email. Required.
     71    *
     72    * [--name]
     73    * : Client name. Required.
     74    *
     75    * [--password]
     76    * : Client password. Optional, if not set, it will be generated automatically.
     77    *
     78    * [--channel_id]
     79    * : Chanel ID. To bind the client to a channel. Optional.
     80    *
     81    * [--goods=<goods>]
     82    * : Goods. To set the type of demo products. For a list of current options, contact your manager. Optional.
     83    * ---
     84    * default: apparel
     85    * options:
     86    *   - apparel
     87    *   - health
     88    *   - electronics
     89    *   - jewelry
     90    *   - food_ecommerce
     91    *   - food_restaurant
     92    * ---
     93    *
     94    */
     95    function create_store( $args, $assoc_args ) {
     96       
     97        $params = $assoc_args;
     98        $is_set_user = ! empty( WP_CLI::get_config( 'user' ) );
     99
     100        if ( empty( $params['email'] ) && ! $is_set_user ) {
     101            WP_CLI::error( 'Email is required', true );
     102        }
     103
     104        if ( empty( $params['name'] ) && ! $is_set_user ) {
     105            WP_CLI::error( 'Name is required', true );
     106        }
     107
     108        $result = ecwid_create_store( $params );
     109       
     110        $data = json_decode( $result['body'] );
     111        $is_store_created = is_array( $result ) && $result['response']['code'] == 200;
     112       
     113        if( $is_store_created ) {
     114            WP_CLI::success( 'Store created: ' . $data->id );
     115        } else {
     116            WP_CLI::error( 'Store creation failed: [' . $result['response']['code'] . '] ' . $data->errorCode . ' : ' . $data->errorMessage, true );
     117        }
     118    }
     119
    65120}
    66121 
  • ecwid-shopping-cart/trunk/includes/importer/class-ecwid-import-page.php

    r3183692 r3202954  
    105105    }
    106106
     107    public function is_ajax_request() {
     108        return ! empty( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REQUESTED_WITH'] ) ) ) == 'xmlhttprequest';
     109    }
     110
    107111    public function do_woo_import() {
    108112        check_ajax_referer( self::AJAX_ACTION_DO_WOO_IMPORT );
     113
     114        if( ! $this->is_ajax_request() ) {
     115            die();
     116        }
    109117
    110118        if ( ! current_user_can( 'manage_options' ) ) {
  • ecwid-shopping-cart/trunk/lib/ecwid_api_v3.php

    r3131402 r3202954  
    743743    }
    744744
    745     public function create_store() {
     745    public function create_store( $params = array() ) {
    746746        global $current_user;
    747747        $admin_email = $current_user->user_email;
     
    751751            $admin_first = get_user_meta( $current_user->ID, 'nickname', true );
    752752        }
     753       
    753754        $admin_last = get_user_meta( $current_user->ID, 'last_name', true );
    754755        if ( ! $admin_last ) {
    755756            $admin_last = get_user_meta( $current_user->ID, 'nickname', true );
    756757        }
    757         $admin_name     = "$admin_first $admin_last";
    758         $admin_nickname = $current_user->display_name;
     758
     759        $admin_name     = implode( ' ', array($admin_first, $admin_last) );
    759760        $store_url      = Ecwid_Store_Page::get_store_url();
    760761        $site_name      = get_bloginfo( 'name' );
     
    762763        $timezone       = get_option( 'timezone_string', 'UTC+0' );
    763764
    764         $params = array(
     765        if( !empty( $params['email'] ) ) {
     766            $admin_email = $params['email'];
     767        }
     768
     769        if( !empty( $params['name'] ) ) {
     770            $admin_name = $params['name'];
     771        }
     772
     773        if( !empty( $params['password'] ) ) {
     774            $password = $params['password'];
     775        } else {
     776            $password = wp_generate_password( 8 );
     777        }
     778
     779        $data = array(
    765780            'merchant'         => array(
    766781                'email'    => $admin_email,
    767782                'name'     => $admin_name,
    768                 'password' => wp_generate_password( 8 ),
     783                'password' => $password,
    769784            ),
    770785            'affiliatePartner' => array(
     
    777792                'account'           => array(
    778793                    'accountName'     => $admin_name,
    779                     'accountNickName' => $admin_nickname,
    780794                    'accountEmail'    => $admin_email,
    781795                ),
     
    793807        );
    794808
     809        if( !empty( $params['channel_id'] ) ) {
     810            $data['merchant']['channelId'] = $params['channel_id'];
     811        }
     812
     813        if( !empty( $params['goods'] ) ) {
     814            $data['profile']['registrationAnswers']['goods'] = $params['goods'];
     815        }
     816
    795817        if ( isset( $_SERVER['REMOTE_ADDR'] ) && ! in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1' ) ) ) {
    796             $params['merchant']['ip'] = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
     818            $data['merchant']['ip'] = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
    797819        }
    798820
     
    800822
    801823        if ( $ref ) {
    802             $params['affiliatePartner']['ambassador'] = array(
     824            $data['affiliatePartner']['ambassador'] = array(
    803825                'ref' => $ref,
    804826            );
     
    814836        $result = EcwidPlatform::http_post_request(
    815837            $url,
    816             json_encode( $params ),
     838            json_encode( $data ),
    817839            array(
    818840                'timeout' => 20,
  • ecwid-shopping-cart/trunk/lib/ecwid_platform.php

    r3116030 r3202954  
    257257
    258258        if ( is_object( $item ) || is_array( $item ) ) {
    259             array_walk_recursive( $item, 'self::encode_emoji' );
     259            array_walk_recursive( $item, 'EcwidPlatform::encode_emoji' );
    260260        } elseif ( is_string( $item ) ) {
    261261            $item = wp_encode_emoji( $item );
  • ecwid-shopping-cart/trunk/readme.txt

    r3183712 r3202954  
    66Requires at least: 4.4
    77Tested up to: 6.7
    8 Stable tag: 6.12.22
     8Stable tag: 6.12.23
    99
    1010Powerful, easy to use ecommerce shopping cart for WordPress. Sell on Facebook and Instagram. iPhone & Android apps. Superb support. Free plan available.
     
    154154
    155155== Changelog ==
     156= 6.12.23 - Dec 5, 2024 =
     157- Fixed a PHP error message ("Deprecated: Use of "self" in callables is deprecated") for PHP versions since 8.2.
     158- Internal improvements and optimizations.
     159
    156160= 6.12.22 - Nov 7, 2024 =
    157161- **WordPress 6.7 and Twenty Twenty Five theme compatibility.** The new WordPress version will be released soon. The Ecwid ecommerce shopping cart plugin is ready for the new release — everything works well in your WordPress admin and storefront pages. Feel free to upgrade your site to WordPress 6.7 and try a new theme.
Note: See TracChangeset for help on using the changeset viewer.