예제 #1
0
 /**
  * Retrieve the registered option name for theme options.
  *
  * @since 1.0.0
  * @uses get_audiotheme_theme_options_support()
  */
 function get_audiotheme_theme_options_name()
 {
     static $option_name;
     if (!isset($option_name) && ($name = get_audiotheme_theme_options_support('option_name'))) {
         // The default option name is the first one registered in add_theme_support().
         $option_name = is_array($name) ? $name[0] : $name;
     }
     return isset($option_name) ? $option_name : false;
 }
예제 #2
0
/**
 * Initialize the settings object and related hooks, and add a Theme Options
 * screen if the current theme supports it.
 *
 * Hooked on 'init' in audiotheme_admin_setup().
 *
 * @since 1.0.0
 */
function audiotheme_settings_init()
{
    // Add theme options support.
    if (($support = get_audiotheme_theme_options_support()) && !empty($support['callback']) && function_exists($support['callback'])) {
        $settings = get_audiotheme_settings();
        $screen = add_audiotheme_settings_screen('audiotheme-theme-options', __('Theme Options', 'audiotheme'), array('menu_title' => $support['menu_title'], 'option_group' => 'audiotheme_theme_mods', 'option_name' => $support['option_name'], 'show_in_menu' => 'themes.php', 'capability' => 'edit_theme_options'));
        // Registering the callback like this ensures that an error isn't thrown if the framework isn't active.
        add_action('audiotheme_register_settings', $support['callback']);
    }
    // These must occur after the callback to register settings.
    add_action('customize_register', 'audiotheme_settings_register_customizer_settings');
    // Lower priority allows screens to be registered in the 'admin_menu' hook and still have the menu item display.
    add_action('admin_menu', 'audiotheme_settings_add_admin_menus', 20);
    add_action('network_admin_menu', 'audiotheme_settings_add_admin_menus', 20);
    // Settings should be registered before this.
    add_action('admin_init', 'audiotheme_settings_register_wp_settings_api', 20);
    add_action('admin_init', 'audiotheme_settings_save_network_options');
    // Custom settings should be registered during this hook.
    do_action('audiotheme_register_settings');
}