88 */
99class ToolKit {
1010
11- protected static $ config ;
1211 protected static $ cache ;
12+ protected static $ registry ;
1313
1414 protected function init ( $ base_dir = null , $ args = null ) {
1515
@@ -34,13 +34,14 @@ protected function init( $base_dir = null, $args = null ) {
3434 // Define toolkit version
3535 if ( !defined ( __NAMESPACE__ . '\VERSION ' ) ) define ( __NAMESPACE__ . '\VERSION ' , $ config ->get ( 'toolkit-version ' ) );
3636
37- self ::$ config = $ config ;
38-
3937 // Initialize ObjectCache
4038 self ::$ cache = new ObjectCache ( $ config );
4139
4240 // Load Environmental Variables
43- $ this ->load_env_vars ( [ $ base_dir , self ::$ config ->get ( 'wordpress/root_dir ' ) ] );
41+ $ this ->load_env_vars ( [ $ base_dir , $ config ->get ( 'wordpress/root_dir ' ) ] );
42+
43+ self ::$ registry = $ config ;
44+ return $ config ;
4445
4546 }
4647
@@ -55,7 +56,7 @@ protected function init( $base_dir = null, $args = null ) {
5556 */
5657 public static function prefix ( $ field_name = null , $ before = '' , $ after = '_ ' ) {
5758
58- $ prefix = $ before . self ::$ config ->get ( 'prefix ' ) . $ after ;
59+ $ prefix = $ before . self ::$ registry ->get ( 'prefix ' ) . $ after ;
5960 return $ field_name !== null ? $ prefix . $ field_name : $ prefix ;
6061
6162 }
@@ -69,7 +70,7 @@ public static function prefix( $field_name = null, $before = '', $after = '_' )
6970 * @since 0.1.4
7071 */
7172 protected function get_config ( $ key = null ) {
72- return self ::$ config ->get ( $ key );
73+ return self ::$ registry ->get ( $ key );
7374 }
7475
7576 /**
@@ -80,11 +81,11 @@ protected function get_config( $key = null) {
8081 * @since 0.2.0
8182 */
8283 protected function get_current_plugin_meta ( $ type = ConfigRegistry ) {
83- if ( !self ::$ config ->get ( 'base_dir ' ) ) return [];
84+ if ( !self ::$ registry ->get ( 'base_dir ' ) ) return [];
8485
85- $ plugin_data ['slug ' ] = current ( explode ( DIRECTORY_SEPARATOR , plugin_basename ( self ::$ config ->get ( 'base_dir ' ) ) ) );
86- $ plugin_data ['path ' ] = trailingslashit ( str_replace ( plugin_basename ( self ::$ config ->get ( 'base_dir ' ) ), '' , rtrim ( self ::$ config ->get ( 'base_dir ' ), '/ ' ) ) . $ plugin_data ['slug ' ] );
87- $ plugin_data ['url ' ] = current ( explode ( $ plugin_data ['slug ' ] . '/ ' , plugin_dir_url ( self ::$ config ->get ( 'base_dir ' ) ) ) ) . $ plugin_data ['slug ' ] . '/ ' ;
86+ $ plugin_data ['slug ' ] = current ( explode ( DIRECTORY_SEPARATOR , plugin_basename ( self ::$ registry ->get ( 'base_dir ' ) ) ) );
87+ $ plugin_data ['path ' ] = trailingslashit ( str_replace ( plugin_basename ( self ::$ registry ->get ( 'base_dir ' ) ), '' , rtrim ( self ::$ registry ->get ( 'base_dir ' ), '/ ' ) ) . $ plugin_data ['slug ' ] );
88+ $ plugin_data ['url ' ] = current ( explode ( $ plugin_data ['slug ' ] . '/ ' , plugin_dir_url ( self ::$ registry ->get ( 'base_dir ' ) ) ) ) . $ plugin_data ['slug ' ] . '/ ' ;
8889
8990 // Get plugin path/file identifier
9091 foreach ( get_plugins () as $ key => $ plugin ) {
0 commit comments