Completed
Push — develop ( 5804a9...758947 )
by Aristeides
02:44
created
core/class-kirki-values.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -43,14 +43,14 @@  discard block
 block discarded – undo
43 43
 		$config_id = ( '' === $config_id ) ? 'global' : $config_id;
44 44
 
45 45
 		// Fallback to 'global' if $config_id is not found.
46
-		if ( ! isset( Kirki::$config[ $config_id ] ) ) {
46
+		if ( ! isset( Kirki::$config[$config_id] ) ) {
47 47
 			$config_id = 'global';
48 48
 		}
49 49
 
50
-		switch ( Kirki::$config[ $config_id ]['option_type'] ) {
50
+		switch ( Kirki::$config[$config_id]['option_type'] ) {
51 51
 			case 'option':
52 52
 			case 'site_option':
53
-				$site_option = (bool) ( 'site_option' === Kirki::$config[ $config_id ] );
53
+				$site_option = (bool) ( 'site_option' === Kirki::$config[$config_id] );
54 54
 				return apply_filters( 'kirki/values/get_value', $this->get_from_option( $config_id, $field_id, $site_option ), $field_id );
55 55
 			case 'user_meta':
56 56
 				$user_id = get_current_user_id();
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	private static function get_from_theme_mod( $field_id ) {
74 74
 		// We're using theme_mods so just get the value using get_theme_mod.
75 75
 		$default_value = null;
76
-		if ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ]['default'] ) ) {
77
-			$default_value = Kirki::$fields[ $field_id ]['default'];
76
+		if ( isset( Kirki::$fields[$field_id] ) && isset( Kirki::$fields[$field_id]['default'] ) ) {
77
+			$default_value = Kirki::$fields[$field_id]['default'];
78 78
 		}
79 79
 		return get_theme_mod( $field_id, $default_value );
80 80
 	}
@@ -92,25 +92,25 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	private static function get_from_option( $config_id, $field_id, $site_option = false ) {
94 94
 		$get_option = ( $site_option ) ? 'get_site_option' : 'get_option';
95
-		if ( '' !== Kirki::$config[ $config_id ]['option_name'] ) {
95
+		if ( '' !== Kirki::$config[$config_id]['option_name'] ) {
96 96
 
97 97
 			// Options are serialized as a single option in the db.
98 98
 			// We'll have to get the option and then get the item from the array.
99
-			$options = $get_option( Kirki::$config[ $config_id ]['option_name'] );
99
+			$options = $get_option( Kirki::$config[$config_id]['option_name'] );
100 100
 
101
-			if ( ! isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']' ] ) ) {
102
-				$field_id = Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']';
101
+			if ( ! isset( Kirki::$fields[$field_id] ) && isset( Kirki::$fields[Kirki::$config[$config_id]['option_name'] . '[' . $field_id . ']'] ) ) {
102
+				$field_id = Kirki::$config[$config_id]['option_name'] . '[' . $field_id . ']';
103 103
 			}
104
-			$setting_modified = str_replace( ']', '', str_replace( Kirki::$config[ $config_id ]['option_name'] . '[', '', $field_id ) );
104
+			$setting_modified = str_replace( ']', '', str_replace( Kirki::$config[$config_id]['option_name'] . '[', '', $field_id ) );
105 105
 
106
-			$default_value = ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ]['default'] ) ) ? Kirki::$fields[ $field_id ]['default'] : '';
107
-			$value = ( isset( $options[ $setting_modified ] ) ) ? $options[ $setting_modified ] : $default_value;
106
+			$default_value = ( isset( Kirki::$fields[$field_id] ) && isset( Kirki::$fields[$field_id]['default'] ) ) ? Kirki::$fields[$field_id]['default'] : '';
107
+			$value = ( isset( $options[$setting_modified] ) ) ? $options[$setting_modified] : $default_value;
108 108
 			$value = maybe_unserialize( $value );
109 109
 			return apply_filters( 'kirki/values/get_value', $value, $field_id );
110 110
 		}
111 111
 
112 112
 		// Each option separately saved in the db.
113
-		return $get_option( $field_id, Kirki::$fields[ $field_id ]['default'] );
113
+		return $get_option( $field_id, Kirki::$fields[$field_id]['default'] );
114 114
 	}
115 115
 
116 116
 	/**
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 			if ( isset( $field['option_name'] ) && '' !== $field['option_name'] ) {
130 130
 				$all_values = get_option( $field['option_name'], array() );
131 131
 				$sub_setting_id = str_replace( array( ']', $field['option_name'] . '[' ), '', $field['settings'] );
132
-				if ( isset( $all_values[ $sub_setting_id ] ) ) {
133
-					$value = $all_values[ $sub_setting_id ];
132
+				if ( isset( $all_values[$sub_setting_id] ) ) {
133
+					$value = $all_values[$sub_setting_id];
134 134
 				}
135 135
 			} else {
136 136
 				$value = get_option( $field['settings'], $field['default'] );
Please login to merge, or discard this patch.