Skip to content

Commit 13bcf5b

Browse files
authored
Bug fixes and code improvements
1 parent 6415f96 commit 13bcf5b

File tree

1 file changed

+47
-34
lines changed

1 file changed

+47
-34
lines changed

smarty-performance-improvements-for-woocommerce.php

+47-34
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* WC tested up to: 9.4
1616
*/
1717

18+
// If this file is called directly, abort.
1819
if (!defined('WPINC')) {
1920
die;
2021
}
@@ -236,11 +237,13 @@ function smarty_remove_dashboard_widgets() {
236237
}
237238
}
238239

239-
/**
240-
* Disable the setup widget.
241-
*/
242-
function smarty_disable_setup_widget() {
243-
remove_meta_box('wc_admin_dashboard_setup', 'dashboard', 'normal');
240+
if (!function_exists('smarty_disable_setup_widget')) {
241+
/**
242+
* Disable the setup widget.
243+
*/
244+
function smarty_disable_setup_widget() {
245+
remove_meta_box('wc_admin_dashboard_setup', 'dashboard', 'normal');
246+
}
244247
}
245248

246249
if (!function_exists('smarty_disable_woocommerce_widgets')) {
@@ -281,23 +284,27 @@ function smarty_disable_woocommerce_com_notice() {
281284
}
282285
}
283286

284-
/**
285-
* Hide "Marketplace" and "My Subscriptions" submenus.
286-
*/
287-
function smarty_hide_woocommerce_menus() {
288-
remove_submenu_page('woocommerce', 'wc-addons');
289-
remove_submenu_page('woocommerce', 'wc-addons&section=helper');
287+
if (!function_exists('smarty_hide_woocommerce_menus')) {
288+
/**
289+
* Hide "Marketplace" and "My Subscriptions" submenus.
290+
*/
291+
function smarty_hide_woocommerce_menus() {
292+
remove_submenu_page('woocommerce', 'wc-addons');
293+
remove_submenu_page('woocommerce', 'wc-addons&section=helper');
294+
}
290295
}
291296

292-
/**
293-
* Disable WooCommerce Marketing Hub.
294-
*/
295-
function smarty_disable_marketing_hub($features) {
296-
$key = array_search('marketing', $features);
297-
if ($key !== false) {
298-
unset($features[$key]);
297+
if (!function_exists('smarty_disable_marketing_hub')) {
298+
/**
299+
* Disable WooCommerce Marketing Hub.
300+
*/
301+
function smarty_disable_marketing_hub($features) {
302+
$key = array_search('marketing', $features);
303+
if ($key !== false) {
304+
unset($features[$key]);
305+
}
306+
return $features;
299307
}
300-
return $features;
301308
}
302309

303310
if (!function_exists('smarty_disable_stripe_scripts')) {
@@ -314,23 +321,29 @@ function smarty_disable_stripe_scripts() {
314321
}
315322
}
316323

317-
/**
318-
* Deregister unnecessary scripts.
319-
*/
320-
function smarty_deregister_woocommerce_scripts() {
321-
wp_dequeue_script('wc-password-strength-meter');
324+
if (!function_exists('smarty_deregister_woocommerce_scripts')) {
325+
/**
326+
* Deregister unnecessary scripts.
327+
*/
328+
function smarty_deregister_woocommerce_scripts() {
329+
wp_dequeue_script('wc-password-strength-meter');
330+
}
322331
}
323332

324-
/**
325-
* Increase CSV batch export limit.
326-
*/
327-
function smarty_increase_csv_batch_limit() {
328-
return 5000;
333+
if (!function_exists('smarty_increase_csv_batch_limit')) {
334+
/**
335+
* Increase CSV batch export limit.
336+
*/
337+
function smarty_increase_csv_batch_limit() {
338+
return 5000;
339+
}
329340
}
330341

331-
/**
332-
* Clear unused WooCommerce tracker cron job.
333-
*/
334-
function smarty_clear_unused_cron_jobs() {
335-
wp_clear_scheduled_hook('woocommerce_tracker_send_event');
342+
if (!function_exists('smarty_clear_unused_cron_jobs')) {
343+
/**
344+
* Clear unused WooCommerce tracker cron job.
345+
*/
346+
function smarty_clear_unused_cron_jobs() {
347+
wp_clear_scheduled_hook('woocommerce_tracker_send_event');
348+
}
336349
}

0 commit comments

Comments
 (0)