Completed
Branch codeclean (07bbe5)
by Sébastien
01:40
created
auto-load-next-post.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 		 * @access public
260 260
 		 * @since  1.5.0
261 261
 		 * @static
262
-		 * @return string|boolean
262
+		 * @return string|false
263 263
 		 */
264 264
 		public static function is_alnp_using_customizer() {
265 265
 			if ( is_customize_preview() ) {
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 		 * @param   string  $name      The ID to register with WordPress.
280 280
 		 * @param   string  $file_path The path to the actual file.
281 281
 		 * @param   bool    $is_script Optional, argument for if the incoming file_path is a JavaScript source file.
282
-		 * @param   array   $support   Optional, for requiring other javascripts for the source file you are calling.
282
+		 * @param   string[]   $support   Optional, for requiring other javascripts for the source file you are calling.
283 283
 		 * @param   string  $version   Optional, can match the version of the plugin or version of the source file.
284 284
 		 * @param   bool    $footer Optional, can set the JavaScript to load in the footer instead.
285 285
 		 */
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,10 +133,10 @@  discard block
 block discarded – undo
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
-			$this->define('AUTO_LOAD_NEXT_POST_3RD_PARTY', AUTO_LOAD_NEXT_POST_FILE_PATH . '/includes/3rd-party/');
139
+			$this->define('AUTO_LOAD_NEXT_POST_3RD_PARTY', AUTO_LOAD_NEXT_POST_FILE_PATH.'/includes/3rd-party/');
140 140
 
141 141
 			$this->define('AUTO_LOAD_NEXT_POST_WP_VERSION_REQUIRE', '4.4');
142 142
 
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 		 * @access private
160 160
 		 * @since  1.4.3
161 161
 		 */
162
-		private function define( $name, $value ) {
163
-			if ( ! defined( $name ) ) {
164
-				define( $name, $value );
162
+		private function define($name, $value) {
163
+			if ( ! defined($name)) {
164
+				define($name, $value);
165 165
 			}
166 166
 		} // END define()
167 167
 
@@ -174,29 +174,29 @@  discard block
 block discarded – undo
174 174
 		 * @return  void
175 175
 		 */
176 176
 		public function includes() {
177
-			include_once( dirname( __FILE__ ) . '/includes/class-alnp-autoloader.php' ); // Autoloader.
178
-			include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-conditional-functions.php' ); // Conditional functions.
179
-			include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-formatting-functions.php' ); // Formatting functions.
180
-			include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-themes-supported.php' ); // Handles all supported themes out of the box.
181
-			include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-core-functions.php' ); // Contains core functions for the front/back end.
177
+			include_once(dirname(__FILE__).'/includes/class-alnp-autoloader.php'); // Autoloader.
178
+			include_once(dirname(__FILE__).'/includes/auto-load-next-post-conditional-functions.php'); // Conditional functions.
179
+			include_once(dirname(__FILE__).'/includes/auto-load-next-post-formatting-functions.php'); // Formatting functions.
180
+			include_once(dirname(__FILE__).'/includes/auto-load-next-post-themes-supported.php'); // Handles all supported themes out of the box.
181
+			include_once(dirname(__FILE__).'/includes/auto-load-next-post-core-functions.php'); // Contains core functions for the front/back end.
182 182
 
183 183
 			// Include theme support.
184 184
 			alnp_include_theme_support();
185 185
 
186 186
 			// 3rd Party support.
187
-			include_once( dirname( __FILE__ ) . '/includes/3rd-party/3rd-party.php' );
187
+			include_once(dirname(__FILE__).'/includes/3rd-party/3rd-party.php');
188 188
 
189 189
 			// Customizer.
190
-			include_once( dirname( __FILE__ ) . '/includes/customizer/class-alnp-customizer.php' );
191
-			include_once( dirname( __FILE__ ) . '/includes/customizer/class-alnp-customizer-scripts.php' );
190
+			include_once(dirname(__FILE__).'/includes/customizer/class-alnp-customizer.php');
191
+			include_once(dirname(__FILE__).'/includes/customizer/class-alnp-customizer-scripts.php');
192 192
 
193 193
 			// Include admin class to handle all back-end functions.
194
-			if ( is_admin() ) {
195
-				include_once( dirname( __FILE__ ) . '/includes/admin/class-alnp-admin.php' ); // Admin section.
194
+			if (is_admin()) {
195
+				include_once(dirname(__FILE__).'/includes/admin/class-alnp-admin.php'); // Admin section.
196 196
 			}
197 197
 
198 198
 			// Install.
199
-			require_once( dirname( __FILE__ ) . '/includes/class-alnp-install.php' );
199
+			require_once(dirname(__FILE__).'/includes/class-alnp-install.php');
200 200
 		} // END includes()
201 201
 
202 202
 		/**
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 		 * @return  void
212 212
 		 */
213 213
 		public function load_plugin_textdomain() {
214
-			load_plugin_textdomain( 'auto-load-next-post', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
214
+			load_plugin_textdomain('auto-load-next-post', false, dirname(plugin_basename(__FILE__)).'/languages/');
215 215
 		} // END load_plugin_textdomain()
216 216
 
217 217
 		/**
@@ -223,33 +223,33 @@  discard block
 block discarded – undo
223 223
 		 */
224 224
 		public function alnp_enqueue_scripts() {
225 225
 			// Load the Javascript if found as a singluar post and the user is not a bot.
226
-			if ( !alnp_is_bot() && is_singular() && get_post_type() == 'post' ) {
226
+			if ( ! alnp_is_bot() && is_singular() && get_post_type() == 'post') {
227 227
 				// This checks to see if the JavaScript should load in the footer or not.
228 228
 				$load_in_footer = alnp_load_js_in_footer();
229 229
 
230
-				$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 );
230
+				$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);
231 231
 
232 232
 				// Only load History.js when not in the customizer.
233
-				if ( ! is_customize_preview() ) {
234
-					$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 );
233
+				if ( ! is_customize_preview()) {
234
+					$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);
235 235
 				}
236 236
 
237
-				$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 );
237
+				$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);
238 238
 
239 239
 				// Variables for the JavaScript
240
-				wp_localize_script( 'auto-load-next-post-script', 'auto_load_next_post_params', array(
240
+				wp_localize_script('auto-load-next-post-script', 'auto_load_next_post_params', array(
241 241
 					'alnp_version'              => AUTO_LOAD_NEXT_POST_VERSION,
242
-					'alnp_content_container'    => get_option( 'auto_load_next_post_content_container' ),
243
-					'alnp_title_selector'       => get_option( 'auto_load_next_post_title_selector' ),
244
-					'alnp_navigation_container' => get_option( 'auto_load_next_post_navigation_container' ),
245
-					'alnp_comments_container'   => get_option( 'auto_load_next_post_comments_container' ),
246
-					'alnp_remove_comments'      => get_option( 'auto_load_next_post_remove_comments' ),
247
-					'alnp_google_analytics'     => get_option( 'auto_load_next_post_google_analytics' ),
248
-					'alnp_event_on_load'        => get_option( 'auto_load_next_post_on_load_event' ),
249
-					'alnp_event_on_entering'    => get_option( 'auto_load_next_post_on_entering_event' ),
242
+					'alnp_content_container'    => get_option('auto_load_next_post_content_container'),
243
+					'alnp_title_selector'       => get_option('auto_load_next_post_title_selector'),
244
+					'alnp_navigation_container' => get_option('auto_load_next_post_navigation_container'),
245
+					'alnp_comments_container'   => get_option('auto_load_next_post_comments_container'),
246
+					'alnp_remove_comments'      => get_option('auto_load_next_post_remove_comments'),
247
+					'alnp_google_analytics'     => get_option('auto_load_next_post_google_analytics'),
248
+					'alnp_event_on_load'        => get_option('auto_load_next_post_on_load_event'),
249
+					'alnp_event_on_entering'    => get_option('auto_load_next_post_on_entering_event'),
250 250
 					'alnp_is_customizer'        => $this->is_alnp_using_customizer(),
251 251
 					'alnp_load_in_footer'       => $load_in_footer
252
-				) );
252
+				));
253 253
 			} // END if is_singular() && get_post_type()
254 254
 		} // END alnp_enqueue_scripts()
255 255
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 		 * @return string|boolean
263 263
 		 */
264 264
 		public static function is_alnp_using_customizer() {
265
-			if ( is_customize_preview() ) {
265
+			if (is_customize_preview()) {
266 266
 				return "yes";
267 267
 			}
268 268
 
@@ -283,19 +283,19 @@  discard block
 block discarded – undo
283 283
 		 * @param   string  $version   Optional, can match the version of the plugin or version of the source file.
284 284
 		 * @param   bool    $footer Optional, can set the JavaScript to load in the footer instead.
285 285
 		 */
286
-		public static function load_file( $name, $file_path, $is_script = false, $support = array(), $version = '', $footer = false ) {
287
-			$url = AUTO_LOAD_NEXT_POST_URL_PATH . $file_path; // URL to the file.
288
-
289
-			if ( file_exists( AUTO_LOAD_NEXT_POST_FILE_PATH . $file_path ) ) {
290
-				if ( $is_script ) {
291
-					if ( !wp_script_is( $name, 'registered' ) ) {
292
-						wp_register_script( $name, $url, $support, $version, $footer );
293
-						wp_enqueue_script( $name );
286
+		public static function load_file($name, $file_path, $is_script = false, $support = array(), $version = '', $footer = false) {
287
+			$url = AUTO_LOAD_NEXT_POST_URL_PATH.$file_path; // URL to the file.
288
+
289
+			if (file_exists(AUTO_LOAD_NEXT_POST_FILE_PATH.$file_path)) {
290
+				if ($is_script) {
291
+					if ( ! wp_script_is($name, 'registered')) {
292
+						wp_register_script($name, $url, $support, $version, $footer);
293
+						wp_enqueue_script($name);
294 294
 					}
295 295
 				} else {
296
-					if ( !wp_style_is( $name, 'registered' ) ) {
297
-						wp_register_style( $name, $url );
298
-						wp_enqueue_style( $name );
296
+					if ( ! wp_style_is($name, 'registered')) {
297
+						wp_register_style($name, $url);
298
+						wp_enqueue_style($name);
299 299
 					}
300 300
 				} // end if
301 301
 			} // end if
Please login to merge, or discard this patch.
includes/auto-load-next-post-core-functions.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 // Exit if accessed directly.
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
  * @version 1.5.4
27 27
  * @global  WP_Query $wp_query - The object information defining the current request and determines what type of query it's dealing with. See https://codex.wordpress.org/Class_Reference/WP_Query
28 28
  */
29
-if ( ! function_exists( 'auto_load_next_post_template_redirect' ) ) {
29
+if ( ! function_exists('auto_load_next_post_template_redirect')) {
30 30
 	function auto_load_next_post_template_redirect() {
31 31
 		global $wp_query;
32 32
 
33 33
 		// If this is not a request for alnp or a singular object then bail
34
-		if ( ! isset( $wp_query->query_vars['alnp'] ) || ! is_singular() ) {
34
+		if ( ! isset($wp_query->query_vars['alnp']) || ! is_singular()) {
35 35
 			return;
36 36
 		}
37 37
 
@@ -40,28 +40,28 @@  discard block
 block discarded – undo
40 40
 		 * If theme does not have a template file for Auto Load Next Post,
41 41
 		 * the plugin will load a default template.
42 42
 		 */
43
-		$child_path    = get_stylesheet_directory() . '/' . AUTO_LOAD_NEXT_POST_TEMPLATE_PATH;
44
-		$template_path = get_template_directory() . '/' . AUTO_LOAD_NEXT_POST_TEMPLATE_PATH;
43
+		$child_path    = get_stylesheet_directory().'/'.AUTO_LOAD_NEXT_POST_TEMPLATE_PATH;
44
+		$template_path = get_template_directory().'/'.AUTO_LOAD_NEXT_POST_TEMPLATE_PATH;
45 45
 		$default_path  = AUTO_LOAD_NEXT_POST_FILE_PATH;
46 46
 
47
-		if ( file_exists( $child_path . 'content-alnp.php' ) ) {
48
-			$template_redirect = $child_path . 'content-alnp.php';
47
+		if (file_exists($child_path.'content-alnp.php')) {
48
+			$template_redirect = $child_path.'content-alnp.php';
49 49
 		}
50
-		else if( file_exists( $template_path . 'content-alnp.php') ) {
51
-			$template_redirect = $template_path . 'content-alnp.php';
50
+		else if (file_exists($template_path.'content-alnp.php')) {
51
+			$template_redirect = $template_path.'content-alnp.php';
52 52
 		}
53
-		else if( file_exists( $default_path . '/template/content-alnp.php' ) ) {
54
-			$template_redirect = $default_path . '/template/content-alnp.php';
53
+		else if (file_exists($default_path.'/template/content-alnp.php')) {
54
+			$template_redirect = $default_path.'/template/content-alnp.php';
55 55
 		}
56 56
 
57
-		$template_redirect = apply_filters( 'alnp_template_redirect', $template_redirect );
57
+		$template_redirect = apply_filters('alnp_template_redirect', $template_redirect);
58 58
 
59
-		include( $template_redirect );
59
+		include($template_redirect);
60 60
 
61 61
 		exit;
62 62
 	} // END auto_load_next_post_template_redirect()
63 63
 }
64
-add_action( 'template_redirect', 'auto_load_next_post_template_redirect' );
64
+add_action('template_redirect', 'auto_load_next_post_template_redirect');
65 65
 
66 66
 /**
67 67
  * Adds the comments template after the post content.
@@ -70,15 +70,15 @@  discard block
 block discarded – undo
70 70
  * @since   1.4.8
71 71
  * @version 1.5.4
72 72
  */
73
-if ( ! function_exists( 'auto_load_next_post_comments' ) ) {
73
+if ( ! function_exists('auto_load_next_post_comments')) {
74 74
 	function auto_load_next_post_comments() {
75 75
 		// If comments are open or we have at least one comment, load up the comment template.
76
-		if ( comments_open() || get_comments_number() ) :
76
+		if (comments_open() || get_comments_number()) :
77 77
 			comments_template();
78 78
 		endif;
79 79
 	} // END auto_load_next_post_comments()
80 80
 }
81
-add_action( 'alnp_load_after_content', 'auto_load_next_post_comments', 1, 5 );
81
+add_action('alnp_load_after_content', 'auto_load_next_post_comments', 1, 5);
82 82
 
83 83
 /**
84 84
  * Adds the post navigation for the previous link only after the post content.
@@ -87,16 +87,16 @@  discard block
 block discarded – undo
87 87
  * @since   1.4.8
88 88
  * @version 1.5.4
89 89
  */
90
-if ( ! function_exists( 'auto_load_next_post_navigation' ) ) {
90
+if ( ! function_exists('auto_load_next_post_navigation')) {
91 91
 	function auto_load_next_post_navigation() {
92 92
 	?>
93 93
 	<nav class="navigation post-navigation" role="navigation">
94
-		<span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'auto-load-next-post' ) . '</span> %title' ); ?></span>
94
+		<span class="nav-previous"><?php previous_post_link('%link', '<span class="meta-nav">'._x('&larr;', 'Previous post link', 'auto-load-next-post').'</span> %title'); ?></span>
95 95
 	</nav>
96 96
 	<?php
97 97
 	} // END auto_load_next_post_navigation()
98 98
 }
99
-add_action( 'alnp_load_after_content', 'auto_load_next_post_navigation', 1, 10 );
99
+add_action('alnp_load_after_content', 'auto_load_next_post_navigation', 1, 10);
100 100
 
101 101
 /**
102 102
  * Returns the permalink of a random page
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
  * @param  string $post_type - Default is post.
106 106
  * @return int|boolean
107 107
  */
108
-if ( ! function_exists( 'alnp_get_random_page_permalink' ) ) {
109
-	function alnp_get_random_page_permalink( $post_type = 'post' ) {
108
+if ( ! function_exists('alnp_get_random_page_permalink')) {
109
+	function alnp_get_random_page_permalink($post_type = 'post') {
110 110
 		$args = array(
111 111
 			'post_type'      => $post_type,
112 112
 			'post_status'    => 'publish',
@@ -114,13 +114,13 @@  discard block
 block discarded – undo
114 114
 			'posts_per_page' => 1
115 115
 		);
116 116
 
117
-		$query = new WP_Query( $args );
117
+		$query = new WP_Query($args);
118 118
 
119
-		if ( $query->have_posts() ) {
120
-			while ( $query->have_posts() ) : $query->the_post();
119
+		if ($query->have_posts()) {
120
+			while ($query->have_posts()) : $query->the_post();
121 121
 				$id = get_the_ID();
122 122
 
123
-				return get_permalink( $id );
123
+				return get_permalink($id);
124 124
 			endwhile;
125 125
 		}
126 126
 		else {
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
  * @since 1.5.7
136 136
  * @return boolean
137 137
  */
138
-if ( ! function_exists( 'alnp_load_js_in_footer' ) ) {
138
+if ( ! function_exists('alnp_load_js_in_footer')) {
139 139
 	function alnp_load_js_in_footer() {
140
-		$load_in_footer = get_option( 'auto_load_next_post_load_js_in_footer', false );
140
+		$load_in_footer = get_option('auto_load_next_post_load_js_in_footer', false);
141 141
 
142
-		if ( isset( $load_in_footer ) && $load_in_footer == 'yes' ) {
142
+		if (isset($load_in_footer) && $load_in_footer == 'yes') {
143 143
 			return true;
144 144
 		}
145 145
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
  * @since  1.5.11
155 155
  * @return array
156 156
  */
157
-if ( ! function_exists( 'alnp_get_admin_screens' ) ) {
157
+if ( ! function_exists('alnp_get_admin_screens')) {
158 158
 	function alnp_get_admin_screens() {
159 159
 		$show_on_screens = array(
160 160
 			'dashboard',
Please login to merge, or discard this patch.
includes/admin/class-alnp-admin-settings.php 1 patch
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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()
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 		 * @return  void
153 153
 		 */
154 154
 		public static function output() {
155
-			do_action( 'auto_load_next_post_settings_start' );
155
+			do_action('auto_load_next_post_settings_start');
156 156
 
157
-			include( dirname( __FILE__ ) . '/views/html-admin-settings.php' );
157
+			include(dirname(__FILE__).'/views/html-admin-settings.php');
158 158
 		} // END output()
159 159
 
160 160
 		/**
@@ -166,33 +166,33 @@  discard block
 block discarded – undo
166 166
 		 * @param  mixed $option_name
167 167
 		 * @return string
168 168
 		 */
169
-		public static function get_option( $option_name, $default = '' ) {
169
+		public static function get_option($option_name, $default = '') {
170 170
 			// Array value
171
-			if ( strstr( $option_name, '[' ) ) {
172
-				parse_str( $option_name, $option_array );
171
+			if (strstr($option_name, '[')) {
172
+				parse_str($option_name, $option_array);
173 173
 
174 174
 				// Option name is first key
175
-				$option_name = current( array_keys( $option_array ) );
175
+				$option_name = current(array_keys($option_array));
176 176
 
177 177
 				// Get value
178
-				$option_values = get_option( $option_name, '' );
178
+				$option_values = get_option($option_name, '');
179 179
 
180
-				$key = key( $option_array[$option_name] );
180
+				$key = key($option_array[$option_name]);
181 181
 
182
-				if ( isset( $option_values[$key] ) ) {
182
+				if (isset($option_values[$key])) {
183 183
 					$option_value = $option_values[$key];
184 184
 				} else {
185 185
 					$option_value = null;
186 186
 				}
187 187
 			} else {
188 188
 				// Single value
189
-				$option_value = get_option( $option_name, null );
189
+				$option_value = get_option($option_name, null);
190 190
 			}
191 191
 
192
-			if ( is_array( $option_value ) ) {
193
-				$option_value = array_map( 'stripslashes', $option_value );
194
-			} elseif ( ! is_null( $option_value ) ) {
195
-				$option_value = stripslashes( $option_value );
192
+			if (is_array($option_value)) {
193
+				$option_value = array_map('stripslashes', $option_value);
194
+			} elseif ( ! is_null($option_value)) {
195
+				$option_value = stripslashes($option_value);
196 196
 			}
197 197
 
198 198
 			return $option_value === null ? $default : $option_value;
@@ -209,84 +209,84 @@  discard block
 block discarded – undo
209 209
 		 * @version 1.5.0
210 210
 		 * @param   array $options Opens array to output
211 211
 		 */
212
-		public static function output_fields( $options ) {
213
-			foreach ( $options as $key => $value ) {
212
+		public static function output_fields($options) {
213
+			foreach ($options as $key => $value) {
214 214
 
215
-			if ( ! isset( $value['type'] ) ) {
215
+			if ( ! isset($value['type'])) {
216 216
 					continue;
217 217
 				}
218
-				if ( ! isset( $value['id'] ) ) {
218
+				if ( ! isset($value['id'])) {
219 219
 					$value['id'] = '';
220 220
 				}
221
-				if ( ! isset( $value['title'] ) ) {
222
-					$value['title'] = isset( $value['name'] ) ? $value['name'] : '';
221
+				if ( ! isset($value['title'])) {
222
+					$value['title'] = isset($value['name']) ? $value['name'] : '';
223 223
 				}
224
-				if ( ! isset( $value['class'] ) ) {
224
+				if ( ! isset($value['class'])) {
225 225
 					$value['class'] = '';
226 226
 				}
227
-				if ( ! isset( $value['css'] ) ) {
227
+				if ( ! isset($value['css'])) {
228 228
 					$value['css'] = '';
229 229
 				}
230
-				if ( ! isset( $value['default'] ) ) {
230
+				if ( ! isset($value['default'])) {
231 231
 					$value['default'] = '';
232 232
 				}
233
-				if ( ! isset( $value['desc'] ) ) {
233
+				if ( ! isset($value['desc'])) {
234 234
 					$value['desc'] = '';
235 235
 				}
236
-				if ( ! isset( $value['placeholder'] ) ) {
236
+				if ( ! isset($value['placeholder'])) {
237 237
 					$value['placeholder'] = '';
238 238
 				}
239 239
 
240 240
 				// Custom attribute handling
241 241
 				$custom_attributes = array();
242 242
 
243
-				if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) ) {
244
-					foreach ( $value['custom_attributes'] as $attribute => $attribute_value ) {
245
-						$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
243
+				if ( ! empty($value['custom_attributes']) && is_array($value['custom_attributes'])) {
244
+					foreach ($value['custom_attributes'] as $attribute => $attribute_value) {
245
+						$custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"';
246 246
 					}
247 247
 				}
248 248
 
249 249
 				// Description handling
250
-				if ( ! empty( $value['desc'] ) ) {
250
+				if ( ! empty($value['desc'])) {
251 251
 					$description = $value['desc'];
252 252
 				}
253 253
 
254
-				if ( $description && in_array( $value['type'], array( 'textarea', 'radio' ), true ) ) {
255
-					$description = '<p style="margin-top:0">' . wp_kses_post( $description ) . '</p>';
256
-				} elseif ( $description && in_array( $value['type'], array( 'checkbox' ), true ) ) {
257
-					$description = wp_kses_post( $description );
258
-				} elseif ( $description ) {
259
-					$description = '<p class="description">' . wp_kses_post( $description ) . '</p>';
254
+				if ($description && in_array($value['type'], array('textarea', 'radio'), true)) {
255
+					$description = '<p style="margin-top:0">'.wp_kses_post($description).'</p>';
256
+				} elseif ($description && in_array($value['type'], array('checkbox'), true)) {
257
+					$description = wp_kses_post($description);
258
+				} elseif ($description) {
259
+					$description = '<p class="description">'.wp_kses_post($description).'</p>';
260 260
 				}
261 261
 
262 262
 				// Switch based on type
263
-				switch( $value['type'] ) {
263
+				switch ($value['type']) {
264 264
 
265 265
 					// Section Titles
266 266
 					case 'title':
267
-						if ( ! empty( $value['title'] ) ) {
268
-							echo '<h2>' . esc_html( $value['title'] ) . '</h2>';
267
+						if ( ! empty($value['title'])) {
268
+							echo '<h2>'.esc_html($value['title']).'</h2>';
269 269
 						}
270
-						if ( ! empty( $value['desc'] ) ) {
271
-							echo '<div id="' . esc_attr( sanitize_title( $value['id'] ) ) . '-description">';
272
-							echo wp_kses_post( wpautop( wptexturize( $value['desc'] ) ) );
270
+						if ( ! empty($value['desc'])) {
271
+							echo '<div id="'.esc_attr(sanitize_title($value['id'])).'-description">';
272
+							echo wp_kses_post(wpautop(wptexturize($value['desc'])));
273 273
 							echo '</div>';
274 274
 						}
275 275
 						echo '<table class="form-table">'."\n\n";
276
-						if ( ! empty( $value['id'] ) ) {
277
-							do_action( 'auto_load_next_post_settings_' . sanitize_title( $value['id'] ) );
276
+						if ( ! empty($value['id'])) {
277
+							do_action('auto_load_next_post_settings_'.sanitize_title($value['id']));
278 278
 						}
279 279
 
280 280
 						break;
281 281
 
282 282
 					// Section Ends
283 283
 					case 'sectionend':
284
-						if ( ! empty( $value['id'] ) ) {
285
-							do_action( 'auto_load_next_post_settings_' . sanitize_title( $value['id'] ) . '_end' );
284
+						if ( ! empty($value['id'])) {
285
+							do_action('auto_load_next_post_settings_'.sanitize_title($value['id']).'_end');
286 286
 						}
287 287
 						echo '</table>';
288
-						if ( ! empty( $value['id'] ) ) {
289
-							do_action( 'auto_load_next_post_settings_' . sanitize_title( $value['id'] ) . '_after' );
288
+						if ( ! empty($value['id'])) {
289
+							do_action('auto_load_next_post_settings_'.sanitize_title($value['id']).'_after');
290 290
 						}
291 291
 						break;
292 292
 
@@ -299,22 +299,22 @@  discard block
 block discarded – undo
299 299
 					case 'time':
300 300
 					case 'week':
301 301
 					case 'email':
302
-						$option_value = self::get_option( $value['id'], $value['default'] );
302
+						$option_value = self::get_option($value['id'], $value['default']);
303 303
 
304 304
 						?><tr valign="top">
305 305
 							<th scope="row" class="titledesc">
306
-								<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
306
+								<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
307 307
 							</th>
308
-							<td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>">
308
+							<td class="forminp forminp-<?php echo esc_attr(sanitize_title($value['type'])); ?>">
309 309
 								<input
310
-									name="<?php echo esc_attr( $value['id'] ); ?>"
311
-									id="<?php echo esc_attr( $value['id'] ); ?>"
312
-									type="<?php echo esc_attr( $value['type'] ); ?>"
313
-									style="<?php echo esc_attr( $value['css'] ); ?>"
314
-									value="<?php echo esc_attr( $option_value ); ?>"
315
-									class="<?php echo esc_attr( $value['class'] ); ?>"
316
-									placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>"
317
-									<?php echo implode(' ', $custom_attributes ); ?>
310
+									name="<?php echo esc_attr($value['id']); ?>"
311
+									id="<?php echo esc_attr($value['id']); ?>"
312
+									type="<?php echo esc_attr($value['type']); ?>"
313
+									style="<?php echo esc_attr($value['css']); ?>"
314
+									value="<?php echo esc_attr($option_value); ?>"
315
+									class="<?php echo esc_attr($value['class']); ?>"
316
+									placeholder="<?php echo esc_attr($value['placeholder']); ?>"
317
+									<?php echo implode(' ', $custom_attributes); ?>
318 318
 								/><?php echo $description; ?>
319 319
 							</td>
320 320
 						</tr><?php
@@ -322,23 +322,23 @@  discard block
 block discarded – undo
322 322
 
323 323
 					// Textarea.
324 324
 					case 'textarea':
325
-						$option_value = self::get_option( $value['id'], $value['default'] );
325
+						$option_value = self::get_option($value['id'], $value['default']);
326 326
 						?>
327 327
 						<tr valign="top">
328 328
 							<th scope="row" class="titledesc">
329
-								<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
329
+								<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
330 330
 							</th>
331
-							<td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>">
331
+							<td class="forminp forminp-<?php echo esc_attr(sanitize_title($value['type'])); ?>">
332 332
 								<?php echo $description; ?>
333 333
 
334 334
 								<textarea
335
-									name="<?php echo esc_attr( $value['id'] ); ?>"
336
-									id="<?php echo esc_attr( $value['id'] ); ?>"
337
-									style="<?php echo esc_attr( $value['css'] ); ?>"
338
-									class="<?php echo esc_attr( $value['class'] ); ?>"
339
-									placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>"
340
-									<?php echo implode( ' ', $custom_attributes ); ?>
341
-									><?php echo esc_textarea( $option_value ); ?></textarea>
335
+									name="<?php echo esc_attr($value['id']); ?>"
336
+									id="<?php echo esc_attr($value['id']); ?>"
337
+									style="<?php echo esc_attr($value['css']); ?>"
338
+									class="<?php echo esc_attr($value['class']); ?>"
339
+									placeholder="<?php echo esc_attr($value['placeholder']); ?>"
340
+									<?php echo implode(' ', $custom_attributes); ?>
341
+									><?php echo esc_textarea($option_value); ?></textarea>
342 342
 							</td>
343 343
 						</tr>
344 344
 						<?php
@@ -347,35 +347,35 @@  discard block
 block discarded – undo
347 347
 					// Select boxes.
348 348
 					case 'select':
349 349
 					case 'multiselect':
350
-						$option_value = self::get_option( $value['id'], $value['default'] );
350
+						$option_value = self::get_option($value['id'], $value['default']);
351 351
 						?>
352 352
 						<tr valign="top">
353 353
 							<th scope="row" class="titledesc">
354
-								<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
354
+								<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
355 355
 							</th>
356
-							<td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>">
356
+							<td class="forminp forminp-<?php echo esc_attr(sanitize_title($value['type'])); ?>">
357 357
 								<select
358
-									name="<?php echo esc_attr( $value['id'] ); ?><?php echo ( 'multiselect' === $value['type'] ) ? '[]' : ''; ?>"
359
-									id="<?php echo esc_attr( $value['id'] ); ?>"
360
-									style="<?php echo esc_attr( $value['css'] ); ?>"
361
-									class="<?php echo esc_attr( $value['class'] ); ?>"
362
-									data-placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>"
363
-									<?php echo implode( ' ', $custom_attributes ); ?>
358
+									name="<?php echo esc_attr($value['id']); ?><?php echo ('multiselect' === $value['type']) ? '[]' : ''; ?>"
359
+									id="<?php echo esc_attr($value['id']); ?>"
360
+									style="<?php echo esc_attr($value['css']); ?>"
361
+									class="<?php echo esc_attr($value['class']); ?>"
362
+									data-placeholder="<?php echo esc_attr($value['placeholder']); ?>"
363
+									<?php echo implode(' ', $custom_attributes); ?>
364 364
 									<?php echo 'multiselect' === $value['type'] ? 'multiple="multiple"' : ''; ?>
365 365
 									>
366 366
 									<?php
367
-									foreach ( $value['options'] as $key => $val ) {
367
+									foreach ($value['options'] as $key => $val) {
368 368
 										?>
369
-										<option value="<?php echo esc_attr( $key ); ?>"
369
+										<option value="<?php echo esc_attr($key); ?>"
370 370
 											<?php
371
-											if ( is_array( $option_value ) ) {
372
-												selected( in_array( (string) $key, $option_value, true ), true );
371
+											if (is_array($option_value)) {
372
+												selected(in_array((string) $key, $option_value, true), true);
373 373
 											} else {
374
-												selected( $option_value, (string) $key );
374
+												selected($option_value, (string) $key);
375 375
 											}
376 376
 											?>
377 377
 											>
378
-											<?php echo esc_html( $val ); ?></option>
378
+											<?php echo esc_html($val); ?></option>
379 379
 											<?php
380 380
 									}
381 381
 									?>
@@ -387,29 +387,29 @@  discard block
 block discarded – undo
387 387
 
388 388
 					// Radio inputs.
389 389
 					case 'radio':
390
-						$option_value = self::get_option( $value['id'], $value['default'] );
390
+						$option_value = self::get_option($value['id'], $value['default']);
391 391
 						?>
392 392
 						<tr valign="top">
393 393
 							<th scope="row" class="titledesc">
394
-								<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
394
+								<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
395 395
 							</th>
396
-							<td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>">
396
+							<td class="forminp forminp-<?php echo esc_attr(sanitize_title($value['type'])); ?>">
397 397
 								<fieldset>
398 398
 									<?php echo $description; ?>
399 399
 									<ul>
400 400
 									<?php
401
-									foreach ( $value['options'] as $key => $val ) {
401
+									foreach ($value['options'] as $key => $val) {
402 402
 										?>
403 403
 										<li>
404 404
 											<label><input
405
-													name="<?php echo esc_attr( $value['id'] ); ?>"
406
-													value="<?php echo esc_attr( $key ); ?>"
405
+													name="<?php echo esc_attr($value['id']); ?>"
406
+													value="<?php echo esc_attr($key); ?>"
407 407
 													type="radio"
408
-													style="<?php echo esc_attr( $value['css'] ); ?>"
409
-													class="<?php echo esc_attr( $value['class'] ); ?>"
410
-													<?php echo implode( ' ', $custom_attributes ); // WPCS: XSS ok. ?>
411
-													<?php checked( $key, $option_value ); ?>
412
-													/> <?php echo esc_html( $val ); ?></label>
408
+													style="<?php echo esc_attr($value['css']); ?>"
409
+													class="<?php echo esc_attr($value['class']); ?>"
410
+													<?php echo implode(' ', $custom_attributes); // WPCS: XSS ok. ?>
411
+													<?php checked($key, $option_value); ?>
412
+													/> <?php echo esc_html($val); ?></label>
413 413
 										</li>
414 414
 										<?php
415 415
 									}
@@ -423,58 +423,58 @@  discard block
 block discarded – undo
423 423
 
424 424
 					// Checkbox input.
425 425
 					case 'checkbox':
426
-						$option_value     = self::get_option( $value['id'], $value['default'] );
426
+						$option_value     = self::get_option($value['id'], $value['default']);
427 427
 						$visibility_class = array();
428 428
 
429
-						if ( ! isset( $value['hide_if_checked'] ) ) {
429
+						if ( ! isset($value['hide_if_checked'])) {
430 430
 							$value['hide_if_checked'] = false;
431 431
 						}
432
-						if ( ! isset( $value['show_if_checked'] ) ) {
432
+						if ( ! isset($value['show_if_checked'])) {
433 433
 							$value['show_if_checked'] = false;
434 434
 						}
435
-						if ( 'yes' === $value['hide_if_checked'] || 'yes' === $value['show_if_checked'] ) {
435
+						if ('yes' === $value['hide_if_checked'] || 'yes' === $value['show_if_checked']) {
436 436
 							$visibility_class[] = 'hidden_option';
437 437
 						}
438
-						if ( 'option' === $value['hide_if_checked'] ) {
438
+						if ('option' === $value['hide_if_checked']) {
439 439
 							$visibility_class[] = 'hide_options_if_checked';
440 440
 						}
441
-						if ( 'option' === $value['show_if_checked'] ) {
441
+						if ('option' === $value['show_if_checked']) {
442 442
 							$visibility_class[] = 'show_options_if_checked';
443 443
 						}
444 444
 
445
-						if ( ! isset( $value['checkboxgroup'] ) || 'start' === $value['checkboxgroup'] ) {
445
+						if ( ! isset($value['checkboxgroup']) || 'start' === $value['checkboxgroup']) {
446 446
 							?>
447
-								<tr valign="top" class="<?php echo esc_attr( implode( ' ', $visibility_class ) ); ?>">
448
-									<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ); ?></th>
447
+								<tr valign="top" class="<?php echo esc_attr(implode(' ', $visibility_class)); ?>">
448
+									<th scope="row" class="titledesc"><?php echo esc_html($value['title']); ?></th>
449 449
 									<td class="forminp forminp-checkbox">
450 450
 										<fieldset>
451 451
 							<?php
452 452
 						} else {
453 453
 							?>
454
-								<fieldset class="<?php echo esc_attr( implode( ' ', $visibility_class ) ); ?>">
454
+								<fieldset class="<?php echo esc_attr(implode(' ', $visibility_class)); ?>">
455 455
 							<?php
456 456
 						}
457 457
 
458
-						if ( ! empty( $value['title'] ) ) {
458
+						if ( ! empty($value['title'])) {
459 459
 							?>
460
-								<legend class="screen-reader-text"><span><?php echo esc_html( $value['title'] ); ?></span></legend>
460
+								<legend class="screen-reader-text"><span><?php echo esc_html($value['title']); ?></span></legend>
461 461
 							<?php
462 462
 						}
463 463
 						?>
464
-								<label for="<?php echo esc_attr( $value['id'] ); ?>">
464
+								<label for="<?php echo esc_attr($value['id']); ?>">
465 465
 									<input
466
-										name="<?php echo esc_attr( $value['id'] ); ?>"
467
-										id="<?php echo esc_attr( $value['id'] ); ?>"
466
+										name="<?php echo esc_attr($value['id']); ?>"
467
+										id="<?php echo esc_attr($value['id']); ?>"
468 468
 										type="checkbox"
469
-										class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>"
469
+										class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>"
470 470
 										value="1"
471
-										<?php checked( $option_value, 'yes' ); ?>
472
-										<?php echo implode( ' ', $custom_attributes ); ?>
471
+										<?php checked($option_value, 'yes'); ?>
472
+										<?php echo implode(' ', $custom_attributes); ?>
473 473
 									/> <?php echo $description; ?>
474 474
 								</label>
475 475
 								<?php
476 476
 
477
-								if ( ! isset( $value['checkboxgroup'] ) || 'end' === $value['checkboxgroup'] ) {
477
+								if ( ! isset($value['checkboxgroup']) || 'end' === $value['checkboxgroup']) {
478 478
 									?>
479 479
 										</fieldset>
480 480
 									</td>
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 
490 490
 					// Default: run an action
491 491
 					default:
492
-						do_action( 'auto_load_next_post_admin_field_' . $value['type'], $value );
492
+						do_action('auto_load_next_post_admin_field_'.$value['type'], $value);
493 493
 
494 494
 						break;
495 495
 				} // end switch()
@@ -508,8 +508,8 @@  discard block
 block discarded – undo
508 508
 		 * @param   array $options Opens array to output
509 509
 		 * @return  bool
510 510
 		 */
511
-		public static function save_fields( $options ) {
512
-			if ( empty( $_POST ) ) {
511
+		public static function save_fields($options) {
512
+			if (empty($_POST)) {
513 513
 				return false;
514 514
 			}
515 515
 
@@ -518,48 +518,48 @@  discard block
 block discarded – undo
518 518
 			$autoload_options = array();
519 519
 
520 520
 			// Loop options and get values to save
521
-			foreach ( $options as $option ) {
522
-				if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) {
521
+			foreach ($options as $option) {
522
+				if ( ! isset($option['id']) || ! isset($option['type'])) {
523 523
 					continue;
524 524
 				}
525 525
 
526 526
 				// Get posted value.
527
-				if ( strstr( $option['id'], '[' ) ) {
528
-					parse_str( $option['id'], $option_name_array );
529
-					$option_name  = current( array_keys( $option_name_array ) );
530
-					$setting_name = key( $option_name_array[ $option_name ] );
531
-					$raw_value    = isset( $_POST[ $option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $option_name ][ $setting_name ] ) : null;
527
+				if (strstr($option['id'], '[')) {
528
+					parse_str($option['id'], $option_name_array);
529
+					$option_name  = current(array_keys($option_name_array));
530
+					$setting_name = key($option_name_array[$option_name]);
531
+					$raw_value    = isset($_POST[$option_name][$setting_name]) ? wp_unslash($_POST[$option_name][$setting_name]) : null;
532 532
 				} else {
533 533
 					$option_name  = $option['id'];
534 534
 					$setting_name = '';
535
-					$raw_value    = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null;
535
+					$raw_value    = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null;
536 536
 				}
537 537
 
538
-				switch ( $option['type'] ) {
538
+				switch ($option['type']) {
539 539
 					case "checkbox" :
540 540
 						$value = '1' === $raw_value || 'yes' === $raw_value ? 'yes' : 'no';
541 541
 						break;
542 542
 
543 543
 					case "textarea" :
544
-						$value = wp_kses_post( trim( stripslashes( $_POST[$option['id']] ) ) );
544
+						$value = wp_kses_post(trim(stripslashes($_POST[$option['id']])));
545 545
 						break;
546 546
 
547 547
 					case "multiselect" :
548
-						$value = array_filter( array_map( 'auto_load_next_post_clean', (array) $raw_value ) );
548
+						$value = array_filter(array_map('auto_load_next_post_clean', (array) $raw_value));
549 549
 						break;
550 550
 
551 551
 					case 'select' :
552
-						$allowed_values = empty( $option['options'] ) ? array() : array_map( 'strval', array_keys( $option['options'] ) );
553
-						if ( empty( $option['default'] ) && empty( $allowed_values ) ) {
552
+						$allowed_values = empty($option['options']) ? array() : array_map('strval', array_keys($option['options']));
553
+						if (empty($option['default']) && empty($allowed_values)) {
554 554
 							$value = null;
555 555
 							break;
556 556
 						}
557
-						$default = ( empty( $option['default'] ) ? $allowed_values[0] : $option['default'] );
558
-						$value   = in_array( $raw_value, $allowed_values, true ) ? $raw_value : $default;
557
+						$default = (empty($option['default']) ? $allowed_values[0] : $option['default']);
558
+						$value   = in_array($raw_value, $allowed_values, true) ? $raw_value : $default;
559 559
 						break;
560 560
 
561 561
 					default :
562
-						$value = auto_load_next_post_clean( $raw_value );
562
+						$value = auto_load_next_post_clean($raw_value);
563 563
 						break;
564 564
 				} // END switch()
565 565
 
@@ -568,59 +568,59 @@  discard block
 block discarded – undo
568 568
 				 *
569 569
 				 * @deprecated 1.5.0 - doesn't allow manipulation of values!
570 570
 				 */
571
-				if ( has_action( 'auto_load_next_post_update_option_' . sanitize_title( $option['type'] ) ) ) {
572
-					if ( is_ajax() ) {
573
-						error_log( 'auto_load_next_post_update_option_' . sanitize_title( $option['type'] ) . ' is deprecated since version 1.5.0' );
571
+				if (has_action('auto_load_next_post_update_option_'.sanitize_title($option['type']))) {
572
+					if (is_ajax()) {
573
+						error_log('auto_load_next_post_update_option_'.sanitize_title($option['type']).' is deprecated since version 1.5.0');
574 574
 					} else {
575
-						_deprecated_hook( 'auto_load_next_post_update_option_' . sanitize_title( $option['type'] ), '1.5.0' );
575
+						_deprecated_hook('auto_load_next_post_update_option_'.sanitize_title($option['type']), '1.5.0');
576 576
 					}
577 577
 
578
-					do_action( 'auto_load_next_post_update_option_' . sanitize_title( $option['type'] ), $option );
578
+					do_action('auto_load_next_post_update_option_'.sanitize_title($option['type']), $option);
579 579
 					continue;
580 580
 				}
581 581
 
582
-				if ( is_null( $value ) ) {
582
+				if (is_null($value)) {
583 583
 					continue;
584 584
 				}
585 585
 
586 586
 				// Check if option is an array and handle that differently to single values.
587
-				if ( $option_name && $setting_name ) {
588
-					if ( ! isset( $update_options[ $option_name ] ) ) {
589
-						$update_options[ $option_name ] = get_option( $option_name, array() );
587
+				if ($option_name && $setting_name) {
588
+					if ( ! isset($update_options[$option_name])) {
589
+						$update_options[$option_name] = get_option($option_name, array());
590 590
 					}
591
-					if ( ! is_array( $update_options[ $option_name ] ) ) {
592
-						$update_options[ $option_name ] = array();
591
+					if ( ! is_array($update_options[$option_name])) {
592
+						$update_options[$option_name] = array();
593 593
 					}
594
-					$update_options[ $option_name ][ $setting_name ] = $value;
594
+					$update_options[$option_name][$setting_name] = $value;
595 595
 				} else {
596
-					$update_options[ $option_name ] = $value;
596
+					$update_options[$option_name] = $value;
597 597
 				}
598 598
 
599
-				$autoload_options[ $option_name ] = isset( $option['autoload'] ) ? (bool) $option['autoload'] : true;
599
+				$autoload_options[$option_name] = isset($option['autoload']) ? (bool) $option['autoload'] : true;
600 600
 
601 601
 				/**
602 602
 				 * Fire an action before saved.
603 603
 				 *
604 604
 				 * @deprecated 1.5.0 - doesn't allow manipulation of values!
605 605
 				 */
606
-				if ( has_action( 'auto_load_next_post_update_option' ) ) {
607
-					if ( is_ajax() ) {
608
-						error_log( 'auto_load_next_post_update_option is deprecated since version 1.5.0' );
606
+				if (has_action('auto_load_next_post_update_option')) {
607
+					if (is_ajax()) {
608
+						error_log('auto_load_next_post_update_option is deprecated since version 1.5.0');
609 609
 					} else {
610
-						_deprecated_hook( 'auto_load_next_post_update_option', '1.5.0' );
610
+						_deprecated_hook('auto_load_next_post_update_option', '1.5.0');
611 611
 					}
612 612
 
613
-					do_action( 'auto_load_next_post_update_option', $option );
613
+					do_action('auto_load_next_post_update_option', $option);
614 614
 				}
615 615
 			}
616 616
 
617 617
 			// Now save the options
618
-			foreach ( $update_options as $name => $value ) {
619
-				update_option( $name, $value, $autoload_options[ $name ] ? 'yes' : 'no' );
618
+			foreach ($update_options as $name => $value) {
619
+				update_option($name, $value, $autoload_options[$name] ? 'yes' : 'no');
620 620
 			}
621 621
 
622 622
 			// Save all options as an array. Ready for export.
623
-			update_option( 'auto_load_next_post_options', $update_options );
623
+			update_option('auto_load_next_post_options', $update_options);
624 624
 
625 625
 			return true;
626 626
 		} // END save_fields()
Please login to merge, or discard this patch.
includes/admin/views/html-admin-settings.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 // Exit if accessed directly.
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
20 20
 global $current_section, $current_tab;
21 21
 
22 22
 // Get tabs for the settings page
23
-$tabs = apply_filters( 'auto_load_next_post_settings_tabs_array', array() );
23
+$tabs = apply_filters('auto_load_next_post_settings_tabs_array', array());
24 24
 
25
-$tab_exists        = isset( $tabs[ $current_tab ] ) || has_action( 'auto_load_next_post_sections_' . $current_tab ) || has_action( 'auto_load_next_post_settings_' . $current_tab ) || has_action( 'auto_load_next_post_settings_tabs_' . $current_tab );
26
-$current_tab_label = isset( $tabs[ $current_tab ] ) ? $tabs[ $current_tab ] : '';
25
+$tab_exists        = isset($tabs[$current_tab]) || has_action('auto_load_next_post_sections_'.$current_tab) || has_action('auto_load_next_post_settings_'.$current_tab) || has_action('auto_load_next_post_settings_tabs_'.$current_tab);
26
+$current_tab_label = isset($tabs[$current_tab]) ? $tabs[$current_tab] : '';
27 27
 
28
-if ( ! $tab_exists ) {
29
-	wp_safe_redirect( admin_url( 'options-general.php?page=auto-load-next-post-settings' ) );
28
+if ( ! $tab_exists) {
29
+	wp_safe_redirect(admin_url('options-general.php?page=auto-load-next-post-settings'));
30 30
 	exit;
31 31
 }
32 32
 ?>
@@ -34,39 +34,39 @@  discard block
 block discarded – undo
34 34
 	<form method="post" id="mainform" action="" enctype="multipart/form-data">
35 35
 		<nav class="nav-tab-wrapper">
36 36
 			<?php
37
-				foreach ( $tabs as $slug => $label ) {
38
-					echo '<a href="' . esc_html( admin_url( 'options-general.php?page=auto-load-next-post-settings&tab=' . esc_attr( $slug ) ) ) . '" class="nav-tab ' . ( $current_tab === $slug ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>';
37
+				foreach ($tabs as $slug => $label) {
38
+					echo '<a href="'.esc_html(admin_url('options-general.php?page=auto-load-next-post-settings&tab='.esc_attr($slug))).'" class="nav-tab '.($current_tab === $slug ? 'nav-tab-active' : '').'">'.esc_html($label).'</a>';
39 39
 				}
40 40
 
41
-				do_action( 'auto_load_next_post_settings_tabs' );
41
+				do_action('auto_load_next_post_settings_tabs');
42 42
 			?>
43 43
 		</nav>
44
-		<h1 class="screen-reader-text"><?php echo esc_html( $current_tab_label ); ?></h1>
44
+		<h1 class="screen-reader-text"><?php echo esc_html($current_tab_label); ?></h1>
45 45
 		<?php
46
-		do_action( 'auto_load_next_post_sections_' . $current_tab );
46
+		do_action('auto_load_next_post_sections_'.$current_tab);
47 47
 
48 48
 		self::show_messages();
49 49
 
50
-		do_action( 'auto_load_next_post_settings_' . $current_tab );
50
+		do_action('auto_load_next_post_settings_'.$current_tab);
51 51
 		?>
52 52
 		<p class="submit">
53
-			<?php submit_button( esc_attr__( 'Save Changes', 'auto-load-next-post' ), 'button-primary', esc_attr__( 'Save Changes', 'auto-load-next-post' ), false, array( 'id' => 'save' ) ); ?>
54
-			<?php wp_nonce_field( 'auto-load-next-post-settings' ); ?>
53
+			<?php submit_button(esc_attr__('Save Changes', 'auto-load-next-post'), 'button-primary', esc_attr__('Save Changes', 'auto-load-next-post'), false, array('id' => 'save')); ?>
54
+			<?php wp_nonce_field('auto-load-next-post-settings'); ?>
55 55
 		</p>
56 56
 	</form>
57 57
 
58 58
 	<?php
59 59
 	// Checks if Auto Load Next Post Pro is installed before displaying sidebar.
60
-	if ( ! is_alnp_pro_version_installed() ) {
61
-		include_once( dirname( __FILE__ ) . '/html-admin-sidebar.php' );
60
+	if ( ! is_alnp_pro_version_installed()) {
61
+		include_once(dirname(__FILE__).'/html-admin-sidebar.php');
62 62
 	}
63 63
 	else {
64 64
 		echo '<div class="alnp-sidebar">';
65 65
 
66
-		do_action( 'auto_load_next_post_after_settings' );
66
+		do_action('auto_load_next_post_after_settings');
67 67
 
68 68
 		// Use this hook to display after settings for a specific tab.
69
-		do_action( 'auto_load_next_post_after_settings_' . $current_tab );
69
+		do_action('auto_load_next_post_after_settings_'.$current_tab);
70 70
 
71 71
 		echo '</div>';
72 72
 	}
Please login to merge, or discard this patch.
includes/admin/settings/class-alnp-settings-misc.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
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_Settings_Misc_Tab' ) ) {
18
+if ( ! class_exists('Auto_Load_Next_Post_Settings_Misc_Tab')) {
19 19
 
20 20
 	class Auto_Load_Next_Post_Settings_Misc_Tab extends Auto_Load_Next_Post_Settings_Page {
21 21
 
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
 		 */
29 29
 		public function __construct() {
30 30
 			$this->id    = 'misc';
31
-			$this->label = esc_html__( 'Misc', 'auto-load-next-post' );
31
+			$this->label = esc_html__('Misc', 'auto-load-next-post');
32 32
 
33 33
 			parent::__construct();
34 34
 
35
-			add_filter( 'auto_load_next_post_misc_settings', array( __CLASS__, 'lock_js_in_footer' ), 0, 1 );
36
-			add_action( 'auto_load_next_post_sections_misc', array( __CLASS__, 'no_comment_selector_set' ), 10 );
35
+			add_filter('auto_load_next_post_misc_settings', array(__CLASS__, 'lock_js_in_footer'), 0, 1);
36
+			add_action('auto_load_next_post_sections_misc', array(__CLASS__, 'no_comment_selector_set'), 10);
37 37
 		} // END __construct()
38 38
 
39 39
 		/**
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 		 * @since  1.5.0
45 45
 		 */
46 46
 		public static function no_comment_selector_set() {
47
-			$comments_container = get_option( 'auto_load_next_post_comments_container' );
48
-			$remove_comments    = get_option( 'auto_load_next_post_remove_comments' );
47
+			$comments_container = get_option('auto_load_next_post_comments_container');
48
+			$remove_comments    = get_option('auto_load_next_post_remove_comments');
49 49
 
50
-			if ( empty( $comments_container ) && ! empty( $remove_comments ) ) {
51
-				include( dirname( AUTO_LOAD_NEXT_POST_FILE ) . '/includes/admin/views/html-notice-no-comment-selector.php' );
50
+			if (empty($comments_container) && ! empty($remove_comments)) {
51
+				include(dirname(AUTO_LOAD_NEXT_POST_FILE).'/includes/admin/views/html-notice-no-comment-selector.php');
52 52
 			}
53 53
 		} // END no_comment_selector_set()
54 54
 
@@ -64,19 +64,19 @@  discard block
 block discarded – undo
64 64
 		 * @param   array $settings
65 65
 		 * @return  array $settings
66 66
 		 */
67
-		public static function lock_js_in_footer( $settings ) {
68
-			$js_locked_in_footer = get_option( 'auto_load_next_post_lock_js_in_footer' );
67
+		public static function lock_js_in_footer($settings) {
68
+			$js_locked_in_footer = get_option('auto_load_next_post_lock_js_in_footer');
69 69
 
70
-			if ( ! empty( $js_locked_in_footer ) && $js_locked_in_footer == 'yes' ) {
70
+			if ( ! empty($js_locked_in_footer) && $js_locked_in_footer == 'yes') {
71 71
 				// Setting key to look for.
72 72
 				$key = 'load_js_in_footer';
73 73
 
74 74
 				// Find the setting.
75
-				$find_setting = array_search( $key, $settings );
75
+				$find_setting = array_search($key, $settings);
76 76
 
77 77
 				// Does the setting exist?
78
-				if ( is_bool( $find_setting ) === true ) {
79
-					unset( $settings[$key] );
78
+				if (is_bool($find_setting) === true) {
79
+					unset($settings[$key]);
80 80
 				}
81 81
 			}
82 82
 
@@ -97,45 +97,45 @@  discard block
 block discarded – undo
97 97
 					'title' => array(
98 98
 						'title' => $this->label,
99 99
 						'type'  => 'title',
100
-						'desc'  => sprintf( esc_html__( 'Here you set if you want to track pageviews, remove comments and load %s javascript in the footer.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ),
100
+						'desc'  => sprintf(esc_html__('Here you set if you want to track pageviews, remove comments and load %s javascript in the footer.', 'auto-load-next-post'), esc_html__('Auto Load Next Post', 'auto-load-next-post')),
101 101
 						'id'    => 'misc_options'
102 102
 					),
103 103
 
104 104
 					'remove_comments' => array(
105
-						'title'   => esc_html__( 'Remove Comments', 'auto-load-next-post' ),
106
-						'desc'    => esc_html__( 'Enable to remove comments when each post loads including the initial post.', 'auto-load-next-post' ),
105
+						'title'   => esc_html__('Remove Comments', 'auto-load-next-post'),
106
+						'desc'    => esc_html__('Enable to remove comments when each post loads including the initial post.', 'auto-load-next-post'),
107 107
 						'id'      => 'auto_load_next_post_remove_comments',
108 108
 						'default' => 'yes',
109 109
 						'type'    => 'checkbox'
110 110
 					),
111 111
 
112 112
 					'google_analytics' => array(
113
-						'title'   => esc_html__( 'Update Google Analytics', 'auto-load-next-post' ),
114
-						'desc'    => esc_html__( 'Enable to track each post the visitor is reading. This will count as a pageview. You must already have Google Analytics setup.', 'auto-load-next-post' ),
113
+						'title'   => esc_html__('Update Google Analytics', 'auto-load-next-post'),
114
+						'desc'    => esc_html__('Enable to track each post the visitor is reading. This will count as a pageview. You must already have Google Analytics setup.', 'auto-load-next-post'),
115 115
 						'id'      => 'auto_load_next_post_google_analytics',
116 116
 						'default' => 'no',
117 117
 						'type'    => 'checkbox'
118 118
 					),
119 119
 
120 120
 					'load_js_in_footer' => array(
121
-						'title'   => esc_html__( 'JavaScript in Footer?', 'auto-load-next-post' ),
122
-						'desc'    => esc_html__( 'Enable to load Auto Load Next Post in the footer instead of the header. Can be useful to optimize your site or if the current theme requires it.', 'auto-load-next-post' ),
121
+						'title'   => esc_html__('JavaScript in Footer?', 'auto-load-next-post'),
122
+						'desc'    => esc_html__('Enable to load Auto Load Next Post in the footer instead of the header. Can be useful to optimize your site or if the current theme requires it.', 'auto-load-next-post'),
123 123
 						'id'      => 'auto_load_next_post_load_js_in_footer',
124 124
 						'default' => 'no',
125 125
 						'type'    => 'checkbox'
126 126
 					),
127 127
 
128 128
 					'reset_data' => array(
129
-						'title'   => esc_html__( 'Reset all data?', 'auto-load-next-post' ),
130
-						'desc'    => esc_html__( 'Press the reset button to clear all settings for this plugin and re-install the default settings.', 'auto-load-next-post' ),
129
+						'title'   => esc_html__('Reset all data?', 'auto-load-next-post'),
130
+						'desc'    => esc_html__('Press the reset button to clear all settings for this plugin and re-install the default settings.', 'auto-load-next-post'),
131 131
 						'id'      => 'auto_load_next_post_reset_data',
132 132
 						'default' => 'no',
133 133
 						'type'    => 'reset_data'
134 134
 					),
135 135
 
136 136
 					'uninstall' => array(
137
-						'title'   => esc_html__( 'Remove all data on uninstall?', 'auto-load-next-post' ),
138
-						'desc'    => esc_html__( 'If enabled, all settings for this plugin will all be deleted when uninstalling via Plugins > Delete.', 'auto-load-next-post' ),
137
+						'title'   => esc_html__('Remove all data on uninstall?', 'auto-load-next-post'),
138
+						'desc'    => esc_html__('If enabled, all settings for this plugin will all be deleted when uninstalling via Plugins > Delete.', 'auto-load-next-post'),
139 139
 						'id'      => 'auto_load_next_post_uninstall_data',
140 140
 						'default' => 'no',
141 141
 						'type'    => 'checkbox'
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 		public function output() {
159 159
 			$settings = $this->get_settings();
160 160
 
161
-			Auto_Load_Next_Post_Admin_Settings::output_fields( $settings );
161
+			Auto_Load_Next_Post_Admin_Settings::output_fields($settings);
162 162
 		} // END output()
163 163
 
164 164
 		/**
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		public function save() {
171 171
 			$settings = $this->get_settings();
172 172
 
173
-			Auto_Load_Next_Post_Admin_Settings::save_fields( $settings );
173
+			Auto_Load_Next_Post_Admin_Settings::save_fields($settings);
174 174
 		} // END save()
175 175
 
176 176
 	} // END class
Please login to merge, or discard this patch.
includes/admin/class-alnp-admin.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
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' ) ) {
18
+if ( ! class_exists('Auto_Load_Next_Post_Admin')) {
19 19
 
20 20
 	class Auto_Load_Next_Post_Admin {
21 21
 
@@ -28,23 +28,23 @@  discard block
 block discarded – undo
28 28
 		 */
29 29
 		public function __construct() {
30 30
 			// Include classes.
31
-			add_action( 'admin_init', array( $this, 'includes' ), 10 );
31
+			add_action('admin_init', array($this, 'includes'), 10);
32 32
 
33 33
 			// Register scripts and styles for settings page.
34
-			add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ), 10 );
35
-			add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 10 );
34
+			add_action('admin_enqueue_scripts', array($this, 'admin_styles'), 10);
35
+			add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 10);
36 36
 
37 37
 			// Add a message in the WP Privacy Policy Guide page.
38
-			add_action( 'admin_init', array( $this, 'add_privacy_policy_guide_content' ) );
38
+			add_action('admin_init', array($this, 'add_privacy_policy_guide_content'));
39 39
 
40 40
 			// Add settings page.
41
-			add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
41
+			add_action('admin_menu', array($this, 'admin_menu'), 9);
42 42
 
43 43
 			// Filters plugin row and admin footer.
44
-			add_filter( 'plugin_action_links_' . plugin_basename( AUTO_LOAD_NEXT_POST_FILE ), array( $this, 'plugin_action_links' ) );
45
-			add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta'), 10, 3 );
46
-			add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 15, 1 );
47
-			add_filter( 'update_footer', array( $this, 'update_footer'), 15 );
44
+			add_filter('plugin_action_links_'.plugin_basename(AUTO_LOAD_NEXT_POST_FILE), array($this, 'plugin_action_links'));
45
+			add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 3);
46
+			add_filter('admin_footer_text', array($this, 'admin_footer_text'), 15, 1);
47
+			add_filter('update_footer', array($this, 'update_footer'), 15);
48 48
 		} // END __construct()
49 49
 
50 50
 		/**
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 		 */
56 56
 		public function includes() {
57 57
 			// Classes we only need if the ajax is not-ajax
58
-			if ( ! auto_load_next_post_is_ajax() ) {
59
-				include( dirname( __FILE__ ) . '/class-alnp-admin-notices.php' ); // Plugin Notices
60
-				include( dirname( __FILE__ ) . '/class-alnp-admin-help.php' ); // Plugin Help Tab
58
+			if ( ! auto_load_next_post_is_ajax()) {
59
+				include(dirname(__FILE__).'/class-alnp-admin-notices.php'); // Plugin Notices
60
+				include(dirname(__FILE__).'/class-alnp-admin-help.php'); // Plugin Help Tab
61 61
 			}
62 62
 		} // END includes()
63 63
 
@@ -71,16 +71,16 @@  discard block
 block discarded – undo
71 71
 			$screen    = get_current_screen();
72 72
 			$screen_id = $screen ? $screen->id : '';
73 73
 
74
-			Auto_Load_Next_Post::load_file( AUTO_LOAD_NEXT_POST_SLUG . '_admin', '/assets/css/admin/auto-load-next-post' . AUTO_LOAD_NEXT_POST_SCRIPT_MODE . '.css' );
74
+			Auto_Load_Next_Post::load_file(AUTO_LOAD_NEXT_POST_SLUG.'_admin', '/assets/css/admin/auto-load-next-post'.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.css');
75 75
 
76
-			if ( $screen_id == 'settings_page_auto-load-next-post-settings' ) {
76
+			if ($screen_id == 'settings_page_auto-load-next-post-settings') {
77 77
 				// Select2 - Make sure that we remove other registered Select2 to prevent styling issues.
78
-				if ( wp_script_is( 'select2', 'registered' ) ) {
79
-					wp_dequeue_style( 'select2' );
80
-					wp_deregister_style( 'select2' );
78
+				if (wp_script_is('select2', 'registered')) {
79
+					wp_dequeue_style('select2');
80
+					wp_deregister_style('select2');
81 81
 				}
82 82
 
83
-				Auto_Load_Next_Post::load_file( 'select2', '/assets/css/libs/select2' . AUTO_LOAD_NEXT_POST_SCRIPT_MODE . '.css' );
83
+				Auto_Load_Next_Post::load_file('select2', '/assets/css/libs/select2'.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.css');
84 84
 			}
85 85
 		} // END admin_styles()
86 86
 
@@ -95,24 +95,24 @@  discard block
 block discarded – undo
95 95
 			$screen    = get_current_screen();
96 96
 			$screen_id = $screen ? $screen->id : '';
97 97
 
98
-			if ( $screen->id == 'settings_page_auto-load-next-post-settings' ) {
98
+			if ($screen->id == 'settings_page_auto-load-next-post-settings') {
99 99
 				// Select2 - Make sure that we remove other registered Select2 to prevent plugin conflict issues.
100
-				if ( wp_script_is( 'select2', 'registered' ) ) {
101
-					wp_dequeue_script( 'select2' );
102
-					wp_deregister_script( 'select2' );
100
+				if (wp_script_is('select2', 'registered')) {
101
+					wp_dequeue_script('select2');
102
+					wp_deregister_script('select2');
103 103
 				}
104 104
 
105 105
 				// Load Select2
106
-				Auto_Load_Next_Post::load_file( 'select2', '/assets/js/libs/select2' . AUTO_LOAD_NEXT_POST_SCRIPT_MODE . '.js', true, array( 'jquery' ), '4.0.5', true );
106
+				Auto_Load_Next_Post::load_file('select2', '/assets/js/libs/select2'.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.js', true, array('jquery'), '4.0.5', true);
107 107
 
108 108
 				// Load plugin settings.
109
-				Auto_Load_Next_Post::load_file( AUTO_LOAD_NEXT_POST_SLUG . '_admin', '/assets/js/admin/settings' . AUTO_LOAD_NEXT_POST_SCRIPT_MODE . '.js', true, array( 'jquery' ), AUTO_LOAD_NEXT_POST_VERSION, true );
109
+				Auto_Load_Next_Post::load_file(AUTO_LOAD_NEXT_POST_SLUG.'_admin', '/assets/js/admin/settings'.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.js', true, array('jquery'), AUTO_LOAD_NEXT_POST_VERSION, true);
110 110
 
111 111
 				// Variables for Admin JavaScripts
112
-				wp_localize_script( AUTO_LOAD_NEXT_POST_SLUG . '_admin', 'alnp_settings_params', array(
112
+				wp_localize_script(AUTO_LOAD_NEXT_POST_SLUG.'_admin', 'alnp_settings_params', array(
113 113
 					'is_rtl'           => is_rtl() ? 'rtl' : 'ltr',
114
-					'i18n_nav_warning' => esc_html__( 'The changes you made will be lost if you navigate away from this page.', 'auto-load-next-post' ),
115
-				) );
114
+					'i18n_nav_warning' => esc_html__('The changes you made will be lost if you navigate away from this page.', 'auto-load-next-post'),
115
+				));
116 116
 			}
117 117
 		} // END admin_scripts()
118 118
 
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 		 * @static
125 125
 		 */
126 126
 		public static function add_privacy_policy_guide_content() {
127
-			if ( function_exists( 'wp_add_privacy_policy_content' ) ) {
128
-				wp_add_privacy_policy_content( esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ), self::get_privacy_policy_guide_message() );
127
+			if (function_exists('wp_add_privacy_policy_content')) {
128
+				wp_add_privacy_policy_content(esc_html__('Auto Load Next Post', 'auto-load-next-post'), self::get_privacy_policy_guide_message());
129 129
 			}
130 130
 		} // END add_privacy_policy_guide_content()
131 131
 
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 		protected static function get_privacy_policy_guide_message() {
141 141
 			$content = '
142 142
 				<div contenteditable="false">' .
143
-					'<p class="wp-policy-help">' .
144
-						sprintf( __( '%s does not collect, store or share any personal data.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ) .
145
-					'</p>' .
143
+					'<p class="wp-policy-help">'.
144
+						sprintf(__('%s does not collect, store or share any personal data.', 'auto-load-next-post'), esc_html__('Auto Load Next Post', 'auto-load-next-post')).
145
+					'</p>'.
146 146
 				'</div>';
147 147
 
148 148
 			return $content;
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
 		 */
158 158
 		public function admin_menu() {
159 159
 			$settings_page = add_options_page(
160
-				sprintf( __( '%s Settings', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ),
161
-				esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ),
160
+				sprintf(__('%s Settings', 'auto-load-next-post'), esc_html__('Auto Load Next Post', 'auto-load-next-post')),
161
+				esc_html__('Auto Load Next Post', 'auto-load-next-post'),
162 162
 				'manage_options',
163 163
 				'auto-load-next-post-settings',
164
-				array( $this, 'settings_page' )
164
+				array($this, 'settings_page')
165 165
 			);
166 166
 
167
-			add_action( 'load-' . $settings_page, array( $this, 'settings_page_init' ) );
167
+			add_action('load-'.$settings_page, array($this, 'settings_page_init'));
168 168
 		} // END admin_menu()
169 169
 
170 170
 		/**
@@ -179,29 +179,29 @@  discard block
 block discarded – undo
179 179
 			global $current_tab, $current_section;
180 180
 
181 181
 			// Include settings pages.
182
-			include_once( dirname( __FILE__ ) . '/class-alnp-admin-settings.php' );
182
+			include_once(dirname(__FILE__).'/class-alnp-admin-settings.php');
183 183
 
184 184
 			Auto_Load_Next_Post_Admin_Settings::get_settings_pages();
185 185
 
186 186
 			// Get current tab/section.
187
-			$current_tab     = empty( $_GET['tab'] ) ? 'theme-selectors' : sanitize_title( wp_unslash( $_GET['tab'] ) );
188
-			$current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( wp_unslash( $_REQUEST['section'] ) );
187
+			$current_tab     = empty($_GET['tab']) ? 'theme-selectors' : sanitize_title(wp_unslash($_GET['tab']));
188
+			$current_section = empty($_REQUEST['section']) ? '' : sanitize_title(wp_unslash($_REQUEST['section']));
189 189
 
190 190
 			// Save settings if data has been posted.
191
-			if ( apply_filters( '' !== $current_section ? "auto_load_next_post_save_settings_{$current_tab}_{$current_section}" : "auto_load_next_post_save_settings_{$current_tab}", ! empty( $_POST ) ) ) {
191
+			if (apply_filters('' !== $current_section ? "auto_load_next_post_save_settings_{$current_tab}_{$current_section}" : "auto_load_next_post_save_settings_{$current_tab}", ! empty($_POST))) {
192 192
 				Auto_Load_Next_Post_Admin_Settings::save();
193 193
 			}
194 194
 
195 195
 			// Add any posted messages.
196
-			if ( ! empty( $_GET['auto_load_next_post_error'] ) ) {
197
-				Auto_Load_Next_Post_Admin_Settings::add_error( wp_kses_post( wp_unslash( $_GET['auto_load_next_post_error'] ) ) );
196
+			if ( ! empty($_GET['auto_load_next_post_error'])) {
197
+				Auto_Load_Next_Post_Admin_Settings::add_error(wp_kses_post(wp_unslash($_GET['auto_load_next_post_error'])));
198 198
 			}
199 199
 
200
-			if ( ! empty( $_GET['auto_load_next_post_message'] ) ) {
201
-				Auto_Load_Next_Post_Admin_Settings::add_message( wp_kses_post( wp_unslash( $_GET['auto_load_next_post_message'] ) ) );
200
+			if ( ! empty($_GET['auto_load_next_post_message'])) {
201
+				Auto_Load_Next_Post_Admin_Settings::add_message(wp_kses_post(wp_unslash($_GET['auto_load_next_post_message'])));
202 202
 			}
203 203
 
204
-			do_action( 'auto_load_next_post_settings_page_init' );
204
+			do_action('auto_load_next_post_settings_page_init');
205 205
 		} // END settings_page_init()
206 206
 
207 207
 		/**
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 		 * @since  1.0.0
212 212
 		 */
213 213
 		public function settings_page() {
214
-			include_once( dirname( __FILE__ ) . '/class-alnp-admin-settings.php' );
214
+			include_once(dirname(__FILE__).'/class-alnp-admin-settings.php');
215 215
 
216 216
 			Auto_Load_Next_Post_Admin_Settings::output();
217 217
 		} // END settings_page()
@@ -225,18 +225,18 @@  discard block
 block discarded – undo
225 225
 		 * @param   array $links
226 226
 		 * @return  array $links
227 227
 		 */
228
-		public function plugin_action_links( $links ) {
228
+		public function plugin_action_links($links) {
229 229
 			$plugin_action_links = array();
230 230
 
231
-			if ( current_user_can( 'manage_options' ) ) {
231
+			if (current_user_can('manage_options')) {
232 232
 				// Checks if Auto Load Next Post Pro has been installed.
233
-				if ( ! is_alnp_pro_version_installed() ) {
234
-					$plugin_action_links['go-pro'] = '<a href="' . esc_url( AUTO_LOAD_NEXT_POST_STORE_URL . 'pro/?utm_source=plugin&utm_medium=link&utm_campaign=plugins-page' ) . '" aria-label="' . esc_attr__( 'Sign up for Auto Load Next Post Pro', 'auto-load-next-post' ) . '" target="_blank" style="color:green; font-weight:bold;">' . __( 'Sign up for Pro', 'auto-load-next-post' ) . '</a>';
233
+				if ( ! is_alnp_pro_version_installed()) {
234
+					$plugin_action_links['go-pro'] = '<a href="'.esc_url(AUTO_LOAD_NEXT_POST_STORE_URL.'pro/?utm_source=plugin&utm_medium=link&utm_campaign=plugins-page').'" aria-label="'.esc_attr__('Sign up for Auto Load Next Post Pro', 'auto-load-next-post').'" target="_blank" style="color:green; font-weight:bold;">'.__('Sign up for Pro', 'auto-load-next-post').'</a>';
235 235
 				}
236 236
 
237
-				$plugin_action_links['settings'] = '<a href="' . admin_url( 'options-general.php?page=auto-load-next-post-settings' ) . '" aria-label="' . esc_attr__( 'View Auto Load Next Post settings', 'auto-load-next-post' ) . '">' . __( 'Settings', 'auto-load-next-post' ) . '</a>';
237
+				$plugin_action_links['settings'] = '<a href="'.admin_url('options-general.php?page=auto-load-next-post-settings').'" aria-label="'.esc_attr__('View Auto Load Next Post settings', 'auto-load-next-post').'">'.__('Settings', 'auto-load-next-post').'</a>';
238 238
 
239
-				return array_merge( $plugin_action_links, $links );
239
+				return array_merge($plugin_action_links, $links);
240 240
 			}
241 241
 
242 242
 			return $links;
@@ -253,18 +253,18 @@  discard block
 block discarded – undo
253 253
 		 * @param   array  $data  Plugin Information
254 254
 		 * @return  array  $links
255 255
 		 */
256
-		public function plugin_row_meta( $links, $file, $data ) {
257
-			if ( $file == plugin_basename( AUTO_LOAD_NEXT_POST_FILE ) ) {
258
-				$links[ 1 ] = sprintf( __( 'Developed By %s', 'auto-load-next-post' ), '<a href="' . $data[ 'AuthorURI' ] . '" aria-label="' . esc_attr__( 'View the developers site', 'auto-load-next-post' ) . '">' . $data[ 'Author' ] . '</a>' );
256
+		public function plugin_row_meta($links, $file, $data) {
257
+			if ($file == plugin_basename(AUTO_LOAD_NEXT_POST_FILE)) {
258
+				$links[1] = sprintf(__('Developed By %s', 'auto-load-next-post'), '<a href="'.$data['AuthorURI'].'" aria-label="'.esc_attr__('View the developers site', 'auto-load-next-post').'">'.$data['Author'].'</a>');
259 259
 
260 260
 				$row_meta = array(
261
-					'docs' => '<a href="' . esc_url( AUTO_LOAD_NEXT_POST_STORE_URL . 'documentation/?utm_source=plugin&utm_medium=link&utm_campaign=plugins-page' ) . '" aria-label="' . esc_attr__( 'View Auto Load Next Post documentation', 'auto-load-next-post' ) . '" target="_blank">' . esc_attr__( 'Documentation', 'auto-load-next-post' ) . '</a>',
262
-					'community' => '<a href="' . esc_url( 'https://wordpress.org/support/plugin/auto-load-next-post' ) . '" aria-label="' . esc_attr__( 'Get support from the community', 'auto-load-next-post' ). '" target="_blank">' . esc_attr__( 'Community Support', 'auto-load-next-post' ) . '</a>',
263
-					'theme-support' => '<a href="' . esc_url( AUTO_LOAD_NEXT_POST_STORE_URL . 'product/theme-support/?utm_source=plugin&utm_medium=link&utm_campaign=plugins-page' ) . '" attr-label="' . esc_attr__( 'Get theme support', 'auto-load-next-post' ) . '" target="_blank">' . esc_attr__( 'Theme Support', 'auto-load-next-post' ) . '</a>',
264
-					'review' => '<a href="' . esc_url( AUTO_LOAD_NEXT_POST_REVIEW_URL ) . '" aria-label="' . esc_attr( __( 'Review Auto Load Next Post on WordPress.org', 'auto-load-next-post' ) ) . '" target="_blank">' . __( 'Leave a Review', 'auto-load-next-post' ) . '</a>',
261
+					'docs' => '<a href="'.esc_url(AUTO_LOAD_NEXT_POST_STORE_URL.'documentation/?utm_source=plugin&utm_medium=link&utm_campaign=plugins-page').'" aria-label="'.esc_attr__('View Auto Load Next Post documentation', 'auto-load-next-post').'" target="_blank">'.esc_attr__('Documentation', 'auto-load-next-post').'</a>',
262
+					'community' => '<a href="'.esc_url('https://wordpress.org/support/plugin/auto-load-next-post').'" aria-label="'.esc_attr__('Get support from the community', 'auto-load-next-post').'" target="_blank">'.esc_attr__('Community Support', 'auto-load-next-post').'</a>',
263
+					'theme-support' => '<a href="'.esc_url(AUTO_LOAD_NEXT_POST_STORE_URL.'product/theme-support/?utm_source=plugin&utm_medium=link&utm_campaign=plugins-page').'" attr-label="'.esc_attr__('Get theme support', 'auto-load-next-post').'" target="_blank">'.esc_attr__('Theme Support', 'auto-load-next-post').'</a>',
264
+					'review' => '<a href="'.esc_url(AUTO_LOAD_NEXT_POST_REVIEW_URL).'" aria-label="'.esc_attr(__('Review Auto Load Next Post on WordPress.org', 'auto-load-next-post')).'" target="_blank">'.__('Leave a Review', 'auto-load-next-post').'</a>',
265 265
 				);
266 266
 
267
-				$links = array_merge( $links, $row_meta );
267
+				$links = array_merge($links, $row_meta);
268 268
 			}
269 269
 
270 270
 			return $links;
@@ -280,16 +280,16 @@  discard block
 block discarded – undo
280 280
 		 * @param   string $text text to be rendered in the footer.
281 281
 		 * @return  string $text
282 282
 		 */
283
-		public function admin_footer_text( $text ) {
283
+		public function admin_footer_text($text) {
284 284
 			$current_screen = get_current_screen();
285 285
 
286
-			if ( isset( $current_screen->id ) && $current_screen->id == 'settings_page_auto-load-next-post-settings' ) {
286
+			if (isset($current_screen->id) && $current_screen->id == 'settings_page_auto-load-next-post-settings') {
287 287
 				// Rating and Review
288 288
 				$text = sprintf(
289 289
 					/* translators: 1: Auto Load Next Post 2:: five stars */
290
-					__( 'If you like %1$s, please leave a %2$s rating. A huge thank you in advance!', 'auto-load-next-post' ),
291
-					sprintf( '<strong>%1$s</strong>', esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ),
292
-					'<a href="' . AUTO_LOAD_NEXT_POST_REVIEW_URL . '?rate=5#new-post" target="_blank" aria-label="' . esc_attr__( 'five star', 'auto-load-next-post' ) . '" data-rated="' . esc_attr__( 'Thanks :)', 'auto-load-next-post' ) . '">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
290
+					__('If you like %1$s, please leave a %2$s rating. A huge thank you in advance!', 'auto-load-next-post'),
291
+					sprintf('<strong>%1$s</strong>', esc_html__('Auto Load Next Post', 'auto-load-next-post')),
292
+					'<a href="'.AUTO_LOAD_NEXT_POST_REVIEW_URL.'?rate=5#new-post" target="_blank" aria-label="'.esc_attr__('five star', 'auto-load-next-post').'" data-rated="'.esc_attr__('Thanks :)', 'auto-load-next-post').'">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
293 293
 				);
294 294
 			}
295 295
 
@@ -306,11 +306,11 @@  discard block
 block discarded – undo
306 306
 		 * @param   string $text
307 307
 		 * @return  string $text
308 308
 		 */
309
-		public function update_footer( $text ) {
309
+		public function update_footer($text) {
310 310
 			$screen = get_current_screen();
311 311
 
312
-			if ( $screen->id == 'settings_page_auto-load-next-post-settings' ) {
313
-				return sprintf( __( '%s Version', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ) . ' ' . esc_attr( AUTO_LOAD_NEXT_POST_VERSION );
312
+			if ($screen->id == 'settings_page_auto-load-next-post-settings') {
313
+				return sprintf(__('%s Version', 'auto-load-next-post'), esc_html__('Auto Load Next Post', 'auto-load-next-post')).' '.esc_attr(AUTO_LOAD_NEXT_POST_VERSION);
314 314
 			}
315 315
 
316 316
 			return $text;
Please login to merge, or discard this patch.
includes/admin/class-alnp-admin-notices.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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_notices', array( $this, 'add_notices' ), 0 );
49
+			add_action('admin_notices', array($this, 'add_notices'), 0);
50 50
 		} // END __construct()
51 51
 
52 52
 		/**
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
-			$template = get_option( 'template' );
133
+			$template = get_option('template');
134 134
 
135 135
 			// Checks if the theme supports Auto Load Next Post and not provided via a plugin.
136
-			if ( is_alnp_supported() ) {
137
-				$plugin_supported = alnp_get_theme_support( 'plugin_support' );
136
+			if (is_alnp_supported()) {
137
+				$plugin_supported = alnp_get_theme_support('plugin_support');
138 138
 
139 139
 				// Return if theme is supported via plugin.
140
-				if ( ! empty( $plugin_supported ) && $plugin_supported == 'yes' ) {
141
-					update_option( 'auto_load_next_post_theme_supported', $template );
140
+				if ( ! empty($plugin_supported) && $plugin_supported == 'yes') {
141
+					update_option('auto_load_next_post_theme_supported', $template);
142 142
 					return false;
143 143
 				}
144 144
 
145 145
 				// If supported theme does not match active theme then show notice.
146
-				if ( get_option( 'auto_load_next_post_theme_supported' ) !== $template ) {
147
-					add_action( 'admin_notices', array( $this, 'theme_ready_notice' ) );
148
-					update_option( 'auto_load_next_post_theme_supported', $template );
146
+				if (get_option('auto_load_next_post_theme_supported') !== $template) {
147
+					add_action('admin_notices', array($this, 'theme_ready_notice'));
148
+					update_option('auto_load_next_post_theme_supported', $template);
149 149
 				}
150 150
 			}
151 151
 			else {
152 152
 				// If theme not supported then delete option.
153
-				delete_option( 'auto_load_next_post_theme_supported' );
153
+				delete_option('auto_load_next_post_theme_supported');
154 154
 			}
155 155
 
156 156
 			// Is admin welcome notice hidden?
157
-			$hide_welcome_notice = get_user_meta( $current_user->ID, 'auto_load_next_post_hide_welcome_notice', true );
157
+			$hide_welcome_notice = get_user_meta($current_user->ID, 'auto_load_next_post_hide_welcome_notice', true);
158 158
 
159 159
 			// Check if we need to display the welcome notice.
160
-			if ( empty( $hide_welcome_notice ) ) {
160
+			if (empty($hide_welcome_notice)) {
161 161
 				// If the user has just installed the plugin for the first time then welcome the user.
162
-				if ( ( intval( time() - strtotime( self::$install_date ) ) / WEEK_IN_SECONDS ) % 52 <= 2 ) {
163
-					add_action( 'admin_notices', array( $this, 'welcome_notice' ) );
162
+				if ((intval(time() - strtotime(self::$install_date)) / WEEK_IN_SECONDS) % 52 <= 2) {
163
+					add_action('admin_notices', array($this, 'welcome_notice'));
164 164
 				}
165 165
 			}
166 166
 
167 167
 			// Is admin review notice hidden?
168
-			$hide_review_notice = get_user_meta( $current_user->ID, 'auto_load_next_post_hide_review_notice', true );
168
+			$hide_review_notice = get_user_meta($current_user->ID, 'auto_load_next_post_hide_review_notice', true);
169 169
 
170 170
 			// Check if we need to display the review plugin notice.
171
-			if ( empty( $hide_review_notice ) ) {
171
+			if (empty($hide_review_notice)) {
172 172
 				// If it has been a week or more since activating the plugin then display the review notice.
173
-				if ( ( intval( time() - self::$install_date ) ) > WEEK_IN_SECONDS ) {
174
-					add_action( 'admin_notices', array( $this, 'plugin_review_notice' ) );
173
+				if ((intval(time() - self::$install_date)) > WEEK_IN_SECONDS) {
174
+					add_action('admin_notices', array($this, 'plugin_review_notice'));
175 175
 				}
176 176
 			}
177 177
 
178 178
 			// Is this version of Auto Load Next Post a beta release?
179
-			if ( is_alnp_beta() && empty( get_transient( 'alnp_beta_notice_hidden' ) ) ) {
180
-				add_action( 'admin_notices', array( $this, 'beta_notice' ) );
179
+			if (is_alnp_beta() && empty(get_transient('alnp_beta_notice_hidden'))) {
180
+				add_action('admin_notices', array($this, 'beta_notice'));
181 181
 			}
182 182
 		} // END add_notices()
183 183
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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.
Please login to merge, or discard this patch.