-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from Codeinwp/development
Added compatibility with the new pro options Added new documentation help Added legacy filters and functions
- Loading branch information
Showing
15 changed files
with
386 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
/** | ||
* The Options main wrapper class. | ||
* | ||
* @link http://themeisle.com | ||
* @since 3.0.3 | ||
* | ||
* @package feedzy-rss-feeds | ||
* @subpackage feedzy-rss-feeds/includes/admin | ||
*/ | ||
if ( ! class_exists( 'Feedy_Rss_Feeds_Options' ) ) { | ||
/** | ||
* Singleton class for options wrapper | ||
*/ | ||
class Feedzy_Rss_Feeds_Options { | ||
|
||
/** | ||
* The main instance var. | ||
* | ||
* @var Feedzy_Rss_Feeds_Options The one Feedy_Rss_Feeds_Options istance. | ||
* @since 3.0.3 | ||
*/ | ||
private static $instance; | ||
|
||
/** | ||
* The main options array. | ||
* | ||
* @var array The options array. | ||
* @since 3.0.3 | ||
*/ | ||
private $options; | ||
|
||
/** | ||
* Init the main singleton instance class. | ||
* | ||
* @return Feedzy_Rss_Feeds_Options Return the instance class | ||
*/ | ||
public static function instance() { | ||
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Feedzy_Rss_Feeds_Options ) ) { | ||
self::$instance = new Feedzy_Rss_Feeds_Options; | ||
self::$instance->init(); | ||
} | ||
|
||
return self::$instance; | ||
} | ||
|
||
/** | ||
* Init the default values of the options class. | ||
*/ | ||
public function init() { | ||
self::$instance->options = get_option( Feedzy_Rss_Feeds::get_plugin_name() ); | ||
} | ||
|
||
/** | ||
* Get the key option value from DB. | ||
* | ||
* @param string $key The key name of the option. | ||
* | ||
* @return bool|mixed The value of the option | ||
*/ | ||
public function get_var( $key ) { | ||
if ( isset( self::$instance->options[ $key ] ) ) { | ||
return self::$instance->options[ $key ]; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Setter method for updating the options array. | ||
* | ||
* @param string $key The name of option. | ||
* @param string $value The value of the option. | ||
* | ||
* @return bool|mixed The value of the option. | ||
*/ | ||
public function set_var( $key, $value = '' ) { | ||
self::$instance->options[ $key ] = apply_filters( 'feedzy_pre_set_option_' . $key, $value ); | ||
|
||
return update_option( Feedzy_Rss_Feeds::get_plugin_name(), self::$instance->options ); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* The Options main wrapper class. | ||
* | ||
* @link http://themeisle.com | ||
* @since 3.0.3 | ||
* | ||
* @package feedzy-rss-feeds | ||
* @subpackage feedzy-rss-feeds/includes/admin | ||
*/ | ||
if ( ! class_exists( 'Feedzy_Rss_Feeds_Upgrader' ) ) { | ||
/** | ||
* Class Feedzy_Rss_Feeds_Upgrader for upgrading processes | ||
*/ | ||
class Feedzy_Rss_Feeds_Upgrader { | ||
/** | ||
* Store the database version of the plugin. | ||
* | ||
* @var string $db_version Version from the database of the plugin. | ||
*/ | ||
public $db_version; | ||
|
||
/** | ||
* Stores the plugin php version. | ||
* | ||
* @var string $php_version The plugin php version | ||
*/ | ||
public $php_version; | ||
|
||
/** | ||
* Feedzy_Rss_Feeds_Upgrader constructor. | ||
*/ | ||
public function __construct() { | ||
$php_version = Feedzy_Rss_Feeds::get_version(); | ||
$db_version = feedzy_options()->get_var( 'db_version' ); | ||
if ( $db_version === false ) { | ||
feedzy_options()->set_var( 'db_version', $php_version ); | ||
$this->db_version = $php_version; | ||
} else { | ||
if ( feedzy_options()->get_var( 'is_new' ) === false ) { | ||
feedzy_options()->set_var( 'is_new', 'no' ); | ||
} | ||
$this->db_version = $db_version; | ||
} | ||
$this->php_version = $php_version; | ||
} | ||
|
||
/** | ||
* Check if we need to run an upgrade or not. | ||
*/ | ||
public function check() { | ||
if ( version_compare( $this->db_version, $this->php_version ) === - 1 ) { | ||
do_action( 'feedzy_upgrade_to_' . self::version_to_hook( $this->php_version ), $this->db_version ); | ||
} | ||
} | ||
|
||
/** | ||
* Normalize version to be used in hooks. | ||
* | ||
* @param string $version In format 2.0.0. | ||
* | ||
* @return string Version format 2_0_0. | ||
*/ | ||
public static function version_to_hook( $version ) { | ||
return str_replace( '.', '_', $version ); | ||
} | ||
} | ||
} |
Oops, something went wrong.