Skip to content

Commit cceec5f

Browse files
committed
Fixed bug with config registry scope
1 parent cf4e2aa commit cceec5f

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

core/Helpers/StringHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function get_const( $const, $filter_validate = null ) {
4444
*/
4545
public static function encrypt( $str ) {
4646
$salt = defined( 'WP_ENCRYPT_KEY' ) && WP_ENCRYPT_KEY ? WP_ENCRYPT_KEY : SECURE_AUTH_KEY;
47-
return openssl_encrypt($str, self::$config->get( 'encrypt_method' ), $salt);
47+
return openssl_encrypt($str, self::$registry->get( 'encrypt_method' ), $salt);
4848
}
4949

5050
/**
@@ -57,7 +57,7 @@ public static function encrypt( $str ) {
5757
*/
5858
public static function decrypt( $str ) {
5959
$salt = defined( 'WP_ENCRYPT_KEY' ) && WP_ENCRYPT_KEY ? WP_ENCRYPT_KEY : SECURE_AUTH_KEY;
60-
return openssl_decrypt($str, self::$config->get( 'encrypt_method' ), $salt);
60+
return openssl_decrypt($str, self::$registry->get( 'encrypt_method' ), $salt);
6161
}
6262

6363
/**

core/ObjectCache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class ObjectCache extends ToolKit {
2020
*/
2121
public function get_object( $key = null, $callback, $cache_disabled = false ) {
2222

23-
$object_cache_group = self::$config->get( 'object_cache/group' ) ? self::$config->get( 'object_cache/group' ) : sanitize_title( self::$config->get( 'data/Name' ) );
23+
$object_cache_group = self::$registry->get( 'object_cache/group' ) ? self::$registry->get( 'object_cache/group' ) : sanitize_title( self::$registry->get( 'data/Name' ) );
2424
if( is_multisite() ) $object_cache_group .= '_' . get_current_blog_id();
25-
$object_cache_expire = ( is_int( self::$config->get( 'object_cache/expire_hours' ) ) ? self::$config->get( 'object_cache/expire_hours' ) : 24 ) * 86400; // Default to 24 hours
25+
$object_cache_expire = ( is_int( self::$registry->get( 'object_cache/expire_hours' ) ) ? self::$registry->get( 'object_cache/expire_hours' ) : 24 ) * 86400; // Default to 24 hours
2626

2727
$result = null;
2828

core/ScriptObject.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public function __construct( $values ) {
2828
'css_media' => null,
2929
'dependencies' => array(),
3030
'localize' => null,
31-
'variable_name' => $this->prefix( self::$config->get( 'js_object' ) ?: 'js_object' ),
31+
'variable_name' => $this->prefix( self::$registry->get( 'js_object' ) ?: 'js_object' ),
3232
'handle' => $this->prefix( 'dynamic_script' ),
33-
'script_dir' => $this->prefix( self::$config->get( 'dynamic_scripts_directory' ) ?: 'dynamic' ),
33+
'script_dir' => $this->prefix( self::$registry->get( 'dynamic_scripts_directory' ) ?: 'dynamic' ),
3434
'filename' => null
3535
);
3636

core/ToolKit.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
*/
99
class 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

Comments
 (0)