WP RSS Aggregator - Version 4.6

Version Description

(2014-09-22) = * Enhanced: Improved the user interface, with better responsiveness and tooltips. * Enhanced: Removes the ID column. The ID is now shown fixed in row actions. * Enhanced: Feed Preview indicates if feed items have no dates. * Fixed bug: If a feed item has no date, the date and time it was imported is used.

Download this release

Release Info

Developer jeangalea
Plugin Icon 128x128 WP RSS Aggregator
Version 4.6
Comparing to
See all releases

Code changes from version 4.5.3 to 4.6

changelog.txt CHANGED
@@ -1,5 +1,11 @@
 
 
 
 
 
 
1
  4.5.3 (2014-09-15)
2
- New Featured: Added filter to allow adding RSS feeds to the head of your site's pages for CPTs.
3
  Enhanced: Columns in the feed sources table are now sortable.
4
  Enhanced: Removed the ID column in the feed sources table. The ID has been moved as a row action.
5
  Enhanced: Improved various interface elements.
1
+ 4.6 (2014-09-22)
2
+ Enhanced: Improved the user interface, with better responsiveness and tooltips.
3
+ Enhanced: Removes the ID column. The ID is now shown fixed in row actions.
4
+ Enhanced: Feed Preview indicates if feed items have no dates.
5
+ Fixed bug: If a feed item has no date, the date and time it was imported is used.
6
+
7
  4.5.3 (2014-09-15)
8
+ New Feature: Added filter to allow adding RSS feeds to the head of your site's pages for CPTs.
9
  Enhanced: Columns in the feed sources table are now sortable.
10
  Enhanced: Removed the ID column in the feed sources table. The ID has been moved as a row action.
11
  Enhanced: Improved various interface elements.
css/admin-editor.css CHANGED
@@ -102,5 +102,5 @@
102
  #validate-feed-link {
103
  font-size: 0.85em;
104
  text-decoration: none;
105
- margin-left: 10px;
106
  }
102
  #validate-feed-link {
103
  font-size: 0.85em;
104
  text-decoration: none;
105
+ margin-left: 3px;
106
  }
css/admin-styles.css CHANGED
@@ -1,3 +1,13 @@
 
 
 
 
 
 
 
 
 
 
1
  .wprss-input {
2
  background: none repeat scroll 0 0 #EAF2FA;
3
  margin-bottom: 20px;
@@ -22,7 +32,7 @@
22
  }
23
 
24
  .wprss-text-input {
25
- display: block;
26
  width: 400px;
27
  max-width: 100%;
28
  }
@@ -135,12 +145,13 @@ color: darkGreen;
135
  /*.rss-aggregator_page_wprss-aggregator-settings .form-table th { width: 80px; }*/
136
 
137
 
138
- /* For excerpts and thumbnails admin screens */
139
  .wprss_feed_page_wprss-aggregator-settings input,
140
  .wprss_feed_page_wprss-aggregator-settings input[type="checkbox"],
141
  .wprss_feed_page_wprss-aggregator-settings input[type="radio"] {
142
  margin-right: 8px;
143
  }
 
144
 
145
  input#default-thumbnail,
146
  input#wprss-et-license-key,
@@ -251,7 +262,6 @@ input#thumbnails-width {
251
  /* Number Roller for Feed Source Limit */
252
  .wprss-number-roller {
253
  width: 80px;
254
- margin-right: 5px;
255
  vertical-align: middle;
256
  }
257
  @media screen and (max-width: 782px) {
@@ -544,4 +554,54 @@ body.post-type-wprss_blacklist .alignleft.actions.bulkactions {
544
  .wprss-header-small {
545
  color: #777;
546
  font-size: 0.7em;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
547
  }
1
+ body.post-type-wprss_feed q {
2
+ font-style: italic;
3
+ }
4
+ body.post-type-wprss_feed q:before {
5
+ content: '"';
6
+ }
7
+ body.post-type-wprss_feed q:after {
8
+ content: '"';
9
+ }
10
+
11
  .wprss-input {
12
  background: none repeat scroll 0 0 #EAF2FA;
13
  margin-bottom: 20px;
32
  }
33
 
34
  .wprss-text-input {
35
+ display: inline-block;
36
  width: 400px;
37
  max-width: 100%;
38
  }
145
  /*.rss-aggregator_page_wprss-aggregator-settings .form-table th { width: 80px; }*/
146
 
147
 
148
+ /* For excerpts and thumbnails admin screens
149
  .wprss_feed_page_wprss-aggregator-settings input,
150
  .wprss_feed_page_wprss-aggregator-settings input[type="checkbox"],
151
  .wprss_feed_page_wprss-aggregator-settings input[type="radio"] {
152
  margin-right: 8px;
153
  }
154
+ */
155
 
156
  input#default-thumbnail,
157
  input#wprss-et-license-key,
262
  /* Number Roller for Feed Source Limit */
263
  .wprss-number-roller {
264
  width: 80px;
 
265
  vertical-align: middle;
266
  }
267
  @media screen and (max-width: 782px) {
554
  .wprss-header-small {
555
  color: #777;
556
  font-size: 0.7em;
557
+ }
558
+
559
+ /* Inline Help ============================================================== */
560
+
561
+ .wprss-tooltip-handle,
562
+ .wprss-tooltip-handle:hover,
563
+ .wprss-tooltip-handle:focus {
564
+ text-decoration: none;
565
+ color: #aaaaaa;
566
+ outline: none;
567
+ }
568
+
569
+ .wprss-tooltip-handle {
570
+ margin-left: 5px;
571
+ font-size: 1.3em;
572
+ color: rgb(190, 190, 190);
573
+ vertical-align: middle;
574
+ }
575
+
576
+ .wprss-tooltip-handle-side {
577
+ float: right;
578
+ }
579
+
580
+ .wprss-tooltip-content {
581
+ display: none;
582
+ }
583
+
584
+ .wprss-ui-tooltip {
585
+ color: #444 !important;
586
+ padding: 8px 10px !important;
587
+ background: #fefefe !important;
588
+ border: 1px solid #ccc !important;
589
+ border-radius: 1px !important;
590
+ font-family: "Open Sans", sans-serif !important;
591
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.17) !important;
592
+ }
593
+ .wprss-ui-tooltip p:first-child {
594
+ margin-top: 0;
595
+ }
596
+ .wprss-ui-tooltip p:last-child {
597
+ margin-bottom: 0;
598
+ }
599
+ .wprss-ui-tooltip p {
600
+ margin: 8px 0;
601
+ }
602
+ .wprss-ui-tooltip p, code {
603
+ font-size: 0.9em !important;
604
+ }
605
+ .wprss-ui-tooltip hr {
606
+ margin: 0;
607
  }
includes/admin-dashboard.php CHANGED
@@ -28,6 +28,7 @@
28
  'wprss-welcome',
29
  'wprss_show_welcome_screen'
30
  );
 
31
  }
32
 
33
 
28
  'wprss-welcome',
29
  'wprss_show_welcome_screen'
30
  );
31
+
32
  }
33
 
34
 
includes/admin-display.php CHANGED
@@ -230,7 +230,7 @@
230
  break;
231
 
232
  case "publishdate":
233
- $item_date = get_post_meta( get_the_ID(), 'wprss_item_date', true );
234
  $item_date = ( $item_date === '' )? date('U') : $item_date;
235
  $publishdate = date( 'Y-m-d H:i:s', $item_date ) ;
236
  echo $publishdate;
@@ -280,8 +280,8 @@
280
  // If user clicks on the reorder link, implement reordering
281
  $orderby = $query->get( 'orderby');
282
  if( 'publishdate' == $orderby ) {
283
- $query->set( 'meta_key', 'wprss_item_date' );
284
- $query->set( 'orderby', 'meta_value_num' );
285
  }
286
  }
287
  }
@@ -322,10 +322,7 @@
322
  */
323
  function wprss_remove_row_actions( $actions, $post )
