* @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 '
'; /* description */ echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : ''; /* format setting inner wrapper */ echo '
'; /* build background colorpicker */ echo '
'; /* colorpicker JS */ echo ''; /* set background color */ $background_color = isset( $field_value['background-color'] ) ? esc_attr( $field_value['background-color'] ) : ''; /* set border color */ $border_color = in_array( $background_color, array( '#FFFFFF', '#FFF', '#ffffff', '#fff' ) ) ? '#ccc' : $background_color; /* input */ echo ''; echo '
'; echo '
'; echo '
'; /* build background repeat */ $background_repeat = isset( $field_value['background-repeat'] ) ? esc_attr( $field_value['background-repeat'] ) : ''; echo ''; /* build background attachment */ $background_attachment = isset( $field_value['background-attachment'] ) ? esc_attr( $field_value['background-attachment'] ) : ''; echo ''; /* build background position */ $background_position = isset( $field_value['background-position'] ) ? esc_attr( $field_value['background-position'] ) : ''; echo ''; echo '
'; /* build background image */ echo '
'; /* input */ echo ''; /* add media button */ echo '' . __( 'Add Media', 'option-tree' ) . ''; echo '
'; /* media */ if ( isset( $field_value['background-image'] ) && $field_value['background-image'] !== '' ) { echo '
'; if ( preg_match( '/\.(?:jpe?g|png|gif|ico)$/i', $field_value['background-image'] ) ) echo '
'; echo '' . __( 'Remove Media', 'option-tree' ) . ''; echo '
'; } echo '
'; echo '
'; } } /** * Category 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_category_checkbox' ) ) { function ot_type_category_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 category array */ $categories = get_categories( array( 'hide_empty' => false ) ); /* build categories */ if ( ! empty( $categories ) ) { foreach ( $categories as $category ) { echo '

'; echo 'term_id] ) ? checked( $field_value[$category->term_id], $category->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; echo ''; echo '

'; } } else { echo '

' . __( 'No Categories Found', 'option-tree' ) . '

'; } echo '
'; 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 '
'; /* description */ echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : ''; /* format setting inner wrapper */ echo '
'; /* build checkbox */ foreach ( (array) $field_choices as $key => $choice ) { if ( isset( $choice['value'] ) && isset( $choice['label'] ) ) { echo '

'; echo ''; echo ''; echo '

'; } } echo '
'; 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 '
'; /* description */ echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : ''; /* format setting inner wrapper */ echo '
'; /* build colorpicker */ echo '
'; /* colorpicker JS */ echo ''; /* input */ echo ''; /* set border color */ $border_color = in_array( $field_value, array( '#FFFFFF', '#FFF', '#ffffff', '#fff' ) ) ? '#ccc' : esc_attr( $field_value ); echo '
'; echo '
'; echo '
'; 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 '
'; /* description */ echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : ''; /* format setting inner wrapper */ echo '
'; /* setup the post types */ $post_type = isset( $field_post_type ) ? explode( ',', $field_post_type ) : array( 'post' ); /* query posts array */ $my_posts = get_posts( apply_filters( 'ot_type_custom_post_type_checkbox_query', array( 'post_type' => $post_type, 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any' ), $field_id ) ); /* has posts */ if ( is_array( $my_posts ) && ! empty( $my_posts ) ) { foreach( $my_posts as $my_post ){ echo '

'; echo 'ID] ) ? checked( $field_value[$my_post->ID], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; echo ''; echo '

'; } } else { echo '

' . __( 'No Posts Found', 'option-tree' ) . '

'; } echo '
'; 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 ''; /* button */ echo '' . __( 'Add New', 'option-tree' ) . ''; /* description */ 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 '
'; /* description */ echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : ''; /* format setting inner wrapper */ echo '
'; /* query pages array */ $my_posts = get_posts( apply_filters( 'ot_type_page_checkbox_query', array( 'post_type' => array( 'page' ), 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any' ), $field_id ) ); /* has pages */ if ( is_array( $my_posts ) && ! empty( $my_posts ) ) { foreach( $my_posts as $my_post ){ echo '

'; echo 'ID] ) ? checked( $field_value[$my_post->ID], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; echo ''; echo '

'; } } else { echo '

' . __( 'No Pages Found', 'option-tree' ) . '

'; } echo '
'; 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 ''; /* button */ echo '' . __( 'Add New', 'option-tree' ) . ''; /* description */ 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 '
'; /* description */ echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : ''; /* format setting inner wrapper */ echo '
'; /* query posts array */ $my_posts = get_posts( apply_filters( 'ot_type_post_checkbox_query', array( 'post_type' => array( 'post' ), 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any' ), $field_id ) ); /* has posts */ if ( is_array( $my_posts ) && ! empty( $my_posts ) ) { foreach( $my_posts as $my_post ){ echo '

'; echo 'ID] ) ? checked( $field_value[$my_post->ID], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; echo ''; echo '

'; } } else { echo '

' . __( 'No Posts Found', 'option-tree' ) . '

'; } echo '
'; 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 '' . esc_attr( $choice['label'] ) .''; 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 '

'; echo 'term_id] ) ? checked( $field_value[$tag->term_id], $tag->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; echo ''; echo '

'; } } else { echo '

' . __( 'No Tags Found', 'option-tree' ) . '

'; } echo '
'; 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 '
'; /* description */ echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : ''; /* format setting inner wrapper */ echo '
'; /* setup the taxonomy */ $taxonomy = isset( $field_taxonomy ) ? explode( ',', $field_taxonomy ) : array( 'category' ); /* get taxonomies */ $taxonomies = get_categories( array( 'hide_empty' => false, 'taxonomy' => $taxonomy ) ); /* has tags */ if ( $taxonomies ) { foreach( $taxonomies as $taxonomy ) { echo '

'; echo 'term_id] ) ? checked( $field_value[$taxonomy->term_id], $taxonomy->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; echo ''; echo '

'; } } else { echo '

' . __( 'No Taxonomies Found', 'option-tree' ) . '

'; } echo '
'; 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 '
'; /* description */ echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : ''; /* format setting inner wrapper */ echo '
'; /* build textarea */ wp_editor( $field_value, esc_attr( $field_id ), array( 'editor_class' => esc_attr( $field_class ), 'wpautop' => apply_filters( 'ot_wpautop', false, $field_id ), 'media_buttons' => apply_filters( 'ot_media_buttons', true, $field_id ), 'textarea_name' => esc_attr( $field_name ), 'textarea_rows' => esc_attr( $field_rows ), 'tinymce' => apply_filters( 'ot_tinymce', true, $field_id ), 'quicktags' => apply_filters( 'ot_quicktags', array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ), $field_id ) ) ); echo '
'; echo '
'; } } /** * Textarea Simple 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_simple' ) ) { function ot_type_textarea_simple( $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 '
'; /* filter to allow wpautop */ $wpautop = apply_filters( 'ot_wpautop', false, $field_id ); /* wpautop $field_value */ if ( $wpautop == true ) $field_value = wpautop( $field_value ); /* build textarea simple */ echo ''; echo '
'; 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 '
'; /* description */ echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : ''; /* format setting inner wrapper */ echo '
'; /* allow fields to be filtered */ $ot_recognized_typography_fields = apply_filters( 'ot_recognized_typography_fields', array( 'font-color', 'font-family', 'font-size', 'font-style', 'font-variant', 'font-weight', 'letter-spacing', 'line-height', 'text-decoration', 'text-transform' ), $field_id ); /* build background colorpicker */ if ( in_array( 'font-color', $ot_recognized_typography_fields ) ) { echo '
'; /* colorpicker JS */ echo ''; /* set background color */ $background_color = isset( $field_value['font-color'] ) ? esc_attr( $field_value['font-color'] ) : ''; /* set border color */ $border_color = in_array( $background_color, array( '#FFFFFF', '#FFF', '#ffffff', '#fff' ) ) ? '#ccc' : $background_color; /* input */ echo ''; echo '
'; echo '
'; } /* build font family */ if ( in_array( 'font-family', $ot_recognized_typography_fields ) ) { $font_family = isset( $field_value['font-family'] ) ? $field_value['font-family'] : ''; echo ''; } /* build font size */ if ( in_array( 'font-size', $ot_recognized_typography_fields ) ) { $font_size = isset( $field_value['font-size'] ) ? esc_attr( $field_value['font-size'] ) : ''; echo ''; } /* build font style */ if ( in_array( 'font-style', $ot_recognized_typography_fields ) ) { $font_style = isset( $field_value['font-style'] ) ? esc_attr( $field_value['font-style'] ) : ''; echo ''; } /* build font variant */ if ( in_array( 'font-variant', $ot_recognized_typography_fields ) ) { $font_variant = isset( $field_value['font-variant'] ) ? esc_attr( $field_value['font-variant'] ) : ''; echo ''; } /* build font weight */ if ( in_array( 'font-weight', $ot_recognized_typography_fields ) ) { $font_weight = isset( $field_value['font-weight'] ) ? esc_attr( $field_value['font-weight'] ) : ''; echo ''; } /* build letter spacing */ if ( in_array( 'letter-spacing', $ot_recognized_typography_fields ) ) { $letter_spacing = isset( $field_value['letter-spacing'] ) ? esc_attr( $field_value['letter-spacing'] ) : ''; echo ''; } /* build line height */ if ( in_array( 'line-height', $ot_recognized_typography_fields ) ) { $line_height = isset( $field_value['line-height'] ) ? esc_attr( $field_value['line-height'] ) : ''; echo ''; } /* build text decoration */ if ( in_array( 'text-decoration', $ot_recognized_typography_fields ) ) { $text_decoration = isset( $field_value['text-decoration'] ) ? esc_attr( $field_value['text-decoration'] ) : ''; echo ''; } /* build text transform */ if ( in_array( 'text-transform', $ot_recognized_typography_fields ) ) { $text_transform = isset( $field_value['text-transform'] ) ? esc_attr( $field_value['text-transform'] ) : ''; echo ''; } echo '
'; 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 '
'; /* description */ echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : ''; /* format setting inner wrapper */ echo '
'; /* build upload */ echo '
'; /* input */ echo ''; /* add media button */ echo '' . __( 'Add Media', 'option-tree' ) . ''; echo '
'; /* media */ if ( $field_value ) { echo '
'; if ( preg_match( '/\.(?:jpe?g|png|gif|ico)$/i', $field_value ) ) echo '
'; echo '' . __( 'Remove Media', 'option-tree' ) . ''; echo '
'; } echo '
'; echo '
'; } } /* End of file ot-functions-option-types.php */ /* Location: ./includes/ot-functions-option-types.php */