@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | // If this file is called directly, abort. |
| 24 | 24 | if ( ! defined( 'WPINC' ) ) { |
| 25 | - die; |
|
| 25 | + die; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /*----------------------------------------------------------------------------* |
@@ -48,456 +48,456 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | class AS_Boilerplate_Loader { |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * ID of the item. |
|
| 53 | - * |
|
| 54 | - * The item ID must match teh post ID on the e-commerce site. |
|
| 55 | - * Using the item ID instead of its name has the huge advantage of |
|
| 56 | - * allowing changes in the item name. |
|
| 57 | - * |
|
| 58 | - * If the ID is not set the class will fall back on the plugin name instead. |
|
| 59 | - * |
|
| 60 | - * @since 0.1.3 |
|
| 61 | - * @var int |
|
| 62 | - */ |
|
| 63 | - protected $item_id; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Required version of the core. |
|
| 67 | - * |
|
| 68 | - * The minimum version of the core that's required |
|
| 69 | - * to properly run this addon. If the minimum version |
|
| 70 | - * requirement isn't met an error message is displayed |
|
| 71 | - * and the addon isn't registered. |
|
| 72 | - * |
|
| 73 | - * @since 0.1.0 |
|
| 74 | - * @var string |
|
| 75 | - */ |
|
| 76 | - protected $version_required = '3.2.5'; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * Required version of PHP. |
|
| 80 | - * |
|
| 81 | - * Follow WordPress latest requirements and require |
|
| 82 | - * PHP version 5.4 at least. |
|
| 83 | - * |
|
| 84 | - * @var string |
|
| 85 | - */ |
|
| 86 | - protected $php_version_required = '5.4'; |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Plugin slug. |
|
| 90 | - * |
|
| 91 | - * @since 0.1.0 |
|
| 92 | - * @var string |
|
| 93 | - */ |
|
| 94 | - protected $slug = 'boilerplate'; |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Instance of this loader class. |
|
| 98 | - * |
|
| 99 | - * @since 0.1.0 |
|
| 100 | - * @var object |
|
| 101 | - */ |
|
| 102 | - protected static $instance = null; |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Instance of the addon itself. |
|
| 106 | - * |
|
| 107 | - * @since 0.1.0 |
|
| 108 | - * @var object |
|
| 109 | - */ |
|
| 110 | - public $addon = null; |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Possible error message. |
|
| 114 | - * |
|
| 115 | - * @var null|WP_Error |
|
| 116 | - */ |
|
| 117 | - protected $error = null; |
|
| 118 | - |
|
| 119 | - public function __construct() { |
|
| 120 | - $this->declare_constants(); |
|
| 121 | - $this->init(); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Return an instance of this class. |
|
| 126 | - * |
|
| 127 | - * @since 3.0.0 |
|
| 128 | - * @return object A single instance of this class. |
|
| 129 | - */ |
|
| 130 | - public static function get_instance() { |
|
| 131 | - |
|
| 132 | - // If the single instance hasn't been set, set it now. |
|
| 133 | - if ( null == self::$instance ) { |
|
| 134 | - self::$instance = new self; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - return self::$instance; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Return an instance of the addon. |
|
| 142 | - * |
|
| 143 | - * @since 0.1.0 |
|
| 144 | - * @return object |
|
| 145 | - */ |
|
| 146 | - public function scope() { |
|
| 147 | - return $this->addon; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - public function declare_constants() { |
|
| 151 | - define( 'AS_BP_VERSION', '0.1.0' ); |
|
| 152 | - define( 'AS_BP_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) ); |
|
| 153 | - define( 'AS_BP_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) ); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Activate the plugin. |
|
| 158 | - * |
|
| 159 | - * The activation method just checks if the main plugin |
|
| 160 | - * Awesome Support is installed (active or inactive) on the site. |
|
| 161 | - * If not, the addon installation is aborted and an error message is displayed. |
|
| 162 | - * |
|
| 163 | - * @since 0.1.0 |
|
| 164 | - * @return void |
|
| 165 | - */ |
|
| 166 | - public static function activate() { |
|
| 167 | - |
|
| 168 | - if ( ! class_exists( 'Awesome_Support' ) ) { |
|
| 169 | - deactivate_plugins( basename( __FILE__ ) ); |
|
| 170 | - wp_die( |
|
| 171 | - sprintf( __( 'You need Awesome Support to activate this addon. Please <a href="%s" target="_blank">install Awesome Support</a> before continuing.', 'wpascr' ), esc_url( 'http://getawesomesupport.com/?utm_source=internal&utm_medium=addon_loader&utm_campaign=Addons' ) ) |
|
| 172 | - ); |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * Initialize the addon. |
|
| 179 | - * |
|
| 180 | - * This method is the one running the checks and |
|
| 181 | - * registering the addon to the core. |
|
| 182 | - * |
|
| 183 | - * @since 0.1.0 |
|
| 184 | - * @return boolean Whether or not the addon was registered |
|
| 185 | - */ |
|
| 186 | - public function init() { |
|
| 187 | - |
|
| 188 | - $plugin_name = $this->plugin_data( 'Name' ); |
|
| 189 | - |
|
| 190 | - if ( ! $this->is_core_active() ) { |
|
| 191 | - $this->add_error( sprintf( __( '%s requires Awesome Support to be active. Please activate the core plugin first.', 'wpas-boilerplate' ), $plugin_name ) ); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - if ( ! $this->is_php_version_enough() ) { |
|
| 195 | - $this->add_error( sprintf( __( 'Unfortunately, %s can not run on PHP versions older than %s. Read more information about <a href="%s" target="_blank">how you can update</a>.', 'wpas-boilerplate' ), $plugin_name, $this->php_version_required, esc_url( 'http://www.wpupdatephp.com/update/' ) ) ); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - if ( ! $this->is_version_compatible() ) { |
|
| 199 | - $this->add_error( sprintf( __( '%s requires Awesome Support version %s or greater. Please update the core plugin first.', 'wpas-boilerplate' ), $plugin_name, $this->version_required ) ); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - if ( is_a( $this->error, 'WP_Error' ) ) { |
|
| 203 | - add_action( 'admin_notices', array( $this, 'display_error' ), 10, 0 ); |
|
| 204 | - add_action( 'admin_init', array( $this, 'deactivate' ), 10, 0 ); |
|
| 205 | - return false; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * Add the addon license field |
|
| 210 | - */ |
|
| 211 | - if ( is_admin() ) { |
|
| 212 | - |
|
| 213 | - // Add the license admin notice |
|
| 214 | - $this->add_license_notice(); |
|
| 215 | - |
|
| 216 | - add_filter( 'wpas_addons_licenses', array( $this, 'addon_license' ), 10, 1 ); |
|
| 217 | - add_filter( 'plugin_row_meta', array( $this, 'license_notice_meta' ), 10, 4 ); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Register the addon |
|
| 222 | - */ |
|
| 223 | - wpas_register_addon( $this->slug, array( $this, 'load' ) ); |
|
| 224 | - |
|
| 225 | - return true; |
|
| 226 | - |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * Get the plugin data. |
|
| 231 | - * |
|
| 232 | - * @since 0.1.0 |
|
| 233 | - * @param string $data Plugin data to retrieve |
|
| 234 | - * @return string Data value |
|
| 235 | - */ |
|
| 236 | - protected function plugin_data( $data ) { |
|
| 237 | - |
|
| 238 | - if ( ! function_exists( 'get_plugin_data' ) ) { |
|
| 51 | + /** |
|
| 52 | + * ID of the item. |
|
| 53 | + * |
|
| 54 | + * The item ID must match teh post ID on the e-commerce site. |
|
| 55 | + * Using the item ID instead of its name has the huge advantage of |
|
| 56 | + * allowing changes in the item name. |
|
| 57 | + * |
|
| 58 | + * If the ID is not set the class will fall back on the plugin name instead. |
|
| 59 | + * |
|
| 60 | + * @since 0.1.3 |
|
| 61 | + * @var int |
|
| 62 | + */ |
|
| 63 | + protected $item_id; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Required version of the core. |
|
| 67 | + * |
|
| 68 | + * The minimum version of the core that's required |
|
| 69 | + * to properly run this addon. If the minimum version |
|
| 70 | + * requirement isn't met an error message is displayed |
|
| 71 | + * and the addon isn't registered. |
|
| 72 | + * |
|
| 73 | + * @since 0.1.0 |
|
| 74 | + * @var string |
|
| 75 | + */ |
|
| 76 | + protected $version_required = '3.2.5'; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * Required version of PHP. |
|
| 80 | + * |
|
| 81 | + * Follow WordPress latest requirements and require |
|
| 82 | + * PHP version 5.4 at least. |
|
| 83 | + * |
|
| 84 | + * @var string |
|
| 85 | + */ |
|
| 86 | + protected $php_version_required = '5.4'; |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Plugin slug. |
|
| 90 | + * |
|
| 91 | + * @since 0.1.0 |
|
| 92 | + * @var string |
|
| 93 | + */ |
|
| 94 | + protected $slug = 'boilerplate'; |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Instance of this loader class. |
|
| 98 | + * |
|
| 99 | + * @since 0.1.0 |
|
| 100 | + * @var object |
|
| 101 | + */ |
|
| 102 | + protected static $instance = null; |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Instance of the addon itself. |
|
| 106 | + * |
|
| 107 | + * @since 0.1.0 |
|
| 108 | + * @var object |
|
| 109 | + */ |
|
| 110 | + public $addon = null; |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Possible error message. |
|
| 114 | + * |
|
| 115 | + * @var null|WP_Error |
|
| 116 | + */ |
|
| 117 | + protected $error = null; |
|
| 118 | + |
|
| 119 | + public function __construct() { |
|
| 120 | + $this->declare_constants(); |
|
| 121 | + $this->init(); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Return an instance of this class. |
|
| 126 | + * |
|
| 127 | + * @since 3.0.0 |
|
| 128 | + * @return object A single instance of this class. |
|
| 129 | + */ |
|
| 130 | + public static function get_instance() { |
|
| 131 | + |
|
| 132 | + // If the single instance hasn't been set, set it now. |
|
| 133 | + if ( null == self::$instance ) { |
|
| 134 | + self::$instance = new self; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + return self::$instance; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Return an instance of the addon. |
|
| 142 | + * |
|
| 143 | + * @since 0.1.0 |
|
| 144 | + * @return object |
|
| 145 | + */ |
|
| 146 | + public function scope() { |
|
| 147 | + return $this->addon; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + public function declare_constants() { |
|
| 151 | + define( 'AS_BP_VERSION', '0.1.0' ); |
|
| 152 | + define( 'AS_BP_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) ); |
|
| 153 | + define( 'AS_BP_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) ); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Activate the plugin. |
|
| 158 | + * |
|
| 159 | + * The activation method just checks if the main plugin |
|
| 160 | + * Awesome Support is installed (active or inactive) on the site. |
|
| 161 | + * If not, the addon installation is aborted and an error message is displayed. |
|
| 162 | + * |
|
| 163 | + * @since 0.1.0 |
|
| 164 | + * @return void |
|
| 165 | + */ |
|
| 166 | + public static function activate() { |
|
| 167 | + |
|
| 168 | + if ( ! class_exists( 'Awesome_Support' ) ) { |
|
| 169 | + deactivate_plugins( basename( __FILE__ ) ); |
|
| 170 | + wp_die( |
|
| 171 | + sprintf( __( 'You need Awesome Support to activate this addon. Please <a href="%s" target="_blank">install Awesome Support</a> before continuing.', 'wpascr' ), esc_url( 'http://getawesomesupport.com/?utm_source=internal&utm_medium=addon_loader&utm_campaign=Addons' ) ) |
|
| 172 | + ); |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * Initialize the addon. |
|
| 179 | + * |
|
| 180 | + * This method is the one running the checks and |
|
| 181 | + * registering the addon to the core. |
|
| 182 | + * |
|
| 183 | + * @since 0.1.0 |
|
| 184 | + * @return boolean Whether or not the addon was registered |
|
| 185 | + */ |
|
| 186 | + public function init() { |
|
| 187 | + |
|
| 188 | + $plugin_name = $this->plugin_data( 'Name' ); |
|
| 189 | + |
|
| 190 | + if ( ! $this->is_core_active() ) { |
|
| 191 | + $this->add_error( sprintf( __( '%s requires Awesome Support to be active. Please activate the core plugin first.', 'wpas-boilerplate' ), $plugin_name ) ); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + if ( ! $this->is_php_version_enough() ) { |
|
| 195 | + $this->add_error( sprintf( __( 'Unfortunately, %s can not run on PHP versions older than %s. Read more information about <a href="%s" target="_blank">how you can update</a>.', 'wpas-boilerplate' ), $plugin_name, $this->php_version_required, esc_url( 'http://www.wpupdatephp.com/update/' ) ) ); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + if ( ! $this->is_version_compatible() ) { |
|
| 199 | + $this->add_error( sprintf( __( '%s requires Awesome Support version %s or greater. Please update the core plugin first.', 'wpas-boilerplate' ), $plugin_name, $this->version_required ) ); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + if ( is_a( $this->error, 'WP_Error' ) ) { |
|
| 203 | + add_action( 'admin_notices', array( $this, 'display_error' ), 10, 0 ); |
|
| 204 | + add_action( 'admin_init', array( $this, 'deactivate' ), 10, 0 ); |
|
| 205 | + return false; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * Add the addon license field |
|
| 210 | + */ |
|
| 211 | + if ( is_admin() ) { |
|
| 212 | + |
|
| 213 | + // Add the license admin notice |
|
| 214 | + $this->add_license_notice(); |
|
| 215 | + |
|
| 216 | + add_filter( 'wpas_addons_licenses', array( $this, 'addon_license' ), 10, 1 ); |
|
| 217 | + add_filter( 'plugin_row_meta', array( $this, 'license_notice_meta' ), 10, 4 ); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Register the addon |
|
| 222 | + */ |
|
| 223 | + wpas_register_addon( $this->slug, array( $this, 'load' ) ); |
|
| 224 | + |
|
| 225 | + return true; |
|
| 226 | + |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * Get the plugin data. |
|
| 231 | + * |
|
| 232 | + * @since 0.1.0 |
|
| 233 | + * @param string $data Plugin data to retrieve |
|
| 234 | + * @return string Data value |
|
| 235 | + */ |
|
| 236 | + protected function plugin_data( $data ) { |
|
| 237 | + |
|
| 238 | + if ( ! function_exists( 'get_plugin_data' ) ) { |
|
| 239 | 239 | |
| 240 | - $site_url = get_site_url() . '/'; |
|
| 240 | + $site_url = get_site_url() . '/'; |
|
| 241 | 241 | |
| 242 | - if ( defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN && 'http://' === substr( $site_url, 0, 7 ) ) { |
|
| 243 | - $site_url = str_replace( 'http://', 'https://', $site_url ); |
|
| 244 | - } |
|
| 242 | + if ( defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN && 'http://' === substr( $site_url, 0, 7 ) ) { |
|
| 243 | + $site_url = str_replace( 'http://', 'https://', $site_url ); |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - $admin_path = str_replace( $site_url, ABSPATH, get_admin_url() ); |
|
| 246 | + $admin_path = str_replace( $site_url, ABSPATH, get_admin_url() ); |
|
| 247 | 247 | |
| 248 | - require_once( $admin_path . 'includes/plugin.php' ); |
|
| 248 | + require_once( $admin_path . 'includes/plugin.php' ); |
|
| 249 | 249 | |
| 250 | - } |
|
| 251 | - |
|
| 252 | - $plugin = get_plugin_data( __FILE__, false, false ); |
|
| 253 | - |
|
| 254 | - if ( array_key_exists( $data, $plugin ) ) { |
|
| 255 | - return $plugin[$data]; |
|
| 256 | - } else { |
|
| 257 | - return ''; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - /** |
|
| 263 | - * Check if core is active. |
|
| 264 | - * |
|
| 265 | - * Checks if the core plugin is listed in the acitve |
|
| 266 | - * plugins in the WordPress database. |
|
| 267 | - * |
|
| 268 | - * @since 0.1.0 |
|
| 269 | - * @return boolean Whether or not the core is active |
|
| 270 | - */ |
|
| 271 | - protected function is_core_active() { |
|
| 272 | - if ( in_array( 'awesome-support/awesome-support.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { |
|
| 273 | - return true; |
|
| 274 | - } else { |
|
| 275 | - return false; |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - /** |
|
| 280 | - * Check if the core version is compatible with this addon. |
|
| 281 | - * |
|
| 282 | - * @since 0.1.0 |
|
| 283 | - * @return boolean |
|
| 284 | - */ |
|
| 285 | - protected function is_version_compatible() { |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * Return true if the core is not active so that this message won't show. |
|
| 289 | - * We already have the error saying the plugin is disabled, no need to add this one. |
|
| 290 | - */ |
|
| 291 | - if ( ! $this->is_core_active() ) { |
|
| 292 | - return true; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - if ( empty( $this->version_required ) ) { |
|
| 296 | - return true; |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - if ( ! defined( 'WPAS_VERSION' ) ) { |
|
| 300 | - return false; |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - if ( version_compare( WPAS_VERSION, $this->version_required, '<' ) ) { |
|
| 304 | - return false; |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - return true; |
|
| 308 | - |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - /** |
|
| 312 | - * Check if the version of PHP is compatible with this addon. |
|
| 313 | - * |
|
| 314 | - * @since 0.1.0 |
|
| 315 | - * @return boolean |
|
| 316 | - */ |
|
| 317 | - protected function is_php_version_enough() { |
|
| 318 | - |
|
| 319 | - /** |
|
| 320 | - * No version set, we assume everything is fine. |
|
| 321 | - */ |
|
| 322 | - if ( empty( $this->php_version_required ) ) { |
|
| 323 | - return true; |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - if ( version_compare( phpversion(), $this->php_version_required, '<' ) ) { |
|
| 327 | - return false; |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - return true; |
|
| 331 | - |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - /** |
|
| 335 | - * Add error. |
|
| 336 | - * |
|
| 337 | - * Add a new error to the WP_Error object |
|
| 338 | - * and create the object if it doesn't exist yet. |
|
| 339 | - * |
|
| 340 | - * @since 0.1.0 |
|
| 341 | - * @param string $message Error message to add |
|
| 342 | - * @return void |
|
| 343 | - */ |
|
| 344 | - public function add_error( $message ) { |
|
| 345 | - |
|
| 346 | - if ( ! is_object( $this->error ) || ! is_a( $this->error, 'WP_Error' ) ) { |
|
| 347 | - $this->error = new WP_Error(); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - $this->error->add( 'addon_error', $message ); |
|
| 351 | - |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - /** |
|
| 355 | - * Display error. |
|
| 356 | - * |
|
| 357 | - * Get all the error messages and display them |
|
| 358 | - * in the admin notices. |
|
| 359 | - * |
|
| 360 | - * @since 0.1.0 |
|
| 361 | - * @return void |
|
| 362 | - */ |
|
| 363 | - public function display_error() { |
|
| 364 | - |
|
| 365 | - if ( ! is_a( $this->error, 'WP_Error' ) ) { |
|
| 366 | - return; |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - $message = $this->error->get_error_messages(); ?> |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + $plugin = get_plugin_data( __FILE__, false, false ); |
|
| 253 | + |
|
| 254 | + if ( array_key_exists( $data, $plugin ) ) { |
|
| 255 | + return $plugin[$data]; |
|
| 256 | + } else { |
|
| 257 | + return ''; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + /** |
|
| 263 | + * Check if core is active. |
|
| 264 | + * |
|
| 265 | + * Checks if the core plugin is listed in the acitve |
|
| 266 | + * plugins in the WordPress database. |
|
| 267 | + * |
|
| 268 | + * @since 0.1.0 |
|
| 269 | + * @return boolean Whether or not the core is active |
|
| 270 | + */ |
|
| 271 | + protected function is_core_active() { |
|
| 272 | + if ( in_array( 'awesome-support/awesome-support.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { |
|
| 273 | + return true; |
|
| 274 | + } else { |
|
| 275 | + return false; |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + /** |
|
| 280 | + * Check if the core version is compatible with this addon. |
|
| 281 | + * |
|
| 282 | + * @since 0.1.0 |
|
| 283 | + * @return boolean |
|
| 284 | + */ |
|
| 285 | + protected function is_version_compatible() { |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * Return true if the core is not active so that this message won't show. |
|
| 289 | + * We already have the error saying the plugin is disabled, no need to add this one. |
|
| 290 | + */ |
|
| 291 | + if ( ! $this->is_core_active() ) { |
|
| 292 | + return true; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + if ( empty( $this->version_required ) ) { |
|
| 296 | + return true; |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + if ( ! defined( 'WPAS_VERSION' ) ) { |
|
| 300 | + return false; |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + if ( version_compare( WPAS_VERSION, $this->version_required, '<' ) ) { |
|
| 304 | + return false; |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + return true; |
|
| 308 | + |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + /** |
|
| 312 | + * Check if the version of PHP is compatible with this addon. |
|
| 313 | + * |
|
| 314 | + * @since 0.1.0 |
|
| 315 | + * @return boolean |
|
| 316 | + */ |
|
| 317 | + protected function is_php_version_enough() { |
|
| 318 | + |
|
| 319 | + /** |
|
| 320 | + * No version set, we assume everything is fine. |
|
| 321 | + */ |
|
| 322 | + if ( empty( $this->php_version_required ) ) { |
|
| 323 | + return true; |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + if ( version_compare( phpversion(), $this->php_version_required, '<' ) ) { |
|
| 327 | + return false; |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + return true; |
|
| 331 | + |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + /** |
|
| 335 | + * Add error. |
|
| 336 | + * |
|
| 337 | + * Add a new error to the WP_Error object |
|
| 338 | + * and create the object if it doesn't exist yet. |
|
| 339 | + * |
|
| 340 | + * @since 0.1.0 |
|
| 341 | + * @param string $message Error message to add |
|
| 342 | + * @return void |
|
| 343 | + */ |
|
| 344 | + public function add_error( $message ) { |
|
| 345 | + |
|
| 346 | + if ( ! is_object( $this->error ) || ! is_a( $this->error, 'WP_Error' ) ) { |
|
| 347 | + $this->error = new WP_Error(); |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + $this->error->add( 'addon_error', $message ); |
|
| 351 | + |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + /** |
|
| 355 | + * Display error. |
|
| 356 | + * |
|
| 357 | + * Get all the error messages and display them |
|
| 358 | + * in the admin notices. |
|
| 359 | + * |
|
| 360 | + * @since 0.1.0 |
|
| 361 | + * @return void |
|
| 362 | + */ |
|
| 363 | + public function display_error() { |
|
| 364 | + |
|
| 365 | + if ( ! is_a( $this->error, 'WP_Error' ) ) { |
|
| 366 | + return; |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + $message = $this->error->get_error_messages(); ?> |
|
| 370 | 370 | <div class="error"> |
| 371 | 371 | <p> |
| 372 | 372 | <?php |
| 373 | - if ( count( $message ) > 1 ) { |
|
| 373 | + if ( count( $message ) > 1 ) { |
|
| 374 | 374 | |
| 375 | - echo '<ul>'; |
|
| 375 | + echo '<ul>'; |
|
| 376 | 376 | |
| 377 | - foreach ( $message as $msg ) { |
|
| 378 | - echo "<li>$msg</li>"; |
|
| 379 | - } |
|
| 377 | + foreach ( $message as $msg ) { |
|
| 378 | + echo "<li>$msg</li>"; |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | - echo '</li>'; |
|
| 381 | + echo '</li>'; |
|
| 382 | 382 | |
| 383 | - } else { |
|
| 384 | - echo $message[0]; |
|
| 385 | - } |
|
| 386 | - ?> |
|
| 383 | + } else { |
|
| 384 | + echo $message[0]; |
|
| 385 | + } |
|
| 386 | + ?> |
|
| 387 | 387 | </p> |
| 388 | 388 | </div> |
| 389 | 389 | <?php |
| 390 | 390 | |
| 391 | - } |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * Deactivate the addon. |
|
| 395 | - * |
|
| 396 | - * If the requirements aren't met we try to |
|
| 397 | - * deactivate the addon completely. |
|
| 398 | - * |
|
| 399 | - * @return void |
|
| 400 | - */ |
|
| 401 | - public function deactivate() { |
|
| 402 | - if ( function_exists( 'deactivate_plugins' ) ) { |
|
| 403 | - deactivate_plugins( basename( __FILE__ ) ); |
|
| 404 | - } |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - /** |
|
| 408 | - * Add license option. |
|
| 409 | - * |
|
| 410 | - * @since 0.1.0 |
|
| 411 | - * @param array $licenses List of addons licenses |
|
| 412 | - * @return array Updated list of licenses |
|
| 413 | - */ |
|
| 414 | - public function addon_license( $licenses ) { |
|
| 415 | - |
|
| 416 | - $plugin_name = $this->plugin_data( 'Name' ); |
|
| 417 | - $plugin_name = trim( str_replace( 'Awesome Support:', '', $plugin_name ) ); // Remove the Awesome Support prefix from the addon name |
|
| 418 | - |
|
| 419 | - $licenses[] = array( |
|
| 420 | - 'name' => $plugin_name, |
|
| 421 | - 'id' => "license_{$this->slug}", |
|
| 422 | - 'type' => 'edd-license', |
|
| 423 | - 'default' => '', |
|
| 424 | - 'server' => esc_url( 'http://getawesomesupport.com' ), |
|
| 425 | - 'item_name' => $plugin_name, |
|
| 426 | - 'item_id' => $this->item_id, |
|
| 427 | - 'file' => __FILE__ |
|
| 428 | - ); |
|
| 429 | - |
|
| 430 | - return $licenses; |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - /** |
|
| 434 | - * Display notice if user didn't set his Envato license code |
|
| 435 | - * |
|
| 436 | - * @since 0.1.4 |
|
| 437 | - * @return void |
|
| 438 | - */ |
|
| 439 | - public function add_license_notice() { |
|
| 440 | - |
|
| 441 | - /** |
|
| 442 | - * We only want to display the notice to the site admin. |
|
| 443 | - */ |
|
| 444 | - if ( ! current_user_can( 'administrator' ) ) { |
|
| 445 | - return; |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - $license = wpas_get_option( "license_{$this->slug}", '' ); |
|
| 449 | - |
|
| 450 | - /** |
|
| 451 | - * Do not show the notice if the license key has already been entered. |
|
| 452 | - */ |
|
| 453 | - if ( ! empty( $license ) ) { |
|
| 454 | - return; |
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - $link = wpas_get_settings_page_url( 'licenses' ); |
|
| 458 | - WPAS()->admin_notices->add_notice( 'error', "lincense_{$this->slug}", sprintf( __( 'Please <a href="%s">fill-in your product license</a> now. If you don\'t, your copy of the plugin <strong>will never be updated</strong>.', 'wpbp' ), $link ) ); |
|
| 459 | - |
|
| 460 | - } |
|
| 461 | - |
|
| 462 | - /** |
|
| 463 | - * Add license warning in the plugin meta row |
|
| 464 | - * |
|
| 465 | - * @since 0.1.0 |
|
| 466 | - * |
|
| 467 | - * @param array $plugin_meta The current plugin meta row |
|
| 468 | - * @param string $plugin_file The plugin file path |
|
| 469 | - * |
|
| 470 | - * @return array Updated plugin meta |
|
| 471 | - */ |
|
| 472 | - public function license_notice_meta( $plugin_meta, $plugin_file ) { |
|
| 473 | - |
|
| 474 | - $license = wpas_get_option( "license_{$this->slug}", '' ); |
|
| 475 | - |
|
| 476 | - if( ! empty( $license ) ) { |
|
| 477 | - return $plugin_meta; |
|
| 478 | - } |
|
| 479 | - |
|
| 480 | - $license_page = add_query_arg( array( 'post_type' => 'ticket', 'page' => 'settings', 'tab' => 'licenses' ), admin_url( 'edit.php' ) ); |
|
| 481 | - |
|
| 482 | - if ( plugin_basename( __FILE__ ) === $plugin_file ) { |
|
| 483 | - $plugin_meta[] = '<strong>' . sprintf( __( 'You must fill-in your product license in order to get future plugin updates. <a href="%s">Click here to do it</a>.', 'wpas' ), $license_page ) . '</strong>'; |
|
| 484 | - } |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * Deactivate the addon. |
|
| 395 | + * |
|
| 396 | + * If the requirements aren't met we try to |
|
| 397 | + * deactivate the addon completely. |
|
| 398 | + * |
|
| 399 | + * @return void |
|
| 400 | + */ |
|
| 401 | + public function deactivate() { |
|
| 402 | + if ( function_exists( 'deactivate_plugins' ) ) { |
|
| 403 | + deactivate_plugins( basename( __FILE__ ) ); |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + /** |
|
| 408 | + * Add license option. |
|
| 409 | + * |
|
| 410 | + * @since 0.1.0 |
|
| 411 | + * @param array $licenses List of addons licenses |
|
| 412 | + * @return array Updated list of licenses |
|
| 413 | + */ |
|
| 414 | + public function addon_license( $licenses ) { |
|
| 415 | + |
|
| 416 | + $plugin_name = $this->plugin_data( 'Name' ); |
|
| 417 | + $plugin_name = trim( str_replace( 'Awesome Support:', '', $plugin_name ) ); // Remove the Awesome Support prefix from the addon name |
|
| 418 | + |
|
| 419 | + $licenses[] = array( |
|
| 420 | + 'name' => $plugin_name, |
|
| 421 | + 'id' => "license_{$this->slug}", |
|
| 422 | + 'type' => 'edd-license', |
|
| 423 | + 'default' => '', |
|
| 424 | + 'server' => esc_url( 'http://getawesomesupport.com' ), |
|
| 425 | + 'item_name' => $plugin_name, |
|
| 426 | + 'item_id' => $this->item_id, |
|
| 427 | + 'file' => __FILE__ |
|
| 428 | + ); |
|
| 429 | + |
|
| 430 | + return $licenses; |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + /** |
|
| 434 | + * Display notice if user didn't set his Envato license code |
|
| 435 | + * |
|
| 436 | + * @since 0.1.4 |
|
| 437 | + * @return void |
|
| 438 | + */ |
|
| 439 | + public function add_license_notice() { |
|
| 440 | + |
|
| 441 | + /** |
|
| 442 | + * We only want to display the notice to the site admin. |
|
| 443 | + */ |
|
| 444 | + if ( ! current_user_can( 'administrator' ) ) { |
|
| 445 | + return; |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + $license = wpas_get_option( "license_{$this->slug}", '' ); |
|
| 449 | + |
|
| 450 | + /** |
|
| 451 | + * Do not show the notice if the license key has already been entered. |
|
| 452 | + */ |
|
| 453 | + if ( ! empty( $license ) ) { |
|
| 454 | + return; |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + $link = wpas_get_settings_page_url( 'licenses' ); |
|
| 458 | + WPAS()->admin_notices->add_notice( 'error', "lincense_{$this->slug}", sprintf( __( 'Please <a href="%s">fill-in your product license</a> now. If you don\'t, your copy of the plugin <strong>will never be updated</strong>.', 'wpbp' ), $link ) ); |
|
| 459 | + |
|
| 460 | + } |
|
| 461 | + |
|
| 462 | + /** |
|
| 463 | + * Add license warning in the plugin meta row |
|
| 464 | + * |
|
| 465 | + * @since 0.1.0 |
|
| 466 | + * |
|
| 467 | + * @param array $plugin_meta The current plugin meta row |
|
| 468 | + * @param string $plugin_file The plugin file path |
|
| 469 | + * |
|
| 470 | + * @return array Updated plugin meta |
|
| 471 | + */ |
|
| 472 | + public function license_notice_meta( $plugin_meta, $plugin_file ) { |
|
| 473 | + |
|
| 474 | + $license = wpas_get_option( "license_{$this->slug}", '' ); |
|
| 475 | + |
|
| 476 | + if( ! empty( $license ) ) { |
|
| 477 | + return $plugin_meta; |
|
| 478 | + } |
|
| 479 | + |
|
| 480 | + $license_page = add_query_arg( array( 'post_type' => 'ticket', 'page' => 'settings', 'tab' => 'licenses' ), admin_url( 'edit.php' ) ); |
|
| 481 | + |
|
| 482 | + if ( plugin_basename( __FILE__ ) === $plugin_file ) { |
|
| 483 | + $plugin_meta[] = '<strong>' . sprintf( __( 'You must fill-in your product license in order to get future plugin updates. <a href="%s">Click here to do it</a>.', 'wpas' ), $license_page ) . '</strong>'; |
|
| 484 | + } |
|
| 485 | 485 | |
| 486 | - return $plugin_meta; |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - /** |
|
| 490 | - * Load the addon. |
|
| 491 | - * |
|
| 492 | - * Include all necessary files and instanciate the addon. |
|
| 493 | - * |
|
| 494 | - * @since 0.1.0 |
|
| 495 | - * @return void |
|
| 496 | - */ |
|
| 497 | - public function load() { |
|
| 498 | - |
|
| 499 | - // Load the addon here. |
|
| 500 | - |
|
| 501 | - } |
|
| 486 | + return $plugin_meta; |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + /** |
|
| 490 | + * Load the addon. |
|
| 491 | + * |
|
| 492 | + * Include all necessary files and instanciate the addon. |
|
| 493 | + * |
|
| 494 | + * @since 0.1.0 |
|
| 495 | + * @return void |
|
| 496 | + */ |
|
| 497 | + public function load() { |
|
| 498 | + |
|
| 499 | + // Load the addon here. |
|
| 500 | + |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | 503 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | 23 | // If this file is called directly, abort. |
| 24 | -if ( ! defined( 'WPINC' ) ) { |
|
| 24 | +if (!defined('WPINC')) { |
|
| 25 | 25 | die; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * Register the activation hook |
| 34 | 34 | */ |
| 35 | -register_activation_hook( __FILE__, array( 'AS_Boilerplate_Loader', 'activate' ) ); |
|
| 35 | +register_activation_hook(__FILE__, array('AS_Boilerplate_Loader', 'activate')); |
|
| 36 | 36 | |
| 37 | -add_action( 'plugins_loaded', array( 'AS_Boilerplate_Loader', 'get_instance' ) ); |
|
| 37 | +add_action('plugins_loaded', array('AS_Boilerplate_Loader', 'get_instance')); |
|
| 38 | 38 | /** |
| 39 | 39 | * Instanciate the addon. |
| 40 | 40 | * |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | public static function get_instance() { |
| 131 | 131 | |
| 132 | 132 | // If the single instance hasn't been set, set it now. |
| 133 | - if ( null == self::$instance ) { |
|
| 133 | + if (null == self::$instance) { |
|
| 134 | 134 | self::$instance = new self; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | public function declare_constants() { |
| 151 | - define( 'AS_BP_VERSION', '0.1.0' ); |
|
| 152 | - define( 'AS_BP_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) ); |
|
| 153 | - define( 'AS_BP_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) ); |
|
| 151 | + define('AS_BP_VERSION', '0.1.0'); |
|
| 152 | + define('AS_BP_URL', trailingslashit(plugin_dir_url(__FILE__))); |
|
| 153 | + define('AS_BP_PATH', trailingslashit(plugin_dir_path(__FILE__))); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -165,10 +165,10 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | public static function activate() { |
| 167 | 167 | |
| 168 | - if ( ! class_exists( 'Awesome_Support' ) ) { |
|
| 169 | - deactivate_plugins( basename( __FILE__ ) ); |
|
| 168 | + if (!class_exists('Awesome_Support')) { |
|
| 169 | + deactivate_plugins(basename(__FILE__)); |
|
| 170 | 170 | wp_die( |
| 171 | - sprintf( __( 'You need Awesome Support to activate this addon. Please <a href="%s" target="_blank">install Awesome Support</a> before continuing.', 'wpascr' ), esc_url( 'http://getawesomesupport.com/?utm_source=internal&utm_medium=addon_loader&utm_campaign=Addons' ) ) |
|
| 171 | + sprintf(__('You need Awesome Support to activate this addon. Please <a href="%s" target="_blank">install Awesome Support</a> before continuing.', 'wpascr'), esc_url('http://getawesomesupport.com/?utm_source=internal&utm_medium=addon_loader&utm_campaign=Addons')) |
|
| 172 | 172 | ); |
| 173 | 173 | } |
| 174 | 174 | |
@@ -185,42 +185,42 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | public function init() { |
| 187 | 187 | |
| 188 | - $plugin_name = $this->plugin_data( 'Name' ); |
|
| 188 | + $plugin_name = $this->plugin_data('Name'); |
|
| 189 | 189 | |
| 190 | - if ( ! $this->is_core_active() ) { |
|
| 191 | - $this->add_error( sprintf( __( '%s requires Awesome Support to be active. Please activate the core plugin first.', 'wpas-boilerplate' ), $plugin_name ) ); |
|
| 190 | + if (!$this->is_core_active()) { |
|
| 191 | + $this->add_error(sprintf(__('%s requires Awesome Support to be active. Please activate the core plugin first.', 'wpas-boilerplate'), $plugin_name)); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if ( ! $this->is_php_version_enough() ) { |
|
| 195 | - $this->add_error( sprintf( __( 'Unfortunately, %s can not run on PHP versions older than %s. Read more information about <a href="%s" target="_blank">how you can update</a>.', 'wpas-boilerplate' ), $plugin_name, $this->php_version_required, esc_url( 'http://www.wpupdatephp.com/update/' ) ) ); |
|
| 194 | + if (!$this->is_php_version_enough()) { |
|
| 195 | + $this->add_error(sprintf(__('Unfortunately, %s can not run on PHP versions older than %s. Read more information about <a href="%s" target="_blank">how you can update</a>.', 'wpas-boilerplate'), $plugin_name, $this->php_version_required, esc_url('http://www.wpupdatephp.com/update/'))); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if ( ! $this->is_version_compatible() ) { |
|
| 199 | - $this->add_error( sprintf( __( '%s requires Awesome Support version %s or greater. Please update the core plugin first.', 'wpas-boilerplate' ), $plugin_name, $this->version_required ) ); |
|
| 198 | + if (!$this->is_version_compatible()) { |
|
| 199 | + $this->add_error(sprintf(__('%s requires Awesome Support version %s or greater. Please update the core plugin first.', 'wpas-boilerplate'), $plugin_name, $this->version_required)); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if ( is_a( $this->error, 'WP_Error' ) ) { |
|
| 203 | - add_action( 'admin_notices', array( $this, 'display_error' ), 10, 0 ); |
|
| 204 | - add_action( 'admin_init', array( $this, 'deactivate' ), 10, 0 ); |
|
| 202 | + if (is_a($this->error, 'WP_Error')) { |
|
| 203 | + add_action('admin_notices', array($this, 'display_error'), 10, 0); |
|
| 204 | + add_action('admin_init', array($this, 'deactivate'), 10, 0); |
|
| 205 | 205 | return false; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
| 209 | 209 | * Add the addon license field |
| 210 | 210 | */ |
| 211 | - if ( is_admin() ) { |
|
| 211 | + if (is_admin()) { |
|
| 212 | 212 | |
| 213 | 213 | // Add the license admin notice |
| 214 | 214 | $this->add_license_notice(); |
| 215 | 215 | |
| 216 | - add_filter( 'wpas_addons_licenses', array( $this, 'addon_license' ), 10, 1 ); |
|
| 217 | - add_filter( 'plugin_row_meta', array( $this, 'license_notice_meta' ), 10, 4 ); |
|
| 216 | + add_filter('wpas_addons_licenses', array($this, 'addon_license'), 10, 1); |
|
| 217 | + add_filter('plugin_row_meta', array($this, 'license_notice_meta'), 10, 4); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | 221 | * Register the addon |
| 222 | 222 | */ |
| 223 | - wpas_register_addon( $this->slug, array( $this, 'load' ) ); |
|
| 223 | + wpas_register_addon($this->slug, array($this, 'load')); |
|
| 224 | 224 | |
| 225 | 225 | return true; |
| 226 | 226 | |
@@ -233,25 +233,25 @@ discard block |
||
| 233 | 233 | * @param string $data Plugin data to retrieve |
| 234 | 234 | * @return string Data value |
| 235 | 235 | */ |
| 236 | - protected function plugin_data( $data ) { |
|
| 236 | + protected function plugin_data($data) { |
|
| 237 | 237 | |
| 238 | - if ( ! function_exists( 'get_plugin_data' ) ) { |
|
| 238 | + if (!function_exists('get_plugin_data')) { |
|
| 239 | 239 | |
| 240 | - $site_url = get_site_url() . '/'; |
|
| 240 | + $site_url = get_site_url().'/'; |
|
| 241 | 241 | |
| 242 | - if ( defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN && 'http://' === substr( $site_url, 0, 7 ) ) { |
|
| 243 | - $site_url = str_replace( 'http://', 'https://', $site_url ); |
|
| 242 | + if (defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN && 'http://' === substr($site_url, 0, 7)) { |
|
| 243 | + $site_url = str_replace('http://', 'https://', $site_url); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - $admin_path = str_replace( $site_url, ABSPATH, get_admin_url() ); |
|
| 246 | + $admin_path = str_replace($site_url, ABSPATH, get_admin_url()); |
|
| 247 | 247 | |
| 248 | - require_once( $admin_path . 'includes/plugin.php' ); |
|
| 248 | + require_once($admin_path.'includes/plugin.php'); |
|
| 249 | 249 | |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - $plugin = get_plugin_data( __FILE__, false, false ); |
|
| 252 | + $plugin = get_plugin_data(__FILE__, false, false); |
|
| 253 | 253 | |
| 254 | - if ( array_key_exists( $data, $plugin ) ) { |
|
| 254 | + if (array_key_exists($data, $plugin)) { |
|
| 255 | 255 | return $plugin[$data]; |
| 256 | 256 | } else { |
| 257 | 257 | return ''; |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * @return boolean Whether or not the core is active |
| 270 | 270 | */ |
| 271 | 271 | protected function is_core_active() { |
| 272 | - if ( in_array( 'awesome-support/awesome-support.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { |
|
| 272 | + if (in_array('awesome-support/awesome-support.php', apply_filters('active_plugins', get_option('active_plugins')))) { |
|
| 273 | 273 | return true; |
| 274 | 274 | } else { |
| 275 | 275 | return false; |
@@ -288,19 +288,19 @@ discard block |
||
| 288 | 288 | * Return true if the core is not active so that this message won't show. |
| 289 | 289 | * We already have the error saying the plugin is disabled, no need to add this one. |
| 290 | 290 | */ |
| 291 | - if ( ! $this->is_core_active() ) { |
|
| 291 | + if (!$this->is_core_active()) { |
|
| 292 | 292 | return true; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - if ( empty( $this->version_required ) ) { |
|
| 295 | + if (empty($this->version_required)) { |
|
| 296 | 296 | return true; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - if ( ! defined( 'WPAS_VERSION' ) ) { |
|
| 299 | + if (!defined('WPAS_VERSION')) { |
|
| 300 | 300 | return false; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - if ( version_compare( WPAS_VERSION, $this->version_required, '<' ) ) { |
|
| 303 | + if (version_compare(WPAS_VERSION, $this->version_required, '<')) { |
|
| 304 | 304 | return false; |
| 305 | 305 | } |
| 306 | 306 | |
@@ -319,11 +319,11 @@ discard block |
||
| 319 | 319 | /** |
| 320 | 320 | * No version set, we assume everything is fine. |
| 321 | 321 | */ |
| 322 | - if ( empty( $this->php_version_required ) ) { |
|
| 322 | + if (empty($this->php_version_required)) { |
|
| 323 | 323 | return true; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if ( version_compare( phpversion(), $this->php_version_required, '<' ) ) { |
|
| 326 | + if (version_compare(phpversion(), $this->php_version_required, '<')) { |
|
| 327 | 327 | return false; |
| 328 | 328 | } |
| 329 | 329 | |
@@ -341,13 +341,13 @@ discard block |
||
| 341 | 341 | * @param string $message Error message to add |
| 342 | 342 | * @return void |
| 343 | 343 | */ |
| 344 | - public function add_error( $message ) { |
|
| 344 | + public function add_error($message) { |
|
| 345 | 345 | |
| 346 | - if ( ! is_object( $this->error ) || ! is_a( $this->error, 'WP_Error' ) ) { |
|
| 346 | + if (!is_object($this->error) || !is_a($this->error, 'WP_Error')) { |
|
| 347 | 347 | $this->error = new WP_Error(); |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - $this->error->add( 'addon_error', $message ); |
|
| 350 | + $this->error->add('addon_error', $message); |
|
| 351 | 351 | |
| 352 | 352 | } |
| 353 | 353 | |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | */ |
| 363 | 363 | public function display_error() { |
| 364 | 364 | |
| 365 | - if ( ! is_a( $this->error, 'WP_Error' ) ) { |
|
| 365 | + if (!is_a($this->error, 'WP_Error')) { |
|
| 366 | 366 | return; |
| 367 | 367 | } |
| 368 | 368 | |
@@ -370,11 +370,11 @@ discard block |
||
| 370 | 370 | <div class="error"> |
| 371 | 371 | <p> |
| 372 | 372 | <?php |
| 373 | - if ( count( $message ) > 1 ) { |
|
| 373 | + if (count($message) > 1) { |
|
| 374 | 374 | |
| 375 | 375 | echo '<ul>'; |
| 376 | 376 | |
| 377 | - foreach ( $message as $msg ) { |
|
| 377 | + foreach ($message as $msg) { |
|
| 378 | 378 | echo "<li>$msg</li>"; |
| 379 | 379 | } |
| 380 | 380 | |
@@ -399,8 +399,8 @@ discard block |
||
| 399 | 399 | * @return void |
| 400 | 400 | */ |
| 401 | 401 | public function deactivate() { |
| 402 | - if ( function_exists( 'deactivate_plugins' ) ) { |
|
| 403 | - deactivate_plugins( basename( __FILE__ ) ); |
|
| 402 | + if (function_exists('deactivate_plugins')) { |
|
| 403 | + deactivate_plugins(basename(__FILE__)); |
|
| 404 | 404 | } |
| 405 | 405 | } |
| 406 | 406 | |
@@ -411,17 +411,17 @@ discard block |
||
| 411 | 411 | * @param array $licenses List of addons licenses |
| 412 | 412 | * @return array Updated list of licenses |
| 413 | 413 | */ |
| 414 | - public function addon_license( $licenses ) { |
|
| 414 | + public function addon_license($licenses) { |
|
| 415 | 415 | |
| 416 | - $plugin_name = $this->plugin_data( 'Name' ); |
|
| 417 | - $plugin_name = trim( str_replace( 'Awesome Support:', '', $plugin_name ) ); // Remove the Awesome Support prefix from the addon name |
|
| 416 | + $plugin_name = $this->plugin_data('Name'); |
|
| 417 | + $plugin_name = trim(str_replace('Awesome Support:', '', $plugin_name)); // Remove the Awesome Support prefix from the addon name |
|
| 418 | 418 | |
| 419 | 419 | $licenses[] = array( |
| 420 | 420 | 'name' => $plugin_name, |
| 421 | 421 | 'id' => "license_{$this->slug}", |
| 422 | 422 | 'type' => 'edd-license', |
| 423 | 423 | 'default' => '', |
| 424 | - 'server' => esc_url( 'http://getawesomesupport.com' ), |
|
| 424 | + 'server' => esc_url('http://getawesomesupport.com'), |
|
| 425 | 425 | 'item_name' => $plugin_name, |
| 426 | 426 | 'item_id' => $this->item_id, |
| 427 | 427 | 'file' => __FILE__ |
@@ -441,21 +441,21 @@ discard block |
||
| 441 | 441 | /** |
| 442 | 442 | * We only want to display the notice to the site admin. |
| 443 | 443 | */ |
| 444 | - if ( ! current_user_can( 'administrator' ) ) { |
|
| 444 | + if (!current_user_can('administrator')) { |
|
| 445 | 445 | return; |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - $license = wpas_get_option( "license_{$this->slug}", '' ); |
|
| 448 | + $license = wpas_get_option("license_{$this->slug}", ''); |
|
| 449 | 449 | |
| 450 | 450 | /** |
| 451 | 451 | * Do not show the notice if the license key has already been entered. |
| 452 | 452 | */ |
| 453 | - if ( ! empty( $license ) ) { |
|
| 453 | + if (!empty($license)) { |
|
| 454 | 454 | return; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - $link = wpas_get_settings_page_url( 'licenses' ); |
|
| 458 | - WPAS()->admin_notices->add_notice( 'error', "lincense_{$this->slug}", sprintf( __( 'Please <a href="%s">fill-in your product license</a> now. If you don\'t, your copy of the plugin <strong>will never be updated</strong>.', 'wpbp' ), $link ) ); |
|
| 457 | + $link = wpas_get_settings_page_url('licenses'); |
|
| 458 | + WPAS()->admin_notices->add_notice('error', "lincense_{$this->slug}", sprintf(__('Please <a href="%s">fill-in your product license</a> now. If you don\'t, your copy of the plugin <strong>will never be updated</strong>.', 'wpbp'), $link)); |
|
| 459 | 459 | |
| 460 | 460 | } |
| 461 | 461 | |
@@ -469,18 +469,18 @@ discard block |
||
| 469 | 469 | * |
| 470 | 470 | * @return array Updated plugin meta |
| 471 | 471 | */ |
| 472 | - public function license_notice_meta( $plugin_meta, $plugin_file ) { |
|
| 472 | + public function license_notice_meta($plugin_meta, $plugin_file) { |
|
| 473 | 473 | |
| 474 | - $license = wpas_get_option( "license_{$this->slug}", '' ); |
|
| 474 | + $license = wpas_get_option("license_{$this->slug}", ''); |
|
| 475 | 475 | |
| 476 | - if( ! empty( $license ) ) { |
|
| 476 | + if (!empty($license)) { |
|
| 477 | 477 | return $plugin_meta; |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - $license_page = add_query_arg( array( 'post_type' => 'ticket', 'page' => 'settings', 'tab' => 'licenses' ), admin_url( 'edit.php' ) ); |
|
| 480 | + $license_page = add_query_arg(array('post_type' => 'ticket', 'page' => 'settings', 'tab' => 'licenses'), admin_url('edit.php')); |
|
| 481 | 481 | |
| 482 | - if ( plugin_basename( __FILE__ ) === $plugin_file ) { |
|
| 483 | - $plugin_meta[] = '<strong>' . sprintf( __( 'You must fill-in your product license in order to get future plugin updates. <a href="%s">Click here to do it</a>.', 'wpas' ), $license_page ) . '</strong>'; |
|
| 482 | + if (plugin_basename(__FILE__) === $plugin_file) { |
|
| 483 | + $plugin_meta[] = '<strong>'.sprintf(__('You must fill-in your product license in order to get future plugin updates. <a href="%s">Click here to do it</a>.', 'wpas'), $license_page).'</strong>'; |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | return $plugin_meta; |