twentyeleven_theme_options_init

Definition:
function twentyeleven_theme_options_init() {}

Register the form setting for our twentyeleven_options array.
This function is attached to the admin_init action hook.

Source code

function twentyeleven_theme_options_init() {



	// If we have no options in the database, let's add them now.

	if ( false === twentyeleven_get_theme_options() )

		add_option( 'twentyeleven_theme_options', twentyeleven_get_default_theme_options() );



	register_setting(

		'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_validate' // The sanitization callback, see twentyeleven_theme_options_validate()

	);



	// Register our settings field group

	add_settings_section(

		'general', // Unique identifier for the settings section

		'', // Section title (we don't want one)

		'__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()

	);



	// Register our individual settings fields

	add_settings_field(

		'color_scheme',  // Unique identifier for the field for this section

		__( 'Color Scheme', 'twentyeleven' ), // Setting field label

		'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()

		'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( 'layout',     __( 'Default Layout', 'twentyeleven' ), 'twentyeleven_settings_field_layout',     'theme_options', 'general' );

}

14757

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: