44 *
55 * @author Seth Carstens
66 * @package abtract-plugin-base
7- * @version 2.6.0
7+ * @version 2.6.2
88 * @license GPL 2.0 - please retain comments that express original build of this file by the author.
99 */
1010
@@ -122,7 +122,7 @@ abstract class Abstract_Plugin {
122122 *
123123 * @var array $plugin_data Array of meta data representing meta from main plugin file
124124 */
125- public $ plugin_data = array () ;
125+ public $ plugin_data = [] ;
126126
127127 /**
128128 * If plugin_data is built, this represents the version number defined the the main plugin file meta
@@ -155,6 +155,7 @@ abstract class Abstract_Plugin {
155155
156156 /**
157157 * First thing setup by class with provided namespace for use as prefix in WordPress hooks & actions
158+ *
158159 * @var string
159160 */
160161 public $ wp_hook_pre = '' ;
@@ -165,31 +166,31 @@ abstract class Abstract_Plugin {
165166 */
166167 public function __construct () {
167168
168- // setup hook prefix used to create unique actions/filters unique to this plugin
169+ // Setup hook prefix used to create unique actions/filters unique to this plugin.
169170 $ this ->wp_hook_pre = trim ( strtolower ( str_ireplace ( '\\' , '_ ' , get_called_class () ) ) ) . '_ ' ;
170171
171172 // Hook can be used by mu plugins to modify plugin behavior after plugin is setup.
172173 do_action ( $ this ->wp_hook_pre . '_preface ' , $ this );
173174
174- // configure and setup the plugin class variables.
175+ // Configure and setup the plugin class variables.
175176 $ this ->configure_defaults ();
176177
177178 // Define globals used by the plugin including bloginfo.
178179 $ this ->defines_and_globals ();
179180
180181 // If enabled, register auto-loading to include any files in the $autoload_dir.
181182 if ( ! empty ( static ::$ autoload_type ) ) {
182- spl_autoload_register ( array ( $ this , 'autoload ' ) );
183+ spl_autoload_register ( [ $ this , 'autoload ' ] );
183184 }
184185
185186 // Onload to do things during plugin construction.
186187 $ this ->onload ( $ this );
187188
188189 // Most actions go into init which loads after WordPress core sets up all the defaults.
189- add_action ( 'init ' , array ( $ this , 'init ' ) );
190+ add_action ( 'init ' , [ $ this , 'init ' ] );
190191
191192 // Init for use with logged in users, see this::authenticated_init for more details.
192- add_action ( 'init ' , array ( $ this , 'authenticated_init ' ) );
193+ add_action ( 'init ' , [ $ this , 'authenticated_init ' ] );
193194
194195 // Hook can be used by mu plugins to modify plugin behavior after plugin is setup.
195196 do_action ( $ this ->wp_hook_pre . '_setup ' , $ this );
@@ -227,7 +228,7 @@ public function autoload( $class ) {
227228 $ intersect = array_intersect_assoc ( $ parent , $ class_array );
228229 $ intersect_depth = count ( $ intersect );
229230 $ autoload_match_depth = static ::$ autoload_ns_match_depth ;
230- // Confirm $class is in same namespace as this autoloader
231+ // Confirm $class is in same namespace as this autoloader.
231232 if ( $ intersect_depth >= $ autoload_match_depth ) {
232233 $ file = $ this ->get_file_name_from_class ( $ class );
233234 if ( 'classmap ' === static ::$ autoload_type && is_array ( $ this ->autoload_dir ) ) {
@@ -259,7 +260,7 @@ protected function configure_defaults() {
259260
260261 if ( file_exists ( $ this ->plugin_file ) ) {
261262 $ this ->installed_url = plugins_url ( '/ ' , $ this ->plugin_file );
262- // Ensure get_plugin_data is available
263+ // Ensure get_plugin_data is available.
263264 require_once ( ABSPATH . 'wp-admin/includes/plugin.php ' );
264265 $ this ->plugin_data = get_plugin_data ( $ this ->plugin_file , $ markup = true , $ translate = true );
265266 if ( is_array ( $ this ->plugin_data ) && isset ( $ this ->plugin_data ['Version ' ] ) ) {
@@ -295,8 +296,8 @@ abstract protected function defines_and_globals();
295296 /**
296297 * Dirname function that mimics PHP7 dirname() enhancements so that we can enable PHP5.6 support.
297298 *
298- * @param $path
299- * @param int $count
299+ * @param string $path Path to this specific plugins directory.
300+ * @param int $count How many directories to look upwards.
300301 *
301302 * @return string
302303 */
@@ -325,8 +326,8 @@ public static function filepath_to_classname( $file, $installed_dir, $namespace
325326 $ path_info = pathinfo ( $ path_info );
326327 $ converted_dir = str_replace ( '/ ' , '\\' , $ path_info ['dirname ' ] );
327328 $ converted_dir = ucwords ( $ converted_dir , '_ \\' );
328- $ filename_search = array ( static ::$ filename_prefix , '- ' ) ;
329- $ filename_replace = array ( '' , '_ ' ) ;
329+ $ filename_search = [ static ::$ filename_prefix , '- ' ] ;
330+ $ filename_replace = [ '' , '_ ' ] ;
330331 $ class = str_ireplace ( $ filename_search , $ filename_replace , $ path_info ['filename ' ] );
331332 $ class_name = $ namespace . $ converted_dir . '\\' . ucwords ( $ class , '_ ' );
332333
@@ -407,19 +408,19 @@ private function load_file( $path ) {
407408 /**
408409 * Take a namespaced class name and turn it into a file name.
409410 *
410- * @param string $class
411+ * @param string $class The name of the class to load.
411412 *
412413 * @return string
413414 */
414415 private function psr4_get_file_name_from_class ( $ class ) {
415416 $ class = strtolower ( $ class );
416417 if ( stristr ( $ class , '\\' ) ) {
417418
418- // if the first item is == the collection name, trim it off
419+ // If the first item is == the collection name, trim it off.
419420 $ class = str_ireplace ( static ::$ autoload_class_prefix , '' , $ class );
420421
421422 // Maybe fix formatting underscores to dashes and double to single slashes.
422- $ class = str_replace ( array ( '_ ' , '\\' ), array ( '- ' , '/ ' ) , $ class );
423+ $ class = str_replace ( [ '_ ' , '\\' ], [ '- ' , '/ ' ] , $ class );
423424 $ class = explode ( '/ ' , $ class );
424425 $ file_name = &$ class [ count ( $ class ) - 1 ];
425426 $ file_name = static ::$ filename_prefix . $ file_name . '.php ' ;
@@ -434,19 +435,19 @@ private function psr4_get_file_name_from_class( $class ) {
434435 /**
435436 * Setup special hooks that don't run after plugins_loaded action
436437 *
437- * @param $file
438+ * @param string $file File location on the server, passed in and used to build other paths.
438439 */
439440 public static function run ( $ file ) {
440441 // Logic required for WordPress VIP plugins to load during themes function file initialization.
441442 if ( did_action ( 'plugins_loaded ' ) ) {
442- add_action ( 'init ' , array ( get_called_class (), 'load ' ) , 1 );
443+ add_action ( 'init ' , [ get_called_class (), 'load ' ] , 1 );
443444 } else {
444- add_action ( 'plugins_loaded ' , array ( get_called_class (), 'load ' ) );
445+ add_action ( 'plugins_loaded ' , [ get_called_class (), 'load ' ] );
445446 }
446447 // Installation and un-installation hooks.
447- register_activation_hook ( $ file , array ( get_called_class (), 'activate ' ) );
448- register_deactivation_hook ( $ file , array ( get_called_class (), 'deactivate ' ) );
449- register_uninstall_hook ( $ file , array ( get_called_class (), 'uninstall ' ) );
448+ register_activation_hook ( $ file , [ get_called_class (), 'activate ' ] );
449+ register_deactivation_hook ( $ file , [ get_called_class (), 'deactivate ' ] );
450+ register_uninstall_hook ( $ file , [ get_called_class (), 'uninstall ' ] );
450451 }
451452
452453 /**
0 commit comments