first commit
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,336 @@
|
||||
<?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
|
||||
/**
|
||||
* Compatibility Functions.
|
||||
*
|
||||
* @package OptionTree
|
||||
* @author Derek Herman <derek@valendesigns.com>
|
||||
* @copyright Copyright (c) 2012, Derek Herman
|
||||
* @since 2.0
|
||||
*/
|
||||
|
||||
/* run the actions & filters */
|
||||
add_action( 'admin_init', 'compat_ot_import_from_files', 1 );
|
||||
add_filter( 'ot_option_types_array', 'compat_ot_option_types_array', 10, 1 );
|
||||
add_filter( 'ot_recognized_font_styles', 'compat_ot_recognized_font_styles', 10, 2 );
|
||||
add_filter( 'ot_recognized_font_weights', 'compat_ot_recognized_font_weights', 10, 2 );
|
||||
add_filter( 'ot_recognized_font_variants', 'compat_ot_recognized_font_variants', 10, 2 );
|
||||
add_filter( 'ot_recognized_font_families', 'compat_ot_recognized_font_families', 10, 2 );
|
||||
add_filter( 'ot_recognized_background_repeat', 'compat_ot_recognized_background_repeat', 10, 2 );
|
||||
add_filter( 'ot_recognized_background_position', 'compat_ot_recognized_background_position', 10, 2 );
|
||||
add_filter( 'ot_measurement_unit_types', 'compat_ot_measurement_unit_types', 10, 2 );
|
||||
|
||||
/**
|
||||
* Import from the old 1.x files for backwards compatibility.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access private
|
||||
* @since 2.0.8
|
||||
*/
|
||||
if ( ! function_exists( 'compat_ot_import_from_files' ) ) {
|
||||
|
||||
function compat_ot_import_from_files() {
|
||||
|
||||
/* file path & name without extention */
|
||||
$ot_xml = '/option-tree/theme-options.xml';
|
||||
$ot_data = '/option-tree/theme-options.txt';
|
||||
$ot_layout = '/option-tree/layouts.txt';
|
||||
|
||||
/* XML file path - child theme first then parent */
|
||||
$xml_file = get_stylesheet_directory() . $ot_xml;
|
||||
if ( ! is_readable( $xml_file ) )
|
||||
$xml_file = get_template_directory() . $ot_xml;
|
||||
|
||||
/* Data file path - child theme first then parent */
|
||||
$data_file = get_stylesheet_directory() . $ot_data;
|
||||
if ( ! is_readable( $data_file ) )
|
||||
$data_file = get_template_directory() . $ot_data;
|
||||
|
||||
/* Layout file path - child theme first then parent */
|
||||
$layout_file = get_stylesheet_directory() . $ot_layout;
|
||||
if ( ! is_readable( $layout_file ) )
|
||||
$layout_file = get_template_directory() . $ot_layout;
|
||||
|
||||
/* check for files */
|
||||
$has_xml = ( is_readable( $xml_file ) ) ? true : false;
|
||||
$has_data = ( is_readable( $data_file ) ) ? true : false;
|
||||
$has_layout = ( is_readable( $layout_file ) ) ? true : false;
|
||||
|
||||
/* auto import XML file */
|
||||
if ( $has_xml == true && ! get_option( 'option_tree_settings' ) && class_exists( 'SimpleXMLElement' ) && function_exists( 'file_get_contents' ) ) {
|
||||
|
||||
$settings = ot_import_xml( $xml_file );
|
||||
|
||||
if ( isset( $settings ) && ! empty( $settings ) ) {
|
||||
|
||||
update_option( 'option_tree_settings', $settings );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* auto import Data file */
|
||||
if ( $has_data == true && ! get_option( 'option_tree' ) && function_exists( 'file_get_contents' ) ) {
|
||||
|
||||
$rawdata = @file_get_contents( $data_file );
|
||||
$options = unserialize( base64_decode( $rawdata ) );
|
||||
|
||||
/* get settings array */
|
||||
$settings = get_option( 'option_tree_settings' );
|
||||
|
||||
/* has options */
|
||||
if ( is_array( $options ) ) {
|
||||
|
||||
/* validate options */
|
||||
if ( is_array( $settings ) ) {
|
||||
|
||||
foreach( $settings['settings'] as $setting ) {
|
||||
|
||||
if ( isset( $options[$setting['id']] ) ) {
|
||||
|
||||
$content = ot_stripslashes( $options[$setting['id']] );
|
||||
|
||||
$options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* update the option tree array */
|
||||
update_option( 'option_tree', $options );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* auto import Layout file */
|
||||
if ( $has_layout == true && ! get_option( 'option_tree_layouts' ) && function_exists( 'file_get_contents' ) ) {
|
||||
|
||||
$rawdata = @file_get_contents( $layout_file );
|
||||
$layouts = unserialize( base64_decode( $rawdata ) );
|
||||
|
||||
/* get settings array */
|
||||
$settings = get_option( 'option_tree_settings' );
|
||||
|
||||
/* has layouts */
|
||||
if ( is_array( $layouts ) ) {
|
||||
|
||||
/* validate options */
|
||||
if ( is_array( $settings ) ) {
|
||||
|
||||
foreach( $layouts as $key => $value ) {
|
||||
|
||||
if ( $key == 'active_layout' )
|
||||
continue;
|
||||
|
||||
$options = unserialize( base64_decode( $value ) );
|
||||
|
||||
foreach( $settings['settings'] as $setting ) {
|
||||
|
||||
if ( isset( $options[$setting['id']] ) ) {
|
||||
|
||||
$content = ot_stripslashes( $options[$setting['id']] );
|
||||
|
||||
$options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$layouts[$key] = base64_encode( serialize( $options ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* update the option tree array */
|
||||
if ( isset( $layouts['active_layout'] ) ) {
|
||||
|
||||
update_option( 'option_tree', unserialize( base64_decode( $layouts[$layouts['active_layout']] ) ) );
|
||||
|
||||
}
|
||||
|
||||
/* update the option tree layouts array */
|
||||
update_option( 'option_tree_layouts', $layouts );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the option types array.
|
||||
*
|
||||
* Allows the old 'option_tree_option_types' filter to
|
||||
* change the new 'ot_option_types_array' return value.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'compat_ot_option_types_array' ) ) {
|
||||
|
||||
function compat_ot_option_types_array( $array ) {
|
||||
|
||||
return apply_filters( 'option_tree_option_types', $array );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the recognized font styles array.
|
||||
*
|
||||
* Allows the old 'recognized_font_styles' filter to
|
||||
* change the new 'ot_recognized_font_styles' return value.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'compat_ot_recognized_font_styles' ) ) {
|
||||
|
||||
function compat_ot_recognized_font_styles( $array, $id ) {
|
||||
|
||||
return apply_filters( 'recognized_font_styles', $array, $id );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the recognized font weights array.
|
||||
*
|
||||
* Allows the old 'recognized_font_weights' filter to
|
||||
* change the new 'ot_recognized_font_weights' return value.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'compat_ot_recognized_font_weights' ) ) {
|
||||
|
||||
function compat_ot_recognized_font_weights( $array, $id ) {
|
||||
|
||||
return apply_filters( 'recognized_font_weights', $array, $id );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the recognized font variants array.
|
||||
*
|
||||
* Allows the old 'recognized_font_variants' filter to
|
||||
* change the new 'ot_recognized_font_variants' return value.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'compat_ot_recognized_font_variants' ) ) {
|
||||
|
||||
function compat_ot_recognized_font_variants( $array, $id ) {
|
||||
|
||||
return apply_filters( 'recognized_font_variants', $array, $id );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the recognized font families array.
|
||||
*
|
||||
* Allows the old 'recognized_font_families' filter to
|
||||
* change the new 'ot_recognized_font_families' return value.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'compat_ot_recognized_font_families' ) ) {
|
||||
|
||||
function compat_ot_recognized_font_families( $array, $id ) {
|
||||
|
||||
return apply_filters( 'recognized_font_families', $array, $id );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the recognized background repeat array.
|
||||
*
|
||||
* Allows the old 'recognized_background_repeat' filter to
|
||||
* change the new 'ot_recognized_background_repeat' return value.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'compat_ot_recognized_background_repeat' ) ) {
|
||||
|
||||
function compat_ot_recognized_background_repeat( $array, $id ) {
|
||||
|
||||
return apply_filters( 'recognized_background_repeat', $array, $id );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the recognized background position array.
|
||||
*
|
||||
* Allows the old 'recognized_background_position' filter to
|
||||
* change the new 'ot_recognized_background_position' return value.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'compat_ot_recognized_background_position' ) ) {
|
||||
|
||||
function compat_ot_recognized_background_position( $array, $id ) {
|
||||
|
||||
return apply_filters( 'recognized_background_position', $array, $id );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the measurement unit types array.
|
||||
*
|
||||
* Allows the old 'measurement_unit_types' filter to
|
||||
* change the new 'ot_measurement_unit_types' return value.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'compat_ot_measurement_unit_types' ) ) {
|
||||
|
||||
function compat_ot_measurement_unit_types( $array, $id ) {
|
||||
|
||||
return apply_filters( 'measurement_unit_types', $array, $id );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* End of file ot-functions-compat.php */
|
||||
/* Location: ./includes/ot-functions-compat.php */
|
@ -0,0 +1,99 @@
|
||||
<?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
|
||||
/**
|
||||
* OptionTree deprecated functions
|
||||
*
|
||||
* @package OptionTree
|
||||
* @author Derek Herman <derek@valendesigns.com>
|
||||
* @copyright Copyright (c) 2012, Derek Herman
|
||||
* @since 2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Displays or returns a value from the 'option_tree' array.
|
||||
*
|
||||
* @param string $item_id
|
||||
* @param array $options
|
||||
* @param bool $echo
|
||||
* @param bool $is_array
|
||||
* @param int $offset
|
||||
* @return mixed array or comma seperated lists of values
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @updated 2.0
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'get_option_tree' ) ) {
|
||||
|
||||
function get_option_tree( $item_id = '', $options = '', $echo = false, $is_array = false, $offset = -1 ) {
|
||||
/* load saved options */
|
||||
if ( ! $options )
|
||||
$options = get_option( 'option_tree' );
|
||||
|
||||
/* no value return */
|
||||
if ( ! isset( $options[$item_id] ) || empty( $options[$item_id] ) )
|
||||
return;
|
||||
|
||||
/* set content value & strip slashes */
|
||||
$content = option_tree_stripslashes( $options[$item_id] );
|
||||
|
||||
/* is an array */
|
||||
if ( $is_array == true ) {
|
||||
/* saved as a comma seperated lists of values, explode into an array */
|
||||
if ( !is_array( $content ) )
|
||||
$content = explode( ',', $content );
|
||||
|
||||
/* get an array value using an offset */
|
||||
if ( is_numeric( $offset ) && $offset >= 0 ) {
|
||||
$content = $content[$offset];
|
||||
} else if ( ! is_numeric( $offset ) && isset( $content[$offset] ) ) {
|
||||
$content = $content[$offset];
|
||||
}
|
||||
|
||||
/* not an array */
|
||||
} else if ( $is_array == false ) {
|
||||
/* saved as array, implode and return a comma seperated lists of values */
|
||||
if ( is_array( $content ) )
|
||||
$content = implode( ',', $content ); /* This is fucked */
|
||||
}
|
||||
|
||||
/* echo content */
|
||||
if ( $echo )
|
||||
echo $content;
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom stripslashes from single value or array.
|
||||
*
|
||||
* @param mixed $input
|
||||
* @return mixed
|
||||
*
|
||||
* @access public
|
||||
* @since 1.1.3
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'option_tree_stripslashes' ) ) {
|
||||
|
||||
function option_tree_stripslashes( $input ) {
|
||||
if ( is_array( $input ) ) {
|
||||
foreach( $input as &$val ) {
|
||||
if ( is_array( $val ) ) {
|
||||
$val = option_tree_stripslashes( $val );
|
||||
} else {
|
||||
$val = stripslashes( $val );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$input = stripslashes( $input );
|
||||
}
|
||||
return $input;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file ot-functions-deprecated.php */
|
||||
/* Location: ./includes/ot-functions-deprecated.php */
|
@ -0,0 +1,957 @@
|
||||
<?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
|
||||
/**
|
||||
* OptionTree documentation page functions.
|
||||
*
|
||||
* @package OptionTree
|
||||
* @author Derek Herman <derek@valendesigns.com>
|
||||
* @copyright Copyright (c) 2012, Derek Herman
|
||||
* @since 2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creating Options option type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_creating_options' ) ) {
|
||||
|
||||
function ot_type_creating_options() {
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textblock wide-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<h4>'. __( 'Label', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Label field should be a short but descriptive block of text 100 characters or less with no HTML.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'ID', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The ID field is a unique alphanumeric key used to differentiate each theme option (underscores are acceptable). Also, the plugin will change all text you write in this field to lowercase and replace spaces and special characters with an underscore automatically.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Type', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'You are required to choose one of the supported option types when creating a new option. Here is a list of the available option types. For more information about each type click the <code>Option Types</code> tab to the left.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<ul class="docs-ul">';
|
||||
foreach( ot_option_types_array() as $key => $value )
|
||||
echo '<li>' . $value . '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<h4>'. __( 'Description', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'Enter a detailed description for the users to read on the Theme Options page, HTML is allowed. This is also where you enter content for both the Textblock & Textblock Titled option types.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Choices', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'Click the "Add Choice" button to add an item to the choices array. This will only affect the following option types: Checkbox, Radio, Select & Select Image.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Settings', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'Click the "Add Setting" button found inside a newly created setting to add an item to the settings array. This will only affect the List Item type.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Standard', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'Setting the standard value for your option only works for some option types. Those types are one that have a single string value saved to them and not an array of values.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Rows', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'Enter a numeric value for the number of rows in your textarea. This will only affect the following option types: CSS, Textarea, & Textarea Simple.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Post Type', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'Add a comma separated list of post type like <code>post,page</code>. This will only affect the following option types: Custom Post Type Checkbox, & Custom Post Type Select. Below are the default post types available with WordPress and that are also compatible with OptionTree. You can also add your own custom <code>post_type</code>. At this time <code>any</code> does not seem to return results properly and is something I plan on looking into.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<ul class="docs-ul">';
|
||||
echo '<li><code>post</code></li>';
|
||||
echo '<li><code>page</code></li>';
|
||||
echo '<li><code>attachment</code></li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<h4>'. __( 'Taxonomy', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'Add a comma separated list of any registered taxonomy like <code>category,post_tag</code>. This will only affect the following option types: Taxonomy Checkbox, & Taxonomy Select.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* ot_get_option() option type.
|
||||
*
|
||||
* This is a callback function to display text about ot_get_option().
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_option_types' ) ) {
|
||||
|
||||
function ot_type_option_types() {
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textblock wide-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<h4>'. __( 'Background', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Background option type is for adding background styles to your theme either dynamically via the CSS option type below or manually with <code>ot_get_option()</code>. Background has filters that allow you to change the defaults. For example, you can filter on <code>ot_recognized_background_repeat</code>, <code>ot_recognized_background_attachment</code>, and <code>ot_recognized_background_position</code>. These filters allow you to fine tune the select lists for your specific CSS needs.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Category Select', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Category Select option type displays a list of category IDs. It allows the user to select only one category ID and will return that value for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Category Checkbox', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Category Checkbox option type displays a list of category IDs. It allows the user to check multiple category IDs and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Checkbox', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Checkbox option type is fairly self explanatory. Typically used to ask questions. For example, "Do you want to activate asynchronous Google analytics?" would be a single checkbox with a value of yes. You could have more complex usages but the idea is that you can easily grab the value of the checkbox and use it in you theme. In this situation you would test if the checkbox has a value and execute a block of code if it does and do nothing if it doesn\'t.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Colorpicker', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Colorpicker option type saves a hexadecimal color code for use in CSS. Use it to modify the color of something in your theme.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'CSS', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The CSS option type is a textarea that when used properly can add dynamic CSS to your theme from within OptionTree. Unfortunately, due server limitations you will need to create a file named <code>dynamic.css</code> at the root level of your theme and change permissions using chmod so the server can write to the file. I have had the most success setting this single file to 0777 but feel free to play around with permissions until everything is working. A good starting point is 0666. When the server can save to the file CSS will automatically be updated each time you save your theme options.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<p class="aside">' . __( 'An example of the CSS option type: This assumes you have an option with the ID of <code>custom_background_css</code> which will display the saved values for that option.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<p>'. __( 'Input', 'option-tree' ) . ':</p>';
|
||||
echo '<pre><code>body {
|
||||
{{custom_background_css}}
|
||||
background-color: {{custom_background_css|background-color}};
|
||||
}</code></pre>';
|
||||
|
||||
echo '<p>'. __( 'Output', 'option-tree' ) . ':</p>';
|
||||
echo '<pre><code>/* BEGIN custom_background_css */
|
||||
body {
|
||||
background: color image repeat attachment position;
|
||||
background-color: color;
|
||||
}
|
||||
/* END custom_background_css */</code></pre>';
|
||||
|
||||
echo '<h4>'. __( 'Custom Post Type Select', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It will return a single post ID for use in a custom function or loop. Requires at least one valid <code>post_type</code> when created in the settings. For some reason <code>any</code> does not work correctly and will looked into in future version.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Custom Post Type Checkbox', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It allows the user to check multiple post IDs for use in a custom function or loop. Requires at least one valid <code>post_type</code> when created in the settings. For some reason <code>any</code> does not work correctly and will looked into in future version.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'List Item', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The list Item replaced the old Slider option type. It allows for a great deal of customization. You can add settings to the List Item and those settings will be displayed to the user when they add a new List Item. Typical use is for creating sliding content or blocks of code for custom layouts.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Measurement', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Measurement option type is a mix of input and select fields. The text input excepts a value and the select lets you choose the unit of measurement to add to that value. Currently the default units are <code>px</code>, <code>%</code>, <code>em</code>, <code>pt</code>. However, you can change them with the <code>ot_measurement_unit_types</code> filter.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<p>' . __( 'Example filter to add new units to the Measurement option type. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>';
|
||||
echo '<pre><code>function filter_measurement_unit_types( $array, $field_id ) {
|
||||
|
||||
/* only run the filter on measurement with a field ID of my_measurement */
|
||||
if ( $field_id == \'my_measurement\' ) {
|
||||
$array[\'in\'] = \'inches\';
|
||||
$array[\'ft\'] = \'feet\';
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
add_filter( \'ot_measurement_unit_types\', \'filter_measurement_unit_types\', 10, 2 );</code></pre>';
|
||||
|
||||
echo '<p>' . __( 'Example filter to completely change the units in the Measurement option type. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>';
|
||||
echo '<pre><code>function filter_measurement_unit_types( $array, $field_id ) {
|
||||
|
||||
/* only run the filter on measurement with a field ID of my_measurement */
|
||||
if ( $field_id == \'my_measurement\' ) {
|
||||
$array = array(
|
||||
\'in\' => \'inches\',
|
||||
\'ft\' => \'feet\'
|
||||
);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
add_filter( \'ot_measurement_unit_types\', \'filter_measurement_unit_types\', 10, 2 );</code></pre>';
|
||||
|
||||
echo '<h4>'. __( 'Page Select', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Page Select option type displays a list of page IDs. It will return a single page ID for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Page Checkbox', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Page Select option type displays a list of page IDs. It allows the user to check multiple page IDs for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Post Select', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Post Select option type displays a list of post IDs. It will return a single post ID for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Post Checkbox', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Post Select option type displays a list of post IDs. It allows the user to check multiple post IDs for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Radio', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Radio option type could ask a question. For example, "Do you want to activate the custom navigation?" could require a yes or no answer with a radio option. In this situation you would test if the radio has a value of \'yes\' and execute a block of code, or if it\'s \'no\' execute a different block of code.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Radio Image', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'the Radio Images option type is primarily used for layouts. However, you can filter the image list using <code>ot_radio_images</code>. As well, you can add your own custom images using the choices array.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<p>' . __( 'This example executes the <code>ot_radio_images</code> filter on layout images attached to the <code>my_radio_images</code> field. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>';
|
||||
echo '<pre><code>function filter_radio_images( $array, $field_id ) {
|
||||
|
||||
/* only run the filter where the field ID is my_radio_images */
|
||||
if ( $field_id == \'my_radio_images\' ) {
|
||||
$array = array(
|
||||
array(
|
||||
\'value\' => \'left-sidebar\',
|
||||
\'label\' => __( \'Left Sidebar\', \'option-tree\' ),
|
||||
\'src\' => OT_URL . \'/assets/images/layout/left-sidebar.png\'
|
||||
),
|
||||
array(
|
||||
\'value\' => \'right-sidebar\',
|
||||
\'label\' => __( \'Right Sidebar\', \'option-tree\' ),
|
||||
\'src\' => OT_URL . \'/assets/images/layout/right-sidebar.png\'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $array;
|
||||
|
||||
}
|
||||
add_filter( \'ot_radio_images\', \'filter_radio_images\', 10, 2 );</code></pre>';
|
||||
|
||||
echo '<h4>'. __( 'Select', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Select option type is used to list anything you want that would be chosen from a select list.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Slider', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Slider option type is technically deprecated. Use the List Item option type instead, as it\'s infinitely more customizable. Typical use is for creating sliding image content.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Tag Checkbox', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Tag Checkbox option type displays a list of tag IDs. It allows the user to check multiple tag IDs and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Tag Select', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Tag Select option type displays a list of tag IDs. It allows the user to select only one tag ID and will return that value for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Taxonomy Checkbox', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Taxonomy Checkbox option type displays a list of taxonomy IDs. It allows the user to check multiple taxonomy IDs and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Taxonomy Select', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Taxonomy Select option type displays a list of taxonomy IDs. It allows the user to select only one taxonomy ID and will return that value for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Text (Input)', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Text option type would be used to save a string value. For example, a link to feedburner, your Twitter username, or Google Analytics ID are all good candidates. Any optional or required text that is of reasonably short character length.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Textarea', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Textarea option type is a large string value used for custom code or text in the theme. The new Textarea has a WYSIWYG editor that can be filtered to change the buttons shown. For example, you can filter on <code>wpautop</code>, <code>media_buttons</code>, <code>tinymce</code>, and <code>quicktags</code>.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<p class="aside">' . __( 'Example filters to alter the Textarea option type. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<p>' . __( 'This example keeps WordPress from executing the <code>wpautop</code> filter on the line breaks. The default is <code>true</code> which means it wraps line breaks with an HTML <code>p</code> tag.', 'option-tree' ) . '</p>';
|
||||
echo '<pre><code>function filter_textarea_wpautop( $content, $field_id ) {
|
||||
|
||||
/* only run the filter on the textarea with a field ID of my_textarea */
|
||||
if ( $field_id == \'my_textarea\' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
||||
}
|
||||
add_filter( \'ot_wpautop\', \'filter_textarea_wpautop\', 10, 1 );</code></pre>';
|
||||
|
||||
echo '<p>' . __( 'This example keeps WordPress from executing the <code>media_buttons</code> filter on the textarea WYSIWYG. The default is <code>true</code> which means show the buttons.', 'option-tree' ) . '</p>';
|
||||
echo '<pre><code>function filter_textarea_media_buttons( $content, $field_id ) {
|
||||
|
||||
/* only run the filter on the textarea with a field ID of my_textarea */
|
||||
if ( $field_id == \'my_textarea\' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
||||
}
|
||||
add_filter( \'ot_media_buttons\', \'filter_textarea_media_buttons\', 10, 2 );</code></pre>';
|
||||
|
||||
echo '<p>' . __( 'This example keeps WordPress from executing the <code>tinymce</code> filter on the textarea WYSIWYG. The default is <code>true</code> which means show the tinymce.', 'option-tree' ) . '</p>';
|
||||
echo '<pre><code>function filter_textarea_tinymce( $content, $field_id ) {
|
||||
|
||||
/* only run the filter on the textarea with a field ID of my_textarea */
|
||||
if ( $field_id == \'my_textarea\' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
||||
}
|
||||
add_filter( \'ot_tinymce\', \'filter_textarea_tinymce\', 10, 2 );</code></pre>';
|
||||
|
||||
echo '<p>' . __( 'This example alters the <code>quicktags</code> filter on the textarea WYSIWYG. The default is <code>array( \'buttons\' => \'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close\' )</code> which means show those quicktags. It also means you can filter in your own custom quicktags.', 'option-tree' ) . '</p>';
|
||||
echo '<pre><code>function filter_textarea_quicktags( $content, $field_id ) {
|
||||
|
||||
/* only run the filter on the textarea with a field ID of my_textarea */
|
||||
if ( $field_id == \'my_textarea\' ) {
|
||||
return array( \'buttons\' => \'strong,em,link,block,del,ins,img,ul,ol,li,code,more,spell,close,fullscreen\' );
|
||||
} else if ( $field_id == \'my_other_textarea\' ) {
|
||||
return false; /* show no quicktags */
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
||||
}
|
||||
add_filter( \'ot_quicktags\', \'filter_textarea_quicktags\', 10, 1 );</code></pre>';
|
||||
|
||||
echo '<h4>'. __( 'Textarea Simple', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Textarea Simple option type is a large string value used for custom code or text in the theme. The new Textarea Simple does not have a WYSIWYG editor. But you can still filter on <code>wpautop</code>.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<p class="aside">' . __( 'This example tells WordPress to execute the <code>wpautop</code> filter on the line breaks. The default is <code>false</code> which means it does not wraps line breaks with an HTML <code>p</code> tag. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>';
|
||||
echo '<pre><code>function filter_textarea_simple_wpautop( $content, $field_id ) {
|
||||
|
||||
/* only run the filter on the textarea with a field ID of my_textarea */
|
||||
if ( $field_id == \'my_textarea\' ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
||||
}
|
||||
add_filter( \'ot_wpautop\', \'filter_textarea_simple_wpautop\', 10, 2 );</code></pre>';
|
||||
|
||||
echo '<h4>'. __( 'Textblock', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Textblock option type is used only on the Theme Option page. It will allow you to create & display HTML on your Theme Options page but has no title above the text block. You can then use the Textblock to add a more detailed set of instruction on how the options are used in your theme. You would NEVER use this in your themes template files as it does not save a value.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Textblock Titled', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Textblock Titled option type is used only on the Theme Option page. It will allow you to create & display HTML on your Theme Options page and has a title above the text block. You can then use the Textblock Titled to add a more detailed set of instruction on how the options are used in your theme. You would NEVER use this in your themes template files as it does not save a value.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>'. __( 'Typography', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Typography option type is for adding typographic styles to your theme either dynamically via the CSS option type below or manually with <code>ot_get_option()</code>. Typography has filters that allow you to change the defaults. For example, you can filter on <code>ot_recognized_font_styles</code>, <code>ot_recognized_font_weights</code>, <code>ot_recognized_font_variants</code>, and <code>ot_recognized_font_families</code>. These filters allow you to fine tune the select lists for your specific CSS needs. The most important one though is <code>ot_recognized_font_families</code> as you can add your Google Fonts to create custom font stacks.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<p class="aside">' . __( 'This example would filter <code>ot_recognized_font_families</code> to build your own font stack. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>';
|
||||
echo '<pre><code>function filter_ot_recognized_font_families( $array, $field_id ) {
|
||||
|
||||
/* only run the filter when the field ID is my_google_fonts_headings */
|
||||
if ( $field_id == \'my_google_fonts_headings\' ) {
|
||||
$array = array(
|
||||
\'sans-serif\' => \'sans-serif\',
|
||||
\'open-sans\' => \'"Open Sans", sans-serif\',
|
||||
\'droid-sans\' => \'"Droid Sans", sans-serif\'
|
||||
);
|
||||
}
|
||||
|
||||
return $array;
|
||||
|
||||
}
|
||||
add_filter( \'ot_recognized_font_families\', \'filter_ot_recognized_font_families\', 10, 2 );</code></pre>';
|
||||
|
||||
echo '<h4>'. __( 'Upload', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( 'The Upload option type is used to upload any WordPress supported media. After uploading, users are required to press the "Send to OptionTree" button in order to populate the input with the URI of that media. There is one caveat of this feature. If you import the theme options and have uploaded media on one site the old URI will not reflect the URI of your new site. You\'ll have to re-upload or FTP any media to your new server and change the URIs if necessary.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* ot_get_option() option type.
|
||||
*
|
||||
* This is a callback function to display text about ot_get_option().
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_ot_get_option' ) ) {
|
||||
|
||||
function ot_type_ot_get_option() {
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textblock wide-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<h4>'. __( 'Description', 'option-tree' ) . ':</h4>';
|
||||
|
||||
echo '<p>' . __( 'This function returns a value from the "option_tree" array of saved values or the default value supplied. The returned value would be mixed. Meaning it could be a string, integer, boolean, or array.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>' . __( 'Usage', 'option-tree' ) . ':</h4>';
|
||||
|
||||
echo '<p><code><?php ot_get_option( $option_id, $default ); ?></code></p>';
|
||||
|
||||
echo '<h4>' . __( 'Parameters', 'option-tree' ) . ':</h4>';
|
||||
|
||||
echo '<code>$option_id</code>';
|
||||
|
||||
echo '<p>(<em>' . __( 'string', 'option-tree' ) . '</em>) (<em>' . __( 'required', 'option-tree' ) . '</em>) ' . __( 'Enter the options unique identifier.', 'option-tree' ) . '<br />' . __( 'Default:', 'option-tree' ) . ' <em>' . __( 'None', 'option-tree' ) . '</em></p>';
|
||||
|
||||
echo '<code>$default</code>';
|
||||
|
||||
echo '<p>(<em>' . __( 'string', 'option-tree' ) . '</em>) (<em>' . __( 'optional', 'option-tree' ) . '</em>) ' . __( 'Enter a default return value. This is just incase the request returns null.', 'option-tree' ) . '<br />' . __( 'Default', 'option-tree' ) . ': <em>' . __( 'None', 'option-tree' ) . '</em></p>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* get_option_tree() option type.
|
||||
*
|
||||
* This is a callback function to display text about get_option_tree().
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_get_option_tree' ) ) {
|
||||
|
||||
function ot_type_get_option_tree() {
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textblock wide-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<p class="deprecated">' . __( 'This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<p>' . __( 'Use', 'option-tree' ) . '<code>ot_get_option()</code>' . __( 'instead', 'option-tree' ) . '.</p>';
|
||||
|
||||
echo '<h4>'. __( 'Description', 'option-tree' ) . ':</h4>';
|
||||
|
||||
echo '<p>' . __( 'This function returns, or echos if asked, a value from the "option_tree" array of saved values.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>' . __( 'Usage', 'option-tree' ) . ':</h4>';
|
||||
|
||||
echo '<p><code><?php get_option_tree( $item_id, $options, $echo, $is_array, $offset ); ?></code></p>';
|
||||
|
||||
echo '<h4>' . __( 'Parameters', 'option-tree' ) . ':</h4>';
|
||||
|
||||
echo '<code>$item_id</code>';
|
||||
|
||||
echo '<p>(<em>' . __( 'string', 'option-tree' ) . '</em>) (<em>' . __( 'required', 'option-tree' ) . '</em>) ' . __( 'Enter a unique Option Key to get a returned value or array.', 'option-tree' ) . '<br />' . __( 'Default:', 'option-tree' ) . ' <em>' . __( 'None', 'option-tree' ) . '</em></p>';
|
||||
|
||||
echo '<code>$options</code>';
|
||||
|
||||
echo '<p>(<em>' . __( 'array', 'option-tree' ) . '</em>) (<em>' . __( 'optional', 'option-tree' ) . '</em>) ' . __( 'Used to cut down on database queries in template files.', 'option-tree' ) . '<br />' . __( 'Default', 'option-tree' ) . ': <em>' . __( 'None', 'option-tree' ) . '</em></p>';
|
||||
|
||||
echo '<code>$echo</code>';
|
||||
|
||||
echo '<p>(<em>' . __( 'boolean', 'option-tree' ) . '</em>) (<em>' . __( 'optional', 'option-tree' ) . '</em>) ' . __( 'Echo the output.', 'option-tree' ) . '<br />' . __( 'Default', 'option-tree' ) . ': FALSE</p>';
|
||||
|
||||
echo '<code>$is_array</code>';
|
||||
|
||||
echo '<p>(<em>' . __( 'boolean', 'option-tree' ) . '</em>) (<em>' . __( 'optional', 'option-tree' ) . '</em>) ' . __( 'Used to indicate the $item_id is an array of values.', 'option-tree' ) . '<br />' . __( 'Default', 'option-tree' ) . ': FALSE</p>';
|
||||
|
||||
echo '<code>$offset</code>';
|
||||
|
||||
echo '<p>(<em>' . __( 'integer', 'option-tree' ) . '</em>) (<em>' . __( 'optional', 'option-tree' ) . '</em>) ' . __( 'Numeric offset key for the $item_id array, -1 will return all values (an array starts at 0).', 'option-tree' ) . '<br />' . __( 'Default', 'option-tree' ) . ': -1</p>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Examples option type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_examples' ) ) {
|
||||
|
||||
function ot_type_examples() {
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textblock wide-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<p class="aside">' . __( 'If you\'re using the plugin version of OptionTree it is highly recommended to include a <code>function_exists</code> check in your code, as described in the examples below. If you\'ve integrated OptionTree directly into your themes root directory, you will <strong>not</strong> need to wrap your code with <code>function_exists</code>, as you\'re guaranteed to have the <code>ot_get_option()</code> function available.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>' . __( 'String Examples', 'option-tree' ) . ':</h4>';
|
||||
|
||||
echo '<p>' . __( 'Returns the value of <code>test_input</code>.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
|
||||
$test_input = ot_get_option( \'test_input\' );
|
||||
}</code></pre>';
|
||||
|
||||
echo '<p>' . __( 'Returns the value of <code>test_input</code>, but also has a default value if it returns empty.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
|
||||
$test_input = ot_get_option( \'test_input\', \'default input value goes here.\' );
|
||||
}</code></pre>';
|
||||
|
||||
echo '<h4>' . __( 'Array Examples', 'option-tree' ) . ':</h4>';
|
||||
|
||||
echo '<p>' . __( 'Assigns the value of <code>navigation_ids</code> to the variable <code>$ids</code>. It then echos an unordered list of links (navigation) using <code>wp_list_pages()</code>.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
|
||||
/* get an array of page id\'s */
|
||||
$ids = ot_get_option( \'navigation_ids\', array() );
|
||||
|
||||
/* echo custom navigation using wp_list_pages() */
|
||||
if ( ! empty( $ids ) )
|
||||
echo \'<ul>\';
|
||||
wp_list_pages(
|
||||
array(
|
||||
\'include\' => $ids,
|
||||
\'title_li\' => \'\'
|
||||
)
|
||||
);
|
||||
echo \'</ul>\';
|
||||
}
|
||||
|
||||
}</code></pre>';
|
||||
|
||||
echo '<p>' . __( 'The next two examples demonstrate how to use the <strong>Measurement</strong> option type. The Measurement option type is an array with two key/value pairs. The first is the value of measurement and the second is the unit of measurement.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
|
||||
/* get the array */
|
||||
$measurement = ot_get_option( \'measurement_option_type_id\' );
|
||||
|
||||
/* only echo values if they actually exist, else echo some default value */
|
||||
if ( isset( measurement[0] ) && $measurement[1] ) {
|
||||
echo $measurement[0].$measurement[1];
|
||||
} else {
|
||||
echo \'10px\';
|
||||
}
|
||||
|
||||
}</code></pre>';
|
||||
|
||||
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
|
||||
/* get the array, and have a default just incase */
|
||||
$measurement = ot_get_option( \'measurement_option_type_id\', array( \'10\', \'px\' ) );
|
||||
|
||||
/* implode array into a string value */
|
||||
if ( ! empty( measurement ) ) {
|
||||
echo implode( \'\', $measurement );
|
||||
}
|
||||
|
||||
}</code></pre>';
|
||||
|
||||
echo '<p>' . __( 'This example displays a very basic slider loop.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
|
||||
|
||||
/* get the slider array */
|
||||
$slides = ot_get_option( \'my_slider\', array() );
|
||||
|
||||
if ( ! empty( $slides ) ) {
|
||||
foreach( $slides as $slide ) {
|
||||
echo \'
|
||||
<li>
|
||||
<a href="\' . $slide[\'link\'] . \'"><img src="\' . $slide[\'image\'] . \'" alt="\' . $slide[\'title\'] . \'" /></a>
|
||||
<div class="description">\' . $slide[\'description\'] . \'</div>
|
||||
</li>\';
|
||||
}
|
||||
}
|
||||
|
||||
}</code></pre>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Layouts Overview option type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_layouts_overview' ) ) {
|
||||
|
||||
function ot_type_layouts_overview() {
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textblock wide-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<h4>'. __( 'It\'s Super Simple', 'option-tree' ) . '</h4>';
|
||||
|
||||
echo '<p>' . __( 'Layouts make your theme awesome! With theme options data that you can save/import/export you can package themes with different color variations, or make it easy to do A/B testing on text and so much more. Basically, you save a snapshot of your data as a layout.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<p>' . __( 'Once you have created all your different layouts, or theme variations, you can save them to a separate text file for repackaging with your theme. Alternatively, you could just make different variations for yourself and change your theme with the click of a button, all without deleting your previous options data.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<p class="aside">' . __( ' Adding a layout is ridiculously easy, follow these steps and you\'ll be on your way to having a WordPress super theme.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h4>' . __( 'For Developers', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( '', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h5>' . __( 'Creating a Layout', 'option-tree' ) . ':</h5>';
|
||||
echo '<ul class="docs-ul">';
|
||||
echo '<li>'. __( 'Go to the <code>OptionTre->Settings->Layouts</code> tab.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Enter a name for your layout in the text field and hit "Save Layouts", you\'ve created your first layout.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Adding a new layout is as easy as repeating the steps above.', 'option-tree' ) . '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<h5>' . __( 'Activating a Layout', 'option-tree' ) . ':</h5>';
|
||||
echo '<ul class="docs-ul">';
|
||||
echo '<li>'. __( 'Go to the <code>OptionTre->Settings->Layouts</code> tab.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Click on the activate layout button in the actions list.', 'option-tree' ) . '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<h5>' . __( 'Deleting a Layout', 'option-tree' ) . ':</h5>';
|
||||
echo '<ul class="docs-ul">';
|
||||
echo '<li>'. __( 'Go to the <code>OptionTre->Settings->Layouts</code> tab.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Click on the delete layout button in the actions list.', 'option-tree' ) . '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<h5>' . __( 'Edit Layout Data', 'option-tree' ) . ':</h5>';
|
||||
echo '<ul class="docs-ul">';
|
||||
echo '<li>'. __( 'Go to the <code>Appearance->Theme Options</code> page.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Modify and save your theme options and the layout will be updated automatically.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Saving theme options data will update the currently active layout, so before you start saving make sure you want to modify the current layout.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'If you want to edit a new layout, first create it then save your theme options.', 'option-tree' ) . '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<h4>' . __( 'End-Users Mode', 'option-tree' ) . ':</h4>';
|
||||
echo '<p>' . __( '', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h5>' . __( 'Creating a Layout', 'option-tree' ) . ':</h5>';
|
||||
echo '<ul class="docs-ul">';
|
||||
echo '<li>'. __( 'Go to the <code>Appearance->Theme Options</code> page.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Enter a name for your layout in the text field and hit "New Layout", you\'ve created your first layout.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Adding a new layout is as easy as repeating the steps above.', 'option-tree' ) . '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<h5>' . __( 'Activating a Layout', 'option-tree' ) . ':</h5>';
|
||||
echo '<ul class="docs-ul">';
|
||||
echo '<li>'. __( 'Go to the <code>Appearance->Theme Options</code> page.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Choose a layout from the select list and click the "Activate Layout" button.', 'option-tree' ) . '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<h5>' . __( 'Deleting a Layout', 'option-tree' ) . ':</h5>';
|
||||
echo '<ul class="docs-ul">';
|
||||
echo '<li>'. __( 'End-Users mode does not allow deleting layouts.', 'option-tree' ) . '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<h5>' . __( 'Edit Layout Data', 'option-tree' ) . ':</h5>';
|
||||
echo '<ul class="docs-ul">';
|
||||
echo '<li>'. __( 'Go to the <code>Appearance->Theme Options</code> tab.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Modify and save your theme options and the layout will be updated automatically.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Saving theme options data will update the currently active layout, so before you start saving make sure you want to modify the current layout.', 'option-tree' ) . '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta Boxes option type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_meta_boxes' ) ) {
|
||||
|
||||
function ot_type_meta_boxes() {
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textblock wide-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<h4>'. __( 'How-to-guide', 'option-tree' ) . '</h4>';
|
||||
|
||||
echo '<p>' . __( 'There are a few simple steps you need to take in order to use OptionTree\'s built in Meta Box API. In the code below I\'ll show you a basic demo of how to create your very own custom meta box using any number of the option types you have at your disposal. If you would like to see some demo code, there is a directory named <code>theme-mode</code> inside the <code>assets</code> directory that contains a file named <code>demo-meta-boxes.php</code> you can reference.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<p>' . __( 'It\'s important to note that Meta Boxes do not support WYSIWYG editors at this time and if you set one of your options to Textarea it will automatically revert to a Textarea Simple until a valid solution is found. WordPress released this statement regarding the wp_editor() function:', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<blockquote>' . __( 'Once instantiated, the WYSIWYG editor cannot be moved around in the DOM. What this means in practical terms, is that you cannot put it in meta-boxes that can be dragged and placed elsewhere on the page.', 'option-tree' ) . '</blockquote>';
|
||||
|
||||
echo '<h5>' . __( 'Create and include your custom meta boxes file.', 'option-tree' ) . '</h5>';
|
||||
echo '<ul class="docs-ul">';
|
||||
echo '<li>'. __( 'Create a file and name it anything you want, maybe <code>meta-boxes.php</code>.', 'option-tree' ) . '</li>';
|
||||
echo '<li>'. __( 'As well, you\'ll probably want to create a directory named <code>includes</code> to put your <code>meta-boxes.php</code> into which will help keep you file structure nice and tidy.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Add the following code to your <code>functions.php</code>.', 'option-tree' ) . '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<pre><code>/**
|
||||
* Meta Boxes
|
||||
*/
|
||||
include_once( \'includes/meta-boxes.php\' );
|
||||
</code></pre>';
|
||||
|
||||
echo '<ul class="docs-ul">';
|
||||
echo '<li>' . __( 'Add a variation of the following code to your <code>meta-boxes.php</code>. You\'ll obviously need to fill it in with all your custom array values. It\'s important to note here that we use the <code>admin_init</code> filter because if you were to call the <code>ot_register_meta_box</code> function before OptionTree was loaded the sky would fall on your head.', 'option-tree' ) . '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo "<pre><code>/**
|
||||
* Initialize the meta boxes.
|
||||
*/
|
||||
add_action( 'admin_init', 'custom_meta_boxes' );
|
||||
|
||||
function custom_meta_boxes() {
|
||||
|
||||
$my_meta_box = array(
|
||||
'id' => 'my_meta_box',
|
||||
'title' => 'My Meta Box',
|
||||
'desc' => '',
|
||||
'pages' => array( 'post' ),
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => 'background',
|
||||
'label' => 'Background',
|
||||
'desc' => '',
|
||||
'std' => '',
|
||||
'type' => 'background',
|
||||
'class' => '',
|
||||
'choices' => array()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
ot_register_meta_box( $my_meta_box );
|
||||
|
||||
}</code></pre>";
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme Mode option type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_theme_mode' ) ) {
|
||||
|
||||
function ot_type_theme_mode() {
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textblock wide-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<h4>'. __( 'How-to-guide', 'option-tree' ) . '</h4>';
|
||||
|
||||
echo '<p>' . __( 'There are a few simple steps you need to take in order to use OptionTree as a theme included module. In the code below I\'ll show you a basic demo of how to include the entire plugin as a module, which will allow you to have the most up-to-date version of OptionTree without ever needing to hack the core of the plugin. If you would like to see some demo code, there is a directory named <code>theme-mode</code> inside the <code>assets</code> directory that contains a file named <code>demo-theme-options.php</code> you can reference.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h5>' . __( 'Step 1: Include the plugin & turn on theme mode.', 'option-tree' ) . '</h5>';
|
||||
echo '<ul class="docs-ul">';
|
||||
echo '<li>'. __( 'Download the latest version of <a href="http://wordpress.org/extend/plugins/option-tree/" rel="nofollow" target="_blank">OptionTree</a>.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Unpack the ZIP archive.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Put the <code>option-tree</code> directory in the root of your theme. For example, the server path would be <code>/wp-content/themes/theme-name/option-tree/</code>.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Add the following code to the beginning of your <code>functions.php</code>.', 'option-tree' ) . '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<pre><code>/**
|
||||
* Optional: set \'ot_show_pages\' filter to false.
|
||||
* This will hide the settings & documentation pages.
|
||||
*/
|
||||
add_filter( \'ot_show_pages\', \'__return_false\' );
|
||||
|
||||
/**
|
||||
* Required: set \'ot_theme_mode\' filter to true.
|
||||
*/
|
||||
add_filter( \'ot_theme_mode\', \'__return_true\' );
|
||||
|
||||
/**
|
||||
* Required: include OptionTree.
|
||||
*/
|
||||
include_once( \'option-tree/ot-loader.php\' );
|
||||
</code></pre>';
|
||||
|
||||
echo '<p class="aside">' . __( 'It\'s that simple! You now have OptionTree built into your theme and anytime there\'s an update to the plugin you just replace the old version and you\'re good to go..', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<h5>' . __( 'Step 2: Create Theme Options without using the UI Builder.', 'option-tree' ) . '</h5>';
|
||||
echo '<ul class="docs-ul">';
|
||||
echo '<li>'. __( 'Create a file and name it anything you want, maybe <code>theme-options.php</code>, or use the built in file export to create it for you. Remember, you should always check the file for errors before including it in your theme.', 'option-tree' ) . '</li>';
|
||||
echo '<li>'. __( 'As well, you\'ll probably want to create a directory named <code>includes</code> to put your <code>theme-options.php</code> into which will help keep you file structure nice and tidy.', 'option-tree' ) . '</li>';
|
||||
echo '<li>' . __( 'Add the following code to your <code>functions.php</code>.', 'option-tree' ) . '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<pre><code>/**
|
||||
* Theme Options
|
||||
*/
|
||||
include_once( \'includes/theme-options.php\' );
|
||||
</code></pre>';
|
||||
|
||||
echo '<ul class="docs-ul">';
|
||||
echo '<li>' . __( 'Add a variation of the following code to your <code>theme-options.php</code>. You\'ll obviously need to fill it in with all your custom array values for contextual help (optional), sections (required), and settings (required).', 'option-tree' ) . '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<p>' . __( 'The code below is a boilerplate to get your started. For a full list of the available option types click the "Option Types" tab above. Also a quick note, you don\'t need to put OptionTree in theme mode to manually create options but you will want to hide the docs and settings as each time you load the admin area the settings be be written over with the code below if they\'ve changed in any way. However, this ensures your settings do not get tampered with by the end-user.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo "<pre><code>/**
|
||||
* Initialize the options before anything else.
|
||||
*/
|
||||
add_action( 'admin_init', 'custom_theme_options', 1 );
|
||||
|
||||
/**
|
||||
* Build the custom settings & update OptionTree.
|
||||
*/
|
||||
function custom_theme_options() {
|
||||
/**
|
||||
* Get a copy of the saved settings array.
|
||||
*/
|
||||
$saved_settings = get_option( 'option_tree_settings', array() );
|
||||
|
||||
/**
|
||||
* Custom settings array that will eventually be
|
||||
* passes to the OptionTree Settings API Class.
|
||||
*/
|
||||
$custom_settings = array(
|
||||
'contextual_help' => array(
|
||||
'content' => array(
|
||||
array(
|
||||
'id' => 'general_help',
|
||||
'title' => 'General',
|
||||
'content' => '<p>Help content goes here!</p>'
|
||||
)
|
||||
),
|
||||
'sidebar' => '<p>Sidebar content goes here!</p>',
|
||||
),
|
||||
'sections' => array(
|
||||
array(
|
||||
'id' => 'general',
|
||||
'title' => 'General'
|
||||
)
|
||||
),
|
||||
'settings' => array(
|
||||
array(
|
||||
'id' => 'my_checkbox',
|
||||
'label' => 'Checkbox',
|
||||
'desc' => '',
|
||||
'std' => '',
|
||||
'type' => 'checkbox',
|
||||
'section' => 'general',
|
||||
'class' => '',
|
||||
'choices' => array(
|
||||
array(
|
||||
'value' => 'yes',
|
||||
'label' => 'Yes'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => 'my_layout',
|
||||
'label' => 'Layout',
|
||||
'desc' => 'Choose a layout for your theme',
|
||||
'std' => 'right-sidebar',
|
||||
'type' => 'radio-image',
|
||||
'section' => 'general',
|
||||
'class' => '',
|
||||
'choices' => array(
|
||||
array(
|
||||
'value' => 'left-sidebar',
|
||||
'label' => 'Left Sidebar',
|
||||
'src' => OT_URL . '/assets/images/layout/left-sidebar.png'
|
||||
),
|
||||
array(
|
||||
'value' => 'right-sidebar',
|
||||
'label' => 'Right Sidebar',
|
||||
'src' => OT_URL . '/assets/images/layout/right-sidebar.png'
|
||||
),
|
||||
array(
|
||||
'value' => 'full-width',
|
||||
'label' => 'Full Width (no sidebar)',
|
||||
'src' => OT_URL . '/assets/images/layout/full-width.png'
|
||||
),
|
||||
array(
|
||||
'value' => 'dual-sidebar',
|
||||
'label' => __( 'Dual Sidebar', 'option-tree' ),
|
||||
'src' => OT_URL . '/assets/images/layout/dual-sidebar.png'
|
||||
),
|
||||
array(
|
||||
'value' => 'left-dual-sidebar',
|
||||
'label' => __( 'Left Dual Sidebar', 'option-tree' ),
|
||||
'src' => OT_URL . '/assets/images/layout/left-dual-sidebar.png'
|
||||
),
|
||||
array(
|
||||
'value' => 'right-dual-sidebar',
|
||||
'label' => __( 'Right Dual Sidebar', 'option-tree' ),
|
||||
'src' => OT_URL . '/assets/images/layout/right-dual-sidebar.png'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => 'my_slider',
|
||||
'label' => 'Images',
|
||||
'desc' => '',
|
||||
'std' => '',
|
||||
'type' => 'list-item',
|
||||
'section' => 'general',
|
||||
'class' => '',
|
||||
'choices' => array(),
|
||||
'settings' => array(
|
||||
array(
|
||||
'id' => 'slider_image',
|
||||
'label' => 'Image',
|
||||
'desc' => '',
|
||||
'std' => '',
|
||||
'type' => 'upload',
|
||||
'class' => '',
|
||||
'choices' => array()
|
||||
),
|
||||
array(
|
||||
'id' => 'slider_link',
|
||||
'label' => 'Link to Post',
|
||||
'desc' => 'Enter the posts url.',
|
||||
'std' => '',
|
||||
'type' => 'text',
|
||||
'class' => '',
|
||||
'choices' => array()
|
||||
),
|
||||
array(
|
||||
'id' => 'slider_description',
|
||||
'label' => 'Description',
|
||||
'desc' => 'This text is used to add fancy captions in the slider.',
|
||||
'std' => '',
|
||||
'type' => 'textarea',
|
||||
'class' => '',
|
||||
'choices' => array()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
/* settings are not the same update the DB */
|
||||
if ( $saved_settings !== $custom_settings ) {
|
||||
update_option( 'option_tree_settings', $custom_settings );
|
||||
}
|
||||
|
||||
}
|
||||
</code></pre>";
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file ot-functions-docs-page.php */
|
||||
/* Location: ./includes/ot-functions-docs-page.php */
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,570 @@
|
||||
<?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
|
||||
/**
|
||||
* OptionTree settings page functions.
|
||||
*
|
||||
* @package OptionTree
|
||||
* @author Derek Herman <derek@valendesigns.com>
|
||||
* @copyright Copyright (c) 2012, Derek Herman
|
||||
* @since 2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create option type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_theme_options_ui' ) ) {
|
||||
|
||||
function ot_type_theme_options_ui() {
|
||||
global $blog_id;
|
||||
|
||||
echo '<form method="post" id="option-tree-settings-form">';
|
||||
|
||||
/* form nonce */
|
||||
wp_nonce_field( 'option_tree_settings_form', 'option_tree_settings_nonce' );
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textblock has-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<h4>'. __( 'Warning!', 'option-tree' ) . '</h4>';
|
||||
echo '<p class="warning">' . sprintf( __( 'Go to the %s page if you want to save data, this page is for adding settings.', 'option-tree' ), '<a href="' . get_admin_url( $blog_id, 'themes.php?page=ot-theme-options' ) . '"><code>Appearance->Theme Options</code></a>' ) . '</p>';
|
||||
echo '<p class="warning">' . sprintf( __( 'If you\'re unsure or not completely positive that you should be editing these settings, you should read the %s first.', 'option-tree' ), '<a href="' . get_admin_url( $blog_id, 'admin.php?page=ot-documentation' ) . '"><code>OptionTree->Documentation</code></a>' ) . '</p>';
|
||||
echo '<h4>'. __( 'Things could break or be improperly displayed to the end-user if you do one of the following:', 'option-tree' ) . '</h4>';
|
||||
echo '<p class="warning">' . __( 'Give two sections the same ID, give two settings the same ID, give two contextual help content areas the same ID, don\'t create any settings, or have a section at the end of the settings list.', 'option-tree' ) . '</p>';
|
||||
echo '<p>' . __( 'You can create as many settings as your project requires and use them how you see fit. When you add a setting here, it will be available on the Theme Options page for use in your theme. To separate your settings into sections, click the "Add Section" button, fill in the input fields, and a new navigation menu item will be created.', 'option-tree' ) . '</p>';
|
||||
echo '<p>' . __( 'All of the settings can be sorted and rearranged to your liking with Drag & Drop. Don\'t worry about the order in which you create your settings, you can always reorder them.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
/* get the saved settings */
|
||||
$settings = get_option( 'option_tree_settings' );
|
||||
|
||||
/* wrap settings array */
|
||||
echo '<div class="format-setting-inner">';
|
||||
|
||||
/* set count to zero */
|
||||
$count = 0;
|
||||
|
||||
/* loop through each section and its settings */
|
||||
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_list" data-name="option_tree_settings[settings]">';
|
||||
|
||||
if ( isset( $settings['sections'] ) ) {
|
||||
|
||||
foreach( $settings['sections'] as $section ) {
|
||||
|
||||
/* section */
|
||||
echo '<li class="' . ( $count == 0 ? 'ui-state-disabled' : 'ui-state-default' ) . ' list-section">' . ot_sections_view( 'option_tree_settings[sections]', $count, $section ) . '</li>';
|
||||
|
||||
/* increment item count */
|
||||
$count++;
|
||||
|
||||
/* settings in this section */
|
||||
if ( isset( $settings['settings'] ) ) {
|
||||
|
||||
foreach( $settings['settings'] as $setting ) {
|
||||
|
||||
if ( isset( $setting['section'] ) && $setting['section'] == $section['id'] ) {
|
||||
|
||||
echo '<li class="ui-state-default list-setting">' . ot_settings_view( 'option_tree_settings[settings]', $count, $setting ) . '</li>';
|
||||
|
||||
/* increment item count */
|
||||
$count++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
/* buttons */
|
||||
echo '<a href="javascript:void(0);" class="option-tree-section-add option-tree-ui-button blue hug-left">' . __( 'Add Section', 'option-tree' ) . '</a>';
|
||||
echo '<a href="javascript:void(0);" class="option-tree-setting-add blue option-tree-ui-button">' . __( 'Add Setting', 'option-tree' ) . '</a>';
|
||||
echo '<button class="option-tree-ui-button grey right hug-right">' . __( 'Save Changes', 'option-tree' ) . '</button>';
|
||||
|
||||
/* sidebar textarea */
|
||||
echo '
|
||||
<div class="format-setting-label" id="contextual-help-label">
|
||||
<h3 class="label">' . __( 'Contextual Help', 'option-tree' ) . '</h3>
|
||||
</div>
|
||||
<div class="format-settings" id="contextual-help-setting">
|
||||
<div class="format-setting type-textarea no-desc">
|
||||
<div class="description"><strong>' . __( 'Contextual Help Sidebar', 'option-tree' ) . '</strong>: ' . __( 'If you decide to add contextual help to the Theme Option page, enter the optional "Sidebar" HTML here. This would be an extremely useful place to add links to your themes documentation or support forum. Only after you\'ve added some content below will this display to the user.', 'option-tree' ) . '</div>
|
||||
<div class="format-setting-inner">
|
||||
<textarea class="textarea" rows="10" cols="40" name="option_tree_settings[contextual_help][sidebar]">' . ( isset( $settings['contextual_help']['sidebar'] ) ? esc_html( $settings['contextual_help']['sidebar'] ) : '' ) . '</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
/* set count to zero */
|
||||
$count = 0;
|
||||
|
||||
/* loop through each contextual_help content section */
|
||||
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_help" data-name="option_tree_settings[contextual_help][content]">';
|
||||
|
||||
if ( isset( $settings['contextual_help']['content'] ) ) {
|
||||
|
||||
foreach( $settings['contextual_help']['content'] as $content ) {
|
||||
|
||||
/* content */
|
||||
echo '<li class="ui-state-default list-contextual-help">' . ot_contextual_help_view( 'option_tree_settings[contextual_help][content]', $count, $content ) . '</li>';
|
||||
|
||||
/* increment content count */
|
||||
$count++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
echo '<a href="javascript:void(0);" class="option-tree-help-add blue option-tree-ui-button hug-left">' . __( 'Add Contextual Help Content', 'option-tree' ) . '</a>';
|
||||
echo '<button class="option-tree-ui-button grey right hug-right">' . __( 'Save Changes', 'option-tree' ) . '</button>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</form>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Import XML option type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_import_xml' ) ) {
|
||||
|
||||
function ot_type_import_xml() {
|
||||
|
||||
echo '<form method="post" id="import-xml-form">';
|
||||
|
||||
/* form nonce */
|
||||
wp_nonce_field( 'import_xml_form', 'import_xml_nonce' );
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textblock has-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<p class="deprecated">' . __( 'This import method has been deprecated. That means it has been replaced by a new method and is no longer supported, and may be removed from future versions. All themes that use this import method should be converted to use its replacement below.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<p>' . __( 'If you were given a Theme Options XML file with a premium or free theme, locate it on your hard drive and upload that file by clicking the blue upload button. A popup window will appear, upload the XML file and click "Send to OptionTree". The file URL should be in the upload input, if it is click "Import XML".', 'option-tree' ) . '</p>';
|
||||
|
||||
/* button */
|
||||
echo '<button class="option-tree-ui-button grey right hug-right">' . __( 'Import XML', 'option-tree' ) . '</button>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="format-setting-inner">';
|
||||
|
||||
/* build upload */
|
||||
echo '<div class="option-tree-ui-upload-parent">';
|
||||
|
||||
/* input */
|
||||
echo '<input type="text" name="import_xml" id="import_xml" value="" class="widefat option-tree-ui-upload-input" />';
|
||||
|
||||
/* get media post_id */
|
||||
$post_id = ( $id = ot_get_media_post_ID() ) ? (int) $id : 0;
|
||||
|
||||
/* add xml button */
|
||||
echo '<a href="javascript:void(0);" class="ot_upload_media option-tree-ui-button blue light" rel="' . $post_id . '" title="' . __( 'Add XML', 'option-tree' ) . '"><span class="icon upload">' . __( 'Add XML', 'option-tree' ) . '</span></a>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</form>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Import Settings option type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_import_settings' ) ) {
|
||||
|
||||
function ot_type_import_settings() {
|
||||
|
||||
echo '<form method="post" id="import-settings-form">';
|
||||
|
||||
/* form nonce */
|
||||
wp_nonce_field( 'import_settings_form', 'import_settings_nonce' );
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textarea has-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<p>' . __( 'To import your Settings copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Settings" button.', 'option-tree' ) . '</p>';
|
||||
|
||||
/* button */
|
||||
echo '<button class="option-tree-ui-button grey right hug-right">' . __( 'Import Settings', 'option-tree' ) . '</button>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
/* textarea */
|
||||
echo '<div class="format-setting-inner">';
|
||||
|
||||
echo '<textarea rows="10" cols="40" name="import_settings" id="import_settings" class="textarea"></textarea>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</form>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Import Data option type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_import_data' ) ) {
|
||||
|
||||
function ot_type_import_data() {
|
||||
|
||||
echo '<form method="post" id="import-data-form">';
|
||||
|
||||
/* form nonce */
|
||||
wp_nonce_field( 'import_data_form', 'import_data_nonce' );
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textarea has-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<p>' . __( 'Only after you\'ve imported the Settings should you try and update your Theme Options.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<p>' . __( 'To import your Theme Options copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Theme Options" button.', 'option-tree' ) . '</p>';
|
||||
|
||||
/* button */
|
||||
echo '<button class="option-tree-ui-button grey right hug-right">' . __( 'Import Theme Options', 'option-tree' ) . '</button>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
/* textarea */
|
||||
echo '<div class="format-setting-inner">';
|
||||
|
||||
echo '<textarea rows="10" cols="40" name="import_data" id="import_data" class="textarea"></textarea>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</form>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Import Layouts option type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_import_layouts' ) ) {
|
||||
|
||||
function ot_type_import_layouts() {
|
||||
|
||||
echo '<form method="post" id="import-layouts-form">';
|
||||
|
||||
/* form nonce */
|
||||
wp_nonce_field( 'import_layouts_form', 'import_layouts_nonce' );
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textarea has-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<p>' . __( 'Only after you\'ve imported the Settings should you try and update your Layouts.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '<p>' . __( 'To import your Layouts copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Layouts" button. Keep in mind that when you import your layouts, the active layout\'s saved data will write over the current data set for your Theme Options.', 'option-tree' ) . '</p>';
|
||||
|
||||
/* button */
|
||||
echo '<button class="option-tree-ui-button grey right hug-right">' . __( 'Import Layouts', 'option-tree' ) . '</button>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
/* textarea */
|
||||
echo '<div class="format-setting-inner">';
|
||||
|
||||
echo '<textarea rows="10" cols="40" name="import_layouts" id="import_layouts" class="textarea"></textarea>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</form>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Export Settings File option type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0.8
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_export_settings_file' ) ) {
|
||||
|
||||
function ot_type_export_settings_file() {
|
||||
global $blog_id;
|
||||
|
||||
echo '<form method="post" id="export-settings-file-form">';
|
||||
|
||||
/* form nonce */
|
||||
wp_nonce_field( 'export_settings_file_form', 'export_settings_file_nonce' );
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textarea simple has-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<p>' . sprintf( __( 'Export your Settings into a fully functional <code>theme-options.php</code> file by clicking this button. For more information on how to use this file read the theme mode %s. Remember, you should always check the file for errors before including it in your theme.', 'option-tree' ), '<a href="' . get_admin_url( $blog_id, 'admin.php?page=ot-documentation#section_theme_mode' ) . '"><code>OptionTree->Documentation</code></a>' ) . '</p>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="format-setting-inner">';
|
||||
|
||||
/* button */
|
||||
echo '<button class="option-tree-ui-button grey hug-left">' . __( 'Export Settings File', 'option-tree' ) . '</button>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</form>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Export Settings option type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_export_settings' ) ) {
|
||||
|
||||
function ot_type_export_settings() {
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textarea simple has-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<p>' . __( 'Export your Settings by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the <code>OptionTree->Settings->Import</code> <strong>Settings</strong> textarea on another web site.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
/* get theme options data */
|
||||
$settings = get_option( 'option_tree_settings' );
|
||||
$settings = ! empty( $settings ) ? base64_encode( serialize( $settings ) ) : '';
|
||||
|
||||
echo '<div class="format-setting-inner">';
|
||||
echo '<textarea rows="10" cols="40" name="export_settings" id="export_settings" class="textarea">' . $settings . '</textarea>';
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Export Data option type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_export_data' ) ) {
|
||||
|
||||
function ot_type_export_data() {
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textarea simple has-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<p>' . __( 'Export your Theme Options data by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the <code>OptionTree->Settings->Import</code> <strong>Theme Options</strong> textarea on another web site.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
/* get theme options data */
|
||||
$data = get_option( 'option_tree' );
|
||||
$data = ! empty( $data ) ? base64_encode( serialize( $data ) ) : '';
|
||||
|
||||
echo '<div class="format-setting-inner">';
|
||||
echo '<textarea rows="10" cols="40" name="export_data" id="export_data" class="textarea">' . $data . '</textarea>';
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Export Layouts option type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_export_layouts' ) ) {
|
||||
|
||||
function ot_type_export_layouts() {
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textarea simple has-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<p>' . __( 'Export your Layouts by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the <code>OptionTree->Settings->Import</code> <strong>Layouts</strong> textarea on another web site.', 'option-tree' ) . '</p>';
|
||||
|
||||
|
||||
echo '</div>';
|
||||
|
||||
/* get layout data */
|
||||
$layouts = get_option( 'option_tree_layouts' );
|
||||
$layouts = ! empty( $layouts ) ? base64_encode( serialize( $layouts ) ) : '';
|
||||
|
||||
echo '<div class="format-setting-inner">';
|
||||
echo '<textarea rows="10" cols="40" name="export_layouts" id="export_layouts" class="textarea">' . $layouts . '</textarea>';
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify Layouts option type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_type_modify_layouts' ) ) {
|
||||
|
||||
function ot_type_modify_layouts() {
|
||||
|
||||
echo '<form method="post" id="option-tree-settings-form">';
|
||||
|
||||
/* form nonce */
|
||||
wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
|
||||
|
||||
/* format setting outer wrapper */
|
||||
echo '<div class="format-setting type-textarea has-desc">';
|
||||
|
||||
/* description */
|
||||
echo '<div class="description">';
|
||||
|
||||
echo '<p>' . __( 'To add a new layout enter a unique lower case alphanumeric string (dashes allowed) in the text field and click "Save Layouts".', 'option-tree' ) . '</p>';
|
||||
echo '<p>' . __( 'As well, you can activate, remove, and drag & drop the order; all situations require you to click "Save Layouts" for the changes to be applied.', 'option-tree' ) . '</p>';
|
||||
echo '<p>' . __( 'When you create a new layout it will become active and any changes made to the Theme Options will be applied to it. If you switch back to a different layout immediately after creating a new layout that new layout will have a snapshot of the current Theme Options data attached to it.', 'option-tree' ) . '</p>';
|
||||
echo '<p>' . __( 'Visit <code>OptionTree->Documentation->Layouts Overview</code> to see a more in-depth description of what layouts are and how to use them.', 'option-tree' ) . '</p>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="format-setting-inner">';
|
||||
|
||||
/* get the saved layouts */
|
||||
$layouts = get_option( 'option_tree_layouts' );
|
||||
|
||||
/* set active layout */
|
||||
$active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
|
||||
|
||||
echo '<input type="hidden" name="option_tree_layouts[active_layout]" value="' . esc_attr( $active_layout ) . '" class="active-layout-input" />';
|
||||
|
||||
/* add new layout */
|
||||
echo '<input type="text" name="option_tree_layouts[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />';
|
||||
|
||||
/* loop through each layout */
|
||||
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_layouts">';
|
||||
|
||||
if ( is_array( $layouts ) && ! empty( $layouts ) ) {
|
||||
|
||||
foreach( $layouts as $key => $data ) {
|
||||
|
||||
/* skip active layout array */
|
||||
if ( $key == 'active_layout' )
|
||||
continue;
|
||||
|
||||
/* content */
|
||||
echo '<li class="ui-state-default list-layouts">' . ot_layout_view( $key, $data, $active_layout ) . '</li>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
echo '<button class="option-tree-ui-button grey right hug-right">' . __( 'Save Layouts', 'option-tree' ) . '</button>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</form>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file ot-functions-settings-page.php */
|
||||
/* Location: ./includes/ot-functions-settings-page.php */
|
@ -0,0 +1,98 @@
|
||||
<?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
|
||||
/**
|
||||
* OptionTree functions
|
||||
*
|
||||
* @package OptionTree
|
||||
* @author Derek Herman <derek@valendesigns.com>
|
||||
* @copyright Copyright (c) 2012, Derek Herman
|
||||
* @since 2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get Option.
|
||||
*
|
||||
* Helper function to return the option value.
|
||||
* If no value has been saved, it returns $default.
|
||||
*
|
||||
* @param string The option ID.
|
||||
* @param string The default option value.
|
||||
* @return mixed
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_get_option' ) ) {
|
||||
|
||||
function ot_get_option( $option_id, $default = '' ) {
|
||||
|
||||
/* get the saved options */
|
||||
$options = get_option( 'option_tree' );
|
||||
|
||||
/* look for the saved value */
|
||||
if ( isset( $options[$option_id] ) && '' != $options[$option_id] ) {
|
||||
return $options[$option_id];
|
||||
}
|
||||
|
||||
return $default;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue the dynamic CSS.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_load_dynamic_css' ) ) {
|
||||
|
||||
function ot_load_dynamic_css() {
|
||||
|
||||
/* don't load in the admin */
|
||||
if ( is_admin() )
|
||||
return;
|
||||
|
||||
/* grab a copy of the paths */
|
||||
$ot_css_file_paths = get_option( 'ot_css_file_paths', array() );
|
||||
|
||||
if ( ! empty( $ot_css_file_paths ) ) {
|
||||
|
||||
$last_css = '';
|
||||
|
||||
/* loop through paths */
|
||||
foreach( $ot_css_file_paths as $key => $path ) {
|
||||
|
||||
if ( '' != $path && file_exists( $path ) ) {
|
||||
|
||||
$parts = explode( '/wp-content', $path );
|
||||
|
||||
if ( isset( $parts[1] ) ) {
|
||||
|
||||
$css = home_url( '/wp-content' . $parts[1] );
|
||||
|
||||
if ( $last_css !== $css ) {
|
||||
|
||||
/* enqueue filtered file */
|
||||
wp_enqueue_style( 'ot-dynamic-' . $key, $css, false, OT_VERSION );
|
||||
|
||||
$last_css = $css;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file ot-functions.php */
|
||||
/* Location: ./includes/ot-functions.php */
|
@ -0,0 +1,281 @@
|
||||
<?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
|
||||
/**
|
||||
* OptionTree Meta Box API
|
||||
*
|
||||
* This class loads all the methods and helpers specific to build a meta box.
|
||||
*
|
||||
* @package OptionTree
|
||||
* @author Derek Herman <derek@valendesigns.com>
|
||||
* @copyright Copyright (c) 2012, Derek Herman
|
||||
*/
|
||||
if ( ! class_exists( 'OT_Meta_Box' ) ) {
|
||||
|
||||
class OT_Meta_Box {
|
||||
|
||||
/* variable to store the meta box array */
|
||||
private $meta_box;
|
||||
|
||||
/**
|
||||
* PHP5 constructor method.
|
||||
*
|
||||
* This method adds other methods of the class to specific hooks within WordPress.
|
||||
*
|
||||
* @uses add_action()
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
*/
|
||||
function __construct( $meta_box ) {
|
||||
if ( ! is_admin() )
|
||||
return;
|
||||
|
||||
$this->meta_box = $meta_box;
|
||||
|
||||
add_action( 'add_meta_boxes', array( &$this, 'add_meta_boxes' ) );
|
||||
|
||||
add_action( 'save_post', array( &$this, 'save_meta_box' ), 1, 2 );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds meta box to any post type
|
||||
*
|
||||
* @uses add_meta_box()
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
*/
|
||||
function add_meta_boxes() {
|
||||
foreach ( (array) $this->meta_box['pages'] as $page ) {
|
||||
add_meta_box( $this->meta_box['id'], $this->meta_box['title'], array( &$this, 'build_meta_box' ), $page, $this->meta_box['context'], $this->meta_box['priority'], $this->meta_box['fields'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta box view
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
*/
|
||||
function build_meta_box( $post, $metabox ) {
|
||||
|
||||
echo '<div class="ot-metabox-wrapper">';
|
||||
|
||||
/* Use nonce for verification */
|
||||
echo '<input type="hidden" name="' . $this->meta_box['id'] . '_nonce" value="' . wp_create_nonce( $this->meta_box['id'] ) . '" />';
|
||||
|
||||
/* meta box description */
|
||||
echo isset( $this->meta_box['desc'] ) ? '<div class="description" style="padding-top:10px;">' . htmlspecialchars_decode( $this->meta_box['desc'] ) . '</div>' : '';
|
||||
|
||||
/* loop through meta box fields */
|
||||
foreach ( $this->meta_box['fields'] as $field ) {
|
||||
|
||||
/* get current post meta data */
|
||||
$field_value = get_post_meta( $post->ID, $field['id'], true );
|
||||
|
||||
/* set default to standard value */
|
||||
if ( '' == $field_value && isset( $field['std'] ) ) {
|
||||
$field_value = trim( $field['std'] );
|
||||
}
|
||||
|
||||
/* build the arguments array */
|
||||
$_args = array(
|
||||
'type' => $field['type'],
|
||||
'field_id' => $field['id'],
|
||||
'field_name' => $field['id'],
|
||||
'field_value' => $field_value,
|
||||
'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '',
|
||||
'field_std' => isset( $field['std'] ) ? $field['std'] : '',
|
||||
'field_rows' => isset( $field['rows'] ) && ! empty( $field['rows'] ) ? $field['rows'] : 10,
|
||||
'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post',
|
||||
'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
|
||||
'field_class' => isset( $field['class'] ) ? $field['class'] : '',
|
||||
'field_choices' => isset( $field['choices'] ) ? $field['choices'] : array(),
|
||||
'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
|
||||
'post_id' => $post->ID,
|
||||
'meta' => true
|
||||
);
|
||||
|
||||
/* only allow simple textarea due to DOM issues with wp_editor() */
|
||||
if ( $_args['type'] == 'textarea' )
|
||||
$_args['type'] = 'textarea-simple';
|
||||
|
||||
/* option label */
|
||||
echo '<div class="format-settings">';
|
||||
echo '<div class="format-setting-label">';
|
||||
echo '<label for="' . $_args['field_id'] . '" class="label">' . $field['label'] . '</label>';
|
||||
echo '</div>';
|
||||
|
||||
/* get the option HTML */
|
||||
echo ot_display_by_type( $_args );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the meta box values
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
*/
|
||||
function save_meta_box( $post_id, $post_object ) {
|
||||
global $pagenow;
|
||||
|
||||
/* don't save during quick edit */
|
||||
if ( $pagenow == 'admin-ajax.php' )
|
||||
return $post_id;
|
||||
|
||||
/* don't save during autosave */
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
|
||||
return $post_id;
|
||||
|
||||
/* don't save if viewing a revision */
|
||||
if ( $post_object->post_type == 'revision' )
|
||||
return $post_id;
|
||||
|
||||
/* verify nonce */
|
||||
if ( isset( $_POST[ $this->meta_box['id'] . '_nonce'] ) && ! wp_verify_nonce( $_POST[ $this->meta_box['id'] . '_nonce'], $this->meta_box['id'] ) )
|
||||
return $post_id;
|
||||
|
||||
/* check permissions */
|
||||
if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) {
|
||||
if ( ! current_user_can( 'edit_page', $post_id ) )
|
||||
return $post_id;
|
||||
} else {
|
||||
if ( ! current_user_can( 'edit_post', $post_id ) )
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
foreach ( $this->meta_box['fields'] as $field ) {
|
||||
|
||||
$old = get_post_meta( $post_id, $field['id'], true );
|
||||
$new = '';
|
||||
|
||||
/* there is data to validate */
|
||||
if ( isset( $_POST[$field['id']] ) ) {
|
||||
|
||||
/* slider and list item */
|
||||
if ( in_array( $field['type'], array( 'list-item', 'slider' ) ) ) {
|
||||
|
||||
/* required title setting */
|
||||
$required_setting = array(
|
||||
array(
|
||||
'id' => 'title',
|
||||
'label' => __( 'Title', 'option-tree' ),
|
||||
'desc' => '',
|
||||
'std' => '',
|
||||
'type' => 'text',
|
||||
'rows' => '',
|
||||
'class' => 'option-tree-setting-title',
|
||||
'post_type' => '',
|
||||
'choices' => array()
|
||||
)
|
||||
);
|
||||
|
||||
/* get the settings array */
|
||||
$settings = isset( $_POST[$field['id'] . '_settings_array'] ) ? unserialize( base64_decode( $_POST[$field['id'] . '_settings_array'] ) ) : array();
|
||||
|
||||
/* settings are empty for some odd ass reason get the defaults */
|
||||
if ( empty( $settings ) ) {
|
||||
$settings = 'slider' == $field['type'] ?
|
||||
ot_slider_settings( $field['id'] ) :
|
||||
ot_list_item_settings( $field['id'] );
|
||||
}
|
||||
|
||||
/* merge the two settings array */
|
||||
$settings = array_merge( $required_setting, $settings );
|
||||
|
||||
foreach( $_POST[$field['id']] as $k => $setting_array ) {
|
||||
|
||||
foreach( $settings as $sub_setting ) {
|
||||
|
||||
/* verify sub setting has a type & value */
|
||||
if ( isset( $sub_setting['type'] ) && isset( $_POST[$field['id']][$k][$sub_setting['id']] ) ) {
|
||||
|
||||
$_POST[$field['id']][$k][$sub_setting['id']] = ot_validate_setting( $_POST[$field['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* set up new data with validated data */
|
||||
$new = $_POST[$field['id']];
|
||||
|
||||
} else {
|
||||
|
||||
/* run through validattion */
|
||||
$new = ot_validate_setting( $_POST[$field['id']], $field['type'], $field['id'] );
|
||||
|
||||
}
|
||||
|
||||
/* insert CSS */
|
||||
if ( $field['type'] == 'css' ) {
|
||||
|
||||
/* insert CSS into dynamic.css */
|
||||
if ( '' !== $new ) {
|
||||
|
||||
ot_insert_css_with_markers( $field['id'], $new, true );
|
||||
|
||||
/* remove old CSS from dynamic.css */
|
||||
} else {
|
||||
|
||||
ot_remove_old_css( $field['id'] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $new && $new !== $old ) {
|
||||
update_post_meta( $post_id, $field['id'], $new );
|
||||
} else if ( '' == $new && $old ) {
|
||||
delete_post_meta( $post_id, $field['id'], $old );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method instantiates the meta box class & builds the UI.
|
||||
*
|
||||
* @uses OT_Meta_Box()
|
||||
*
|
||||
* @param array Array of arguments to create a meta box
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_register_meta_box' ) ) {
|
||||
|
||||
function ot_register_meta_box( $args ) {
|
||||
if ( ! $args )
|
||||
return;
|
||||
|
||||
$ot_meta_box =& new OT_Meta_Box( $args );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file ot-meta-box-api.php */
|
||||
/* Location: ./includes/ot-meta-box-api.php */
|
@ -0,0 +1,849 @@
|
||||
<?php if ( ! defined( 'OT_VERSION') ) exit( 'No direct script access allowed' );
|
||||
/**
|
||||
* OptionTree Settings API
|
||||
*
|
||||
* This class loads all the methods and helpers specific to a Settings page.
|
||||
*
|
||||
* @package OptionTree
|
||||
* @author Derek Herman <derek@valendesigns.com>
|
||||
* @copyright Copyright (c) 2012, Derek Herman
|
||||
*/
|
||||
if ( ! class_exists( 'OT_Settings' ) ) {
|
||||
|
||||
class OT_Settings {
|
||||
|
||||
/* the options array */
|
||||
private $options;
|
||||
|
||||
/* hooks for targeting admin pages */
|
||||
private $page_hook;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array An array of options
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function __construct( $args ) {
|
||||
|
||||
$this->options = $args;
|
||||
|
||||
/* return early if not viewing an admin page or no options */
|
||||
if ( ! is_admin() || ! is_array( $this->options ) )
|
||||
return false;
|
||||
|
||||
/* load everything */
|
||||
$this->hooks();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the WordPress Hooks
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
/* add pages & menu items */
|
||||
add_action( 'admin_menu', array( &$this, 'add_page' ) );
|
||||
|
||||
/* register sections */
|
||||
add_action( 'admin_init', array( &$this, 'add_sections' ) );
|
||||
|
||||
/* register settings */
|
||||
add_action( 'admin_init', array( &$this, 'add_settings' ) );
|
||||
|
||||
/* reset options */
|
||||
add_action( 'admin_init', array( &$this, 'reset_options' ), 10 );
|
||||
|
||||
/* initialize settings */
|
||||
add_action( 'admin_init', array( &$this, 'initialize_settings' ), 11 );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads each admin page
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function add_page() {
|
||||
|
||||
/* loop through options */
|
||||
foreach( (array) $this->options as $option ) {
|
||||
|
||||
/* loop through pages */
|
||||
foreach( (array) $this->get_pages( $option ) as $page ) {
|
||||
|
||||
/* load page in WP top level menu */
|
||||
if ( ! isset( $page['parent_slug'] ) || empty( $page['parent_slug'] ) ) {
|
||||
$page_hook = add_menu_page(
|
||||
$page['page_title'],
|
||||
$page['menu_title'],
|
||||
$page['capability'],
|
||||
$page['menu_slug'],
|
||||
array( &$this, 'display_page' ),
|
||||
$page['icon_url'],
|
||||
$page['position']
|
||||
);
|
||||
/* load page in WP sub menu */
|
||||
} else {
|
||||
$page_hook = add_submenu_page(
|
||||
$page['parent_slug'],
|
||||
$page['page_title'],
|
||||
$page['menu_title'],
|
||||
$page['capability'],
|
||||
$page['menu_slug'],
|
||||
array( &$this, 'display_page' )
|
||||
);
|
||||
}
|
||||
|
||||
/* only load if not a hidden page */
|
||||
if ( ! isset( $page['hidden_page'] ) ) {
|
||||
|
||||
/* associate $page_hook with page id */
|
||||
$this->page_hook[$page['id']] = $page_hook;
|
||||
|
||||
/* add scripts */
|
||||
add_action( 'admin_print_scripts-' . $page_hook, array( &$this, 'scripts' ) );
|
||||
|
||||
/* add styles */
|
||||
add_action( 'admin_print_styles-' . $page_hook, array( &$this, 'styles' ) );
|
||||
|
||||
/* add contextual help */
|
||||
add_action( 'load-' . $page_hook, array( &$this, 'help' ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the scripts
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function scripts() {
|
||||
ot_admin_scripts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the styles
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function styles() {
|
||||
ot_admin_styles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the contextual help for each page
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function help() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
/* loop through options */
|
||||
foreach( (array) $this->options as $option ) {
|
||||
|
||||
/* loop through pages */
|
||||
foreach( (array) $this->get_pages( $option ) as $page ) {
|
||||
|
||||
/* verify page */
|
||||
if ( ! isset( $page['hidden_page'] ) && $screen->id == $this->page_hook[$page['id']] ) {
|
||||
|
||||
/* set up the help tabs */
|
||||
if ( ! empty( $page['contextual_help']['content'] ) ) {
|
||||
foreach( $page['contextual_help']['content'] as $contextual_help ) {
|
||||
$screen->add_help_tab(
|
||||
array(
|
||||
'id' => esc_attr( $contextual_help['id'] ),
|
||||
'title' => esc_attr( $contextual_help['title'] ),
|
||||
'content' => htmlspecialchars_decode( $contextual_help['content'] ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* set up the help sidebar */
|
||||
if ( ! empty( $page['contextual_help']['sidebar'] ) ) {
|
||||
$screen->set_help_sidebar( htmlspecialchars_decode( $page['contextual_help']['sidebar'] ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the content for each page
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function display_page() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
/* loop through settings */
|
||||
foreach( (array) $this->options as $option ) {
|
||||
|
||||
/* loop through pages */
|
||||
foreach( (array) $this->get_pages( $option ) as $page ) {
|
||||
|
||||
/* verify page */
|
||||
if ( ! isset( $page['hidden_page'] ) && $screen->id == $this->page_hook[$page['id']] ) {
|
||||
|
||||
$show_buttons = isset( $page['show_buttons'] ) && $page['show_buttons'] == false ? false : true;
|
||||
|
||||
/* update active layout content */
|
||||
if ( isset( $_REQUEST['settings-updated'] ) && $_REQUEST['settings-updated'] == 'true' ) {
|
||||
|
||||
$layouts = get_option( 'option_tree_layouts' );
|
||||
|
||||
/* has active layout */
|
||||
if ( isset( $layouts['active_layout'] ) ) {
|
||||
$option_tree = get_option( $option['id'] );
|
||||
$layouts[$layouts['active_layout']] = base64_encode( serialize( $option_tree ) );
|
||||
update_option( 'option_tree_layouts', $layouts );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '<div class="wrap settings-wrap" id ="page-' . $page['id'] . '">';
|
||||
|
||||
screen_icon( ( isset( $page['screen_icon'] ) ? $page['screen_icon'] : 'options-general' ) );
|
||||
echo '<h2>' . $page['page_title'] . '</h2>';
|
||||
|
||||
echo ot_alert_message( $page );
|
||||
|
||||
settings_errors( 'option-tree' );
|
||||
|
||||
/* Header */
|
||||
echo '<div id="option-tree-header-wrap">';
|
||||
|
||||
echo '<ul id="option-tree-header">';
|
||||
|
||||
echo '<li id="option-tree-logo"><a href="http://wordpress.org/extend/plugins/option-tree/" target="_blank">OptionTree</a></li>';
|
||||
|
||||
echo '<li id="option-tree-version"><span>Version ' . OT_VERSION . '</span></li>';
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
/* layouts form */
|
||||
if ( $page['id'] == 'ot_theme_options' )
|
||||
ot_theme_options_layouts_form();
|
||||
|
||||
echo '</div>';
|
||||
|
||||
/* remove forms on the custom settings pages */
|
||||
if ( $show_buttons ) {
|
||||
|
||||
echo '<form action="options.php" method="post" id="option-tree-settings-api">';
|
||||
|
||||
settings_fields( $option['id'] );
|
||||
|
||||
} else {
|
||||
|
||||
echo '<div id="option-tree-settings-api">';
|
||||
|
||||
}
|
||||
|
||||
/* Sub Header */
|
||||
echo '<div id="option-tree-sub-header">';
|
||||
|
||||
if ( $show_buttons )
|
||||
echo '<button class="option-tree-ui-button grey right">' . $page['button_text'] . '</button>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
/* Navigation */
|
||||
echo '<div class="ui-tabs">';
|
||||
|
||||
/* check for sections */
|
||||
if ( isset( $page['sections'] ) && count( $page['sections'] ) > 0 ) {
|
||||
|
||||
echo '<ul class="ui-tabs-nav">';
|
||||
|
||||
/* loop through page sections */
|
||||
foreach( (array) $page['sections'] as $section ) {
|
||||
echo '<li><a href="#section_' . $section['id'] . '">' . $section['title'] . '</a></li>';
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
}
|
||||
|
||||
/* sections */
|
||||
echo '<div id="poststuff" class="metabox-holder">';
|
||||
|
||||
echo '<div id="post-body">';
|
||||
|
||||
echo '<div id="post-body-content">';
|
||||
|
||||
$this->do_settings_sections( $_GET['page'] );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
/* buttons */
|
||||
if ( $show_buttons ) {
|
||||
|
||||
echo '<div class="option-tree-ui-buttons">';
|
||||
|
||||
echo '<button class="option-tree-ui-button grey right">' . $page['button_text'] . '</button>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
echo $show_buttons ? '</form>' : '</div>';
|
||||
|
||||
/* reset button */
|
||||
if ( $show_buttons ) {
|
||||
|
||||
echo '<form method="post" action="' . str_replace( '&settings-updated=true', '', $_SERVER["REQUEST_URI"] ) . '">';
|
||||
|
||||
/* form nonce */
|
||||
wp_nonce_field( 'option_tree_reset_form', 'option_tree_reset_nonce' );
|
||||
|
||||
echo '<input type="hidden" name="action" value="reset" />';
|
||||
|
||||
echo '<button type="submit" class="option-tree-ui-button red light left reset-settings" title="' . __( 'Reset Options', 'option-tree' ) . '">' . __( 'Reset Options', 'option-tree' ) . '</button>';
|
||||
|
||||
echo '</form>';
|
||||
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds sections to the page
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function add_sections() {
|
||||
|
||||
/* loop through options */
|
||||
foreach( (array) $this->options as $option ) {
|
||||
|
||||
/* loop through pages */
|
||||
foreach( (array) $this->get_pages( $option ) as $page ) {
|
||||
|
||||
/* loop through page sections */
|
||||
foreach( (array) $this->get_sections( $page ) as $section ) {
|
||||
|
||||
/* add each section */
|
||||
add_settings_section(
|
||||
$section['id'],
|
||||
$section['title'],
|
||||
array( &$this, 'display_section' ),
|
||||
$page['menu_slug']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for add_settings_section()
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function display_section() {
|
||||
/* currently pointless */
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings the the page
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function add_settings() {
|
||||
|
||||
/* loop through options */
|
||||
foreach( (array) $this->options as $option ) {
|
||||
|
||||
register_setting( $option['id'], $option['id'], array ( &$this, 'sanitize_callback' ) );
|
||||
|
||||
/* loop through pages */
|
||||
foreach( (array) $this->get_pages( $option ) as $page ) {
|
||||
|
||||
/* loop through page settings */
|
||||
foreach( (array) $this->get_settings( $page ) as $setting ) {
|
||||
|
||||
/* skip if no setting ID */
|
||||
if ( ! isset( $setting['id'] ) )
|
||||
continue;
|
||||
|
||||
/* add get_option param to the array */
|
||||
$setting['get_option'] = $option['id'];
|
||||
|
||||
/* add each setting */
|
||||
add_settings_field(
|
||||
$setting['id'],
|
||||
$setting['label'],
|
||||
array( &$this, 'display_setting' ),
|
||||
$page['menu_slug'],
|
||||
$setting['section'],
|
||||
$setting
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for add_settings_field() to build each setting by type
|
||||
*
|
||||
* @param array Setting object array
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function display_setting( $args = array() ) {
|
||||
extract( $args );
|
||||
|
||||
/* get current saved data */
|
||||
$options = get_option( $get_option, false );
|
||||
|
||||
/* set default to standard value */
|
||||
if ( ! isset( $options[$id] ) && isset( $std ) ) {
|
||||
$options[$id] = trim( $std );
|
||||
}
|
||||
|
||||
/* build the arguments array */
|
||||
$_args = array(
|
||||
'type' => $type,
|
||||
'field_id' => $id,
|
||||
'field_name' => 'option_tree[' . $id . ']',
|
||||
'field_value' => isset( $options[$id] ) ? $options[$id] : '',
|
||||
'field_desc' => isset( $desc ) ? $desc : '',
|
||||
'field_std' => isset( $std ) ? $std : '',
|
||||
'field_rows' => isset( $rows ) && ! empty( $rows ) ? $rows : 15,
|
||||
'field_post_type' => isset( $post_type ) && ! empty( $post_type ) ? $post_type : 'post',
|
||||
'field_taxonomy' => isset( $taxonomy ) && ! empty( $taxonomy ) ? $taxonomy : 'category',
|
||||
'field_class' => isset( $class ) ? $class : '',
|
||||
'field_choices' => isset( $choices ) && ! empty( $choices ) ? $choices : array(),
|
||||
'field_settings' => isset( $settings ) && ! empty( $settings ) ? $settings : array(),
|
||||
'post_id' => ot_get_media_post_ID(),
|
||||
'get_option' => $get_option,
|
||||
);
|
||||
|
||||
/* get the option HTML */
|
||||
echo ot_display_by_type( $_args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the option standards if nothing yet exists.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function initialize_settings() {
|
||||
|
||||
/* loop through options */
|
||||
foreach( (array) $this->options as $option ) {
|
||||
|
||||
/* skip if option is already set */
|
||||
if ( isset( $option['id'] ) && get_option( $option['id'], false ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$defaults = array();
|
||||
|
||||
/* loop through pages */
|
||||
foreach( (array) $this->get_pages( $option ) as $page ) {
|
||||
|
||||
/* loop through page settings */
|
||||
foreach( (array) $this->get_settings( $page ) as $setting ) {
|
||||
|
||||
if ( isset( $setting['std'] ) ) {
|
||||
|
||||
$defaults[$setting['id']] = ot_validate_setting( $setting['std'], $setting['type'], $setting['id'] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
update_option( $option['id'], $defaults );
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize callback for register_setting()
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function sanitize_callback( $input ) {
|
||||
|
||||
/* loop through options */
|
||||
foreach( (array) $this->options as $option ) {
|
||||
|
||||
/* loop through pages */
|
||||
foreach( (array) $this->get_pages( $option ) as $page ) {
|
||||
|
||||
/* loop through page settings */
|
||||
foreach( (array) $this->get_settings( $page ) as $setting ) {
|
||||
|
||||
/* verify setting has a type & value */
|
||||
if ( isset( $setting['type'] ) && isset( $input[$setting['id']] ) ) {
|
||||
|
||||
/* validate setting */
|
||||
if ( is_array( $input[$setting['id']] ) && in_array( $setting['type'], array( 'list-item', 'slider' ) ) ) {
|
||||
|
||||
/* required title setting */
|
||||
$required_setting = array(
|
||||
array(
|
||||
'id' => 'title',
|
||||
'label' => __( 'Title', 'option-tree' ),
|
||||
'desc' => '',
|
||||
'std' => '',
|
||||
'type' => 'text',
|
||||
'rows' => '',
|
||||
'class' => 'option-tree-setting-title',
|
||||
'post_type' => '',
|
||||
'choices' => array()
|
||||
)
|
||||
);
|
||||
|
||||
/* get the settings array */
|
||||
$settings = isset( $_POST[$setting['id'] . '_settings_array'] ) ? unserialize( base64_decode( $_POST[$setting['id'] . '_settings_array'] ) ) : array();
|
||||
|
||||
/* settings are empty for some odd ass reason get the defaults */
|
||||
if ( empty( $settings ) ) {
|
||||
$settings = 'slider' == $setting['type'] ?
|
||||
ot_slider_settings( $setting['id'] ) :
|
||||
ot_list_item_settings( $setting['id'] );
|
||||
}
|
||||
|
||||
/* merge the two settings array */
|
||||
$settings = array_merge( $required_setting, $settings );
|
||||
|
||||
foreach( $input[$setting['id']] as $k => $setting_array ) {
|
||||
|
||||
foreach( $settings as $sub_setting ) {
|
||||
|
||||
/* verify sub setting has a type & value */
|
||||
if ( isset( $sub_setting['type'] ) && isset( $input[$setting['id']][$k][$sub_setting['id']] ) ) {
|
||||
|
||||
$input[$setting['id']][$k][$sub_setting['id']] = ot_validate_setting( $input[$setting['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$input[$setting['id']] = ot_validate_setting( $input[$setting['id']], $setting['type'], $setting['id'] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get the pages array for an option
|
||||
*
|
||||
* @param array Option array
|
||||
* @return mixed
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function get_pages( $option = array() ) {
|
||||
|
||||
if ( empty( $option ) )
|
||||
return false;
|
||||
|
||||
/* check for pages */
|
||||
if ( isset( $option['pages'] ) && ! empty( $option['pages'] ) ) {
|
||||
|
||||
/* return pages array */
|
||||
return $option['pages'];
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get the sections array for a page
|
||||
*
|
||||
* @param array Page array
|
||||
* @return mixed
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function get_sections( $page = array() ) {
|
||||
|
||||
if ( empty( $page ) )
|
||||
return false;
|
||||
|
||||
/* check for sections */
|
||||
if ( isset( $page['sections'] ) && ! empty( $page['sections'] ) ) {
|
||||
|
||||
/* return sections array */
|
||||
return $page['sections'];
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get the settings array for a page
|
||||
*
|
||||
* @param array Page array
|
||||
* @return mixed
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function get_settings( $page = array() ) {
|
||||
|
||||
if ( empty( $page ) )
|
||||
return false;
|
||||
|
||||
/* check for settings */
|
||||
if ( isset( $page['settings'] ) && ! empty( $page['settings'] ) ) {
|
||||
|
||||
/* return settings array */
|
||||
return $page['settings'];
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints out all settings sections added to a particular settings page
|
||||
*
|
||||
* @global $wp_settings_sections Storage array of all settings sections added to admin pages
|
||||
* @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
|
||||
*
|
||||
* @param string The slug name of the page whos settings sections you want to output
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function do_settings_sections( $page ) {
|
||||
global $wp_settings_sections, $wp_settings_fields;
|
||||
|
||||
if ( ! isset( $wp_settings_sections ) || ! isset( $wp_settings_sections[$page] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( (array) $wp_settings_sections[$page] as $section ) {
|
||||
|
||||
if ( ! isset( $section['id'] ) )
|
||||
continue;
|
||||
|
||||
echo '<div id="section_' . $section['id'] . '" class="postbox ui-tabs-panel">';
|
||||
|
||||
call_user_func( $section['callback'], $section );
|
||||
|
||||
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[$page] ) || ! isset( $wp_settings_fields[$page][$section['id']] ) )
|
||||
continue;
|
||||
|
||||
echo '<div class="inside">';
|
||||
|
||||
$this->do_settings_fields( $page, $section['id'] );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out the settings fields for a particular settings section
|
||||
*
|
||||
* @global $wp_settings_fields Storage array of settings fields and their pages/sections
|
||||
*
|
||||
* @param string $page Slug title of the admin page who's settings fields you want to show.
|
||||
* @param string $section Slug title of the settings section who's fields you want to show.
|
||||
* @return string
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function do_settings_fields( $page, $section ) {
|
||||
global $wp_settings_fields;
|
||||
|
||||
if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
|
||||
return;
|
||||
|
||||
foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
|
||||
|
||||
echo '<div class="format-settings">';
|
||||
|
||||
if ( $field['args']['type'] != 'textblock' ) {
|
||||
|
||||
echo '<div class="format-setting-label">';
|
||||
|
||||
echo '<h3 class="label">' . $field['title'] . '</h3>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
call_user_func( $field['callback'], $field['args'] );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets page options before the screen is displayed
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
public function reset_options() {
|
||||
|
||||
/* check for reset action */
|
||||
if ( isset( $_POST['option_tree_reset_nonce'] ) && wp_verify_nonce( $_POST['option_tree_reset_nonce'], 'option_tree_reset_form' ) ) {
|
||||
|
||||
/* loop through options */
|
||||
foreach( (array) $this->options as $option ) {
|
||||
|
||||
/* loop through pages */
|
||||
foreach( (array) $this->get_pages( $option ) as $page ) {
|
||||
|
||||
/* verify page */
|
||||
if ( isset( $_GET['page'] ) && $_GET['page'] == $page['menu_slug'] ) {
|
||||
|
||||
/* reset options */
|
||||
delete_option( $option['id'] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method instantiates the settings class & builds the UI.
|
||||
*
|
||||
* @uses OT_Settings()
|
||||
*
|
||||
* @param array Array of arguments to create settings
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @since 2.0
|
||||
*/
|
||||
if ( ! function_exists( 'ot_register_settings' ) ) {
|
||||
|
||||
function ot_register_settings( $args ) {
|
||||
if ( ! $args )
|
||||
return;
|
||||
|
||||
$ot_settings =& new OT_Settings( $args );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file ot-settings-api.php */
|
||||
/* Location: ./includes/ot-settings-api.php */
|
@ -0,0 +1,225 @@
|
||||
<?php if ( ! defined( 'OT_VERSION') ) exit( 'No direct script access allowed' );
|
||||
/**
|
||||
* Builds the Setting & Documentation UI.
|
||||
*
|
||||
* @uses ot_register_settings()
|
||||
*
|
||||
* @package OptionTree
|
||||
* @author Derek Herman <derek@valendesigns.com>
|
||||
* @copyright Copyright (c) 2012, Derek Herman
|
||||
*/
|
||||
if ( function_exists( 'ot_register_settings' ) ) {
|
||||
|
||||
ot_register_settings( array(
|
||||
array(
|
||||
'id' => 'option_tree_settings',
|
||||
'pages' => apply_filters( 'ot_register_pages_array', array(
|
||||
array(
|
||||
'id' => 'ot',
|
||||
'page_title' => __( 'OptionTree', 'option-tree' ),
|
||||
'menu_title' => __( 'OptionTree', 'option-tree' ),
|
||||
'capability' => 'manage_options',
|
||||
'menu_slug' => 'ot-settings',
|
||||
'icon_url' => OT_URL . '/assets/images/ot-logo-mini.png',
|
||||
'position' => 61,
|
||||
'hidden_page' => true
|
||||
),
|
||||
array(
|
||||
'id' => 'settings',
|
||||
'parent_slug' => 'ot-settings',
|
||||
'page_title' => __( 'Settings', 'option-tree' ),
|
||||
'menu_title' => __( 'Settings', 'option-tree' ),
|
||||
'capability' => 'manage_options',
|
||||
'menu_slug' => 'ot-settings',
|
||||
'icon_url' => null,
|
||||
'position' => null,
|
||||
'updated_message' => __( 'Theme Options updated.', 'option-tree' ),
|
||||
'reset_message' => __( 'Theme Options reset.', 'option-tree' ),
|
||||
'button_text' => __( 'Save Settings', 'option-tree' ),
|
||||
'show_buttons' => false,
|
||||
'screen_icon' => 'themes',
|
||||
'sections' => array(
|
||||
array(
|
||||
'id' => 'create_setting',
|
||||
'title' => __( 'Theme Options UI', 'option-tree' )
|
||||
),
|
||||
array(
|
||||
'id' => 'import',
|
||||
'title' => __( 'Import', 'option-tree' )
|
||||
),
|
||||
array(
|
||||
'id' => 'export',
|
||||
'title' => __( 'Export', 'option-tree' )
|
||||
),
|
||||
array(
|
||||
'id' => 'layouts',
|
||||
'title' => __( 'Layouts', 'option-tree' )
|
||||
)
|
||||
),
|
||||
'settings' => array(
|
||||
array(
|
||||
'id' => 'theme_options_ui_text',
|
||||
'label' => __( 'Theme Options UI Builder', 'option-tree' ),
|
||||
'type' => 'theme_options_ui',
|
||||
'section' => 'create_setting'
|
||||
),
|
||||
array(
|
||||
'id' => 'import_xml_text',
|
||||
'label' => __( 'Settings XML', 'option-tree' ),
|
||||
'type' => 'import-xml',
|
||||
'section' => 'import'
|
||||
),
|
||||
array(
|
||||
'id' => 'import_settings_text',
|
||||
'label' => __( 'Settings', 'option-tree' ),
|
||||
'type' => 'import-settings',
|
||||
'section' => 'import'
|
||||
),
|
||||
array(
|
||||
'id' => 'import_data_text',
|
||||
'label' => __( 'Theme Options', 'option-tree' ),
|
||||
'type' => 'import-data',
|
||||
'section' => 'import'
|
||||
),
|
||||
array(
|
||||
'id' => 'import_layouts_text',
|
||||
'label' => __( 'Layouts', 'option-tree' ),
|
||||
'type' => 'import-layouts',
|
||||
'section' => 'import'
|
||||
),
|
||||
array(
|
||||
'id' => 'export_settings_file_text',
|
||||
'label' => __( 'Settings PHP File', 'option-tree' ),
|
||||
'type' => 'export-settings-file',
|
||||
'section' => 'export'
|
||||
),
|
||||
array(
|
||||
'id' => 'export_settings_text',
|
||||
'label' => __( 'Settings', 'option-tree' ),
|
||||
'type' => 'export-settings',
|
||||
'section' => 'export'
|
||||
),
|
||||
array(
|
||||
'id' => 'export_data_text',
|
||||
'label' => __( 'Theme Options', 'option-tree' ),
|
||||
'type' => 'export-data',
|
||||
'section' => 'export'
|
||||
),
|
||||
array(
|
||||
'id' => 'export_layout_text',
|
||||
'label' => __( 'Layouts', 'option-tree' ),
|
||||
'type' => 'export-layouts',
|
||||
'section' => 'export'
|
||||
),
|
||||
array(
|
||||
'id' => 'modify_layouts_text',
|
||||
'label' => __( 'Add, Activate, & Remove Layouts', 'option-tree' ),
|
||||
'type' => 'modify-layouts',
|
||||
'section' => 'layouts'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => 'documentation',
|
||||
'parent_slug' => 'ot-settings',
|
||||
'page_title' => __( 'Documentation', 'option-tree' ),
|
||||
'menu_title' => __( 'Documentation', 'option-tree' ),
|
||||
'capability' => 'manage_options',
|
||||
'menu_slug' => 'ot-documentation',
|
||||
'icon_url' => null,
|
||||
'position' => null,
|
||||
'updated_message' => __( 'Theme Options updated.', 'option-tree' ),
|
||||
'reset_message' => __( 'Theme Options reset.', 'option-tree' ),
|
||||
'button_text' => __( 'Save Settings', 'option-tree' ),
|
||||
'show_buttons' => false,
|
||||
'screen_icon' => 'themes',
|
||||
'sections' => array(
|
||||
array(
|
||||
'id' => 'creating_options',
|
||||
'title' => __( 'Creating Options', 'option-tree' )
|
||||
),
|
||||
array(
|
||||
'id' => 'option_types',
|
||||
'title' => __( 'Option Types', 'option-tree' )
|
||||
),
|
||||
array(
|
||||
'id' => 'functions',
|
||||
'title' => __( 'Function References', 'option-tree' )
|
||||
),
|
||||
array(
|
||||
'id' => 'theme_mode',
|
||||
'title' => __( 'Theme Mode', 'option-tree' )
|
||||
),
|
||||
array(
|
||||
'id' => 'meta_boxes',
|
||||
'title' => __( 'Meta Boxes', 'option-tree' )
|
||||
),
|
||||
array(
|
||||
'id' => 'examples',
|
||||
'title' => __( 'Code Examples', 'option-tree' )
|
||||
),
|
||||
array(
|
||||
'id' => 'layouts_overview',
|
||||
'title' => __( 'Layouts Overview', 'option-tree' )
|
||||
)
|
||||
),
|
||||
'settings' => array(
|
||||
array(
|
||||
'id' => 'creating_options_text',
|
||||
'label' => __( 'Overview of available Theme Option fields.', 'option-tree' ),
|
||||
'type' => 'creating-options',
|
||||
'section' => 'creating_options'
|
||||
),
|
||||
array(
|
||||
'id' => 'option_types_text',
|
||||
'label' => __( 'Option types in alphabetical order & hooks to filter them.', 'option-tree' ),
|
||||
'type' => 'option-types',
|
||||
'section' => 'option_types'
|
||||
),
|
||||
array(
|
||||
'id' => 'functions_ot_get_option',
|
||||
'label' => __( 'Function Reference:ot_get_option()', 'option-tree' ),
|
||||
'type' => 'ot-get-option',
|
||||
'section' => 'functions'
|
||||
),
|
||||
array(
|
||||
'id' => 'functions_get_option_tree',
|
||||
'label' => __( 'Function Reference:get_option_tree()', 'option-tree' ),
|
||||
'type' => 'get-option-tree',
|
||||
'section' => 'functions'
|
||||
),
|
||||
array(
|
||||
'id' => 'theme_mode_text',
|
||||
'label' => __( 'Theme Mode', 'option-tree' ),
|
||||
'type' => 'theme-mode',
|
||||
'section' => 'theme_mode'
|
||||
),
|
||||
array(
|
||||
'id' => 'meta_boxes_text',
|
||||
'label' => __( 'Meta Boxes', 'option-tree' ),
|
||||
'type' => 'meta-boxes',
|
||||
'section' => 'meta_boxes'
|
||||
),
|
||||
array(
|
||||
'id' => 'example_text',
|
||||
'label' => __( 'Code examples for front-end development.', 'option-tree' ),
|
||||
'type' => 'examples',
|
||||
'section' => 'examples'
|
||||
),
|
||||
array(
|
||||
'id' => 'layouts_overview_text',
|
||||
'label' => __( 'What\'s a layout anyhow?', 'option-tree' ),
|
||||
'type' => 'layouts-overview',
|
||||
'section' => 'layouts_overview'
|
||||
)
|
||||
)
|
||||
)
|
||||
) )
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/* End of file ot-ui-admin.php */
|
||||
/* Location: ./option-tree/ot-ui-admin.php */
|
@ -0,0 +1,56 @@
|
||||
<?php if ( ! defined( 'OT_VERSION') ) exit( 'No direct script access allowed' );
|
||||
/**
|
||||
* Builds the Theme Option UI.
|
||||
*
|
||||
* @uses ot_register_settings()
|
||||
*
|
||||
* @package OptionTree
|
||||
* @author Derek Herman <derek@valendesigns.com>
|
||||
* @copyright Copyright (c) 2012, Derek Herman
|
||||
*/
|
||||
|
||||
/* get the settings array */
|
||||
$get_settings = get_option( 'option_tree_settings' );
|
||||
|
||||
/* sections array */
|
||||
$sections = isset( $get_settings['sections'] ) ? $get_settings['sections'] : array();
|
||||
|
||||
/* settings array */
|
||||
$settings = isset( $get_settings['settings'] ) ? $get_settings['settings'] : array();
|
||||
|
||||
/* contexual_help array */
|
||||
$contextual_help = isset( $get_settings['contextual_help'] ) ? $get_settings['contextual_help'] : array();
|
||||
|
||||
/* build the Theme Options */
|
||||
if ( function_exists( 'ot_register_settings' ) ) {
|
||||
|
||||
ot_register_settings( array(
|
||||
array(
|
||||
'id' => 'option_tree',
|
||||
'pages' => array(
|
||||
array(
|
||||
'id' => 'ot_theme_options',
|
||||
'parent_slug' => 'themes.php',
|
||||
'page_title' => __( 'Theme Options', 'option-tree' ),
|
||||
'menu_title' => __( 'Theme Options', 'option-tree' ),
|
||||
'capability' => 'manage_options',
|
||||
'menu_slug' => 'ot-theme-options',
|
||||
'icon_url' => null,
|
||||
'position' => null,
|
||||
'updated_message' => __( 'Theme Options updated.', 'option-tree' ),
|
||||
'reset_message' => __( 'Theme Options reset.', 'option-tree' ),
|
||||
'button_text' => __( 'Save Changes', 'option-tree' ),
|
||||
'screen_icon' => 'themes',
|
||||
'contextual_help' => $contextual_help,
|
||||
'sections' => $sections,
|
||||
'settings' => $settings
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/* End of file ot-ui-theme-options.php */
|
||||
/* Location: ./option-tree/ot-ui-theme-options.php */
|
Reference in New Issue
Block a user