Skip to content

Commit

Permalink
Merge pull request #299 from Ecwid/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
meteor-ec authored Oct 3, 2024
2 parents c68e699 + 3aa910b commit bffea18
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 460 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
== Changelog ==
= 6.12.20 - Oct 3, 2024 =
- In the "Only featured products" mode, the "Store Home Page" ecommerce block was displayed incorrectly. We've fixed this.
- Fixed an issue with the "Manage access to store control panel" feature where in some cases users couldn't have access to embedded store control panel.
- Internal improvements and optimizations.

= 6.12.19 - Sep 11, 2024 =
- Fixed an issue with processing some store pages links.
- Internal improvements and optimizations.
Expand Down
8 changes: 5 additions & 3 deletions ecwid-shopping-cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Description: Ecwid by Lightspeed is a free full-featured shopping cart. It can be easily integrated with any Wordpress blog and takes less than 5 minutes to set up.
Text Domain: ecwid-shopping-cart
Author: Ecwid Ecommerce
Version: 6.12.19
Version: 6.12.20
Author URI: https://ecwid.to/ecwid-site
License: GPLv2 or later
*/
Expand Down Expand Up @@ -108,11 +108,11 @@
require_once ECWID_PLUGIN_DIR . 'lib/ecwid_api_v3.php';

require_once ECWID_PLUGIN_DIR . 'includes/themes.php';
require_once ECWID_PLUGIN_DIR . 'includes/oembed.php';
require_once ECWID_PLUGIN_DIR . 'includes/widgets.php';
require_once ECWID_PLUGIN_DIR . 'includes/shortcodes.php';
require_once ECWID_PLUGIN_DIR . 'includes/kliken.php';

