Skip to content
Snippets Groups Projects
Commit b42b5f6d authored by Grzegorz Rola's avatar Grzegorz Rola
Browse files

1.9

parent ba54336e
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
private $plugin;
public function __construct( WPDesk_Plugin_1_8 $plugin ) {
public function __construct( WPDesk_Plugin_1_9 $plugin ) {
$this->plugin = $plugin;
$this->hooks();
}
......
......@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
require_once 'functions.php';
if ( ! class_exists( 'WPDesk_Plugin_1_8' ) ) {
if ( ! class_exists( 'WPDesk_Plugin_1_9' ) ) {
require_once 'class-settings.php';
......@@ -14,7 +14,7 @@ if ( ! class_exists( 'WPDesk_Plugin_1_8' ) ) {
* @author Grzegorz
*
*/
class WPDesk_Plugin_1_8 {
class WPDesk_Plugin_1_9 {
const VERSION = '1.8';
......@@ -45,7 +45,7 @@ if ( ! class_exists( 'WPDesk_Plugin_1_8' ) ) {
$this->init_base_variables( $base_file );
if ( $this->plugin_is_active ) {
if ( $this->plugin_has_settings ) {
$this->settings = new WPDesk_Settings_1_8( $this, $this->get_namespace(), $this->default_settings_tab );
$this->settings = new WPDesk_Settings_1_9( $this, $this->get_namespace(), $this->default_settings_tab );
$this->options = $this->settings->get_settings();
}
}
......
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! class_exists( 'WPDesk_Requirements_1_9' ) ) {
// https://markjaquith.wordpress.com/2018/02/19/handling-old-wordpress-and-php-versions-in-your-plugin/
class WPDesk_Requirements_1_9 {
private $title = '';
private $php = '5.3';
private $wp = '4.5';
private $woocommerce = '2.6';
private $file;
public function __construct( $args ) {
foreach ( array( 'title', 'php', 'wp', 'file', 'woocommerce' ) as $setting ) {
if ( isset( $args[$setting] ) ) {
$this->$setting = $args[$setting];
}
}
}
public function passes() {
$passes = $this->php_passes() && $this->wp_passes();
if ( ! $passes ) {
add_action( 'admin_notices', array( $this, 'deactivate' ) );
}
return $passes;
}
public function deactivate() {
if ( isset( $this->file ) ) {
deactivate_plugins( plugin_basename( $this->file ) );
}
}
private function php_passes() {
if ( $this->__php_at_least( $this->php ) ) {
return true;
} else {
add_action( 'admin_notices', array( $this, 'php_version_notice' ) );
return false;
}
}
private static function __php_at_least( $min_version ) {
return version_compare( phpversion(), $min_version, '>=' );
}
public function php_version_notice() {
echo '<div class="error">';
echo "<p>The &#8220;" . esc_html( $this->title ) . "&#8221; plugin cannot run on PHP versions older than " . $this->php . '. Please contact your host and ask them to upgrade.</p>';
echo '</div>';
}
private function wp_passes() {
if ( $this->__wp_at_least( $this->wp ) ) {
return true;
} else {
add_action( 'admin_notices', array( $this, 'wp_version_notice' ) );
return false;
}
}
private static function __wp_at_least( $min_version ) {
return version_compare( get_bloginfo( 'version' ), $min_version, '>=' );
}
public function wp_version_notice() {
echo '<div class="error">';
echo "<p>The &#8220;" . esc_html( $this->title ) . "&#8221; plugin cannot run on WordPress versions older than " . $this->wp . '. Please update WordPress.</p>';
echo '</div>';
}
}
}
......@@ -2,9 +2,9 @@
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! class_exists( 'WPDesk_Settings_1_8' ) ) {
if ( ! class_exists( 'WPDesk_Settings_1_9' ) ) {
if ( ! class_exists( 'WPDesk_S214_Settings_1_8' ) ) {
if ( ! class_exists( 'WPDesk_S214_Settings_1_9' ) ) {
require_once 'settings-api/class.s214-settings.php';
}
......@@ -14,7 +14,7 @@ if ( ! class_exists( 'WPDesk_Settings_1_8' ) ) {
* @author Grzegorz
*
*/
class WPDesk_Settings_1_8 extends WPDesk_S214_Settings_1_8 {
class WPDesk_Settings_1_9 extends WPDesk_S214_Settings_1_9 {
private $slug;
......@@ -26,7 +26,7 @@ if ( ! class_exists( 'WPDesk_Settings_1_8' ) ) {
protected $func = 'wpdesk_plugin';
public function __construct( WPDesk_Plugin_1_8 $plugin, $slug = 'wpdesk-settings', $default_tab = 'general' ) {
public function __construct( WPDesk_Plugin_1_9 $plugin, $slug = 'wpdesk-settings', $default_tab = 'general' ) {
parent::__construct( $slug, $default_tab );
$this->slug = $slug;
$this->plugin = $plugin;
......@@ -40,7 +40,6 @@ if ( ! class_exists( 'WPDesk_Settings_1_8' ) ) {
}
public function render_settings_page() {
settings_errors();
parent::render_settings_page();
}
......
......@@ -18,7 +18,7 @@ if( ! defined( 'ABSPATH' ) ) {
*
* @since 1.0.0
*/
class WPDesk_S214_Settings_1_8 {
class WPDesk_S214_Settings_1_9 {
/**
......
......@@ -42,7 +42,7 @@
require_once( 'classes/wpdesk/class-plugin.php' );
class WPDesk_Plugin_Template_Plugin extends WPDesk_Plugin_1_8 {
class WPDesk_Plugin_Template_Plugin extends WPDesk_Plugin_1_9 {
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment