| @@ -18,11 +18,8 @@ | ||
| 18 | 18 | const PLUGIN_NAME = 'ShopBuilder - Woocommerce Builder for Elementor'; |
| 19 | 19 | |
| 20 | 20 | use SingletonTrait; |
| 21 | 21 | |
| 22 | - /** | |
| 23 | - * @var array | |
| 24 | - */ | |
| 25 | 22 | private $missing = []; |
| 26 | 23 | /** |
| 27 | 24 | * @var bool |
| 28 | 25 | */ |
| @@ -50,19 +47,25 @@ | ||
| 50 | 47 | if ( ! is_plugin_active( $woocommerce ) ) { |
| 51 | 48 | if ( $this->is_plugins_installed( $woocommerce ) ) { |
| 52 | 49 | $activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $woocommerce . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $woocommerce ); |
| 53 | 50 | $message = sprintf( |
| 54 | - '<strong>%s</strong> requires <strong>WooCommerce</strong> plugin to be active. Please activate WooCommerce to continue.', | |
| 51 | + '<strong>%s</strong> %s <strong>%s</strong> %s', | |
| 55 | 52 | esc_html( self::PLUGIN_NAME ), |
| 53 | + esc_html__( 'requires', 'shopbuilder' ), | |
| 54 | + esc_html__( 'WooCommerce', 'shopbuilder' ), | |
| 55 | + esc_html__( 'plugin to be active. Please activate WooCommerce to continue.', 'shopbuilder' ) | |
| 56 | 56 | ); |
| 57 | - $button_text = 'Activate WooCommerce'; | |
| 57 | + $button_text = esc_html__( 'Activate WooCommerce', 'shopbuilder' ); | |
| 58 | 58 | } else { |
| 59 | 59 | $activation_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' ); |
| 60 | 60 | $message = sprintf( |
| 61 | - '<strong>%s</strong> requires <strong>WooCommerce</strong> plugin to be active. Please activate WooCommerce to continue.', | |
| 61 | + '<strong>%s</strong> %s <strong>%s</strong> %s', | |
| 62 | 62 | esc_html( self::PLUGIN_NAME ), |
| 63 | + esc_html__( 'requires', 'shopbuilder' ), | |
| 64 | + esc_html__( 'WooCommerce', 'shopbuilder' ), | |
| 65 | + esc_html__( 'plugin to be installed and activated. Please install WooCommerce to continue.', 'shopbuilder' ) | |
| 63 | 66 | ); |
| 64 | - $button_text = 'Install WooCommerce'; | |
| 67 | + $button_text = esc_html__( 'Install WooCommerce', 'shopbuilder' ); | |
| 65 | 68 | } |
| 66 | 69 | $this->missing['woocommerce'] = [ |
| 67 | 70 | 'name' => 'WooCommerce', |
| 68 | 71 | 'slug' => 'woocommerce', |
| @@ -73,8 +76,38 @@ | ||
| 73 | 76 | ]; |
| 74 | 77 | $this->allOk = false; |
| 75 | 78 | } |
| 76 | 79 | |
| 80 | + $elementor = 'elementor/elementor.php'; | |
| 81 | + | |
| 82 | + /* | |
| 83 | + if ( ! is_plugin_active( $elementor ) ) { | |
| 84 | + $message = sprintf( | |
| 85 | + '<strong>%s</strong> %s', | |
| 86 | + esc_html__( 'ShopBuilder - WooCommerce Builder for Elementor:', 'shopbuilder' ), | |
| 87 | + esc_html__( 'Elementor plugin is optional. Please install Elementor if you want to build WooCommerce pages using Elementor.', 'shopbuilder' ) | |
| 88 | + ); | |
| 89 | + if ( $this->is_plugins_installed( $elementor ) ) { | |
| 90 | + $activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $elementor . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $elementor ); | |
| 91 | + $button_text = esc_html__( 'Activate Elementor', 'shopbuilder' ); | |
| 92 | + } else { | |
| 93 | + $activation_url = wp_nonce_url( | |
| 94 | + self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), | |
| 95 | + 'install-plugin_elementor' | |
| 96 | + ); | |
| 97 | + $button_text = esc_html__( 'Install Elementor', 'shopbuilder' ); | |
| 98 | + } | |
| 99 | + $this->missing['elementor'] = [ | |
| 100 | + 'name' => 'Elementor', | |
| 101 | + 'slug' => 'elementor', | |
| 102 | + 'file_name' => $elementor, | |
| 103 | + 'url' => '', | |
| 104 | + 'message' => $message . ' <a href="' . esc_url( $activation_url ) . '" > ' . esc_html( $button_text ) . '</a>', | |
| 105 | + 'button_txt' => '', | |
| 106 | + ]; | |
| 107 | + } | |
| 108 | + */ | |
| 109 | + | |
| 77 | 110 | if ( ! empty( $this->missing ) ) { |
| 78 | 111 | add_action( 'admin_notices', [ $this, '_missing_plugins_warning' ] ); |
| 79 | 112 | } |
| 80 | 113 | |
| @@ -90,11 +123,11 @@ | ||
| 90 | 123 | unset( $_GET['activate'] ); |
| 91 | 124 | } |
| 92 | 125 | $message = sprintf( |
| 93 | 126 | /* translators: 1: Plugin name 2: PHP 3: Required PHP version */ |
| 94 | - esc_html( '"%1$s" requires "%2$s" version %3$s or greater.' ), | |
| 95 | - '<strong>ShopBuilder</strong>', | |
| 96 | - '<strong>PHP</strong>', | |
| 127 | + esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'shopbuilder' ), | |
| 128 | + '<strong>' . esc_html__( 'ShopBuilder', 'shopbuilder' ) . '</strong>', | |
| 129 | + '<strong>' . esc_html__( 'PHP', 'shopbuilder' ) . '</strong>', | |
| 97 | 130 | self::MINIMUM_PHP_VERSION |
| 98 | 131 | ); |
| 99 | 132 | printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', wp_kses_post( $message ) ); |
| 100 | 133 | } |
| @@ -109,14 +142,15 @@ | ||
| 109 | 142 | $counter++; |
| 110 | 143 | if ( $counter == count( $this->missing ) ) { |
| 111 | 144 | $sep = ''; |
| 112 | 145 | } elseif ( $counter == count( $this->missing ) - 1 ) { |
| 113 | - $sep = ' and '; | |
| 146 | + $sep = ' ' . esc_html__( 'and', 'shopbuilder' ) . ' '; | |
| 114 | 147 | } else { |
| 115 | 148 | $sep = ', '; |
| 116 | 149 | } |
| 117 | 150 | if ( current_user_can( 'activate_plugins' ) ) { |
| 118 | - $button = ! empty( $plugin['url'] ) ? '<p><a href="' . esc_url( $plugin['url'] ) . '" class="button-primary">' . esc_html( $plugin['button_txt'] ) . '</a></p>' : ''; | |
| 151 | + $button = ! empty($plugin['url'] ) ? '<p><a href="' . esc_url( $plugin['url'] ) . '" class="button-primary">'. esc_html( $plugin['button_txt'] ) . '</a></p>' : ''; | |
| 152 | + // $plugin['message'] Already used escaping function | |
| 119 | 153 | printf( '<div class="error"><p>%1$s</p>%2$s</div>', $plugin['message'], $button ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 120 | 154 | } else { |
| 121 | 155 | $missingPlugins .= '<strong>' . esc_html( $plugin['name'] ) . '</strong>' . $sep; |
| 122 | 156 | } |