324
  {
325
- $actions = array_reverse( $actions );
326
- $actions['id'] = "<span class='wprss-row-id'>ID: $post->ID</span>";
327
- $actions = array_reverse( $actions );
328
-
329
  $page = isset( $_GET['paged'] )? '&paged=' . $_GET['paged'] : '';
330
  if ( get_post_type($post) === 'wprss_feed_item' ) {
331
  unset( $actions[ 'edit' ] );
@@ -334,6 +331,10 @@
334
  unset( $actions[ 'inline hide-if-no-js' ] );
335
  }
336
  elseif ( get_post_type($post) === 'wprss_feed' ) {
 
 
 
 
337
  unset( $actions[ 'view'] );
338
  unset( $actions[ 'inline hide-if-no-js'] );
339
  if ( get_post_status( $post->ID ) !== 'trash' ) {
230
  break;
231
 
232
  case "publishdate":
233
+ $item_date = get_the_time( 'U', get_the_ID() );
234
  $item_date = ( $item_date === '' )? date('U') : $item_date;
235
  $publishdate = date( 'Y-m-d H:i:s', $item_date ) ;
236
  echo $publishdate;
280
  // If user clicks on the reorder link, implement reordering
281
  $orderby = $query->get( 'orderby');
282
  if( 'publishdate' == $orderby ) {
283
+ $query->set( 'order', 'DESC' );
284
+ $query->set( 'orderby', 'date' );
285
  }
286
  }
287
  }
322
  */
323
  function wprss_remove_row_actions( $actions, $post )
324
  {
325
+
 
 
 
326
  $page = isset( $_GET['paged'] )? '&paged=' . $_GET['paged'] : '';
327
  if ( get_post_type($post) === 'wprss_feed_item' ) {
328
  unset( $actions[ 'edit' ] );
331
  unset( $actions[ 'inline hide-if-no-js' ] );
332
  }
333
  elseif ( get_post_type($post) === 'wprss_feed' ) {
334
+ $actions = array_reverse( $actions );
335
+ $actions['id'] = "<span class='wprss-row-id'>ID: $post->ID</span>";
336
+ $actions = array_reverse( $actions );
337
+
338
  unset( $actions[ 'view'] );
339
  unset( $actions[ 'inline hide-if-no-js'] );
340
  if ( get_post_status( $post->ID ) !== 'trash' ) {
includes/admin-help-metaboxes.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if( class_exists('WPRSS_Help') ) {
4
+ $help = WPRSS_Help::get_instance();
5
+
6
+ // Feed source setting fields
7
+ $prefix = 'field_';
8
+ $tooltips = array(
9
+ /* -----------------------------
10
+ * Feed Source Details Metabox
11
+ * -----------------------------
12
+ */
13
+ // Feed Source URL
14
+ 'wprss_url' => 'The URL of the feed source. In most cases, the URL of the site will also work, but for best results we recommend trying to find the URL of the RSS feed.
15
+
16
+ Also include the <code>http://</code> prefix in the URL.',
17
+ // Feed limit
18
+ 'wprss_limit' => 'The maximum number of imported items from this feed to keep stored.
19
+
20
+ When new items are imported and the limit is exceeded, the oldest feed items will be deleted to make room for new ones.
21
+
22
+ If you already have items imported from this feed source, setting this option now may delete some of your items, in order to comply with the limit.',
23
+ // Link to Enclosure
24
+ 'wprss_enclosure' => 'Tick this box to make feed items link to their enclosure URL, rather than link to the original article.
25
+
26
+ Enclosure tags are RSS tags that may be included with a feed items. These tags typically contain links to images, audio, videos, attachment files or even flash content.',
27
+
28
+ /* -------------------------
29
+ * Feed Processing Metabox
30
+ * -------------------------
31
+ */
32
+ // Feed State
33
+ 'wprss_state' => 'State of the feed, active or paused.
34
+
35
+ If active, the feed source will fetch items periodically, according to the settings below.
36
+
37
+ If paused, the feed source will not fetch feed items periodically.',
38
+ // Activate Feed: [date]
39
+ 'wprss_activate_feed' => 'You can set a time, in UTC, in the future when the feed source will become active, if it is paused.
40
+
41
+ Leave blank to activate immediately.',
42
+ // Pause Feed: [date]
43
+ 'wprss_pause_feed' => 'You can set a time, in UTC, in the future when the feed source will become paused, if it is active.
44
+
45
+ Leave blank to never pause.',
46
+ // Update Interval
47
+ 'wprss_update_interval' => 'How frequently the feed source should check for new items and fetch if needed.
48
+
49
+ If left as <em>Default</em>, the interval in the global settings is used.',
50
+ // Delete items older than: [date]
51
+ 'wprss_age_limit' => 'The maximum age allowed for feed items. Very useful if you are only concerned with, say, last week\'s news.
52
+
53
+ Items already imported will be deleted if they eventually exceed this age limit.
54
+
55
+ Also, items in the RSS feed that are already older than this age will not be imported at all.
56
+
57
+ Leaving empty to use the <em>Limit feed items by age</em> option in the general settings.',
58
+
59
+ /* ----------------------
60
+ * Feed Preview Metabox
61
+ * ----------------------
62
+ */
63
+ // Force Feed
64
+ 'wprss_force_feed' => 'Use this option if you are seeing an <q>Invalid feed URL</q> error in the Feed Preview above, but you are sure that the URL is correct.
65
+
66
+ Note, however, that this will disable auto-discovery, meaning that the given URL must be an RSS feed URL. Using the site\'s URL will not work.'
67
+ );
68
+ $help->add_tooltips( $tooltips, $prefix );
69
+ }
includes/admin-help-settings.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if( class_exists('WPRSS_Help') ) {
4
+ $help = WPRSS_Help::get_instance();
5
+
6
+ // Feed source setting fields
7
+ $prefix = 'setting-';
8
+ $tooltips = array(
9
+ /* -----------------
10
+ * General Section
11
+ * -----------------
12
+ */ // Limit feed items by age
13
+ 'limit-feed-items-by-age' => 'The maximum age allowed for feed items.
14
+ <hr/>
15
+
16
+ Items already imported will be deleted if they eventually exceed this age limit.
17
+
18
+ Also, items in the RSS feed that are already older than this age will not be imported at all.
19
+ <hr/>
20
+
21
+ <em>Leave empty for no limit.</em>',
22
+ // Limit feed items per feed
23
+ 'limit-feed-items-imported' => 'The maximum number of imported items to keep stored, for feed sources that do not have their own limit.
24
+ <hr/>
25
+
26
+ When new items are imported and the limit for a feed source is exceeded, the oldest feed items for that feed source will be deleted to make room for the new ones.
27
+
28
+ If you already have items imported from this feed source, setting this option now may delete some of your items, in order to comply with the limit.
29
+ <hr/>
30
+
31
+ <em>Use 0 or leave empty for no limit.</em>',
32
+ // Feed processing interval
33
+ 'cron-interval' => 'How frequently should the feed sources (that do not have their own update interval) check for updates and fetch items accordingly.
34
+
35
+ It is recommended to not have more than 20 feed sources that use this global update interval. Having too many feed sources updating precisely at the same time can cause the WP Cron System to crash.',
36
+ // Custom Feed URL
37
+ 'custom-feed-url' => 'The URL of the custom feed, located at <code>http://yoursite.com/[custom feed url]</code>.
38
+ <hr/>
39
+
40
+ WP RSS Aggregator allows you to create a custom RSS feed, that contains all of your imported feed items. This setting allows you to change the URL of this custom feed.
41
+
42
+ <hr/>
43
+
44
+ <strong>Note:</strong> You may be required to refresh you Permalinks after you change this setting, by going to <em>Settings <i class="fa fa-angle-right"></i> Permalinks</e> and clicking <em>Save</em>.',
45
+ // Custom Feed Title
46
+ 'custom-feed-title' => 'The title of the custom feed.
47
+
48
+ This title will be included in the RSS source of the custom feed, in a <code>&lt;title&gt;</code> tag.',
49
+ // Custom Feed Limit
50
+ 'custom-feed-limit' => 'The maximum number of feed items in the custom feed.',
51
+
52
+ /* --------------------------
53
+ * General Display Settings
54
+ * --------------------------
55
+ */ // Link titles
56
+ 'link-enable' => 'Check this box to make the feed item titles link to the original article.',
57
+ // Title Maximum length
58
+ 'title-limit' => 'Set the maximum number of characters to show for feed item titles.
59
+ <hr/>
60
+
61
+ <em>Leave empty for no limit.</em>',
62
+ // Show Authors
63
+ 'authors-enable' => 'Check this box to show the author for each feed item, if it is available.',
64
+ // Video Links
65
+ 'video-links' => 'For feed items from YouTube, Vimeo or Dailymotion, you can choose whether you want to have the items link to the original page link, or a link to the embedded video player only.',
66
+ // Pagination Type
67
+ 'pagination' => 'The type of pagination to use when showing feed items on multiple pages.
68
+
69
+ The first shows two links, "Older" and "Newer", which allow you to navigate through the pages.
70
+
71
+ The second shows links for all the pages, together with links for the next and previous pages.',
72
+ // Feed Limit
73
+ 'feed-limit' => 'The maximum number of feed items to display when using the shortcode.
74
+
75
+ This enables pagination if set to a number smaller than the number of items to be displayed.',
76
+ // Open Links Behaviour
77
+ 'open-dd' => 'Choose how you want links to be opened. This applies to the feed item title and the source link.',
78
+ // Set links as no follow
79
+ 'follow-dd' => 'Enable this option to set all links displayed as "NoFollow".
80
+ <hr/>
81
+
82
+ "Nofollow" provides a way to tell search engines to <em>not</em> follow certain links, such as links to feed items in this case.',
83
+
84
+ /* -------------------------
85
+ * Source Display Settings
86
+ * -------------------------
87
+ */ // Source Enabled
88
+ 'source-enable' => 'Enable this option to show the feed source name for each feed item.',
89
+ // Text preceding source
90
+ 'text-preceding-source' => 'Enter the text that you want to show before the source name. A space is automatically added between this text and the feed source name.',
91
+ // Source Link
92
+ 'source-link' => 'Enable this option to link the feed source name to the RSS feed\'s source site.',
93
+
94
+ /* -------------------------
95
+ * Date Display Settings
96
+ * -------------------------
97
+ */ // Source Enabled
98
+ 'date-enable' => 'Enable this to show the feed item\'s date.',
99
+ // Text preceding date
100
+ 'text-preceding-date' => 'Enter the text that you want to show before the feed item date. A space is automatically added between this text and the date.',
101
+ // Date Format
102
+ 'date-format' => 'The format to use for the feed item dates, as a PHP date format.',
103
+ // Time Ago Format Enable
104
+ 'time-ago-format-enable' => 'Enable this option to show the elapsed time from the feed item\'s date and time to the present time.
105
+ <em>Eg. 2 hours ago</em>',
106
+
107
+ /* --------
108
+ * Styles
109
+ * --------
110
+ */ // Styles Disable
111
+ 'styles-disable' => 'Check this box to disable all plugin styles used for displaying feed items.
112
+
113
+ This will allow you to provide your own custom CSS styles for displaying the feed items.'
114
+ );
115
+ $help->add_tooltips( $tooltips, $prefix );
116
+ }
includes/admin-help.php CHANGED
@@ -4,24 +4,884 @@
4
  *
5
  * @since 4.2
6
  */
7
- function wprss_help_page_display() {
8
  ?>
9
 
10
- <div class="wrap">
11
- <?php screen_icon( 'wprss-aggregator' ); ?>
12
-
13
- <h2><?php _e( 'Help & Support', 'wprss' ); ?></h2>
14
- <h3>Documentation</h3>
15
- <p>In the <a href="www.wprssaggregator.com/documentation/">documentation area</a> on the WP RSS Aggregator website you will find comprehensive details on how to use the core plugin
16
- and all the add-ons.</p><p>There are also some videos to help you make a quick start to setting up and enjoying this plugin.</p>
17
- <h3>Frequently Asked Questions (FAQ)</h3>
18
- <p>If after going through the documentation you still have questions, please take a look at the <a href="http://www.wprssaggregator.com/faq/">FAQ page</a> on the site, we set this
19
- up purposely to answer the most commonly asked questions by our users.</p>
20
- <h3>Support Forums - Core (free version) Plugin Users Only</h3>
21
- <p>If you're using the free version of the plugin found on WordPress.org, you can ask questions on the <a href="http://wordpress.org/support/plugin/wp-rss-aggregator">support forum</a>.</p>
22
- <h3>Email Ticketing System - Premium Add-on Users Only</h3>
23
- <p>If you still can't find an answer to your query after reading the documentation and going through the FAQ, just <a href="http://www.wprssaggregator.com/contact/">open a support request ticket</a>.<br>
24
- We'll be happy to help you out.</p>
25
- </div>
26
  <?php
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  *
5
  * @since 4.2
6
  */
7
+ function wprss_help_page_display() {
8
  ?>
9
 
10
+ <div class="wrap">
11
+ <?php screen_icon( 'wprss-aggregator' ); ?>
12
+
13
+ <h2><?php _e( 'Help & Support', 'wprss' ); ?></h2>
14
+ <h3>Documentation</h3>
15
+ <p>In the <a href="www.wprssaggregator.com/documentation/">documentation area</a> on the WP RSS Aggregator website you will find comprehensive details on how to use the core plugin
16
+ and all the add-ons.</p><p>There are also some videos to help you make a quick start to setting up and enjoying this plugin.</p>
17
+ <h3>Frequently Asked Questions (FAQ)</h3>
18
+ <p>If after going through the documentation you still have questions, please take a look at the <a href="http://www.wprssaggregator.com/faq/">FAQ page</a> on the site, we set this
19
+ up purposely to answer the most commonly asked questions by our users.</p>
20
+ <h3>Support Forums - Core (free version) Plugin Users Only</h3>
21
+ <p>If you're using the free version of the plugin found on WordPress.org, you can ask questions on the <a href="http://wordpress.org/support/plugin/wp-rss-aggregator">support forum</a>.</p>
22
+ <h3>Email Ticketing System - Premium Add-on Users Only</h3>
23
+ <p>If you still can't find an answer to your query after reading the documentation and going through the FAQ, just <a href="http://www.wprssaggregator.com/contact/">open a support request ticket</a>.<br>
24
+ We'll be happy to help you out.</p>
25
+ </div>
26
  <?php
27
+ }
28
+
29
+ /**
30
+ * Encapsulates features for providing inline help in the admin interface.
31
+ *
32
+ * The following filters are introduced:
33
+ *
34
+ * - `wprss_help_default_options` - The default options to be extended.
35
+ *
36
+ * 1. The array of options
37
+ *
38
+ * - `wprss_help_template_path` - The path of template retrieved by WPRSS_Help::get_template().
39
+ *
40
+ * 1. The path to the template.
41
+ * 2. The array of variables passed.
42
+ *
43
+ * - `wprss_help_template_vars` - The variables for the template, received by WPRSS_Help::get_template().
44
+ *
45
+ * 1. The variables array.
46
+ * 2. The path to the template, filtered by `wprss_help_template_path`.
47
+ *
48
+ * - `wprss_help_tooltip_options` - Options that are in effect when adding tooltips with WPRSS_Help::add_tooltip().
49
+ * - `wprss_help_tooltip_handle_html_options` - Options that are in effect when retrieving tooltip handle HTML with WPRSS_Help::wprss_help_tooltip_handle_html_options.
50
+ *
51
+ *
52
+ * Also, the following options are available:
53
+ *
54
+ * - `tooltip_id_prefix` - The HTML element ID prefix that will be used for tooltips.
55
+ * - `tooltip_handle_text` - The text that will appear inside the handle HTML elements.
56
+ * - `tooltip_handle_class` - The CSS class that will be assigned to tooltip handles.
57
+ * - `tooltip_content_class` - The CSS class that will be assigned to tooltip content HTML elements.
58
+ * - `enqueue_tooltip_content` - Whether or not content is to be enqueued, instead of being output directly.
59
+ *
60
+ * 1. The absolute path to the core plugin directory
61
+ */
62
+ class WPRSS_Help {
63
+
64
+ static $_instance;
65
+
66
+ protected $_options;
67
+ protected $_enqueued_tooltip_content = array();
68
+ protected $_tooltips = array();
69
+
70
+ const OPTION_NAME = 'wprss_settings_help';
71
+ const CODE_PREFIX = 'wprss_help_';
72
+ const OVERRIDE_DEFAULT_PREFIX = '!';
73
+ const TEXT_DOMAIN = WPRSS_TEXT_DOMAIN;
74
+ const HASHING_CONCATENATOR = '|';
75
+ const OPTIONS_FILTER_SUFFIX = '_options';
76
+
77
+ const TOOLTIP_DATA_KEY_ID = 'id';
78
+ const TOOLTIP_DATA_KEY_TEXT = 'text';
79
+ const TOOLTIP_DATA_KEY_OPTIONS = 'options';
80
+
81
+ /**
82
+ * Retrieve the singleton instance
83
+ *
84
+ * @return WPRSS_Help
85
+ */
86
+ public static function get_instance() {
87
+ if ( is_null( self::$_instance ) ) {
88
+ $class_name = __CLASS__; // Late static bindings not allowed
89
+ self::$_instance = new $class_name();
90
+ }
91
+
92
+ return self::$_instance;
93
+ }
94
+
95
+
96
+ public static function init() {
97
+ // Actions
98
+ add_action( 'admin_enqueue_scripts', array( self::get_instance(), '_admin_enqueue_scripts' ) );
99
+ add_action( 'admin_footer', array( self::get_instance(), '_admin_footer' ) );
100
+ }
101
+
102
+
103
+ /**
104
+ * Filters used:
105
+ *
106
+ * - `wprss_help_default_options`
107
+ *
108
+ * @param array $options Options that will overwrite defaults.
109
+ */
110
+ public function __construct( $options = array() ) {
111
+ $defaults = apply_filters( 'wprss_help_default_options', array(
112
+ 'tooltip_id_prefix' => 'wprss-tooltip-',
113
+ 'tooltip_handle_text' => '',
114
+ 'tooltip_handle_class' => 'wprss-tooltip-handle', // Used in logic to identify handle elements
115
+ 'tooltip_handle_class_extra' => 'fa fa-question-circle', // Not used in logic
116
+ 'tooltip_content_class' => 'wprss-tooltip-content',
117
+ 'tooltip_class' => 'wprss-ui-tooltip', // Overrides default jQuery UI class
118
+ 'is_enqueue_tooltip_content' => '0',
119
+ 'tooltip_handle_template' => '%1$s/help-tooltip-handle.php',
120
+ 'tooltip_content_template' => '%1$s/help-tooltip-content.php',
121
+ 'admin_footer_js_template' => '%1$s/help-footer-js.php',
122
+ 'tooltip_not_found_handle_html' => '',
123
+ 'text_domain' => self::TEXT_DOMAIN
124
+ ));
125
+ $db_options = $this->get_options_db();
126
+ $this->_set_options( $this->array_merge_recursive_distinct( $db_options, $defaults ) );
127
+
128
+ $this->_construct();
129
+ }
130
+
131
+
132
+ /**
133
+ * Used for parameter-less extension of constructor logic
134
+ */
135
+ protected function _construct() {
136
+
137
+ }
138
+
139
+
140
+ /**
141
+ * Return an option value, or the whole array of internal options.
142
+ * These options are a product of the defaults, the database, and anything
143
+ * set later on, applied on top of eachother and overwriting in that order.
144
+ *
145
+ * @param null|string $key The key of the option to return.
146
+ * @param null|mixed $default What to return if options with the specified key not found.
147
+ * @return array|mixed|null The option value, or an array of options.
148
+ */
149
+ public function get_options( $key = null, $default = null ) {
150
+ $options = $this->_options;
151
+
152
+ if ( is_null( $key ) ) {
153
+ return $options;
154
+ }
155
+
156
+ if( is_array( $key ) ) {
157
+ return $this->array_merge_recursive_distinct( $options, $key );
158
+ }
159
+
160
+ return isset( $options[ $key ] ) ? $options[ $key ] : $default;
161
+ }
162
+
163
+
164
+ /**
165
+ * Set the value of an internal option or options.
166
+ * Existing options will be overwritten. New options will be added.
167
+ * Database options will not be modified.
168
+ *
169
+ * @param string|array $key The key of the option to set, or an array of options.
170
+ * @param null|mixed $value The value of the option to set.
171
+ * @return WPRSS_Help This instance.
172
+ */
173
+ public function set_options( $key, $value = null ) {
174
+ if ( is_array( $key ) ) {
175
+ foreach ( $key as $_key => $_value ) {
176
+ $this->_set_options( $_key, $_value );
177
+ }
178
+
179
+ return $this;
180
+ }
181
+
182
+ $this->_set_options( $key, $value );
183
+ }
184
+
185
+
186
+ /**
187
+ * Set an option value, or all options.
188
+ * In latter case completely overrides the whole options array.
189
+ *
190
+ * @param string|array $key The key of the option to set, or the whole options array.
191
+ * @param null|mixed $value Value of the option to set.
192
+ * @return WPRSS_Help This instance.
193
+ */
194
+ protected function _set_options( $key, $value = null ) {
195
+ if ( is_array( $key ) ) {
196
+ $this->_options = $key;
197
+ return $this;
198
+ }
199
+
200
+ $this->_options[ $key ] = $value;
201
+ return $this;
202
+ }
203
+
204
+
205
+ /**
206
+ * Returns a WPRSS_Help option or options from the database.
207
+ *
208
+ * @param string $key The key of the option to return.
209
+ * @param null|mixed $default What to return if option identified by $key is not found.
210
+ * @return null|array|mixed The options or option value.
211
+ */
212
+ public function get_options_db( $key = null, $default = null ) {
213
+ $options = (array) get_option( self::OPTION_NAME, array() );
214
+
215
+ if ( is_null( $key ) ) {
216
+ return $options;
217
+ }
218
+
219
+ return isset( $options[ $key ] ) ? $options[ $key ] : $default;
220
+ }
221
+
222
+
223
+ /**
224
+ * Get content of a template.
225
+ *
226
+ * Filters used
227
+ *
228
+ * - `wprss_help_template_path`
229
+ * - `wprss_help_template_vars`
230
+ *
231
+ * @param string $path Full path to the template
232
+ * @param array $vars This will be passed to the template
233
+ */
234
+ public function get_template( $path, $vars = array() ) {
235
+ $vars = (array) $vars;
236
+
237
+ // Entry points
238
+ $path = apply_filters( 'wprss_help_template_path', $path, $vars );
239
+ $vars = apply_filters( 'wprss_help_template_vars', $vars, $path );
240
+
241
+ ob_start();
242
+ include($path);
243
+ $content = ob_get_contents();
244
+ ob_end_clean();
245
+
246
+ return $content;
247
+ }
248
+
249
+
250
+ /**
251
+ * This is called during the `admin_enqueue_scripts` action, and will
252
+ * enqueue scripts needed for the backend.
253
+ *
254
+ * Filters used:
255
+ *
256
+ * - `wprss_help_admin_scripts`
257
+ *
258
+ * @return WPRSS_Help This instance.
259
+ */
260
+ public function _admin_enqueue_scripts() {
261
+ $scripts = $this->apply_filters( 'admin_scripts', array(
262
+ 'jquery-ui-tooltip' => array()
263
+ ));
264
+
265
+ foreach ( $scripts as $_handle => $_args ) {
266
+ // Allows numeric array with handles as values
267
+ if ( is_numeric( $_handle ) ) {
268
+ $_handle = $_args;
269
+ }
270
+
271
+ // Allows specifying null as value to simply enqueue handle
272
+ if ( empty( $_args ) ){
273
+ $_args = array();
274
+ }
275
+
276
+ array_unshift( $_args, $_handle );
277
+ call_user_func_array( 'wp_enqueue_script', $_args );
278
+ }
279
+
280
+ return $this;
281
+ }
282
+
283
+
284
+ public function _admin_footer() {
285
+ $html = '';
286
+ $html .= $this->get_enqueued_tooltip_content_html() . "\n";
287
+ $html .= $this->get_admin_footer_js_html();
288
+ $html = $this->apply_filters( 'admin_footer', $html );
289
+
290
+ echo $html;
291
+ }
292
+
293
+
294
+ public function is_overrides_default_prefix( $string ) {
295
+ return strpos( $string, self::OVERRIDE_DEFAULT_PREFIX ) === 0;
296
+ }
297
+
298
+
299
+ /**
300
+ * @return string This class's text domain
301
+ */
302
+ public function get_text_domain() {
303
+ return self::TEXT_DOMAIN;
304
+ }
305
+
306
+ /**
307
+ * Format this string, replacing placeholders with values, and translate it
308
+ * in the class's text domain.
309
+ *
310
+ * @see sprintf()
311
+ * @param string $string The string to translate.
312
+ * @param mixed $argN,.. Additional arguments.
313
+ */
314
+ public function __( $string, $argN = null ) {
315
+ $args = func_get_args();
316
+ $args[0] = $string = __( $string, $this->get_text_domain() );
317
+
318
+ $string = call_user_func_array( 'sprintf', $args );
319
+
320
+ return $string;
321
+ }
322
+
323
+ /**
324
+ * Hashes all the given values into a single hash.
325
+ * Accepts an infinite number of parameters, all of which will be first
326
+ * glued together by a separator, then hashed.
327
+ * Non-scalar values will be serialized.
328
+ *
329
+ * @param mixed $value The value to hash.
330
+ * @param mixed $argN Other values to hash.
331
+ * @return string The hash.
332
+ */
333
+ public function get_hash( $value ) {
334
+ $args = func_get_args();
335
+ $glue = self::HASHING_CONCATENATOR;
336
+
337
+ $blob = '';
338
+ foreach ( $args as $_idx => $_arg ) {
339
+ $blob .= is_scalar( $_arg ) ? $_arg : serialize( $_arg );
340
+ $blob .= $glue;
341
+ }
342
+
343
+ $blob = substr( $blob, 0, -1 );
344
+
345
+ return sha1( $blob );
346
+ }
347
+
348
+ /**
349
+ * Get the class code prefix, or the specified prefixed with it.
350
+ *
351
+ * @param string $string A string to prefix.
352
+ * @return string The code prefix or the prefixed string.
353
+ */
354
+ public function get_code_prefix( $string = '' ) {
355
+ return self::CODE_PREFIX . (string)$string;
356
+ }
357
+
358
+ /**
359
+ * Optionally prefix a string with the class code prefix, unless it
360
+ * contains the "!" character in the very beginning, in which case it will
361
+ * simply be removed.
362
+ *
363
+ * @param string $string The string to consider for prefixing.
364
+ * @return string The prefixed or clean string.
365
+ */
366
+ public function prefix( $string ) {
367
+ return $this->is_overrides_default_prefix( $string )
368
+ ? substr( $string, 1 )
369
+ : $this->get_code_prefix( $string );
370
+ }
371
+
372
+ /**
373
+ * Applies filters, but prefixes the filter name with 'wprss_help_',
374
+ * unless '!' is specified as the first character of the filter.
375
+ *
376
+ * @param string $filter_name Name or "tag" of the filter.
377
+ * @param mixed $subject The value to apply filters to.
378
+ * @param mixed $argN,.. Additional filter arguments
379
+ * @return mixed Result of filtering
380
+ */
381
+ public function apply_filters( $filter_name, $subject, $argN = null ) {
382
+ $args = func_get_args();
383
+
384
+ $args[0] = $filter_name = $this->prefix( $filter_name );
385
+
386
+ return call_user_func_array( 'apply_filters', $args );
387
+ }
388
+
389
+
390
+ /**
391
+ * Applies a filters with the specified name to the options that were
392
+ * applied on top of defaults.
393
+ * The name will be prefixed with the class prefix 'wprss_help_', and
394
+ * suffixed with '_options'.
395
+ *
396
+ * @param string $filter_name Name of the filter to apply to the options
397
+ * @param array $options The options to filter
398
+ * @param mixed $filter_argN,.. Other filter arguments to be passed to filter
399
+ */
400
+ public function apply_options_filters( $filter_name, $options = array(), $filter_argN = null ) {
401
+ $args = func_get_args();
402
+
403
+ // Adding sufix
404
+ $args[0] = $filter_name .= self::OPTIONS_FILTER_SUFFIX;
405
+
406
+ // Applying defaults
407
+ $args[1] = $options = $this->get_options( $options );
408
+
409
+ // Entry point. Order of args is already correct.
410
+ $options = call_user_func_array( array( $this, 'apply_filters' ), $args );
411
+
412
+ return $options;
413
+ }
414
+
415
+
416
+ /**
417
+ * Parses the tooltip handle template path for placeholders.
418
+ *
419
+ * Filters used:
420
+ *
421
+ * - `wprss_help_admin_footer_js_html_template`
422
+ *
423
+ * @param null|string $path Optional path to parse and retrieve. Default: value of the 'admin_footer_js_template' option.
424
+ * @return string Path to the template.
425
+ */
426
+ public function get_admin_footer_js_html_template( $path = null ) {
427
+ // Default is from options
428
+ if ( is_null( $path ) ) {
429
+ $path = $this->get_options( 'admin_footer_js_template' );
430
+ }
431
+
432
+ // Entry point
433
+ $path = $this->apply_filters( 'admin_footer_js_html_template', $path );
434
+
435
+ return $this->parse_path( $path );
436
+ }
437
+
438
+
439
+ /**
440
+ * Get the HTML of the JavaScript for the footer in Admin Panel.
441
+ *
442
+ * Filters used:
443
+ *
444
+ * - `wprss_help_admin_footer_js_html`
445
+ *
446
+ * @param array $options Any additional options to be used with defaults.
447
+ * @return string The HTML.
448
+ */
449
+ public function get_admin_footer_js_html( $options = array() ) {
450
+ $options = $this->apply_options_filters( 'admin_footer_js_html', $options);
451
+
452
+ $templatePath = $this->get_admin_footer_js_html_template( $options['admin_footer_js_template'] );
453
+
454
+ return $this->get_template($templatePath, $options);
455
+ }
456
+
457
+
458
+ /**
459
+ * Parses the tooltip handle template path for placeholders.
460
+ *
461
+ * Filters used:
462
+ *
463
+ * - `wprss_help_tooltip_handle_html_template`
464
+ *
465
+ * @param null|string $path Optional path to parse and retrieve. Default: value of the 'tooltip_handle_template' option.
466
+ * @return string Path to the template.
467
+ */
468
+ public function get_tooltip_handle_html_template( $path = null ) {
469
+ // Default is from options
470
+ if ( is_null( $path ) ) {
471
+ $path = $this->get_options( 'tooltip_handle_template' );
472
+ }
473
+
474
+ // Entry point
475
+ $path = $this->apply_filters( 'tooltip_handle_html_template', $path );
476
+
477
+ return $this->parse_path( $path );
478
+ }
479
+
480
+
481
+ /**
482
+ * Get the HTML of the tooltip handle.
483
+ *
484
+ * Filters used:
485
+ *
486
+ * - `wprss_help_tooltip_handle_html_options`
487
+ *
488
+ * @param string $text Content of the tooltip text.
489
+ * @param string $id ID of the tooltip.
490
+ * @param array $options Any additional options to be used with defaults.
491
+ * @return string The HTML.
492
+ */
493
+ public function get_tooltip_handle_html( $text, $id, $options = array() ) {
494
+ $options = $this->apply_options_filters( 'tooltip_handle_html', $options, $text, $id);
495
+
496
+ // Add template varialbes
497
+ $options['tooltip_id'] = $id;
498
+ $options['tooltip_text'] = $text;
499
+
500
+ $templatePath = $this->get_tooltip_handle_html_template( $options['tooltip_handle_template'] );
501
+
502
+ return $this->get_template($templatePath, $options);
503
+ }
504
+
505
+
506
+ /**
507
+ * Parses the tooltip content template path for placeholders.
508
+ *
509
+ * Filters used:
510
+ *
511
+ * - `wprss_help_tooltip_content_html_template`
512
+ *
513
+ * @param null|string $path Optional path to parse and retrieve. Default: value of the 'tooltip_handle_template' option.
514
+ * @return string Path to the template.
515
+ */
516
+ public function get_tooltip_content_html_template( $path = null ) {
517
+ // Default is from options
518
+ if ( is_null( $path ) ) {
519
+ $path = $this->get_options( 'tooltip_content_template' );
520
+ }
521
+
522
+ // Entry point
523
+ $path = $this->apply_filters( 'tooltip_content_html_template', $path );
524
+
525
+ return $this->parse_path( $path );
526
+ }
527
+
528
+
529
+ /**
530
+ * Get the HTML of the tooltip content.
531
+ *
532
+ * Filters used:
533
+ *
534
+ * - `wprss_help_tooltip_content_html_options`
535
+ *
536
+ * @param string $text Content of the tooltip text.
537
+ * @param string $id ID of the tooltip.
538
+ * @param array $options Any additional options to be used with defaults.
539
+ * @return string The HTML.
540
+ */
541
+ public function get_tooltip_content_html( $text, $id, $options = array() ) {
542
+ $options = $this->apply_options_filters( 'tooltip_content_html', $options, $text, $id );
543
+
544
+ // Add template varialbes
545
+ $options['tooltip_id'] = $id;
546
+ $options['tooltip_text'] = $text;
547
+
548
+ $templatePath = $this->get_tooltip_content_html_template( $options['tooltip_content_template'] );
549
+
550
+ return $this->get_template( $templatePath, $options );
551
+ }
552
+
553
+
554
+ /**
555
+ * Add tooltip and get tooltip HTML.
556
+ * If $text is null, just get the HTML of tooltip with specified ID.
557
+ * The `is_enqueue_tooltip_content` option determines whether to enqueue
558
+ * the content, instead of outputting it after the handle.
559
+ *
560
+ * @param string $id ID for this tooltip
561
+ * @param string|null $text Text of this tooltip. If null, tooltip will not be added, but only retrieved.
562
+ * @param array|bool $options The options for this operation, or a boolean indicating whether or not content is to be enqueued
563
+ * @return string The tooltip handle and, optionally, content.
564
+ */
565
+ public function tooltip( $id, $text = null, $options = array() ) {
566
+ $this->add_tooltip( $id, $text, $options );
567
+ return $this->do_tooltip( $id );
568
+ }
569
+
570
+
571
+ /**
572
+ * Add tooltips in a batch, with optionally prefixed ID.
573
+ *
574
+ * @param array $tooltips An array where key is tooltip ID and value is tooltip text.
575
+ * @param string $prefix A prefix to add to all tooltip IDs.
576
+ * @param array $options Arra of options for all the tooltips to add.
577
+ * @return \WPRSS_Help
578
+ */
579
+ public function add_tooltips( $tooltips, $prefix = null, $options = array() ) {
580
+ $prefix = (string) $prefix;
581
+ if ( !is_array($options) ) $options = array();
582
+
583
+ foreach ( $tooltips as $_id => $_text ) {
584
+ $this->add_tooltip( $prefix . $_id, $_text, $options );
585
+ }
586
+
587
+ return $this;
588
+ }
589
+
590
+
591
+ /**
592
+ * Add a tooltip for later display.
593
+ * Text and options will be replaced by existing text and options, if they
594
+ * are empty, and a tooltip with the same ID is already registered.
595
+ *
596
+ * @param string $id The ID of this tooltip
597
+ * @param string $text Text for this tooltip
598
+ * @param array $options Options for this tooltip.
599
+ * @return WPRSS_Help This instance.
600
+ */
601
+ public function add_tooltip( $id, $text = null, $options = array() ) {
602
+ if ( $tooltip = $this->get_tooltip( $id ) ) {
603
+ if ( is_null( $text ) ) $text = isset( $tooltip[ self::TOOLTIP_DATA_KEY_TEXT ] ) ? $tooltip[ self::TOOLTIP_DATA_KEY_TEXT ] : $text;
604
+ if ( empty( $options ) ) $options = isset( $tooltip[ self::TOOLTIP_DATA_KEY_OPTIONS ] ) ? $tooltip[ self::TOOLTIP_DATA_KEY_OPTIONS ] : $options;
605
+ }
606
+
607
+ $this->set_tooltip( $id, $text, $options );
608
+
609
+ return $this;
610
+ }
611
+
612
+
613
+ /**
614
+ * Set a tooltip, existing or not.
615
+ *
616
+ * @param string $id The ID of this tooltip
617
+ * @param string $text Text for this tooltip
618
+ * @param array $options Options for this tooltip.
619
+ * @return WPRSS_Help This instance.
620
+ */
621
+ public function set_tooltip( $id, $text = null, $options = array() ) {
622
+ $this->_tooltips[ $id ] = array(
623
+ self::TOOLTIP_DATA_KEY_ID => $id,
624
+ self::TOOLTIP_DATA_KEY_TEXT => $text,
625
+ self::TOOLTIP_DATA_KEY_OPTIONS => $options
626
+ );
627
+
628
+ return $this;
629
+ }
630
+
631
+
632
+ /**
633
+ * Retrieve one tooltip, or an array containing all tooltips.
634
+ *
635
+ * @param string|null $id The ID of the tooltip to retrieve.
636
+ * @param mixed|null $default What to return if tooltip with specified ID not found.
637
+ * @return array An array that contains the following indexes: 'id', 'text', 'options'. See {@link add_tooltip()} for details.
638
+ */
639
+ public function get_tooltip( $id = null, $default = null ) {
640
+ if ( is_null( $id ) ) {
641
+ return $this->_tooltips;
642
+ }
643
+
644
+ return $this->has_tooltip( $id ) ? $this->_tooltips[ $id ] : $default;
645
+ }
646
+
647
+
648
+ /**
649
+ * Check whether a tooltip with the specified ID exists.
650
+ *
651
+ * @param string $id ID of the tooltip to check for.
652
+ * @return boolean True if a tooltip with the specified ID exists; false otherwise.
653
+ */
654
+ public function has_tooltip( $id ) {
655
+ return isset( $this->_tooltips[ $id ] );
656
+ }
657
+
658
+ /**
659
+ * Get registered tooltip HTML.
660
+ *
661
+ * Filters used:
662
+ *
663
+ * - `wprss_help_tooltip_options` - Filters options used for tooltip
664
+ *
665
+ * @param string $id ID for this tooltip
666
+ * @param string $text Text of this tooltip
667
+ * @param array|bool $options The options for this operation, or a boolean indicating whether or not content is to be enqueued
668
+ * @return string The tooltip handle and, optionally, content.
669
+ */
670
+ public function do_tooltip( $id ) {
671
+ $options = $this->get_options();
672
+
673
+ if ( !($tooltip = $this->get_tooltip( $id )) || !isset($tooltip[ self::TOOLTIP_DATA_KEY_TEXT ]) || !$tooltip[ self::TOOLTIP_DATA_KEY_TEXT ] ) {
674
+ return isset( $options['tooltip_not_found_handle_html'] )
675
+ ? $options['tooltip_not_found_handle_html']
676
+ : null;
677
+ }
678
+
679
+ $options = isset( $tooltip[ self::TOOLTIP_DATA_KEY_OPTIONS ] ) ? $tooltip[ self::TOOLTIP_DATA_KEY_OPTIONS ] : null;
680
+ $text = isset( $tooltip[ self::TOOLTIP_DATA_KEY_TEXT ] ) ? $tooltip[ self::TOOLTIP_DATA_KEY_TEXT ] : null;
681
+
682
+ if ( !is_array( $options ) ) {
683
+ $options = array( 'is_enqueue_tooltip_content' => $options );
684
+ }
685
+
686
+ // Entry point
687
+ $options = $this->apply_options_filters( 'tooltip', $options, $id, $text );
688
+
689
+ // Get handle HTML
690
+ $output = $this->get_tooltip_handle_html( $text, $id, $options );
691
+
692
+ if ( $this->evaluate_boolean( $options['is_enqueue_tooltip_content'] ) ) {
693
+ $this->enqueue_tooltip_content($text, $id, $options);
694
+ }
695
+ else {
696
+ $output .= $this->get_tooltip_content_html( $text, $id, $options );
697
+ }
698
+
699
+ return $output;
700
+ }
701
+
702
+
703
+ /**
704
+ * Enqueue tooltip content to be displayed in another part of the page.
705
+ *
706
+ * @param string $text The text of the tooltip content to enqueue.
707
+ * @param string $id ID of the tooltip, the content of which to enqueue.
708
+ * @param array $options This tooltip's options.
709
+ * @return \WP_Error|\WPRSS_Help This instance, or error if enqueue method is invalid.
710
+ */
711
+ public function enqueue_tooltip_content( $text, $id, $options = array() ) {
712
+ $queue_method = $this->apply_filters( 'enqueue_tooltip_content_method', array( $this, '_enqueue_tooltip_content' ), $options, $id, $text );
713
+
714
+ // "Error handling" WP style
715
+ if ( !is_callable( $queue_method ) ) {
716
+ return new WP_Error( $this->prefix( 'invalid_queue_method' ), $this->__( 'Could not enqueue tooltip content: the queue method is not a valid callable.' ), array(
717
+ 'queue_method' => $queue_method,
718
+ 'text' => $text,
719
+ 'id' => $id,
720
+ 'options' => $options
721
+ ));
722
+ }
723
+
724
+ call_user_func_array( $queue_method, array( $text, $id, $options ) );
725
+
726
+ return $this;
727
+ }
728
+
729
+
730
+ public function _enqueue_tooltip_content( $text, $id, $options = array() ) {
731
+ $hash = $this->get_hash( $text, $id, $options );
732
+ $this->_enqueued_tooltip_content[ $hash ] = array(
733
+ self::TOOLTIP_DATA_KEY_TEXT => $text,
734
+ self::TOOLTIP_DATA_KEY_ID => $id,
735
+ self::TOOLTIP_DATA_KEY_OPTIONS => $options
736
+ );
737
+
738
+ return $this;
739
+ }
740
+
741
+
742
+ public function get_enqueued_tooltip_content() {
743
+ return $this->_enqueued_tooltip_content;
744
+ }
745
+
746
+
747
+ public function get_enqueued_tooltip_content_html() {
748
+ $output = '';
749
+ foreach ( $this->get_enqueued_tooltip_content() as $_hash => $_vars ) {
750
+ $options = is_array( $_vars[ self::TOOLTIP_DATA_KEY_OPTIONS ] ) ? $_vars[ self::TOOLTIP_DATA_KEY_OPTIONS ] : array();
751
+ $output = $this->get_tooltip_content_html( $_vars[ self::TOOLTIP_DATA_KEY_ID ], $_vars[ self::TOOLTIP_DATA_KEY_ID ], $options );
752
+ }
753
+
754
+ echo $output;
755
+ }
756
+
757
+
758
+ /**
759
+ * Check whether or not the given value is false.
760
+ * False values are all {@link empty()} values, and also strings 'false' and 'no'.
761
+ *
762
+ * @param mixed $value The value to check.
763
+ * @return boolean Whether or not the value is considered to be false.
764
+ */
765
+ public function evaluate_boolean( $value ) {
766
+ return (empty( $value ) || strtolower( $value ) === 'false' || strtolower( $value ) === 'no')
767
+ ? false
768
+ : true;
769
+ }
770
+
771
+
772
+ /**
773
+ * Merge two arrays in an intuitive way.
774
+ * Input arrays remain unchanged.
775
+ *
776
+ * @see http://php.net/manual/en/function.array-merge-recursive.php#92195
777
+ * @param array $array1 The array to merge.
778
+ * @param array $array2 The array to merge into.
779
+ * @return array The merged array.
780
+ */
781
+ public function array_merge_recursive_distinct( array &$array1, array &$array2 ) {
782
+ $merged = $array1;
783
+
784
+ foreach ( $array2 as $key => &$value ) {
785
+ if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
786
+ $merged[ $key ] = array_merge_recursive_distinct( $merged[ $key ], $value );
787
+ } else {
788
+ $merged[ $key ] = $value;
789
+ }
790
+ }
791
+
792
+ return $merged;
793
+ }
794
+
795
+
796
+ /**
797
+ * Converts an array to a numeric array.
798
+ * If $map is empty, assumes that the array keys are already in order.
799
+ * If $map is a number, assumes it's the amount of elements to return.
800
+ * If $map is an array, assumes it is the map of intended numeric indexes to their value in the input array.
801
+ *
802
+ * @param array $array The array to convert to a numeric array
803
+ * @param false|null|array $map The map of the array indexes, or number of array elements to slice, or nothing.
804
+ * @return array The resulting numeric array.
805
+ */
806
+ public function array_to_numeric( $array, $map = null ) {
807
+ $result = array();
808
+
809
+ // If map is not an array, assume it's an indicator
810
+ if ( !is_array( $map ) ) {
811
+ $array = array_values( $array );
812
+ }
813
+
814
+ // If map is empty, assume keys are in order
815
+ if ( empty( $map ) ) {
816
+ return $array;
817
+ }
818
+
819
+ // If map is a number, assume it's the amount of elements to return
820
+ if ( is_numeric( $map ) ) {
821
+ $map = intval( $map );
822
+ return array_slice( $array, 0, $map );
823
+ }
824
+
825
+ foreach( $map as $_idx => $_key ) {
826
+ $result[ $_idx ] = $array[ $_key ];
827
+ }
828
+
829
+ return $result;
830
+ }
831
+
832
+
833
+ /**
834
+ * Parses the template and replaces placeholders with their values.
835
+ * This function uses {@see sprintf()} to format the template string using
836
+ * the values provided in $data.
837
+ * It is also possible for $data to be an associative array of key-value pairs.
838
+ * To achieve the same result, a map can be provided, mapping data keys to
839
+ * their placeholder positions.
840
+ * If no map is provided,
841
+ *
842
+ * @param string $string The template string.
843
+ * @param array $data The key-value pairs of template data.
844
+ * @param false|null|array $map {@see array_to_numeric()} The template value map.
845
+ * @return string The parsed and modified template.
846
+ */
847
+ public function parse_template( $string, $data, $map = null ) {
848
+ $data = $this->array_to_numeric( $data, $map );
849
+ array_unshift( $data, $string );
850
+ return call_user_func_array( 'sprintf', $data );
851
+ }
852
+
853
+
854
+ /**
855
+ * Parses a path template specifically with WPRSS_Help path placeholders.
856
+ *
857
+ * Filters used (in order):
858
+ *
859
+ * 1. `parse_path_data_default`;
860
+ * 2. `parse_path_data`;
861
+ * 3. `parse_path_map`;
862
+ * 4. `parse_path_path`.
863
+ *
864
+ * @see WPRSS_Help::parse_template()
865
+ * @param string $path The path to parse.
866
+ * @param null|array $data Any additional data. Will be merged with defaults.
867
+ * @param null|array $map The map for parsing.
868
+ * @return string The path with placeholders replaced
869
+ */
870
+ public function parse_path( $path, $data = null, $map = null ) {
871
+ if( is_null( $data ) ) {
872
+ $data = array();
873
+ }
874
+
875
+ $defaults = $this->apply_filters( 'parse_path_data_default', array(
876
+ 'wprss_templates_dir' => wprss_get_templates_dir()
877
+ ));
878
+ $data = $this->array_merge_recursive_distinct( $data, $defaults );
879
+ $data = $this->apply_filters( 'parse_path_data', $data, $path, $map );
880
+ $map = $this->apply_filters( 'parse_path_map', $map, $data, $path );
881
+ $path = $this->apply_filters( 'parse_path_path', $path, $data, $map );
882
+
883
+ return $this->parse_template( $path, $data, $map );
884
+ }
885
+ }
886
+
887
+ WPRSS_Help::init();
includes/admin-metaboxes.php CHANGED
@@ -39,18 +39,7 @@
39
  'high'
40
  );
41
 
42
- /*
43
- add_meta_box(
44
- 'wprss-help-meta',
45
- __( 'WP RSS Aggregator Help', 'wprss' ),
46
- 'wprss_help_meta_box_callback',
47
- 'wprss_feed',
48
- 'side',
49
- 'low'
50
- );
51
- */
52
-
53
- if ( !defined('WPRSS_FTP_VERSION') ) {
54
  add_meta_box(
55
  'wprss-like-meta',
56
  __( 'Like This Plugin?', 'wprss' ),
@@ -60,18 +49,6 @@
60
  'low'
61
  );
62
  }
63
-
64
- /*
65
- add_meta_box(
66
- 'wprss-follow-meta',
67
- __( 'Follow Us', 'wprss' ),
68
- 'wprss_follow_meta_box_callback',
69
- 'wprss_feed',
70
- 'side',
71
- 'low'
72
- );
73
- */
74
-
75
 
76
  add_meta_box(
77
  'custom_meta_box',
@@ -81,7 +58,6 @@
81
  'normal',
82
  'high'
83
  );
84
-
85
 
86
  }
87
 
@@ -97,31 +73,20 @@
97
  // Field Array
98
  $wprss_meta_fields[ 'url' ] = array(
99
  'label' => __( 'URL', 'wprss' ),
100
- 'desc' => __( 'Enter the RSS feed URL (including http://)', 'wprss' ),
101
  'id' => $prefix .'url',
102
  'type' => 'url',
103
  'after' => 'wprss_validate_feed_link',
104
  'placeholder' => 'http://'
105
  );
106
- /*
107
- $wprss_meta_fields[ 'description' ] = array(
108
- 'label' => __( 'Description', 'wprss' ),
109
- 'desc' => __( 'A short description about this feed source (optional)', 'wprss' ),
110
- 'id' => $prefix .'description',
111
- 'type' => 'textarea'
112
- );
113
- */
114
 
115
  $wprss_meta_fields[ 'limit' ] = array(
116
  'label' => __( 'Limit', 'wprss' ),
117
- 'desc' => __( 'Enter the maximum number of items to import.', 'wprss' ),
118
  'id' => $prefix . 'limit',
119
  'type' => 'number'
120
  );
121
 
122
  $wprss_meta_fields[ 'enclosure' ] = array(
123
  'label' => __( 'Link to enclosure', 'wprss' ),
124
- 'desc' => __( 'Check this box to make the feed items link to their enclosure in the feed.', 'wprss' ),
125
  'id' => $prefix . 'enclosure',
126
  'type' => 'checkbox'
127
  );
@@ -139,6 +104,8 @@
139
  function wprss_show_meta_box_callback() {
140
  global $post;
141
  $meta_fields = wprss_get_custom_fields();
 
 
142
 
143
  // Use nonce for verification
144
  wp_nonce_field( basename( __FILE__ ), 'wprss_meta_box_nonce' );
@@ -162,28 +129,54 @@
162
  }
163
 
164
  // Add default placeholder value
165
- $field = wp_parse_args( $field, array( 'placeholder' => '' ) );
166
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  switch( $field['type'] ) {
168
 
169
  // text/url
170
  case 'url':
171
  case 'text':
172
- echo '<input type="'.$field['type'].'" name="'.$field['id'].'" id="'.$field['id'].'" value="'. esc_attr( $meta ) .'" placeholder="'.__($field['placeholder'], 'wprss').'" class="wprss-text-input"/>
173
- <label for="'.$field['id'].'" class="description">'.$field['desc'].'</label>';
 
 
 
174
  break;
175
 
176
  // textarea
177
  case 'textarea':
178
- echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="60" rows="4">'. esc_attr( $meta ) .'</textarea>
179
- <br/><label for="'.$field['id'].'" class="description">'.$field['desc'].'</label>';
 
 
 
180
  break;
181
 
182
  // checkbox
183
  case 'checkbox':
184
  echo '<input type="hidden" name="'.$field['id'].'" value="false" />';
185
- echo '<input type="checkbox" name="'.$field['id'].'" id="'.$field['id'].'" value="true" ', checked( $meta, 'true' ), ' />
186
- <label for="'.$field['id'].'" class="description">'.$field['desc'].'</label>';
 
 
 
187
  break;
188
 
189
  // select
@@ -192,14 +185,21 @@
192
  foreach ($field['options'] as $option) {
193
  echo '<option', $meta == $option['value'] ? ' selected="selected"' : '', ' value="'.$option['value'].'">'.$option['label'].'</option>';
194
  }
195
- echo '</select><br/><label for="'.$field['id'].'" class="description">'.$field['desc'].'</label>';
 
 
 
 
 
196
  break;
197
 
198
  // number
199
  case 'number':
200
- echo '<input class="wprss-number-roller" type="number" placeholder="Default" min="0" name="'.$field['id'].'" id="'.$field['id'].'" value="'.esc_attr( $meta ).'" />
201
- <label for="'.$field['id'].'" class="description">'.$field['desc'].'</label>';
202
-
 
 
203
  break;
204
 
205
  } //end switch
@@ -220,6 +220,7 @@
220
  */
221
  function wprss_validate_feed_link() {
222
  ?>
 
223
  <a href="#" id="validate-feed-link">Validate feed</a>
224
  <script type="text/javascript">
225
  (function($){
@@ -240,8 +241,7 @@
240
  e.preventDefault();
241
  e.stopPropagation();
242
  return false;
243
- })
244
- .appendTo('td label[for="wprss_url"].description');
245
  });
246
  })(jQuery);
247
  </script>
@@ -346,23 +346,33 @@
346
  function wprss_preview_meta_box_callback() {
347
  global $post;
348
  $feed_url = get_post_meta( $post->ID, 'wprss_url', true );
 
 
 
349
 
350
- if( ! empty( $feed_url ) ) {
351
- $feed = wprss_fetch_feed( $feed_url, $post->ID );
352
  if ( ! is_wp_error( $feed ) ) {
353
- $items = $feed->get_items();
354
  // Figure out how many total items there are
355
  $total = $feed->get_item_quantity();
356
  // Get the number of items again, but limit it to 5.
357
  $maxitems = $feed->get_item_quantity(5);
358
 
359
  // Build an array of all the items, starting with element 0 (first element).
360
- $items = $feed->get_items( 0, $maxitems );
361
- echo "<h4>Latest $maxitems feed items out of $total available from " . get_the_title() . '</h4>';
362
- echo '<ul>';
363
- foreach ( $items as $item ) {
 
 
364
  // Get human date (comment if you want to use non human date)
365
- $item_date = human_time_diff( $item->get_date('U'), current_time('timestamp')).' '.__( 'ago', 'rc_mdm' );
 
 
 
 
 
366
  // Start displaying item content within a <li> tag
367
  echo '<li>';
368
  // create item link
@@ -374,8 +384,10 @@
374
  echo ' <div class="rss-date"><small>'.$item_date.'</small></div>';
375
  // End <li> tag
376
  echo '</li>';
377
- }
378
- echo '</ul>';
 
 
379
  }
380
  else {
381
  ?>
@@ -399,17 +411,10 @@
399
  <hr/>
400
 
401
  <p>
402
- <label for="wprss-force-feed">
403
- <strong><?php _e('Are you seeing an error, but sure the feed URL is correct?', 'wprss' ); ?></strong>
404
- </label>
405
- </p>
406
- <p>
407
- <label for="wprss-force-feed">Force the feed</label>
408
  <input type="hidden" name="wprss_force_feed" value="false" />
409
  <input type="checkbox" name="wprss_force_feed" id="wprss-force-feed" value="true" <?php echo checked( $force_feed, 'true' ); ?> />
410
- </p>
411
- <p class="description">
412
- <strong>Note:</strong> This will disable auto discovery of the RSS feed, meaning you will have to use the feed's URL. Using the site's URL will not work.
413
  </p>
414
 
415
  <?php
@@ -463,6 +468,10 @@
463
  $wprss_schedules
464
  );
465
 
 
 
 
 
466
  ?>
467
 
468
  <div class="wprss-meta-side-setting">
@@ -472,6 +481,7 @@
472
  <option value="<?php echo $value; ?>" <?php selected( $state, $value ) ?> ><?php echo $label; ?></option>
473
  <?php endforeach; ?>
474
  </select>
 
475
  </div>
476
 
477
  <div class="wprss-meta-side-setting">
@@ -479,18 +489,12 @@
479
  <label for="">Activate feed: </label>
480
  <strong id="wprss-activate-feed-viewer"><?php echo ( ( $activate !== '' )? $activate : $default_activate ); ?></strong>
481
  <a href="#">Edit</a>
 
482
  </p>
483
  <div class="wprss-meta-slider" data-collapse-viewer="wprss-activate-feed-viewer" data-default-value="<?php echo $default_activate; ?>">
484
  <input id="wprss_activate_feed" class="wprss-datetimepicker-from-today" name="wprss_activate_feed" value="<?php echo $activate; ?>" />
485
-
486
- <label class="description" for="wprss_activate_feed">
487
- Leave blank to activate the feed immediately.
488
- </label>
489
-
490
- <br/><br/>
491
-
492
  <span class="description">
493
- <b>Note:</b> WordPress uses UTC time for schedules, not local time. Current UTC time is: <code><?php echo date( 'd/m/Y H:i:s', current_time('timestamp',1) ); ?></code>
494
  </span>
495
  </div>
496
  </div>
@@ -500,15 +504,12 @@
500
  <label for="">Pause feed: </label>
501
  <strong id="wprss-pause-feed-viewer"><?php echo ( ( $pause !== '' )? $pause : $default_pause ); ?></strong>
502
  <a href="#">Edit</a>
 
503
  </p>
504
  <div class="wprss-meta-slider" data-collapse-viewer="wprss-pause-feed-viewer" data-default-value="<?php echo $default_pause; ?>">
505
  <input id="wprss_pause_feed" class="wprss-datetimepicker-from-today" name="wprss_pause_feed" value="<?php echo $pause; ?>" />
506
- <label class="description" for="wprss_pause_feed">
507
- Leave blank to never pause the feed.
508
- </label>
509
- <br/><br/>
510
  <span class="description">
511
- <b>Note:</b> WordPress uses UTC time for schedules, not local time. Current UTC time is: <code><?php echo date( 'd/m/Y H:i:s', current_time('timestamp',1) ); ?></code>
512
  </span>
513
  </div>
514
  </div>
@@ -528,6 +529,7 @@
528
  ?>
529
  </strong>
530
  <a href="#">Edit</a>
 
531
  </p>
532
  <div class="wprss-meta-slider" data-collapse-viewer="wprss-feed-update-interval-viewer" data-default-value="<?php echo $default_interval; ?>">
533
  <select id="feed-update-interval" name="wprss_update_interval">
@@ -536,11 +538,6 @@
536
  <option value="<?php echo $value; ?>" <?php selected( $update_interval, $value ); ?> ><?php echo $text; ?></option>
537
  <?php endforeach; ?>
538
  </select>
539
-
540
- <br/>
541
- <span class='description' for='feed-update-interval'>
542
- Enter the interval at which to update this feed. The feed will only be updated if it is <strong>active</strong>.
543
- </span>
544
  </div>
545
  </div>
546
 
@@ -550,6 +547,7 @@
550
  <label id="wprss-age-limit-feed-label" for="" data-when-empty="Delete old feed items:">Delete feed items older than: </label>
551
  <strong id="wprss-age-limit-feed-viewer"><?php echo $age_limit . ' ' . $age_unit; ?></strong>
552
  <a href="#">Edit</a>
 
553
  </p>
554
  <div class="wprss-meta-slider" data-collapse-viewer="wprss-age-limit-feed-viewer" data-label="#wprss-age-limit-feed-label" data-default-value="" data-empty-controller="#limit-feed-items-age" data-hybrid="#limit-feed-items-age, #limit-feed-items-age-unit">
555
  <input id="limit-feed-items-age" name="wprss_age_limit" type="number" min="0" class="wprss-number-roller" placeholder="No limit" value="<?php echo $age_limit; ?>" />
@@ -559,13 +557,6 @@
559
  <option value="<?php echo $unit; ?>" <?php selected( $age_unit, $unit ); ?> ><?php echo $unit; ?></option>
560
  <?php endforeach; ?>
561
  </select>
562
-
563
- <br/>
564
- <span class='description' for='limit-feed-items-age'>
565
- Enter the maximum age of feed items to be stored in the database. Feed items older than the specified age will be deleted everyday at midnight.
566
- <br/>
567
- Leave empty for no limit.
568
- </span>
569
  </div>
570
  </div>
571
 
39
  'high'
40
  );
41
 
42
+ if ( !defined('WPRSS_FTP_VERSION') && !defined('WPRSS_ET_VERSION') && !defined('WPRSS_C_VERSION') ) {
 
 
 
 
 
 
 
 
 
 
 
43
  add_meta_box(
44
  'wprss-like-meta',
45
  __( 'Like This Plugin?', 'wprss' ),
49
  'low'
50
  );
51
  }
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  add_meta_box(
54
  'custom_meta_box',
58
  'normal',
59
  'high'
60
  );
 
61
 
62
  }
63
 
73
  // Field Array
74
  $wprss_meta_fields[ 'url' ] = array(
75
  'label' => __( 'URL', 'wprss' ),
 
76
  'id' => $prefix .'url',
77
  'type' => 'url',
78
  'after' => 'wprss_validate_feed_link',
79
  'placeholder' => 'http://'
80
  );
 
 
 
 
 
 
 
 
81
 
82
  $wprss_meta_fields[ 'limit' ] = array(
83
  'label' => __( 'Limit', 'wprss' ),
 
84
  'id' => $prefix . 'limit',
85
  'type' => 'number'
86
  );
87
 
88
  $wprss_meta_fields[ 'enclosure' ] = array(
89
  'label' => __( 'Link to enclosure', 'wprss' ),
 
90
  'id' => $prefix . 'enclosure',
91
  'type' => 'checkbox'
92
  );
104
  function wprss_show_meta_box_callback() {
105
  global $post;
106
  $meta_fields = wprss_get_custom_fields();
107
+ $field_tooltip_id_prefix = 'field_';
108
+ $help = WPRSS_Help::get_instance();
109
 
110
  // Use nonce for verification
111
  wp_nonce_field( basename( __FILE__ ), 'wprss_meta_box_nonce' );
129
  }
130
 
131
  // Add default placeholder value
132
+ $field = wp_parse_args( $field, array(
133
+ 'desc' => '',
134
+ 'placeholder' => '',
135
+ 'type' => 'text'
136
+ ) );
137
+
138
+ $tooltip = isset( $field['tooltip'] ) ? trim( $field['tooltip'] ) : null;
139
+ $tooltip_id = isset( $field['id'] ) ? $field_tooltip_id_prefix . $field['id'] : uniqid( $field_tooltip_id_prefix );
140
+
141
+ /*
142
+ * So, here's how tooltips work here.
143
+ * Tooltip output will be attempted in any case.
144
+ * If 'tooltip' index is not defined, or is null, then
145
+ * a registered tooltip will be attempted. If that is
146
+ * not found, default value will be output. This value
147
+ * is by default an empty string, but can be altered
148
+ * by the `tooltip_not_found_handle_html` option of `WPRSS_Help`.
149
+ */
150
+
151
  switch( $field['type'] ) {
152
 
153
  // text/url
154
  case 'url':
155
  case 'text':
156
+ echo '<input type="'.$field['type'].'" name="'.$field['id'].'" id="'.$field['id'].'" value="'. esc_attr( $meta ) .'" placeholder="'.__($field['placeholder'], 'wprss').'" class="wprss-text-input"/>';
157
+ echo $help->tooltip( $tooltip_id, $tooltip );
158
+ if ( strlen( trim( $field['desc'] ) ) > 0 ) {
159
+ echo '<br>label for="'.$field['id'].'"><span class="description">'.$field['desc'].'</span></label>';
160
+ }
161
  break;
162
 
163
  // textarea
164
  case 'textarea':
165
+ echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="60" rows="4">'. esc_attr( $meta ) .'</textarea>';
166
+ echo $help->tooltip( $tooltip_id, $tooltip );
167
+ if ( strlen( trim( $field['desc'] ) ) > 0 ) {
168
+ echo '<br>label for="'.$field['id'].'"><span class="description">'.$field['desc'].'</span></label>';
169
+ }
170
  break;
171
 
172
  // checkbox
173
  case 'checkbox':
174
  echo '<input type="hidden" name="'.$field['id'].'" value="false" />';
175
+ echo '<input type="checkbox" name="'.$field['id'].'" id="'.$field['id'].'" value="true" ', checked( $meta, 'true' ), ' />';
176
+ echo $help->tooltip( $tooltip_id, $tooltip );
177
+ if ( strlen( trim( $field['desc'] ) ) > 0 ) {
178
+ echo '<label for="'.$field['id'].'"><span class="description">'.$field['desc'].'</span></label>';
179
+ }
180
  break;
181
 
182
  // select
185
  foreach ($field['options'] as $option) {
186
  echo '<option', $meta == $option['value'] ? ' selected="selected"' : '', ' value="'.$option['value'].'">'.$option['label'].'</option>';
187
  }
188
+
189
+ echo '</select>';
190
+ echo $help->tooltip( $tooltip_id, $tooltip );
191
+ if ( strlen( trim( $field['desc'] ) ) > 0 ) {
192
+ echo '<label for="'.$field['id'].'"><span class="description">'.$field['desc'].'</span></label>';
193
+ }
194
  break;
195
 
196
  // number
197
  case 'number':
198
+ echo '<input class="wprss-number-roller" type="number" placeholder="Default" min="0" name="'.$field['id'].'" id="'.$field['id'].'" value="'.esc_attr( $meta ).'" />';
199
+ echo $help->tooltip( $tooltip_id, $tooltip );
200
+ if ( strlen( trim( $field['desc'] ) ) > 0 ) {
201
+ echo '<label for="'.$field['id'].'"><span class="description">'.$field['desc'].'</span></label>';
202
+ }
203
  break;
204
 
205
  } //end switch
220
  */
221
  function wprss_validate_feed_link() {
222
  ?>
223
+ <br/>
224
  <a href="#" id="validate-feed-link">Validate feed</a>
225
  <script type="text/javascript">
226
  (function($){
241
  e.preventDefault();
242
  e.stopPropagation();
243
  return false;
244
+ });
 
245
  });
246
  })(jQuery);
247
  </script>
