69
Options Pages for Themes and Plugins Caspar Green

WCNC2015 - Options Pages for Themes and Plugins

Embed Size (px)

Citation preview

Options Pagesfor

Themes and PluginsCaspar Green

Decisionsnot

Options

Options API C-R-U-D for the WP Options Table

Create add_option()

Read get_option()

Update update_option()

Delete delete_option()

Page Title

Page TitleMenu Title

Page TitleMenu Title

Capability

Page TitleMenu Title

CapabilityMenu Slug

Page TitleMenu Title

CapabilityMenu Slug

Function to Display

Page TitleMenu Title

CapabilityMenu Slug

Function to Display

Settings API Groups and Sections and Fields, Oh MY!

Settings API Groups and Sections and Fields, Oh MY!

GroupA Group of optionsthat will be savedtogether in theoptions table. Use:register_setting()unregister_setting()settings_fields()

Settings API Groups and Sections and Fields, Oh MY!

GroupA Group of optionsthat will be savedtogether in theoptions table. Use:register_setting()unregister_setting()settings_fields()

SectionA sub-group of options that will render together on an options page. Use:add_settings_section()do_settings_section()

AnotherSection

Settings API Groups and Sections and Fields, Oh MY!

GroupA Group of optionsthat will be savedtogether in theoptions table. Use:register_setting()unregister_setting()settings_fields()

SectionA sub-group of options that will render together on an options page. Use:add_settings_section()do_settings_section()

AnotherSection

FieldAn individual option. Use:add_settings_field()do_settings_field()

Another Field

Another Field

Name of group

Name of groupName of group in database

Name of groupName of group in database

Validation function

Section Slug (ID)

Section Slug (ID)Section Title

Section Slug (ID)Section Title

Section Callback

Section Slug (ID)Section Title

Section CallbackPage Section Appears On

Field ID

Field IDField Title

Field IDField Title

Function to render html

Field IDField Title

Function to render htmlPage name

Field IDField Title

Function to render htmlPage name

Section name

Field IDField Title

Function to render htmlPage name

Section nameArray for rendering function

Should Have Whitelisted

Sanitize on the Front End, too!

Caspar Green@i_Caspar

[email protected] www.caspar.green github.com/iCaspar

www.slideshare.net/CasparGreen