@@ -86,7 +86,7 @@ public function get( $args = array(), $assoc_args = array() ) {
8686 }
8787
8888 // This array will hold the list of theme mods in a format suitable for the WP CLI Formatter.
89- $ list = array ();
89+ $ mod_list = array ();
9090
9191 // If specific mods are requested, filter out any that aren't requested.
9292 $ mods = ! empty ( $ args ) ? array_intersect_key ( get_theme_mods (), array_flip ( $ args ) ) : get_theme_mods ();
@@ -99,17 +99,17 @@ public function get( $args = array(), $assoc_args = array() ) {
9999 $ separator = '!!! ' ;
100100 array_walk (
101101 $ mods ,
102- function ( $ value , $ key ) use ( &$ list , $ separator ) {
103- $ this ->mod_to_string ( $ key , $ value , $ list , $ separator );
102+ function ( $ value , $ key ) use ( &$ mod_list , $ separator ) {
103+ $ this ->mod_to_string ( $ key , $ value , $ mod_list , $ separator );
104104 }
105105 );
106106
107107 // Take our Formatter-friendly list and adjust it according to the requested format.
108108 switch ( \WP_CLI \Utils \get_flag_value ( $ assoc_args , 'format ' ) ) {
109109 // For tables we use a double space to indent child items.
110110 case 'table ' :
111- $ list = array_map (
112- function ( $ item ) {
111+ $ mod_list = array_map (
112+ function ( $ item ) {
113113 $ parts = explode ( '!!! ' , $ item ['key ' ] );
114114 $ new_key = array_pop ( $ parts );
115115 if ( ! empty ( $ parts ) ) {
@@ -120,71 +120,74 @@ function( $item ) {
120120 'value ' => $ item ['value ' ],
121121 ];
122122 },
123- $ list
123+ $ mod_list
124124 );
125125 break ;
126126
127127 // For JSON, CSV, and YAML formats we use dot notation to show the hierarchy.
128128 case 'csv ' :
129129 case 'yaml ' :
130130 case 'json ' :
131- $ list = array_filter ( array_map (
132- function ( $ item ) {
133- return [
134- 'key ' => str_replace ( '!!! ' , '. ' , $ item ['key ' ] ),
135- 'value ' => $ item ['value ' ],
136- ];
137- },
138- $ list
139- ), function ( $ item ) {
140- return ! empty ( $ item ['value ' ] );
141- } );
131+ $ mod_list = array_filter (
132+ array_map (
133+ function ( $ item ) {
134+ return [
135+ 'key ' => str_replace ( '!!! ' , '. ' , $ item ['key ' ] ),
136+ 'value ' => $ item ['value ' ],
137+ ];
138+ },
139+ $ mod_list
140+ ),
141+ function ( $ item ) {
142+ return ! empty ( $ item ['value ' ] );
143+ }
144+ );
142145 break ;
143146 }
144147
145148 // Output the list using the WP CLI Formatter.
146149 $ formatter = new \WP_CLI \Formatter ( $ assoc_args , $ this ->fields , 'thememods ' );
147- $ formatter ->display_items ( $ list );
150+ $ formatter ->display_items ( $ mod_list );
148151 }
149152
150153 /**
151154 * Convert the theme mods to a flattened array with a string representation of the keys.
152155 *
153156 * @param string $key The mod key
154157 * @param mixed $value The value of the mod.
155- * @param array $list The list so far, passed by reference.
158+ * @param array $mod_list The list so far, passed by reference.
156159 * @param string $separator A string to separate keys to denote their place in the tree.
157160 */
158- private function mod_to_string ( $ key , $ value , &$ list , $ separator ) {
161+ private function mod_to_string ( $ key , $ value , &$ mod_list , $ separator ) {
159162 if ( is_array ( $ value ) || is_object ( $ value ) ) {
160163 // Convert objects to arrays for easier handling.
161164 $ value = (array ) $ value ;
162165
163166 // Explicitly handle empty arrays to ensure they are displayed.
164167 if ( empty ( $ value ) ) {
165- $ list [] = array (
168+ $ mod_list [] = array (
166169 'key ' => $ key ,
167170 'value ' => '[empty array] ' ,
168171 );
169172 return ;
170173 }
171174
172175 // Arrays get their own entry in the list to allow for sensible table output.
173- $ list [] = array (
176+ $ mod_list [] = array (
174177 'key ' => $ key ,
175178 'value ' => '' ,
176179 );
177180
178181 foreach ( $ value as $ child_key => $ child_value ) {
179- $ this ->mod_to_string ( $ key . $ separator . $ child_key , $ child_value , $ list , $ separator );
182+ $ this ->mod_to_string ( $ key . $ separator . $ child_key , $ child_value , $ mod_list , $ separator );
180183 }
181184 } else {
182185 // Explicitly handle boolean values to ensure they are displayed correctly.
183186 if ( is_bool ( $ value ) ) {
184187 $ value = $ value ? '[true] ' : '[false] ' ;
185188 }
186189
187- $ list [] = array (
190+ $ mod_list [] = array (
188191 'key ' => $ key ,
189192 'value ' => $ value ,
190193 );
0 commit comments