Skip to content

Commit

Permalink
Merge pull request #296 from Ecwid/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
meteor-ec authored Sep 11, 2024
2 parents b3d068d + dc2c785 commit c68e699
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 38 deletions.
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@

.distignore
.gitignore
composer.json
CHANGELOG.txt
README.md
4 changes: 4 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
== Changelog ==
= 6.12.19 - Sep 11, 2024 =
- Fixed an issue with processing some store pages links.
- Internal improvements and optimizations.

= 6.12.18 - Aug 19, 2024 =
- Improved compatibility with pages created using the Jetpack plugin. Now ecommerce blocks added to Portfolio and Testimonial pages work as well as on regular pages.
- Fixed an issue with product option fields working on product pages. In some cases, product options were not clickable. We've fixed this.
Expand Down
16 changes: 5 additions & 11 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.18
Version: 6.12.19
Author URI: https://ecwid.to/ecwid-site
License: GPLv2 or later
*/
Expand Down Expand Up @@ -1732,6 +1732,8 @@ function ecwid_uninstall() {

EcwidPlatform::cache_reset('need_add_rewrite');
Ecwid_Store_Page::delete_page_from_nav_menus();

Ec_Store_Admin_Access::reset_all_access();
}

function ecwid_abs_intval($value) {
Expand Down Expand Up @@ -2162,26 +2164,18 @@ function ecwid_get_demo_store_id() {

$demo_stores = ecwid_get_demo_stores();

$locale = get_locale();

if ( strpos( $locale, 'ru' ) === 0 ) {
return $demo_stores['locale_ru'];
} else {
return $demo_stores['locale_other'];
}
return $demo_stores['locale_other'];
}

function ecwid_get_demo_stores() {
return $demo_stores = array(
return array(
'legacy' => 1003,
'locale_ru' => 13437191,
'locale_other' => 13433173
);
}

function ecwid_get_demo_store_public_key() {
$public_keys = array(
13437191 => 'public_LRaZBiDigZCMJquHkRWDpdAt4HPmb4zH',
13433173 => 'public_9EYLuZ15kfKEHdpsuKMsqp9MZ2Umxtcp'
);

Expand Down
50 changes: 34 additions & 16 deletions includes/class-ec-store-admin-access.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ public static function get_users_with_manage_access() {
return get_users( $args );
}

public static function get_users_with_grant_access() {
$args = array(
'capability' => self::CAP_CAN_GRANT_ACCESS,
'fields' => array( 'ID' ),
);

return get_users( $args );
}

public static function has_scope( $user_id = null ) {
$has_scope = false;

Expand Down Expand Up @@ -88,11 +97,9 @@ public function can_grant_access() {
return true;
}

$args = array(
'capability' => self::CAP_CAN_GRANT_ACCESS,
'fields' => array( 'ID' ),
);
if ( empty( get_users( $args ) ) && is_super_admin() ) {
$users = self::get_users_with_grant_access();

if ( empty( $users ) && is_super_admin() ) {
return true;
}

Expand All @@ -113,17 +120,6 @@ public function hook_admin_get_capability( $cap ) {
return $this->capability;
}

$args = array(
'meta_query' => array( //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
array(
'key' => 'wp_capabilities',
'value' => self::CAP_MANAGE_CONTROL_PANEL . '";b:1',
'compare' => 'LIKE',
),
),
'fields' => array( 'ID' ),
);

if ( ! empty( self::get_users_with_manage_access() ) ) {
$cap = self::CAP_MANAGE_CONTROL_PANEL;
}
Expand All @@ -133,6 +129,28 @@ public function hook_admin_get_capability( $cap ) {
return $cap;
}

public static function reset_all_access() {
$users = self::get_users_with_manage_access();

if ( ! empty( $users ) ) {
foreach ( $users as $user ) {
$user = new WP_User( $user->ID );
$user->remove_cap( self::CAP_MANAGE_CONTROL_PANEL );
}
}

$users = self::get_users_with_grant_access();

if ( ! empty( $users ) ) {
foreach ( $users as $user ) {
$user = new WP_User( $user->ID );
$user->remove_cap( self::CAP_CAN_GRANT_ACCESS );
}
}

return true;
}

public function print_custom_user_profile_fields( $user ) {

if ( ! $this->can_grant_access() ) {
Expand Down
24 changes: 21 additions & 3 deletions includes/class-ecwid-seo-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,28 @@ public static function get_seo_links_patterns() {
'search',
'search\?.*',
'signin',
'signOut',
'signIn.*',
'signOut.*',
'pages\/about',
'pages\/shipping-payment',
'pages\/returns',
'pages\/terms',
'pages\/privacy-policy',
'signIn.*',
'resetPassword.*',
'checkoutAB.*',
'downloadError.*',
'orderFailure.*',
'checkoutCC.*',
'checkoutEC.*',
'checkoutAC.*',
'downloadError.*',
'checkoutResult.*',
'checkoutWait.*',
'orderFailure.*',
'FBAutofillCheckout.*',
'pay.*',
'repeat-order.*',
'subscribe.*',
'unsubscribe.*',
);
}

Expand Down Expand Up @@ -502,7 +510,17 @@ public static function is_noindex_page() {
'account',
'checkout',
'signin',
'signOut',
'search',
'pages',
'downloadError',
'checkoutResult',
'checkoutWait',
'orderFailure',
'pay',
'repeat-order',
'subscribe',
'unsubscribe',
);

$home_url = home_url();
Expand Down
7 changes: 0 additions & 7 deletions includes/class-ecwid-wp-dashboard-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ public function dashboard_setup() {
$media_url = 'https://www.ecwid.com/wp-json/wp/v2/media/';
$images_cdn = 'https://web-cdn.ecwid.com/wp-content/uploads/';

$lang = ecwid_get_current_user_locale();
if ( $lang === 'ru_RU' ) {
$url = 'https://www.ecwid.ru/wp-json/wp/v2/posts?per_page=3&categories=1';
$media_url = 'https://www.ecwid.ru/wp-json/wp/v2/media/';
$images_cdn = 'https://web-cdn.ecwid.com/wp-content/uploads/ru/';
}

wp_enqueue_style( 'ecwid-dashboard-blog', ECWID_PLUGIN_URL . '/css/dashboard-blog.css', array(), get_option( 'ecwid_plugin_version' ) );

wp_enqueue_script( 'ecwid-dashboard-blog', ECWID_PLUGIN_URL . '/js/dashboard-blog.js', array( 'jquery' ), get_option( 'ecwid_plugin_version' ) );
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Requires at least: 4.4
Tested up to: 6.6
Stable tag: 6.12.18
Stable tag: 6.12.19

Powerful, easy to use ecommerce shopping cart for WordPress. Sell on Facebook and Instagram. iPhone & Android apps. Superb support. Free plan available.

Expand Down Expand Up @@ -153,6 +153,10 @@ You can use Ecwid’s built-in import tools to copy your store products from any
* [Ecwid Help Center](http://help.ecwid.com "Ecwid Help")

== Changelog ==
= 6.12.19 - Sep 11, 2024 =
- Fixed an issue with processing some store pages links.
- Internal improvements and optimizations.

= 6.12.18 - Aug 19, 2024 =
- Improved compatibility with pages created using the Jetpack plugin. Now ecommerce blocks added to Portfolio and Testimonial pages work as well as on regular pages.
- Fixed an issue with product option fields working on product pages. In some cases, product options were not clickable. We've fixed this.
Expand Down
53 changes: 53 additions & 0 deletions templates/debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,59 @@
<?php endforeach; ?>
</div>

<?php if ( class_exists( 'Ec_Store_Admin_Access' ) ) : ?>
<h2>Who can grant access to Control Panel</h2>
<div>
<p>Required capability: <?php echo Ec_Store_Admin_Access::CAP_CAN_GRANT_ACCESS; ?></p>
<?php
$args = array(
'capability' => Ec_Store_Admin_Access::CAP_CAN_GRANT_ACCESS,
'fields' => array( 'ID', 'user_nicename' ),
);
$users = get_users( $args );
if ( ! empty( $users ) ) {
echo '<ul>';
foreach ( $users as $user ) {
printf(
"<li>ID=%s <a href='%s' target='_blank'>%s</a></li>",
esc_attr( $user->ID ),
esc_attr( add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ) ),
esc_attr( $user->user_nicename )
);
}
echo '</ul>';
} else {
echo 'No one found';
}
?>
</div>
<h2>Who has an access to Control Panel</h2>
<div>
<p>Required capability: <?php echo Ec_Store_Admin_Access::CAP_MANAGE_CONTROL_PANEL; ?></p>
<?php
$args = array(
'capability' => Ec_Store_Admin_Access::CAP_MANAGE_CONTROL_PANEL,
'fields' => array( 'ID', 'user_nicename' ),
);
$users = get_users( $args );
if ( ! empty( $users ) ) {
echo '<ul>';
foreach ( $users as $user ) {
printf(
"<li>ID=%s <a href='%s' target='_blank'>%s</a></li>",
esc_attr( $user->ID ),
esc_attr( add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ) ),
esc_attr( $user->user_nicename )
);
}
echo '</ul>';
} else {
echo 'No one found';
}
?>
</div>
<?php endif; ?>


<?php if ( Ecwid_Config::is_wl() ) : ?>
<?php
Expand Down

0 comments on commit c68e699

Please sign in to comment.