Skip to content

Commit

Permalink
Merge pull request #29 from Codeinwp/development
Browse files Browse the repository at this point in the history
Added compatibility with the new pro options
Added new documentation help
Added legacy filters and functions
  • Loading branch information
selul authored Jan 10, 2017
2 parents f027cf6 + bc5ab4b commit 0785d15
Show file tree
Hide file tree
Showing 15 changed files with 386 additions and 137 deletions.
2 changes: 1 addition & 1 deletion css/feedzy-rss-feeds.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* feedzy-rss-feeds.css
* Feedzy RSS Feed
* Copyright: (c) 2016 Themeisle, themeisle.com
* Version: 3.0.2
* Version: 3.0.3
* Plugin Name: FEEDZY RSS Feeds
* Plugin URI: http://themeisle.com/plugins/feedzy-rss-feeds/
* Author: Themeisle
Expand Down
5 changes: 5 additions & 0 deletions css/form.css
Original file line number Diff line number Diff line change
Expand Up @@ -722,3 +722,8 @@ img {
.feedzy-template-style2 {
background: url(../img/feedzy-style2-template.jpg) no-repeat bottom center;
}

input[disabled],
select[disabled] {
cursor: not-allowed;
}
21 changes: 8 additions & 13 deletions feedzy-rss-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@
* Plugin Name: Feedzy RSS Feeds Lite
* Plugin URI: https://themeisle.com/plugins/feedzy-rss-feeds-lite/
* Description: This is a short description of what the plugin does. It's displayed in the WordPress admin area.
* Version: 3.0.2
* Version: 3.0.3
* Author: Themeisle
* Author URI: http://themeisle.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: feedzy-rss-feeds
* Domain Path: /languages
*/

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}

