Exemplo n.º 1
0
<?php

// Set up the sections in Theme Options
$section = array("name" => "header", "title" => __('Header', 'nuts'), "description" => __('Options for the header, logo, etc.', 'nuts'), "tab" => "Header");
nuts_register_section($section);
$section = array("name" => "colors", "title" => __('Colors', 'nuts'), "description" => __('Set up the theme colors here', 'nuts'), "tab" => "Colors");
nuts_register_section($section);
$section = array("name" => "other", "title" => __('Other options', 'nuts'), "description" => __('Some miscellaneous options', 'nuts'), "tab" => "Other");
nuts_register_section($section);
// And some custom field sections for posts
$section = array("name" => "post::post_options", "title" => __('Post Options', 'nuts'), "description" => __('This is an example metabox section', 'nuts'), "tab" => "");
nuts_register_section($section);
Exemplo n.º 2
0
function nuts_admin_init()
{
    global $nuts_options_array;
    add_theme_page(__('NUTS Theme Options', 'nuts'), __('Theme Options', 'nuts'), 'manage_options', 'nuts_theme_options', 'nuts_theme_options');
    if (get_option('nuts_theme_options') == false) {
        add_option('nuts_theme_options');
    }
    register_setting('nuts_theme_options', 'nuts_theme_options');
    $loaded_sections = array();
    // Add the option fields
    foreach ($nuts_options_array as $option) {
        // Dynamically create sections if not registered yet.
        if (!in_array($option["section"], $loaded_sections)) {
            add_settings_section($option["section"], nuts_section_name($option["section"]), 'nuts_section_info', 'nuts_theme_options');
            $loaded_sections[] = $option["section"];
            if (!nuts_section_registered($option["section"])) {
                nuts_register_section(array("name" => $option["section"], "title" => $option["section"], "description" => "", "tab" => $option["section"]));
            }
        }
        if (!isset($option["type"])) {
            $option["type"] = "";
        }
        if (strstr($option["section"], "::") == false) {
            add_settings_field($option["name"], $option["title"], 'nuts_theme_options_callback', 'nuts_theme_options', $option["section"], $option);
        }
    }
}