Skip to content

Instantly share code, notes, and snippets.

@jeremyHixon
Created March 27, 2015 03:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jeremyHixon/d485808ab24ae254ee0e to your computer and use it in GitHub Desktop.
Save jeremyHixon/d485808ab24ae254ee0e to your computer and use it in GitHub Desktop.
Example of my Rational WordPress option page class
<?php
if ( is_admin() ) {
include 'rational-option-page/class.rational-option-page.php';
$my_options_page = new RationalOptionPages();
$pages = array(
// page
array(
'page_title' => 'My Options',
'menu_title' => 'My Options',
'capability' => 'manage_options',
'menu_slug' => 'my_options',
'description' => '<p>Some options for my theme.</p>',
// section
'sections' => array(
array(
'id' => 'sample_fields',
'title' => 'Sample Fields',
'description' => '<p>Sample fields supported by the class</p>',
// fields
'fields' => array(
array(
'id' => 'sample_text',
'title' => 'Sample Text',
'type' => 'text',
'description' => 'Things like text, search, url, tel, email and password.',
'value' => 'Default value',
),
array(
'id' => 'sample_textarea',
'title' => 'Sample Textarea',
'type' => 'textarea',
'value' => 'Defaults to a large, code-style block but can easily be changed with class, rows and cols.',
),
array(
'id' => 'sample_checkbox',
'title' => 'Sample Checkbox',
'type' => 'checkbox',
'description' => 'Checkboxes of course.',
),
array(
'id' => 'sample_radio',
'title' => 'Sample Radio',
'type' => 'radio',
'options' => array(
'Radio options are similar to those for selects',
'radio-two' => 'Sequential or associative arrays work',
),
),
array(
'id' => 'sample_select',
'title' => 'Sample Select',
'type' => 'select',
'options' => array(
'Radio options are similar to those for selects',
'radio-two' => 'Sequential or associative arrays work',
),
'description' => 'See? Same as the radio input above.'
),
array(
'id' => 'sample_file',
'title' => 'Sample File',
'type' => 'file',
'description' => 'Included file uploads for fun.'
),
),
),
),
),
);
$my_options_page->pages( $pages );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment