Skip to content

Commit 2c7442f

Browse files
author
Guido W. Pettinari
committed
Fix bug per cui estendendo config non si prendeva il db_prefix
1 parent 7d5faa7 commit 2c7442f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/class-config.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
* per accedere alle opzioni, invece di dover fare
1515
* $sezione_x = get_option('sezione_x)
1616
* $opzione_y = $sezione_x['opzione_y]
17+
*
18+
* Estendi la classe per definire dei valori di default
19+
* e per definire un prefisso a database.
1720
*/
1821
abstract class config
1922
{
@@ -78,14 +81,14 @@ public static function config( string $query, $default = null )
7881
throw new Exception( 'Passato valore vuoto o invalido a config', 1 );
7982
}
8083

81-
$default = $default ?? self::getDefaultValue( $query );
84+
$default = $default ?? static::getDefaultValue( $query );
8285

8386
$option_key = $option_name;
8487

85-
if ( self::$db_prefix ) {
86-
$option_key = self::$db_prefix . $option_key;
88+
if ( static::$db_prefix ) {
89+
$option_key = static::$db_prefix . $option_key;
8790
}
88-
91+
8992
$option_value = get_option( $option_key, $default );
9093

9194
if ( count( $tokens ) === 1 ) {
@@ -101,7 +104,7 @@ public static function config( string $query, $default = null )
101104
*/
102105
public static function getDefaultValue( string $query )
103106
{
104-
$defaults = self::getDefaults();
107+
$defaults = static::getDefaults();
105108

106109
return $defaults[ $query ] ?? null;
107110
}

0 commit comments

Comments
 (0)