Completed
Branch codeclean (caf552)
by Sébastien
01:58
created
auto-load-next-post.php 1 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
 		/**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 			$this->init_hooks();
102 102
 
103 103
 			// Auto Load Next Post is fully loaded.
104
-			do_action( 'auto_load_next_post_loaded' );
104
+			do_action('auto_load_next_post_loaded');
105 105
 		} // END __construct()
106 106
 
107 107
 		/**
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 		 */
113 113
 		public function init_hooks() {
114 114
 			// Load translation files.
115
-			add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
115
+			add_action('init', array($this, 'load_plugin_textdomain'));
116 116
 
117 117
 			// Load Auto Load Next Post scripts on the frontend.
118
-			add_action( 'wp_enqueue_scripts', array( $this, 'alnp_enqueue_scripts' ) );
118
+			add_action('wp_enqueue_scripts', array($this, 'alnp_enqueue_scripts'));
119 119
 		} // END init_hooks()
120 120
 
121 121
 		/**
@@ -130,10 +130,10 @@  discard block
 block discarded – undo
130 130
 			$this->define('AUTO_LOAD_NEXT_POST_FILE', __FILE__);
131 131
 			$this->define('AUTO_LOAD_NEXT_POST_SLUG', 'auto-load-next-post');
132 132
 
133
-			$this->define('AUTO_LOAD_NEXT_POST_URL_PATH', untrailingslashit( plugins_url( '/', __FILE__ ) ) );
134
-			$this->define('AUTO_LOAD_NEXT_POST_FILE_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
133
+			$this->define('AUTO_LOAD_NEXT_POST_URL_PATH', untrailingslashit(plugins_url('/', __FILE__)));
134
+			$this->define('AUTO_LOAD_NEXT_POST_FILE_PATH', untrailingslashit(plugin_dir_path(__FILE__)));
135 135
 			$this->define('AUTO_LOAD_NEXT_POST_TEMPLATE_PATH', 'auto-load-next-post/');
136
-			$this->define('AUTO_LOAD_NEXT_POST_3RD_PARTY', AUTO_LOAD_NEXT_POST_FILE_PATH . '/includes/3rd-party/');
136
+			$this->define('AUTO_LOAD_NEXT_POST_3RD_PARTY', AUTO_LOAD_NEXT_POST_FILE_PATH.'/includes/3rd-party/');
137 137
 
138 138
 			$this->define('AUTO_LOAD_NEXT_POST_WP_VERSION_REQUIRE', '4.4');
139 139
 
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 		 * @access private
157 157
 		 * @since  1.4.3
158 158
 		 */
159
-		private function define( $name, $value ) {
160
-			if ( ! defined( $name ) ) {
161
-				define( $name, $value );
159
+		private function define($name, $value) {
160
+			if ( ! defined($name)) {
161
+				define($name, $value);
162 162
 			}
163 163
 		} // END define()
164 164
 
@@ -171,29 +171,29 @@  discard block
 block discarded – undo
171 171
 		 * @return  void
172 172
 		 */
173 173
 		public function includes() {
174
-			include_once( dirname( __FILE__ ) . '/includes/class-alnp-autoloader.php' ); // Autoloader.
175
-			include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-conditional-functions.php' ); // Conditional functions.
176
-			include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-formatting-functions.php' ); // Formatting functions.
177
-			include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-themes-supported.php' ); // Handles all supported themes out of the box.
178
-			include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-core-functions.php' ); // Contains core functions for the front/back end.
174
+			include_once(dirname(__FILE__).'/includes/class-alnp-autoloader.php'); // Autoloader.
175
+			include_once(dirname(__FILE__).'/includes/auto-load-next-post-conditional-functions.php'); // Conditional functions.
176
+			include_once(dirname(__FILE__).'/includes/auto-load-next-post-formatting-functions.php'); // Formatting functions.
177
+			include_once(dirname(__FILE__).'/includes/auto-load-next-post-themes-supported.php'); // Handles all supported themes out of the box.
178
+			include_once(dirname(__FILE__).'/includes/auto-load-next-post-core-functions.php'); // Contains core functions for the front/back end.
179 179
 
180 180
 			// Include theme support.
181 181
 			alnp_include_theme_support();
182 182
 
183 183
 			// 3rd Party support.
184
-			include_once( dirname( __FILE__ ) . '/includes/3rd-party/3rd-party.php' );
184
+			include_once(dirname(__FILE__).'/includes/3rd-party/3rd-party.php');
185 185
 
186 186
 			// Customizer.
187
-			include_once( dirname( __FILE__ ) . '/includes/customizer/class-alnp-customizer.php' );
188
-			include_once( dirname( __FILE__ ) . '/includes/customizer/class-alnp-customizer-scripts.php' );
187
+			include_once(dirname(__FILE__).'/includes/customizer/class-alnp-customizer.php');
188
+			include_once(dirname(__FILE__).'/includes/customizer/class-alnp-customizer-scripts.php');
189 189
 
190 190
 			// Include admin class to handle all back-end functions.
191
-			if ( is_admin() ) {
192
-				include_once( dirname( __FILE__ ) . '/includes/admin/class-alnp-admin.php' ); // Admin section.
191
+			if (is_admin()) {
192
+				include_once(dirname(__FILE__).'/includes/admin/class-alnp-admin.php'); // Admin section.
193 193
 			}
194 194
 
195 195
 			// Install.
196
-			require_once( dirname( __FILE__ ) . '/includes/class-alnp-install.php' );
196
+			require_once(dirname(__FILE__).'/includes/class-alnp-install.php');
197 197
 		} // END includes()
198 198
 
199 199
 		/**
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		 * @return  void
209 209
 		 */
210 210
 		public function load_plugin_textdomain() {
211
-			load_plugin_textdomain( 'auto-load-next-post', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
211
+			load_plugin_textdomain('auto-load-next-post', false, dirname(plugin_basename(__FILE__)).'/languages/');
212 212
 		} // END load_plugin_textdomain()
213 213
 
214 214
 		/**
@@ -220,33 +220,33 @@  discard block
 block discarded – undo
220 220
 		 */
221 221
 		public function alnp_enqueue_scripts() {
222 222
 			// Load the Javascript if found as a singluar post and the user is not a bot.
223
-			if ( !alnp_is_bot() && is_singular() && get_post_type() == 'post' ) {
223
+			if ( ! alnp_is_bot() && is_singular() && get_post_type() == 'post') {
224 224
 				// This checks to see if the JavaScript should load in the footer or not.
225 225
 				$load_in_footer = alnp_load_js_in_footer();
226 226
 
227
-				$this->load_file( 'auto-load-next-post-scrollspy', '/assets/js/libs/scrollspy.min.js', true, array('jquery'), AUTO_LOAD_NEXT_POST_VERSION, $load_in_footer );
227
+				$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);
228 228
 
229 229
 				// Only load History.js when not in the customizer.
230
-				if ( ! is_customize_preview() ) {
231
-					$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 );
230
+				if ( ! is_customize_preview()) {
231
+					$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);
232 232
 				}
233 233
 
234
-				$this->load_file( 'auto-load-next-post-script', '/assets/js/frontend/auto-load-next-post' . AUTO_LOAD_NEXT_POST_DEBUG_MODE.AUTO_LOAD_NEXT_POST_SCRIPT_MODE . '.js', true, array('auto-load-next-post-scrollspy'), AUTO_LOAD_NEXT_POST_VERSION, $load_in_footer );
234
+				$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);
235 235
 
236 236
 				// Variables for the JavaScript
237
-				wp_localize_script( 'auto-load-next-post-script', 'auto_load_next_post_params', array(
237
+				wp_localize_script('auto-load-next-post-script', 'auto_load_next_post_params', array(
238 238
 					'alnp_version'              => AUTO_LOAD_NEXT_POST_VERSION,
239
-					'alnp_content_container'    => get_option( 'auto_load_next_post_content_container' ),
240
-					'alnp_title_selector'       => get_option( 'auto_load_next_post_title_selector' ),
241
-					'alnp_navigation_container' => get_option( 'auto_load_next_post_navigation_container' ),
242
-					'alnp_comments_container'   => get_option( 'auto_load_next_post_comments_container' ),
243
-					'alnp_remove_comments'      => get_option( 'auto_load_next_post_remove_comments' ),
244
-					'alnp_google_analytics'     => get_option( 'auto_load_next_post_google_analytics' ),
245
-					'alnp_event_on_load'        => get_option( 'auto_load_next_post_on_load_event' ),
246
-					'alnp_event_on_entering'    => get_option( 'auto_load_next_post_on_entering_event' ),
239
+					'alnp_content_container'    => get_option('auto_load_next_post_content_container'),
240
+					'alnp_title_selector'       => get_option('auto_load_next_post_title_selector'),
241
+					'alnp_navigation_container' => get_option('auto_load_next_post_navigation_container'),
242
+					'alnp_comments_container'   => get_option('auto_load_next_post_comments_container'),
243
+					'alnp_remove_comments'      => get_option('auto_load_next_post_remove_comments'),
244
+					'alnp_google_analytics'     => get_option('auto_load_next_post_google_analytics'),
245
+					'alnp_event_on_load'        => get_option('auto_load_next_post_on_load_event'),
246
+					'alnp_event_on_entering'    => get_option('auto_load_next_post_on_entering_event'),
247 247
 					'alnp_is_customizer'        => $this->is_alnp_using_customizer(),
248 248
 					'alnp_load_in_footer'       => $load_in_footer
249
-				) );
249
+				));
250 250
 			} // END if is_singular() && get_post_type()
251 251
 		} // END alnp_enqueue_scripts()
252 252
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 		 * @return string|false
260 260
 		 */
261 261
 		public static function is_alnp_using_customizer() {
262
-			if ( is_customize_preview() ) {
262
+			if (is_customize_preview()) {
263 263
 				return "yes";
264 264
 			}
265 265
 
@@ -280,19 +280,19 @@  discard block
 block discarded – undo
280 280
 		 * @param   string  $version   Optional, can match the version of the plugin or version of the source file.
281 281
 		 * @param   bool    $footer Optional, can set the JavaScript to load in the footer instead.
282 282
 		 */
283
-		public static function load_file( $name, $file_path, $is_script = false, $support = array(), $version = '', $footer = false ) {
284
-			$url = AUTO_LOAD_NEXT_POST_URL_PATH . $file_path; // URL to the file.
285
-
286
-			if ( file_exists( AUTO_LOAD_NEXT_POST_FILE_PATH . $file_path ) ) {
287
-				if ( $is_script ) {
288
-					if ( !wp_script_is( $name, 'registered' ) ) {
289
-						wp_register_script( $name, $url, $support, $version, $footer );
290
-						wp_enqueue_script( $name );
283
+		public static function load_file($name, $file_path, $is_script = false, $support = array(), $version = '', $footer = false) {
284
+			$url = AUTO_LOAD_NEXT_POST_URL_PATH.$file_path; // URL to the file.
285
+
286
+			if (file_exists(AUTO_LOAD_NEXT_POST_FILE_PATH.$file_path)) {
287
+				if ($is_script) {
288
+					if ( ! wp_script_is($name, 'registered')) {
289
+						wp_register_script($name, $url, $support, $version, $footer);
290
+						wp_enqueue_script($name);
291 291
 					}
292 292
 				} else {
293
-					if ( !wp_style_is( $name, 'registered' ) ) {
294
-						wp_register_style( $name, $url );
295
-						wp_enqueue_style( $name );
293
+					if ( ! wp_style_is($name, 'registered')) {
294
+						wp_register_style($name, $url);
295
+						wp_enqueue_style($name);
296 296
 					}
297 297
 				} // end if
298 298
 			} // end if
Please login to merge, or discard this patch.