Skip to content

Instantly share code, notes, and snippets.

@vishalbasnet23
Last active April 19, 2016 10:08
Show Gist options
  • Save vishalbasnet23/ba99ad51c7112bda99e738cc6408938d to your computer and use it in GitHub Desktop.
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.
<?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