346
  function wprss_preview_meta_box_callback() {
347
  global $post;
348
  $feed_url = get_post_meta( $post->ID, 'wprss_url', true );
349
+
350
+ $help = WPRSS_Help::get_instance();
351
+ /* @var $help WPRSS_Help */
352
 
353
+ if ( ! empty( $feed_url ) ) {
354
+ $feed = wprss_fetch_feed( $feed_url, $post->ID );
355
  if ( ! is_wp_error( $feed ) ) {
356
+ $items = $feed->get_items();
357
  // Figure out how many total items there are
358
  $total = $feed->get_item_quantity();
359
  // Get the number of items again, but limit it to 5.
360
  $maxitems = $feed->get_item_quantity(5);
361
 
362
  // Build an array of all the items, starting with element 0 (first element).
363
+ $items = $feed->get_items( 0, $maxitems );
364
+ ?>
365
+ <h4><?php echo sprintf( __( 'Latest %1$s feed items out of %2$s available from %3$s' ), $maxitems, $total, get_the_title() ) ?></h4>
366
+ <ul>
367
+ <?php
368
+ foreach ( $items as $item ) {
369
  // Get human date (comment if you want to use non human date)
370
+ $has_date = $item->get_date( 'U' ) ? TRUE : FALSE;
371
+ if ( $has_date ) {
372
+ $item_date = human_time_diff( $item->get_date('U'), current_time('timestamp')).' '.__( 'ago', 'rc_mdm' );
373
+ } else {
374
+ $item_date = '<em>[No Date]</em>';
375
+ }
376
  // Start displaying item content within a <li> tag
377
  echo '<li>';
378
  // create item link
384
  echo ' <div class="rss-date"><small>'.$item_date.'</small></div>';
385
  // End <li> tag
386
  echo '</li>';
387
+ }
388
+ ?>
389
+ </ul>
390
+ <?php
391
  }
392
  else {
393
  ?>
411
  <hr/>
412
 
413
  <p>
414
+ <label for="wprss-force-feed"><?php _e('Force the feed') ?></label>
 
 
 
 
 
415
  <input type="hidden" name="wprss_force_feed" value="false" />
416
  <input type="checkbox" name="wprss_force_feed" id="wprss-force-feed" value="true" <?php echo checked( $force_feed, 'true' ); ?> />
417
+ <?php echo $help->tooltip( 'field_wprss_force_feed' ) ?>
 
 
418
  </p>
419
 
420
  <?php
468
  $wprss_schedules
469
  );
470
 
471
+ // Inline help
472
+ $help = WPRSS_Help::get_instance();
473
+ $help_options = array('tooltip_handle_class_extra' => $help->get_options('tooltip_handle_class_extra') . ' ' . $help->get_options('tooltip_handle_class') . '-side');
474
+
475
  ?>
476
 
477
  <div class="wprss-meta-side-setting">
481
  <option value="<?php echo $value; ?>" <?php selected( $state, $value ) ?> ><?php echo $label; ?></option>
482
  <?php endforeach; ?>
483
  </select>
484
+ <?php echo $help->tooltip( 'field_wprss_state', null, $help_options ) ?>
485
  </div>
486
 
487
  <div class="wprss-meta-side-setting">
489
  <label for="">Activate feed: </label>
490
  <strong id="wprss-activate-feed-viewer"><?php echo ( ( $activate !== '' )? $activate : $default_activate ); ?></strong>
491
  <a href="#">Edit</a>
492
+ <?php echo $help->tooltip( 'field_wprss_activate_feed', null, $help_options ) ?>
493
  </p>
494
  <div class="wprss-meta-slider" data-collapse-viewer="wprss-activate-feed-viewer" data-default-value="<?php echo $default_activate; ?>">
495
  <input id="wprss_activate_feed" class="wprss-datetimepicker-from-today" name="wprss_activate_feed" value="<?php echo $activate; ?>" />
 
 
 
 
 
 
 
496
  <span class="description">
497
+ Current UTC time is:<br/><code><?php echo date( 'd/m/Y H:i:s', current_time('timestamp',1) ); ?></code>
498
  </span>
499
  </div>
500
  </div>
504
  <label for="">Pause feed: </label>
505
  <strong id="wprss-pause-feed-viewer"><?php echo ( ( $pause !== '' )? $pause : $default_pause ); ?></strong>
506
  <a href="#">Edit</a>
507
+ <?php echo $help->tooltip( 'field_wprss_pause_feed', null, $help_options ) ?>
508
  </p>
509
  <div class="wprss-meta-slider" data-collapse-viewer="wprss-pause-feed-viewer" data-default-value="<?php echo $default_pause; ?>">
510
  <input id="wprss_pause_feed" class="wprss-datetimepicker-from-today" name="wprss_pause_feed" value="<?php echo $pause; ?>" />
 
 
 
 
511
  <span class="description">
512
+ Current UTC time is:<br/><code><?php echo date( 'd/m/Y H:i:s', current_time('timestamp',1) ); ?></code>
513
  </span>
514
  </div>
515
  </div>
529
  ?>
530
  </strong>
531
  <a href="#">Edit</a>
532
+ <?php echo $help->tooltip( 'field_wprss_update_interval', null, $help_options ) ?>
533
  </p>
534
  <div class="wprss-meta-slider" data-collapse-viewer="wprss-feed-update-interval-viewer" data-default-value="<?php echo $default_interval; ?>">
535
  <select id="feed-update-interval" name="wprss_update_interval">
538
  <option value="<?php echo $value; ?>" <?php selected( $update_interval, $value ); ?> ><?php echo $text; ?></option>
539
  <?php endforeach; ?>
540
  </select>
 
 
 
 
 
541
  </div>
542
  </div>
543
 
547
  <label id="wprss-age-limit-feed-label" for="" data-when-empty="Delete old feed items:">Delete feed items older than: </label>
548
  <strong id="wprss-age-limit-feed-viewer"><?php echo $age_limit . ' ' . $age_unit; ?></strong>
549
  <a href="#">Edit</a>
550
+ <?php echo $help->tooltip( 'field_wprss_age_limit', null, $help_options ) ?>
551
  </p>
552
  <div class="wprss-meta-slider" data-collapse-viewer="wprss-age-limit-feed-viewer" data-label="#wprss-age-limit-feed-label" data-default-value="" data-empty-controller="#limit-feed-items-age" data-hybrid="#limit-feed-items-age, #limit-feed-items-age-unit">
553
  <input id="limit-feed-items-age" name="wprss_age_limit" type="number" min="0" class="wprss-number-roller" placeholder="No limit" value="<?php echo $age_limit; ?>" />
557
  <option value="<?php echo $unit; ?>" <?php selected( $age_unit, $unit ); ?> ><?php echo $unit; ?></option>
558
  <?php endforeach; ?>
559
  </select>
 
 
 
 
 
 
 
560
  </div>
561
  </div>
562
 
includes/admin-options.php CHANGED
@@ -53,11 +53,11 @@
53
  $sections = apply_filters(
54
  'wprss_settings_sections_array',
55
  array(
56
- 'general' => __( 'General plugin settings', 'wprss' ),
57
- 'display' => __( 'General display settings', 'wprss' ),
58
- 'source' => __( 'Source display settings', 'wprss' ),
59
- 'date' => __( 'Date display settings', 'wprss' ),
60
- 'styles' => __( 'Styles', 'wprss' ),
61
  )
62
  );
63
 
@@ -67,35 +67,35 @@
67
  array(
68
  'general' => array(
69
  'limit-feed-items-by-age' => array(
70
- 'label' => __( 'Limit feed items by age', 'wprss' ),
71
  'callback' => 'wprss_setting_limit_feed_items_age_callback'
72
  ),
73
  'limit-feed-items-db' => array(
74
- 'label' => __( 'Limit feed items stored', 'wprss' ),
75
  'callback' => 'wprss_setting_limit_feed_items_callback'
76
  ),
77
  'limit-feed-items-imported' => array(
78
- 'label' => __( 'Limit feed items per feed', 'wprss' ),
79
  'callback' => 'wprss_setting_limit_feed_items_imported_callback'
80
  ),
81
  'cron-interval' => array(
82
- 'label' => __( 'Feed processing interval', 'wprss' ),
83
  'callback' => 'wprss_setting_cron_interval_callback'
84
  ),
85
  'custom-feed-url' => array(
86
- 'label' => __( 'Custom feed URL', 'wprss' ),
87
  'callback' => 'wprss_settings_custom_feed_url_callback'
88
  ),
89
  'custom-feed-title' => array(
90
- 'label' => __( 'Custom feed Title', 'wprss' ),
91
  'callback' => 'wprss_settings_custom_feed_title_callback'
92
  ),
93
  'custom-feed-limit' => array(
94
- 'label' => __( 'Custom feed limit', 'wprss' ),
95
  'callback' => 'wprss_setings_custom_feed_limit_callback'
96
  ),
97
  'tracking' => array(
98
- 'label' => __( 'Anonymous tracking', 'wprss' ),
99
  'callback' => 'wprss_tracking_callback',
100
  )
101
  ),
@@ -103,11 +103,11 @@
103
  'display' => array(
104
  // Title options
105
  'link-enable' => array(
106
- 'label' => __( 'Link title', 'wprss' ),
107
  'callback' => 'wprss_setting_title_link_callback'
108
  ),
109
  'title-limit' => array(
110
- 'label' => __( 'Title maximum length', 'wprss' ),
111
  'callback' => 'wprss_setting_title_length_callback'
112
  ),
113
 
@@ -115,27 +115,27 @@
115
 
116
  // Misc Options
117
  'authors-enable' => array(
118
- 'label' => __( 'Show authors', 'wprss' ),
119
  'callback' => 'wprss_setting_authors_enable_callback',
120
  ),
121
  'video-links' => array(
122
- 'label' => __( 'For video feed items use', 'wprss' ),
123
  'callback' => 'wprss_setting_video_links_callback'
124
  ),
125
  'pagination' => array(
126
- 'label' => __( 'Pagination type', 'wprss' ),
127
  'callback' => 'wprss_setting_pagination_type_callback',
128
  ),
129
  'feed-limit' => array(
130
- 'label' => __( 'Feed display limit', 'wprss' ),
131
  'callback' => 'wprss_setting_feed_limit_callback'
132
  ),
133
  'open-dd' => array(
134
- 'label' => __( 'Open links behaviour', 'wprss' ),
135
  'callback' => 'wprss_setting_open_dd_callback'
136
  ),
137
  'follow-dd' => array(
138
- 'label' => __( 'Set links as nofollow', 'wprss' ),
139
  'callback' => 'wprss_setting_follow_dd_callback'
140
  ),
141
  ),
@@ -143,15 +143,15 @@
143
  // Source Options
144
  'source' => array(
145
  'source-enable' => array(
146
- 'label' => __( 'Show source', 'wprss' ),
147
  'callback' => 'wprss_setting_source_enable_callback'
148
  ),
149
  'text-preceding-source' => array(
150
- 'label' => __( 'Text preceding source', 'wprss' ),
151
  'callback' => 'wprss_setting_text_preceding_source_callback'
152
  ),
153
  'source-link' => array(
154
- 'label' => __( 'Link source', 'wprss' ),
155
  'callback' => 'wprss_setting_source_link_callback'
156
  ),
157
  ),
@@ -159,26 +159,26 @@
159
  // Date options
160
  'date' => array(
161
  'date-enable' => array(
162
- 'label' => __( 'Show date', 'wprss' ),
163
  'callback' => 'wprss_setting_date_enable_callback'
164
  ),
165
  'text-preceding-date' => array(
166
- 'label' => __( 'Text preceding date', 'wprss' ),
167
  'callback' => 'wprss_setting_text_preceding_date_callback'
168
  ),
169
  'date-format' => array(
170
- 'label' => __( 'Date format', 'wprss' ),
171
  'callback' => 'wprss_setting_date_format_callback'
172
  ),
173
  'time-ago-format-enable' => array(
174
- 'label' => __( 'Time ago format', 'wprss' ),
175
  'callback' => 'wprss_setting_time_ago_format_enable_callback'
176
  ),
177
  ),
178
 
179
  'styles' => array(
180
  'styles-disable' => array(
181
- 'label' => __( 'Disable Styles', 'wprss' ),
182
  'callback' => 'wprss_setting_styles_disable_callback'
183
  )
184
  )
@@ -188,6 +188,8 @@
188
  if ( apply_filters( 'wprss_use_fixed_feed_limit', FALSE ) === FALSE ) {
189
  unset( $settings['general']['limit-feed-items-db'] );
190
  }
 
 
191
 
192
 
193
  // Loop through each setting field and register it
@@ -203,12 +205,26 @@
203
 
204
  foreach ( $fields as $id => $data ) {
205
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  add_settings_field(
207
- 'wprss-settings-' . $id,
208
  $data['label'],
209
  $data['callback'],
210
  'wprss_settings_general',
211
- "wprss_settings_${section}_section"
 
212
  );
213
 
214
  }
@@ -225,13 +241,13 @@
225
  );
226
  add_settings_section(
227
  'wprss_secure_reset_section', // ID of section
228
- __( 'Secure Reset', 'wprss' ), // Title of section
229
  'wprss_secure_reset_section_callback', // Callback that renders the section header
230
  'wprss_settings_general' // The page on which to display the section
231
  );
232
  add_settings_field(
233
  'wprss-settings-secure-reset', // ID of setting
234
- __( 'Secure Reset', 'wprss' ), // The title of the setting
235
  'wprss_settings_secure_reset_code_callback', // The callback that renders the setting
236
  'wprss_settings_general', // The page on which to display the setting
237
  "wprss_secure_reset_section" // The section in which to display the setting
@@ -241,7 +257,78 @@
241
 
242
 
243
  do_action( 'wprss_admin_init' );
244
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
 
246
 
247
  /**
@@ -253,7 +340,7 @@
253
  <div class="wrap">
254
  <?php screen_icon( 'wprss-aggregator' ); ?>
255
 
256
- <h2><?php _e( 'WP RSS Aggregator Settings', 'wprss' ); ?></h2>
257
 
258
  <?php settings_errors(); ?>
259
 
@@ -263,11 +350,11 @@
263
 
264
  $default_tabs = array(
265
  'general' => array(
266
- 'label' => __( 'General', 'wprss' ),
267
  'slug' => 'general_settings',
268
  ),
269
  'licenses' => array(
270
- 'label' => __( 'Licenses', 'wprss' ),
271
  'slug' => 'licenses_settings'
272
  )
273
  );
@@ -307,7 +394,7 @@
307
  do_action( 'wprss_add_settings_fields_sections', $active_tab );
308
  }
309
 
310
- submit_button( __( 'Save Settings', 'wprss' ) );
311
 
312
  ?>
313
  </form>
@@ -321,7 +408,7 @@
321
  * @since 3.0
322
  */
323
  function wprss_settings_general_callback() {
324
- echo '<p>' . __( 'These are the general settings for WP RSS Aggregator.', 'wprss' ) . '</p>';
325
  }
326
 
327
 
@@ -330,7 +417,7 @@
330
  * @since 3.5
331
  */
332
  function wprss_settings_display_callback() {
333
- echo '<p>' . __( 'In this section you can find some general options that control how the feed items are displayed.', 'wprss' ) . '</p>';
334
  }
335
 
336
 
@@ -340,7 +427,7 @@
340
  * @since 4.2.4
341
  */
342
  function wprss_settings_source_callback() {
343
- echo '<p>' . __( 'Options that control how the feed item\'s source is displayed.', 'wprss' ) . '</p>';
344
  }
345
 
346
  /**
@@ -349,7 +436,7 @@
349
  * @since 4.2.4
350
  */
351
  function wprss_settings_date_callback() {
352
- echo '<p>' . __( 'Options that control how the feed item\'s date is displayed.', 'wprss' ) . '</p>';
353
  }
354
 
355
 
@@ -358,7 +445,7 @@
358
  * @since 3.0
359
  */
360
  function wprss_settings_styles_callback() {
361
- echo '<p>' . __( 'If you would like to disable all styles used in this plugin, tick the checkbox.', 'wprss' ) . '</p>';
362
  }
363
 
364
 
@@ -367,7 +454,7 @@
367
  * @since 3.0
368
  */
369
  function wprss_secure_reset_section_callback() {
370
- echo '<p>' . __( 'Set your security reset code, in case of any errors.', 'wprss' ) . '</p>';
371
  }
372
 
373
 
@@ -376,7 +463,7 @@
376
  * @since 3.0
377
  */
378
  function wprss_tracking_section_callback() {
379
- echo '<p>' . __( 'Participate in helping us make the plugin better.', 'wprss' ) . '</p>';
380
  }
381
 
382
 
@@ -384,18 +471,15 @@
384
  * Follow or No Follow dropdown
385
  * @since 1.1
386
  */
387
- function wprss_setting_follow_dd_callback() {
388
  $follow_dd = wprss_get_general_setting( 'follow_dd' );
389
 
390
  $checked = ( $follow_dd === 'no_follow' );
391
  $checked_attr = ( $checked )? 'checked="checked"' : '';
392
-
393
- echo "<input type='hidden' name='wprss_settings_general[follow_dd]' value='follow'>";
394
- echo "<input type='checkbox' id='follow-dd' name='wprss_settings_general[follow_dd]' value='no_follow' $checked_attr>";
395
-
396
- echo '<label class="description" for="follow-dd">';
397
- echo '"Nofollow" provides a way for webmasters to tell search engines "Don\'t follow links on this page" or "Don\'t follow this specific link."';
398
- echo '</label>';
399
  }
400
 
401
 
@@ -403,19 +487,28 @@
403
  * Use original video link, or embedded video links dropwdown
404
  * @since 3.4
405
  */
406
- function wprss_setting_video_links_callback() {
407
  $video_link = wprss_get_general_setting('video_link');
408
  $items = array(
409
- 'false' => __( 'Original page link', 'wprss' ),
410
- 'true' => __( 'Embedded video player link', 'wprss' )
411
  );
412
- echo "<select id='video-link' name='wprss_settings_general[video_link]'>";
 
 
413
  foreach ( $items as $boolean => $text ) {
414
  $selected = ( $video_link === $boolean )? 'selected="selected"' : '';
415
- echo "<option value='$boolean' $selected>$text</option>";
416
  }
417
- echo "</select>";
418
- echo "<label class='description' for='video-link'>This will not affect already imported feed items.</label>";
 
 
 
 
 
 
 
419
  }
420
 
421
 
@@ -423,25 +516,24 @@
423
  * Link open setting dropdown
424
  * @since 1.1
425
  */
426
- function wprss_setting_open_dd_callback() {
427
  $open_dd = wprss_get_general_setting('open_dd');
428
 
429
  $items = array(
430
- __( 'Lightbox', 'wprss' ),
431
- __( 'New window', 'wprss' ),
432
- __( 'Self', 'wprss' )
433
  );
434
- echo "<select id='open-dd' name='wprss_settings_general[open_dd]'>";
 
 
435
  foreach( $items as $item ) {
436
  $selected = ( $open_dd == $item ) ? 'selected="selected"' : '';
437
- echo "<option value='$item' $selected>$item</option>";
438
  }
439
- echo "</select>";
440
- ?>
441
- <label for="open-dd" class="description">
442
- Choose how to open links for your feed items.
443
- </label>
444
- <?php
445
  }
446
 
447
 
@@ -449,10 +541,11 @@
449
  * Set limit for feeds on frontend
450
  * @since 2.0
451
  */
452
- function wprss_setting_feed_limit_callback() {
453
  $feed_limit = wprss_get_general_setting( 'feed_limit' );
454
- echo "<input id='feed-limit' name='wprss_settings_general[feed_limit]' type='text' value='$feed_limit' />";
455
- echo "<label class='description' for='feed-limit'>Enter the number of feeds to display on the front end</label>";
 
456
  }
457
 
458
 
@@ -460,10 +553,17 @@
460
  * Set date format
461
  * @since 3.0
462
  */
463
- function wprss_setting_date_format_callback() {
464
  $date_format = wprss_get_general_setting( 'date_format' );
465
- echo "<input id='date-format' name='wprss_settings_general[date_format]' type='text' value='$date_format' />";
466
- echo "<label class='description' for='date-format'>Date formatting, using the <a href='http://codex.wordpress.org/Formatting_Date_and_Time'>PHP date formats</a></label>";
 
 
 
 
 
 
 
467
  }
468
 
469
 
@@ -472,10 +572,11 @@
472
  * Enable linked title
473
  * @since 3.0
474
  */
475
- function wprss_setting_title_link_callback( $args ) {
476
  $title_link = wprss_get_general_setting( 'title_link' );
477
- echo "<input id='title-link' name='wprss_settings_general[title_link]' type='checkbox' value='1' " . checked( 1, $title_link, false ) . " />";
478
- echo "<label class='description' for='title-link'>Check this box to enable linked titles</label>";
 
479
  }
480
 
481
 
@@ -484,10 +585,11 @@
484
  * Set the title length limit
485
  * @since 3.0
486
  */
487
- function wprss_setting_title_length_callback( $args ) {
488
  $title_limit = wprss_get_general_setting( 'title_limit' );
489
- echo "<input id='title-limit' name='wprss_settings_general[title_limit]' type='number' class='wprss-number-roller' min='0' value='$title_limit' placeholder='No limit' />";
490
- echo "<label class='description' for='title-limit'>Set the maximum number of characters for feed titles.</label>";
 
491
  }
492
 
493
 
@@ -495,20 +597,22 @@
495
  * Enable source
496
  * @since 3.0
497
  */
498
- function wprss_setting_source_enable_callback( $args ) {
499
  $source_enable = wprss_get_general_setting( 'source_enable' );
500
- echo "<input id='source-enable' name='wprss_settings_general[source_enable]' type='checkbox' value='1' " . checked( 1, $source_enable, false ) . " />";
501
- echo "<label class='description' for='source-enable'>Check this box to enable feed source display</label>";
 
502
  }
503
 
504
  /**
505
  * Enable linked title
506
  * @since 3.0
507
  */
508
- function wprss_setting_source_link_callback( $args ) {
509
- $source_link = wprss_get_general_setting( 'source_link' );
510
- echo "<input id='source-link' name='wprss_settings_general[source_link]' type='checkbox' value='1' " . checked( 1, $source_link, false ) . " />";
511
- echo "<label class='description' for='source-link'>Check this box to enable linked sources</label>";
 
512
  }
513
 
514
 
@@ -516,29 +620,32 @@
516
  * Set text preceding source
517
  * @since 3.0
518
  */
519
- function wprss_setting_text_preceding_source_callback() {
520
  $text_preceding_source = wprss_get_general_setting( 'text_preceding_source' );
521
- echo "<input id='text-preceding-source' name='wprss_settings_general[text_preceding_source]' type='text' value='$text_preceding_source' />";
522
- echo "<label class='description' for='text-preceding-source'>Enter the text you want shown before the feed item's source</label>";
 
523
  }
524
  /**
525
  * Enable date
526
  * @since 3.0
527
  */
528
- function wprss_setting_date_enable_callback( $args ) {
529
  $date_enable = wprss_get_general_setting( 'date_enable' );
530
- echo "<input id='date-enable' name='wprss_settings_general[date_enable]' type='checkbox' value='1' " . checked( 1, $date_enable, false ) . " />";
531
- echo "<label class='description' for='date-enable'>Check this box to enable display of date published</label>";
 
532
  }
533
 
534
  /**
535
  * Set text preceding date
536
  * @since 3.0
537
  */
538
- function wprss_setting_text_preceding_date_callback() {
539
  $text_preceding_date = wprss_get_general_setting( 'text_preceding_date' );
540
- echo "<input id='text-preceding-date' name='wprss_settings_general[text_preceding_date]' type='text' value='$text_preceding_date' />";
541
- echo "<label class='description' for='text-preceding-date'>Enter the text you want shown before the feed item's publish date</label>";
 
542
  }
543
 
544
 
@@ -547,10 +654,11 @@
547
  *
548
  * @since 4.2.4
549
  */
550
- function wprss_setting_authors_enable_callback() {
551
  $authors_enable = wprss_get_general_setting( 'authors_enable' );
552
- echo "<input id='authors-enable' name='wprss_settings_general[authors_enable]' type='checkbox' value='1' " . checked( 1, $authors_enable, false ) . " />";
553
- echo "<label class='description' for='authors-enable'>Check this box to show the author name for each feed item, if specified in the feed.</label>";
 
554
  }
555
 
556
 
@@ -559,19 +667,22 @@
559
  *
560
  * @since 4.2.3
561
  */
562
- function wprss_setting_pagination_type_callback() {
563
  $pagination = wprss_get_general_setting( 'pagination' );
564
  $options = array(
565
- 'default' => '"Older posts" and "Newer posts" links',
566
- 'numbered' => 'Page numbers with "Next" and "Previous" page links',
567
  );
568
- echo "<select id='pagination' name='wprss_settings_general[pagination]'>";
 
 
569
  foreach( $options as $value => $text ) {
570
  $selected = ( $value === $pagination )? 'selected="selected"' : '';
571
- echo "<option value='$value' $selected>$text</option>";
572
  }
573
- echo "</select>";
574
- echo "<label class='description' for='pagination'>Choose the pagination type to use when displaying multiple pages of feed items.</label>";
 
575
  }
576
 
577
 
@@ -580,28 +691,24 @@
580
  * Limit number of feed items stored by their age
581
  * @since 3.0
582
  */
583
- function wprss_setting_limit_feed_items_age_callback() {
584
  $limit_feed_items_age = wprss_get_general_setting( 'limit_feed_items_age' );
585
  $limit_feed_items_age_unit = wprss_get_general_setting( 'limit_feed_items_age_unit' );
586
  $units = wprss_age_limit_units();
 
587
  ?>
588
-
589
- <input id="limit-feed-items-age" name="wprss_settings_general[limit_feed_items_age]" type="number" min="0"
590
- class="wprss-number-roller" placeholder="No limit" value="<?php echo $limit_feed_items_age; ?>" />
591
 
592
  <select id="limit-feed-items-age-unit" name="wprss_settings_general[limit_feed_items_age_unit]">
593
  <?php foreach ( $units as $unit ) : ?>
594
- <option value="<?php echo $unit; ?>" <?php selected( $limit_feed_items_age_unit, $unit ); ?> ><?php echo $unit; ?></option>
595
- <?php endforeach; ?>
596
  </select>
597
-
 
598
  <br/>
599
- <label class='description' for='limit-feed-items-age'>
600
- Enter the maximum age of feed items to be stored in the database. Feed items older than the specified age will be deleted everyday at midnight.
601
- <br/>
602
- Leave empty for no limit.
603
- </label>
604
-
605
  <?php
606
  }
607
 
@@ -611,10 +718,11 @@
611
  * Limit number of feed items stored
612
  * @since 3.0
613
  */
614
- function wprss_setting_limit_feed_items_callback() {
615
  $limit_feed_items_db = wprss_get_general_setting( 'limit_feed_items_db' );
616
- echo "<input id='limit-feed-items-db' name='wprss_settings_general[limit_feed_items_db]' type='text' value='$limit_feed_items_db' />";
617
- echo "<label class='description' for='limit-feed-items-db'>Enter the maximum number of feeds to store in the database; enter 0 for unlimited feed items</label>";
 
618
  }
619
 
620
 
@@ -622,16 +730,11 @@
622
  * Limit number of feed items imported per feed
623
  * @since 3.1
624
  */
625
- function wprss_setting_limit_feed_items_imported_callback() {
626
  $limit_feed_items_imported = wprss_get_general_setting( 'limit_feed_items_imported' );
627
- echo "<input id='limit-feed-items-imported' name='wprss_settings_general[limit_feed_items_imported]' type='text' value='$limit_feed_items_imported' placeholder='No Limit' />";
628
  ?>
629
- <label class='description' for='limit-feed-items-imported'>
630
- Enter the maximum number of feed items to import, for each feed source that does not have its own limit.
631
- <br/>
632
- <small>Use 0 or leave empty to use no limit.</small>
633
- </label>
634
- <?php
635
  }
636
 
637
 
@@ -650,7 +753,7 @@
650
  * Cron interval dropdown callback
651
  * @since 3.0
652
  */
653
- function wprss_setting_cron_interval_callback() {
654
  $options = get_option( 'wprss_settings_general' );
655
  $current = $options['cron_interval'];
656
 
@@ -660,56 +763,62 @@
660
  'wprss_schedules',
661
  array( 'fifteen_min', 'thirty_min', 'hourly', 'two_hours', 'twicedaily', 'daily' )
662
  );
663
- echo "<select id='cron-interval' name='wprss_settings_general[cron_interval]'>";
664
- foreach( $schedules as $schedule_name => $schedule_data ) {
665
- if ( in_array( $schedule_name, $wprss_schedules ) ) { ?>
666
- <option value="<?php echo $schedule_name; ?>" <?php selected( $current, $schedule_name ); ?> >
667
- <?php echo $schedule_data['display']; ?> (<?php echo wprss_interval( $schedule_data['interval'] ); ?>)
 
 
668
  </option>
669
- <?php } ?>
670
- <?php } ?>
671
- </select><?php
 
672
  }
673
 
674
  /**
675
  * Sets the custom feed URL
676
  * @since 3.3
677
  */
678
- function wprss_settings_custom_feed_url_callback() {
679
  $custom_feed_url = wprss_get_general_setting( 'custom_feed_url' );
680
- echo "<input id='custom_feed_url' name='wprss_settings_general[custom_feed_url]' type='text' value='$custom_feed_url' />";
681
- echo "<label class='description' for='custom_feed_url'>" . __( 'The URL of the custom feed. This might require you to re-save your Permalink settings for the custom feed to work.', 'wprss' ) . "</label>";
 
682
  }
683
 
684
  /**
685
  * Sets the custom feed title
686
  * @since 4.1.2
687
  */
688
- function wprss_settings_custom_feed_title_callback() {
689
  $custom_feed_title = wprss_get_general_setting( 'custom_feed_title' );
690
- echo "<input id='custom_feed_title' name='wprss_settings_general[custom_feed_title]' type='text' value='$custom_feed_title' />";
691
- echo "<label class='description' for='custom_feed_title'>" . __( 'The title of the custom feed', 'wprss' ) . "</label>";
 
692
  }
693
 
694
  /**
695
  * Sets the custom feed limit
696
  * @since 3.3
697
  */
698
- function wprss_setings_custom_feed_limit_callback() {
699
  $custom_feed_limit = wprss_get_general_setting( 'custom_feed_limit' );
700
- echo "<input id='custom_feed_limit' name='wprss_settings_general[custom_feed_limit]' placeholder='Default' min='0' class='wprss-number-roller' type='number' value='$custom_feed_limit' />";
701
- echo "<label class='description' for='custom_feed_limit'>" . __( 'Number of items to show in the custom feed', 'wprss' ) . "</label>";
 
702
  }
703
 
704
  /**
705
  * Disable styles
706
  * @since 3.0
707
  */
708
- function wprss_setting_styles_disable_callback( $args ) {
709
  $styles_disable = wprss_get_general_setting( 'styles_disable' );
710
- echo "<input id='styles-disable' name='wprss_settings_general[styles_disable]' type='checkbox' value='1' " . checked( 1, $styles_disable, false ) . " />";
711
- echo "<label class='description' for='styles-disable'>Check this box to disable all plugin styles</label>";
712
- echo "<p class='description'>You will then be responsible for providing your own CSS styles.</p>";
713
  }
714
 
715
 
@@ -723,27 +832,27 @@
723
  $reset_code = get_option( 'wprss_secure_reset_code', '' );
724
  ?>
725
  <input id="wprss-secure-reset-code" name="wprss_secure_reset_code" type="input" value="<?php echo $reset_code; ?>" />
726
- <button type="button" role="button" id="wprss-secure-reset-generate">Generate Random Code</button>
727
 
728
  <br/>
729
 
730
  <label class="description" for="wprss-secure-reset-code">
731
- Enter the code to use to securely reset the plugin and deactivate it. Be sure to save this code somewhere safe.<br/>
732
  </label>
733
 
734
  <br/>
735
 
736
  <p>
737
- Leave this empty to disable the secure reset function.<br/>
738
- You use this code by adding any of the following to any URL on your site.
739
  <ol>
740
- <li>"?wprss_action=reset&wprss_security_code=&lt;your_code&gt;" - <b>Resets your WP RSS Aggregator settings</b></li>
741
- <li>"?wprss_action=deactivate&wprss_security_code=&lt;your_code&gt;" - <b>Deactivates WP RSS Aggregator</b></li>
742
- <li>"?wprss_action=reset_and_deactivate&wprss_security_code=&lt;your_code&gt;" - <b>Does both of the above</b></li>
743
  </ol>
744
  </p>
745
  <p class="description">
746
- Use the above actions only when absolutely necessary, or when instructed to by support staff.
747
  </p>
748
  <?php
749
  }
@@ -753,21 +862,26 @@
753
  * Tracking checkbox
754
  * @since 3.6
755
  */
756
- function wprss_tracking_callback( $args ) {
757
  $tracking = wprss_get_general_setting( 'tracking' );
758
- echo "<input type='checkbox' id='tracking' name='wprss_settings_general[tracking]' value='1' " . checked( 1, $tracking, false ) . " />";
759
- echo "<label class='description' for='tracking'>Please help us improve WP RSS Aggregator by allowing us to gather anonymous usage statistics.</label>";
760
- echo "<p class='description'>No sensitive data will be sent.</p>";
 
 
 
 
761
  }
762
 
763
  /**
764
  * Time ago format checkbox
765
  * @since 4.2
766
  */
767
- function wprss_setting_time_ago_format_enable_callback() {
768
  $time_ago_format = wprss_get_general_setting( 'time_ago_format_enable' );
769
- echo "<input type='checkbox' id='time-ago-format' name='wprss_settings_general[time_ago_format_enable]' value='1' " . checked( 1, $time_ago_format, false ) . " />";
770
- echo "<label class='description' for='time-ago-format'>Check this box to show time since update e.g.: 2 hours ago.</label>";
 
771
  }
772
 
773
 
@@ -794,7 +908,7 @@
794
  */
795
  function wprss_interval( $since ) {
796
  if ( $since === wprss_get_default_feed_source_update_interval() ) {
797
- return __( 'Default', 'wprss' );
798
  }
799
  // array of time period chunks
800
  $chunks = array(
@@ -809,7 +923,7 @@
809
 
810
 
811
  if( $since <= 0 ) {
812
- return __( 'now', 'wprss' );
813
  }
814
 
815
  // we only want to output two chunks of time here, eg:
@@ -831,7 +945,7 @@
831
  }
832
 
833
  // set output var
834
- $output = sprintf(_n($name[0], $name[1], $count, 'wprss'), $count);
835
 
836
  // step two: the second chunk
837
  if ($i + 1 < $j)
@@ -842,7 +956,7 @@
842
  if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0)
843
  {
844
  // add to output var
845
- $output .= ' '.sprintf(_n($name2[0], $name2[1], $count2, 'wprss'), $count2);
846
  }
847
  }
