Version Description
(2015-08-19) * Requirement: WordPress 4.0 or greater now required. * Fixed bug in image caching * Fixed bug in admin interface due to incorrectly translated IDs
Download this release
Release Info
Developer | markzahra |
Plugin | WP RSS Aggregator |
Version | 4.7.4 |
Comparing to | |
See all releases |
Code changes from version 4.7.3 to 4.7.4
- css/admin-styles.css +19 -0
- includes/admin-ajax-notice.php +1138 -21
- includes/admin-options.php +6 -6
- includes/feed-display.php +9 -9
- includes/image-caching.php +2 -2
- includes/scripts.php +16 -0
- js/admin-notifications.js +12 -0
- js/admin-notifications.min.js +2 -0
- js/aventura.js +73 -0
- js/aventura.min.js +2 -0
- js/class.js +69 -0
- js/class.min.js +2 -0
- js/xdn.js +251 -0
- js/xdn.min.js +2 -0
- readme.txt +7 -2
- wp-rss-aggregator.php +80 -9
css/admin-styles.css
CHANGED
@@ -614,6 +614,25 @@ body.post-type-wprss_blacklist .alignleft.actions.bulkactions {
|
|
614 |
margin: 0;
|
615 |
}
|
616 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
617 |
/* For non settings page screens */
|
618 |
@media only screen and (max-width: 850px) {
|
619 |
|
614 |
margin: 0;
|
615 |
}
|
616 |
|
617 |
+
|
618 |
+
|
619 |
+
/* Admin Notifications ====================================================== */
|
620 |
+
.wprss_admin-notice {
|
621 |
+
position: relative;
|
622 |
+
}
|
623 |
+
|
624 |
+
.wprss_admin-notice .notice-content {
|
625 |
+
margin-right: 200px;
|
626 |
+
}
|
627 |
+
|
628 |
+
.wprss_admin-notice .btn-close {
|
629 |
+
position: absolute;
|
630 |
+
right: 15px;
|
631 |
+
top: 10px;
|
632 |
+
text-decoration: none;
|
633 |
+
}
|
634 |
+
|
635 |
+
|
636 |
/* For non settings page screens */
|
637 |
@media only screen and (max-width: 850px) {
|
638 |
|
includes/admin-ajax-notice.php
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
/**
|
4 |
* Serves up a notice to leave a review for this plugin
|
5 |
-
*
|
6 |
* @link http://wp.tutsplus.com/tutorials/creative-coding/a-primer-on-ajax-in-the-wordpress-dashboard-requesting-and-responding/
|
7 |
* @link http://wptheming.com/2011/08/admin-notices-in-wordpress/
|
8 |
-
*
|
9 |
* @since 3.0
|
10 |
-
*
|
11 |
*/
|
12 |
|
13 |
add_action( 'admin_notices', 'wprss_display_admin_notice' );
|
14 |
/**
|
15 |
* Renders the administration notice. Also renders a hidden nonce used for security when processing the Ajax request.
|
16 |
-
*
|
17 |
* @since 3.0
|
18 |
*/
|
19 |
function wprss_display_admin_notice() {
|
@@ -37,35 +37,35 @@
|
|
37 |
$html .= '</p>';
|
38 |
$html .= '<span id="ajax-notification-nonce" class="hidden">' . wp_create_nonce( 'ajax-notification-nonce' ) . '</span>';
|
39 |
$html .= '</div>';
|
40 |
-
|
41 |
echo $html;
|
42 |
}
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
add_action( 'wp_ajax_wprss_hide_admin_notification', 'wprss_hide_admin_notification' );
|
47 |
/**
|
48 |
* JavaScript callback used to hide the administration notice when the 'Dismiss' anchor is clicked on the front end.
|
49 |
-
*
|
50 |
* @since 3.0
|
51 |
*/
|
52 |
function wprss_hide_admin_notification() {
|
53 |
-
|
54 |
-
// First, check the nonce to make sure it matches what we created when displaying the message.
|
55 |
// If not, we won't do anything.
|
56 |
if( wp_verify_nonce( $_REQUEST['nonce'], 'ajax-notification-nonce' ) ) {
|
57 |
-
|
58 |
// If the update to the option is successful, send 1 back to the browser;
|
59 |
// Otherwise, send 0.
|
60 |
-
$general_settings = get_option( 'wprss_settings_notices' );
|
61 |
$general_settings = true;
|
62 |
|
63 |
if( update_option( 'wprss_settings_notices', $general_settings ) ) {
|
64 |
die( '1' );
|
65 |
} else {
|
66 |
die( '0' );
|
67 |
-
}
|
68 |
-
}
|
69 |
}
|
70 |
|
71 |
|
@@ -73,7 +73,7 @@
|
|
73 |
/**
|
74 |
* Checks if the addon notices option exists in the database, and creates it
|
75 |
* if it does not.
|
76 |
-
*
|
77 |
* @return The addon notices option
|
78 |
* @since 3.4.2
|
79 |
*/
|
@@ -90,7 +90,7 @@
|
|
90 |
|
91 |
/**
|
92 |
* This function is called through AJAX to dismiss a particular addon notification.
|
93 |
-
*
|
94 |
* @since 3.4.2
|
95 |
*/
|
96 |
function wprss_dismiss_addon_notice() {
|
@@ -125,7 +125,7 @@
|
|
125 |
|
126 |
/**
|
127 |
* AJAX action for the tracking pointer
|
128 |
-
*
|
129 |
* @since 3.6
|
130 |
*/
|
131 |
function wprss_tracking_ajax_opt() {
|
@@ -138,4 +138,1121 @@
|
|
138 |
die();
|
139 |
}
|
140 |
|
141 |
-
add_action( 'wp_ajax_wprss_tracking_ajax_opt', 'wprss_tracking_ajax_opt' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
|
3 |
/**
|
4 |
* Serves up a notice to leave a review for this plugin
|
5 |
+
*
|
6 |
* @link http://wp.tutsplus.com/tutorials/creative-coding/a-primer-on-ajax-in-the-wordpress-dashboard-requesting-and-responding/
|
7 |
* @link http://wptheming.com/2011/08/admin-notices-in-wordpress/
|
8 |
+
*
|
9 |
* @since 3.0
|
10 |
+
*
|
11 |
*/
|
12 |
|
13 |
add_action( 'admin_notices', 'wprss_display_admin_notice' );
|
14 |
/**
|
15 |
* Renders the administration notice. Also renders a hidden nonce used for security when processing the Ajax request.
|
16 |
+
*
|
17 |
* @since 3.0
|
18 |
*/
|
19 |
function wprss_display_admin_notice() {
|
37 |
$html .= '</p>';
|
38 |
$html .= '<span id="ajax-notification-nonce" class="hidden">' . wp_create_nonce( 'ajax-notification-nonce' ) . '</span>';
|
39 |
$html .= '</div>';
|
40 |
+
|
41 |
echo $html;
|
42 |
}
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
add_action( 'wp_ajax_wprss_hide_admin_notification', 'wprss_hide_admin_notification' );
|
47 |
/**
|
48 |
* JavaScript callback used to hide the administration notice when the 'Dismiss' anchor is clicked on the front end.
|
49 |
+
*
|
50 |
* @since 3.0
|
51 |
*/
|
52 |
function wprss_hide_admin_notification() {
|
53 |
+
|
54 |
+
// First, check the nonce to make sure it matches what we created when displaying the message.
|
55 |
// If not, we won't do anything.
|
56 |
if( wp_verify_nonce( $_REQUEST['nonce'], 'ajax-notification-nonce' ) ) {
|
57 |
+
|
58 |
// If the update to the option is successful, send 1 back to the browser;
|
59 |
// Otherwise, send 0.
|
60 |
+
$general_settings = get_option( 'wprss_settings_notices' );
|
61 |
$general_settings = true;
|
62 |
|
63 |
if( update_option( 'wprss_settings_notices', $general_settings ) ) {
|
64 |
die( '1' );
|
65 |
} else {
|
66 |
die( '0' );
|
67 |
+
}
|
68 |
+
}
|
69 |
}
|
70 |
|
71 |
|
73 |
/**
|
74 |
* Checks if the addon notices option exists in the database, and creates it
|
75 |
* if it does not.
|
76 |
+
*
|
77 |
* @return The addon notices option
|
78 |
* @since 3.4.2
|
79 |
*/
|
90 |
|
91 |
/**
|
92 |
* This function is called through AJAX to dismiss a particular addon notification.
|
93 |
+
*
|
94 |
* @since 3.4.2
|
95 |
*/
|
96 |
function wprss_dismiss_addon_notice() {
|
125 |
|
126 |
/**
|
127 |
* AJAX action for the tracking pointer
|
128 |
+
*
|
129 |
* @since 3.6
|
130 |
*/
|
131 |
function wprss_tracking_ajax_opt() {
|
138 |
die();
|
139 |
}
|
140 |
|
141 |
+
add_action( 'wp_ajax_wprss_tracking_ajax_opt', 'wprss_tracking_ajax_opt' );
|
142 |
+
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Responsible for tracking and outputting admin notices
|
146 |
+
*
|
147 |
+
* @since 4.7.4
|
148 |
+
*/
|
149 |
+
class WPRSS_Admin_Notices {
|
150 |
+
|
151 |
+
// How should a set of conditions be evaluated
|
152 |
+
const CONDITION_TYPE_ALL = 'all'; // Requires all conditions to be true
|
153 |
+
const CONDITION_TYPE_ANY = 'any'; // Requires one condition to be true
|
154 |
+
const CONDITION_TYPE_NONE = 'none'; // Requires none of the conditions to be true
|
155 |
+
const CONDITION_TYPE_ALMOST = 'almost'; // Requires at least one of the conditions to be false
|
156 |
+
|
157 |
+
// What happens if a condition encounters an error
|
158 |
+
// const CONDITION_ON_ERROR_STOP_FALSE = 'stop_false'; // Assume that the condition was not satisfied, and do not evaluate other conditions
|
159 |
+
// const CONDITION_ON_ERROR_STOP_TRUE = 'stop_true'; // Assume that the condition was satisfied, and do not evaluate other conditions
|
160 |
+
// const CONDITION_ON_ERROR_CONTINUE_FALSE = 'continue_false'; // Assume that the condition was not satisfied, and continue evaluating
|
161 |
+
// const CONDITION_ON_ERROR_CONTINUE_TRUE = 'continue_true'; // Assume that the condition was satisfied, and continue evaluating
|
162 |
+
const CONDITION_ON_ERROR_THROW_EXCEPTION = 'throw_exception'; // Just halt
|
163 |
+
|
164 |
+
|
165 |
+
protected $_notices = array();
|
166 |
+
protected $_setting_code;
|
167 |
+
protected $_id_prefix;
|
168 |
+
protected $_text_domain;
|
169 |
+
protected $_notice_base_class;
|
170 |
+
protected $_nonce_base_class;
|
171 |
+
protected $_btn_close_base_class;
|
172 |
+
|
173 |
+
|
174 |
+
/**
|
175 |
+
*
|
176 |
+
* @since 4.7.4
|
177 |
+
* @param null|array The settings of this instance.
|
178 |
+
* Possible values are:
|
179 |
+
* - 'setting_code': The code of the database setting used for storing and managing notices of this instance.
|
180 |
+
* See {@link set_setting_code()}.
|
181 |
+
* If a string is passed as data, this is what it is assumed to be.
|
182 |
+
* - 'id_prefix': The prefix of all IDs generated by this instance.
|
183 |
+
* See {@link set_id_prefix()}.
|
184 |
+
* - 'text_domain': The text domain to use for translation.
|
185 |
+
* See {@link set_text_domain()}.
|
186 |
+
* - 'notice_base_class': The class for all notice elements.
|
187 |
+
* See {@link set_notice_base_class()}.
|
188 |
+
* - 'nonce_base_class': The class for all notice nonce elements.
|
189 |
+
* See {@link set_nonce_base_class()}.
|
190 |
+
*/
|
191 |
+
public function __construct( $data = array() ) {
|
192 |
+
if ( is_string( $data ) )
|
193 |
+
$data = array( 'setting_code' => $data );
|
194 |
+
|
195 |
+
if ( isset( $data['setting_code'] ) )
|
196 |
+
$this->set_setting_code ( $data['setting_code'] );
|
197 |
+
|
198 |
+
if ( isset( $data['id_prefix'] ) )
|
199 |
+
$this->set_id_prefix( $data['id_prefix'] );
|
200 |
+
|
201 |
+
if ( isset( $data['text_domain'] ) )
|
202 |
+
$this->set_text_domain( $data['text_domain'] );
|
203 |
+
|
204 |
+
// Common class for all notices
|
205 |
+
if ( !isset( $data['notice_base_class'] ) )
|
206 |
+
$data['notice_base_class'] = $this->prefix( 'admin-notice' );
|
207 |
+
$this->set_notice_base_class( $data['notice_base_class'] );
|
208 |
+
|
209 |
+
// Common class for all nonces
|
210 |
+
if ( !isset( $data['nonce_base_class'] ) )
|
211 |
+
$data['nonce_base_class'] = $this->prefix( 'admin-notice-nonce' );
|
212 |
+
$this->set_nonce_base_class( $data['nonce_base_class'] );
|
213 |
+
|
214 |
+
// Common class for all close buttons
|
215 |
+
if ( !isset( $data['btn_close_base_class'] ) )
|
216 |
+
$data['btn_close_base_class'] = $this->prefix( 'admin-notice-btn-close' );
|
217 |
+
$this->set_btn_close_base_class( $data['btn_close_base_class'] );
|
218 |
+
|
219 |
+
$this->_construct();
|
220 |
+
}
|
221 |
+
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Internal, parameter-less constructor.
|
225 |
+
*
|
226 |
+
* @since 4.7.4
|
227 |
+
*/
|
228 |
+
protected function _construct() {
|
229 |
+
|
230 |
+
}
|
231 |
+
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Initializes the instance for use with WP.
|
235 |
+
*
|
236 |
+
* Essentially, this is what prepares it and hooks the handlers in.
|
237 |
+
*
|
238 |
+
* @since 4.7.4
|
239 |
+
* @uses-action admin_notice_before_init To expose the object before initialization
|
240 |
+
* @uses-action admin_notice_before_init To expose the object after initialization
|
241 |
+
* @return \WPRSS_Admin_Notices This instance.
|
242 |
+
*/
|
243 |
+
public function init() {
|
244 |
+
do_action( $this->prefix( 'admin_notice_before_init' ), $this );
|
245 |
+
add_action( 'admin_notices', array( $this, 'output_allowed_notices' ) );
|
246 |
+
do_action( $this->prefix( 'admin_notice_after_init' ), $this );
|
247 |
+
|
248 |
+
return $this;
|
249 |
+
}
|
250 |
+
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Get the ID prefix, or a prefixed string.
|
254 |
+
*
|
255 |
+
* This function is also used internally by this class to prefix generated
|
256 |
+
* IDs that are specific to this instance.
|
257 |
+
* Currently, this prefix is used in HTML of the notices, and in names
|
258 |
+
* of hooks.
|
259 |
+
*
|
260 |
+
* @param null|string $string The string to prefix.
|
261 |
+
* @return string The prefix, or prefixed string
|
262 |
+
*/
|
263 |
+
public function prefix( $string = null ) {
|
264 |
+
$prefix = (string)$this->_id_prefix;
|
265 |
+
return is_null( $string ) ? $prefix : $prefix . $string;
|
266 |
+
}
|
267 |
+
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Sets a prefix that will be added to IDs specific to this collection.
|
271 |
+
*
|
272 |
+
* @since 4.7.4
|
273 |
+
* @param string $prefix The prefix to set.
|
274 |
+
* @return \WPRSS_Admin_Notices This instance.
|
275 |
+
*/
|
276 |
+
public function set_id_prefix( $prefix ) {
|
277 |
+
$this->_id_prefix = $prefix;
|
278 |
+
return $this;
|
279 |
+
}
|
280 |
+
|
281 |
+
|
282 |
+
/**
|
283 |
+
* Set the name of the setting to store the notices in.
|
284 |
+
*
|
285 |
+
* @since 4.7.4
|
286 |
+
* @see get_setting_name()
|
287 |
+
* @param string $name The name of the notices setting to use.
|
288 |
+
* @return \WPRSS_Admin_Notices This instance.
|
289 |
+
*/
|
290 |
+
public function set_setting_code( $name ) {
|
291 |
+
$this->_setting_code = $name;
|
292 |
+
return $this;
|
293 |
+
}
|
294 |
+
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Get the name of the notices setting.
|
298 |
+
*
|
299 |
+
* @since 4.7.4
|
300 |
+
* @see set_setting_name()
|
301 |
+
* @return string The name of the setting which stores notices and their states.
|
302 |
+
*/
|
303 |
+
public function get_setting_name() {
|
304 |
+
return $this->_setting_code;
|
305 |
+
}
|
306 |
+
|
307 |
+
|
308 |
+
/**
|
309 |
+
* Retrieve the text domain that is used for translation by this instance.
|
310 |
+
*
|
311 |
+
* @since 4.7.4
|
312 |
+
* @return string The text domain.
|
313 |
+
*/
|
314 |
+
public function get_text_domain() {
|
315 |
+
return $this->_text_domain;
|
316 |
+
}
|
317 |
+
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Set the text domain that is used for translation by this instance.
|
321 |
+
*
|
322 |
+
* @since 4.7.4
|
323 |
+
* @param string $text_domain The text domain.
|
324 |
+
* @return \WPRSS_Admin_Notices This instance.
|
325 |
+
*/
|
326 |
+
public function set_text_domain( $text_domain ) {
|
327 |
+
$this->_text_domain = $text_domain;
|
328 |
+
return $this;
|
329 |
+
}
|
330 |
+
|
331 |
+
|
332 |
+
/**
|
333 |
+
* Get the class that is the base, common class for all notices' top HTML elements.
|
334 |
+
*
|
335 |
+
* @since 4.7.4
|
336 |
+
* @uses-filter admin_notice_base_class To modify return value.
|
337 |
+
* @return string The class common to all notices
|
338 |
+
*/
|
339 |
+
public function get_notice_base_class() {
|
340 |
+
return apply_filters( $this->prefix( 'admin_notice_base_class' ), $this->_notice_base_class );
|
341 |
+
}
|
342 |
+
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Set the class that will be the base, common class for all notices' top HTML elements.
|
346 |
+
*
|
347 |
+
* @since 4.7.4
|
348 |
+
* @param string $class The class name that will be common to all notices.
|
349 |
+
* @return \WPRSS_Admin_Notices This instance.
|
350 |
+
*/
|
351 |
+
public function set_notice_base_class( $class ) {
|
352 |
+
$this->_notice_base_class = $class;
|
353 |
+
return $this;
|
354 |
+
}
|
355 |
+
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Get the class that is the base, common class for all notices' nonces' HTML elements.
|
359 |
+
*
|
360 |
+
* @since 4.7.4
|
361 |
+
* @uses-filter admin_notice_nonce_base_class To modify return value.
|
362 |
+
* @return string The class common to all nonces
|
363 |
+
*/
|
364 |
+
public function get_nonce_base_class() {
|
365 |
+
return apply_filters( $this->prefix( 'admin_notice_nonce_base_class' ), $this->_nonce_base_class );
|
366 |
+
}
|
367 |
+
|
368 |
+
|
369 |
+
/**
|
370 |
+
* Set the class that will be the base, common class for all notices' nonces' HTML elements.
|
371 |
+
*
|
372 |
+
* @since 4.7.4
|
373 |
+
* @param string $class The class name that will be common to all nonces.
|
374 |
+
* @return \WPRSS_Admin_Notices This instance.
|
375 |
+
*/
|
376 |
+
public function set_nonce_base_class( $class ) {
|
377 |
+
$this->_nonce_base_class = $class;
|
378 |
+
return $this;
|
379 |
+
}
|
380 |
+
|
381 |
+
|
382 |
+
/**
|
383 |
+
* Get the class that is the base, common class for all notices' close buttons' HTML elements.
|
384 |
+
*
|
385 |
+
* @since 4.7.4
|
386 |
+
* @uses-filter admin_notice_btn_close_base_class To modify return value.
|
387 |
+
* @return string The class common to all close buttons
|
388 |
+
*/
|
389 |
+
public function get_btn_close_base_class() {
|
390 |
+
return apply_filters( $this->prefix( 'admin_notice_btn_close_base_class' ), $this->_btn_close_base_class );
|
391 |
+
}
|
392 |
+
|
393 |
+
|
394 |
+
/**
|
395 |
+
* Set the class that will be the base, common class for all notices' close buttons' HTML elements.
|
396 |
+
*
|
397 |
+
* @since 4.7.4
|
398 |
+
* @param string $class The class name that will be common to close buttons.
|
399 |
+
* @return \WPRSS_Admin_Notices This instance.
|
400 |
+
*/
|
401 |
+
public function set_btn_close_base_class( $class ) {
|
402 |
+
$this->_btn_close_base_class = $class;
|
403 |
+
return $this;
|
404 |
+
}
|
405 |
+
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Adds an admin notice.
|
409 |
+
*
|
410 |
+
* - If 'id' is not passed, a unique ID will be auto-generated.
|
411 |
+
* - If 'nonce' is not passed, a nonce will be auto-generated based on the ID.
|
412 |
+
* - A 'condition' is one or more callbacks. If none are passed, the notice will be displayed on all admin pages.
|
413 |
+
* - A 'condition_type' is one of the CONDITION_TYPE_* class constants. By default, all conditions have to be true.
|
414 |
+
* - The 'class' index determinces what type of notice it is. Currently, the valid values are 'updated', 'error' and 'update-nag'. See https://codex.wordpress.org/Plugin_API/Action_Reference/admin_notices
|
415 |
+
* - The 'content index is the literal content of the notice.
|
416 |
+
* - If 'btn_close_id' is not passed, it will be auto-generated based on the ID.
|
417 |
+
* - The 'btn_close_class' index determines the class that the close button will have, in addition to the default 'btn-close'.
|
418 |
+
* - The 'btn_close_content' index determines the literal content of the element of the close button. HTML allowed.
|
419 |
+
*
|
420 |
+
* @since 4.7.4
|
421 |
+
* @uses-filter admin_notice_add_before_normalize To allow pre-normalization modification of notice.
|
422 |
+
* @uses-filter admin_notice_add_before To allow post-normalization modification of notice.
|
423 |
+
* @uses-action admin_notice_add_after To expose data of added notice. This will not be fired if notice was not added.
|
424 |
+
* @param array $notice Data of the notice to add.
|
425 |
+
* @return \WPRSS_Admin_Notices This instance.
|
426 |
+
*/
|
427 |
+
public function add_notice( $notice ) {
|
428 |
+
$notice = apply_filters( $this->prefix( 'admin_notice_add_before_normalize' ), $notice, $this );
|
429 |
+
$notice = $this->normalize_notice_data( $notice );
|
430 |
+
$notice = apply_filters( $this->prefix( 'admin_notice_add_before' ), $notice, $this );
|
431 |
+
$this->set_notice( $notice );
|
432 |
+
do_action( $this->prefix( 'admin_notice_add_after' ), $notice, $this );
|
433 |
+
|
434 |
+
return $this;
|
435 |
+
}
|
436 |
+
|
437 |
+
|
438 |
+
/**
|
439 |
+
* Sets the data for a notice with the specified ID.
|
440 |
+
*
|
441 |
+
* No normalization or checks are made, except for the presence of an ID.
|
442 |
+
*
|
443 |
+
* @since 4.7.4
|
444 |
+
* @uses-filter admin_notice_set_before To alter the data of the notice before setting.
|
445 |
+
* @uses-action admin_notice_set_after To expose the data of the notice after setting.
|
446 |
+
* @param array $notice Data of the notice.
|
447 |
+
* @param null|string $id The ID of the notice. If set, overrides 'id' index in notice data.
|
448 |
+
* @return \WPRSS_Admin_Notices This instance.
|
449 |
+
* @throws Exception If ID is missing.
|
450 |
+
*/
|
451 |
+
public function set_notice( $notice, $id = null ) {
|
452 |
+
$notice = apply_filters( $this->prefix( 'admin_notice_set_before' ), $notice, $id, $this );
|
453 |
+
$id = isset( $notice['id'] ) ? $notice['id'] : $id;
|
454 |
+
if ( is_null( $id ) )
|
455 |
+
throw new Exception( 'Could not set admin notice: ID must be specified in either notice data, or as separate argument' );
|
456 |
+
|
457 |
+
$this->_notices[ $id ] = $notice;
|
458 |
+
do_action( $this->prefix( 'admin_notice_set_after' ), $notice, $id, $this );
|
459 |
+
return $this;
|
460 |
+
}
|
461 |
+
|
462 |
+
|
463 |
+
/**
|
464 |
+
* Normalize data of a notice, adding defaults.
|
465 |
+
*
|
466 |
+
* Auto-generating 'id', 'nonce', 'btn_close_id', 'nonce_element_id', 'btn_close_id'.
|
467 |
+
*
|
468 |
+
* @since 4.7.4
|
469 |
+
* @uses-filter admin_notice_defaults Default values, before addin auto-generated values.
|
470 |
+
* @uses-filter admin_notice_defaults_autogenerated Default values, after adding auto-generated values.
|
471 |
+
* @param array $data The notice data to normalize
|
472 |
+
* @return array $data The normalized data of a notice
|
473 |
+
*/
|
474 |
+
public function normalize_notice_data( $data ) {
|
475 |
+
$data = wp_parse_args( $data, apply_filters( $this->prefix( 'admin_notice_defaults' ), array(
|
476 |
+
'id' => null, // ID of the notice. Unique for the notice in this collection.
|
477 |
+
'nonce' => null, // Nonce for the notice. Prevents unauthorised manipulation.
|
478 |
+
'condition' => array(), // These callbacks will decide whether or not the nonce is to be displayed
|
479 |
+
'condition_type' => self::CONDITION_TYPE_ALL, // Which of the conditions have to be satisfied
|
480 |
+
'conditon_on_error' => self::CONDITION_ON_ERROR_THROW_EXCEPTION,
|
481 |
+
'is_active' => true, // Whether this notice should be assumed to be active, unless set otherwise
|
482 |
+
'nonce_element_class' => $this->prefix( 'admin-notice-nonce' ), // HTML class for the element that contains the nonce
|
483 |
+
'nonce_element_id' => null,
|
484 |
+
'class' => '', // HTML class for the element of the notice
|
485 |
+
'notice_type' => 'updated', // Type of the notice.
|
486 |
+
'notice_element_class' => $this->prefix( 'admin-notice' ),
|
487 |
+
'content' => '', // The content of this notice
|
488 |
+
'btn_close_id' => null, // The HTML ID for the close button
|
489 |
+
'btn_close_class' => 'btn-close', // The HTML class for the close button, in addition to default
|
490 |
+
'btn_close_content' => __( 'Dismiss this notification', $this->get_text_domain() ), // The content of the close button. HTML allowed.
|
491 |
+
)));
|
492 |
+
|
493 |
+
// Auto-generate ID
|
494 |
+
if ( is_null( $data['id'] ) )
|
495 |
+
$data['id'] = $this->generate_unique_id( 'admin-notice-' );
|
496 |
+
|
497 |
+
// Prefix ID
|
498 |
+
$data['id'] = $this->prefix( $data['id'] );
|
499 |
+
|
500 |
+
// Auto-generate nonce
|
501 |
+
if ( is_null( $data['nonce'] ) && !is_null( $data['id'] ) ) {
|
502 |
+
$data['nonce'] = $this->generate_nonce_for_notice( $data['id'] );
|
503 |
+
}
|
504 |
+
|
505 |
+
// Auto-generate nonce element ID
|
506 |
+
if ( is_null( $data['nonce_element_id'] ) && !is_null( $data['id'] ) )
|
507 |
+
$data['nonce_element_id'] = sprintf( '%1$s-nonce', $data['id'] );
|
508 |
+
|
509 |
+
// Auto-generate close button ID
|
510 |
+
if ( is_null( $data['btn_close_id'] ) && !is_null( $data['id'] ) )
|
511 |
+
$data['btn_close_id'] = sprintf( 'close-%1$s', $data['id'] );
|
512 |
+
|
513 |
+
return apply_filters( $this->prefix( 'admin_notice_defaults_autogenerated' ), $data );
|
514 |
+
}
|
515 |
+
|
516 |
+
|
517 |
+
/**
|
518 |
+
* Removes a notice from this collection.
|
519 |
+
*
|
520 |
+
* @since 4.7.4
|
521 |
+
* @uses-filter admin_notice_remove_before To modify the notice ID that will be removed. Returning falsy value prevents removal.
|
522 |
+
* @uses-action admin_notice_remove_before To expose notice ID after removal.
|
523 |
+
* @param array|int $notice A notice, or notice ID.
|
524 |
+
* @return \WPRSS_Admin_Notices This instance.
|
525 |
+
*/
|
526 |
+
public function remove_notice( $notice ) {
|
527 |
+
if ( is_array( $notice ) )
|
528 |
+
$notice = isset( $notice['id'] ) ? $notice['id'] : null;
|
529 |
+
|
530 |
+
if ( is_null( $notice ) )
|
531 |
+
return $this;
|
532 |
+
|
533 |
+
if ( !$this->has_notice( $notice ) )
|
534 |
+
return $this;
|
535 |
+
|
536 |
+
$notice = apply_filters( $this->prefix( 'admin_notice_remove_before' ), $notice, $this );
|
537 |
+
if( !$notice ) return $this;
|
538 |
+
|
539 |
+
$this->_remove_notice ( $notice, $this->_notices);
|
540 |
+
do_action( $this->prefix( 'admin_notice_remove_before' ), $notice, $this );
|
541 |
+
|
542 |
+
return $this;
|
543 |
+
}
|
544 |
+
|
545 |
+
|
546 |
+
/**
|
547 |
+
* Removes a notice by ID from the supplied array.
|
548 |
+
*
|
549 |
+
* @since 4.7.4
|
550 |
+
* @uses-filter admin_notice_internal_remove_before To modify notice before removal. Returning falsy value prevents removal.
|
551 |
+
* @uses-action admin_notice_internal_remove_after To expose data of notice after removal.
|
552 |
+
* @param array|string $notice A notice, or notice ID
|
553 |
+
* @param array $array The array, from which to remove the notice.
|
554 |
+
* @return \WPRSS_Admin_Notices This instance.
|
555 |
+
* @throws Exception If no ID specified.
|
556 |
+
*/
|
557 |
+
protected function _remove_notice( $notice, &$array = null ) {
|
558 |
+
if ( is_array( $notice ) )
|
559 |
+
$notice = isset( $notice['id'] ) ? $notice['id'] : null;
|
560 |
+
|
561 |
+
if ( is_null( $notice ) )
|
562 |
+
throw new Exception( 'Could not remove notice: an ID must be specified' );
|
563 |
+
|
564 |
+
if ( is_null( $array ) )
|
565 |
+
$array = &$this->_notices;
|
566 |
+
|
567 |
+
if ( !array_key_exists( $notice, $array ) )
|
568 |
+
return $this;
|
569 |
+
|
570 |
+
$notice = apply_filters( $this->prefix( 'admin_notice_internal_remove_before' ), $notice, $array, $this );
|
571 |
+
if ( !$notice ) return $this;
|
572 |
+
|
573 |
+
unset( $array[ $notice ] );
|
574 |
+
do_action( $this->prefix( 'admin_notice_internal_remove_after' ), $notice, $array, $this );
|
575 |
+
|
576 |
+
return $this;
|
577 |
+
}
|
578 |
+
|
579 |
+
|
580 |
+
/**
|
581 |
+
* Checks whether a notice already exists.
|
582 |
+
*
|
583 |
+
* @since 4.7.4
|
584 |
+
* @param array|int $notice A notice, or notice ID to check for.
|
585 |
+
* @return boolean True if notice already exists; false otherwise.
|
586 |
+
*/
|
587 |
+
public function has_notice( $notice ) {
|
588 |
+
if ( is_array( $notice ) )
|
589 |
+
$notice = isset( $notice['id'] ) ? $notice['id'] : null;
|
590 |
+
|
591 |
+
return array_key_exists( $notice , $this->_notices );
|
592 |
+
}
|
593 |
+
|
594 |
+
|
595 |
+
/**
|
596 |
+
* Get all notices, or a notice with the specified ID.
|
597 |
+
*
|
598 |
+
* @since 4.7.4
|
599 |
+
* @uses-filter admin_notice_get_all To modify all notices returned.
|
600 |
+
* @uses-filter admin_notice_get To modify single returned notice.
|
601 |
+
* @param null|string $id The ID of a notice to retrieve.
|
602 |
+
* @param null $default What to return if notice not found.
|
603 |
+
* @return array Retrieve all or one notice. See {@link normalize_notice_data()} for data keys.
|
604 |
+
*/
|
605 |
+
public function get_notices( $id = null, $default = null ) {
|
606 |
+
if ( is_null( $id ) )
|
607 |
+
return apply_filters( $this->prefix( 'admin_notice_get_all' ), $this->_notices, $this );
|
608 |
+
|
609 |
+
return apply_filters( $this->prefix( 'admin_notice_get' ),
|
610 |
+
isset( $this->_notices[ $id ] ) ? $this->_notices[ $id ] : $default,
|
611 |
+
$id,
|
612 |
+
$default,
|
613 |
+
$this );
|
614 |
+
}
|
615 |
+
|
616 |
+
|
617 |
+
/**
|
618 |
+
* Get all notices that are active.
|
619 |
+
*
|
620 |
+
* @since 4.7.4
|
621 |
+
* @see is_notice_active()
|
622 |
+
* @return array Notices that are currently active;
|
623 |
+
*/
|
624 |
+
public function get_active_notices( $is_default_active = null ) {
|
625 |
+
if ( is_null( $is_default_active ) )
|
626 |
+
$is_default_active = true;
|
627 |
+
|
628 |
+
$active_notices = array();
|
629 |
+
foreach ( $this->get_notices() as $_id => $_notice ) {
|
630 |
+
if ( $this->is_notice_active( $_notice, $is_default_active ) )
|
631 |
+
$active_notices[ $_id ] = $_notice;
|
632 |
+
}
|
633 |
+
|
634 |
+
return $active_notices;
|
635 |
+
}
|
636 |
+
|
637 |
+
|
638 |
+
/**
|
639 |
+
* Determine whether the specified notice is active.
|
640 |
+
*
|
641 |
+
* If data array is passed, it's 'is_active' key will be used as default.
|
642 |
+
* Otherwise, data will be retrieved by ID and compared to database.
|
643 |
+
*
|
644 |
+
* @since 4.7.4
|
645 |
+
* @uses-filter admin_notice_is_active To modify return value. Used in several places.
|
646 |
+
* @param array|string $notice Notice or notice ID.
|
647 |
+
* @param boolean $default What to return if no notice state data exists.
|
648 |
+
* @return boolean Whether or not the specified notice is active.
|
649 |
+
* @throws Exception If ID not specified.
|
650 |
+
*/
|
651 |
+
public function is_notice_active( $notice, $default = null ) {
|
652 |
+
// State if no state provided
|
653 |
+
if ( is_null( $default ) )
|
654 |
+
$default = true;
|
655 |
+
|
656 |
+
// If ID passed, retrieve the notice
|
657 |
+
if ( !is_array( $notice ) )
|
658 |
+
$notice = $this->get_notices( $notice, array() );
|
659 |
+
// Last resort defaults
|
660 |
+
$id = isset( $notice['id'] ) ? $notice['id'] : null;
|
661 |
+
$is_active_default = isset( $notice['is_active'] ) ? (bool)$notice['is_active'] : $default;
|
662 |
+
|
663 |
+
if ( is_null( $id ) )
|
664 |
+
throw new Exception( 'Could not determine notice state: ID must be specified' );
|
665 |
+
|
666 |
+
// Settings from DB
|
667 |
+
$settings = $this->get_notices_settings( $id );
|
668 |
+
|
669 |
+
// If no state, assume default
|
670 |
+
if ( !isset( $settings['is_active'] ) )
|
671 |
+
return apply_filters( $this->prefix( 'admin_notice_is_active' ), $is_active_default, $id, $this );
|
672 |
+
|
673 |
+
return apply_filters( $this->prefix( 'admin_notice_is_active' ), (bool)$settings['is_active'], $id, $this );
|
674 |
+
}
|
675 |
+
|
676 |
+
|
677 |
+
/**
|
678 |
+
* Set notice active state.
|
679 |
+
*
|
680 |
+
* @since 4.7.4
|
681 |
+
* @param array|string $notice Notice data or ID.
|
682 |
+
* @param null|boolean $is_active If true, notice state will be set to active; if false - to inactive. Default: true.
|
683 |
+
*/
|
684 |
+
public function set_notice_active( $notice, $is_active = null ) {
|
685 |
+
if ( is_null( $is_active ) )
|
686 |
+
$is_active = true;
|
687 |
+
|
688 |
+
$this->set_notices_settings( $notice, (bool)$is_active );
|
689 |
+
return $this;
|
690 |
+
}
|
691 |
+
|
692 |
+
|
693 |
+
/**
|
694 |
+
* Gets all notices that pass their conditions according to the condition type.
|
695 |
+
*
|
696 |
+
* Allowed notices are also only active ones. Inactive notices are not evaluated.
|
697 |
+
*
|
698 |
+
* @since 4.7.4
|
699 |
+
* @see is_notice_allowed()
|
700 |
+
* @uses-filter admin_notice_all_allowed To modify return value.
|
701 |
+
* @return array Allowed notices.
|
702 |
+
*/
|
703 |
+
public function get_allowed_notices() {
|
704 |
+
$allowed_notices = array();
|
705 |
+
foreach ( $this->get_active_notices() as $_id => $_notice ) {
|
706 |
+
if ( $this->is_notice_allowed( $_notice) )
|
707 |
+
$allowed_notices[ $_id ] = $_notice;
|
708 |
+
}
|
709 |
+
|
710 |
+
return apply_filters( $this->prefix( 'admin_notice_all_allowed' ), $allowed_notices, $this );
|
711 |
+
}
|
712 |
+
|
713 |
+
|
714 |
+
/**
|
715 |
+
* Checks if the specified notice is allowed.
|
716 |
+
*
|
717 |
+
* To determine that, the notice's conditions are evaluated according
|
718 |
+
* to the condition type.
|
719 |
+
*
|
720 |
+
* @since 4.7.4
|
721 |
+
* @uses-filter admin_notice_is_allowed To modify return value.
|
722 |
+
* @param array|string $notice Notice or notice ID.
|
723 |
+
* @return bool Whether or not the specified notice passed it's conditions to be allowed.
|
724 |
+
* @throws Exception If ID not specified.
|
725 |
+
*/
|
726 |
+
public function is_notice_allowed( $notice ) {
|
727 |
+
if ( !is_array( $notice ) )
|
728 |
+
$notice = $this->get_notices( $notice );
|
729 |
+
|
730 |
+
$conditions = isset( $notice['condition'] ) ? $notice['condition'] : array();
|
731 |
+
$condition_type = isset( $notice['condition_type'] ) ? $notice['condition_type'] : self::CONDITION_TYPE_ALL;
|
732 |
+
$is_allowed = $this->evaluate_conditions( $conditions, $condition_type, array( $notice ) );
|
733 |
+
return apply_filters( $this->prefix( 'admin_notice_is_allowed' ), $is_allowed, $notice );
|
734 |
+
}
|
735 |
+
|
736 |
+
|
737 |
+
/**
|
738 |
+
* Generates a nonce for a notice ID.
|
739 |
+
*
|
740 |
+
* @since 4.7.4
|
741 |
+
* @see wp_create_nonce()
|
742 |
+
* @see generate_nonce_code()
|
743 |
+
* @uses-filter admin_notice_nonce_for_notice
|
744 |
+
* @param array|string $notice Notice or notice ID.
|
745 |
+
* @return string The nonce.
|
746 |
+
* @throws Exception If ID not specified.
|
747 |
+
*/
|
748 |
+
public function generate_nonce_for_notice( $notice ) {
|
749 |
+
if ( is_array( $notice ) )
|
750 |
+
$notice = isset( $notice['id'] ) ? $notice['id'] : null;
|
751 |
+
|
752 |
+
if ( is_null( $notice ) )
|
753 |
+
throw new Exception( 'Could not get nonce for notice: notice ID must be specified' );
|
754 |
+
|
755 |
+
$nonce_code = $this->generate_nonce_code( $notice );
|
756 |
+
$nonce = wp_create_nonce( $nonce_code );
|
757 |
+
|
758 |
+
return apply_filters( $this->prefix( 'admin_notice_nonce_for_notice' ), $nonce, $notice, $nonce_code, $this );
|
759 |
+
}
|
760 |
+
|
761 |
+
|
762 |
+
/**
|
763 |
+
* Generates a code that is used to generate a nonce for a notice.
|
764 |
+
*
|
765 |
+
* @since 4.7.4
|
766 |
+
* @see wp_create_nonce()
|
767 |
+
* @see generate_nonce_for_notice()
|
768 |
+
* @uses-filter admin_notice_nonce_code To modify return value.
|
769 |
+
* @param array|string $notice Notice or notice ID;
|
770 |
+
* @return string Code (action) for the nonce.
|
771 |
+
* @throws Exception If nonce ID not specified.
|
772 |
+
*/
|
773 |
+
public function generate_nonce_code( $notice ) {
|
774 |
+
if ( is_array( $notice ) )
|
775 |
+
$notice = isset( $notice['id'] ) ? $notice['id'] : null;
|
776 |
+
|
777 |
+
if ( is_null( $notice ) )
|
778 |
+
throw new Exception( 'Could not generate nonce code for notice: notice ID must be specified' );
|
779 |
+
|
780 |
+
return apply_filters( $this->prefix( 'admin_notice_nonce_code' ), sprintf( '%1$s-nonce', $notice ), $notice, $this );
|
781 |
+
}
|
782 |
+
|
783 |
+
|
784 |
+
/**
|
785 |
+
* Evaluates a condition or group of conditions based on the condition type.
|
786 |
+
*
|
787 |
+
* A condition is a callable that returns true or false (no type checking is done here).
|
788 |
+
*
|
789 |
+
* @since 4.7.4
|
790 |
+
* @uses-filter admin_notice_conditions_evaluated To modify the return value.
|
791 |
+
* @uses-filter admin_notice_condition_result To alter the result of each condition's evaluated.
|
792 |
+
* @param array|callable $conditions A callable or an array of callables.
|
793 |
+
* @param string $condition_type One of the CONDITION_TYPE_* class constants. Default: CONDITION_TYPE_ALL.
|
794 |
+
* @param array $args These args will be passed to the condition callable.
|
795 |
+
* @return boolean Whether or not the conditions evaluate according to the condition type.
|
796 |
+
* @throws Exception If a condition cannot be called.
|
797 |
+
*/
|
798 |
+
public function evaluate_conditions( $conditions, $condition_type = self::CONDITION_TYPE_ALL, $args = array() ) {
|
799 |
+
$event_name = $this->prefix( 'admin_notice_conditions_evaluated' );
|
800 |
+
if ( empty( $conditions ) ) return apply_filters ( $event_name, true, $condition_type, $this ); // Unconditional ;)
|
801 |
+
if ( !is_array( $conditions ) ) $conditions = (array)$conditions; // Normalizing
|
802 |
+
|
803 |
+
foreach ( $conditions as $_idx => $_condition ) {
|
804 |
+
$func = is_array( $_condition ) && isset( $_condition['func'] )
|
805 |
+
? $_condition['func']
|
806 |
+
: $_condition;
|
807 |
+
$args = array_merge( // Appending our args to the passed args
|
808 |
+
array_values( isset( $_condition['args'] ) ? (array)$_condition['args'] : array() ),
|
809 |
+
array_values( $args ));
|
810 |
+
|
811 |
+
if ( !is_callable( $func ) )
|
812 |
+
throw new Exception ( sprintf( 'Could not evaluate condition %1$d: condition must contain a callable', $_idx ) );
|
813 |
+
|
814 |
+
$_value = call_user_func_array( $func, $args );
|
815 |
+
$_value = apply_filters( $this->prefix( 'admin_notice_condition_result' ), $_value, $_idx, $condition_type, $_condition, $args, $this );
|
816 |
+
switch ( $condition_type ) {
|
817 |
+
case self::CONDITION_TYPE_ANY: // At least one must be true
|
818 |
+
if ( (bool)$_value ) return apply_filters ( $event_name, true, $condition_type, $this );
|
819 |
+
$result = false;
|
820 |
+
break;
|
821 |
+
|
822 |
+
case self::CONDITION_TYPE_ALMOST: // At least one must be false
|
823 |
+
if ( !(bool)$_value ) return apply_filters ( $event_name, true, $condition_type, $this );
|
824 |
+
$result = false;
|
825 |
+
break;
|
826 |
+
|
827 |
+
case self::CONDITION_TYPE_NONE: // All must be false
|
828 |
+
if ( (bool)$_value ) return apply_filters ( $event_name, false, $condition_type, $this );
|
829 |
+
$result = true;
|
830 |
+
break;
|
831 |
+
|
832 |
+
default:
|
833 |
+
case self::CONDITION_TYPE_ALL: // All must be true
|
834 |
+
if ( !(bool)$_value ) return apply_filters ( $event_name, false, $condition_type, $this );
|
835 |
+
$result = true;
|
836 |
+
break;
|
837 |
+
}
|
838 |
+
}
|
839 |
+
|
840 |
+
return apply_filters ( $event_name, $result, $condition_type, $this );
|
841 |
+
}
|
842 |
+
|
843 |
+
|
844 |
+
/**
|
845 |
+
* Get settings for all notices, or just one.
|
846 |
+
*
|
847 |
+
* It appears that options are already being cached by WP.
|
848 |
+
* Also, some notices in the returned array may not be registered for display,
|
849 |
+
* in which case they will not be displayed. And vice-versa: some of the registered
|
850 |
+
* notices will not have any settings associated with them, in which case
|
851 |
+
* defaults are assumed. See {@link is_notice_active()} for information.
|
852 |
+
* The settings contain states, not notice information.
|
853 |
+
*
|
854 |
+
* @since 4.7.4
|
855 |
+
* @uses-filter admin_notice_get_notices_settings_all To modify settings of all notices.
|
856 |
+
* @uses-filter admin_notice_get_notices_settings To modify settings of just one notice. May have been modified by admin_notice_get_notices_settings_all.
|
857 |
+
* @param null|string $id Notice ID
|
858 |
+
* @param null|mixed $default What to return if no settings for notice. Default: empty array.
|
859 |
+
* @return array An array, where key is notice ID, and value is boolean indicating whether or not it is active.
|
860 |
+
*/
|
861 |
+
public function get_notices_settings( $id = null, $default = null ) {
|
862 |
+
if( is_null( $default ) )
|
863 |
+
$default = array();
|
864 |
+
|
865 |
+
$settings = apply_filters( $this->prefix( 'admin_notice_get_notices_settings_all' ),
|
866 |
+
get_option( $this->get_setting_name(), array() ),
|
867 |
+
$this );
|
868 |
+
|
869 |
+
if ( is_null( $id ) )
|
870 |
+
return $settings;
|
871 |
+
|
872 |
+
// Normalize
|
873 |
+
$settings = isset( $settings[ $id ] ) ? $settings[ $id ] : $default;
|
874 |
+
$settings = $this->normalize_notice_data_from_db( $settings );
|
875 |
+
|
876 |
+
return apply_filters( $this->prefix( 'admin_notice_get_notices_settings' ),
|
877 |
+
$settings,
|
878 |
+
$id,
|
879 |
+
$default,
|
880 |
+
$this );
|
881 |
+
}
|
882 |
+
|
883 |
+
|
884 |
+
/**
|
885 |
+
*
|
886 |
+
*
|
887 |
+
* @since 4.7.4
|
888 |
+
* @uses-filter admin_notice_set_settings_before To modify what gets saved. Also see {@link prepare_notice_data_for_db()}.
|
889 |
+
* @uses-action admin_notice_set_settings_after To expose data that has been saved.
|
890 |
+
* @param string|array $notice The notice data, or notice ID, to save.
|
891 |
+
* @param null|array|boolean $settings The settings, or just the active state, to save.
|
892 |
+
* @return \WPRSS_Admin_Notices This instance.
|
893 |
+
* @throws Exception If an ID is nowhere to be found. How to save? :S
|
894 |
+
*/
|
895 |
+
public function set_notices_settings( $notice, $settings = null ) {
|
896 |
+
// Normalizing notice data
|
897 |
+
if ( !is_array( $notice ) )
|
898 |
+
$notice = array( 'id' => $notice );
|
899 |
+
// If using just the notice data to save everything
|
900 |
+
if ( is_null( $settings ) )
|
901 |
+
$settings = $notice;
|
902 |
+
// If saving just the active state
|
903 |
+
if ( is_bool( $settings ) )
|
904 |
+
$settings = array( 'is_active' => $settings );
|
905 |
+
|
906 |
+
// Making sure notice ID isn't overwritten
|
907 |
+
if( isset( $settings['id'] ) )
|
908 |
+
unset( $settings['id'] );
|
909 |
+
|
910 |
+
// Merging the data together to get all data to save
|
911 |
+
$settings = wp_parse_args( $settings, $notice );
|
912 |
+
|
913 |
+
// Making sure that an ID ultimately exists
|
914 |
+
if ( !isset( $settings['id'] ) )
|
915 |
+
throw new Exception( 'Could not set notice settings: ID must be specified' );
|
916 |
+
|
917 |
+
$id = $settings['id'];
|
918 |
+
$db_settings = $this->get_notices_settings( $id );
|
919 |
+
|
920 |
+
// Merge again to only update what is in the database
|
921 |
+
$settings = wp_parse_args( $settings, $db_settings );
|
922 |
+
|
923 |
+
// Get all settings data
|
924 |
+
$all_settings = $this->get_notices_settings();
|
925 |
+
// Set and finally save
|
926 |
+
$settings = apply_filters( $this->prefix( 'admin_notice_set_settings_before' ), $settings, $id, $this );
|
927 |
+
$settings = $this->prepare_notice_data_for_db( $settings );
|
928 |
+
$all_settings[ $id ] = $settings;
|
929 |
+
$this->set_notices_settings_all( $all_settings );
|
930 |
+
do_action( $this->prefix( 'admin_notice_set_settings_after' ), $settings, $id, $this );
|
931 |
+
|
932 |
+
return $this;
|
933 |
+
}
|
934 |
+
|
935 |
+
|
936 |
+
/**
|
937 |
+
* Saves the data of all specified notices to the database.
|
938 |
+
*
|
939 |
+
* The passed data will replace all data currently stored in the option.
|
940 |
+
*
|
941 |
+
* @since 4.7.4
|
942 |
+
* @see get_setting_name()
|
943 |
+
* @uses-filter admin_notice_set_settings_all_before To modify what gets saved.
|
944 |
+
* @uses-action admin_notice_set_settings_all_after To expose saved data.
|
945 |
+
* @param array $settings An array containing data of all notices.
|
946 |
+
* @return \WPRSS_Admin_Notices This instance.
|
947 |
+
*/
|
948 |
+
public function set_notices_settings_all( $settings ) {
|
949 |
+
$settings = apply_filters( $this->prefix( 'admin_notice_set_settings_all_before' ), $settings, $this );
|
950 |
+
update_option( $this->get_setting_name(), $settings );
|
951 |
+
do_action( $this->prefix( 'admin_notice_set_settings_all_after' ), $settings, $this );
|
952 |
+
|
953 |
+
return $this;
|
954 |
+
}
|
955 |
+
|
956 |
+
|
957 |
+
/**
|
958 |
+
* Normalize a single notice's data that was returned from the database.
|
959 |
+
*
|
960 |
+
* @since[*next-version*]
|
961 |
+
* @uses-filter admin_notice_normalize_notice_data_from_db To modify the return value.
|
962 |
+
* @param null|mixed|array $data The individual notice's data to normalize.
|
963 |
+
* @return array The notice data returned from the database.
|
964 |
+
*/
|
965 |
+
public function normalize_notice_data_from_db( $data ) {
|
966 |
+
if ( is_null( $data ) )
|
967 |
+
$data = array();
|
968 |
+
|
969 |
+
if ( !is_array( $data ) )
|
970 |
+
$data = array( 'is_active' => (bool)$data );
|
971 |
+
|
972 |
+
return apply_filters( $this->prefix( 'admin_notice_normalize_notice_data_from_db' ), $data, $this );
|
973 |
+
}
|
974 |
+
|
975 |
+
|
976 |
+
/**
|
977 |
+
* Prepares data of a single notice to be saved to the database.
|
978 |
+
*
|
979 |
+
* Is responsible for preserving only allowed fields, and adding some
|
980 |
+
* required ones, if necessary and possible.
|
981 |
+
*
|
982 |
+
* @since[*next-version*]
|
983 |
+
* @uses-filter admin_notice_prepare_notice_data_for_db To modify the resulting prepared data.
|
984 |
+
* @param array $data The data to prepare.
|
985 |
+
* @return array The data that should be saved to the database.
|
986 |
+
*/
|
987 |
+
public function prepare_notice_data_for_db( $data ) {
|
988 |
+
$prepared_data = array();
|
989 |
+
if ( isset( $data['is_active'] ) )
|
990 |
+
$prepared_data['is_active'] = (bool)$data['is_active'];
|
991 |
+
|
992 |
+
return apply_filters( $this->prefix( 'admin_notice_prepare_notice_data_for_db' ), $prepared_data, $data, $this );
|
993 |
+
}
|
994 |
+
|
995 |
+
|
996 |
+
/**
|
997 |
+
* Generates a unique ID.
|
998 |
+
*
|
999 |
+
* This ID will be unique to this collection.
|
1000 |
+
*
|
1001 |
+
* @since 4.7.4
|
1002 |
+
* @see uniqid()
|
1003 |
+
* @uses-filter admin_notice_generate_unique_id To allow modification of ID.
|
1004 |
+
* @param string $prefix The prefix to give to the generated ID.
|
1005 |
+
* @return string A notice ID unique to this instance in the scope of this collection.
|
1006 |
+
*/
|
1007 |
+
public function generate_unique_id( $prefix = '' ) {
|
1008 |
+
do {
|
1009 |
+
$id = uniqid( $prefix );
|
1010 |
+
} while ( $this->has_notice( $id ) );
|
1011 |
+
|
1012 |
+
return apply_filters( $this->prefix( 'admin_notice_generate_unique_id' ), $id, $prefix, $this );
|
1013 |
+
}
|
1014 |
+
|
1015 |
+
|
1016 |
+
/**
|
1017 |
+
* Generate the HTML for all allowed notices, sequentially.
|
1018 |
+
*
|
1019 |
+
* @since 4.7.4
|
1020 |
+
* @return string The rendered HTML.
|
1021 |
+
*/
|
1022 |
+
public function render_allowed_notices() {
|
1023 |
+
$output = '';
|
1024 |
+
foreach ( $this->get_allowed_notices() as $_id => $_notice ) {
|
1025 |
+
$output .= $this->render_notice( $_notice );
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
return $output;
|
1029 |
+
}
|
1030 |
+
|
1031 |
+
|
1032 |
+
/**
|
1033 |
+
* Directly output the rendered HTML of all allowed notices.
|
1034 |
+
*
|
1035 |
+
* @since 4.7.4
|
1036 |
+
* @return \WPRSS_Admin_Notices This instance.
|
1037 |
+
*/
|
1038 |
+
public function output_allowed_notices() {
|
1039 |
+
echo $this->render_allowed_notices();
|
1040 |
+
return $this;
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
|
1044 |
+
/**
|
1045 |
+
* Generate the HTML of a notice.
|
1046 |
+
*
|
1047 |
+
* @since 4.7.4
|
1048 |
+
* @uses-filter admin_notice_render_before To allow modification of notice data before rendering.
|
1049 |
+
* @uses-action admin_notice_render_after To allow injection inside the notice HTML.
|
1050 |
+
* @uses-filter admin_notice_rendered To allow modification of rendered HTML.
|
1051 |
+
* @param array|string $id Notice, or notice ID.
|
1052 |
+
* @return string The HTML output of the notice.
|
1053 |
+
* @throws Exception If no notice found for ID.
|
1054 |
+
*/
|
1055 |
+
public function render_notice( $id ) {
|
1056 |
+
$notice = is_array( $id )
|
1057 |
+
? $id
|
1058 |
+
: $this->get_notices( $id );
|
1059 |
+
|
1060 |
+
if ( !$notice )
|
1061 |
+
throw new Exception( sprintf( 'Could not render notice: no notice found for ID "%1$s"' ), $id );
|
1062 |
+
ob_start();
|
1063 |
+
$notice = apply_filters( $this->prefix( 'admin_notice_render_before' ), $notice, $this );
|
1064 |
+
?>
|
1065 |
+
|
1066 |
+
<div id="<?php echo $notice['id'] ?>" class="<?php echo $notice['notice_type'] ?> <?php echo $notice['notice_element_class'] ?> <?php echo $this->get_notice_base_class() ?>">
|
1067 |
+
<div class="notice-content">
|
1068 |
+
<?php echo $notice['content'] ?>
|
1069 |
+
</div>
|
1070 |
+
<a href="javascript:;" id="<?php echo $notice['btn_close_id'] ?>" style="float:right;" class="<?php echo $this->get_btn_close_base_class() ?> <?php echo $notice['btn_close_class'] ?>"><?php echo $notice['btn_close_content'] ?></a>
|
1071 |
+
<span id="<?php echo $notice['nonce_element_id'] ?>" class="hidden <?php echo $notice['nonce_element_class'] ?> <?php echo $this->get_nonce_base_class() ?>"><?php echo $notice['nonce'] ?></span>
|
1072 |
+
</div>
|
1073 |
+
<?php
|
1074 |
+
do_action( $this->prefix( 'admin_notice_render_after' ), $notice, $this );
|
1075 |
+
$output = ob_get_clean();
|
1076 |
+
|
1077 |
+
return apply_filters( $this->prefix( 'admin_notice_rendered' ), $output, $notice, $this );
|
1078 |
+
}
|
1079 |
+
|
1080 |
+
|
1081 |
+
/**
|
1082 |
+
* Used to hide a notice, typically responding to a frontend event.
|
1083 |
+
*
|
1084 |
+
* @since 4.7.4
|
1085 |
+
* @param array|string $notice Notice or notice ID.
|
1086 |
+
* @param string $nonce The nonce from the frontend.
|
1087 |
+
* @return \WPRSS_Admin_Notices This instance.
|
1088 |
+
* @throws Exception If no notice ID specified, or no notice found for it,
|
1089 |
+
* or specified nonce does not belong to the notice, or the nonce is not right.
|
1090 |
+
*/
|
1091 |
+
public function hide_notice( $notice, $nonce ) {
|
1092 |
+
if ( is_array( $notice ) )
|
1093 |
+
$notice = isset( $notice['id'] ) ? $notice['id'] : null;
|
1094 |
+
|
1095 |
+
if ( is_null( $notice ) )
|
1096 |
+
throw new Exception( sprintf( 'Could not hide notice: Notice ID must be specified' ) );
|
1097 |
+
if ( is_null( $nonce ) )
|
1098 |
+
throw new Exception( sprintf( 'Could not hide notice: nonce must be specified' ) );
|
1099 |
+
if ( !($notice = $this->get_notices( $notice ) ) )
|
1100 |
+
throw new Exception( sprintf( 'Could not hide notice: No notice found for ID "%1$s"', $notice ) );
|
1101 |
+
|
1102 |
+
// Is it the right nonce?
|
1103 |
+
if ( $notice['nonce'] !== $nonce )
|
1104 |
+
throw new Exception( sprintf( 'Could not hide notice: Nonce "%1$s" does not belong to notice "%2$s"', $nonce, $notice_id ) );
|
1105 |
+
|
1106 |
+
// Verify nonce
|
1107 |
+
if( !wp_verify_nonce( $nonce, $this->generate_nonce_code( $notice ) ) )
|
1108 |
+
throw new Exception( sprintf( 'Could not hide notice: Nonce "%1$s" is incorrect', $nonce ) );
|
1109 |
+
|
1110 |
+
wprss_admin_notice_get_collection()->set_notice_active( $notice, false );
|
1111 |
+
|
1112 |
+
return $this;
|
1113 |
+
}
|
1114 |
+
}
|
1115 |
+
|
1116 |
+
|
1117 |
+
// This should initialize the notice collection before anything can use it
|
1118 |
+
add_action( 'init', 'wprss_admin_notice_get_collection', 9 );
|
1119 |
+
|
1120 |
+
|
1121 |
+
/**
|
1122 |
+
* Returns the singleton, plugin-wide instane of the admin notices controller.
|
1123 |
+
* Initializes it if necessary.
|
1124 |
+
*
|
1125 |
+
* @since 4.7.4
|
1126 |
+
* @uses-filter wprss_admin_notice_collection_before_init To modify collection before initialization.
|
1127 |
+
* @uses-filter wprss_admin_notice_collection_after_init To modify collection after initialization.
|
1128 |
+
* @uses-filter wprss_admin_notice_collection_before_enqueue_scripts To modify list of script handles to enqueue.
|
1129 |
+
* @uses-action wprss_admin_notice_collection_after_enqueue_scripts To access list of enqueued script handles.
|
1130 |
+
* @uses-filter wprss_admin_notice_collection_before_localize_vars To modify list of vars to expose to the frontend.
|
1131 |
+
* @uses-action wprss_admin_notice_collection_before_localize_vars To access list of vars exposed to the frontend.
|
1132 |
+
* @staticvar WPRSS_Admin_Notices $collection The singleton instance.
|
1133 |
+
* @return \WPRSS_Admin_Notices The singleton instance.
|
1134 |
+
*/
|
1135 |
+
function wprss_admin_notice_get_collection() {
|
1136 |
+
static $collection = null;
|
1137 |
+
|
1138 |
+
if ( is_null( $collection ) ) {
|
1139 |
+
// Initialize collection
|
1140 |
+
$collection = new WPRSS_Admin_Notices(array(
|
1141 |
+
'setting_code' => 'wprss_admin_notices',
|
1142 |
+
'id_prefix' => 'wprss_',
|
1143 |
+
'text_domain' => WPRSS_TEXT_DOMAIN
|
1144 |
+
));
|
1145 |
+
$collection = apply_filters( 'wprss_admin_notice_collection_before_init', $collection );
|
1146 |
+
$collection->init();
|
1147 |
+
$collection = apply_filters( 'wprss_admin_notice_collection_after_init', $collection );
|
1148 |
+
|
1149 |
+
$script_handles = apply_filters( 'wprss_admin_notice_collection_before_enqueue_scripts', array( 'wprss-admin-notifications' ), $collection );
|
1150 |
+
foreach ( $script_handles as $_idx => $_handle ) wp_enqueue_script( $_handle );
|
1151 |
+
do_action( 'wprss_admin_notice_collection_after_enqueue_scripts', $script_handles, $collection );
|
1152 |
+
|
1153 |
+
// Frontend settings
|
1154 |
+
$settings = apply_filters( 'wprss_admin_notice_collection_before_localize_vars', array(
|
1155 |
+
'notice_class' => $collection->get_notice_base_class(),
|
1156 |
+
'nonce_class' => $collection->get_nonce_base_class(),
|
1157 |
+
'btn_close_class' => $collection->get_btn_close_base_class(),
|
1158 |
+
'action_code' => wprss_admin_notice_get_action_code()
|
1159 |
+
), $collection );
|
1160 |
+
wp_localize_script( 'aventura', 'adminNoticeGlobalVars', $settings);
|
1161 |
+
do_action( 'wprss_admin_notice_collection_before_localize_vars', $settings, $collection );
|
1162 |
+
}
|
1163 |
+
|
1164 |
+
return $collection;
|
1165 |
+
}
|
1166 |
+
|
1167 |
+
|
1168 |
+
/**
|
1169 |
+
* Centralizes access to the name of the AJAX action handler for dismissing admin notices.
|
1170 |
+
*
|
1171 |
+
* This is necessary for configuration of the frontend.
|
1172 |
+
*
|
1173 |
+
* @since 4.7.4
|
1174 |
+
* @uses-filter wprss_admin_notice_action_code To modify return value.
|
1175 |
+
* @return string The action code
|
1176 |
+
*/
|
1177 |
+
function wprss_admin_notice_get_action_code() {
|
1178 |
+
return apply_filters( 'wprss_admin_notice_action_code', 'wprss_admin_notice_hide' );
|
1179 |
+
}
|
1180 |
+
|
1181 |
+
|
1182 |
+
/**
|
1183 |
+
* Adds a notice to be displayed on top of an admin page.
|
1184 |
+
*
|
1185 |
+
* @since 4.7.4
|
1186 |
+
* @param array $notice Data of the notice
|
1187 |
+
* @return bool|WP_Error True if notice added, or WP_Error if something went wrong.
|
1188 |
+
*/
|
1189 |
+
function wprss_admin_notice_add( $notice ) {
|
1190 |
+
try {
|
1191 |
+
wprss_admin_notice_get_collection()->add_notice( $notice );
|
1192 |
+
} catch ( Exception $e ) {
|
1193 |
+
return new WP_Error( 'could_not_add_admin_notice', $e->getMessage() );
|
1194 |
+
}
|
1195 |
+
|
1196 |
+
return true;
|
1197 |
+
}
|
1198 |
+
|
1199 |
+
|
1200 |
+
add_action( sprintf( 'wp_ajax_%1$s', wprss_admin_notice_get_action_code() ), 'wprss_admin_notice_hide' );
|
1201 |
+
/**
|
1202 |
+
* This is what handles the AJAX action of dismissing admin notices.
|
1203 |
+
*
|
1204 |
+
* @see WPRSS_Admin_Notices::hide_notice()
|
1205 |
+
* @since 4.7.4
|
1206 |
+
*/
|
1207 |
+
function wprss_admin_notice_hide() {
|
1208 |
+
$notice_id = isset( $_REQUEST['notice_id'] ) ? $_REQUEST['notice_id'] : null;
|
1209 |
+
$nonce = isset( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : null;
|
1210 |
+
|
1211 |
+
try {
|
1212 |
+
wprss_admin_notice_get_collection()->hide_notice( $notice_id, $nonce );
|
1213 |
+
} catch (Exception $e) {
|
1214 |
+
// Failure
|
1215 |
+
echo $e->getMessage();
|
1216 |
+
exit();
|
1217 |
+
}
|
1218 |
+
|
1219 |
+
// Success
|
1220 |
+
exit( '1' );
|
1221 |
+
}
|
1222 |
+
|
1223 |
+
|
1224 |
+
/**
|
1225 |
+
* Check whether the current page is related to WP RSS Aggregator.
|
1226 |
+
*
|
1227 |
+
* @since 4.7.4
|
1228 |
+
* @uses-filter wprss_is_wprss_page To modify return value.
|
1229 |
+
* @global string $typenow Post type of the current page.
|
1230 |
+
* @return boolean True if the current page is a WPRSS-related page; false otherwise.
|
1231 |
+
*/
|
1232 |
+
function wprss_is_wprss_page() {
|
1233 |
+
global $typenow;
|
1234 |
+
|
1235 |
+
if ( empty( $typenow ) && !empty( $_GET['post'] ) ) {
|
1236 |
+
$post = get_post( $_GET['post'] );
|
1237 |
+
if ( $post !== NULL && !is_wp_error( $post ) )
|
1238 |
+
$typenow = $post->post_type;
|
1239 |
+
}
|
1240 |
+
|
1241 |
+
$is_wprss_page = ( $typenow == 'wprss_feed' ) || ( $typenow == 'wprss_feed_item' );
|
1242 |
+
return apply_filters( 'wprss_is_wprss_page', $is_wprss_page );
|
1243 |
+
}
|
1244 |
+
|
1245 |
+
|
1246 |
+
/**
|
1247 |
+
* Check whether the currently logged in user can manage WP options.
|
1248 |
+
*
|
1249 |
+
* This normally describes the administrator.
|
1250 |
+
*
|
1251 |
+
* @since 4.7.4
|
1252 |
+
* @uses-filter wprss_user_can_manage_options To modify return value.
|
1253 |
+
* @return bool True if the currently logged in user has the 'manage_options' privilege; false otherwise.
|
1254 |
+
*/
|
1255 |
+
function wprss_user_can_manage_options() {
|
1256 |
+
return apply_filters( 'wprss_user_can_manage_options', current_user_can( 'manage_options' ) );
|
1257 |
+
}
|
1258 |
+
|
includes/admin-options.php
CHANGED
@@ -524,16 +524,16 @@
|
|
524 |
$open_dd = wprss_get_general_setting('open_dd');
|
525 |
|
526 |
$items = array(
|
527 |
-
__( 'Lightbox', WPRSS_TEXT_DOMAIN ),
|
528 |
-
__( 'New window', WPRSS_TEXT_DOMAIN ),
|
529 |
-
__( 'Self', WPRSS_TEXT_DOMAIN )
|
530 |
);
|
531 |
?>
|
532 |
<select id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[open_dd]">
|
533 |
<?php
|
534 |
-
foreach( $items as $item ) {
|
535 |
-
$selected = ( $open_dd == $
|
536 |
-
?><option value="<?php echo $
|
537 |
}
|
538 |
?>
|
539 |
</select>
|
524 |
$open_dd = wprss_get_general_setting('open_dd');
|
525 |
|
526 |
$items = array(
|
527 |
+
'Lightbox' => __( 'Lightbox', WPRSS_TEXT_DOMAIN ),
|
528 |
+
'New window' => __( 'New window', WPRSS_TEXT_DOMAIN ),
|
529 |
+
'Self' => __( 'Self', WPRSS_TEXT_DOMAIN )
|
530 |
);
|
531 |
?>
|
532 |
<select id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[open_dd]">
|
533 |
<?php
|
534 |
+
foreach( $items as $key => $item ) {
|
535 |
+
$selected = ( $open_dd == $key ) ? 'selected="selected"' : '';
|
536 |
+
?><option value="<?php echo $key ?>" <?php echo $selected ?>><?php echo $item ?></option><?php
|
537 |
}
|
538 |
?>
|
539 |
</select>
|
includes/feed-display.php
CHANGED
@@ -92,9 +92,9 @@
|
|
92 |
|
93 |
$text_preceding_date = wprss_get_general_setting('text_preceding_date');
|
94 |
$text_preceding_date = ltrim( __( $text_preceding_date, WPRSS_TEXT_DOMAIN ) . ' ' );
|
95 |
-
|
96 |
do_action( 'wprss_get_post_data' );
|
97 |
-
|
98 |
$meta = $extra_options;
|
99 |
$extra_meta = apply_filters( 'wprss_template_extra_meta', $meta, $args, $ID );
|
100 |
|
@@ -114,7 +114,7 @@
|
|
114 |
echo $item_title;
|
115 |
|
116 |
do_action( 'wprss_after_feed_item_title', $extra_meta, $display_settings, $ID );
|
117 |
-
|
118 |
// FEED ITEM META
|
119 |
echo '<div class="wprss-feed-meta">';
|
120 |
|
@@ -146,7 +146,7 @@
|
|
146 |
echo ' ' . $author_text;
|
147 |
echo '</span>';
|
148 |
}
|
149 |
-
|
150 |
echo '</div>';
|
151 |
|
152 |
// TIME AGO
|
@@ -255,7 +255,7 @@
|
|
255 |
} else {
|
256 |
$paged = 1;
|
257 |
}
|
258 |
-
|
259 |
$feed_items_args = array(
|
260 |
'post_type' => 'wprss_feed_item',
|
261 |
'posts_per_page' => $posts_per_page,
|
@@ -275,7 +275,7 @@
|
|
275 |
if ( isset( $settings['no-paged'] ) && $settings['no-paged'] === TRUE ) {
|
276 |
unset( $feed_items_args['no-paged'] );
|
277 |
}
|
278 |
-
|
279 |
// If either the source or exclude arguments are set (but not both), prepare a meta query
|
280 |
if ( isset( $settings['source'] ) xor isset( $settings['exclude'] ) ) {
|
281 |
// Set the appropriate setting and operator
|
@@ -390,7 +390,7 @@
|
|
390 |
function wprss_pagination_links( $output ) {
|
391 |
// Get the general setting
|
392 |
$pagination = wprss_get_general_setting( 'pagination' );;
|
393 |
-
|
394 |
// Check the pagination setting, if using page numbers
|
395 |
if ( $pagination === 'numbered' ) {
|
396 |
global $wp_query;
|
@@ -408,7 +408,7 @@
|
|
408 |
$output .= '<div class="nav-links">';
|
409 |
$output .= ' <div class="nav-previous alignleft">' . get_next_posts_link( __( 'Older posts', WPRSS_TEXT_DOMAIN ) ) . '</div>';
|
410 |
$output .= ' <div class="nav-next alignright">' . get_previous_posts_link( __( 'Newer posts', WPRSS_TEXT_DOMAIN ) ) . '</div>';
|
411 |
-
$output .= '</div>';
|
412 |
return $output;
|
413 |
}
|
414 |
}
|
@@ -417,7 +417,7 @@
|
|
417 |
add_filter( 'the_title', 'wprss_shorten_title', 10, 2 );
|
418 |
/**
|
419 |
* Checks the title limit option and shortens the title when necassary.
|
420 |
-
*
|
421 |
* @since 1.0
|
422 |
*/
|
423 |
function wprss_shorten_title( $title, $id = null ) {
|
92 |
|
93 |
$text_preceding_date = wprss_get_general_setting('text_preceding_date');
|
94 |
$text_preceding_date = ltrim( __( $text_preceding_date, WPRSS_TEXT_DOMAIN ) . ' ' );
|
95 |
+
|
96 |
do_action( 'wprss_get_post_data' );
|
97 |
+
|
98 |
$meta = $extra_options;
|
99 |
$extra_meta = apply_filters( 'wprss_template_extra_meta', $meta, $args, $ID );
|
100 |
|
114 |
echo $item_title;
|
115 |
|
116 |
do_action( 'wprss_after_feed_item_title', $extra_meta, $display_settings, $ID );
|
117 |
+
|
118 |
// FEED ITEM META
|
119 |
echo '<div class="wprss-feed-meta">';
|
120 |
|
146 |
echo ' ' . $author_text;
|
147 |
echo '</span>';
|
148 |
}
|
149 |
+
|
150 |
echo '</div>';
|
151 |
|
152 |
// TIME AGO
|
255 |
} else {
|
256 |
$paged = 1;
|
257 |
}
|
258 |
+
|
259 |
$feed_items_args = array(
|
260 |
'post_type' => 'wprss_feed_item',
|
261 |
'posts_per_page' => $posts_per_page,
|
275 |
if ( isset( $settings['no-paged'] ) && $settings['no-paged'] === TRUE ) {
|
276 |
unset( $feed_items_args['no-paged'] );
|
277 |
}
|
278 |
+
|
279 |
// If either the source or exclude arguments are set (but not both), prepare a meta query
|
280 |
if ( isset( $settings['source'] ) xor isset( $settings['exclude'] ) ) {
|
281 |
// Set the appropriate setting and operator
|
390 |
function wprss_pagination_links( $output ) {
|
391 |
// Get the general setting
|
392 |
$pagination = wprss_get_general_setting( 'pagination' );;
|
393 |
+
|
394 |
// Check the pagination setting, if using page numbers
|
395 |
if ( $pagination === 'numbered' ) {
|
396 |
global $wp_query;
|
408 |
$output .= '<div class="nav-links">';
|
409 |
$output .= ' <div class="nav-previous alignleft">' . get_next_posts_link( __( 'Older posts', WPRSS_TEXT_DOMAIN ) ) . '</div>';
|
410 |
$output .= ' <div class="nav-next alignright">' . get_previous_posts_link( __( 'Newer posts', WPRSS_TEXT_DOMAIN ) ) . '</div>';
|
411 |
+
$output .= '</div>';
|
412 |
return $output;
|
413 |
}
|
414 |
}
|
417 |
add_filter( 'the_title', 'wprss_shorten_title', 10, 2 );
|
418 |
/**
|
419 |
* Checks the title limit option and shortens the title when necassary.
|
420 |
+
*
|
421 |
* @since 1.0
|
422 |
*/
|
423 |
function wprss_shorten_title( $title, $id = null ) {
|
includes/image-caching.php
CHANGED
@@ -383,7 +383,7 @@ class WPRSS_Image_Cache {
|
|
383 |
public function is_valid_url( $url ) {
|
384 |
$url = trim( $url );
|
385 |
$protocol_regex = '^([a-z][\w-]+:)?//';
|
386 |
-
return !is_object() && preg_match( $protocol_regex, $url ) && wprss_validate_url( $url );
|
387 |
}
|
388 |
|
389 |
|
@@ -543,7 +543,7 @@ class WPRSS_Image_Cache {
|
|
543 |
$hash_funcs = apply_filters( 'wprss_image_cache_hash_functions', array( 'sha1', 'md5' ) );
|
544 |
foreach ( $hash_funcs as $_idx => $_func )
|
545 |
if ( is_callable( $_func ) )
|
546 |
-
return call_user_func_array ( $_func, array( $
|
547 |
|
548 |
return $default;
|
549 |
}
|
383 |
public function is_valid_url( $url ) {
|
384 |
$url = trim( $url );
|
385 |
$protocol_regex = '^([a-z][\w-]+:)?//';
|
386 |
+
return !is_object( $url ) && preg_match( sprintf( '!%1$s!', $protocol_regex ), $url ) && wprss_validate_url( $url );
|
387 |
}
|
388 |
|
389 |
|
543 |
$hash_funcs = apply_filters( 'wprss_image_cache_hash_functions', array( 'sha1', 'md5' ) );
|
544 |
foreach ( $hash_funcs as $_idx => $_func )
|
545 |
if ( is_callable( $_func ) )
|
546 |
+
return call_user_func_array ( $_func, array( $value ) );
|
547 |
|
548 |
return $default;
|
549 |
}
|
includes/scripts.php
CHANGED
@@ -5,6 +5,17 @@
|
|
5 |
* @package WPRSSAggregator
|
6 |
*/
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
add_action( 'admin_enqueue_scripts', 'wprss_admin_scripts_styles' );
|
10 |
/**
|
@@ -26,6 +37,11 @@
|
|
26 |
|
27 |
$screen = get_current_screen();
|
28 |
|
|
|
|
|
|
|
|
|
|
|
29 |
wp_enqueue_script( 'wprss-admin-addon-ajax', WPRSS_JS .'admin-addon-ajax.js', array('jquery') );
|
30 |
wp_localize_script( 'wprss-admin-addon-ajax', 'wprss_admin_addon_ajax', array(
|
31 |
'please_wait' => __( 'Please wait ...', WPRSS_TEXT_DOMAIN )
|
5 |
* @package WPRSSAggregator
|
6 |
*/
|
7 |
|
8 |
+
add_action( 'init', 'wprss_register_scripts', 9 );
|
9 |
+
function wprss_register_scripts() {
|
10 |
+
// Add the Class library, the Xdn library, and the Aventura namespace and classes
|
11 |
+
wp_register_script( 'wprss-xdn-class', wprss_get_script_url( 'class' ), array('jquery') );
|
12 |
+
wp_register_script( 'wprss-xdn-lib', wprss_get_script_url( 'xdn' ), array('wprss-xdn-class') );
|
13 |
+
wp_register_script( 'aventura', wprss_get_script_url( 'aventura' ), array('wprss-xdn-lib') );
|
14 |
+
|
15 |
+
// This handles the client side for WPRSS_Admin_Notices
|
16 |
+
wp_register_script( 'wprss-admin-notifications', wprss_get_script_url( 'admin-notifications' ), array('aventura'), false, true );
|
17 |
+
}
|
18 |
+
|
19 |
|
20 |
add_action( 'admin_enqueue_scripts', 'wprss_admin_scripts_styles' );
|
21 |
/**
|
37 |
|
38 |
$screen = get_current_screen();
|
39 |
|
40 |
+
// Enqueue scripts for all admin pages
|
41 |
+
wp_enqueue_script( 'wprss-xdn-class' );
|
42 |
+
wp_enqueue_script( 'wprss-xdn-lib' );
|
43 |
+
wp_enqueue_script( 'aventura' );
|
44 |
+
|
45 |
wp_enqueue_script( 'wprss-admin-addon-ajax', WPRSS_JS .'admin-addon-ajax.js', array('jquery') );
|
46 |
wp_localize_script( 'wprss-admin-addon-ajax', 'wprss_admin_addon_ajax', array(
|
47 |
'please_wait' => __( 'Please wait ...', WPRSS_TEXT_DOMAIN )
|
js/admin-notifications.js
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Notifications client-side handling.
|
3 |
+
* Depends on Aventura.Wp.Admin.Notices.
|
4 |
+
*/
|
5 |
+
|
6 |
+
;(function($, window, document, undefined) {
|
7 |
+
var globalVars = adminNoticeGlobalVars || {};
|
8 |
+
var notices = Aventura.Wp.Admin.Notices.getGlobal();
|
9 |
+
notices.setOptions(globalVars)
|
10 |
+
.setOptions('ajax_url', ajaxurl);
|
11 |
+
notices.attach();
|
12 |
+
})(jQuery, top, document);
|
js/admin-notifications.min.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/* Automatically minified by JS CSS Minify Compress, a NetBeans plugin */;
|
2 |
+
(function($,window,document,undefined){var globalVars=adminNoticeGlobalVars||{};var notices=Aventura.Wp.Admin.Notices.getGlobal();notices.setOptions(globalVars).setOptions("ajax_url",ajaxurl);notices.attach()})(jQuery,top,document);
|
js/aventura.js
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Base functions and classes for Aventura namespace.
|
3 |
+
* Creates that top-level namespace.
|
4 |
+
* Depends on Xdn.
|
5 |
+
*/
|
6 |
+
|
7 |
+
;(function($, window, document, undefined) {
|
8 |
+
// This is the base, top level namespace
|
9 |
+
window.Aventura = window.Aventura || {};
|
10 |
+
})(jQuery, top, document);
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
;(function($, window, document, undefined) {
|
16 |
+
var Aventura_Wp_Admin_Notices = Xdn.Object.Configurable.extend({
|
17 |
+
|
18 |
+
attach: function() {
|
19 |
+
var noticeClass, btnCloseClass, nonceElementClass, ajaxUrl, actionCode;
|
20 |
+
|
21 |
+
if ( !( noticeClass = this.getOptions( 'notice_class' ) ) )
|
22 |
+
console.error( 'Could not initialize admin notices: "notice_class" option must be specified' );
|
23 |
+
|
24 |
+
if ( !( btnCloseClass = this.getOptions( 'btn_close_class' ) ) )
|
25 |
+
console.error( 'Could not initialize admin notices: "btn_close_class" must be specified' );
|
26 |
+
|
27 |
+
if ( !( nonceElementClass = this.getOptions( 'nonce_class' ) ) )
|
28 |
+
console.error( 'Could not initialize admin notices: "nonce_class" must be specified' );
|
29 |
+
|
30 |
+
if ( !( ajaxUrl = this.getOptions( 'ajax_url' ) ) )
|
31 |
+
console.error( 'Could not initialize admin notices: "ajax_url" must be specified' );
|
32 |
+
|
33 |
+
if ( !( actionCode = this.getOptions( 'action_code' ) ) )
|
34 |
+
console.error( 'Could not initialize admin notices: "action_code" must be specified' );
|
35 |
+
|
36 |
+
// Look through each notice
|
37 |
+
$( '.'+noticeClass ).each(function(i, el) {
|
38 |
+
$(el).find('.'+btnCloseClass).on( 'click', function(e) {
|
39 |
+
e.preventDefault();
|
40 |
+
e.stopPropagation();
|
41 |
+
|
42 |
+
$.post(ajaxUrl, {
|
43 |
+
// The name of the function to fire on the server
|
44 |
+
action: actionCode,
|
45 |
+
// The nonce value to send for the security check
|
46 |
+
nonce: $.trim( $(el).find('.'+nonceElementClass).text() ),
|
47 |
+
// The ID of the notice itself
|
48 |
+
notice_id: $(el).attr('id')
|
49 |
+
}, function (response) {
|
50 |
+
// Unsuccessful
|
51 |
+
if ( response !== '1' ) {
|
52 |
+
$(el).removeClass('updated').addClass('error');
|
53 |
+
console.error( response );
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
|
57 |
+
$(el).remove();
|
58 |
+
});
|
59 |
+
});
|
60 |
+
});
|
61 |
+
}
|
62 |
+
});
|
63 |
+
Xdn.assignNamespace(Aventura_Wp_Admin_Notices, 'Aventura.Wp.Admin.Notices');
|
64 |
+
|
65 |
+
var globalNotices;
|
66 |
+
Aventura.Wp.Admin.Notices.getGlobal = function() {
|
67 |
+
globalNotices = globalNotices || (function() {
|
68 |
+
return new Aventura.Wp.Admin.Notices();
|
69 |
+
})();
|
70 |
+
return globalNotices;
|
71 |
+
}
|
72 |
+
})(jQuery, top, document);
|
73 |
+
|
js/aventura.min.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/* Automatically minified by JS CSS Minify Compress, a NetBeans plugin */;
|
2 |
+
(function($,window,document,undefined){window.Aventura=window.Aventura||{}})(jQuery,top,document);(function($,window,document,undefined){var Aventura_Wp_Admin_Notices=Xdn.Object.Configurable.extend({attach:function(){var noticeClass,btnCloseClass,nonceElementClass,ajaxUrl,actionCode;if(!(noticeClass=this.getOptions("notice_class"))){console.error('Could not initialize admin notices: "notice_class" option must be specified')}if(!(btnCloseClass=this.getOptions("btn_close_class"))){console.error('Could not initialize admin notices: "btn_close_class" must be specified')}if(!(nonceElementClass=this.getOptions("nonce_class"))){console.error('Could not initialize admin notices: "nonce_class" must be specified')}if(!(ajaxUrl=this.getOptions("ajax_url"))){console.error('Could not initialize admin notices: "ajax_url" must be specified')}if(!(actionCode=this.getOptions("action_code"))){console.error('Could not initialize admin notices: "action_code" must be specified')}$("."+noticeClass).each(function(i,el){$(el).find("."+btnCloseClass).on("click",function(e){e.preventDefault();e.stopPropagation();$.post(ajaxUrl,{action:actionCode,nonce:$.trim($(el).find("."+nonceElementClass).text()),notice_id:$(el).attr("id")},function(response){if(response!=="1"){$(el).removeClass("updated").addClass("error");console.error(response);return}$(el).remove()})})})}});Xdn.assignNamespace(Aventura_Wp_Admin_Notices,"Aventura.Wp.Admin.Notices");var globalNotices;Aventura.Wp.Admin.Notices.getGlobal=function(){globalNotices=globalNotices||(function(){return new Aventura.Wp.Admin.Notices()})();return globalNotices}})(jQuery,top,document);
|
js/class.js
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;
|
2 |
+
/**
|
3 |
+
* Creates the top namespace of the company, and provides an OO approach to objects.
|
4 |
+
* Enhances John Resig's Class pattern with `augment()` method for structured mixins.
|
5 |
+
* @author Xedin Unknown <xedin.unknown@gmail.com>
|
6 |
+
*/
|
7 |
+
|
8 |
+
// Based on John Resig's Class pattern
|
9 |
+
(function () {
|
10 |
+
Xdn = top.Xdn || {};
|
11 |
+
var initializing = false, fnTest = /xyz/.test(function () {
|
12 |
+
xyz;
|
13 |
+
}) ? /\b_super\b/ : /.*/;
|
14 |
+
Xdn.Class = function () {
|
15 |
+
};
|
16 |
+
Xdn.Class.extend = function (prop) {
|
17 |
+
var _super = this.prototype;
|
18 |
+
initializing = true;
|
19 |
+
var prototype = new this();
|
20 |
+
initializing = false;
|
21 |
+
for (var name in prop) {
|
22 |
+
prototype[name] = typeof prop[name] == "function" && typeof _super[name] == "function" && fnTest.test(prop[name]) ? (function (name, fn) {
|
23 |
+
return function () {
|
24 |
+
var tmp = this._super;
|
25 |
+
this._super = _super[name];
|
26 |
+
var ret = fn.apply(this, arguments);
|
27 |
+
this._super = tmp;
|
28 |
+
return ret;
|
29 |
+
};
|
30 |
+
})(name, prop[name]) : prop[name];
|
31 |
+
}
|
32 |
+
function Class() {
|
33 |
+
if (!initializing && this.init) {
|
34 |
+
this.init.apply(this, arguments);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
Class.prototype = prototype;
|
38 |
+
Class.prototype.constructor = Class;
|
39 |
+
Class.extend = arguments.callee;
|
40 |
+
return Class;
|
41 |
+
};
|
42 |
+
})();
|
43 |
+
;
|
44 |
+
// A customization of the Class pattern. Allows structured Mixins
|
45 |
+
(function (Class) {
|
46 |
+
Class.augment = function (destination, source) {
|
47 |
+
for (var prop in source) {
|
48 |
+
if (!source.hasOwnProperty(prop))
|
49 |
+
continue;
|
50 |
+
destination.prototype[prop] = typeof (destination.prototype[prop]) !== 'undefined' ?
|
51 |
+
(function (prop) {
|
52 |
+
var fn = destination.prototype[prop];
|
53 |
+
return function () {
|
54 |
+
// Save any _super variable that already existed
|
55 |
+
var tmp = this._super;
|
56 |
+
|
57 |
+
this._super = source[prop];
|
58 |
+
fn.apply(this, arguments);
|
59 |
+
|
60 |
+
// Restore _super
|
61 |
+
this._super = tmp;
|
62 |
+
};
|
63 |
+
})(prop) :
|
64 |
+
source[prop];
|
65 |
+
}
|
66 |
+
|
67 |
+
return destination;
|
68 |
+
};
|
69 |
+
})(Xdn.Class);
|
js/class.min.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/* Automatically minified by JS CSS Minify Compress, a NetBeans plugin */;
|
2 |
+
(function(){Xdn=top.Xdn||{};var initializing=false,fnTest=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;Xdn.Class=function(){};Xdn.Class.extend=function(prop){var _super=this.prototype;initializing=true;var prototype=new this();initializing=false;for(var name in prop){prototype[name]=typeof prop[name]=="function"&&typeof _super[name]=="function"&&fnTest.test(prop[name])?(function(name,fn){return function(){var tmp=this._super;this._super=_super[name];var ret=fn.apply(this,arguments);this._super=tmp;return ret}})(name,prop[name]):prop[name]}function Class(){if(!initializing&&this.init){this.init.apply(this,arguments)}}Class.prototype=prototype;Class.prototype.constructor=Class;Class.extend=arguments.callee;return Class}})();(function(Class){Class.augment=function(destination,source){for(var prop in source){if(!source.hasOwnProperty(prop)){continue}destination.prototype[prop]=typeof(destination.prototype[prop])!=="undefined"?(function(prop){var fn=destination.prototype[prop];return function(){var tmp=this._super;this._super=source[prop];fn.apply(this,arguments);this._super=tmp}})(prop):source[prop]}return destination}})(Xdn.Class);
|
js/xdn.js
ADDED
@@ -0,0 +1,251 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* A truncated version of essential classes in the Xdn namespace.
|
3 |
+
* Requires Xdn.Class.
|
4 |
+
* @author Xedin Unknown <xedin.unknown@gmail.com>
|
5 |
+
*/
|
6 |
+
|
7 |
+
;(function($, window, document, undefined) {
|
8 |
+
// This is the base, top level namespace
|
9 |
+
window.Xdn = window.Xdn || {};
|
10 |
+
|
11 |
+
// Allows easy namespacing of classes
|
12 |
+
Xdn.assignNamespace = function (object, ns, overwrite) {
|
13 |
+
if( !object ) return;
|
14 |
+
|
15 |
+
if( (typeof object) === 'string' && !ns ) {
|
16 |
+
ns = object;
|
17 |
+
object = this;
|
18 |
+
}
|
19 |
+
|
20 |
+
ns = ns.split('.');
|
21 |
+
var obj, base;
|
22 |
+
for( var i=0; i<(ns.length-1); i++ ) {
|
23 |
+
base = i ? obj : window;
|
24 |
+
base[ns[i]] = base[ns[i]] || {};
|
25 |
+
obj = base[ns[i]];
|
26 |
+
}
|
27 |
+
|
28 |
+
if( obj && !overwrite && obj[ns[i]] && $.isPlainObject(obj[ns[i]]) ) {
|
29 |
+
object = $.extend(object, obj[ns[i]]);
|
30 |
+
}
|
31 |
+
obj[ns[i]] = object;
|
32 |
+
};
|
33 |
+
|
34 |
+
// Prevents errors in browsers that do not have a `console` global
|
35 |
+
!window.console && (window.console = {
|
36 |
+
log: function() {},
|
37 |
+
info: function() {},
|
38 |
+
warn: function() {},
|
39 |
+
error: function() {}
|
40 |
+
});
|
41 |
+
})(jQuery, top, document);
|
42 |
+
|
43 |
+
/* Xdn.Object */
|
44 |
+
;(function($, window, document, undefined) {
|
45 |
+
|
46 |
+
var Xdn_Object = Xdn.Class.extend(
|
47 |
+
/**
|
48 |
+
* @lends Xdn.Object
|
49 |
+
*/
|
50 |
+
{
|
51 |
+
_data: {},
|
52 |
+
|
53 |
+
init: function(data) {
|
54 |
+
this._data = {};
|
55 |
+
data && (this._data = data);
|
56 |
+
},
|
57 |
+
|
58 |
+
getData: function(key) {
|
59 |
+
return key ? this._data[key] : this._data;
|
60 |
+
},
|
61 |
+
|
62 |
+
setData: function(key, value) {
|
63 |
+
if( !value ) {
|
64 |
+
this._data = key;
|
65 |
+
return this;
|
66 |
+
}
|
67 |
+
|
68 |
+
this._data[key.toString()] = value;
|
69 |
+
return this;
|
70 |
+
},
|
71 |
+
|
72 |
+
unsData: function(key) {
|
73 |
+
if( !key ) {
|
74 |
+
this._data = {};
|
75 |
+
return this;
|
76 |
+
}
|
77 |
+
|
78 |
+
delete this._data[key];
|
79 |
+
},
|
80 |
+
|
81 |
+
addData: function(key, value) {
|
82 |
+
if( value ) {
|
83 |
+
this.setData(key, value);
|
84 |
+
return this;
|
85 |
+
}
|
86 |
+
|
87 |
+
this.setData($.extend({}, this.getData(), key));
|
88 |
+
},
|
89 |
+
|
90 |
+
clone: function(additionalData) {
|
91 |
+
var newObject = new Xdn.Object(this.getData());
|
92 |
+
additionalData && newObject.addData(additionalData);
|
93 |
+
return newObject;
|
94 |
+
},
|
95 |
+
|
96 |
+
_beforeMix: function(mixin) {
|
97 |
+
return mixin;
|
98 |
+
},
|
99 |
+
|
100 |
+
_afterMix: function(mixin) {
|
101 |
+
return this;
|
102 |
+
},
|
103 |
+
|
104 |
+
mix: function(mixin) {
|
105 |
+
var self = this;
|
106 |
+
mixin = mixin instanceof Array ? mixin : [mixin];
|
107 |
+
mixin = this._beforeMix(mixin);
|
108 |
+
$.each(mixin, function(i, mixin) {
|
109 |
+
if( (/boolean|number|string|array/).test(typeof mixin) ) return true;
|
110 |
+
Xdn.Object.augment(self, mixin);
|
111 |
+
});
|
112 |
+
this._afterMix(mixin);
|
113 |
+
|
114 |
+
return this;
|
115 |
+
},
|
116 |
+
|
117 |
+
// Dummy function for mixin initialization. To be implemented in mixin
|
118 |
+
_mix: function() {
|
119 |
+
}
|
120 |
+
});
|
121 |
+
|
122 |
+
Xdn_Object.find = function(object, value, one) {
|
123 |
+
one = one && true;
|
124 |
+
var result = [];
|
125 |
+
$.each(object, function(k, v) {
|
126 |
+
var end = v == value && result.push(k) > 1 && one;
|
127 |
+
if( end ) return false;
|
128 |
+
});
|
129 |
+
|
130 |
+
return one ? result : result[0];
|
131 |
+
};
|
132 |
+
|
133 |
+
Xdn_Object.augment = function(destination, source) {
|
134 |
+
for(var prop in source) {
|
135 |
+
if( !source.hasOwnProperty(prop) ) continue;
|
136 |
+
destination[prop] = typeof(destination[prop]) !== 'undefined' ?
|
137 |
+
(function(prop) {
|
138 |
+
var fn = source[prop],
|
139 |
+
_super = destination[prop];
|
140 |
+
return function() {
|
141 |
+
// Save any _super variable that already existed
|
142 |
+
var tmp = this._super,
|
143 |
+
result;
|
144 |
+
|
145 |
+
this._super = _super;
|
146 |
+
result = fn.apply(this, arguments);
|
147 |
+
|
148 |
+
// Restore _super
|
149 |
+
this._super = tmp;
|
150 |
+
return result;
|
151 |
+
};
|
152 |
+
})(prop) :
|
153 |
+
source[prop];
|
154 |
+
}
|
155 |
+
|
156 |
+
return destination;
|
157 |
+
};
|
158 |
+
|
159 |
+
/**
|
160 |
+
* @name Xdn.Object
|
161 |
+
* @class
|
162 |
+
*/
|
163 |
+
Xdn.assignNamespace(Xdn_Object, 'Xdn.Object');
|
164 |
+
|
165 |
+
Xdn.Object.camelize = function(string, separator) {
|
166 |
+
separator = separator || '_';
|
167 |
+
var ex = new RegExp(separator+'([a-zA-Z])', 'g');
|
168 |
+
return string.replace(ex, function (g) { return g[1].toUpperCase(); });
|
169 |
+
}
|
170 |
+
|
171 |
+
})(jQuery, top, document);
|
172 |
+
|
173 |
+
/* Xdn.Options */
|
174 |
+
;(function($, window, document, undefined) {
|
175 |
+
|
176 |
+
var Xdn_Options = Xdn.Object.extend({
|
177 |
+
read: function(key) {
|
178 |
+
return this.getData(key);
|
179 |
+
},
|
180 |
+
|
181 |
+
write: function(key, value) {
|
182 |
+
this.setData(key, value);
|
183 |
+
return this;
|
184 |
+
},
|
185 |
+
|
186 |
+
unset: function(key) {
|
187 |
+
this.unsData(key);
|
188 |
+
return this;
|
189 |
+
},
|
190 |
+
|
191 |
+
extend: function(key, value) {
|
192 |
+
this.addData(key, value);
|
193 |
+
return this;
|
194 |
+
},
|
195 |
+
|
196 |
+
configure: function(key, value, deep) {
|
197 |
+
if( value && !$.isPlainObject(key) ) {
|
198 |
+
key = (function(key, value) { var newKey = {}; newKey[key] = value; return newKey; })(key, value);
|
199 |
+
}
|
200 |
+
|
201 |
+
var args = [{}, key, this.read()];
|
202 |
+
deep && args.unshift(true);
|
203 |
+
|
204 |
+
this.write($.extend.apply($, args));
|
205 |
+
}
|
206 |
+
});
|
207 |
+
|
208 |
+
Xdn.assignNamespace(Xdn_Options, 'Xdn.Options');
|
209 |
+
})(jQuery, top, document);
|
210 |
+
|
211 |
+
/* Xdn.Object.Configurable */
|
212 |
+
;(function($, window, document, undefined) {
|
213 |
+
|
214 |
+
var Xdn_Object_Configurable = Xdn.Object.extend({
|
215 |
+
_options: null,
|
216 |
+
|
217 |
+
init: function(options) {
|
218 |
+
this._super();
|
219 |
+
this._options = new Xdn.Options();
|
220 |
+
$.isPlainObject(options) && this.setOptions(options);
|
221 |
+
this._init();
|
222 |
+
},
|
223 |
+
|
224 |
+
_init: function() {
|
225 |
+
|
226 |
+
},
|
227 |
+
|
228 |
+
getOptions: function(key) {
|
229 |
+
return key ? this._options.read(key) : this._options;
|
230 |
+
},
|
231 |
+
|
232 |
+
setOptions: function(key, value) {
|
233 |
+
this.getOptions().write(key, value);
|
234 |
+
return this;
|
235 |
+
},
|
236 |
+
|
237 |
+
unsetOptions: function(key) {
|
238 |
+
this.getOptions().unset(key);
|
239 |
+
return this;
|
240 |
+
},
|
241 |
+
|
242 |
+
mix: function(mixin) {
|
243 |
+
mixin = mixin || this.getOption('mixins');
|
244 |
+
this._super(mixin);
|
245 |
+
return this;
|
246 |
+
}
|
247 |
+
});
|
248 |
+
|
249 |
+
Xdn.assignNamespace(Xdn_Object_Configurable, 'Xdn.Object.Configurable');
|
250 |
+
})(jQuery, top, document);
|
251 |
+
|
js/xdn.min.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/* Automatically minified by JS CSS Minify Compress, a NetBeans plugin */;
|
2 |
+
(function($,window,document,undefined){window.Xdn=window.Xdn||{};Xdn.assignNamespace=function(object,ns,overwrite){if(!object){return}if((typeof object)==="string"&&!ns){ns=object;object=this}ns=ns.split(".");var obj,base;for(var i=0;i<(ns.length-1);i++){base=i?obj:window;base[ns[i]]=base[ns[i]]||{};obj=base[ns[i]]}if(obj&&!overwrite&&obj[ns[i]]&&$.isPlainObject(obj[ns[i]])){object=$.extend(object,obj[ns[i]])}obj[ns[i]]=object};!window.console&&(window.console={log:function(){},info:function(){},warn:function(){},error:function(){}})})(jQuery,top,document);(function($,window,document,undefined){var Xdn_Object=Xdn.Class.extend({_data:{},init:function(data){this._data={};data&&(this._data=data)},getData:function(key){return key?this._data[key]:this._data},setData:function(key,value){if(!value){this._data=key;return this}this._data[key.toString()]=value;return this},unsData:function(key){if(!key){this._data={};return this}delete this._data[key]},addData:function(key,value){if(value){this.setData(key,value);return this}this.setData($.extend({},this.getData(),key))},clone:function(additionalData){var newObject=new Xdn.Object(this.getData());additionalData&&newObject.addData(additionalData);return newObject},_beforeMix:function(mixin){return mixin},_afterMix:function(mixin){return this},mix:function(mixin){var self=this;mixin=mixin instanceof Array?mixin:[mixin];mixin=this._beforeMix(mixin);$.each(mixin,function(i,mixin){if((/boolean|number|string|array/).test(typeof mixin)){return true}Xdn.Object.augment(self,mixin)});this._afterMix(mixin);return this},_mix:function(){}});Xdn_Object.find=function(object,value,one){one=one&&true;var result=[];$.each(object,function(k,v){var end=v==value&&result.push(k)>1&&one;if(end){return false}});return one?result:result[0]};Xdn_Object.augment=function(destination,source){for(var prop in source){if(!source.hasOwnProperty(prop)){continue}destination[prop]=typeof(destination[prop])!=="undefined"?(function(prop){var fn=source[prop],_super=destination[prop];return function(){var tmp=this._super,result;this._super=_super;result=fn.apply(this,arguments);this._super=tmp;return result}})(prop):source[prop]}return destination};Xdn.assignNamespace(Xdn_Object,"Xdn.Object");Xdn.Object.camelize=function(string,separator){separator=separator||"_";var ex=new RegExp(separator+"([a-zA-Z])","g");return string.replace(ex,function(g){return g[1].toUpperCase()})}})(jQuery,top,document);(function($,window,document,undefined){var Xdn_Options=Xdn.Object.extend({read:function(key){return this.getData(key)},write:function(key,value){this.setData(key,value);return this},unset:function(key){this.unsData(key);return this},extend:function(key,value){this.addData(key,value);return this},configure:function(key,value,deep){if(value&&!$.isPlainObject(key)){key=(function(key,value){var newKey={};newKey[key]=value;return newKey})(key,value)}var args=[{},key,this.read()];deep&&args.unshift(true);this.write($.extend.apply($,args))}});Xdn.assignNamespace(Xdn_Options,"Xdn.Options")})(jQuery,top,document);(function($,window,document,undefined){var Xdn_Object_Configurable=Xdn.Object.extend({_options:null,init:function(options){this._super();this._options=new Xdn.Options();$.isPlainObject(options)&&this.setOptions(options);this._init()},_init:function(){},getOptions:function(key){return key?this._options.read(key):this._options},setOptions:function(key,value){this.getOptions().write(key,value);return this},unsetOptions:function(key){this.getOptions().unset(key);return this},mix:function(mixin){mixin=mixin||this.getOption("mixins");this._super(mixin);return this}});Xdn.assignNamespace(Xdn_Object_Configurable,"Xdn.Object.Configurable")})(jQuery,top,document);
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: jeangalea, Mekku, xedin.unknown, markzahra, doytch, chiragswadia
|
3 |
Plugin URI: http://www.wprssaggregator.com
|
4 |
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, rss feeder, rss post importer, autoblog aggregator, autoblog, autopost, content curation, feedwordpress, wp rss multi import, hungryfeed, wp-o-matic, rss feed, rss feed to post, rss retriever, syndication
|
5 |
-
Requires at least:
|
6 |
Tested up to: 4.2.3
|
7 |
-
Stable tag: 4.7.
|
8 |
License: GPLv2 or later
|
9 |
The no.1 RSS feed importer for WordPress. Premium add-ons available for more functionality.
|
10 |
|
@@ -169,6 +169,11 @@ The full documentation section can be found on the [WP RSS Aggregator website](w
|
|
169 |
|
170 |
== Changelog ==
|
171 |
|
|
|
|
|
|
|
|
|
|
|
172 |
= 4.7.3 (2015-08-04) =
|
173 |
* Enhanced: Core now implements an image cache logic.
|
174 |
* Enhanced: Add-ons on the "Add-ons" page now have an installed-but-inactive status.
|
2 |
Contributors: jeangalea, Mekku, xedin.unknown, markzahra, doytch, chiragswadia
|
3 |
Plugin URI: http://www.wprssaggregator.com
|
4 |
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, rss feeder, rss post importer, autoblog aggregator, autoblog, autopost, content curation, feedwordpress, wp rss multi import, hungryfeed, wp-o-matic, rss feed, rss feed to post, rss retriever, syndication
|
5 |
+
Requires at least: 4.0
|
6 |
Tested up to: 4.2.3
|
7 |
+
Stable tag: 4.7.4
|
8 |
License: GPLv2 or later
|
9 |
The no.1 RSS feed importer for WordPress. Premium add-ons available for more functionality.
|
10 |
|
169 |
|
170 |
== Changelog ==
|
171 |
|
172 |
+
= 4.7.4 (2015-08-19)
|
173 |
+
* Requirement: WordPress 4.0 or greater now required.
|
174 |
+
* Fixed bug in image caching
|
175 |
+
* Fixed bug in admin interface due to incorrectly translated IDs
|
176 |
+
|
177 |
= 4.7.3 (2015-08-04) =
|
178 |
* Enhanced: Core now implements an image cache logic.
|
179 |
* Enhanced: Add-ons on the "Add-ons" page now have an installed-but-inactive status.
|
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.7.
|
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.7.
|
33 |
* @since 1.0
|
34 |
* @author Jean Galea <info@wprssaggregator.com>
|
35 |
* @copyright Copyright (c) 2012-2015, Jean Galea
|
@@ -43,7 +43,10 @@
|
|
43 |
|
44 |
// Set the version number of the plugin.
|
45 |
if( !defined( 'WPRSS_VERSION' ) )
|
46 |
-
define( 'WPRSS_VERSION', '4.7.
|
|
|
|
|
|
|
47 |
|
48 |
// Set the database version number of the plugin.
|
49 |
if( !defined( 'WPRSS_DB_VERSION' ) )
|
@@ -296,10 +299,6 @@
|
|
296 |
* @since 3.6
|
297 |
*/
|
298 |
function wprss_prepare_pointers() {
|
299 |
-
// Don't run on WP < 3.3
|
300 |
-
if ( get_bloginfo( 'version' ) < '3.3' )
|
301 |
-
return;
|
302 |
-
|
303 |
// If the user is not an admin, do not show the pointer
|
304 |
if ( !current_user_can( 'manage_options' ) )
|
305 |
return;
|
@@ -393,6 +392,27 @@
|
|
393 |
}
|
394 |
|
395 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
/**
|
397 |
* Plugin activation procedure
|
398 |
*
|
@@ -401,9 +421,9 @@
|
|
401 |
*/
|
402 |
function wprss_activate() {
|
403 |
/* Prevents activation of plugin if compatible version of WordPress not found */
|
404 |
-
if (
|
405 |
deactivate_plugins ( basename( __FILE__ )); // Deactivate plugin
|
406 |
-
wp_die( __( 'This plugin requires WordPress version
|
407 |
}
|
408 |
wprss_settings_initialize();
|
409 |
flush_rewrite_rules();
|
@@ -556,3 +576,54 @@
|
|
556 |
|
557 |
return wprss_local_date_i18n( $timestamp, $format );
|
558 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.7.4
|
7 |
Author: Jean Galea
|
8 |
Author URI: http://www.wprssaggregator.com
|
9 |
License: GPLv2
|
29 |
|
30 |
/**
|
31 |
* @package WPRSSAggregator
|
32 |
+
* @version 4.7.4
|
33 |
* @since 1.0
|
34 |
* @author Jean Galea <info@wprssaggregator.com>
|
35 |
* @copyright Copyright (c) 2012-2015, Jean Galea
|
43 |
|
44 |
// Set the version number of the plugin.
|
45 |
if( !defined( 'WPRSS_VERSION' ) )
|
46 |
+
define( 'WPRSS_VERSION', '4.7.4', true );
|
47 |
+
|
48 |
+
if( !defined( 'WPRSS_WP_MIN_VERSION' ) )
|
49 |
+
define( 'WPRSS_WP_MIN_VERSION', '4.0', true );
|
50 |
|
51 |
// Set the database version number of the plugin.
|
52 |
if( !defined( 'WPRSS_DB_VERSION' ) )
|
299 |
* @since 3.6
|
300 |
*/
|
301 |
function wprss_prepare_pointers() {
|
|
|
|
|
|
|
|
|
302 |
// If the user is not an admin, do not show the pointer
|
303 |
if ( !current_user_can( 'manage_options' ) )
|
304 |
return;
|
392 |
}
|
393 |
|
394 |
|
395 |
+
function wprss_wp_min_version_satisfied() {
|
396 |
+
return version_compare( get_bloginfo( 'version' ), WPRSS_WP_MIN_VERSION, '>=' );
|
397 |
+
}
|
398 |
+
|
399 |
+
|
400 |
+
add_action( 'init', 'wprss_add_wp_version_warning' );
|
401 |
+
function wprss_add_wp_version_warning() {
|
402 |
+
if ( wprss_wp_min_version_satisfied() )
|
403 |
+
return;
|
404 |
+
|
405 |
+
wprss_admin_notice_add(array(
|
406 |
+
'id' => 'wp_version_warning',
|
407 |
+
'content' => sprintf( __(
|
408 |
+
'<p><strong>WP RSS Aggregator requires WordPress to be of version %1$s or higher.</strong></br>'
|
409 |
+
. 'Older versions of WordPress are no longer supported by WP RSS Aggregator. Please upgrade your WordPress core to continue benefiting from WP RSS Aggregator support services.</p>',
|
410 |
+
WPRSS_TEXT_DOMAIN ), WPRSS_WP_MIN_VERSION ),
|
411 |
+
'notice_type' => 'error'
|
412 |
+
));
|
413 |
+
}
|
414 |
+
|
415 |
+
|
416 |
/**
|
417 |
* Plugin activation procedure
|
418 |
*
|
421 |
*/
|
422 |
function wprss_activate() {
|
423 |
/* Prevents activation of plugin if compatible version of WordPress not found */
|
424 |
+
if ( !wprss_wp_min_version_satisfied() ) {
|
425 |
deactivate_plugins ( basename( __FILE__ )); // Deactivate plugin
|
426 |
+
wp_die( sprintf ( __( 'This plugin requires WordPress version %1$s or higher.' ), WPRSS_WP_MIN_VERSION ), 'WP RSS Aggregator', array( 'back_link' => true ) );
|
427 |
}
|
428 |
wprss_settings_initialize();
|
429 |
flush_rewrite_rules();
|
576 |
|
577 |
return wprss_local_date_i18n( $timestamp, $format );
|
578 |
}
|
579 |
+
|
580 |
+
|
581 |
+
/**
|
582 |
+
* Checks whether or not the Script Debug mode is on.
|
583 |
+
*
|
584 |
+
* By default, this is the value of the SCRIPT_DEBUG WordPress constant.
|
585 |
+
* However, this can be changed via the filter.
|
586 |
+
* Also, in earlier versions of WordPress, this constant does not seem
|
587 |
+
* to be initially declared. In this case it is assumed to be false,
|
588 |
+
* as per {@link https://codex.wordpress.org/Debugging_in_WordPress#SCRIPT_DEBUG WordPress Codex} documentation.
|
589 |
+
*
|
590 |
+
* @since 4.7.4
|
591 |
+
* @uses-filter wprss_is_script_debug To modify return value.
|
592 |
+
* @return boolean True if script debugging is on; false otherwise.
|
593 |
+
*/
|
594 |
+
function wprss_is_script_debug() {
|
595 |
+
return apply_filters( 'wprss_is_script_debug', defined( 'SCRIPT_DEBUG' ) ? SCRIPT_DEBUG : false );
|
596 |
+
}
|
597 |
+
|
598 |
+
|
599 |
+
/**
|
600 |
+
* Get the prefix for minified resources' extensions.
|
601 |
+
*
|
602 |
+
* @since 4.7.4
|
603 |
+
* @see wprss_is_script_debug()
|
604 |
+
* @uses-filter wprss_minified_extension_prefix To modify return value.
|
605 |
+
* @return string The prefix that is to be applied to minified resources' file names, before the extension.
|
606 |
+
*/
|
607 |
+
function wprss_get_minified_extension_prefix() {
|
608 |
+
return apply_filters( 'wprss_minified_extension_prefix', '.min' );
|
609 |
+
}
|
610 |
+
|
611 |
+
|
612 |
+
/**
|
613 |
+
* Get the absolute URL to a WP RSS Aggregator script.
|
614 |
+
*
|
615 |
+
* If Script Debugging is on, the extension will be prefixed appropriately.
|
616 |
+
*
|
617 |
+
* @since 4.7.4
|
618 |
+
* @see wprss_get_minified_extension_prefix()
|
619 |
+
* @param string $url The relative URL to the script resource, without the extension.
|
620 |
+
* @param string $extension The extension of the script file name, including the period (.). Default: '.js'.
|
621 |
+
* @return string The URL to the script local to WP RSS Aggregator, possibly minified.
|
622 |
+
*/
|
623 |
+
function wprss_get_script_url( $url, $extension = null ) {
|
624 |
+
if ( is_null( $extension ) )
|
625 |
+
$extension = '.js';
|
626 |
+
|
627 |
+
$script_url = WPRSS_JS . $url . (wprss_is_script_debug() ? wprss_get_minified_extension_prefix() : '') . $extension;
|
628 |
+
return apply_filters( 'wprss_script_url', $script_url, $url, $extension );
|
629 |
+
}
|