| @@ -40,11 +40,11 @@ | ||
| 40 | 40 | } |
| 41 | 41 | if ( ! function_exists( 'wp_create_nonce' ) ) { |
| 42 | 42 | require_once ABSPATH . 'wp-includes/pluggable.php'; |
| 43 | 43 | } |
| 44 | - // Check WooCommerce | |
| 44 | + | |
| 45 | + // Check WooCommerce. | |
| 45 | 46 | $woocommerce = 'woocommerce/woocommerce.php'; |
| 46 | - | |
| 47 | 47 | if ( ! is_plugin_active( $woocommerce ) ) { |
| 48 | 48 | if ( $this->is_plugins_installed( $woocommerce ) ) { |
| 49 | 49 | $activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $woocommerce . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $woocommerce ); |
| 50 | 50 | $message = sprintf( |
| @@ -54,9 +54,8 @@ | ||
| 54 | 54 | esc_html__( 'WooCommerce', 'shopbuilder' ), |
| 55 | 55 | esc_html__( 'plugin to be active. Please activate WooCommerce to continue.', 'shopbuilder' ) |
| 56 | 56 | ); |
| 57 | 57 | $button_text = esc_html__( 'Activate WooCommerce', 'shopbuilder' ); |
| 58 | - | |
| 59 | 58 | } else { |
| 60 | 59 | $activation_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' ); |
| 61 | 60 | $message = sprintf( |
| 62 | 61 | '<strong>%s</strong> %s <strong>%s</strong> %s', |
| @@ -74,51 +73,43 @@ | ||
| 74 | 73 | 'url' => $activation_url, |
| 75 | 74 | 'message' => $message, |
| 76 | 75 | 'button_txt' => $button_text, |
| 77 | 76 | ]; |
| 77 | + $this->allOk = false; | |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $elementor = 'elementor/elementor.php'; |
| 81 | 81 | |
| 82 | + /* | |
| 82 | 83 | if ( ! is_plugin_active( $elementor ) ) { |
| 83 | - | |
| 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 | + ); | |
| 84 | 89 | if ( $this->is_plugins_installed( $elementor ) ) { |
| 85 | 90 | $activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $elementor . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $elementor ); |
| 86 | - $message = sprintf( | |
| 87 | - '<strong>%s</strong> %s <strong>%s</strong> %s', | |
| 88 | - esc_html( self::PLUGIN_NAME ), | |
| 89 | - esc_html__( 'requires', 'shopbuilder' ), | |
| 90 | - esc_html__( 'Elementor', 'shopbuilder' ), | |
| 91 | - esc_html__( 'plugin to be active. Please activate Elementor to continue.', 'shopbuilder' ) | |
| 92 | - ); | |
| 93 | 91 | $button_text = esc_html__( 'Activate Elementor', 'shopbuilder' ); |
| 94 | - | |
| 95 | 92 | } else { |
| 96 | - $activation_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), | |
| 97 | - 'install-plugin_elementor' ); | |
| 98 | - $message = sprintf( | |
| 99 | - '<strong>%s</strong> %s <strong>%s</strong> %s', | |
| 100 | - esc_html( self::PLUGIN_NAME ), | |
| 101 | - esc_html__( 'requires', 'shopbuilder' ), | |
| 102 | - esc_html__( 'Elementor', 'shopbuilder' ), | |
| 103 | - esc_html__( 'plugin to be installed and activated. Please install Elementor to continue.', 'shopbuilder' ) | |
| 93 | + $activation_url = wp_nonce_url( | |
| 94 | + self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), | |
| 95 | + 'install-plugin_elementor' | |
| 104 | 96 | ); |
| 105 | 97 | $button_text = esc_html__( 'Install Elementor', 'shopbuilder' ); |
| 106 | 98 | } |
| 107 | - | |
| 108 | 99 | $this->missing['elementor'] = [ |
| 109 | 100 | 'name' => 'Elementor', |
| 110 | 101 | 'slug' => 'elementor', |
| 111 | 102 | 'file_name' => $elementor, |
| 112 | - 'url' => $activation_url, | |
| 113 | - 'message' => $message, | |
| 114 | - 'button_txt' => $button_text, | |
| 103 | + 'url' => '', | |
| 104 | + 'message' => $message . ' <a href="' . esc_url( $activation_url ) . '" > ' . esc_html( $button_text ) . '</a>', | |
| 105 | + 'button_txt' => '', | |
| 115 | 106 | ]; |
| 116 | 107 | } |
| 108 | + */ | |
| 109 | + | |
| 117 | 110 | if ( ! empty( $this->missing ) ) { |
| 118 | 111 | add_action( 'admin_notices', [ $this, '_missing_plugins_warning' ] ); |
| 119 | - | |
| 120 | - $this->allOk = false; | |
| 121 | 112 | } |
| 122 | 113 | |
| 123 | 114 | return $this->allOk; |
| 124 | 115 | } |
| @@ -126,9 +117,10 @@ | ||
| 126 | 117 | /** |
| 127 | 118 | * Admin Notice For Required PHP Version |
| 128 | 119 | */ |
| 129 | 120 | public function minimum_php_version() { |
| 130 | - if ( isset( $_GET['activate'] ) ) { | |
| 121 | + // Protect plugin Activation with error. | |
| 122 | + if ( isset( $_GET['activate'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 131 | 123 | unset( $_GET['activate'] ); |
| 132 | 124 | } |
| 133 | 125 | $message = sprintf( |
| 134 | 126 | /* translators: 1: Plugin name 2: PHP 3: Required PHP version */ |
| @@ -136,9 +128,9 @@ | ||
| 136 | 128 | '<strong>' . esc_html__( 'ShopBuilder', 'shopbuilder' ) . '</strong>', |
| 137 | 129 | '<strong>' . esc_html__( 'PHP', 'shopbuilder' ) . '</strong>', |
| 138 | 130 | self::MINIMUM_PHP_VERSION |
| 139 | 131 | ); |
| 140 | - printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); | |
| 132 | + printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', wp_kses_post( $message ) ); | |
| 141 | 133 | } |
| 142 | 134 | |
| 143 | 135 | /** |
| 144 | 136 | * Adds admin notice. |
| @@ -146,18 +138,18 @@ | ||
| 146 | 138 | public function _missing_plugins_warning() { |
| 147 | 139 | $missingPlugins = ''; |
| 148 | 140 | $counter = 0; |
| 149 | 141 | foreach ( $this->missing as $plugin ) { |
| 150 | - $counter ++; | |
| 151 | - if ( $counter == sizeof( $this->missing ) ) { | |
| 142 | + $counter++; | |
| 143 | + if ( $counter == count( $this->missing ) ) { | |
| 152 | 144 | $sep = ''; |
| 153 | - } elseif ( $counter == sizeof( $this->missing ) - 1 ) { | |
| 145 | + } elseif ( $counter == count( $this->missing ) - 1 ) { | |
| 154 | 146 | $sep = ' ' . esc_html__( 'and', 'shopbuilder' ) . ' '; |
| 155 | 147 | } else { |
| 156 | 148 | $sep = ', '; |
| 157 | 149 | } |
| 158 | 150 | if ( current_user_can( 'activate_plugins' ) ) { |
| 159 | - $button = '<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>' : ''; | |
| 160 | 152 | // $plugin['message'] Already used escaping function |
| 161 | 153 | printf( '<div class="error"><p>%1$s</p>%2$s</div>', $plugin['message'], $button ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 162 | 154 | } else { |
| 163 | 155 | $missingPlugins .= '<strong>' . esc_html( $plugin['name'] ) . '</strong>' . $sep; |
| @@ -174,7 +166,5 @@ | ||
| 174 | 166 | $installed_plugins_list = get_plugins(); |
| 175 | 167 | |
| 176 | 168 | return isset( $installed_plugins_list[ $plugin_file_path ] ); |
| 177 | 169 | } |
| 178 | - | |
| 179 | - | |
| 180 | 170 | } |