848
 
53
  $sections = apply_filters(
54
  'wprss_settings_sections_array',
55
  array(
56
+ 'general' => __( 'General plugin settings', WPRSS_TEXT_DOMAIN ),
57
+ 'display' => __( 'General display settings', WPRSS_TEXT_DOMAIN ),
58
+ 'source' => __( 'Source display settings', WPRSS_TEXT_DOMAIN ),
59
+ 'date' => __( 'Date display settings', WPRSS_TEXT_DOMAIN ),
60
+ 'styles' => __( 'Styles', WPRSS_TEXT_DOMAIN ),
61
  )
62
  );
63
 
67
  array(
68
  'general' => array(
69
  'limit-feed-items-by-age' => array(
70
+ 'label' => __( 'Limit feed items by age', WPRSS_TEXT_DOMAIN ),
71
  'callback' => 'wprss_setting_limit_feed_items_age_callback'
72
  ),
73
  'limit-feed-items-db' => array(
74
+ 'label' => __( 'Limit feed items stored', WPRSS_TEXT_DOMAIN ),
75
  'callback' => 'wprss_setting_limit_feed_items_callback'
76
  ),
77
  'limit-feed-items-imported' => array(
78
+ 'label' => __( 'Limit feed items per feed', WPRSS_TEXT_DOMAIN ),
79
  'callback' => 'wprss_setting_limit_feed_items_imported_callback'
80
  ),
81
  'cron-interval' => array(
82
+ 'label' => __( 'Feed processing interval', WPRSS_TEXT_DOMAIN ),
83
  'callback' => 'wprss_setting_cron_interval_callback'
84
  ),
85
  'custom-feed-url' => array(
86
+ 'label' => __( 'Custom feed URL', WPRSS_TEXT_DOMAIN ),
87
  'callback' => 'wprss_settings_custom_feed_url_callback'
88
  ),
89
  'custom-feed-title' => array(
90
+ 'label' => __( 'Custom feed Title', WPRSS_TEXT_DOMAIN ),
91
  'callback' => 'wprss_settings_custom_feed_title_callback'
92
  ),
93
  'custom-feed-limit' => array(
94
+ 'label' => __( 'Custom feed limit', WPRSS_TEXT_DOMAIN ),
95
  'callback' => 'wprss_setings_custom_feed_limit_callback'
96
  ),
97
  'tracking' => array(
98
+ 'label' => __( 'Anonymous tracking', WPRSS_TEXT_DOMAIN ),
99
  'callback' => 'wprss_tracking_callback',
100
  )
101
  ),
103
  'display' => array(
104
  // Title options
105
  'link-enable' => array(
106
+ 'label' => __( 'Link title', WPRSS_TEXT_DOMAIN ),
107
  'callback' => 'wprss_setting_title_link_callback'
108
  ),
109
  'title-limit' => array(
110
+ 'label' => __( 'Title maximum length', WPRSS_TEXT_DOMAIN ),
111
  'callback' => 'wprss_setting_title_length_callback'
112
  ),
113
 
115
 
116
  // Misc Options
117
  'authors-enable' => array(
118
+ 'label' => __( 'Show authors', WPRSS_TEXT_DOMAIN ),
119
  'callback' => 'wprss_setting_authors_enable_callback',
120
  ),
121
  'video-links' => array(
122
+ 'label' => __( 'For video feed items use', WPRSS_TEXT_DOMAIN ),
123
  'callback' => 'wprss_setting_video_links_callback'
124
  ),
125
  'pagination' => array(
126
+ 'label' => __( 'Pagination type', WPRSS_TEXT_DOMAIN ),
127
  'callback' => 'wprss_setting_pagination_type_callback',
128
  ),
129
  'feed-limit' => array(
130
+ 'label' => __( 'Feed display limit', WPRSS_TEXT_DOMAIN ),
131
  'callback' => 'wprss_setting_feed_limit_callback'
132
  ),
133
  'open-dd' => array(
134
+ 'label' => __( 'Open links behaviour', WPRSS_TEXT_DOMAIN ),
135
  'callback' => 'wprss_setting_open_dd_callback'
136
  ),
137
  'follow-dd' => array(
138
+ 'label' => __( 'Set links as nofollow', WPRSS_TEXT_DOMAIN ),
139
  'callback' => 'wprss_setting_follow_dd_callback'
140
  ),
141
  ),
143
  // Source Options
144
  'source' => array(
145
  'source-enable' => array(
146
+ 'label' => __( 'Show source', WPRSS_TEXT_DOMAIN ),
147
  'callback' => 'wprss_setting_source_enable_callback'
148
  ),
149
  'text-preceding-source' => array(
150
+ 'label' => __( 'Text preceding source', WPRSS_TEXT_DOMAIN ),
151
  'callback' => 'wprss_setting_text_preceding_source_callback'
152
  ),
153
  'source-link' => array(
154
+ 'label' => __( 'Link source', WPRSS_TEXT_DOMAIN ),
155
  'callback' => 'wprss_setting_source_link_callback'
156
  ),
157
  ),
159
  // Date options
160
  'date' => array(
161
  'date-enable' => array(
162
+ 'label' => __( 'Show date', WPRSS_TEXT_DOMAIN ),
163
  'callback' => 'wprss_setting_date_enable_callback'
164
  ),
165
  'text-preceding-date' => array(
166
+ 'label' => __( 'Text preceding date', WPRSS_TEXT_DOMAIN ),
167
  'callback' => 'wprss_setting_text_preceding_date_callback'
168
  ),
169
  'date-format' => array(
170
+ 'label' => __( 'Date format', WPRSS_TEXT_DOMAIN ),
171
  'callback' => 'wprss_setting_date_format_callback'
172
  ),
173
  'time-ago-format-enable' => array(
174
+ 'label' => __( 'Time ago format', WPRSS_TEXT_DOMAIN ),
175
  'callback' => 'wprss_setting_time_ago_format_enable_callback'
176
  ),
177
  ),
178
 
179
  'styles' => array(
180
  'styles-disable' => array(
181
+ 'label' => __( 'Disable Styles', WPRSS_TEXT_DOMAIN ),
182
  'callback' => 'wprss_setting_styles_disable_callback'
183
  )
184
  )
188
  if ( apply_filters( 'wprss_use_fixed_feed_limit', FALSE ) === FALSE ) {
189
  unset( $settings['general']['limit-feed-items-db'] );
190
  }
191
+
192
+ $setting_field_id_prefix = 'wprss-settings-';
193
 
194
 
195
  // Loop through each setting field and register it
205
 
206
  foreach ( $fields as $id => $data ) {
207
 
208
+ /**
209
+ * @var This will be passed to the field callback as the only argument
210
+ * @see http://codex.wordpress.org/Function_Reference/add_settings_field#Parameters
211
+ */
212
+ $callback_args = array(
213
+ 'field_id' => $id,
214
+ 'field_id_prefix' => $setting_field_id_prefix,
215
+ 'section_id' => $section,
216
+ 'field_label' => isset( $data['label'] ) ? $data['label'] : null,
217
+ 'tooltip' => isset( $data['tooltip'] ) ? $data['tooltip'] : null
218
+ );
219
+
220
+
221
  add_settings_field(
222
+ $setting_field_id_prefix . $id,
223
  $data['label'],
224
  $data['callback'],
225
  'wprss_settings_general',
226
+ "wprss_settings_${section}_section",
227
+ $callback_args
228
  );
229
 
230
  }
241
  );
242
  add_settings_section(
243
  'wprss_secure_reset_section', // ID of section
244
+ __( 'Secure Reset', WPRSS_TEXT_DOMAIN ), // Title of section
245
  'wprss_secure_reset_section_callback', // Callback that renders the section header
246
  'wprss_settings_general' // The page on which to display the section
247
  );
248
  add_settings_field(
249
  'wprss-settings-secure-reset', // ID of setting
250
+ __( 'Secure Reset', WPRSS_TEXT_DOMAIN ), // The title of the setting
251
  'wprss_settings_secure_reset_code_callback', // The callback that renders the setting
252
  'wprss_settings_general', // The page on which to display the setting
253
  "wprss_secure_reset_section" // The section in which to display the setting
257
 
258
 
259
  do_action( 'wprss_admin_init' );
260
+ }
261
+
262
+
263
+ /**
264
+ * Returns the HTML of a tooltip handle.
265
+ *
266
+ * Filters used:
267
+ * - `wprss_settings_inline_help_default_options` - The default options for "Settings" page's tooltips
268
+ * - `wprss_settings_inline_help_id_prefix` - The prefix for all tooltip IDs for the "Settings" page.
269
+ *
270
+ * @param string $id The ID of the tooltip
271
+ * @param string|null $text Text for this tooltip, if any.
272
+ * @param array $options Any options for this setting.
273
+ * @return string Tooltip handle HTML. See {@link WPRSS_Help::tooltip()}.
274
+ */
275
+ function wprss_settings_inline_help( $id, $text = null, $options = array() ) {
276
+ $help = WPRSS_Help::get_instance();
277
+
278
+ // Default options, entry point
279
+ $defaults = apply_filters( 'wprss_settings_inline_help_default_options', array(
280
+ 'tooltip_handle_class_extra' => $help->get_options('tooltip_handle_class_extra') . ' ' . $help->get_options('tooltip_handle_class') . '-setting'
281
+ ));
282
+
283
+ $options = $help->array_merge_recursive_distinct( $defaults, $options );
284
+
285
+ // ID Prefix
286
+ $id = apply_filters( 'wprss_settings_inline_help_id_prefix', 'setting-' ) . $id;
287
+
288
+ return $help->tooltip( $id, $text, $options );
289
+ }
290
+
291
+
292
+ /**
293
+ *
294
+ * @param type $string
295
+ * @return type
296
+ */
297
+ function wprss_settings_field_name_prefix( $string = '' ) {
298
+ $string = (string) $string;
299
+ $prefix = apply_filters( 'wprss_settings_field_name_prefix', 'wprss_settings_', $string );
300
+ return $prefix . $string;
301
+ }
302
+
303
+
304
+ /**
305
+ * Generates a uniform setting field name for use in HTML.
306
+ * The parts used are the ID of the field, the section it is in, and an optional prefix.
307
+ * All parts are optional, but, if they appear, they shall appear in this order: $prefix, $section, $id.
308
+ *
309
+ * If only the section is not specified, the $id will be simply prefixed by $prefix.
310
+ * If either the $id or the $section are empty (but not both), $prefix will be stripped of known separators.
311
+ * Empty parts will be excluded.
312
+ *
313
+ * @param string $id ID of the field.
314
+ * @param string|null $section Name of the section, to which this field belongs.
315
+ * @param string|null $prefix The string to prefix the name with; appears first. If boolean false, no prefix will be applied. Default: return value of {@link wprss_settings_field_name_prefix()}.
316
+ * @return string Name of the settings field, namespaced and optionally prefixed.
317
+ */
318
+ function wprss_settings_field_name( $id = null, $section = null, $prefix = null ) {
319
+ if( $prefix !== false ) $prefix = is_null( $prefix ) ? wprss_settings_field_name_prefix() : $prefix;
320
+ else $prefix = '';
321
+
322
+ $section = (string) $section;
323
+
324
+ $format = '';
325
+ if( !strlen( $section ) xor !strlen($id) ) $prefix = trim ( $prefix, "\t\n\r _-:" );
326
+ if( strlen( $prefix ) ) $format .= '%3$s';
327
+ if( strlen( $section ) ) $format .= '%2$s';
328
+ if( strlen( $id ) ) $format .= ( !strlen( $section ) ? '%1$s' : '[%1$s]' );
329
+
330
+ return apply_filters( 'wprss_settings_field_name', sprintf( $format, $id, $section, $prefix ), $id, $section, $prefix );
331
+ }
332
 
