Changeset 3116030
- Timestamp:
- 07/11/2024 05:39:00 AM (21 months ago)
- Location:
- ecwid-shopping-cart
- Files:
-
- 22 edited
- 1 copied
-
tags/6.12.15 (copied) (copied from ecwid-shopping-cart/trunk)
-
tags/6.12.15/ecwid-shopping-cart.php (modified) (3 diffs)
-
tags/6.12.15/includes/class-ecwid-admin-storefront-page.php (modified) (11 diffs)
-
tags/6.12.15/includes/class-ecwid-nav-menus.php (modified) (1 diff)
-
tags/6.12.15/includes/class-ecwid-seo-links.php (modified) (1 diff)
-
tags/6.12.15/includes/class-ecwid-static-page.php (modified) (3 diffs)
-
tags/6.12.15/includes/gutenberg/class-ecwid-gutenberg-block-store.php (modified) (1 diff)
-
tags/6.12.15/includes/themes/class-ecwid-theme-base.php (modified) (2 diffs)
-
tags/6.12.15/lib/ecwid_api_v3.php (modified) (5 diffs)
-
tags/6.12.15/lib/ecwid_catalog.php (modified) (2 diffs)
-
tags/6.12.15/lib/ecwid_platform.php (modified) (3 diffs)
-
tags/6.12.15/readme.txt (modified) (1 diff)
-
trunk/ecwid-shopping-cart.php (modified) (3 diffs)
-
trunk/includes/class-ecwid-admin-storefront-page.php (modified) (11 diffs)
-
trunk/includes/class-ecwid-nav-menus.php (modified) (1 diff)
-
trunk/includes/class-ecwid-seo-links.php (modified) (1 diff)
-
trunk/includes/class-ecwid-static-page.php (modified) (3 diffs)
-
trunk/includes/gutenberg/class-ecwid-gutenberg-block-store.php (modified) (1 diff)
-
trunk/includes/themes/class-ecwid-theme-base.php (modified) (2 diffs)
-
trunk/lib/ecwid_api_v3.php (modified) (5 diffs)
-
trunk/lib/ecwid_catalog.php (modified) (2 diffs)
-
trunk/lib/ecwid_platform.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ecwid-shopping-cart/tags/6.12.15/ecwid-shopping-cart.php
r3110860 r3116030 6 6 Text Domain: ecwid-shopping-cart 7 7 Author: Ecwid Ecommerce 8 Version: 6.12.1 48 Version: 6.12.15 9 9 Author URI: https://ecwid.to/ecwid-site 10 10 License: GPLv2 or later … … 2413 2413 2414 2414 $query_params = array( 2415 'hidden_categories' => true 2415 'hidden_categories' => true, 2416 'responseFields' => 'total,count,items(id,name,url,enabled,parentId)' 2416 2417 ); 2417 2418 … … 2448 2449 } 2449 2450 } 2450 2451 $parents = array();2452 2451 2453 2452 $result = array(); -
ecwid-shopping-cart/tags/6.12.15/includes/class-ecwid-admin-storefront-page.php
r3002218 r3116030 33 33 34 34 if ( $page_id && ! isset( $page_status ) ) { 35 36 35 $page_data = self::get_page_data( $page_id ); 37 36 extract( $page_data, EXTR_PREFIX_ALL, 'page' ); … … 71 70 72 71 $api = new Ecwid_Api_V3(); 73 $res = $api->get_products( array( ) );72 $res = $api->get_products( array( 'responseFields' => 'total,count,items(id,name)' ) ); 74 73 if ( $res ) { 75 74 $products = $res->items; … … 97 96 wp_enqueue_script( 'ecwid-admin-storefront-js', ECWID_PLUGIN_URL . 'js/admin-storefront.js', array(), get_option( 'ecwid_plugin_version' ) ); 98 97 99 wp_localize_script(100 'ecwid-admin-storefront-js',101 'EcwidAdminStorefront', 102 array(103 '_ajax_nonce' => wp_create_nonce( self::NONCE_SLUG ) 104 )105 );98 wp_localize_script( 99 'ecwid-admin-storefront-js', 100 'EcwidAdminStorefront', 101 array( 102 '_ajax_nonce' => wp_create_nonce( self::NONCE_SLUG ), 103 ) 104 ); 106 105 107 106 Ecwid_Admin_UI_Framework::print_fix_js(); … … 131 130 132 131 public function ajax_set_status() { 133 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {134 die();135 }132 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) { 133 die(); 134 } 136 135 137 136 if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) { … … 173 172 174 173 public function ajax_set_store_on_front() { 175 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {176 die();177 }174 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) { 175 die(); 176 } 178 177 179 178 if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) { … … 208 207 209 208 public function ajax_set_mainpage() { 210 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {211 die();212 }209 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) { 210 die(); 211 } 213 212 214 213 if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) { … … 245 244 246 245 public function ajax_set_display_cart_icon() { 247 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {248 die();249 }246 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) { 247 die(); 248 } 250 249 251 250 if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) { … … 266 265 267 266 public function ajax_set_page_slug() { 268 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {269 die();270 }267 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) { 268 die(); 269 } 271 270 272 271 if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) { … … 316 315 317 316 public function ajax_create_page() { 318 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {319 die();320 }317 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) { 318 die(); 319 } 321 320 322 321 if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) { … … 480 479 481 480 if ( version_compare( $version, '5.0' ) < 0 ) { 482 483 481 if ( is_plugin_active( 'gutenberg/gutenberg.php' ) ) { 484 482 return true; … … 573 571 } 574 572 575 echo sprintf( '<li><a%s>%s</a></li>', wp_kses_post( $attributes ), esc_html( $text ) );573 printf( '<li><a%s>%s</a></li>', wp_kses_post( $attributes ), esc_html( $text ) ); 576 574 }//end foreach 577 575 } -
ecwid-shopping-cart/tags/6.12.15/includes/class-ecwid-nav-menus.php
r3021774 r3116030 241 241 $posts = array(); 242 242 $api = new Ecwid_Api_V3(); 243 $result = $api->get_categories( array( 'parent' => 0 ) ); 243 $result = $api->get_categories( 244 array( 245 'parent' => 0, 246 'responseFields' => 'total,count,items(id,name,url,nameTranslated,orderBy)', 247 ) 248 ); 244 249 245 250 if ( $result && $result->count > 0 ) { -
ecwid-shopping-cart/tags/6.12.15/includes/class-ecwid-seo-links.php
r3110860 r3116030 330 330 331 331 public function build_rewrite_rules( $rules ) { 332 $new_rules = array(); 332 $new_rules = array(); 333 $additional_rules = array(); 333 334 334 335 $all_base_urls = $this->_build_all_base_urls(); -
ecwid-shopping-cart/tags/6.12.15/includes/class-ecwid-static-page.php
r3110860 r3116030 181 181 $cached_data->cssFiles = array( $dynamic_css ); //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 182 182 183 EcwidPlatform::s tore_in_static_pages_cache( $url, $cached_data );183 EcwidPlatform::save_in_static_pages_cache( $url, $cached_data ); 184 184 } 185 185 … … 222 222 } 223 223 224 EcwidPlatform::encode_fields_with_emoji( 225 $fetched_data, 226 array( 'htmlCode', 'metaDescriptionHtml', 'ogTagsHtml', 'jsonLDHtml' ) 227 ); 228 224 229 if ( isset( $fetched_data->lastUpdated ) ) { 225 230 $last_update = substr( $fetched_data->lastUpdated, 0, -3 ); … … 230 235 231 236 EcwidPlatform::invalidate_static_pages_cache_from( $last_update ); 232 EcwidPlatform::s tore_in_static_pages_cache( $url, $fetched_data );237 EcwidPlatform::save_in_static_pages_cache( $url, $fetched_data ); 233 238 234 239 return $fetched_data; -
ecwid-shopping-cart/tags/6.12.15/includes/gutenberg/class-ecwid-gutenberg-block-store.php
r3093942 r3116030 287 287 }//end foreach 288 288 289 $categories = ecwid_get_categories_for_selector(); 290 291 if ( $categories ) { 292 $attributes['default_category_id']['values'] = array( 293 array( 294 'value' => '0', 295 'title' => __( 'Store root category', 'ecwid-shopping-cart' ), 296 ), 297 ); 298 foreach ( $categories as $category ) { 299 if ( empty( $category->enabled ) ) { 300 continue; 301 } 302 303 $attributes['default_category_id']['values'][] = array( 304 'value' => $category->id, 305 'title' => $category->name, 289 if ( is_admin() ) { 290 $categories = ecwid_get_categories_for_selector(); 291 292 if ( $categories ) { 293 $attributes['default_category_id']['values'] = array( 294 array( 295 'value' => '0', 296 'title' => __( 'Store root category', 'ecwid-shopping-cart' ), 297 ), 306 298 ); 307 } 308 309 $attributes['default_category_id']['default'] = ''; 310 } else { 311 $api = new Ecwid_Api_V3(); 312 $cats = $api->get_categories( array() ); 313 314 if ( $cats && $cats->total == 0 ) { 315 unset( $attributes['default_category_id'] ); 316 } 299 foreach ( $categories as $category ) { 300 if ( empty( $category->enabled ) ) { 301 continue; 302 } 303 304 $attributes['default_category_id']['values'][] = array( 305 'value' => $category->id, 306 'title' => $category->name, 307 ); 308 } 309 310 $attributes['default_category_id']['default'] = ''; 311 } else { 312 $api = new Ecwid_Api_V3(); 313 $cats = $api->get_categories( array() ); 314 315 if ( $cats && $cats->total == 0 ) { 316 unset( $attributes['default_category_id'] ); 317 } 318 }//end if 317 319 }//end if 318 320 -
ecwid-shopping-cart/tags/6.12.15/includes/themes/class-ecwid-theme-base.php
r2813294 r3116030 68 68 69 69 if ( in_array( 'title', $props, true ) ) { 70 71 70 $store_page_params = Ecwid_Store_Page::get_store_page_params(); 72 71 73 if ( @$store_page_params['product_details_show_product_name']) {72 if ( ! empty( $store_page_params['product_details_show_product_name'] ) ) { 74 73 add_filter( 'option_' . Ecwid_Store_Page::OPTION_REPLACE_TITLE, '__return_false' ); 75 74 } … … 126 125 ); 127 126 } 128 129 127 } -
ecwid-shopping-cart/tags/6.12.15/lib/ecwid_api_v3.php
r3059103 r3116030 164 164 } 165 165 166 $passthru = array( 'offset', 'limit', 'parent', 'baseUrl', 'cleanUrls', 'hidden_categories' );166 $passthru = array( 'offset', 'limit', 'parent', 'baseUrl', 'cleanUrls', 'hidden_categories', 'responseFields' ); 167 167 foreach ( $passthru as $name ) { 168 168 if ( array_key_exists( $name, $input_params ) ) { … … 190 190 if ( ! $result ) { 191 191 $result = EcwidPlatform::fetch_url( $url, $options ); 192 } 193 194 if ( $result['code'] != '200' ) { 195 return false; 196 } 197 198 EcwidPlatform::store_in_categories_cache( $url, $result ); 192 193 if ( $result['code'] != '200' ) { 194 return false; 195 } 196 197 // PLUGINS-6870 there's some cases when data are not cached because emojis, need to encode 198 $data = json_decode( $result['data'] ); 199 200 if ( ! empty( $data->items ) ) { 201 foreach ( $data->items as &$item ) { 202 $item = EcwidPlatform::encode_fields_with_emoji( 203 $item, 204 array( 'name', 'nameTranslated', 'description', 'descriptionTranslated', 'seoTitle', 'seoTitleTranslated', 'seoDescription', 'seoDescriptionTranslated', 'alt' ) 205 ); 206 } 207 } 208 209 $result['data'] = wp_json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); 210 // end PLUGINS-6870 there's some cases when data are not cached because emojis, need to encode 211 212 EcwidPlatform::store_in_categories_cache( $url, $result ); 213 }//end if 199 214 200 215 $result = json_decode( $result['data'] ); … … 249 264 if ( ! $result ) { 250 265 $result = EcwidPlatform::fetch_url( $url, $options ); 251 } 252 253 if ( $result['code'] != '200' ) { 254 return false; 255 } 256 257 EcwidPlatform::store_in_categories_cache( $url, $result ); 266 267 if ( $result['code'] != '200' ) { 268 return false; 269 } 270 271 // PLUGINS-6870 there's some cases when data are not cached because emojis, need to encode 272 $data = json_decode( $result['data'] ); 273 if ( ! empty( $data ) ) { 274 $data = EcwidPlatform::encode_fields_with_emoji( 275 $data, 276 array( 'name', 'nameTranslated', 'description', 'descriptionTranslated', 'seoTitle', 'seoTitleTranslated', 'seoDescription', 'seoDescriptionTranslated', 'alt' ) 277 ); 278 } 279 // end PLUGINS-6870 there's some cases when data are not cached because emojis, need to encode 280 281 $result['data'] = wp_json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); 282 283 EcwidPlatform::store_in_categories_cache( $url, $result ); 284 }//end if 258 285 259 286 $result = json_decode( $result['data'] ); … … 398 425 $params = array(); 399 426 400 $passthru = array( 'updatedFrom', 'offset', 'limit', 'sortBy', 'keyword', 'createdFrom', 'createdTo', 'sku', 'enabled' );427 $passthru = array( 'updatedFrom', 'offset', 'limit', 'sortBy', 'keyword', 'createdFrom', 'createdTo', 'sku', 'enabled', 'responseFields' ); 401 428 402 429 foreach ( $passthru as $name ) { … … 601 628 602 629 $profile = json_decode( $result['data'] ); 630 631 // PLUGINS-6870 there's some cases when data are not cached because emojis, need to encode 632 if ( ! empty( $profile ) ) { 633 $profile->settings = EcwidPlatform::encode_fields_with_emoji( 634 $profile->settings, 635 array( 'storeName', 'storeDescription', 'storeDescriptionTranslated', 'rootCategorySeoTitleTranslated', 'rootCategorySeoDescription', 'rootCategorySeoDescriptionTranslated' ) 636 ); 637 } 638 // end PLUGINS-6870 there's some cases when data are not cached because emojis, need to encode 603 639 604 640 EcwidPlatform::cache_set( self::PROFILE_CACHE_NAME, $profile, 10 * MINUTE_IN_SECONDS ); -
ecwid-shopping-cart/tags/6.12.15/lib/ecwid_catalog.php
r2640505 r3116030 1 1 <?php 2 2 3 class EcwidCatalog 4 { 5 var $store_id = 0;3 class EcwidCatalog { 4 5 var $store_id = 0; 6 6 var $store_base_url = ''; 7 7 8 public function __construct($store_id, $store_base_url) 9 { 10 $this->store_id = intval($store_id); 11 $this->store_base_url = $store_base_url; 8 public function __construct( $store_id, $store_base_url ) { 9 $this->store_id = intval( $store_id ); 10 $this->store_base_url = $store_base_url; 12 11 } 13 12 14 public function warmup_store_page( $category_id ) 15 { 13 public function warmup_store_page( $category_id ) { 16 14 $this->_get_data_for_category( $category_id, null ); 17 15 } 18 19 public function get_product($id)20 {21 $result = $this->_get_data_for_product($id);22 16 23 if ( !$result ) { 17 public function get_product( $id ) { 18 $result = $this->_get_data_for_product( $id ); 19 20 if ( ! $result ) { 24 21 return ''; 25 22 } 26 23 27 24 ob_start(); 28 25 $product = $result->product; 29 26 $formats = $result->formats; 30 require dirname(__FILE__) . '/html-catalog-templates/product.php'; 31 32 $return = ob_get_contents(); 33 ob_end_clean(); 34 35 return $return; 36 } 37 38 public function get_category($id) 39 { 40 $offset = ( isset($_GET['offset']) ) ? intval($_GET['offset']) : 0; 41 $data = $this->_get_data_for_category( $id, $offset ); 42 43 if ( !$data ) { 44 return ''; 45 } 46 47 $main_category = null; 48 if ($id > 0) { 49 $main_category = $data->main_category; 50 } 51 $categories = $data->categories; 52 $products = $data->products; 53 $formats = $data->formats; 54 55 ob_start(); 56 require dirname(__FILE__) . '/html-catalog-templates/category.php'; 27 require __DIR__ . '/html-catalog-templates/product.php'; 57 28 58 29 $return = ob_get_contents(); … … 62 33 } 63 34 64 protected function _get_data_for_product( $id ) 65 { 35 public function get_category( $id ) { 36 $offset = ( isset( $_GET['offset'] ) ) ? intval( $_GET['offset'] ) : 0; 37 $data = $this->_get_data_for_category( $id, $offset ); 38 39 if ( ! $data ) { 40 return ''; 41 } 42 43 $main_category = null; 44 if ( $id > 0 ) { 45 $main_category = $data->main_category; 46 } 47 $categories = $data->categories; 48 $products = $data->products; 49 $formats = $data->formats; 50 51 ob_start(); 52 require __DIR__ . '/html-catalog-templates/category.php'; 53 54 $return = ob_get_contents(); 55 ob_end_clean(); 56 57 return $return; 58 } 59 60 protected function _get_data_for_product( $id ) { 66 61 if ( Ecwid_Api_V3::is_available() ) { 67 62 $api = new Ecwid_Api_V3(); 68 63 69 64 $product = Ecwid_Product::get_by_id( $id ); 70 65 71 66 $profile = $api->get_store_profile(); 72 73 if ( !$profile) {67 68 if ( ! $profile ) { 74 69 return null; 75 70 } 76 71 77 72 return (object) array( 78 73 'product' => $product, 79 'formats' => @$profile->formatsAndUnits 74 'formats' => @$profile->formatsAndUnits, 80 75 ); 81 } 82 76 } 77 83 78 return null; 84 79 } 85 86 protected function _get_data_for_category( $id, $offset = 0 ) 87 { 80 81 protected function _get_data_for_category( $id, $offset = 0 ) { 88 82 if ( Ecwid_Api_V3::is_available() ) { 89 83 $api = new Ecwid_Api_V3(); 90 84 91 85 $main_category = null; 92 if ( $id > 0) {86 if ( $id > 0 ) { 93 87 $main_category = $api->get_category( $id ); 94 88 } 95 89 96 90 $get_categories_params = array( 97 'parent' => $id 91 'parent' => $id, 98 92 ); 99 if ( $offset && $offset > 0) {93 if ( $offset && $offset > 0 ) { 100 94 $get_categories_params['offset'] = $offset; 101 95 } 102 96 $categories = $api->get_categories( $get_categories_params ); 103 97 104 98 $get_products_params = array( 105 'category' => $id 99 'category' => $id, 106 100 ); 107 if ( $offset) {101 if ( $offset ) { 108 102 $get_products_params['offset'] = $offset; 109 103 } 110 104 $products = $api->search_products( $get_products_params ); 111 105 112 106 $profile = $api->get_store_profile(); 113 114 if ( is_null( $profile ) || ! isset( $categories->items ) || !isset( $products->items ) ) {107 108 if ( is_null( $profile ) || ! isset( $categories->items ) || ! isset( $products->items ) ) { 115 109 return null; 116 110 } 117 111 118 112 return (object) array( 119 113 'main_category' => $main_category, 120 'categories' => $categories->items,121 'products' => $products->items,122 'formats' => @$profile->formatsAndUnits114 'categories' => $categories->items, 115 'products' => $products->items, 116 'formats' => @$profile->formatsAndUnits, 123 117 ); 124 } 125 118 }//end if 119 126 120 return null; 127 121 } 128 129 public function parse_escaped_fragment($escaped_fragment)130 {131 $fragment = urldecode($escaped_fragment);132 $return = array();133 122 134 if (preg_match('/^(\/~\/)([a-z]+)\/(.*)$/', $fragment, $matches)) { 135 parse_str($matches[3], $return); 123 public function parse_escaped_fragment( $escaped_fragment ) { 124 $fragment = urldecode( $escaped_fragment ); 125 $return = array(); 126 127 if ( preg_match( '/^(\/~\/)([a-z]+)\/(.*)$/', $fragment, $matches ) ) { 128 parse_str( $matches[3], $return ); 136 129 $return['mode'] = $matches[2]; 137 } elseif ( preg_match('!.*/(p|c)/([0-9]*)!', $fragment, $matches)) {138 if ( count($matches) == 3 && in_array($matches[1], array('p', 'c'))) {139 $return = array(130 } elseif ( preg_match( '!.*/(p|c)/([0-9]*)!', $fragment, $matches ) ) { 131 if ( count( $matches ) == 3 && in_array( $matches[1], array( 'p', 'c' ) ) ) { 132 $return = array( 140 133 'mode' => 'p' == $matches[1] ? 'product' : 'category', 141 'id' => $matches[2]134 'id' => $matches[2], 142 135 ); 143 136 } -
ecwid-shopping-cart/tags/6.12.15/lib/ecwid_platform.php
r3110860 r3116030 226 226 ) 227 227 ); 228 self::encode_emoji( $value );229 228 230 229 set_transient( 'ecwid_' . $name, $value, $expires_after ); 231 230 } 232 231 232 public static function encode_fields_with_emoji( $data, $properties = array() ) { 233 if ( ! is_object( $data ) ) { 234 return $data; 235 } 236 237 if ( ! is_array( $properties ) ) { 238 return $data; 239 } 240 241 foreach ( $properties as $property ) { 242 if ( ! empty( $data->$property ) ) { 243 if ( is_string( $data->$property ) ) { 244 $data->$property = wp_encode_emoji( $data->$property ); 245 } else { 246 self::encode_emoji( $data->$property ); 247 } 248 } 249 } 250 return $data; 251 } 252 233 253 public static function encode_emoji( &$item, $key = false ) { //phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed 254 if ( empty( $item ) ) { 255 return; 256 } 257 234 258 if ( is_object( $item ) || is_array( $item ) ) { 235 259 array_walk_recursive( $item, 'self::encode_emoji' ); … … 306 330 } 307 331 308 if ( $return['code'] == 200 ) {332 if ( $return['code'] == 200 && $api_check_retry_after !== 0 ) { 309 333 update_option( self::OPTION_ECWID_CHECK_API_RETRY_AFTER, 0 ); 310 334 } … … 377 401 378 402 public static function store_in_products_cache( $url, $data ) { 379 self::s tore_in_cache( $url, 'products', $data, WEEK_IN_SECONDS );403 self::save_in_cache( $url, 'products', $data, WEEK_IN_SECONDS ); 380 404 } 381 405 382 406 public static function store_in_categories_cache( $url, $data ) { 383 self::s tore_in_cache( $url, 'categories', $data, WEEK_IN_SECONDS );384 } 385 386 public static function s tore_in_static_pages_cache( $url, $data ) {387 self::s tore_in_cache( $url, 'catalog', $data, WEEK_IN_SECONDS );388 } 389 390 protected static function s tore_in_cache( $url, $type, $data, $expires_after ) {407 self::save_in_cache( $url, 'categories', $data, WEEK_IN_SECONDS ); 408 } 409 410 public static function save_in_static_pages_cache( $url, $data ) { 411 self::save_in_cache( $url, 'catalog', $data, WEEK_IN_SECONDS ); 412 } 413 414 protected static function save_in_cache( $url, $type, $data, $expires_after ) { 391 415 $name = self::_build_cache_name( $url, $type ); 392 416 -
ecwid-shopping-cart/tags/6.12.15/readme.txt
r3112458 r3116030 154 154 155 155 == Changelog == 156 = 6.12.15 - Jul 10, 2024 = 157 - After the last update, the our ecommerce plugin could cause an issue with urls and an issue with loading the admin area. We have fixed these issues. 158 156 159 = 6.12.14 - Jul 2, 2024 = 157 160 - Fixed issues with slow loading of storefront pages that were observed in certain scenarios when using our ecommerce plugin. -
ecwid-shopping-cart/trunk/ecwid-shopping-cart.php
r3110860 r3116030 6 6 Text Domain: ecwid-shopping-cart 7 7 Author: Ecwid Ecommerce 8 Version: 6.12.1 48 Version: 6.12.15 9 9 Author URI: https://ecwid.to/ecwid-site 10 10 License: GPLv2 or later … … 2413 2413 2414 2414 $query_params = array( 2415 'hidden_categories' => true 2415 'hidden_categories' => true, 2416 'responseFields' => 'total,count,items(id,name,url,enabled,parentId)' 2416 2417 ); 2417 2418 … … 2448 2449 } 2449 2450 } 2450 2451 $parents = array();2452 2451 2453 2452 $result = array(); -
ecwid-shopping-cart/trunk/includes/class-ecwid-admin-storefront-page.php
r3002218 r3116030 33 33 34 34 if ( $page_id && ! isset( $page_status ) ) { 35 36 35 $page_data = self::get_page_data( $page_id ); 37 36 extract( $page_data, EXTR_PREFIX_ALL, 'page' ); … … 71 70 72 71 $api = new Ecwid_Api_V3(); 73 $res = $api->get_products( array( ) );72 $res = $api->get_products( array( 'responseFields' => 'total,count,items(id,name)' ) ); 74 73 if ( $res ) { 75 74 $products = $res->items; … … 97 96 wp_enqueue_script( 'ecwid-admin-storefront-js', ECWID_PLUGIN_URL . 'js/admin-storefront.js', array(), get_option( 'ecwid_plugin_version' ) ); 98 97 99 wp_localize_script(100 'ecwid-admin-storefront-js',101 'EcwidAdminStorefront', 102 array(103 '_ajax_nonce' => wp_create_nonce( self::NONCE_SLUG ) 104 )105 );98 wp_localize_script( 99 'ecwid-admin-storefront-js', 100 'EcwidAdminStorefront', 101 array( 102 '_ajax_nonce' => wp_create_nonce( self::NONCE_SLUG ), 103 ) 104 ); 106 105 107 106 Ecwid_Admin_UI_Framework::print_fix_js(); … … 131 130 132 131 public function ajax_set_status() { 133 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {134 die();135 }132 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) { 133 die(); 134 } 136 135 137 136 if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) { … … 173 172 174 173 public function ajax_set_store_on_front() { 175 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {176 die();177 }174 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) { 175 die(); 176 } 178 177 179 178 if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) { … … 208 207 209 208 public function ajax_set_mainpage() { 210 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {211 die();212 }209 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) { 210 die(); 211 } 213 212 214 213 if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) { … … 245 244 246 245 public function ajax_set_display_cart_icon() { 247 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {248 die();249 }246 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) { 247 die(); 248 } 250 249 251 250 if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) { … … 266 265 267 266 public function ajax_set_page_slug() { 268 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {269 die();270 }267 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) { 268 die(); 269 } 271 270 272 271 if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) { … … 316 315 317 316 public function ajax_create_page() { 318 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {319 die();320 }317 if ( ! check_ajax_referer( self::NONCE_SLUG ) ) { 318 die(); 319 } 321 320 322 321 if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) { … … 480 479 481 480 if ( version_compare( $version, '5.0' ) < 0 ) { 482 483 481 if ( is_plugin_active( 'gutenberg/gutenberg.php' ) ) { 484 482 return true; … … 573 571 } 574 572 575 echo sprintf( '<li><a%s>%s</a></li>', wp_kses_post( $attributes ), esc_html( $text ) );573 printf( '<li><a%s>%s</a></li>', wp_kses_post( $attributes ), esc_html( $text ) ); 576 574 }//end foreach 577 575 } -
ecwid-shopping-cart/trunk/includes/class-ecwid-nav-menus.php
r3021774 r3116030 241 241 $posts = array(); 242 242 $api = new Ecwid_Api_V3(); 243 $result = $api->get_categories( array( 'parent' => 0 ) ); 243 $result = $api->get_categories( 244 array( 245 'parent' => 0, 246 'responseFields' => 'total,count,items(id,name,url,nameTranslated,orderBy)', 247 ) 248 ); 244 249 245 250 if ( $result && $result->count > 0 ) { -
ecwid-shopping-cart/trunk/includes/class-ecwid-seo-links.php
r3110860 r3116030 330 330 331 331 public function build_rewrite_rules( $rules ) { 332 $new_rules = array(); 332 $new_rules = array(); 333 $additional_rules = array(); 333 334 334 335 $all_base_urls = $this->_build_all_base_urls(); -
ecwid-shopping-cart/trunk/includes/class-ecwid-static-page.php
r3110860 r3116030 181 181 $cached_data->cssFiles = array( $dynamic_css ); //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 182 182 183 EcwidPlatform::s tore_in_static_pages_cache( $url, $cached_data );183 EcwidPlatform::save_in_static_pages_cache( $url, $cached_data ); 184 184 } 185 185 … … 222 222 } 223 223 224 EcwidPlatform::encode_fields_with_emoji( 225 $fetched_data, 226 array( 'htmlCode', 'metaDescriptionHtml', 'ogTagsHtml', 'jsonLDHtml' ) 227 ); 228 224 229 if ( isset( $fetched_data->lastUpdated ) ) { 225 230 $last_update = substr( $fetched_data->lastUpdated, 0, -3 ); … … 230 235 231 236 EcwidPlatform::invalidate_static_pages_cache_from( $last_update ); 232 EcwidPlatform::s tore_in_static_pages_cache( $url, $fetched_data );237 EcwidPlatform::save_in_static_pages_cache( $url, $fetched_data ); 233 238 234 239 return $fetched_data; -
ecwid-shopping-cart/trunk/includes/gutenberg/class-ecwid-gutenberg-block-store.php
r3093942 r3116030 287 287 }//end foreach 288 288 289 $categories = ecwid_get_categories_for_selector(); 290 291 if ( $categories ) { 292 $attributes['default_category_id']['values'] = array( 293 array( 294 'value' => '0', 295 'title' => __( 'Store root category', 'ecwid-shopping-cart' ), 296 ), 297 ); 298 foreach ( $categories as $category ) { 299 if ( empty( $category->enabled ) ) { 300 continue; 301 } 302 303 $attributes['default_category_id']['values'][] = array( 304 'value' => $category->id, 305 'title' => $category->name, 289 if ( is_admin() ) { 290 $categories = ecwid_get_categories_for_selector(); 291 292 if ( $categories ) { 293 $attributes['default_category_id']['values'] = array( 294 array( 295 'value' => '0', 296 'title' => __( 'Store root category', 'ecwid-shopping-cart' ), 297 ), 306 298 ); 307 } 308 309 $attributes['default_category_id']['default'] = ''; 310 } else { 311 $api = new Ecwid_Api_V3(); 312 $cats = $api->get_categories( array() ); 313 314 if ( $cats && $cats->total == 0 ) { 315 unset( $attributes['default_category_id'] ); 316 } 299 foreach ( $categories as $category ) { 300 if ( empty( $category->enabled ) ) { 301 continue; 302 } 303 304 $attributes['default_category_id']['values'][] = array( 305 'value' => $category->id, 306 'title' => $category->name, 307 ); 308 } 309 310 $attributes['default_category_id']['default'] = ''; 311 } else { 312 $api = new Ecwid_Api_V3(); 313 $cats = $api->get_categories( array() ); 314 315 if ( $cats && $cats->total == 0 ) { 316 unset( $attributes['default_category_id'] ); 317 } 318 }//end if 317 319 }//end if 318 320 -
ecwid-shopping-cart/trunk/includes/themes/class-ecwid-theme-base.php
r2813294 r3116030 68 68 69 69 if ( in_array( 'title', $props, true ) ) { 70 71 70 $store_page_params = Ecwid_Store_Page::get_store_page_params(); 72 71 73 if ( @$store_page_params['product_details_show_product_name']) {72 if ( ! empty( $store_page_params['product_details_show_product_name'] ) ) { 74 73 add_filter( 'option_' . Ecwid_Store_Page::OPTION_REPLACE_TITLE, '__return_false' ); 75 74 } … … 126 125 ); 127 126 } 128 129 127 } -
ecwid-shopping-cart/trunk/lib/ecwid_api_v3.php
r3059103 r3116030 164 164 } 165 165 166 $passthru = array( 'offset', 'limit', 'parent', 'baseUrl', 'cleanUrls', 'hidden_categories' );166 $passthru = array( 'offset', 'limit', 'parent', 'baseUrl', 'cleanUrls', 'hidden_categories', 'responseFields' ); 167 167 foreach ( $passthru as $name ) { 168 168 if ( array_key_exists( $name, $input_params ) ) { … … 190 190 if ( ! $result ) { 191 191 $result = EcwidPlatform::fetch_url( $url, $options ); 192 } 193 194 if ( $result['code'] != '200' ) { 195 return false; 196 } 197 198 EcwidPlatform::store_in_categories_cache( $url, $result ); 192 193 if ( $result['code'] != '200' ) { 194 return false; 195 } 196 197 // PLUGINS-6870 there's some cases when data are not cached because emojis, need to encode 198 $data = json_decode( $result['data'] ); 199 200 if ( ! empty( $data->items ) ) { 201 foreach ( $data->items as &$item ) { 202 $item = EcwidPlatform::encode_fields_with_emoji( 203 $item, 204 array( 'name', 'nameTranslated', 'description', 'descriptionTranslated', 'seoTitle', 'seoTitleTranslated', 'seoDescription', 'seoDescriptionTranslated', 'alt' ) 205 ); 206 } 207 } 208 209 $result['data'] = wp_json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); 210 // end PLUGINS-6870 there's some cases when data are not cached because emojis, need to encode 211 212 EcwidPlatform::store_in_categories_cache( $url, $result ); 213 }//end if 199 214 200 215 $result = json_decode( $result['data'] ); … … 249 264 if ( ! $result ) { 250 265 $result = EcwidPlatform::fetch_url( $url, $options ); 251 } 252 253 if ( $result['code'] != '200' ) { 254 return false; 255 } 256 257 EcwidPlatform::store_in_categories_cache( $url, $result ); 266 267 if ( $result['code'] != '200' ) { 268 return false; 269 } 270 271 // PLUGINS-6870 there's some cases when data are not cached because emojis, need to encode 272 $data = json_decode( $result['data'] ); 273 if ( ! empty( $data ) ) { 274 $data = EcwidPlatform::encode_fields_with_emoji( 275 $data, 276 array( 'name', 'nameTranslated', 'description', 'descriptionTranslated', 'seoTitle', 'seoTitleTranslated', 'seoDescription', 'seoDescriptionTranslated', 'alt' ) 277 ); 278 } 279 // end PLUGINS-6870 there's some cases when data are not cached because emojis, need to encode 280 281 $result['data'] = wp_json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); 282 283 EcwidPlatform::store_in_categories_cache( $url, $result ); 284 }//end if 258 285 259 286 $result = json_decode( $result['data'] ); … … 398 425 $params = array(); 399 426 400 $passthru = array( 'updatedFrom', 'offset', 'limit', 'sortBy', 'keyword', 'createdFrom', 'createdTo', 'sku', 'enabled' );427 $passthru = array( 'updatedFrom', 'offset', 'limit', 'sortBy', 'keyword', 'createdFrom', 'createdTo', 'sku', 'enabled', 'responseFields' ); 401 428 402 429 foreach ( $passthru as $name ) { … … 601 628 602 629 $profile = json_decode( $result['data'] ); 630 631 // PLUGINS-6870 there's some cases when data are not cached because emojis, need to encode 632 if ( ! empty( $profile ) ) { 633 $profile->settings = EcwidPlatform::encode_fields_with_emoji( 634 $profile->settings, 635 array( 'storeName', 'storeDescription', 'storeDescriptionTranslated', 'rootCategorySeoTitleTranslated', 'rootCategorySeoDescription', 'rootCategorySeoDescriptionTranslated' ) 636 ); 637 } 638 // end PLUGINS-6870 there's some cases when data are not cached because emojis, need to encode 603 639 604 640 EcwidPlatform::cache_set( self::PROFILE_CACHE_NAME, $profile, 10 * MINUTE_IN_SECONDS ); -
ecwid-shopping-cart/trunk/lib/ecwid_catalog.php
r2640505 r3116030 1 1 <?php 2 2 3 class EcwidCatalog 4 { 5 var $store_id = 0;3 class EcwidCatalog { 4 5 var $store_id = 0; 6 6 var $store_base_url = ''; 7 7 8 public function __construct($store_id, $store_base_url) 9 { 10 $this->store_id = intval($store_id); 11 $this->store_base_url = $store_base_url; 8 public function __construct( $store_id, $store_base_url ) { 9 $this->store_id = intval( $store_id ); 10 $this->store_base_url = $store_base_url; 12 11 } 13 12 14 public function warmup_store_page( $category_id ) 15 { 13 public function warmup_store_page( $category_id ) { 16 14 $this->_get_data_for_category( $category_id, null ); 17 15 } 18 19 public function get_product($id)20 {21 $result = $this->_get_data_for_product($id);22 16 23 if ( !$result ) { 17 public function get_product( $id ) { 18 $result = $this->_get_data_for_product( $id ); 19 20 if ( ! $result ) { 24 21 return ''; 25 22 } 26 23 27 24 ob_start(); 28 25 $product = $result->product; 29 26 $formats = $result->formats; 30 require dirname(__FILE__) . '/html-catalog-templates/product.php'; 31 32 $return = ob_get_contents(); 33 ob_end_clean(); 34 35 return $return; 36 } 37 38 public function get_category($id) 39 { 40 $offset = ( isset($_GET['offset']) ) ? intval($_GET['offset']) : 0; 41 $data = $this->_get_data_for_category( $id, $offset ); 42 43 if ( !$data ) { 44 return ''; 45 } 46 47 $main_category = null; 48 if ($id > 0) { 49 $main_category = $data->main_category; 50 } 51 $categories = $data->categories; 52 $products = $data->products; 53 $formats = $data->formats; 54 55 ob_start(); 56 require dirname(__FILE__) . '/html-catalog-templates/category.php'; 27 require __DIR__ . '/html-catalog-templates/product.php'; 57 28 58 29 $return = ob_get_contents(); … … 62 33 } 63 34 64 protected function _get_data_for_product( $id ) 65 { 35 public function get_category( $id ) { 36 $offset = ( isset( $_GET['offset'] ) ) ? intval( $_GET['offset'] ) : 0; 37 $data = $this->_get_data_for_category( $id, $offset ); 38 39 if ( ! $data ) { 40 return ''; 41 } 42 43 $main_category = null; 44 if ( $id > 0 ) { 45 $main_category = $data->main_category; 46 } 47 $categories = $data->categories; 48 $products = $data->products; 49 $formats = $data->formats; 50 51 ob_start(); 52 require __DIR__ . '/html-catalog-templates/category.php'; 53 54 $return = ob_get_contents(); 55 ob_end_clean(); 56 57 return $return; 58 } 59 60 protected function _get_data_for_product( $id ) { 66 61 if ( Ecwid_Api_V3::is_available() ) { 67 62 $api = new Ecwid_Api_V3(); 68 63 69 64 $product = Ecwid_Product::get_by_id( $id ); 70 65 71 66 $profile = $api->get_store_profile(); 72 73 if ( !$profile) {67 68 if ( ! $profile ) { 74 69 return null; 75 70 } 76 71 77 72 return (object) array( 78 73 'product' => $product, 79 'formats' => @$profile->formatsAndUnits 74 'formats' => @$profile->formatsAndUnits, 80 75 ); 81 } 82 76 } 77 83 78 return null; 84 79 } 85 86 protected function _get_data_for_category( $id, $offset = 0 ) 87 { 80 81 protected function _get_data_for_category( $id, $offset = 0 ) { 88 82 if ( Ecwid_Api_V3::is_available() ) { 89 83 $api = new Ecwid_Api_V3(); 90 84 91 85 $main_category = null; 92 if ( $id > 0) {86 if ( $id > 0 ) { 93 87 $main_category = $api->get_category( $id ); 94 88 } 95 89 96 90 $get_categories_params = array( 97 'parent' => $id 91 'parent' => $id, 98 92 ); 99 if ( $offset && $offset > 0) {93 if ( $offset && $offset > 0 ) { 100 94 $get_categories_params['offset'] = $offset; 101 95 } 102 96 $categories = $api->get_categories( $get_categories_params ); 103 97 104 98 $get_products_params = array( 105 'category' => $id 99 'category' => $id, 106 100 ); 107 if ( $offset) {101 if ( $offset ) { 108 102 $get_products_params['offset'] = $offset; 109 103 } 110 104 $products = $api->search_products( $get_products_params ); 111 105 112 106 $profile = $api->get_store_profile(); 113 114 if ( is_null( $profile ) || ! isset( $categories->items ) || !isset( $products->items ) ) {107 108 if ( is_null( $profile ) || ! isset( $categories->items ) || ! isset( $products->items ) ) { 115 109 return null; 116 110 } 117 111 118 112 return (object) array( 119 113 'main_category' => $main_category, 120 'categories' => $categories->items,121 'products' => $products->items,122 'formats' => @$profile->formatsAndUnits114 'categories' => $categories->items, 115 'products' => $products->items, 116 'formats' => @$profile->formatsAndUnits, 123 117 ); 124 } 125 118 }//end if 119 126 120 return null; 127 121 } 128 129 public function parse_escaped_fragment($escaped_fragment)130 {131 $fragment = urldecode($escaped_fragment);132 $return = array();133 122 134 if (preg_match('/^(\/~\/)([a-z]+)\/(.*)$/', $fragment, $matches)) { 135 parse_str($matches[3], $return); 123 public function parse_escaped_fragment( $escaped_fragment ) { 124 $fragment = urldecode( $escaped_fragment ); 125 $return = array(); 126 127 if ( preg_match( '/^(\/~\/)([a-z]+)\/(.*)$/', $fragment, $matches ) ) { 128 parse_str( $matches[3], $return ); 136 129 $return['mode'] = $matches[2]; 137 } elseif ( preg_match('!.*/(p|c)/([0-9]*)!', $fragment, $matches)) {138 if ( count($matches) == 3 && in_array($matches[1], array('p', 'c'))) {139 $return = array(130 } elseif ( preg_match( '!.*/(p|c)/([0-9]*)!', $fragment, $matches ) ) { 131 if ( count( $matches ) == 3 && in_array( $matches[1], array( 'p', 'c' ) ) ) { 132 $return = array( 140 133 'mode' => 'p' == $matches[1] ? 'product' : 'category', 141 'id' => $matches[2]134 'id' => $matches[2], 142 135 ); 143 136 } -
ecwid-shopping-cart/trunk/lib/ecwid_platform.php
r3110860 r3116030 226 226 ) 227 227 ); 228 self::encode_emoji( $value );229 228 230 229 set_transient( 'ecwid_' . $name, $value, $expires_after ); 231 230 } 232 231 232 public static function encode_fields_with_emoji( $data, $properties = array() ) { 233 if ( ! is_object( $data ) ) { 234 return $data; 235 } 236 237 if ( ! is_array( $properties ) ) { 238 return $data; 239 } 240 241 foreach ( $properties as $property ) { 242 if ( ! empty( $data->$property ) ) { 243 if ( is_string( $data->$property ) ) { 244 $data->$property = wp_encode_emoji( $data->$property ); 245 } else { 246 self::encode_emoji( $data->$property ); 247 } 248 } 249 } 250 return $data; 251 } 252 233 253 public static function encode_emoji( &$item, $key = false ) { //phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed 254 if ( empty( $item ) ) { 255 return; 256 } 257 234 258 if ( is_object( $item ) || is_array( $item ) ) { 235 259 array_walk_recursive( $item, 'self::encode_emoji' ); … … 306 330 } 307 331 308 if ( $return['code'] == 200 ) {332 if ( $return['code'] == 200 && $api_check_retry_after !== 0 ) { 309 333 update_option( self::OPTION_ECWID_CHECK_API_RETRY_AFTER, 0 ); 310 334 } … … 377 401 378 402 public static function store_in_products_cache( $url, $data ) { 379 self::s tore_in_cache( $url, 'products', $data, WEEK_IN_SECONDS );403 self::save_in_cache( $url, 'products', $data, WEEK_IN_SECONDS ); 380 404 } 381 405 382 406 public static function store_in_categories_cache( $url, $data ) { 383 self::s tore_in_cache( $url, 'categories', $data, WEEK_IN_SECONDS );384 } 385 386 public static function s tore_in_static_pages_cache( $url, $data ) {387 self::s tore_in_cache( $url, 'catalog', $data, WEEK_IN_SECONDS );388 } 389 390 protected static function s tore_in_cache( $url, $type, $data, $expires_after ) {407 self::save_in_cache( $url, 'categories', $data, WEEK_IN_SECONDS ); 408 } 409 410 public static function save_in_static_pages_cache( $url, $data ) { 411 self::save_in_cache( $url, 'catalog', $data, WEEK_IN_SECONDS ); 412 } 413 414 protected static function save_in_cache( $url, $type, $data, $expires_after ) { 391 415 $name = self::_build_cache_name( $url, $type ); 392 416 -
ecwid-shopping-cart/trunk/readme.txt
r3112458 r3116030 154 154 155 155 == Changelog == 156 = 6.12.15 - Jul 10, 2024 = 157 - After the last update, the our ecommerce plugin could cause an issue with urls and an issue with loading the admin area. We have fixed these issues. 158 156 159 = 6.12.14 - Jul 2, 2024 = 157 160 - Fixed issues with slow loading of storefront pages that were observed in certain scenarios when using our ecommerce plugin.
Note: See TracChangeset
for help on using the changeset viewer.