Skip to content

Commit 0785d15

Browse files
authored
Merge pull request #29 from Codeinwp/development
Added compatibility with the new pro options Added new documentation help Added legacy filters and functions
2 parents f027cf6 + bc5ab4b commit 0785d15

15 files changed

+386
-137
lines changed

css/feedzy-rss-feeds.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* feedzy-rss-feeds.css
33
* Feedzy RSS Feed
44
* Copyright: (c) 2016 Themeisle, themeisle.com
5-
* Version: 3.0.2
5+
* Version: 3.0.3
66
* Plugin Name: FEEDZY RSS Feeds
77
* Plugin URI: http://themeisle.com/plugins/feedzy-rss-feeds/
88
* Author: Themeisle

css/form.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,3 +722,8 @@ img {
722722
.feedzy-template-style2 {
723723
background: url(../img/feedzy-style2-template.jpg) no-repeat bottom center;
724724
}
725+
726+
input[disabled],
727+
select[disabled] {
728+
cursor: not-allowed;
729+
}

feedzy-rss-feed.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@
1515
* Plugin Name: Feedzy RSS Feeds Lite
1616
* Plugin URI: https://themeisle.com/plugins/feedzy-rss-feeds-lite/
1717
* Description: This is a short description of what the plugin does. It's displayed in the WordPress admin area.
18-
* Version: 3.0.2
18+
* Version: 3.0.3
1919
* Author: Themeisle
2020
* Author URI: http://themeisle.com
2121
* License: GPL-2.0+
2222
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
2323
* Text Domain: feedzy-rss-feeds
2424
* Domain Path: /languages
2525
*/
26-
2726
// If this file is called directly, abort.
2827
if ( ! defined( 'WPINC' ) ) {
2928
die;
3029
}
31-
3230
/**
3331
* The code that runs during plugin activation.
3432
* This action is documented in includes/feedzy-rss-feeds-activator.php
@@ -49,7 +47,6 @@ function deactivate_feedzy_rss_feeds() {
4947

5048
register_activation_hook( __FILE__, 'activate_feedzy_rss_feeds' );
5149
register_deactivation_hook( __FILE__, 'deactivate_feedzy_rss_feeds' );
52-
5350
/**
5451
* The core plugin class that is used to define internationalization,
5552
* admin-specific hooks, and public-facing site hooks.
@@ -58,36 +55,37 @@ function deactivate_feedzy_rss_feeds() {
5855
*/
5956
function feedzy_rss_feeds_autoload( $class ) {
6057
$namespaces = array( 'Feedzy_Rss_Feeds' );
61-
6258
foreach ( $namespaces as $namespace ) {
6359
if ( substr( $class, 0, strlen( $namespace ) ) == $namespace ) {
6460
$filename = plugin_dir_path( __FILE__ ) . 'includes/' . str_replace( '_', '-', strtolower( $class ) ) . '.php';
6561
if ( is_readable( $filename ) ) {
6662
require_once $filename;
63+
6764
return true;
6865
}
69-
7066
$filename = plugin_dir_path( __FILE__ ) . 'includes/abstract/' . str_replace( '_', '-', strtolower( $class ) ) . '.php';
7167
if ( is_readable( $filename ) ) {
7268
require_once $filename;
69+
7370
return true;
7471
}
75-
7672
$filename = plugin_dir_path( __FILE__ ) . 'includes/admin/' . str_replace( '_', '-', strtolower( $class ) ) . '.php';
7773
if ( is_readable( $filename ) ) {
7874
require_once $filename;
75+
7976
return true;
8077
}
8178
}
8279
}
8380
if ( is_readable( plugin_dir_path( __FILE__ ) . 'includes/admin/feedzy-wp-widget.php' ) ) {
8481
require_once plugin_dir_path( __FILE__ ) . 'includes/admin/feedzy-wp-widget.php';
82+
8583
return true;
8684
}
85+
8786
return false;
8887
}
8988

90-
9189
/**
9290
* Begins execution of the plugin.
9391
*
@@ -101,12 +99,9 @@ function run_feedzy_rss_feeds() {
10199
define( 'FEEDZY_BASEFILE', __FILE__ );
102100
define( 'FEEDZY_ABSURL', plugins_url( '/', __FILE__ ) );
103101
define( 'FEEDZY_ABSPATH', dirname( __FILE__ ) );
104-
105-
$plugin = new Feedzy_Rss_Feeds();
106-
$plugin->run();
107-
102+
$feedzy = new Feedzy_Rss_Feeds();
103+
$feedzy->run();
108104
}
109105

110106
spl_autoload_register( 'feedzy_rss_feeds_autoload' );
111-
112107
run_feedzy_rss_feeds();

form/form.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@
3838
foreach ( $section['elements'] as $name => $props ) {
3939
$element = '';
4040
$disabled = '';
41+
$badge = '';
4142
if ( isset( $props['disabled'] ) && $props['disabled'] ) {
4243
$disabled = 'disabled="true"';
44+
$badge = '<small class="feedzy_pro_tag">' . __( 'Premium', 'feedzy-rss-feeds' ) . '</small>';
4345
}
4446
switch ( $props['type'] ) {
4547
case 'select':
@@ -86,7 +88,7 @@
8688
$output .= '
8789
<div class="row feedzy_element_' . $name . '">
8890
<div class="column column-50">
89-
<label for="' . $name . '">' . $props['label'] . '</label>
91+
<label for="' . $name . '">' . $props['label'] . $badge . '</label>
9092
</div>
9193
<div class="column column-50">
9294
' . $element . '

includes/abstract/feedzy-rss-feeds-admin-abstract.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,17 @@ public function feedzy_summary_input_filter( $description, $content, $feedURL )
317317
* @since 3.0.0
318318
* @access public
319319
* @param boolean $continue A boolean to stop the script.
320-
* @param array $keywords_title The keywords for title.
320+
* @param array $sc The shortcode attributes.
321321
* @param object $item The feed item.
322322
* @param string $feedURL The feed URL.
323323
* @return boolean
324324
*/
325-
public function feedzy_feed_item_keywords_title( $continue, $keywords_title, $item, $feedURL ) {
325+
public function feedzy_feed_item_keywords_title( $continue, $sc, $item, $feedURL ) {
326+
if ( feedzy_is_new() && ! feedzy_is_pro() ) {
327+
return true;
328+
}
329+
330+
$keywords_title = $sc['keywords_title'];
326331
if ( ! empty( $keywords_title ) ) {
327332
$continue = false;
328333
foreach ( $keywords_title as $keyword ) {
@@ -334,21 +339,6 @@ public function feedzy_feed_item_keywords_title( $continue, $keywords_title, $it
334339
return $continue;
335340
}
336341

337-
/**
338-
* Insert cover picture to main rss feed content
339-
*
340-
* @since 3.0.0
341-
* @access public
342-
* @param string $content The item feed content.
343-
* @return string
344-
*/
345-
public function feedzy_insert_thumbnail_rss( $content ) {
346-
global $post;
347-
if ( has_post_thumbnail( $post->ID ) ) {
348-
$content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail' ) . '' . $content;
349-
}
350-
return $content;
351-
}
352342

353343
/**
354344
* Include cover picture (medium) to rss feed enclosure
@@ -456,6 +446,10 @@ public function sanitize_attr( $sc, $feedURL ) {
456446
$sc['keywords_title'] = rtrim( $sc['keywords_title'], ',' );
457447
$sc['keywords_title'] = array_map( 'trim', explode( ',', $sc['keywords_title'] ) );
458448
}
449+
if ( ! empty( $sc['keywords_ban'] ) ) {
450+
$sc['keywords_ban'] = rtrim( $sc['keywords_ban'], ',' );
451+
$sc['keywords_ban'] = array_map( 'trim', explode( ',', $sc['keywords_ban'] ) );
452+
}
459453

460454
if ( ! empty( $sc['summarylength'] ) && ! ctype_digit( $sc['summarylength'] ) ) {
461455
$sc['summarylength'] = '';
@@ -633,7 +627,7 @@ public function render_content( $sc, $feed, $content = '', $feedURL ) {
633627
$items = apply_filters( 'feedzy_feed_items', $feed->get_items(), $feedURL );
634628
$feed_items = array();
635629
foreach ( (array) $items as $item ) {
636-
$continue = apply_filters( 'feedzy_item_keyword', true, $sc['keywords_title'], $item, $feedURL );
630+
$continue = apply_filters( 'feedzy_item_keyword', true, $sc, $item, $feedURL );
637631
if ( $continue == true ) {
638632
// Count items
639633
if ( $count >= $sc['max'] ) {

includes/admin/feedzy-rss-feeds-admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function feedzy_filter_plugin_row_meta( $links, $file ) {
116116
if ( strpos( $file, 'feedzy-rss-feed.php' ) !== false ) {
117117
$new_links = array(
118118
'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>',
119-
'more_plugins' => '<a href="http://themeisle.com/wordpress-plugins/" target="_blank" title="' . __( 'More Plugins', 'feedzy-rss-feeds' ) . '">' . __( 'More Plugins', 'feedzy-rss-feeds' ) . '</a>',
119+
'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>',
120120
);
121121

122122
$links = array_merge( $links, $new_links );
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
/**
3+
* The Options main wrapper class.
4+
*
5+
* @link http://themeisle.com
6+
* @since 3.0.3
7+
*
8+
* @package feedzy-rss-feeds
9+
* @subpackage feedzy-rss-feeds/includes/admin
10+
*/
11+
if ( ! class_exists( 'Feedy_Rss_Feeds_Options' ) ) {
12+
/**
13+
* Singleton class for options wrapper
14+
*/
15+
class Feedzy_Rss_Feeds_Options {
16+
17+
/**
18+
* The main instance var.
19+
*
20+
* @var Feedzy_Rss_Feeds_Options The one Feedy_Rss_Feeds_Options istance.
21+
* @since 3.0.3
22+
*/
23+
private static $instance;
24+
25+
/**
26+
* The main options array.
27+
*
28+
* @var array The options array.
29+
* @since 3.0.3
30+
*/
31+
private $options;
32+
33+
/**
34+
* Init the main singleton instance class.
35+
*
36+
* @return Feedzy_Rss_Feeds_Options Return the instance class
37+
*/
38+
public static function instance() {
39+
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Feedzy_Rss_Feeds_Options ) ) {
40+
self::$instance = new Feedzy_Rss_Feeds_Options;
41+
self::$instance->init();
42+
}
43+
44+
return self::$instance;
45+
}
46+
47+
/**
48+
* Init the default values of the options class.
49+
*/
50+
public function init() {
51+
self::$instance->options = get_option( Feedzy_Rss_Feeds::get_plugin_name() );
52+
}
53+
54+
/**
55+
* Get the key option value from DB.
56+
*
57+
* @param string $key The key name of the option.
58+
*
59+
* @return bool|mixed The value of the option
60+
*/
61+
public function get_var( $key ) {
62+
if ( isset( self::$instance->options[ $key ] ) ) {
63+
return self::$instance->options[ $key ];
64+
}
65+
66+
return false;
67+
}
68+
69+
/**
70+
* Setter method for updating the options array.
71+
*
72+
* @param string $key The name of option.
73+
* @param string $value The value of the option.
74+
*
75+
* @return bool|mixed The value of the option.
76+
*/
77+
public function set_var( $key, $value = '' ) {
78+
self::$instance->options[ $key ] = apply_filters( 'feedzy_pre_set_option_' . $key, $value );
79+
80+
return update_option( Feedzy_Rss_Feeds::get_plugin_name(), self::$instance->options );
81+
82+
}
83+
}
84+
}

includes/admin/feedzy-rss-feeds-ui-lang.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@ public static function get_form_elements() {
229229
'placeholder' => __( '(eg: news, sports etc.)', 'feedzy-rss-feeds' ),
230230
'type' => 'text',
231231
'value' => '',
232+
'disabled' => feedzy_is_new(),
233+
),
234+
'keywords_ban' => array(
235+
'label' => __( 'Exclude items if title or content contains specific keyword(s) (comma-separated list/case sensitive). ', 'feedzy-rss-feeds' ),
236+
'placeholder' => __( '(eg: politics, gossip etc.)', 'feedzy-rss-feeds' ),
237+
'type' => 'text',
238+
'value' => '',
239+
'disabled' => true,
232240
),
233241
),
234242
),
@@ -276,7 +284,7 @@ public static function get_form_elements() {
276284
'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>',
277285
'elements' => array(
278286
'price' => array(
279-
'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>',
287+
'label' => __( 'Should we display the price from the feed if it is available?', 'feedzy-rss-feeds' ),
280288
'type' => 'select',
281289
'disabled' => true,
282290
'value' => '',
@@ -296,21 +304,21 @@ public static function get_form_elements() {
296304
),
297305
),
298306
'referral_url' => array(
299-
'label' => __( 'Referral URL parameters (w/o "?").', 'feedzy-rss-feeds' ) . '<small class="feedzy_pro_tag">' . __( 'Premium', 'feedzy-rss-feeds' ) . '</small>',
307+
'label' => __( 'Referral URL parameters (w/o "?").', 'feedzy-rss-feeds' ),
300308
'placeholder' => __( '(eg. promo_code=feedzy_is_awesome)', 'feedzy-rss-feeds' ),
301309
'type' => 'text',
302310
'disabled' => true,
303311
'value' => '',
304312
),
305313
'columns' => array(
306-
'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>',
314+
'label' => __( 'How many columns we should use to display the feed items', 'feedzy-rss-feeds' ),
307315
'placeholder' => __( '(eg. 1, 2, ..., 6)', 'feedzy-rss-feeds' ),
308316
'type' => 'number',
309317
'disabled' => true,
310318
'value' => '1',
311319
),
312320
'template' => array(
313-
'label' => __( 'Template to use when displaying the feed.', 'feedzy-rss-feeds' ) . '<small class="feedzy_pro_tag">' . __( 'Premium', 'feedzy-rss-feeds' ) . '</small>',
321+
'label' => __( 'Template to use when displaying the feed.', 'feedzy-rss-feeds' ),
314322
'type' => 'radio',
315323
'disabled' => true,
316324
'value' => '',
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* The Options main wrapper class.
4+
*
5+
* @link http://themeisle.com
6+
* @since 3.0.3
7+
*
8+
* @package feedzy-rss-feeds
9+
* @subpackage feedzy-rss-feeds/includes/admin
10+
*/
11+
if ( ! class_exists( 'Feedzy_Rss_Feeds_Upgrader' ) ) {
12+
/**
13+
* Class Feedzy_Rss_Feeds_Upgrader for upgrading processes
14+
*/
15+
class Feedzy_Rss_Feeds_Upgrader {
16+
/**
17+
* Store the database version of the plugin.
18+
*
19+
* @var string $db_version Version from the database of the plugin.
20+
*/
21+
public $db_version;
22+
23+
/**
24+
* Stores the plugin php version.
25+
*
26+
* @var string $php_version The plugin php version
27+
*/
28+
public $php_version;
29+
30+
/**
31+
* Feedzy_Rss_Feeds_Upgrader constructor.
32+
*/
33+
public function __construct() {
34+
$php_version = Feedzy_Rss_Feeds::get_version();
35+
$db_version = feedzy_options()->get_var( 'db_version' );
36+
if ( $db_version === false ) {
37+
feedzy_options()->set_var( 'db_version', $php_version );
38+
$this->db_version = $php_version;
39+
} else {
40+
if ( feedzy_options()->get_var( 'is_new' ) === false ) {
41+
feedzy_options()->set_var( 'is_new', 'no' );
42+
}
43+
$this->db_version = $db_version;
44+
}
45+
$this->php_version = $php_version;
46+
}
47+
48+
/**
49+
* Check if we need to run an upgrade or not.
50+
*/
51+
public function check() {
52+
if ( version_compare( $this->db_version, $this->php_version ) === - 1 ) {
53+
do_action( 'feedzy_upgrade_to_' . self::version_to_hook( $this->php_version ), $this->db_version );
54+
}
55+
}
56+
57+
/**
58+
* Normalize version to be used in hooks.
59+
*
60+
* @param string $version In format 2.0.0.
61+
*
62+
* @return string Version format 2_0_0.
63+
*/
64+
public static function version_to_hook( $version ) {
65+
return str_replace( '.', '_', $version );
66+
}
67+
}
68+
}

0 commit comments

Comments
 (0)