|
6 | 6 |
|
7 | 7 | // Show Admin notice if Woocommerce plugin isn't installed. |
8 | 8 |
|
9 | | -function cbwct_notice_for_wc_admin_notice(){ |
10 | | - |
11 | | - if (!class_exists( 'WooCommerce' )) { |
12 | | - if( ! function_exists('get_plugin_data') ){ |
13 | | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
14 | | - } |
15 | | - $plugin_data = get_plugin_data( CBWCT_TRACKER_PATH .'cbwct.php' ); |
16 | | - $woo_url = 'https://wordpress.org/plugins/woocommerce/'; |
17 | | - |
18 | | - printf('<div class="notice notice-error"> |
19 | | - <p><a href="%s" target="_blank">Woocommerce</a> Is Required! Woocommerce plugin needs to activated if you want to install the <strong>"%s"</strong> plugin.</p> |
20 | | - </div>', $woo_url, $plugin_data['Name']); |
21 | | - }else { |
22 | | - return false; |
23 | | - } |
24 | | - |
| 9 | +function cbwct_notice_for_wc_admin_notice() { |
| 10 | + // Check if WooCommerce is not active |
| 11 | + if (!class_exists('WooCommerce')) { |
| 12 | + // Include the plugin.php file if the get_plugin_data function is not available |
| 13 | + if (!function_exists('get_plugin_data')) { |
| 14 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
| 15 | + } |
| 16 | + |
| 17 | + // Get plugin data |
| 18 | + $plugin_data = get_plugin_data(CBWCT_TRACKER_PATH . 'cbwct.php'); |
| 19 | + $woo_url = 'https://wordpress.org/plugins/woocommerce/'; |
| 20 | + |
| 21 | + // Display the admin notice with proper translation and escaping |
| 22 | + printf( |
| 23 | + '<div class="notice notice-error"> |
| 24 | + <p>%s</p> |
| 25 | + </div>', |
| 26 | + sprintf( |
| 27 | + /* translators: %1$s is the WooCommerce link, %2$s is the plugin name */ |
| 28 | + esc_html__('The %2$s plugin requires WooCommerce to be installed and activated. Please install and activate WooCommerce from %1$s.', 'cbwet'), |
| 29 | + '<a href="' . esc_url($woo_url) . '" target="_blank">' . esc_html__('the WordPress plugin repository', 'cbwet') . '</a>', |
| 30 | + esc_html($plugin_data['Name']) |
| 31 | + ) |
| 32 | + ); |
| 33 | + } else { |
| 34 | + return false; |
| 35 | + } |
25 | 36 | } |
26 | 37 | add_action('admin_notices', 'cbwct_notice_for_wc_admin_notice'); |
27 | 38 |
|
28 | 39 |
|
29 | 40 |
|
| 41 | + |
30 | 42 | if(!class_exists('CBWCT_ORDER_TRACKER')) { |
31 | 43 |
|
32 | 44 | final class CBWCT_ORDER_TRACKER { |
|
0 commit comments