Last active
April 19, 2016 10:08
-
-
Save vishalbasnet23/ba99ad51c7112bda99e738cc6408938d to your computer and use it in GitHub Desktop.
Add custom endpoint to WP-Rest Api to retrive customizer values of active theme.
This file contains hidden or 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_action( 'rest_api_init', 'plugin_customizer_fields'); | |
function plugin_customizer_fields() { | |
register_rest_route( 'beyondthebell/v1', '/customizer-fields/', array( | |
'methods' => 'GET', | |
'callback' => 'get_active_theme_customizer_fields', | |
) ); | |
} | |
function get_active_theme_customizer_fields() { | |
$current_active_theme = wp_get_theme(); | |
$current_active_theme_name = $current_active_theme->get('Name'); | |
$theme_mod = get_option( 'theme_mods_'.$current_active_theme_name ); | |
return $theme_mod; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment