Untitled diff

बनाया गया Diff कभी समाप्त नहीं होता
3 हटाए गए
531 लाइनें
3 जोड़े गए
531 लाइनें
<?php
<?php
/**
/**
* Twenty Eleven Theme Options
* Twenty Eleven Theme Options
*
*
* @package WordPress
* @package WordPress
* @subpackage Twenty_Eleven
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
* @since Twenty Eleven 1.0
*/
*/
/**
/**
* Properly enqueue styles and scripts for our theme options page.
* Properly enqueue styles and scripts for our theme options page.
*
*
* This function is attached to the admin_enqueue_scripts action hook.
* This function is attached to the admin_enqueue_scripts action hook.
*
*
* @since Twenty Eleven 1.0
* @since Twenty Eleven 1.0
*
*
*/
*/
function twentyeleven_admin_enqueue_scripts( $hook_suffix ) {
function twentyeleven_admin_enqueue_scripts( $hook_suffix ) {
wp_enqueue_style( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options.css', false, '2011-04-28' );
wp_enqueue_style( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options.css', false, '2011-04-28' );
wp_enqueue_script( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options.js', array( 'farbtastic' ), '2011-06-10' );
wp_enqueue_script( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options.js', array( 'farbtastic' ), '2011-06-10' );
wp_enqueue_style( 'farbtastic' );
wp_enqueue_style( 'farbtastic' );
}
}
add_action( 'admin_print_styles-appearance_page_theme_options', 'twentyeleven_admin_enqueue_scripts' );
add_action( 'admin_print_styles-appearance_page_theme_options', 'twentyeleven_admin_enqueue_scripts' );
/**
/**
* Register the form setting for our twentyeleven_options array.
* Register the form setting for our twentyeleven_options array.
*
*
* This function is attached to the admin_init action hook.
* This function is attached to the admin_init action hook.
*
*
* This call to register_setting() registers a validation callback, twentyeleven_theme_options_validate(),
* This call to register_setting() registers a validation callback, twentyeleven_theme_options_validate(),
* which is used when the option is saved, to ensure that our option values are complete, properly
* which is used when the option is saved, to ensure that our option values are complete, properly
* formatted, and safe.
* formatted, and safe.
*
*
* @since Twenty Eleven 1.0
* @since Twenty Eleven 1.0
*/
*/
function twentyeleven_theme_options_init() {
function twentyeleven_theme_options_init() {
register_setting(
register_setting(
'twentyeleven_options', // Options group, see settings_fields() call in twentyeleven_theme_options_render_page()
'twentyeleven_options', // Options group, see settings_fields() call in twentyeleven_theme_options_render_page()
'twentyeleven_theme_options', // Database option, see twentyeleven_get_theme_options()
'twentyeleven_theme_options', // Database option, see twentyeleven_get_theme_options()
'twentyeleven_theme_options_validate' // The sanitization callback, see twentyeleven_theme_options_validate()
'twentyeleven_theme_options_validate' // The sanitization callback, see twentyeleven_theme_options_validate()
);
);
// Register our settings field group
// Register our settings field group
add_settings_section(
add_settings_section(
'general', // Unique identifier for the settings section
'general', // Unique identifier for the settings section
'', // Section title (we don't want one)
'', // Section title (we don't want one)
'__return_false', // Section callback (we don't want anything)
'__return_false', // Section callback (we don't want anything)
'theme_options' // Menu slug, used to uniquely identify the page; see twentyeleven_theme_options_add_page()
'theme_options' // Menu slug, used to uniquely identify the page; see twentyeleven_theme_options_add_page()
);
);
// Register our individual settings fields
// Register our individual settings fields
add_settings_field(
add_settings_field(
'color_scheme', // Unique identifier for the field for this section
'color_scheme', // Unique identifier for the field for this section
__( 'Color Scheme', 'twentyeleven' ), // Setting field label
__( 'Color Scheme', 'twentyeleven' ), // Setting field label
'twentyeleven_settings_field_color_scheme', // Function that renders the settings field
'twentyeleven_settings_field_color_scheme', // Function that renders the settings field
'theme_options', // Menu slug, used to uniquely identify the page; see twentyeleven_theme_options_add_page()
'theme_options', // Menu slug, used to uniquely identify the page; see twentyeleven_theme_options_add_page()
'general' // Settings section. Same as the first argument in the add_settings_section() above
'general' // Settings section. Same as the first argument in the add_settings_section() above
);
);
add_settings_field( 'link_color', __( 'Link Color', 'twentyeleven' ), 'twentyeleven_settings_field_link_color', 'theme_options', 'general' );
add_settings_field( 'link_color', __( 'Link Color', 'twentyeleven' ), 'twentyeleven_settings_field_link_color', 'theme_options', 'general' );
add_settings_field( 'layout', __( 'Default Layout', 'twentyeleven' ), 'twentyeleven_settings_field_layout', 'theme_options', 'general' );
add_settings_field( 'layout', __( 'Default Layout', 'twentyeleven' ), 'twentyeleven_settings_field_layout', 'theme_options', 'general' );
}
}
add_action( 'admin_init', 'twentyeleven_theme_options_init' );
add_action( 'admin_init', 'twentyeleven_theme_options_init' );
/**
/**
* Change the capability required to save the 'twentyeleven_options' options group.
* Change the capability required to save the 'twentyeleven_options' options group.
*
*
* @see twentyeleven_theme_options_init() First parameter to register_setting() is the name of the options group.
* @see twentyeleven_theme_options_init() First parameter to register_setting() is the name of the options group.
* @see twentyeleven_theme_options_add_page() The edit_theme_options capability is used for viewing the page.
* @see twentyeleven_theme_options_add_page() The edit_theme_options capability is used for viewing the page.
*
*
* By default, the options groups for all registered settings require the manage_options capability.
* By default, the options groups for all registered settings require the manage_options capability.
* This filter is required to change our theme options page to edit_theme_options instead.
* This filter is required to change our theme options page to edit_theme_options instead.
* By default, only administrators have either of these capabilities, but the desire here is
* By default, only administrators have either of these capabilities, but the desire here is
* to allow for finer-grained control for roles and users.
* to allow for finer-grained control for roles and users.
*
*
* @param string $capability The capability used for the page, which is manage_options by default.
* @param string $capability The capability used for the page, which is manage_options by default.
* @return string The capability to actually use.
* @return string The capability to actually use.
*/
*/
function twentyeleven_option_page_capability( $capability ) {
function twentyeleven_option_page_capability( $capability ) {
return 'edit_theme_options';
return 'edit_theme_options';
}
}
add_filter( 'option_page_capability_twentyeleven_options', 'twentyeleven_option_page_capability' );
add_filter( 'option_page_capability_twentyeleven_options', 'twentyeleven_option_page_capability' );
/**
/**
* Add our theme options page to the admin menu, including some help documentation.
* Add our theme options page to the admin menu, including some help documentation.
*
*
* This function is attached to the admin_menu action hook.
* This function is attached to the admin_menu action hook.
*
*
* @since Twenty Eleven 1.0
* @since Twenty Eleven 1.0
*/
*/
function twentyeleven_theme_options_add_page() {
function twentyeleven_theme_options_add_page() {
$theme_page = add_theme_page(
$theme_page = add_theme_page(
__( 'Theme Options', 'twentyeleven' ), // Name of page
__( 'Theme Options', 'twentyeleven' ), // Name of page
__( 'Theme Options', 'twentyeleven' ), // Label in menu
__( 'Theme Options', 'twentyeleven' ), // Label in menu
'edit_theme_options', // Capability required
'edit_theme_options', // Capability required
'theme_options', // Menu slug, used to uniquely identify the page
'theme_options', // Menu slug, used to uniquely identify the page
'twentyeleven_theme_options_render_page' // Function that renders the options page
'twentyeleven_theme_options_render_page' // Function that renders the options page
);
);