Settings API - Oslo WordPress Meetup - November 22, 2011

488 views

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
488
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Settings API - Oslo WordPress Meetup - November 22, 2011

    1. 1. settings api
    2. 2. codex.wordpress.org/Settings_API
    3. 3. The Settings API, added in WordPress 2.7, allows admin pages containing settings forms to bemanaged semi-automatically. It lets youdefine settings pages, sections within those pages and fields within the sections.
    4. 4. 6“general”functions
    5. 5. settings_fields($option_group); 6register_setting($option_group, $option_name, $sanitize_callback="");unregister_setting($option_group, $option_name, $sanitize_callback="");add_settings_section($id, $title, $callback, $page);add_settings_field($id, $title, $callback, $page, $section, $args = array());do_settings_sections($page)
    6. 6. $option_group – unique group name for option set$option_name – name of each option$sanitize_callback="" – section/field callback function for validation$id – unique ID for the section/field$title – the title of the section/field (displayed on options page)$callback – callback function to be executed$page – options page name (use __FILE__ if creating new options page)$section – ID of the settings section (same as $id inadd_settings_section)$args = array() – additional arguments
    7. 7. live example

    ×