* @copyright Copyright (c) 2013, Derek Herman
* @since 2.0
*/
/**
* Builds the HTML for each of the available option types by calling those
* function with call_user_func and passing the arguments to the second param.
*
* All fields are required!
*
* @param array $args The array of arguments are as follows:
* @param string $type Type of option.
* @param string $field_id The field ID.
* @param string $field_name The field Name.
* @param mixed $field_value The field value is a string or an array of values.
* @param string $field_desc The field description.
* @param string $field_std The standard value.
* @param string $field_class Extra CSS classes.
* @param array $field_choices The array of option choices.
* @param array $field_settings The array of settings for a list item.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_display_by_type' ) ) {
function ot_display_by_type( $args = array() ) {
/* allow filters to be executed on the array */
$args = apply_filters( 'ot_display_by_type', $args );
/* build the function name */
$function_name_by_type = str_replace( '-', '_', 'ot_type_' . $args['type'] );
/* call the function & pass in arguments array */
if ( function_exists( $function_name_by_type ) ) {
call_user_func( $function_name_by_type, $args );
} else {
echo '
' . __( 'Sorry, this function does not exist', 'option-tree' ) . '
';
}
}
}
/**
* Background option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_background' ) ) {
function ot_type_background( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
}
}
/**
* CSS option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_css' ) ) {
function ot_type_css( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
/* build textarea for CSS */
echo '';
echo '
';
echo '
';
}
}
/**
* Custom Post Type Checkbox option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_custom_post_type_checkbox' ) ) {
function ot_type_custom_post_type_checkbox( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
}
}
/**
* Custom Post Type Select option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_custom_post_type_select' ) ) {
function ot_type_custom_post_type_select( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
/* build category */
echo '';
echo '
';
echo '
';
}
}
/**
* List Item option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_list_item' ) ) {
function ot_type_list_item( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
/* pass the settings array arround */
echo '';
/**
* settings pages have array wrappers like 'option_tree'.
* So we need that value to create a proper array to save to.
* This is only for NON metaboxes settings.
*/
if ( ! isset( $get_option ) )
$get_option = '';
/* build list items */
echo '
' . apply_filters( 'ot_list_item_description', __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ), $field_id ) . '
';
echo '
';
echo '
';
}
}
/**
* Measurement option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_measurement' ) ) {
function ot_type_measurement( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
echo '
';
echo '';
echo '
';
/* build measurement */
echo '';
echo '
';
echo '
';
}
}
/**
* Numeric Slider option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.1
*/
if( ! function_exists( 'ot_type_numeric_slider' ) ) {
function ot_type_numeric_slider( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
$_options = explode( ',', $field_min_max_step );
$min = isset( $_options[0] ) ? $_options[0] : 0;
$max = isset( $_options[1] ) ? $_options[1] : 100;
$step = isset( $_options[2] ) ? $_options[2] : 1;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
echo '
';
echo '';
echo '';
echo '';
echo '
';
echo '
';
echo '
';
}
}
/**
* Page Checkbox option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_page_checkbox' ) ) {
function ot_type_page_checkbox( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
}
}
/**
* Page Select option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_page_select' ) ) {
function ot_type_page_select( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
/* build page select */
echo '';
echo '
';
echo '
';
}
}
/**
* List Item option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_slider' ) ) {
function ot_type_slider( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
/* pass the settings array arround */
echo '';
/**
* settings pages have array wrappers like 'option_tree'.
* So we need that value to create a proper array to save to.
* This is only for NON metaboxes settings.
*/
if ( ! isset( $get_option ) )
$get_option = '';
/* build list items */
echo '
' . __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ) . '
';
echo '
';
echo '
';
}
}
/**
* Post Checkbox option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_post_checkbox' ) ) {
function ot_type_post_checkbox( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
}
}
/**
* Post Select option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_post_select' ) ) {
function ot_type_post_select( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
/* build page select */
echo '';
echo '
';
echo '
';
}
}
/**
* Radio option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_radio' ) ) {
function ot_type_radio( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
/* build radio */
foreach ( (array) $field_choices as $key => $choice ) {
echo '';
}
echo '
';
echo '
';
}
}
/**
* Radio Images option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_radio_image' ) ) {
function ot_type_radio_image( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
/**
* load the default filterable images if nothing
* has been set in the choices array.
*/
if ( empty( $field_choices ) )
$field_choices = ot_radio_images( $field_id );
/* build radio image */
foreach ( (array) $field_choices as $key => $choice ) {
$src = str_replace( 'OT_URL', OT_URL, $choice['src'] );
$src = str_replace( 'OT_THEME_URL', OT_THEME_URL, $src );
echo '
';
echo '';
echo '';
echo '
';
}
echo '
';
echo '
';
}
}
/**
* Select option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_select' ) ) {
function ot_type_select( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
/* build select */
echo '';
echo '
';
echo '
';
}
}
/**
* Sidebar Select option type.
*
* This option type makes it possible for users to select a WordPress registered sidebar
* to use on a specific area. By using the two provided filters, 'ot_recognized_sidebars',
* and 'ot_recognized_sidebars_{$field_id}' we can be selective about which sidebars are
* available on a specific content area.
*
* For example, if we create a WordPress theme that provides the ability to change the
* Blog Sidebar and we don't want to have the footer sidebars available on this area,
* we can unset those sidebars either manually or by using a regular expression if we
* have a common name like footer-sidebar-$i.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.1
*/
if ( ! function_exists( 'ot_type_sidebar_select' ) ) {
function ot_type_sidebar_select( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
/* build page select */
echo '';
echo '
';
echo '
';
}
}
/**
* Tag Checkbox option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_tag_checkbox' ) ) {
function ot_type_tag_checkbox( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
/* get tags */
$tags = get_tags( array( 'hide_empty' => false ) );
/* has tags */
if ( $tags ) {
foreach( $tags as $tag ) {
echo '
';
}
}
/**
* Tag Select option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_tag_select' ) ) {
function ot_type_tag_select( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
/* build tag select */
echo '';
echo '
';
echo '
';
}
}
/**
* Taxonomy Checkbox option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_taxonomy_checkbox' ) ) {
function ot_type_taxonomy_checkbox( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
}
}
/**
* Taxonomy Select option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_taxonomy_select' ) ) {
function ot_type_taxonomy_select( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
/* build tag select */
echo '';
echo '
';
echo '
';
}
}
/**
* Text option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_text' ) ) {
function ot_type_text( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
/* description */
echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : '';
/* format setting inner wrapper */
echo '
';
/* build text input */
echo '';
echo '
';
echo '
';
}
}
/**
* Textarea option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_textarea' ) ) {
function ot_type_textarea( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '
';
}
}
/**
* Textblock option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_textblock' ) ) {
function ot_type_textblock( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* format setting outer wrapper */
echo '
';
/* description */
echo '
' . htmlspecialchars_decode( $field_desc ) . '
';
echo '
';
}
}
/**
* Textblock Titled option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_textblock_titled' ) ) {
function ot_type_textblock_titled( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* format setting outer wrapper */
echo '
';
/* description */
echo '
' . htmlspecialchars_decode( $field_desc ) . '
';
echo '
';
}
}
/**
* Typography option type.
*
* See @ot_display_by_type to see the full list of available arguments.
*
* @param array An array of arguments.
* @return string
*
* @access public
* @since 2.0
*/
if ( ! function_exists( 'ot_type_typography' ) ) {
function ot_type_typography( $args = array() ) {
/* turns arguments array into variables */
extract( $args );
/* verify a description */
$has_desc = $field_desc ? true : false;
/* format setting outer wrapper */
echo '