/**
* The code that runs during plugin activation.
* This action is documented in includes/feedzy-rss-feeds-activator.php
Expand All @@ -49,7 +47,6 @@ function deactivate_feedzy_rss_feeds() {

register_activation_hook( __FILE__, 'activate_feedzy_rss_feeds' );
register_deactivation_hook( __FILE__, 'deactivate_feedzy_rss_feeds' );

/**
* The core plugin class that is used to define internationalization,
* admin-specific hooks, and public-facing site hooks.
Expand All @@ -58,36 +55,37 @@ function deactivate_feedzy_rss_feeds() {
*/
function feedzy_rss_feeds_autoload( $class ) {
$namespaces = array( 'Feedzy_Rss_Feeds' );

foreach ( $namespaces as $namespace ) {
if ( substr( $class, 0, strlen( $namespace ) ) == $namespace ) {
$filename = plugin_dir_path( __FILE__ ) . 'includes/' . str_replace( '_', '-', strtolower( $class ) ) . '.php';
if ( is_readable( $filename ) ) {
require_once $filename;

return true;
}

$filename = plugin_dir_path( __FILE__ ) . 'includes/abstract/' . str_replace( '_', '-', strtolower( $class ) ) . '.php';
if ( is_readable( $filename ) ) {
require_once $filename;

return true;
}

$filename = plugin_dir_path( __FILE__ ) . 'includes/admin/' . str_replace( '_', '-', strtolower( $class ) ) . '.php';
if ( is_readable( $filename ) ) {
require_once $filename;

return true;
}
}
}
if ( is_readable( plugin_dir_path( __FILE__ ) . 'includes/admin/feedzy-wp-widget.php' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'includes/admin/feedzy-wp-widget.php';

return true;
}

return false;
}


/**
* Begins execution of the plugin.
*
Expand All @@ -101,12 +99,9 @@ function run_feedzy_rss_feeds() {
define( 'FEEDZY_BASEFILE', __FILE__ );
define( 'FEEDZY_ABSURL', plugins_url( '/', __FILE__ ) );
define( 'FEEDZY_ABSPATH', dirname( __FILE__ ) );

$plugin = new Feedzy_Rss_Feeds();
$plugin->run();

$feedzy = new Feedzy_Rss_Feeds();
$feedzy->run();
}

spl_autoload_register( 'feedzy_rss_feeds_autoload' );

run_feedzy_rss_feeds();
4 changes: 3 additions & 1 deletion form/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
foreach ( $section['elements'] as $name => $props ) {
$element = '';
$disabled = '';
$badge = '';
if ( isset( $props['disabled'] ) && $props['disabled'] ) {
$disabled = 'disabled="true"';
$badge = '<small class="feedzy_pro_tag">' . __( 'Premium', 'feedzy-rss-feeds' ) . '</small>';
}
switch ( $props['type'] ) {
case 'select':
Expand Down Expand Up @@ -86,7 +88,7 @@
$output .= '
<div class="row feedzy_element_' . $name . '">
<div class="column column-50">
<label for="' . $name . '">' . $props['label'] . '</label>
<label for="' . $name . '">' . $props['label'] . $badge . '</label>
</div>
<div class="column column-50">
' . $element . '
Expand Down
30 changes: 12 additions & 18 deletions includes/abstract/feedzy-rss-feeds-admin-abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,17 @@ public function feedzy_summary_input_filter( $description, $content, $feedURL )
* @since 3.0.0
* @access public
* @param boolean $continue A boolean to stop the script.
* @param array $keywords_title The keywords for title.
* @param array $sc The shortcode attributes.
* @param object $item The feed item.
* @param string $feedURL The feed URL.
* @return boolean
*/
public function feedzy_feed_item_keywords_title( $continue, $keywords_title, $item, $feedURL ) {
public function feedzy_feed_item_keywords_title( $continue, $sc, $item, $feedURL ) {
if ( feedzy_is_new() && ! feedzy_is_pro() ) {
return true;
}

$keywords_title = $sc['keywords_title'];
if ( ! empty( $keywords_title ) ) {
$continue = false;
foreach ( $keywords_title as $keyword ) {
Expand All @@ -334,21 +339,6 @@ public function feedzy_feed_item_keywords_title( $continue, $keywords_title, $it
return $continue;
}

/**
* Insert cover picture to main rss feed content
*
* @since 3.0.0
* @access public
* @param string $content The item feed content.
* @return string
*/
public function feedzy_insert_thumbnail_rss( $content ) {
global $post;
if ( has_post_thumbnail( $post->ID ) ) {
$content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail' ) . '' . $content;
}
return $content;
}

/**
* Include cover picture (medium) to rss feed enclosure
Expand Down Expand Up @@ -456,6 +446,10 @@ public function sanitize_attr( $sc, $feedURL ) {
$sc['keywords_title'] = rtrim( $sc['keywords_title'], ',' );
$sc['keywords_title'] = array_map( 'trim', explode( ',', $sc['keywords_title'] ) );
}
if ( ! empty( $sc['keywords_ban'] ) ) {
$sc['keywords_ban'] = rtrim( $sc['keywords_ban'], ',' );
$sc['keywords_ban'] = array_map( 'trim', explode( ',', $sc['keywords_ban'] ) );
}

if ( ! empty( $sc['summarylength'] ) && ! ctype_digit( $sc['summarylength'] ) ) {
$sc['summarylength'] = '';
Expand Down Expand Up @@ -633,7 +627,7 @@ public function render_content( $sc, $feed, $content = '', $feedURL ) {
$items = apply_filters( 'feedzy_feed_items', $feed->get_items(), $feedURL );
$feed_items = array();
foreach ( (array) $items as $item ) {
$continue = apply_filters( 'feedzy_item_keyword', true, $sc['keywords_title'], $item, $feedURL );
$continue = apply_filters( 'feedzy_item_keyword', true, $sc, $item, $feedURL );
if ( $continue == true ) {
// Count items
if ( $count >= $sc['max'] ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/feedzy-rss-feeds-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function feedzy_filter_plugin_row_meta( $links, $file ) {
if ( strpos( $file, 'feedzy-rss-feed.php' ) !== false ) {
$new_links = array(
'doc' => '<a href="http://docs.themeisle.com/article/277-feedzy-rss-feeds-hooks" target="_blank" title="' . __( 'Documentation and examples', 'feedzy-rss-feeds' ) . '">' . __( 'Documentation and examples', 'feedzy-rss-feeds' ) . '</a>',
'more_plugins' => '<a href="http://themeisle.com/wordpress-plugins/" target="_blank" title="' . __( 'More Plugins', 'feedzy-rss-feeds' ) . '">' . __( 'More Plugins', 'feedzy-rss-feeds' ) . '</a>',
'more_features' => '<a href="https://themeisle.com/plugins/feedzy-rss-feeds/" target="_blank" title="' . __( 'More Plugins', 'feedzy-rss-feeds' ) . '">' . __( 'More Features', 'feedzy-rss-feeds' ) . '<i class="dashicons dashicons-unlock"></i></a>',
);

$links = array_merge( $links, $new_links );
Expand Down
84 changes: 84 additions & 0 deletions includes/admin/feedzy-rss-feeds-options.php
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 );

}
}
}
16 changes: 12 additions & 4 deletions includes/admin/feedzy-rss-feeds-ui-lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,14 @@ public static function get_form_elements() {
'placeholder' => __( '(eg: news, sports etc.)', 'feedzy-rss-feeds' ),
'type' => 'text',
'value' => '',
'disabled' => feedzy_is_new(),
),
'keywords_ban' => array(
'label' => __( 'Exclude items if title or content contains specific keyword(s) (comma-separated list/case sensitive). ', 'feedzy-rss-feeds' ),
'placeholder' => __( '(eg: politics, gossip etc.)', 'feedzy-rss-feeds' ),
'type' => 'text',
'value' => '',
'disabled' => true,
),
),
),
Expand Down Expand Up @@ -276,7 +284,7 @@ public static function get_form_elements() {
'description' => __( 'Get access to more options and customizations with full version of Feedzy RSS Feeds . Use existing templates or extend them and make them your own.', 'feedzy-rss-feeds' ) . '<br/>' . '<a href=" https://themeisle.com/plugins/feedzy-rss-feeds/" target="_blank"><small>' . __( 'See more features of Feedzy RSS Feeds ', 'feedzy-rss-feeds' ) . '</small></a>',
'elements' => array(
'price' => array(
'label' => __( 'Should we display the price from the feed if it is available?', 'feedzy-rss-feeds' ) . '<small class="feedzy_pro_tag">' . __( 'Premium', 'feedzy-rss-feeds' ) . '</small>',
'label' => __( 'Should we display the price from the feed if it is available?', 'feedzy-rss-feeds' ),
'type' => 'select',
'disabled' => true,
'value' => '',
Expand All @@ -296,21 +304,21 @@ public static function get_form_elements() {
),
),
'referral_url' => array(
'label' => __( 'Referral URL parameters (w/o "?").', 'feedzy-rss-feeds' ) . '<small class="feedzy_pro_tag">' . __( 'Premium', 'feedzy-rss-feeds' ) . '</small>',
'label' => __( 'Referral URL parameters (w/o "?").', 'feedzy-rss-feeds' ),
'placeholder' => __( '(eg. promo_code=feedzy_is_awesome)', 'feedzy-rss-feeds' ),
'type' => 'text',
'disabled' => true,
'value' => '',
),
'columns' => array(
'label' => __( 'How many columns we should use to display the feed items', 'feedzy-rss-feeds' ) . '<small class="feedzy_pro_tag">' . __( 'Premium', 'feedzy-rss-feeds' ) . '</small>',
'label' => __( 'How many columns we should use to display the feed items', 'feedzy-rss-feeds' ),
'placeholder' => __( '(eg. 1, 2, ..., 6)', 'feedzy-rss-feeds' ),
'type' => 'number',
'disabled' => true,
'value' => '1',
),
'template' => array(
'label' => __( 'Template to use when displaying the feed.', 'feedzy-rss-feeds' ) . '<small class="feedzy_pro_tag">' . __( 'Premium', 'feedzy-rss-feeds' ) . '</small>',
'label' => __( 'Template to use when displaying the feed.', 'feedzy-rss-feeds' ),
'type' => 'radio',
'disabled' => true,
'value' => '',
Expand Down
68 changes: 68 additions & 0 deletions includes/admin/feedzy-rss-feeds-upgrader.php
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 );
}
}
}
Loading

0 comments on commit 0785d15

Please sign in to comment.