示例#1
0
function cstmstff_sanitize_select($input)
{
    // Get select choices
    $choices = cstmstff_select_choices();
    // Check if choices are in array
    if (in_array($input, $choices)) {
        return $input;
    } else {
        return null;
    }
}
示例#2
0
<?php

// Exit if accessed directly
if (!defined('ABSPATH')) {
    exit;
}
// Option array for all sections and fields
$optionPages = array();
$optionPages[] = array('slug' => 'edit.php?post_type=cstmstff-post-type', 'title' => __('Options Page', 'custom-stuff'), 'capability' => 'manage_options', 'menu-slug' => 'cstmstff-options.php', 'options-group' => 'cstmstff-options', 'fields' => array(array('id' => 'cstmstff-option-section-01', 'title' => __('Section 01', 'custom-stuff'), 'desc' => __('Text for Section 01.', 'custom-stuff'), 'type' => 'section'), array('id' => 'cstmstff-option-section-02', 'title' => __('Section 02', 'custom-stuff'), 'desc' => __('Text for Section 02.', 'custom-stuff'), 'type' => 'section'), array('label' => __('Text box', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-text', 'name' => 'cstmstff-options[cstmstff-text]', 'type' => 'text', 'validate' => 'cstmstff_sanitize_html', 'section' => 'cstmstff-option-section-01'), array('label' => __('URL', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-url', 'name' => 'cstmstff-options[cstmstff-url]', 'type' => 'url', 'validate' => 'esc_url', 'section' => 'cstmstff-option-section-01'), array('label' => __('Textarea', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-textarea', 'name' => 'cstmstff-options[cstmstff-textarea]', 'type' => 'textarea', 'validate' => 'cstmstff_sanitize_textarea', 'section' => 'cstmstff-option-section-01'), array('label' => __('Select Box', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-select', 'name' => 'cstmstff-options[cstmstff-select]', 'type' => 'select', 'validate' => 'cstmstff_sanitize_select', 'section' => 'cstmstff-option-section-01', 'options' => cstmstff_select_choices()), array('label' => __('Radio', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-radio', 'name' => 'cstmstff-options[cstmstff-radio]', 'type' => 'radio', 'validate' => 'cstmstff_sanitize_other_radio', 'section' => 'cstmstff-option-section-02', 'options' => cstmstff_other_radio_choices()), array('label' => __('Checkbox', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-checkbox', 'name' => 'cstmstff-options[cstmstff-checkbox]', 'type' => 'checkbox', 'value' => 1, 'validate' => 'cstmstff_sanitize_checkbox', 'section' => 'cstmstff-option-section-02'), array('label' => __('Date', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-date', 'name' => 'cstmstff-options[cstmstff-date]', 'type' => 'date', 'validate' => 'cstmstff_sanitize_date', 'section' => 'cstmstff-option-section-02'), array('label' => __('Color Picker', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-color', 'name' => 'cstmstff-options[cstmstff-color]', 'type' => 'color', 'validate' => 'cstmstff_sanitize_hex', 'section' => 'cstmstff-option-section-02'), array('label' => __('Media Library', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-image', 'name' => 'cstmstff-options[cstmstff-image]', 'type' => 'media', 'validate' => 'esc_url', 'section' => 'cstmstff-option-section-02'), array('label' => __('WordPress Editor', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-editor', 'name' => 'cstmstff-options[cstmstff-editor]', 'type' => 'editor', 'validate' => 'wp_kses_post', 'section' => 'cstmstff-option-section-02')));
<?php

// Exit if accessed directly
if (!defined('ABSPATH')) {
    exit;
}
// Term array for all sections and fields
$termMetaBoxes = array();
$termMetaBoxes[] = array('category' => 'cstmstff-cat-public', 'fields' => array(array('label' => __('Text box', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-text', 'name' => 'cstmstff-text', 'type' => 'text', 'validate' => 'cstmstff_sanitize_html', 'column' => 'yes'), array('label' => __('URL', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-url', 'name' => 'cstmstff-url', 'type' => 'url', 'validate' => 'esc_url', 'column' => 'no'), array('label' => __('Multiple Text Boxes', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-multitext', 'type' => 'multitext', 'validate' => 'cstmstff_sanitize_html', 'column' => 'no', 'options' => array(array('label' => __('Multi Text 01', 'custom-stuff'), 'id' => 'cstmstff-multitext01', 'name' => 'cstmstff-multitext01'), array('label' => __('Multi Text 02', 'custom-stuff'), 'id' => 'cstmstff-multitext02', 'name' => 'cstmstff-multitext02'), array('label' => __('Multi Text 03', 'custom-stuff'), 'id' => 'cstmstff-multitext03', 'name' => 'cstmstff-multitext03'), array('label' => __('Multi Text 04', 'custom-stuff'), 'id' => 'cstmstff-multitext04', 'name' => 'cstmstff-multitext04'))), array('label' => __('Textarea', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-textarea', 'name' => 'cstmstff-textarea', 'type' => 'textarea', 'validate' => 'cstmstff_sanitize_textarea', 'column' => 'no'), array('label' => __('Select Box', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-select', 'name' => 'cstmstff-select', 'type' => 'select', 'validate' => 'cstmstff_sanitize_select', 'column' => 'yes', 'options' => cstmstff_select_choices()), array('label' => __('Radio', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-radio', 'name' => 'cstmstff-radio', 'type' => 'radio', 'validate' => 'cstmstff_sanitize_other_radio', 'column' => 'yes', 'options' => cstmstff_other_radio_choices()), array('label' => __('Checkbox', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-checkbox', 'name' => 'cstmstff-checkbox', 'type' => 'checkbox', 'value' => 1, 'validate' => 'cstmstff_sanitize_checkbox', 'column' => 'yes'), array('label' => __('Multiple Checkboxes', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-multicheck', 'type' => 'multicheck', 'validate' => 'cstmstff_sanitize_checkbox', 'column' => 'no', 'options' => array(array('label' => __('Multi Check 01', 'custom-stuff'), 'value' => 1, 'id' => 'cstmstff-multicheck01', 'name' => 'cstmstff-multicheck01'), array('label' => __('Multi Check 02', 'custom-stuff'), 'value' => 1, 'id' => 'cstmstff-multicheck02', 'name' => 'cstmstff-multicheck02'), array('label' => __('Multi Check 03', 'custom-stuff'), 'value' => 1, 'id' => 'cstmstff-multicheck03', 'name' => 'cstmstff-multicheck03'), array('label' => __('Multi Check 04', 'custom-stuff'), 'value' => 1, 'id' => 'cstmstff-multicheck04', 'name' => 'cstmstff-multicheck04'))), array('label' => __('Date', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-date', 'name' => 'cstmstff-date', 'type' => 'date', 'validate' => 'cstmstff_sanitize_date', 'column' => 'no'), array('label' => __('Color Picker', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-color', 'name' => 'cstmstff-color', 'type' => 'color', 'validate' => 'cstmstff_sanitize_hex', 'column' => 'no'), array('label' => __('Media Library', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-image', 'name' => 'cstmstff-image', 'type' => 'media', 'validate' => 'esc_url', 'column' => 'no'), array('label' => __('WordPress Editor', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => 'cstmstff-editor', 'name' => 'cstmstff-editor', 'type' => 'editor', 'validate' => 'wp_kses_post', 'column' => 'no')));
<?php

// Exit if accessed directly
if (!defined('ABSPATH')) {
    exit;
}
// Post array for all sections and fields
$postMetaBoxes = array();
$postMetaBoxes[] = array('id' => 'cstmstff-metabox01', 'title' => __('Custom meta box 1', 'custom-stuff'), 'page' => 'cstmstff-post-type', 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('label' => __('Text box', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => '_cstmstff-text', 'name' => '_cstmstff-text', 'type' => 'text', 'validate' => 'cstmstff_sanitize_html'), array('label' => __('URL', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => '_cstmstff-url', 'name' => '_cstmstff-url', 'type' => 'url', 'validate' => 'esc_url'), array('label' => __('Multiple Text Boxes', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => '_cstmstff-multitext', 'type' => 'multitext', 'validate' => 'cstmstff_sanitize_html', 'options' => array(array('label' => __('Multi Text 01', 'custom-stuff'), 'id' => '_cstmstff-multitext01', 'name' => '_cstmstff-multitext01'), array('label' => __('Multi Text 02', 'custom-stuff'), 'id' => '_cstmstff-multitext02', 'name' => '_cstmstff-multitext02'), array('label' => __('Multi Text 03', 'custom-stuff'), 'id' => '_cstmstff-multitext03', 'name' => '_cstmstff-multitext03'), array('label' => __('Multi Text 04', 'custom-stuff'), 'id' => '_cstmstff-multitext04', 'name' => '_cstmstff-multitext04'))), array('label' => __('Textarea', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => '_cstmstff-textarea', 'name' => '_cstmstff-textarea', 'type' => 'textarea', 'validate' => 'cstmstff_sanitize_textarea'), array('label' => __('Select Box', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => '_cstmstff-select', 'name' => '_cstmstff-select', 'type' => 'select', 'validate' => 'cstmstff_sanitize_select', 'options' => cstmstff_select_choices())));
$postMetaBoxes[] = array('id' => 'cstmstff-metabox02', 'title' => __('Custom meta box 2', 'custom-stuff'), 'page' => 'cstmstff-post-type', 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('label' => __('Radio', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => '_cstmstff-radio', 'name' => '_cstmstff-radio', 'type' => 'radio', 'validate' => 'cstmstff_sanitize_post_radio', 'options' => cstmstff_post_radio_choices()), array('label' => __('Checkbox', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => '_cstmstff-checkbox', 'name' => '_cstmstff-checkbox', 'type' => 'checkbox', 'value' => 1, 'validate' => 'cstmstff_sanitize_checkbox'), array('label' => __('Multiple Checkboxes', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => '_cstmstff-multicheck', 'type' => 'multicheck', 'validate' => 'cstmstff_sanitize_checkbox', 'options' => array(array('label' => __('Multi Check 01', 'custom-stuff'), 'value' => 1, 'id' => '_cstmstff-multicheck01', 'name' => '_cstmstff-multicheck01'), array('label' => __('Multi Check 02', 'custom-stuff'), 'value' => 1, 'id' => '_cstmstff-multicheck02', 'name' => '_cstmstff-multicheck02'), array('label' => __('Multi Check 03', 'custom-stuff'), 'value' => 1, 'id' => '_cstmstff-multicheck03', 'name' => '_cstmstff-multicheck03'), array('label' => __('Multi Check 04', 'custom-stuff'), 'value' => 1, 'id' => '_cstmstff-multicheck04', 'name' => '_cstmstff-multicheck04'))), array('label' => __('Date', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => '_cstmstff-date', 'name' => '_cstmstff-date', 'type' => 'date', 'validate' => 'cstmstff_sanitize_date'), array('label' => __('Color Picker', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => '_cstmstff-color', 'name' => '_cstmstff-color', 'type' => 'color', 'validate' => 'cstmstff_sanitize_hex'), array('label' => __('Media Library', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => '_cstmstff-image', 'name' => '_cstmstff-image', 'type' => 'media', 'validate' => 'esc_url'), array('label' => __('WordPress Editor', 'custom-stuff'), 'desc' => __('Enter something here if you want. If not, just remove it.', 'custom-stuff'), 'id' => '_cstmstff-editor', 'name' => '_cstmstff-editor', 'type' => 'editor', 'validate' => 'wp_kses_post')));