require_once ECWID_PLUGIN_DIR . 'includes/class-ec-store-oembed.php';
require_once ECWID_PLUGIN_DIR . 'includes/class-ecwid-message-manager.php';
require_once ECWID_PLUGIN_DIR . 'includes/class-ecwid-store-editor.php';
require_once ECWID_PLUGIN_DIR . 'includes/class-ecwid-product-popup.php';
Expand Down Expand Up @@ -1638,10 +1638,11 @@ function ecwid_plugin_activation_redirect( $plugin ) {
&& count($_POST['checked']) > 1;

$is_cli_running = Ecwid_Config::is_cli_running();
$is_wp_playground = Ecwid_Config::is_wp_playground_running();

$is_newbie = ecwid_is_demo_store();

if( !$is_cli_running && !$is_bulk_activation && $is_newbie && $plugin == plugin_basename( __FILE__ ) ) {
if( !$is_cli_running && $is_wp_playground && !$is_bulk_activation && $is_newbie && $plugin == plugin_basename( __FILE__ ) ) {
wp_safe_redirect( Ecwid_Admin::get_dashboard_url() );
exit();
}
Expand Down Expand Up @@ -2987,6 +2988,7 @@ function ecwid_update_store_id( $new_store_id ) {

function ecwid_is_paid_account()
{
return false;
if ( Ecwid_Api_V3::is_available() ) {
$api = new Ecwid_Api_V3();

Expand Down
5 changes: 4 additions & 1 deletion includes/class-ec-store-admin-access.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ public function save_custom_user_profile_fields( $user_id ) {
}

public static function get_users_with_manage_access() {
global $wpdb;
$table_prefix = $wpdb->prefix;

$args = array(
'meta_query' => array( //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
array(
'key' => 'wp_capabilities',
'key' => $table_prefix . 'capabilities',
'value' => self::CAP_MANAGE_CONTROL_PANEL . '";b:1',
'compare' => 'LIKE',
),
Expand Down
100 changes: 100 additions & 0 deletions includes/class-ec-store-oembed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php
class Ec_Store_Oembed {

public static function print_content( $data ) { //phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
echo self::get_content(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}

public static function get_content() {
$post_content = get_post( get_the_ID() )->post_content;
$shortcodes = array();

foreach ( Ecwid_Shortcode_Base::get_store_shortcode_names() as $shortcode_name ) {
$shortcodes = ecwid_find_shortcodes( $post_content, $shortcode_name );
if ( $shortcodes ) {
break;
}
}

if ( ! $shortcodes || ! isset( $shortcodes[0] ) || ! isset( $shortcodes[0][3] ) ) {
return;
}

$attributes = $shortcodes[0][3];
if ( ! preg_match( '/default_category_id=.([\\d]*)./', $attributes, $matches ) ) {
return;
}

$root_category_id = intval( $matches[1] ) <= 0 ? 0 : $matches[1];

$api = new Ecwid_Api_V3();

$categories = $api->get_categories( array( 'parent' => $root_category_id ) );

$max_items = 5;

$items = array();

$see_more = false;
$result = '';
if ( ! empty( $categories->items ) ) {
foreach ( $categories->items as $category ) {
$category = Ecwid_Category::get_by_id( $category->id );
$items[ $category->link ] = $category->name;
if ( count( $items ) >= $max_items ) {
$see_more = true;
break;
}
}
}

$api = new Ecwid_Api_V3();

$category = $api->get_category( $root_category_id );

if ( $category ) {
$trimmed = ecwid_trim_description( $category->description );
$result .= '<div>' . ecwid_trim_description( $category->description );

$descr_length = function_exists( 'mb_strlen' ) ? mb_strlen( $category->description ) : strlen( $category->description );
$trimmed_length = function_exists( 'mb_strlen' ) ? mb_strlen( $trimmed ) : strlen( $trimmed );

if ( $trimmed_length < $descr_length && $trimmed_length == ECWID_TRIMMED_DESCRIPTION_LENGTH ) {
$result .= '... <a class="wp-embed-more" href="' . get_permalink() . '">' . __( 'See more', 'ecwid-shopping-cart' ) . '</a>';
}
$result .= '</div>';
}

if ( ! $see_more ) {
$products = $api->search_products( array( 'category' => $root_category_id ) );

if ( $products->items ) {
foreach ( $products->items as $product ) {
$product = Ecwid_Product::get_by_id( $product->id );
$items[ $product->link ] = $product->name;
if ( count( $items ) >= $max_items ) {
$see_more = true;
break;
}
}
}
}

$result .= '<ul>';
if ( $items ) {
foreach ( $items as $url => $title ) {
$result .= '<li><a href="' . esc_attr( $url ) . '">' . esc_html( $title ) . '</a></li>';
}
}

if ( $see_more ) {
$result .= '<li><a class="wp-embed-more" href="' . get_permalink() . '">' . __( 'See more', 'ecwid-shopping-cart' ) . '</a></li>';
}

$result .= '</ul>';

return $result;
}
}

add_filter( 'embed_content', 'Ec_Store_Oembed::print_content', 10, 1 );
4 changes: 4 additions & 0 deletions includes/class-ecwid-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ public static function is_cli_running() {
return defined( 'WP_CLI' ) && WP_CLI;
}

public static function is_wp_playground_running() {
return defined( 'IS_PLAYGROUND_PREVIEW' ) && IS_PLAYGROUND_PREVIEW;
}

public static function load_from_cli( $config ) {

if ( ! $config ) {
Expand Down
2 changes: 0 additions & 2 deletions includes/class-ecwid-product-browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ public static function get_attributes() {
}

if ( $api->is_store_feature_available( Ecwid_Api_V3::FEATURE_PRODUCT_SUBTITLES ) ) {

$attributes['product_list_subtitles_behavior'] = array(
'name' => 'product_list_subtitles_behavior',
'title' => __( 'Product subtitles', 'ecwid-shopping-cart' ),
Expand All @@ -447,7 +446,6 @@ public static function get_attributes() {
}

return $attributes;

}

protected static function _get_behaviors() {
Expand Down
2 changes: 1 addition & 1 deletion includes/class-ecwid-static-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected static function maybe_fetch_data() {
$pb_attribures[ $param ] = array(
'name' => $param,
'is_storefront_api' => true,
'type' => true,
'type' => 'boolean',
);
}
}
Expand Down
41 changes: 0 additions & 41 deletions includes/class-ecwid-store-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class Ecwid_Store_Page {
const OPTION_LAST_STORE_PAGE_ID = 'ecwid_last_store_page_id';
const OPTION_FLUSH_REWRITES = 'ecwid_flush_rewrites';
const OPTION_REPLACE_TITLE = 'ecwid_replace_title';
const WARMUP_ACTION = 'ecwid_warmup_store';

const META_STORE_DATA = 'ecwid_store';

Expand Down Expand Up @@ -398,45 +397,6 @@ protected static function _get_allowed_post_statuses() {
return array( 'publish', 'private', 'draft' );
}

public static function warmup_store() {
$store_page = get_post( self::get_current_store_page_id() );

if ( ! $store_page ) {
return;
}

$shortcodes = array();
foreach ( Ecwid_Shortcode_Base::get_store_shortcode_names() as $shortcode_name ) {
$shortcodes[] = ecwid_find_shortcodes( $store_page->post_content, $shortcode_name );
}

if ( count( $shortcodes ) === 0 ) {
return;
}

$shortcode_data = $shortcodes[0];

$category = 0;

if ( isset( $shortcode_data[3] ) ) {
$attributes = shortcode_parse_atts( $shortcode_data[3] );

if ( ! $attributes ) {
return;
}

$category = $attributes['default_category_id'];
}

$page_url = get_permalink( $store_page );

include_once ECWID_PLUGIN_DIR . 'lib/ecwid_catalog.php';

$catalog = new EcwidCatalog( get_ecwid_store_id(), $page_url );

$catalog->warmup_store_page( intval( $category ) );
}

public static $main_page_title = '';
// If you figure out a better place to put this the_title functionality, go ahead, move it =)

Expand Down Expand Up @@ -631,7 +591,6 @@ public static function delete_page_from_nav_menus() {

add_action( 'init', array( 'Ecwid_Store_Page', 'flush_rewrites' ) );
add_action( 'save_post', array( 'Ecwid_Store_Page', 'on_save_post' ) );
add_action( 'wp_ajax_' . Ecwid_Store_Page::WARMUP_ACTION, array( 'Ecwid_Store_Page', 'warmup_store' ) );
add_action( 'update_option_page_on_front', array( 'Ecwid_Store_Page', 'schedule_flush_rewrites' ) );
add_action( 'display_post_states', array( 'Ecwid_Store_Page', 'display_post_states' ), 10, 2 );

Expand Down
123 changes: 0 additions & 123 deletions includes/oembed.php

This file was deleted.

Loading

0 comments on commit bffea18

Please sign in to comment.