* @copyright Copyright (c) 2012, 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 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 '
'; } } /** * Category 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_category_select' ) ) { function ot_type_category_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 '
'; } } /** * 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_checkbox' ) ) { function ot_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 '
'; } } /** * Colorpicker 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_colorpicker' ) ) { function ot_type_colorpicker( $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 '
' . __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ) . '
'; 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 '
'; } } /** * 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 ) { 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 '
'; } } /** * 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 ) { $count = 0; 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 '
'; } } /** * Upload 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_upload' ) ) { function ot_type_upload( $args = array() ) { /* turns arguments array into variables extract( $args ); /* verify a description $has_desc = $field_desc ? true : false; /* format setting outer wrapper echo '
'; } } /** * 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 '
'; echo '
'; if ( $field['args']['type'] != 'textblock' ) { echo '