@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
18 | -if ( ! class_exists( 'Auto_Load_Next_Post_Admin_Notices' ) ) { |
|
18 | +if ( ! class_exists('Auto_Load_Next_Post_Admin_Notices')) { |
|
19 | 19 | |
20 | 20 | class Auto_Load_Next_Post_Admin_Notices { |
21 | 21 | |
@@ -37,16 +37,16 @@ discard block |
||
37 | 37 | * @version 1.5.0 |
38 | 38 | */ |
39 | 39 | public function __construct() { |
40 | - self::$install_date = get_site_option( 'auto_load_next_post_install_date', time() ); |
|
40 | + self::$install_date = get_site_option('auto_load_next_post_install_date', time()); |
|
41 | 41 | |
42 | 42 | // Check WordPress enviroment. |
43 | - add_action( 'admin_init', array( $this, 'check_wp' ), 12 ); |
|
43 | + add_action('admin_init', array($this, 'check_wp'), 12); |
|
44 | 44 | |
45 | 45 | // Don't bug the user if they don't want to see any notices. |
46 | - add_action( 'admin_init', array( $this, 'dont_bug_me' ), 15 ); |
|
46 | + add_action('admin_init', array($this, 'dont_bug_me'), 15); |
|
47 | 47 | |
48 | 48 | // Display other admin notices when required. All are dismissable. |
49 | - add_action( 'admin_init', array( $this, 'add_notices' ), 0 ); |
|
49 | + add_action('admin_init', array($this, 'add_notices'), 0); |
|
50 | 50 | } // END __construct() |
51 | 51 | |
52 | 52 | /** |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | public function check_wp() { |
61 | 61 | global $wp_version; |
62 | 62 | |
63 | - if ( ! version_compare( $wp_version, AUTO_LOAD_NEXT_POST_WP_VERSION_REQUIRE, '>=' ) ) { |
|
64 | - add_action( 'admin_notices', array( $this, 'requirement_wp_notice' ) ); |
|
63 | + if ( ! version_compare($wp_version, AUTO_LOAD_NEXT_POST_WP_VERSION_REQUIRE, '>=')) { |
|
64 | + add_action('admin_notices', array($this, 'requirement_wp_notice')); |
|
65 | 65 | return false; |
66 | 66 | } |
67 | 67 | |
@@ -81,25 +81,25 @@ discard block |
||
81 | 81 | $user_hidden_notice = false; |
82 | 82 | |
83 | 83 | // If the user is allowed to install plugins and requested to hide the review notice then hide it for that user. |
84 | - if ( ! empty( $_GET['hide_auto_load_next_post_review_notice'] ) && current_user_can( 'install_plugins' ) ) { |
|
85 | - add_user_meta( $current_user->ID, 'auto_load_next_post_hide_review_notice', '1', true ); |
|
84 | + if ( ! empty($_GET['hide_auto_load_next_post_review_notice']) && current_user_can('install_plugins')) { |
|
85 | + add_user_meta($current_user->ID, 'auto_load_next_post_hide_review_notice', '1', true); |
|
86 | 86 | $user_hidden_notice = true; |
87 | 87 | } |
88 | 88 | |
89 | 89 | // If the user is allowed to install plugins and requested to hide the welcome notice then hide it for that user. |
90 | - if ( ! empty( $_GET['hide_auto_load_next_post_welcome_notice'] ) && current_user_can( 'install_plugins' ) ) { |
|
91 | - add_user_meta( $current_user->ID, 'auto_load_next_post_hide_welcome_notice', '1', true ); |
|
90 | + if ( ! empty($_GET['hide_auto_load_next_post_welcome_notice']) && current_user_can('install_plugins')) { |
|
91 | + add_user_meta($current_user->ID, 'auto_load_next_post_hide_welcome_notice', '1', true); |
|
92 | 92 | $user_hidden_notice = true; |
93 | 93 | } |
94 | 94 | |
95 | - if ( ! empty( $_GET['hide_auto_load_next_post_beta_notice'] ) && current_user_can( 'install_plugins' ) ) { |
|
96 | - set_transient( 'alnp_beta_notice_hidden', 'hidden', WEEK_IN_SECONDS ); |
|
95 | + if ( ! empty($_GET['hide_auto_load_next_post_beta_notice']) && current_user_can('install_plugins')) { |
|
96 | + set_transient('alnp_beta_notice_hidden', 'hidden', WEEK_IN_SECONDS); |
|
97 | 97 | $user_hidden_notice = true; |
98 | 98 | } |
99 | 99 | |
100 | - if ( $user_hidden_notice ) { |
|
100 | + if ($user_hidden_notice) { |
|
101 | 101 | // Redirect to the plugins page. |
102 | - wp_safe_redirect( admin_url( 'plugins.php' ) ); |
|
102 | + wp_safe_redirect(admin_url('plugins.php')); |
|
103 | 103 | exit; |
104 | 104 | } |
105 | 105 | } // END dont_bug_me() |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | global $current_user; |
119 | 119 | |
120 | 120 | // If the current user can not install plugins then return nothing! |
121 | - if ( ! current_user_can( 'install_plugins' ) ) { |
|
121 | + if ( ! current_user_can('install_plugins')) { |
|
122 | 122 | return false; |
123 | 123 | } |
124 | 124 | |
@@ -126,58 +126,58 @@ discard block |
||
126 | 126 | $screen_id = $screen ? $screen->id : ''; |
127 | 127 | |
128 | 128 | // Notices should only show on the main dashboard and on the plugins screen. |
129 | - if ( ! in_array( $screen_id, alnp_get_admin_screens() ) ) { |
|
129 | + if ( ! in_array($screen_id, alnp_get_admin_screens())) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | 133 | // Is admin welcome notice hidden? |
134 | - $hide_welcome_notice = get_user_meta( $current_user->ID, 'auto_load_next_post_hide_welcome_notice', true ); |
|
134 | + $hide_welcome_notice = get_user_meta($current_user->ID, 'auto_load_next_post_hide_welcome_notice', true); |
|
135 | 135 | |
136 | 136 | // Check if we need to display the welcome notice. |
137 | - if ( current_user_can( 'install_plugins' ) && empty( $hide_welcome_notice ) ) { |
|
137 | + if (current_user_can('install_plugins') && empty($hide_welcome_notice)) { |
|
138 | 138 | // If the user has just installed the plugin for the first time then welcome the user. |
139 | - if ( ( intval( time() - strtotime( self::$install_date ) ) / WEEK_IN_SECONDS ) % 52 <= 2 ) { |
|
140 | - add_action( 'admin_notices', array( $this, 'welcome_notice' ) ); |
|
139 | + if ((intval(time() - strtotime(self::$install_date)) / WEEK_IN_SECONDS) % 52 <= 2) { |
|
140 | + add_action('admin_notices', array($this, 'welcome_notice')); |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | 144 | // Is admin review notice hidden? |
145 | - $hide_review_notice = get_user_meta( $current_user->ID, 'auto_load_next_post_hide_review_notice', true ); |
|
145 | + $hide_review_notice = get_user_meta($current_user->ID, 'auto_load_next_post_hide_review_notice', true); |
|
146 | 146 | |
147 | 147 | // Check if we need to display the review plugin notice. |
148 | - if ( current_user_can( 'install_plugins' ) && empty( $hide_review_notice ) ) { |
|
148 | + if (current_user_can('install_plugins') && empty($hide_review_notice)) { |
|
149 | 149 | // If it has been a week or more since activating the plugin then display the review notice. |
150 | - if ( ( intval( time() - self::$install_date ) ) > WEEK_IN_SECONDS ) { |
|
151 | - add_action( 'admin_notices', array( $this, 'plugin_review_notice' ) ); |
|
150 | + if ((intval(time() - self::$install_date)) > WEEK_IN_SECONDS) { |
|
151 | + add_action('admin_notices', array($this, 'plugin_review_notice')); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | 155 | // Is this version of Auto Load Next Post a beta release? |
156 | - if ( is_alnp_beta() && empty( get_transient( 'alnp_beta_notice_hidden' ) ) ) { |
|
157 | - add_action( 'admin_notices', array( $this, 'beta_notice' ) ); |
|
156 | + if (is_alnp_beta() && empty(get_transient('alnp_beta_notice_hidden'))) { |
|
157 | + add_action('admin_notices', array($this, 'beta_notice')); |
|
158 | 158 | } |
159 | 159 | |
160 | - $template = get_option( 'template' ); |
|
160 | + $template = get_option('template'); |
|
161 | 161 | |
162 | 162 | // Checks if the theme supports Auto Load Next Post and not provided via a plugin. |
163 | - if ( is_alnp_supported() ) { |
|
164 | - $plugin_supported = alnp_get_theme_support( 'plugin_support' ); |
|
163 | + if (is_alnp_supported()) { |
|
164 | + $plugin_supported = alnp_get_theme_support('plugin_support'); |
|
165 | 165 | |
166 | 166 | // Return if theme is supported via plugin. |
167 | - if ( ! empty( $plugin_supported ) && $plugin_supported == 'yes' ) { |
|
168 | - update_option( 'auto_load_next_post_theme_supported', $template ); |
|
167 | + if ( ! empty($plugin_supported) && $plugin_supported == 'yes') { |
|
168 | + update_option('auto_load_next_post_theme_supported', $template); |
|
169 | 169 | return false; |
170 | 170 | } |
171 | 171 | |
172 | 172 | // If supported theme does not match active theme then show notice. |
173 | - if ( get_option( 'auto_load_next_post_theme_supported' ) !== $template ) { |
|
174 | - add_action( 'admin_notices', array( $this, 'theme_ready_notice' ) ); |
|
175 | - update_option( 'auto_load_next_post_theme_supported', $template ); |
|
173 | + if (get_option('auto_load_next_post_theme_supported') !== $template) { |
|
174 | + add_action('admin_notices', array($this, 'theme_ready_notice')); |
|
175 | + update_option('auto_load_next_post_theme_supported', $template); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | else { |
179 | 179 | // If theme not supported then delete option. |
180 | - delete_option( 'auto_load_next_post_theme_supported' ); |
|
180 | + delete_option('auto_load_next_post_theme_supported'); |
|
181 | 181 | } |
182 | 182 | } // END add_notices() |
183 | 183 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @since 1.4.3 |
189 | 189 | */ |
190 | 190 | public function requirement_wp_notice() { |
191 | - include( dirname( __FILE__ ) . '/views/html-notice-requirement-wp.php' ); |
|
191 | + include(dirname(__FILE__).'/views/html-notice-requirement-wp.php'); |
|
192 | 192 | } // END requirement_wp_notice() |
193 | 193 | |
194 | 194 | /** |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @since 1.5.0 |
199 | 199 | */ |
200 | 200 | public function theme_ready_notice() { |
201 | - include( dirname( __FILE__ ) . '/views/html-notice-theme-ready.php' ); |
|
201 | + include(dirname(__FILE__).'/views/html-notice-theme-ready.php'); |
|
202 | 202 | } // END theme_ready_notice() |
203 | 203 | |
204 | 204 | /** |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @since 1.5.0 |
209 | 209 | */ |
210 | 210 | public function welcome_notice() { |
211 | - include( dirname( __FILE__ ) . '/views/html-notice-welcome.php' ); |
|
211 | + include(dirname(__FILE__).'/views/html-notice-welcome.php'); |
|
212 | 212 | } // END welcome_notice() |
213 | 213 | |
214 | 214 | /** |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @since 1.5.0 |
219 | 219 | */ |
220 | 220 | public function beta_notice() { |
221 | - include( dirname( __FILE__ ) . '/views/html-notice-trying-beta.php' ); |
|
221 | + include(dirname(__FILE__).'/views/html-notice-trying-beta.php'); |
|
222 | 222 | } // END beta_notice() |
223 | 223 | |
224 | 224 | /** |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | public function plugin_review_notice() { |
232 | 232 | $install_date = self::$install_date; |
233 | 233 | |
234 | - include( dirname( __FILE__ ) . '/views/html-notice-please-review.php' ); |
|
234 | + include(dirname(__FILE__).'/views/html-notice-please-review.php'); |
|
235 | 235 | } // END plugin_review_notice() |
236 | 236 | |
237 | 237 | } // END class. |