Skip to content

Commit

Permalink
Bug fixes and code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mnestorov authored Nov 15, 2024
1 parent 6415f96 commit 13bcf5b
Showing 1 changed file with 47 additions and 34 deletions.
81 changes: 47 additions & 34 deletions smarty-performance-improvements-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* WC tested up to: 9.4
*/

// If this file is called directly, abort.
if (!defined('WPINC')) {
die;
}
Expand Down Expand Up @@ -236,11 +237,13 @@ function smarty_remove_dashboard_widgets() {
}
}

/**
* Disable the setup widget.
*/
function smarty_disable_setup_widget() {
remove_meta_box('wc_admin_dashboard_setup', 'dashboard', 'normal');
if (!function_exists('smarty_disable_setup_widget')) {
/**
* Disable the setup widget.
*/
function smarty_disable_setup_widget() {
remove_meta_box('wc_admin_dashboard_setup', 'dashboard', 'normal');
}
}

if (!function_exists('smarty_disable_woocommerce_widgets')) {
Expand Down Expand Up @@ -281,23 +284,27 @@ function smarty_disable_woocommerce_com_notice() {
}
}

/**
* Hide "Marketplace" and "My Subscriptions" submenus.
*/
function smarty_hide_woocommerce_menus() {
remove_submenu_page('woocommerce', 'wc-addons');
remove_submenu_page('woocommerce', 'wc-addons&section=helper');
if (!function_exists('smarty_hide_woocommerce_menus')) {
/**
* Hide "Marketplace" and "My Subscriptions" submenus.
*/
function smarty_hide_woocommerce_menus() {
remove_submenu_page('woocommerce', 'wc-addons');
remove_submenu_page('woocommerce', 'wc-addons&section=helper');
}
}

/**
* Disable WooCommerce Marketing Hub.
*/
function smarty_disable_marketing_hub($features) {
$key = array_search('marketing', $features);
if ($key !== false) {
unset($features[$key]);
if (!function_exists('smarty_disable_marketing_hub')) {
/**
* Disable WooCommerce Marketing Hub.
*/
function smarty_disable_marketing_hub($features) {
$key = array_search('marketing', $features);
if ($key !== false) {
unset($features[$key]);
}
return $features;
}
return $features;
}

if (!function_exists('smarty_disable_stripe_scripts')) {
Expand All @@ -314,23 +321,29 @@ function smarty_disable_stripe_scripts() {
}
}

/**
* Deregister unnecessary scripts.
*/
function smarty_deregister_woocommerce_scripts() {
wp_dequeue_script('wc-password-strength-meter');
if (!function_exists('smarty_deregister_woocommerce_scripts')) {
/**
* Deregister unnecessary scripts.
*/
function smarty_deregister_woocommerce_scripts() {
wp_dequeue_script('wc-password-strength-meter');
}
}

/**
* Increase CSV batch export limit.
*/
function smarty_increase_csv_batch_limit() {
return 5000;
if (!function_exists('smarty_increase_csv_batch_limit')) {
/**
* Increase CSV batch export limit.
*/
function smarty_increase_csv_batch_limit() {
return 5000;
}
}

/**
* Clear unused WooCommerce tracker cron job.
*/
function smarty_clear_unused_cron_jobs() {
wp_clear_scheduled_hook('woocommerce_tracker_send_event');
if (!function_exists('smarty_clear_unused_cron_jobs')) {
/**
* Clear unused WooCommerce tracker cron job.
*/
function smarty_clear_unused_cron_jobs() {
wp_clear_scheduled_hook('woocommerce_tracker_send_event');
}
}

0 comments on commit 13bcf5b

Please sign in to comment.