333
 
334
  /**
340
  <div class="wrap">
341
  <?php screen_icon( 'wprss-aggregator' ); ?>
342
 
343
+ <h2><?php _e( 'WP RSS Aggregator Settings', WPRSS_TEXT_DOMAIN ); ?></h2>
344
 
345
  <?php settings_errors(); ?>
346
 
350
 
351
  $default_tabs = array(
352
  'general' => array(
353
+ 'label' => __( 'General', WPRSS_TEXT_DOMAIN ),
354
  'slug' => 'general_settings',
355
  ),
356
  'licenses' => array(
357
+ 'label' => __( 'Licenses', WPRSS_TEXT_DOMAIN ),
358
  'slug' => 'licenses_settings'
359
  )
360
  );
394
  do_action( 'wprss_add_settings_fields_sections', $active_tab );
395
  }
396
 
397
+ submit_button( __( 'Save Settings', WPRSS_TEXT_DOMAIN ) );
398
 
399
  ?>
400
  </form>
408
  * @since 3.0
409
  */
410
  function wprss_settings_general_callback() {
411
+ echo '<p>' . __( 'These are the general settings for WP RSS Aggregator.', WPRSS_TEXT_DOMAIN ) . '</p>';
412
  }
413
 
414
 
417
  * @since 3.5
418
  */
419
  function wprss_settings_display_callback() {
420
+ echo '<p>' . __( 'In this section you can find some general options that control how the feed items are displayed.', WPRSS_TEXT_DOMAIN ) . '</p>';
421
  }
422
 
423
 
427
  * @since 4.2.4
428
  */
429
  function wprss_settings_source_callback() {
430
+ echo '<p>' . __( 'Options that control how the feed item\'s source is displayed.', WPRSS_TEXT_DOMAIN ) . '</p>';
431
  }
432
 
433
  /**
436
  * @since 4.2.4
437
  */
438
  function wprss_settings_date_callback() {
439
+ echo '<p>' . __( 'Options that control how the feed item\'s date is displayed.', WPRSS_TEXT_DOMAIN ) . '</p>';
440
  }
441
 
442
 
445
  * @since 3.0
446
  */
447
  function wprss_settings_styles_callback() {
448
+ echo '<p>' . __( 'If you would like to disable all styles used in this plugin, tick the checkbox.', WPRSS_TEXT_DOMAIN ) . '</p>';
449
  }
450
 
451
 
454
  * @since 3.0
455
  */
456
  function wprss_secure_reset_section_callback() {
457
+ echo '<p>' . __( 'Set your security reset code, in case of any errors.', WPRSS_TEXT_DOMAIN ) . '</p>';
458
  }
459
 
460
 
463
  * @since 3.0
464
  */
465
  function wprss_tracking_section_callback() {
466
+ echo '<p>' . __( 'Participate in helping us make the plugin better.', WPRSS_TEXT_DOMAIN ) . '</p>';
467
  }
468
 
469
 
471
  * Follow or No Follow dropdown
472
  * @since 1.1
473
  */
474
+ function wprss_setting_follow_dd_callback( $field ) {
475
  $follow_dd = wprss_get_general_setting( 'follow_dd' );
476
 
477
  $checked = ( $follow_dd === 'no_follow' );
478
  $checked_attr = ( $checked )? 'checked="checked"' : '';
479
+ ?>
480
+ <input type="hidden" name="wprss_settings_general[follow_dd]" value="follow" />
481
+ <input type="checkbox" id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[follow_dd]" value="no_follow" <?php echo $checked_attr ?> />
482
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
 
 
 
483
  }
484
 
485
 
487
  * Use original video link, or embedded video links dropwdown
488
  * @since 3.4
489
  */
490
+ function wprss_setting_video_links_callback( $field ) {
491
  $video_link = wprss_get_general_setting('video_link');
492
  $items = array(
493
+ 'false' => __( 'Original page link', WPRSS_TEXT_DOMAIN ),
494
+ 'true' => __( 'Embedded video player link', WPRSS_TEXT_DOMAIN )
495
  );
496
+ ?>
497
+ <select id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[video_link]">
498
+ <?php
499
  foreach ( $items as $boolean => $text ) {
500
  $selected = ( $video_link === $boolean )? 'selected="selected"' : '';
501
+ ?><option value="<?php echo $boolean ?>" <?php echo $selected ?>><?php echo $text ?></option><?php
502
  }
503
+ ?>
504
+ </select>
505
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] ) ?>
506
+ <p>
507
+ <span class="description">
508
+ <?php _e( 'This will not affect already imported feed items.', WPRSS_TEXT_DOMAIN ) ?>
509
+ </span>
510
+ </p>
511
+ <?php
512
  }
513
 
514
 
516
  * Link open setting dropdown
517
  * @since 1.1
518
  */
519
+ function wprss_setting_open_dd_callback( $field ) {
520
  $open_dd = wprss_get_general_setting('open_dd');
521
 
522
  $items = array(
523
+ __( 'Lightbox', WPRSS_TEXT_DOMAIN ),
524
+ __( 'New window', WPRSS_TEXT_DOMAIN ),
525
+ __( 'Self', WPRSS_TEXT_DOMAIN )
526
  );
527
+ ?>
528
+ <select id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[open_dd]">
529
+ <?php
530
  foreach( $items as $item ) {
531
  $selected = ( $open_dd == $item ) ? 'selected="selected"' : '';
532
+ ?><option value="<?php echo $item ?>" <?php echo $selected ?>><?php echo $item ?></option><?php
533
  }
534
+ ?>
535
+ </select>
536
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
 
 
 
537
  }
538
 
539
 
541
  * Set limit for feeds on frontend
542
  * @since 2.0
543
  */
544
+ function wprss_setting_feed_limit_callback( $field ) {
545
  $feed_limit = wprss_get_general_setting( 'feed_limit' );
546
+ ?>
547
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[feed_limit]" type="text" value="<?php echo $feed_limit ?>" />
548
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
549
  }
550
 
551
 
553
  * Set date format
554
  * @since 3.0
555
  */
556
+ function wprss_setting_date_format_callback( $field ) {
557
  $date_format = wprss_get_general_setting( 'date_format' );
558
+ ?>
559
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[date_format]" type="text" value="<?php echo $date_format ?>" />
560
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] ) ?>
561
+ <p>
562
+ <a href="http://codex.wordpress.org/Formatting_Date_and_Time">
563
+ <?php _e( 'PHP Date Format Reference', WPRSS_TEXT_DOMAIN ); ?>
564
+ </a>
565
+ </p>
566
+ <?php
567
  }
568
 
569
 
572
  * Enable linked title
573
  * @since 3.0
574
  */
575
+ function wprss_setting_title_link_callback( $field ) {
576
  $title_link = wprss_get_general_setting( 'title_link' );
577
+ ?>
578
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[title_link]" type="checkbox" value="1" <?php echo checked( 1, $title_link, false ) ?> />
579
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
580
  }
581
 
582
 
585
  * Set the title length limit
586
  * @since 3.0
587
  */
588
+ function wprss_setting_title_length_callback( $field ) {
589
  $title_limit = wprss_get_general_setting( 'title_limit' );
590
+ ?>
591
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[title_limit]" type="number" class="wprss-number-roller" min="0" value="<?php echo $title_limit ?>" placeholder="<?php _e( 'No limit', WPRSS_TEXT_DOMAIN ) ?>" />
592
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
593
  }
594
 
595
 
597
  * Enable source
598
  * @since 3.0
599
  */
600
+ function wprss_setting_source_enable_callback( $field ) {
601
  $source_enable = wprss_get_general_setting( 'source_enable' );
602
+ ?>
603
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[source_enable]" type="checkbox" value="1" <?php echo checked( 1, $source_enable, false ) ?> />
604
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
605
  }
606
 
607
  /**
608
  * Enable linked title
609
  * @since 3.0
610
  */
611
+ function wprss_setting_source_link_callback( $field ) {
612
+ $source_link = wprss_get_general_setting( 'source_link' );
613
+ ?>
614
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[source_link]" type="checkbox" value="1" <?php echo checked( 1, $source_link, false ) ?> />
615
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
616
  }
617
 
618
 
620
  * Set text preceding source
621
  * @since 3.0
622
  */
623
+ function wprss_setting_text_preceding_source_callback( $field ) {
624
  $text_preceding_source = wprss_get_general_setting( 'text_preceding_source' );
625
+ ?>
626
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[text_preceding_source]" type="text" value="<?php echo $text_preceding_source ?>" />
627
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
628
  }
629
  /**
630
  * Enable date
631
  * @since 3.0
632
  */
633
+ function wprss_setting_date_enable_callback( $field ) {
634
  $date_enable = wprss_get_general_setting( 'date_enable' );
635
+ ?>
636
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[date_enable]" type="checkbox" value="1" <?php echo checked( 1, $date_enable, false ) ?> />
637
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
638
  }
639
 
640
  /**
641
  * Set text preceding date
642
  * @since 3.0
643
  */
644
+ function wprss_setting_text_preceding_date_callback( $field ) {
645
  $text_preceding_date = wprss_get_general_setting( 'text_preceding_date' );
646
+ ?>
647
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[text_preceding_date]" type="text" value="<?php echo $text_preceding_date ?>" />
648
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
649
  }
650
 
651
 
654
  *
655
  * @since 4.2.4
656
  */
657
+ function wprss_setting_authors_enable_callback( $field ) {
658
  $authors_enable = wprss_get_general_setting( 'authors_enable' );
659
+ ?>
660
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[authors_enable]" type="checkbox" value="1" <?php echo checked( 1, $authors_enable, false ) ?> />
661
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
662
  }
663
 
664
 
667
  *
668
  * @since 4.2.3
669
  */
670
+ function wprss_setting_pagination_type_callback( $field ) {
671
  $pagination = wprss_get_general_setting( 'pagination' );
672
  $options = array(
673
+ 'default' => __( '"Older posts" and "Newer posts" links', WPRSS_TEXT_DOMAIN ),
674
+ 'numbered' => __( 'Page numbers with "Next" and "Previous" page links', WPRSS_TEXT_DOMAIN ),
675
  );
676
+ ?>
677
+ <select id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[pagination]">
678
+ <?php
679
  foreach( $options as $value => $text ) {
680
  $selected = ( $value === $pagination )? 'selected="selected"' : '';
681
+ ?><option value="<?php echo $value ?>" <?php echo $selected ?>><?php echo $text ?></option><?php
682
  }
683
+ ?>
684
+ </select>
685
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
686
  }
687
 
688
 
691
  * Limit number of feed items stored by their age
692
  * @since 3.0
693
  */
694
+ function wprss_setting_limit_feed_items_age_callback( $field ) {
695
  $limit_feed_items_age = wprss_get_general_setting( 'limit_feed_items_age' );
696
  $limit_feed_items_age_unit = wprss_get_general_setting( 'limit_feed_items_age_unit' );
697
  $units = wprss_age_limit_units();
698
+ // echo wprss_settings_field_name( $field_info['field_id'], $field_info['section_id'], $field_info['field_name_prefix'] )
699
  ?>
700
+
701
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[limit_feed_items_age]" type="number" min="0"
702
+ class="wprss-number-roller" placeholder="<?php echo _e( 'No limit', WPRSS_TEXT_DOMAIN ) ?>" value="<?php echo $limit_feed_items_age; ?>" />
703
 
704
  <select id="limit-feed-items-age-unit" name="wprss_settings_general[limit_feed_items_age_unit]">
705
  <?php foreach ( $units as $unit ) : ?>
706
+ <option value="<?php echo $unit ?>" <?php selected( $limit_feed_items_age_unit, $unit ) ?> ><?php echo $unit ?></option>
707
+ <?php endforeach ?>
708
  </select>
709
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] ) ?>
710
+
711
  <br/>
 
 
 
 
 
 
712
  <?php
713
  }
714
 
718
  * Limit number of feed items stored
719
  * @since 3.0
720
  */
721
+ function wprss_setting_limit_feed_items_callback( $field ) {
722
  $limit_feed_items_db = wprss_get_general_setting( 'limit_feed_items_db' );
723
+ ?>
724
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[limit_feed_items_db]" type="text" value="<?php echo $limit_feed_items_db ?>" />
725
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
726
  }
727
 
728
 
730
  * Limit number of feed items imported per feed
731
  * @since 3.1
732
  */
733
+ function wprss_setting_limit_feed_items_imported_callback( $field ) {
734
  $limit_feed_items_imported = wprss_get_general_setting( 'limit_feed_items_imported' );
 
735
  ?>
736
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[limit_feed_items_imported]" type="text" value="<?php echo $limit_feed_items_imported ?>" placeholder="<?php _e( 'No Limit', WPRSS_TEXT_DOMAIN ) ?>" />
737
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
 
 
 
 
738
  }
739
 
740
 
753
  * Cron interval dropdown callback
754
  * @since 3.0
755
  */
756
+ function wprss_setting_cron_interval_callback( $field ) {
757
  $options = get_option( 'wprss_settings_general' );
758
  $current = $options['cron_interval'];
759
 
763
  'wprss_schedules',
764
  array( 'fifteen_min', 'thirty_min', 'hourly', 'two_hours', 'twicedaily', 'daily' )
765
  );
766
+ ?>
767
+ <select id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[cron_interval]">
768
+ <?php
769
+ foreach( $schedules as $schedule_name => $schedule_data ):
770
+ if ( in_array( $schedule_name, $wprss_schedules ) ): ?>
771
+ <option value="<?php echo $schedule_name ?>" <?php selected( $current, $schedule_name ) ?> >
772
+ <?php echo $schedule_data['display'] ?> (<?php echo wprss_interval( $schedule_data['interval'] ) ?>)
773
  </option>
774
+ <?php endif ?>
775
+ <?php endforeach ?>
776
+ </select>
777
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] ) ?><?php
778
  }
779
 
780
  /**
781
  * Sets the custom feed URL
782
  * @since 3.3
783
  */
784
+ function wprss_settings_custom_feed_url_callback( $field ) {
785
  $custom_feed_url = wprss_get_general_setting( 'custom_feed_url' );
786
+ ?>
787
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[custom_feed_url]" type="text" value="<?php echo $custom_feed_url ?>" />
788
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
789
  }
790
 
791
  /**
792
  * Sets the custom feed title
793
  * @since 4.1.2
794
  */
795
+ function wprss_settings_custom_feed_title_callback( $field ) {
796
  $custom_feed_title = wprss_get_general_setting( 'custom_feed_title' );
797
+ ?>
798
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[custom_feed_title]" type="text" value="<?php echo $custom_feed_title ?>" />
799
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
800
  }
801
 
802
  /**
803
  * Sets the custom feed limit
804
  * @since 3.3
805
  */
806
+ function wprss_setings_custom_feed_limit_callback( $field ) {
807
  $custom_feed_limit = wprss_get_general_setting( 'custom_feed_limit' );
808
+ ?>
809
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[custom_feed_limit]" placeholder="<?php _e( 'Default', WPRSS_TEXT_DOMAIN ) ?>" min="0" class="wprss-number-roller" type="number" value="<?php echo $custom_feed_limit ?>" />
810
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
811
  }
812
 
813
  /**
814
  * Disable styles
815
  * @since 3.0
816
  */
817
+ function wprss_setting_styles_disable_callback( $field ) {
818
  $styles_disable = wprss_get_general_setting( 'styles_disable' );
819
+ ?>
820
+ <input id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[styles_disable]" type="checkbox" value="1" <?php echo checked( 1, $styles_disable, false ) ?> />
821
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
822
  }
823
 
824
 
832
  $reset_code = get_option( 'wprss_secure_reset_code', '' );
833
  ?>
834
  <input id="wprss-secure-reset-code" name="wprss_secure_reset_code" type="input" value="<?php echo $reset_code; ?>" />
835
+ <button type="button" role="button" id="wprss-secure-reset-generate"><?php _e( 'Generate Random Code', WPRSS_TEXT_DOMAIN ) ?></button>
836
 
837
  <br/>
838
 
839
  <label class="description" for="wprss-secure-reset-code">
840
+ <?php _e( 'Enter the code to use to securely reset the plugin and deactivate it. Be sure to save this code somewhere safe.', WPRSS_TEXT_DOMAIN ) ?><br/>
841
  </label>
842
 
843
  <br/>
844
 
845
  <p>
846
+ <?php _e( 'Leave this empty to disable the secure reset function.<br/>
847
+ You use this code by adding any of the following to any URL on your site.', WPRSS_TEXT_DOMAIN ) ?>
848
  <ol>
849
+ <li>"?wprss_action=reset&wprss_security_code=&lt;your_code&gt;" - <b><?php _e( 'Resets your WP RSS Aggregator settings', WPRSS_TEXT_DOMAIN ) ?></b></li>
850
+ <li>"?wprss_action=deactivate&wprss_security_code=&lt;your_code&gt;" - <b><?php _e( 'Deactivates WP RSS Aggregator', WPRSS_TEXT_DOMAIN ) ?></b></li>
851
+ <li>"?wprss_action=reset_and_deactivate&wprss_security_code=&lt;your_code&gt;" - <b><?php _e( 'Does both of the above', WPRSS_TEXT_DOMAIN ) ?></b></li>
852
  </ol>
853
  </p>
854
  <p class="description">
855
+ <?php _e( 'Use the above actions only when absolutely necessary, or when instructed to by support staff.', WPRSS_TEXT_DOMAIN ) ?>
856
  </p>
857
  <?php
858
  }
862
  * Tracking checkbox
863
  * @since 3.6
864
  */
865
+ function wprss_tracking_callback( $field ) {
866
  $tracking = wprss_get_general_setting( 'tracking' );
867
+ ?>
868
+ <input type="checkbox" id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[tracking]" value="1" <?php echo checked( 1, $tracking, false ) ?> />
869
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] ) ?>
870
+ <label class="description" for="<?php echo $field['field_id'] ?>">
871
+ <?php _e( 'Please help us improve WP RSS Aggregator by allowing us to gather anonymous usage statistics. No sensitive data is collected.', WPRSS_TEXT_DOMAIN ) ?>
872
+ </label>
873
+ <?php
874
  }
875
 
876
  /**
877
  * Time ago format checkbox
878
  * @since 4.2
879
  */
880
+ function wprss_setting_time_ago_format_enable_callback( $field ) {
881
  $time_ago_format = wprss_get_general_setting( 'time_ago_format_enable' );
882
+ ?>
883
+ <input type="checkbox" id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[time_ago_format_enable]" value="1" <?php echo checked( 1, $time_ago_format, false ) ?> />
884
+ <?php echo wprss_settings_inline_help( $field['field_id'], $field['tooltip'] );
885
  }
886
 
887
 
908
  */
909
  function wprss_interval( $since ) {
910
  if ( $since === wprss_get_default_feed_source_update_interval() ) {
911
+ return __( 'Default', WPRSS_TEXT_DOMAIN );
912
  }
913
  // array of time period chunks
914
  $chunks = array(
923
 
924
 
925
  if( $since <= 0 ) {
926
+ return __( 'now', WPRSS_TEXT_DOMAIN );
927
  }
928
 
929
  // we only want to output two chunks of time here, eg:
945
  }
946
 
947
  // set output var
948
+ $output = sprintf(_n($name[0], $name[1], $count, WPRSS_TEXT_DOMAIN), $count);
949
 
950
  // step two: the second chunk
951
  if ($i + 1 < $j)
956
  if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0)
