Last active
July 12, 2019 09:27
-
-
Save Balachandark/d91f892b8b8dc9530f954d6a5591ca5f to your computer and use it in GitHub Desktop.
Fetch all Astra customizer controls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'astra_customizer_configurations', 'register_configuration', 999, 2 ); | |
function register_configuration( $configurations, $wp_customize ) { | |
$arr = array(); | |
foreach ($configurations as $key => $value) { | |
if( isset( $value['parent'] ) ) { | |
$value['parent'] = str_replace( "astra-settings[", "", $value['parent']); | |
$value['parent'] = str_replace( "]", "" , $value['parent'] ); | |
if( array_key_exists( $value['parent'], $arr ) ) { | |
if( is_array( $arr[$value['parent']] ) ) { | |
$arr[ $value['parent'] ] = array_merge( array ( $value['name'] ), $arr[$value['parent']] ); | |
} else { | |
$arr[ $value['parent'] ] = array_merge( array ( $value['name'] ), array ( $arr[$value['parent']] ) ); | |
} | |
} else { | |
$arr[ $value['parent'] ] = $value['name']; | |
} | |
} | |
} | |
echo "<pre>"; | |
print_r( json_encode( $arr ) ); | |
echo "</pre>"; | |
return $configurations; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment