Admin Pages
The admin page (and options) are defined in inc/fx-admin.php.
If you want to make a new page, just extend the abstract class AdminPages.
You then need to set some static values and define the page render (create_admin_page()) and then add input meta in sections (page_init()).
Below is an example on how a basic theme options page can be made containing inputs.
Example
class ThemeOptions extends AdminPages {
public $options_name = 'theme_options';
public $base_name = 'theme-setting-admin';
public function __construct() {
// You don't need this constructor function, but if you do,
// you'll have to call the parent constructor to get things going
parent::__construct();
}
public function register_admin_page() {
add_menu_page(
'page title',
'menu title',
'manage_options',
$this->base_name,
array($this, 'create_admin_page'),
'dashicons-admin-generic' // You can change this icon with another Wordpress dashicon
);
}
public function create_admin_page() {
// You will need to enqueue media lightbox if you want to use the media or media-multiple meta box
wp_enqueue_media();
// Get options and save to object
$this->options = get_option($this->options_name);
// Render your page below
?>
<div class="fx-admin-page wrap">
<h1>Theme Options</h1>
<form method="post" action="options.php">
<?php
settings_fields($this->options_group);
do_settings_sections('theme-setting-admin');
submit_button();
?>
</form>
</div>
<?php
}
public function page_init() {
$example_section = array(
'id' => 'section_id',
'title' => 'Section Title',
'description' => '',
'fields' => array(
'input_id' => array(
'type' => 'textfield',
'title' => 'Title',
'description' => '',
'sanitize' => true
)
)
);
$sections = array(
$example_section
);
$this->register_options_page('theme-setting-admin', $sections);
}
}
// Init the new class only for admin
if (is_admin()) {
$my_settings_page = new ThemeOptions();
}
The main difference between other custom meta and the admin is that inputs in admin have a sanitize option. You should sanitize all inputs, but sometimes you may not want to (eg. textarea with paragraphs).
Declare fields like normal custom meta inputs, you just can't use the columns (yet).
Note: the $options_name is what is used to get the values, Based on the above example ($options_name = 'theme_options');
// Get the options
$options = get_option('theme_options');
// Then the individual input value
$input_value = $options['input_id'];
If you do use $options_name = 'theme_options' (default), you can then use the fx-functions helper function get_opts($input_id), Eg:
$input_value = get_opts('input_id');