@@ -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_Settings' ) ) { |
|
18 | +if ( ! class_exists('Auto_Load_Next_Post_Admin_Settings')) { |
|
19 | 19 | |
20 | 20 | class Auto_Load_Next_Post_Admin_Settings { |
21 | 21 | |
@@ -56,16 +56,16 @@ discard block |
||
56 | 56 | * @return $settings |
57 | 57 | */ |
58 | 58 | public static function get_settings_pages() { |
59 | - if ( empty( self::$settings ) ) { |
|
59 | + if (empty(self::$settings)) { |
|
60 | 60 | $settings = array(); |
61 | 61 | |
62 | - include_once( dirname( __FILE__ ) . '/settings/class-alnp-settings-page.php' ); |
|
62 | + include_once(dirname(__FILE__).'/settings/class-alnp-settings-page.php'); |
|
63 | 63 | |
64 | - $settings[] = include( dirname( __FILE__ ) . '/settings/class-alnp-settings-theme-selectors.php'); |
|
65 | - $settings[] = include( dirname( __FILE__ ) . '/settings/class-alnp-settings-misc.php'); |
|
66 | - $settings[] = include( dirname( __FILE__ ) . '/settings/class-alnp-settings-events.php'); |
|
64 | + $settings[] = include(dirname(__FILE__).'/settings/class-alnp-settings-theme-selectors.php'); |
|
65 | + $settings[] = include(dirname(__FILE__).'/settings/class-alnp-settings-misc.php'); |
|
66 | + $settings[] = include(dirname(__FILE__).'/settings/class-alnp-settings-events.php'); |
|
67 | 67 | |
68 | - self::$settings = apply_filters( 'auto_load_next_post_get_settings_pages', $settings ); |
|
68 | + self::$settings = apply_filters('auto_load_next_post_get_settings_pages', $settings); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | return self::$settings; |
@@ -83,16 +83,16 @@ discard block |
||
83 | 83 | public static function save() { |
84 | 84 | global $current_tab; |
85 | 85 | |
86 | - check_admin_referer( 'auto-load-next-post-settings' ); |
|
86 | + check_admin_referer('auto-load-next-post-settings'); |
|
87 | 87 | |
88 | 88 | // Trigger actions |
89 | - do_action( 'auto_load_next_post_settings_save_' . $current_tab ); |
|
90 | - do_action( 'auto_load_next_post_update_options_' . $current_tab ); |
|
91 | - do_action( 'auto_load_next_post_update_options' ); |
|
89 | + do_action('auto_load_next_post_settings_save_'.$current_tab); |
|
90 | + do_action('auto_load_next_post_update_options_'.$current_tab); |
|
91 | + do_action('auto_load_next_post_update_options'); |
|
92 | 92 | |
93 | - self::add_message( __( 'Your settings have been saved.', 'auto-load-next-post' ) ); |
|
93 | + self::add_message(__('Your settings have been saved.', 'auto-load-next-post')); |
|
94 | 94 | |
95 | - do_action( 'auto_load_next_post_settings_saved' ); |
|
95 | + do_action('auto_load_next_post_settings_saved'); |
|
96 | 96 | } // END save() |
97 | 97 | |
98 | 98 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @since 1.0.0 |
104 | 104 | * @param string $text Message |
105 | 105 | */ |
106 | - public static function add_message( $text ) { |
|
106 | + public static function add_message($text) { |
|
107 | 107 | self::$messages[] = $text; |
108 | 108 | } // END add_message() |
109 | 109 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @since 1.0.0 |
116 | 116 | * @param string $text Error |
117 | 117 | */ |
118 | - public static function add_error( $text ) { |
|
118 | + public static function add_error($text) { |
|
119 | 119 | self::$errors[] = $text; |
120 | 120 | } // END add_error() |
121 | 121 | |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | * @return string |
129 | 129 | */ |
130 | 130 | public static function show_messages() { |
131 | - if ( count( self::$errors ) > 0 ) { |
|
132 | - foreach ( self::$errors as $error ) { |
|
133 | - echo '<div id="message" class="error inline"><p><strong>' . esc_html( $error ) . '</strong></p></div>'; |
|
131 | + if (count(self::$errors) > 0) { |
|
132 | + foreach (self::$errors as $error) { |
|
133 | + echo '<div id="message" class="error inline"><p><strong>'.esc_html($error).'</strong></p></div>'; |
|
134 | 134 | } |
135 | - } elseif ( count( self::$messages ) > 0 ) { |
|
136 | - foreach ( self::$messages as $message ) { |
|
137 | - echo '<div id="message" class="updated inline"><p><strong>' . esc_html( $message ) . '</strong></p></div>'; |
|
135 | + } elseif (count(self::$messages) > 0) { |
|
136 | + foreach (self::$messages as $message) { |
|
137 | + echo '<div id="message" class="updated inline"><p><strong>'.esc_html($message).'</strong></p></div>'; |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | } // END show_messages() |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | public static function output() { |
157 | 157 | global $current_section, $current_tab; |
158 | 158 | |
159 | - do_action( 'auto_load_next_post_settings_start' ); |
|
159 | + do_action('auto_load_next_post_settings_start'); |
|
160 | 160 | |
161 | 161 | // Get tabs for the settings page |
162 | - $tabs = apply_filters( 'auto_load_next_post_settings_tabs_array', array() ); |
|
162 | + $tabs = apply_filters('auto_load_next_post_settings_tabs_array', array()); |
|
163 | 163 | |
164 | 164 | // These tabs do not require settings output. |
165 | - $no_settings_req = array( 'extensions', 'videos' ); |
|
165 | + $no_settings_req = array('extensions', 'videos'); |
|
166 | 166 | |
167 | 167 | // Only include settings output if the current tab requires it. |
168 | - if ( ! in_array( $current_tab, $no_settings_req ) ) { |
|
169 | - include( dirname( __FILE__ ) . '/views/html-admin-settings.php' ); |
|
168 | + if ( ! in_array($current_tab, $no_settings_req)) { |
|
169 | + include(dirname(__FILE__).'/views/html-admin-settings.php'); |
|
170 | 170 | } |
171 | 171 | |
172 | - do_action( 'auto_load_next_post_settings_end', $current_tab, $tabs ); |
|
172 | + do_action('auto_load_next_post_settings_end', $current_tab, $tabs); |
|
173 | 173 | } // END output() |
174 | 174 | |
175 | 175 | /** |
@@ -181,33 +181,33 @@ discard block |
||
181 | 181 | * @param mixed $option_name |
182 | 182 | * @return string |
183 | 183 | */ |
184 | - public static function get_option( $option_name, $default = '' ) { |
|
184 | + public static function get_option($option_name, $default = '') { |
|
185 | 185 | // Array value |
186 | - if ( strstr( $option_name, '[' ) ) { |
|
187 | - parse_str( $option_name, $option_array ); |
|
186 | + if (strstr($option_name, '[')) { |
|
187 | + parse_str($option_name, $option_array); |
|
188 | 188 | |
189 | 189 | // Option name is first key |
190 | - $option_name = current( array_keys( $option_array ) ); |
|
190 | + $option_name = current(array_keys($option_array)); |
|
191 | 191 | |
192 | 192 | // Get value |
193 | - $option_values = get_option( $option_name, '' ); |
|
193 | + $option_values = get_option($option_name, ''); |
|
194 | 194 | |
195 | - $key = key( $option_array[$option_name] ); |
|
195 | + $key = key($option_array[$option_name]); |
|
196 | 196 | |
197 | - if ( isset( $option_values[$key] ) ) { |
|
197 | + if (isset($option_values[$key])) { |
|
198 | 198 | $option_value = $option_values[$key]; |
199 | 199 | } else { |
200 | 200 | $option_value = null; |
201 | 201 | } |
202 | 202 | } else { |
203 | 203 | // Single value |
204 | - $option_value = get_option( $option_name, null ); |
|
204 | + $option_value = get_option($option_name, null); |
|
205 | 205 | } |
206 | 206 | |
207 | - if ( is_array( $option_value ) ) { |
|
208 | - $option_value = array_map( 'stripslashes', $option_value ); |
|
209 | - } elseif ( ! is_null( $option_value ) ) { |
|
210 | - $option_value = stripslashes( $option_value ); |
|
207 | + if (is_array($option_value)) { |
|
208 | + $option_value = array_map('stripslashes', $option_value); |
|
209 | + } elseif ( ! is_null($option_value)) { |
|
210 | + $option_value = stripslashes($option_value); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | return $option_value === null ? $default : $option_value; |
@@ -224,84 +224,84 @@ discard block |
||
224 | 224 | * @version 1.5.0 |
225 | 225 | * @param array $options Opens array to output |
226 | 226 | */ |
227 | - public static function output_fields( $options ) { |
|
228 | - foreach ( $options as $key => $value ) { |
|
227 | + public static function output_fields($options) { |
|
228 | + foreach ($options as $key => $value) { |
|
229 | 229 | |
230 | - if ( ! isset( $value['type'] ) ) { |
|
230 | + if ( ! isset($value['type'])) { |
|
231 | 231 | continue; |
232 | 232 | } |
233 | - if ( ! isset( $value['id'] ) ) { |
|
233 | + if ( ! isset($value['id'])) { |
|
234 | 234 | $value['id'] = ''; |
235 | 235 | } |
236 | - if ( ! isset( $value['title'] ) ) { |
|
237 | - $value['title'] = isset( $value['name'] ) ? $value['name'] : ''; |
|
236 | + if ( ! isset($value['title'])) { |
|
237 | + $value['title'] = isset($value['name']) ? $value['name'] : ''; |
|
238 | 238 | } |
239 | - if ( ! isset( $value['class'] ) ) { |
|
239 | + if ( ! isset($value['class'])) { |
|
240 | 240 | $value['class'] = ''; |
241 | 241 | } |
242 | - if ( ! isset( $value['css'] ) ) { |
|
242 | + if ( ! isset($value['css'])) { |
|
243 | 243 | $value['css'] = ''; |
244 | 244 | } |
245 | - if ( ! isset( $value['default'] ) ) { |
|
245 | + if ( ! isset($value['default'])) { |
|
246 | 246 | $value['default'] = ''; |
247 | 247 | } |
248 | - if ( ! isset( $value['desc'] ) ) { |
|
248 | + if ( ! isset($value['desc'])) { |
|
249 | 249 | $value['desc'] = ''; |
250 | 250 | } |
251 | - if ( ! isset( $value['placeholder'] ) ) { |
|
251 | + if ( ! isset($value['placeholder'])) { |
|
252 | 252 | $value['placeholder'] = ''; |
253 | 253 | } |
254 | 254 | |
255 | 255 | // Custom attribute handling |
256 | 256 | $custom_attributes = array(); |
257 | 257 | |
258 | - if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) ) { |
|
259 | - foreach ( $value['custom_attributes'] as $attribute => $attribute_value ) { |
|
260 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
258 | + if ( ! empty($value['custom_attributes']) && is_array($value['custom_attributes'])) { |
|
259 | + foreach ($value['custom_attributes'] as $attribute => $attribute_value) { |
|
260 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"'; |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | 264 | // Description handling |
265 | - if ( ! empty( $value['desc'] ) ) { |
|
265 | + if ( ! empty($value['desc'])) { |
|
266 | 266 | $description = $value['desc']; |
267 | 267 | } |
268 | 268 | |
269 | - if ( $description && in_array( $value['type'], array( 'textarea', 'radio' ), true ) ) { |
|
270 | - $description = '<p style="margin-top:0">' . wp_kses_post( $description ) . '</p>'; |
|
271 | - } elseif ( $description && in_array( $value['type'], array( 'checkbox' ), true ) ) { |
|
272 | - $description = wp_kses_post( $description ); |
|
273 | - } elseif ( $description ) { |
|
274 | - $description = '<p class="description">' . wp_kses_post( $description ) . '</p>'; |
|
269 | + if ($description && in_array($value['type'], array('textarea', 'radio'), true)) { |
|
270 | + $description = '<p style="margin-top:0">'.wp_kses_post($description).'</p>'; |
|
271 | + } elseif ($description && in_array($value['type'], array('checkbox'), true)) { |
|
272 | + $description = wp_kses_post($description); |
|
273 | + } elseif ($description) { |
|
274 | + $description = '<p class="description">'.wp_kses_post($description).'</p>'; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | // Switch based on type |
278 | - switch( $value['type'] ) { |
|
278 | + switch ($value['type']) { |
|
279 | 279 | |
280 | 280 | // Section Titles |
281 | 281 | case 'title': |
282 | - if ( ! empty( $value['title'] ) ) { |
|
283 | - echo '<h2>' . esc_html( $value['title'] ) . '</h2>'; |
|
282 | + if ( ! empty($value['title'])) { |
|
283 | + echo '<h2>'.esc_html($value['title']).'</h2>'; |
|
284 | 284 | } |
285 | - if ( ! empty( $value['desc'] ) ) { |
|
286 | - echo '<div id="' . esc_attr( sanitize_title( $value['id'] ) ) . '-description">'; |
|
287 | - echo wp_kses_post( wpautop( wptexturize( $value['desc'] ) ) ); |
|
285 | + if ( ! empty($value['desc'])) { |
|
286 | + echo '<div id="'.esc_attr(sanitize_title($value['id'])).'-description">'; |
|
287 | + echo wp_kses_post(wpautop(wptexturize($value['desc']))); |
|
288 | 288 | echo '</div>'; |
289 | 289 | } |
290 | 290 | echo '<table class="form-table">'."\n\n"; |
291 | - if ( ! empty( $value['id'] ) ) { |
|
292 | - do_action( 'auto_load_next_post_settings_' . sanitize_title( $value['id'] ) ); |
|
291 | + if ( ! empty($value['id'])) { |
|
292 | + do_action('auto_load_next_post_settings_'.sanitize_title($value['id'])); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | break; |
296 | 296 | |
297 | 297 | // Section Ends |
298 | 298 | case 'sectionend': |
299 | - if ( ! empty( $value['id'] ) ) { |
|
300 | - do_action( 'auto_load_next_post_settings_' . sanitize_title( $value['id'] ) . '_end' ); |
|
299 | + if ( ! empty($value['id'])) { |
|
300 | + do_action('auto_load_next_post_settings_'.sanitize_title($value['id']).'_end'); |
|
301 | 301 | } |
302 | 302 | echo '</table>'; |
303 | - if ( ! empty( $value['id'] ) ) { |
|
304 | - do_action( 'auto_load_next_post_settings_' . sanitize_title( $value['id'] ) . '_after' ); |
|
303 | + if ( ! empty($value['id'])) { |
|
304 | + do_action('auto_load_next_post_settings_'.sanitize_title($value['id']).'_after'); |
|
305 | 305 | } |
306 | 306 | break; |
307 | 307 | |
@@ -314,22 +314,22 @@ discard block |
||
314 | 314 | case 'time': |
315 | 315 | case 'week': |
316 | 316 | case 'email': |
317 | - $option_value = self::get_option( $value['id'], $value['default'] ); |
|
317 | + $option_value = self::get_option($value['id'], $value['default']); |
|
318 | 318 | |
319 | 319 | ?><tr valign="top"> |
320 | 320 | <th scope="row" class="titledesc"> |
321 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label> |
|
321 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label> |
|
322 | 322 | </th> |
323 | - <td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>"> |
|
323 | + <td class="forminp forminp-<?php echo esc_attr(sanitize_title($value['type'])); ?>"> |
|
324 | 324 | <input |
325 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
326 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
327 | - type="<?php echo esc_attr( $value['type'] ); ?>" |
|
328 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
329 | - value="<?php echo esc_attr( $option_value ); ?>" |
|
330 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
331 | - placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>" |
|
332 | - <?php echo implode(' ', $custom_attributes ); ?> |
|
325 | + name="<?php echo esc_attr($value['id']); ?>" |
|
326 | + id="<?php echo esc_attr($value['id']); ?>" |
|
327 | + type="<?php echo esc_attr($value['type']); ?>" |
|
328 | + style="<?php echo esc_attr($value['css']); ?>" |
|
329 | + value="<?php echo esc_attr($option_value); ?>" |
|
330 | + class="<?php echo esc_attr($value['class']); ?>" |
|
331 | + placeholder="<?php echo esc_attr($value['placeholder']); ?>" |
|
332 | + <?php echo implode(' ', $custom_attributes); ?> |
|
333 | 333 | /><?php echo $description; ?> |
334 | 334 | </td> |
335 | 335 | </tr><?php |
@@ -337,23 +337,23 @@ discard block |
||
337 | 337 | |
338 | 338 | // Textarea. |
339 | 339 | case 'textarea': |
340 | - $option_value = self::get_option( $value['id'], $value['default'] ); |
|
340 | + $option_value = self::get_option($value['id'], $value['default']); |
|
341 | 341 | ?> |
342 | 342 | <tr valign="top"> |
343 | 343 | <th scope="row" class="titledesc"> |
344 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label> |
|
344 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label> |
|
345 | 345 | </th> |
346 | - <td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>"> |
|
346 | + <td class="forminp forminp-<?php echo esc_attr(sanitize_title($value['type'])); ?>"> |
|
347 | 347 | <?php echo $description; ?> |
348 | 348 | |
349 | 349 | <textarea |
350 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
351 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
352 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
353 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
354 | - placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>" |
|
355 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
356 | - ><?php echo esc_textarea( $option_value ); ?></textarea> |
|
350 | + name="<?php echo esc_attr($value['id']); ?>" |
|
351 | + id="<?php echo esc_attr($value['id']); ?>" |
|
352 | + style="<?php echo esc_attr($value['css']); ?>" |
|
353 | + class="<?php echo esc_attr($value['class']); ?>" |
|
354 | + placeholder="<?php echo esc_attr($value['placeholder']); ?>" |
|
355 | + <?php echo implode(' ', $custom_attributes); ?> |
|
356 | + ><?php echo esc_textarea($option_value); ?></textarea> |
|
357 | 357 | </td> |
358 | 358 | </tr> |
359 | 359 | <?php |
@@ -362,35 +362,35 @@ discard block |
||
362 | 362 | // Select boxes. |
363 | 363 | case 'select': |
364 | 364 | case 'multiselect': |
365 | - $option_value = self::get_option( $value['id'], $value['default'] ); |
|
365 | + $option_value = self::get_option($value['id'], $value['default']); |
|
366 | 366 | ?> |
367 | 367 | <tr valign="top"> |
368 | 368 | <th scope="row" class="titledesc"> |
369 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label> |
|
369 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label> |
|
370 | 370 | </th> |
371 | - <td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>"> |
|
371 | + <td class="forminp forminp-<?php echo esc_attr(sanitize_title($value['type'])); ?>"> |
|
372 | 372 | <select |
373 | - name="<?php echo esc_attr( $value['id'] ); ?><?php echo ( 'multiselect' === $value['type'] ) ? '[]' : ''; ?>" |
|
374 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
375 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
376 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
377 | - data-placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>" |
|
378 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
373 | + name="<?php echo esc_attr($value['id']); ?><?php echo ('multiselect' === $value['type']) ? '[]' : ''; ?>" |
|
374 | + id="<?php echo esc_attr($value['id']); ?>" |
|
375 | + style="<?php echo esc_attr($value['css']); ?>" |
|
376 | + class="<?php echo esc_attr($value['class']); ?>" |
|
377 | + data-placeholder="<?php echo esc_attr($value['placeholder']); ?>" |
|
378 | + <?php echo implode(' ', $custom_attributes); ?> |
|
379 | 379 | <?php echo 'multiselect' === $value['type'] ? 'multiple="multiple"' : ''; ?> |
380 | 380 | > |
381 | 381 | <?php |
382 | - foreach ( $value['options'] as $key => $val ) { |
|
382 | + foreach ($value['options'] as $key => $val) { |
|
383 | 383 | ?> |
384 | - <option value="<?php echo esc_attr( $key ); ?>" |
|
384 | + <option value="<?php echo esc_attr($key); ?>" |
|
385 | 385 | <?php |
386 | - if ( is_array( $option_value ) ) { |
|
387 | - selected( in_array( (string) $key, $option_value, true ), true ); |
|
386 | + if (is_array($option_value)) { |
|
387 | + selected(in_array((string) $key, $option_value, true), true); |
|
388 | 388 | } else { |
389 | - selected( $option_value, (string) $key ); |
|
389 | + selected($option_value, (string) $key); |
|
390 | 390 | } |
391 | 391 | ?> |
392 | 392 | > |
393 | - <?php echo esc_html( $val ); ?></option> |
|
393 | + <?php echo esc_html($val); ?></option> |
|
394 | 394 | <?php |
395 | 395 | } |
396 | 396 | ?> |
@@ -402,29 +402,29 @@ discard block |
||
402 | 402 | |
403 | 403 | // Radio inputs. |
404 | 404 | case 'radio': |
405 | - $option_value = self::get_option( $value['id'], $value['default'] ); |
|
405 | + $option_value = self::get_option($value['id'], $value['default']); |
|
406 | 406 | ?> |
407 | 407 | <tr valign="top"> |
408 | 408 | <th scope="row" class="titledesc"> |
409 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label> |
|
409 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label> |
|
410 | 410 | </th> |
411 | - <td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>"> |
|
411 | + <td class="forminp forminp-<?php echo esc_attr(sanitize_title($value['type'])); ?>"> |
|
412 | 412 | <fieldset> |
413 | 413 | <?php echo $description; ?> |
414 | 414 | <ul> |
415 | 415 | <?php |
416 | - foreach ( $value['options'] as $key => $val ) { |
|
416 | + foreach ($value['options'] as $key => $val) { |
|
417 | 417 | ?> |
418 | 418 | <li> |
419 | 419 | <label><input |
420 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
421 | - value="<?php echo esc_attr( $key ); ?>" |
|
420 | + name="<?php echo esc_attr($value['id']); ?>" |
|
421 | + value="<?php echo esc_attr($key); ?>" |
|
422 | 422 | type="radio" |
423 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
424 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
425 | - <?php echo implode( ' ', $custom_attributes ); // WPCS: XSS ok. ?> |
|
426 | - <?php checked( $key, $option_value ); ?> |
|
427 | - /> <?php echo esc_html( $val ); ?></label> |
|
423 | + style="<?php echo esc_attr($value['css']); ?>" |
|
424 | + class="<?php echo esc_attr($value['class']); ?>" |
|
425 | + <?php echo implode(' ', $custom_attributes); // WPCS: XSS ok. ?> |
|
426 | + <?php checked($key, $option_value); ?> |
|
427 | + /> <?php echo esc_html($val); ?></label> |
|
428 | 428 | </li> |
429 | 429 | <?php |
430 | 430 | } |
@@ -438,58 +438,58 @@ discard block |
||
438 | 438 | |
439 | 439 | // Checkbox input. |
440 | 440 | case 'checkbox': |
441 | - $option_value = self::get_option( $value['id'], $value['default'] ); |
|
441 | + $option_value = self::get_option($value['id'], $value['default']); |
|
442 | 442 | $visibility_class = array(); |
443 | 443 | |
444 | - if ( ! isset( $value['hide_if_checked'] ) ) { |
|
444 | + if ( ! isset($value['hide_if_checked'])) { |
|
445 | 445 | $value['hide_if_checked'] = false; |
446 | 446 | } |
447 | - if ( ! isset( $value['show_if_checked'] ) ) { |
|
447 | + if ( ! isset($value['show_if_checked'])) { |
|
448 | 448 | $value['show_if_checked'] = false; |
449 | 449 | } |
450 | - if ( 'yes' === $value['hide_if_checked'] || 'yes' === $value['show_if_checked'] ) { |
|
450 | + if ('yes' === $value['hide_if_checked'] || 'yes' === $value['show_if_checked']) { |
|
451 | 451 | $visibility_class[] = 'hidden_option'; |
452 | 452 | } |
453 | - if ( 'option' === $value['hide_if_checked'] ) { |
|
453 | + if ('option' === $value['hide_if_checked']) { |
|
454 | 454 | $visibility_class[] = 'hide_options_if_checked'; |
455 | 455 | } |
456 | - if ( 'option' === $value['show_if_checked'] ) { |
|
456 | + if ('option' === $value['show_if_checked']) { |
|
457 | 457 | $visibility_class[] = 'show_options_if_checked'; |
458 | 458 | } |
459 | 459 | |
460 | - if ( ! isset( $value['checkboxgroup'] ) || 'start' === $value['checkboxgroup'] ) { |
|
460 | + if ( ! isset($value['checkboxgroup']) || 'start' === $value['checkboxgroup']) { |
|
461 | 461 | ?> |
462 | - <tr valign="top" class="<?php echo esc_attr( implode( ' ', $visibility_class ) ); ?>"> |
|
463 | - <th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ); ?></th> |
|
462 | + <tr valign="top" class="<?php echo esc_attr(implode(' ', $visibility_class)); ?>"> |
|
463 | + <th scope="row" class="titledesc"><?php echo esc_html($value['title']); ?></th> |
|
464 | 464 | <td class="forminp forminp-checkbox"> |
465 | 465 | <fieldset> |
466 | 466 | <?php |
467 | 467 | } else { |
468 | 468 | ?> |
469 | - <fieldset class="<?php echo esc_attr( implode( ' ', $visibility_class ) ); ?>"> |
|
469 | + <fieldset class="<?php echo esc_attr(implode(' ', $visibility_class)); ?>"> |
|
470 | 470 | <?php |
471 | 471 | } |
472 | 472 | |
473 | - if ( ! empty( $value['title'] ) ) { |
|
473 | + if ( ! empty($value['title'])) { |
|
474 | 474 | ?> |
475 | - <legend class="screen-reader-text"><span><?php echo esc_html( $value['title'] ); ?></span></legend> |
|
475 | + <legend class="screen-reader-text"><span><?php echo esc_html($value['title']); ?></span></legend> |
|
476 | 476 | <?php |
477 | 477 | } |
478 | 478 | ?> |
479 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"> |
|
479 | + <label for="<?php echo esc_attr($value['id']); ?>"> |
|
480 | 480 | <input |
481 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
482 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
481 | + name="<?php echo esc_attr($value['id']); ?>" |
|
482 | + id="<?php echo esc_attr($value['id']); ?>" |
|
483 | 483 | type="checkbox" |
484 | - class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>" |
|
484 | + class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>" |
|
485 | 485 | value="1" |
486 | - <?php checked( $option_value, 'yes' ); ?> |
|
487 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
486 | + <?php checked($option_value, 'yes'); ?> |
|
487 | + <?php echo implode(' ', $custom_attributes); ?> |
|
488 | 488 | /> <?php echo $description; ?> |
489 | 489 | </label> |
490 | 490 | <?php |
491 | 491 | |
492 | - if ( ! isset( $value['checkboxgroup'] ) || 'end' === $value['checkboxgroup'] ) { |
|
492 | + if ( ! isset($value['checkboxgroup']) || 'end' === $value['checkboxgroup']) { |
|
493 | 493 | ?> |
494 | 494 | </fieldset> |
495 | 495 | </td> |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | |
505 | 505 | // Default: run an action |
506 | 506 | default: |
507 | - do_action( 'auto_load_next_post_admin_field_' . $value['type'], $value ); |
|
507 | + do_action('auto_load_next_post_admin_field_'.$value['type'], $value); |
|
508 | 508 | |
509 | 509 | break; |
510 | 510 | } // end switch() |
@@ -523,8 +523,8 @@ discard block |
||
523 | 523 | * @param array $options Opens array to output |
524 | 524 | * @return bool |
525 | 525 | */ |
526 | - public static function save_fields( $options ) { |
|
527 | - if ( empty( $_POST ) ) { |
|
526 | + public static function save_fields($options) { |
|
527 | + if (empty($_POST)) { |
|
528 | 528 | return false; |
529 | 529 | } |
530 | 530 | |
@@ -533,48 +533,48 @@ discard block |
||
533 | 533 | $autoload_options = array(); |
534 | 534 | |
535 | 535 | // Loop options and get values to save |
536 | - foreach ( $options as $option ) { |
|
537 | - if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) { |
|
536 | + foreach ($options as $option) { |
|
537 | + if ( ! isset($option['id']) || ! isset($option['type'])) { |
|
538 | 538 | continue; |
539 | 539 | } |
540 | 540 | |
541 | 541 | // Get posted value. |
542 | - if ( strstr( $option['id'], '[' ) ) { |
|
543 | - parse_str( $option['id'], $option_name_array ); |
|
544 | - $option_name = current( array_keys( $option_name_array ) ); |
|
545 | - $setting_name = key( $option_name_array[ $option_name ] ); |
|
546 | - $raw_value = isset( $_POST[ $option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $option_name ][ $setting_name ] ) : null; |
|
542 | + if (strstr($option['id'], '[')) { |
|
543 | + parse_str($option['id'], $option_name_array); |
|
544 | + $option_name = current(array_keys($option_name_array)); |
|
545 | + $setting_name = key($option_name_array[$option_name]); |
|
546 | + $raw_value = isset($_POST[$option_name][$setting_name]) ? wp_unslash($_POST[$option_name][$setting_name]) : null; |
|
547 | 547 | } else { |
548 | 548 | $option_name = $option['id']; |
549 | 549 | $setting_name = ''; |
550 | - $raw_value = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null; |
|
550 | + $raw_value = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null; |
|
551 | 551 | } |
552 | 552 | |
553 | - switch ( $option['type'] ) { |
|
553 | + switch ($option['type']) { |
|
554 | 554 | case "checkbox" : |
555 | 555 | $value = '1' === $raw_value || 'yes' === $raw_value ? 'yes' : 'no'; |
556 | 556 | break; |
557 | 557 | |
558 | 558 | case "textarea" : |
559 | - $value = wp_kses_post( trim( stripslashes( $_POST[$option['id']] ) ) ); |
|
559 | + $value = wp_kses_post(trim(stripslashes($_POST[$option['id']]))); |
|
560 | 560 | break; |
561 | 561 | |
562 | 562 | case "multiselect" : |
563 | - $value = array_filter( array_map( 'auto_load_next_post_clean', (array) $raw_value ) ); |
|
563 | + $value = array_filter(array_map('auto_load_next_post_clean', (array) $raw_value)); |
|
564 | 564 | break; |
565 | 565 | |
566 | 566 | case 'select' : |
567 | - $allowed_values = empty( $option['options'] ) ? array() : array_map( 'strval', array_keys( $option['options'] ) ); |
|
568 | - if ( empty( $option['default'] ) && empty( $allowed_values ) ) { |
|
567 | + $allowed_values = empty($option['options']) ? array() : array_map('strval', array_keys($option['options'])); |
|
568 | + if (empty($option['default']) && empty($allowed_values)) { |
|
569 | 569 | $value = null; |
570 | 570 | break; |
571 | 571 | } |
572 | - $default = ( empty( $option['default'] ) ? $allowed_values[0] : $option['default'] ); |
|
573 | - $value = in_array( $raw_value, $allowed_values, true ) ? $raw_value : $default; |
|
572 | + $default = (empty($option['default']) ? $allowed_values[0] : $option['default']); |
|
573 | + $value = in_array($raw_value, $allowed_values, true) ? $raw_value : $default; |
|
574 | 574 | break; |
575 | 575 | |
576 | 576 | default : |
577 | - $value = auto_load_next_post_clean( $raw_value ); |
|
577 | + $value = auto_load_next_post_clean($raw_value); |
|
578 | 578 | break; |
579 | 579 | } // END switch() |
580 | 580 | |
@@ -583,59 +583,59 @@ discard block |
||
583 | 583 | * |
584 | 584 | * @deprecated 1.5.0 - doesn't allow manipulation of values! |
585 | 585 | */ |
586 | - if ( has_action( 'auto_load_next_post_update_option_' . sanitize_title( $option['type'] ) ) ) { |
|
587 | - if ( is_ajax() ) { |
|
588 | - error_log( 'auto_load_next_post_update_option_' . sanitize_title( $option['type'] ) . ' is deprecated since version 1.5.0' ); |
|
586 | + if (has_action('auto_load_next_post_update_option_'.sanitize_title($option['type']))) { |
|
587 | + if (is_ajax()) { |
|
588 | + error_log('auto_load_next_post_update_option_'.sanitize_title($option['type']).' is deprecated since version 1.5.0'); |
|
589 | 589 | } else { |
590 | - _deprecated_hook( 'auto_load_next_post_update_option_' . sanitize_title( $option['type'] ), '1.5.0' ); |
|
590 | + _deprecated_hook('auto_load_next_post_update_option_'.sanitize_title($option['type']), '1.5.0'); |
|
591 | 591 | } |
592 | 592 | |
593 | - do_action( 'auto_load_next_post_update_option_' . sanitize_title( $option['type'] ), $option ); |
|
593 | + do_action('auto_load_next_post_update_option_'.sanitize_title($option['type']), $option); |
|
594 | 594 | continue; |
595 | 595 | } |
596 | 596 | |
597 | - if ( is_null( $value ) ) { |
|
597 | + if (is_null($value)) { |
|
598 | 598 | continue; |
599 | 599 | } |
600 | 600 | |
601 | 601 | // Check if option is an array and handle that differently to single values. |
602 | - if ( $option_name && $setting_name ) { |
|
603 | - if ( ! isset( $update_options[ $option_name ] ) ) { |
|
604 | - $update_options[ $option_name ] = get_option( $option_name, array() ); |
|
602 | + if ($option_name && $setting_name) { |
|
603 | + if ( ! isset($update_options[$option_name])) { |
|
604 | + $update_options[$option_name] = get_option($option_name, array()); |
|
605 | 605 | } |
606 | - if ( ! is_array( $update_options[ $option_name ] ) ) { |
|
607 | - $update_options[ $option_name ] = array(); |
|
606 | + if ( ! is_array($update_options[$option_name])) { |
|
607 | + $update_options[$option_name] = array(); |
|
608 | 608 | } |
609 | - $update_options[ $option_name ][ $setting_name ] = $value; |
|
609 | + $update_options[$option_name][$setting_name] = $value; |
|
610 | 610 | } else { |
611 | - $update_options[ $option_name ] = $value; |
|
611 | + $update_options[$option_name] = $value; |
|
612 | 612 | } |
613 | 613 | |
614 | - $autoload_options[ $option_name ] = isset( $option['autoload'] ) ? (bool) $option['autoload'] : true; |
|
614 | + $autoload_options[$option_name] = isset($option['autoload']) ? (bool) $option['autoload'] : true; |
|
615 | 615 | |
616 | 616 | /** |
617 | 617 | * Fire an action before saved. |
618 | 618 | * |
619 | 619 | * @deprecated 1.5.0 - doesn't allow manipulation of values! |
620 | 620 | */ |
621 | - if ( has_action( 'auto_load_next_post_update_option' ) ) { |
|
622 | - if ( is_ajax() ) { |
|
623 | - error_log( 'auto_load_next_post_update_option is deprecated since version 1.5.0' ); |
|
621 | + if (has_action('auto_load_next_post_update_option')) { |
|
622 | + if (is_ajax()) { |
|
623 | + error_log('auto_load_next_post_update_option is deprecated since version 1.5.0'); |
|
624 | 624 | } else { |
625 | - _deprecated_hook( 'auto_load_next_post_update_option', '1.5.0' ); |
|
625 | + _deprecated_hook('auto_load_next_post_update_option', '1.5.0'); |
|
626 | 626 | } |
627 | 627 | |
628 | - do_action( 'auto_load_next_post_update_option', $option ); |
|
628 | + do_action('auto_load_next_post_update_option', $option); |
|
629 | 629 | } |
630 | 630 | } |
631 | 631 | |
632 | 632 | // Now save the options |
633 | - foreach ( $update_options as $name => $value ) { |
|
634 | - update_option( $name, $value, $autoload_options[ $name ] ? 'yes' : 'no' ); |
|
633 | + foreach ($update_options as $name => $value) { |
|
634 | + update_option($name, $value, $autoload_options[$name] ? 'yes' : 'no'); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | // Save all options as an array. Ready for export. |
638 | - update_option( 'auto_load_next_post_options', $update_options ); |
|
638 | + update_option('auto_load_next_post_options', $update_options); |
|
639 | 639 | |
640 | 640 | return true; |
641 | 641 | } // END save_fields() |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * The main instance of the plugin. |
27 | 27 | */ |
28 | -if ( ! class_exists( 'Auto_Load_Next_Post' ) ) { |
|
28 | +if ( ! class_exists('Auto_Load_Next_Post')) { |
|
29 | 29 | |
30 | 30 | class Auto_Load_Next_Post { |
31 | 31 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @return Auto_Load_Next_Post Single instance. |
60 | 60 | */ |
61 | 61 | public static function instance() { |
62 | - if ( is_null( self::$_instance ) ) { |
|
62 | + if (is_null(self::$_instance)) { |
|
63 | 63 | self::$_instance = new self(); |
64 | 64 | } |
65 | 65 | return self::$_instance; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function __clone() { |
76 | 76 | // Cloning instances of the class is forbidden |
77 | - _doing_it_wrong( __FUNCTION__, __( 'Cloning this object is forbidden.', 'auto-load-next-post' ), self::$version ); |
|
77 | + _doing_it_wrong(__FUNCTION__, __('Cloning this object is forbidden.', 'auto-load-next-post'), self::$version); |
|
78 | 78 | } // END __clone() |
79 | 79 | |
80 | 80 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @return void |
86 | 86 | */ |
87 | 87 | public function __wakeup() { |
88 | - _doing_it_wrong( __FUNCTION__, __( 'Unserializing instances of this class is forbidden.', 'auto-load-next-post' ), self::$version ); |
|
88 | + _doing_it_wrong(__FUNCTION__, __('Unserializing instances of this class is forbidden.', 'auto-load-next-post'), self::$version); |
|
89 | 89 | } // END __wakeup() |
90 | 90 | |
91 | 91 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * Auto Load Next Post is fully loaded. |
106 | 106 | */ |
107 | - do_action( 'auto_load_next_post_loaded' ); |
|
107 | + do_action('auto_load_next_post_loaded'); |
|
108 | 108 | } // END __construct() |
109 | 109 | |
110 | 110 | /** |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function init_hooks() { |
117 | 117 | // Load translation files. |
118 | - add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
|
118 | + add_action('init', array($this, 'load_plugin_textdomain')); |
|
119 | 119 | |
120 | 120 | // Load Auto Load Next Post scripts on the frontend. |
121 | - add_action( 'wp_enqueue_scripts', array( $this, 'alnp_enqueue_scripts' ) ); |
|
121 | + add_action('wp_enqueue_scripts', array($this, 'alnp_enqueue_scripts')); |
|
122 | 122 | } // END init_hooks() |
123 | 123 | |
124 | 124 | /** |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | $this->define('AUTO_LOAD_NEXT_POST_FILE', __FILE__); |
134 | 134 | $this->define('AUTO_LOAD_NEXT_POST_SLUG', 'auto-load-next-post'); |
135 | 135 | |
136 | - $this->define('AUTO_LOAD_NEXT_POST_URL_PATH', untrailingslashit( plugins_url( '/', __FILE__ ) ) ); |
|
137 | - $this->define('AUTO_LOAD_NEXT_POST_FILE_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); |
|
136 | + $this->define('AUTO_LOAD_NEXT_POST_URL_PATH', untrailingslashit(plugins_url('/', __FILE__))); |
|
137 | + $this->define('AUTO_LOAD_NEXT_POST_FILE_PATH', untrailingslashit(plugin_dir_path(__FILE__))); |
|
138 | 138 | $this->define('AUTO_LOAD_NEXT_POST_TEMPLATE_PATH', 'auto-load-next-post/'); |
139 | 139 | |
140 | 140 | $this->define('AUTO_LOAD_NEXT_POST_WP_VERSION_REQUIRE', '4.4'); |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | * @access private |
159 | 159 | * @since 1.4.3 |
160 | 160 | */ |
161 | - private function define( $name, $value ) { |
|
162 | - if ( ! defined( $name ) ) { |
|
163 | - define( $name, $value ); |
|
161 | + private function define($name, $value) { |
|
162 | + if ( ! defined($name)) { |
|
163 | + define($name, $value); |
|
164 | 164 | } |
165 | 165 | } // END define() |
166 | 166 | |
@@ -173,26 +173,26 @@ discard block |
||
173 | 173 | * @return void |
174 | 174 | */ |
175 | 175 | public function includes() { |
176 | - include_once( dirname( __FILE__ ) . '/includes/class-alnp-autoloader.php' ); // Autoloader. |
|
177 | - include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-conditional-functions.php' ); // Conditional functions. |
|
178 | - include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-formatting-functions.php' ); // Formatting functions. |
|
179 | - include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-themes-supported.php' ); // Handles all supported themes out of the box. |
|
180 | - include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-core-functions.php' ); // Contains core functions for the front/back end. |
|
176 | + include_once(dirname(__FILE__).'/includes/class-alnp-autoloader.php'); // Autoloader. |
|
177 | + include_once(dirname(__FILE__).'/includes/auto-load-next-post-conditional-functions.php'); // Conditional functions. |
|
178 | + include_once(dirname(__FILE__).'/includes/auto-load-next-post-formatting-functions.php'); // Formatting functions. |
|
179 | + include_once(dirname(__FILE__).'/includes/auto-load-next-post-themes-supported.php'); // Handles all supported themes out of the box. |
|
180 | + include_once(dirname(__FILE__).'/includes/auto-load-next-post-core-functions.php'); // Contains core functions for the front/back end. |
|
181 | 181 | |
182 | 182 | // Include theme support. |
183 | 183 | alnp_include_theme_support(); |
184 | 184 | |
185 | 185 | // Customizer. |
186 | - include_once( dirname( __FILE__ ) . '/includes/customizer/class-alnp-customizer.php' ); |
|
187 | - include_once( dirname( __FILE__ ) . '/includes/customizer/class-alnp-customizer-scripts.php' ); |
|
186 | + include_once(dirname(__FILE__).'/includes/customizer/class-alnp-customizer.php'); |
|
187 | + include_once(dirname(__FILE__).'/includes/customizer/class-alnp-customizer-scripts.php'); |
|
188 | 188 | |
189 | 189 | // Include admin class to handle all back-end functions. |
190 | - if ( is_admin() ) { |
|
191 | - include_once( dirname( __FILE__ ) . '/includes/admin/class-alnp-admin.php' ); // Admin section. |
|
190 | + if (is_admin()) { |
|
191 | + include_once(dirname(__FILE__).'/includes/admin/class-alnp-admin.php'); // Admin section. |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | // Install. |
195 | - require_once( dirname( __FILE__ ) . '/includes/class-alnp-install.php' ); |
|
195 | + require_once(dirname(__FILE__).'/includes/class-alnp-install.php'); |
|
196 | 196 | } // END includes() |
197 | 197 | |
198 | 198 | /** |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @return void |
208 | 208 | */ |
209 | 209 | public function load_plugin_textdomain() { |
210 | - load_plugin_textdomain( 'auto-load-next-post', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
|
210 | + load_plugin_textdomain('auto-load-next-post', false, dirname(plugin_basename(__FILE__)).'/languages/'); |
|
211 | 211 | } // END load_plugin_textdomain() |
212 | 212 | |
213 | 213 | /** |
@@ -219,32 +219,32 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public function alnp_enqueue_scripts() { |
221 | 221 | // Load the Javascript if found as a singluar post and the user is not a bot. |
222 | - if ( !alnp_is_bot() && is_singular() && get_post_type() == 'post' ) { |
|
222 | + if ( ! alnp_is_bot() && is_singular() && get_post_type() == 'post') { |
|
223 | 223 | // This helps the plugin decide to load the JavaScript in the footer or not. |
224 | - $load_in_footer = get_option( 'auto_load_next_post_js_footer' ); |
|
224 | + $load_in_footer = get_option('auto_load_next_post_js_footer'); |
|
225 | 225 | |
226 | - $this->load_file( 'auto-load-next-post-scrollspy', '/assets/js/libs/scrollspy.min.js', true, array('jquery'), AUTO_LOAD_NEXT_POST_VERSION, $load_in_footer ); |
|
226 | + $this->load_file('auto-load-next-post-scrollspy', '/assets/js/libs/scrollspy.min.js', true, array('jquery'), AUTO_LOAD_NEXT_POST_VERSION, $load_in_footer); |
|
227 | 227 | |
228 | 228 | // Only load History.js when not in the customizer. |
229 | - if ( ! is_customize_preview() ) { |
|
230 | - $this->load_file( 'auto-load-next-post-history', '/assets/js/libs/jquery.history.js', true, array('jquery'), AUTO_LOAD_NEXT_POST_VERSION, $load_in_footer ); |
|
229 | + if ( ! is_customize_preview()) { |
|
230 | + $this->load_file('auto-load-next-post-history', '/assets/js/libs/jquery.history.js', true, array('jquery'), AUTO_LOAD_NEXT_POST_VERSION, $load_in_footer); |
|
231 | 231 | } |
232 | 232 | |
233 | - $this->load_file( 'auto-load-next-post-script', '/assets/js/frontend/auto-load-next-post' . AUTO_LOAD_NEXT_POST_DEBUG_MODE.AUTO_LOAD_NEXT_POST_SCRIPT_MODE . '.js', true, array('auto-load-next-post-scrollspy'), AUTO_LOAD_NEXT_POST_VERSION, $load_in_footer ); |
|
233 | + $this->load_file('auto-load-next-post-script', '/assets/js/frontend/auto-load-next-post'.AUTO_LOAD_NEXT_POST_DEBUG_MODE.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.js', true, array('auto-load-next-post-scrollspy'), AUTO_LOAD_NEXT_POST_VERSION, $load_in_footer); |
|
234 | 234 | |
235 | 235 | // Variables for the JavaScript |
236 | - wp_localize_script( 'auto-load-next-post-script', 'auto_load_next_post_params', array( |
|
236 | + wp_localize_script('auto-load-next-post-script', 'auto_load_next_post_params', array( |
|
237 | 237 | 'alnp_version' => AUTO_LOAD_NEXT_POST_VERSION, |
238 | - 'alnp_content_container' => get_option( 'auto_load_next_post_content_container' ), |
|
239 | - 'alnp_title_selector' => get_option( 'auto_load_next_post_title_selector' ), |
|
240 | - 'alnp_navigation_container' => get_option( 'auto_load_next_post_navigation_container' ), |
|
241 | - 'alnp_comments_container' => get_option( 'auto_load_next_post_comments_container' ), |
|
242 | - 'alnp_remove_comments' => get_option( 'auto_load_next_post_remove_comments' ), |
|
243 | - 'alnp_google_analytics' => get_option( 'auto_load_next_post_google_analytics' ), |
|
244 | - 'alnp_event_on_load' => get_option( 'auto_load_next_post_on_load_event' ), |
|
245 | - 'alnp_event_on_entering' => get_option( 'auto_load_next_post_on_entering_event' ), |
|
238 | + 'alnp_content_container' => get_option('auto_load_next_post_content_container'), |
|
239 | + 'alnp_title_selector' => get_option('auto_load_next_post_title_selector'), |
|
240 | + 'alnp_navigation_container' => get_option('auto_load_next_post_navigation_container'), |
|
241 | + 'alnp_comments_container' => get_option('auto_load_next_post_comments_container'), |
|
242 | + 'alnp_remove_comments' => get_option('auto_load_next_post_remove_comments'), |
|
243 | + 'alnp_google_analytics' => get_option('auto_load_next_post_google_analytics'), |
|
244 | + 'alnp_event_on_load' => get_option('auto_load_next_post_on_load_event'), |
|
245 | + 'alnp_event_on_entering' => get_option('auto_load_next_post_on_entering_event'), |
|
246 | 246 | 'alnp_is_customizer' => $this->is_alnp_using_customizer(), |
247 | - ) ); |
|
247 | + )); |
|
248 | 248 | } // END if is_singular() && get_post_type() |
249 | 249 | } // END alnp_enqueue_scripts() |
250 | 250 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @return string|boolean |
258 | 258 | */ |
259 | 259 | public static function is_alnp_using_customizer() { |
260 | - if ( is_customize_preview() ) { |
|
260 | + if (is_customize_preview()) { |
|
261 | 261 | return "yes"; |
262 | 262 | } |
263 | 263 | |
@@ -279,21 +279,21 @@ discard block |
||
279 | 279 | * @param bool $footer Optional, can set the JavaScript to load in the footer instead. |
280 | 280 | * @global string $wp_version |
281 | 281 | */ |
282 | - public static function load_file( $name, $file_path, $is_script = false, $support = array(), $version = '', $footer = false ) { |
|
282 | + public static function load_file($name, $file_path, $is_script = false, $support = array(), $version = '', $footer = false) { |
|
283 | 283 | global $wp_version; |
284 | 284 | |
285 | - $url = AUTO_LOAD_NEXT_POST_URL_PATH . $file_path; // URL to the file. |
|
285 | + $url = AUTO_LOAD_NEXT_POST_URL_PATH.$file_path; // URL to the file. |
|
286 | 286 | |
287 | - if ( file_exists( AUTO_LOAD_NEXT_POST_FILE_PATH . $file_path ) ) { |
|
288 | - if ( $is_script ) { |
|
289 | - if ( !wp_script_is( $name, 'registered' ) ) { |
|
290 | - wp_register_script( $name, $url, $support, $version, $footer ); |
|
291 | - wp_enqueue_script( $name ); |
|
287 | + if (file_exists(AUTO_LOAD_NEXT_POST_FILE_PATH.$file_path)) { |
|
288 | + if ($is_script) { |
|
289 | + if ( ! wp_script_is($name, 'registered')) { |
|
290 | + wp_register_script($name, $url, $support, $version, $footer); |
|
291 | + wp_enqueue_script($name); |
|
292 | 292 | } |
293 | 293 | } else { |
294 | - if ( !wp_style_is( $name, 'registered' ) ) { |
|
295 | - wp_register_style( $name, $url ); |
|
296 | - wp_enqueue_style( $name ); |
|
294 | + if ( ! wp_style_is($name, 'registered')) { |
|
295 | + wp_register_style($name, $url); |
|
296 | + wp_enqueue_style($name); |
|
297 | 297 | } |
298 | 298 | } // end if |
299 | 299 | } // end if |