957
  {
958
  // add to output var
959
+ $output .= ' '.sprintf(_n($name2[0], $name2[1], $count2, WPRSS_TEXT_DOMAIN), $count2);
960
  }
961
  }
962
 
includes/admin.php CHANGED
@@ -33,7 +33,8 @@
33
 
34
  // Add the admin options pages as submenus to the Feed CPT
35
  function wprss_register_menu_pages() {
36
-
 
37
  //create submenu items
38
  add_submenu_page( 'edit.php?post_type=wprss_feed', __( 'Export & Import Settings', 'wprss' ), __( 'Import & Export', 'wprss' ), apply_filters( 'wprss_capability', 'manage_feed_settings' ), 'wprss-import-export-settings', 'wprss_import_export_settings_page_display' );
39
  add_submenu_page( 'edit.php?post_type=wprss_feed', __( 'WP RSS Aggregator Settings', 'wprss' ), __( 'Settings', 'wprss' ), apply_filters( 'wprss_capability', 'manage_feed_settings' ), 'wprss-aggregator-settings', 'wprss_settings_page_display' );
33
 
34
  // Add the admin options pages as submenus to the Feed CPT
35
  function wprss_register_menu_pages() {
36
+ global $submenu;
37
+ unset( $submenu['edit.php?post_type=wprss_feed'][10] );
38
  //create submenu items
39
  add_submenu_page( 'edit.php?post_type=wprss_feed', __( 'Export & Import Settings', 'wprss' ), __( 'Import & Export', 'wprss' ), apply_filters( 'wprss_capability', 'manage_feed_settings' ), 'wprss-import-export-settings', 'wprss_import_export_settings_page_display' );
40
  add_submenu_page( 'edit.php?post_type=wprss_feed', __( 'WP RSS Aggregator Settings', 'wprss' ), __( 'Settings', 'wprss' ), apply_filters( 'wprss_capability', 'manage_feed_settings' ), 'wprss-aggregator-settings', 'wprss_settings_page_display' );
includes/custom-post-types.php CHANGED
@@ -19,9 +19,9 @@
19
  'wprss_feed_post_type_labels',
20
  array(
21
  'name' => __( 'Feed Sources', 'wprss' ),
22
- 'singular_name' => __( 'Feed Source', 'wprss' ),
23
  'add_new' => __( 'Add New', 'wprss' ),
24
- 'all_items' => __( 'All Feed Sources', 'wprss' ),
25
  'add_new_item' => __( 'Add New Feed Source', 'wprss' ),
26
  'edit_item' => __( 'Edit Feed Source', 'wprss' ),
27
  'new_item' => __( 'New Feed Source', 'wprss' ),
@@ -68,13 +68,13 @@
68
  $labels = apply_filters(
69
  'wprss_feed_item_post_type_labels',
70
  array(
71
- 'name' => __( 'Feed Items', 'wprss' ),
72
- 'singular_name' => __( 'Feed Item', 'wprss' ),
73
- 'all_items' => __( 'Feed Items', 'wprss' ),
74
- 'view_item' => __( 'View Feed Items', 'wprss' ),
75
- 'search_items' => __( 'Search Feed Items', 'wprss' ),
76
- 'not_found' => __( 'No Feed Items Found', 'wprss' ),
77
- 'not_found_in_trash' => __( 'No Feed Items Found In Trash', 'wprss' )
78
  )
79
  );
80
 
@@ -127,4 +127,4 @@
127
 
128
  return $query;
129
  }
130
- add_filter( 'wp_link_query_args', 'wprss_modify_link_builder_query' );
19
  'wprss_feed_post_type_labels',
20
  array(
21
  'name' => __( 'Feed Sources', 'wprss' ),
22
+ 'singular_name' => __( 'Feed Source', 'wprss' ),
23
  'add_new' => __( 'Add New', 'wprss' ),
24
+ 'all_items' => __( 'Feed Sources', 'wprss' ),
25
  'add_new_item' => __( 'Add New Feed Source', 'wprss' ),
26
  'edit_item' => __( 'Edit Feed Source', 'wprss' ),
27
  'new_item' => __( 'New Feed Source', 'wprss' ),
68
  $labels = apply_filters(
69
  'wprss_feed_item_post_type_labels',
70
  array(
71
+ 'name' => __( 'Feed Items', 'wprss' ),
72
+ 'singular_name' => __( 'Feed Item', 'wprss' ),
73
+ 'all_items' => __( 'Feed Items', 'wprss' ),
74
+ 'view_item' => __( 'View Feed Items', 'wprss' ),
75
+ 'search_items' => __( 'Search Feed Items', 'wprss' ),
76
+ 'not_found' => __( 'No Feed Items Found', 'wprss' ),
77
+ 'not_found_in_trash' => __( 'No Feed Items Found In Trash', 'wprss' )
78
  )
79
  );
80
 
127
 
128
  return $query;
129
  }
130
+ add_filter( 'wp_link_query_args', 'wprss_modify_link_builder_query' );
includes/feed-display.php CHANGED
@@ -94,8 +94,7 @@
94
  $feed_items_args = array(
95
  'post_type' => 'wprss_feed_item',
96
  'posts_per_page' => $posts_per_page,
97
- 'orderby' => 'meta_value',
98
- 'meta_key' => 'wprss_item_date',
99
  'order' => 'DESC',
100
  'paged' => $paged,
101
  'suppress_filters' => true
@@ -196,7 +195,7 @@
196
  $link_enclosure = get_post_meta( $feed_source_id, 'wprss_enclosure', true );
197
  $source_name = get_the_title( $feed_source_id );
198
  $source_url = get_post_meta( $feed_source_id, 'wprss_site_url', true );
199
- $timestamp = intval( get_post_meta( get_the_ID(), 'wprss_item_date', true ) );
200
 
201
  // Fallback for feeds created with older versions of the plugin
202
  if ( $source_url === '' ) $source_url = get_post_meta( $feed_source_id, 'wprss_url', true );
94
  $feed_items_args = array(
95
  'post_type' => 'wprss_feed_item',
96
  'posts_per_page' => $posts_per_page,
97
+ 'orderby' => 'date',
 
98
  'order' => 'DESC',
99
  'paged' => $paged,
100
  'suppress_filters' => true
195
  $link_enclosure = get_post_meta( $feed_source_id, 'wprss_enclosure', true );
196
  $source_name = get_the_title( $feed_source_id );
197
  $source_url = get_post_meta( $feed_source_id, 'wprss_site_url', true );
198
+ $timestamp = get_the_time( 'U', get_the_ID() );
199
 
200
  // Fallback for feeds created with older versions of the plugin
201
  if ( $source_url === '' ) $source_url = get_post_meta( $feed_source_id, 'wprss_url', true );
includes/feed-importing.php CHANGED
@@ -397,7 +397,13 @@
397
 
398
  // If the item is not NULL, continue to inserting the feed item post into the DB
399
  if ( $item !== NULL && !is_bool($item) ) {
400
-
 
 
 
 
 
 
401
  $feed_item = apply_filters(
402
  'wprss_populate_post_data',
403
  array(
@@ -405,8 +411,8 @@
405
  'post_content' => '',
406
  'post_status' => 'publish',
407
  'post_type' => 'wprss_feed_item',
408
- 'post_date' => get_date_from_gmt( $item->get_date( 'Y-m-d H:i:s' ) ),
409
- 'post_date_gmt' => $item->get_date( 'Y-m-d H:i:s' ),
410
  ),
411
  $item
412
  );
@@ -466,7 +472,6 @@
466
  function wprss_items_insert_post_meta( $inserted_ID, $item, $feed_ID, $permalink, $enclosure_url ) {
467
  update_post_meta( $inserted_ID, 'wprss_item_permalink', $permalink );
468
  update_post_meta( $inserted_ID, 'wprss_item_enclosure', $enclosure_url );
469
- update_post_meta( $inserted_ID, 'wprss_item_date', $item->get_date( 'U' ) ); // Save as Unix timestamp format
470
 
471
  $author = $item->get_author();
472
  if ( $author ) {
397
 
398
  // If the item is not NULL, continue to inserting the feed item post into the DB
399
  if ( $item !== NULL && !is_bool($item) ) {
400
+ // Get the date and GTM date and normalize if not valid dor not present
401
+ $format = 'Y-m-d H:i:s';
402
+ $has_date = $item->get_date( 'U' ) ? TRUE : FALSE;
403
+ $timestamp = $has_date ? $item->get_date( 'U' ) : date( 'U' );
404
+ $date = date( $format, $timestamp );
405
+ $date_gmt = gmdate( $format, $timestamp );
406
+ // Prepare the item data
407
  $feed_item = apply_filters(
408
  'wprss_populate_post_data',
409
  array(
411
  'post_content' => '',
412
  'post_status' => 'publish',
413
  'post_type' => 'wprss_feed_item',
414
+ 'post_date' => $date,
415
+ 'post_date_gmt' => $date_gmt
416
  ),
417
  $item
418
  );
472
  function wprss_items_insert_post_meta( $inserted_ID, $item, $feed_ID, $permalink, $enclosure_url ) {
473
  update_post_meta( $inserted_ID, 'wprss_item_permalink', $permalink );
474
  update_post_meta( $inserted_ID, 'wprss_item_enclosure', $enclosure_url );
 
475
 
476
  $author = $item->get_author();
477
  if ( $author ) {
includes/feed-processing.php CHANGED
@@ -75,8 +75,7 @@
75
  'cache_results' => false, // Disable caching, used for one-off queries
76
  'no_found_rows' => true, // We don't need pagination, so disable it
77
  'posts_per_page'=> -1,
78
- 'orderby' => 'meta_value',
79
- 'meta_key' => 'wprss_item_date',
80
  'order' => 'DESC',
81
  'meta_query' => array(
82
  array(
@@ -393,7 +392,7 @@
393
  */
394
  function wprss_is_feed_item_older_than( $id, $timestamp ) {
395
  // GET THE DATE
396
- $age = get_post_meta( $id, 'wprss_item_date', TRUE );
397
  if ( $age === '' ) return FALSE;
398
  // Calculate the age difference
399
  $difference = $age - $timestamp;
75
  'cache_results' => false, // Disable caching, used for one-off queries
76
  'no_found_rows' => true, // We don't need pagination, so disable it
77
  'posts_per_page'=> -1,
78
+ 'orderby' => 'date',
 
79
  'order' => 'DESC',
80
  'meta_query' => array(
81
  array(
392
  */
393
  function wprss_is_feed_item_older_than( $id, $timestamp ) {
394
  // GET THE DATE
395
+ $age = get_the_time( 'U', $id );
396
  if ( $age === '' ) return FALSE;
397
  // Calculate the age difference
398
  $difference = $age - $timestamp;
readme.txt CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.wprssaggregator.com
5
  Tags: rss, feeds, aggregation, rss to post, autoblog aggregator, rss import, feed aggregator, rss aggregator, multiple rss feeds, multi rss feeds, rss multi importer, feed import, feed import, multiple feed import, feed aggregation, rss feader, feed reader, feed to post, multiple feeds, multi feed importer, multi feed import, multi import, autoblogging, autoblogger
6
  Requires at least: 3.3
7
  Tested up to: 4.0
8
- Stable tag: 4.5.3
9
  License: GPLv2 or later
10
  The no.1 RSS feed importer for WordPress. Premium add-ons available for more functionality.
11
 
@@ -165,6 +165,12 @@ The full documentation section can be found on the [WP RSS Aggregator website](w
165
 
166
  == Changelog ==
167
 
 
 
 
 
 
 
168
  = 4.5.3 (2014-09-15) =
169
  * New Featured: Added filter to allow adding RSS feeds to the head of your site's pages for CPTs.
170
  * Enhanced: Columns in the feed sources table are now sortable.
5
  Tags: rss, feeds, aggregation, rss to post, autoblog aggregator, rss import, feed aggregator, rss aggregator, multiple rss feeds, multi rss feeds, rss multi importer, feed import, feed import, multiple feed import, feed aggregation, rss feader, feed reader, feed to post, multiple feeds, multi feed importer, multi feed import, multi import, autoblogging, autoblogger
6
  Requires at least: 3.3
7
  Tested up to: 4.0
8
+ Stable tag: 4.6
9
  License: GPLv2 or later
10
  The no.1 RSS feed importer for WordPress. Premium add-ons available for more functionality.
11
 
165
 
166
  == Changelog ==
167
 
168
+ = 4.6 (2014-09-22) =
169
+ * Enhanced: Improved the user interface, with better responsiveness and tooltips.
170
+ * Enhanced: Removes the ID column. The ID is now shown fixed in row actions.
171
+ * Enhanced: Feed Preview indicates if feed items have no dates.
172
+ * Fixed bug: If a feed item has no date, the date and time it was imported is used.
173
+
174
  = 4.5.3 (2014-09-15) =
175
  * New Featured: Added filter to allow adding RSS feeds to the head of your site's pages for CPTs.
176
  * Enhanced: Columns in the feed sources table are now sortable.
templates/help-footer-js.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for WP RSS Aggregator tooltip JavaScript for the footer.
4
+ *
5
+ * @package WPRSSAggregator
6
+ * @author Jean Galea <info@wprssaggregator.com>
7
+ * @copyright Copyright (c) 2012-2014, Jean Galea
8
+ * @link http://www.wprssaggregator.com/
9
+ * @license http://www.gnu.org/licenses/gpl.html
10
+ */
11
+ ?>
12
+ <script type="text/javascript" id="<?php echo WPRSS_Help::get_instance()->prefix('footer-js') ?>">
13
+ (function($, document, window) {
14
+ $(function() {
15
+ var tooltipHandleClass = '<?php echo isset( $vars['tooltip_handle_class'] ) ? $vars['tooltip_handle_class'] : '' ?>';
16
+
17
+ // If class defined
18
+ tooltipHandleClass.length && (function() {
19
+ $('.'+tooltipHandleClass).tooltip({
20
+ items: '*',
21
+ tooltipClass: '<?php echo $vars['tooltip_class'] ?>',
22
+ hide: 100,
23
+ show: 100,
24
+ position: {
25
+ my: 'left+3 top+3',
26
+ at: 'right bottom'
27
+ },
28
+ content: function(){
29
+ var $this = $(this);
30
+ return $($this.attr('href')).html();
31
+ }
32
+ });
33
+
34
+ $('.'+tooltipHandleClass).on('click', function(e) {
35
+ e.preventDefault();
36
+ });
37
+ })();
38
+ });
39
+ })(jQuery, document, top, undefined);
40
+ </script>
templates/help-tooltip-content.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for WP RSS Aggregator tooltip content.
4
+ *
5
+ * @package WPRSSAggregator
6
+ * @author Jean Galea <info@wprssaggregator.com>
7
+ * @copyright Copyright (c) 2012-2014, Jean Galea
8
+ * @link http://www.wprssaggregator.com/
9
+ * @license http://www.gnu.org/licenses/gpl.html
10
+ */
11
+ ?>
12
+ <div class="<?php echo $vars['tooltip_content_class'] ?>" id="<?php echo $vars['tooltip_id_prefix'] . $vars['tooltip_id'] ?>">
13
+ <?php echo isset( $vars['text_domain'] ) ? __( wpautop( $vars['tooltip_text'] ), $vars['text_domain'] ) : $vars['tooltip_text'] ?>
14
+ </div>
templates/help-tooltip-handle.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for WP RSS Aggregator tooltip handle.
4
+ *
5
+ * @package WPRSSAggregator
6
+ * @author Jean Galea <info@wprssaggregator.com>
7
+ * @copyright Copyright (c) 2012-2014, Jean Galea
8
+ * @link http://www.wprssaggregator.com/
9
+ * @license http://www.gnu.org/licenses/gpl.html
10
+ */
11
+ ?>
12
+ <?php /* @var $vars array Contains combined options for this template */ ?>
13
+ <a class="<?php echo $vars['tooltip_handle_class'] ?><?php if( !empty($vars['tooltip_handle_class_extra']) ): ?> <?php echo $vars['tooltip_handle_class_extra'] ?><?php endif ?>" href="#<?php echo $vars['tooltip_id_prefix'] . $vars['tooltip_id'] ?>"><?php echo $vars['tooltip_handle_text'] ?></a>
14
+
wp-rss-aggregator.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP RSS Aggregator
4
  Plugin URI: http://www.wprssaggregator.com
5
  Description: Imports and aggregates multiple RSS Feeds using SimplePie
6
- Version: 4.5.3
7
  Author: Jean Galea
8
  Author URI: http://www.wprssaggregator.com
9
  License: GPLv2
@@ -29,7 +29,7 @@
29
 
30
  /**
31
  * @package WPRSSAggregator
32
- * @version 4.5.3
33
  * @since 1.0
34
  * @author Jean Galea <info@wprssaggregator.com>
35
  * @copyright Copyright (c) 2012-2014, Jean Galea
@@ -43,7 +43,7 @@
43
 
44
  // Set the version number of the plugin.
45
  if( !defined( 'WPRSS_VERSION' ) )
46
- define( 'WPRSS_VERSION', '4.5.3', true );
47
 
48
  // Set the database version number of the plugin.
49
  if( !defined( 'WPRSS_DB_VERSION' ) )
@@ -94,6 +94,10 @@
94
  define( 'WPRSS_SL_STORE_URL', 'http://www.wprssaggregator.com', TRUE );
95
  }
96
 
 
 
 
 
97
  /**
98
  * Load required files.
99
  */
@@ -155,13 +159,19 @@
155
  /* Load the OPML Importer file */
156
  require_once ( WPRSS_INC . 'opml-importer.php' );
157
 
158
- /* Load the system info file */
159
  require_once ( WPRSS_INC . 'admin-debugging.php' );
160
 
161
- /* Load the system info file */
162
- require_once ( WPRSS_INC . 'admin-help.php' );
 
 
 
 
 
 
163
 
164
- /* Load the system info file */
165
  require_once ( WPRSS_INC . 'admin-addons.php' );
166
 
167
  /* Load the admin display-related functions */
3
  Plugin Name: WP RSS Aggregator
4
  Plugin URI: http://www.wprssaggregator.com
5
  Description: Imports and aggregates multiple RSS Feeds using SimplePie
6
+ Version: 4.6
7
  Author: Jean Galea
8
  Author URI: http://www.wprssaggregator.com
9
  License: GPLv2
29
 
30
  /**
31
  * @package WPRSSAggregator
32
+ * @version 4.6
33
  * @since 1.0
34
  * @author Jean Galea <info@wprssaggregator.com>
35
  * @copyright Copyright (c) 2012-2014, Jean Galea
43
 
44
  // Set the version number of the plugin.
45
  if( !defined( 'WPRSS_VERSION' ) )
46
+ define( 'WPRSS_VERSION', '4.6', true );
47
 
48
  // Set the database version number of the plugin.
49
  if( !defined( 'WPRSS_DB_VERSION' ) )
94
  define( 'WPRSS_SL_STORE_URL', 'http://www.wprssaggregator.com', TRUE );
95
  }
96
 
97
+ if ( !defined( 'WPRSS_TEXT_DOMAIN' ) ) {
98
+ define( 'WPRSS_TEXT_DOMAIN', 'wprss' );
99
+ }
100
+
101
  /**
102
  * Load required files.
103
  */
159
  /* Load the OPML Importer file */
160
  require_once ( WPRSS_INC . 'opml-importer.php' );
161
 
162
+ /* Load the admin debugging page file */
163
  require_once ( WPRSS_INC . 'admin-debugging.php' );
164
 
165
+ /* Load the admin help file */
166
+ require_once ( WPRSS_INC . 'admin-help.php' );
167
+
168
+ /* Load the admin metaboxes help file */
169
+ require_once ( WPRSS_INC . 'admin-help-metaboxes.php' );
170
+
171
+ /* Load the admin settings help file */
172
+ require_once ( WPRSS_INC . 'admin-help-settings.php' );
173
 
174
+ /* Load the addons page file */
175
  require_once ( WPRSS_INC . 'admin-addons.php' );
176
 
177
  /* Load the admin display-related functions */