* @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; /* If an attachment ID is stored here fetch its URL and replace the value */ if ( isset( $field_value['background-image'] ) && wp_attachment_is_image( $field_value['background-image'] ) ) { $attachment_data = wp_get_attachment_image_src( $field_value['background-image'], 'original' ); /* check for attachment data */ if ( $attachment_data ) { $field_src = $attachment_data[0]; } } /* 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_background_fields = apply_filters( 'ot_recognized_background_fields', array( 'background-color', 'background-repeat', 'background-attachment', 'background-position', 'background-size', 'background-image' ), $field_id ); echo '
'; /* build background color */ if ( in_array( 'background-color', $ot_recognized_background_fields ) ) { echo '
'; /* colorpicker JS */ echo ''; /* set background color */ $background_color = isset( $field_value['background-color'] ) ? esc_attr( $field_value['background-color'] ) : ''; /* input */ echo ''; echo '
'; } /* build background repeat */ if ( in_array( 'background-repeat', $ot_recognized_background_fields ) ) { $background_repeat = isset( $field_value['background-repeat'] ) ? esc_attr( $field_value['background-repeat'] ) : ''; echo ''; } /* build background attachment */ if ( in_array( 'background-attachment', $ot_recognized_background_fields ) ) { $background_attachment = isset( $field_value['background-attachment'] ) ? esc_attr( $field_value['background-attachment'] ) : ''; echo ''; } /* build background position */ if ( in_array( 'background-position', $ot_recognized_background_fields ) ) { $background_position = isset( $field_value['background-position'] ) ? esc_attr( $field_value['background-position'] ) : ''; echo ''; } /* Build background size */ if ( in_array( 'background-size', $ot_recognized_background_fields ) ) { /** * Use this filter to create a select instead of an text input. * Be sure to return the array in the correct format. Add an empty * value to the first choice so the user can leave it blank. * array( array( 'label' => 'background-size', 'value' => '' ), array( 'label' => 'cover', 'value' => 'cover' ), array( 'label' => 'contain', 'value' => 'contain' ) ) * */ $choices = apply_filters( 'ot_type_background_size_choices', '', $field_id ); if ( is_array( $choices ) && ! empty( $choices ) ) { /* build select */ echo ''; } else { echo ''; } } echo '
'; /* build background image */ if ( in_array( 'background-image', $ot_recognized_background_fields ) ) { echo '
'; /* input */ echo ''; /* add media button */ echo '' . __( 'Add Media', 'option-tree' ) . ''; echo '
'; /* media */ if ( isset( $field_value['background-image'] ) && $field_value['background-image'] !== '' ) { /* replace image src */ if ( isset( $field_src ) ) $field_value['background-image'] = $field_src; echo '
'; if ( preg_match( '/\.(?:jpe?g|png|gif|ico)$/i', $field_value['background-image'] ) ) echo '
'; echo '' . __( 'Remove Media', 'option-tree' ) . ''; echo '
'; } } echo '
'; echo '
'; } } /** * Border Option Type * * See @ot_display_by_type to see the full list of available arguments. * * @param array The options arguments * @return string The markup. * * @access public * @since 2.5.0 */ if ( ! function_exists( 'ot_type_border' ) ) { function ot_type_border( $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_border_fields = apply_filters( 'ot_recognized_border_fields', array( 'width', 'unit', 'style', 'color' ), $field_id ); /* build border width */ if ( in_array( 'width', $ot_recognized_border_fields ) ) { $width = isset( $field_value['width'] ) ? esc_attr( $field_value['width'] ) : ''; echo '
'; } /* build unit dropdown */ if ( in_array( 'unit', $ot_recognized_border_fields ) ) { echo '
'; echo ''; echo '
'; } /* build style dropdown */ if ( in_array( 'style', $ot_recognized_border_fields ) ) { echo '
'; echo ''; echo '
'; } /* build color */ if ( in_array( 'color', $ot_recognized_border_fields ) ) { echo '
'; /* colorpicker JS */ echo ''; /* set color */ $color = isset( $field_value['color'] ) ? esc_attr( $field_value['color'] ) : ''; /* input */ echo ''; echo '
'; } echo '
'; echo '
'; } } /** * Box Shadow Option Type * * See @ot_display_by_type to see the full list of available arguments. * * @param array The options arguments * @return string The markup. * * @access public * @since 2.5.0 */ if ( ! function_exists( 'ot_type_box_shadow' ) ) { function ot_type_box_shadow( $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_box_shadow_fields = apply_filters( 'ot_recognized_box_shadow_fields', array( 'inset', 'offset-x', 'offset-y', 'blur-radius', 'spread-radius', 'color' ), $field_id ); /* build inset */ if ( in_array( 'inset', $ot_recognized_box_shadow_fields ) ) { echo '

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

'; } /* build horizontal offset */ if ( in_array( 'offset-x', $ot_recognized_box_shadow_fields ) ) { $offset_x = isset( $field_value['offset-x'] ) ? esc_attr( $field_value['offset-x'] ) : ''; echo '
'; } /* build vertical offset */ if ( in_array( 'offset-y', $ot_recognized_box_shadow_fields ) ) { $offset_y = isset( $field_value['offset-y'] ) ? esc_attr( $field_value['offset-y'] ) : ''; echo '
'; } /* build blur-radius radius */ if ( in_array( 'blur-radius', $ot_recognized_box_shadow_fields ) ) { $blur_radius = isset( $field_value['blur-radius'] ) ? esc_attr( $field_value['blur-radius'] ) : ''; echo '
'; } /* build spread-radius radius */ if ( in_array( 'spread-radius', $ot_recognized_box_shadow_fields ) ) { $spread_radius = isset( $field_value['spread-radius'] ) ? esc_attr( $field_value['spread-radius'] ) : ''; echo '
'; } /* build color */ if ( in_array( 'color', $ot_recognized_box_shadow_fields ) ) { echo '
'; /* colorpicker JS */ echo ''; /* set color */ $color = isset( $field_value['color'] ) ? esc_attr( $field_value['color'] ) : ''; /* input */ echo ''; 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( apply_filters( 'ot_type_category_checkbox_query', array( 'hide_empty' => false ), $field_id ) ); /* 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 * @updated 2.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 ''; /* set the default color */ $std = $field_std ? 'data-default-color="' . $field_std . '"' : ''; /* input */ echo ''; echo '
'; echo '
'; echo '
'; } } /** * Colorpicker Opacity 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.5.0 */ if ( ! function_exists( 'ot_type_colorpicker_opacity' ) ) { function ot_type_colorpicker_opacity( $args = array() ) { $args['field_class'] = isset( $args['field_class'] ) ? $args['field_class'] . ' ot-colorpicker-opacity' : 'ot-colorpicker-opacity'; ot_type_colorpicker( $args ); } } /** * 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 ''; /* build pre to convert it into ace editor later */ echo '
' . esc_textarea( $field_value ) . '
'; 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 ) { $post_title = '' != $my_post->post_title ? $my_post->post_title : 'Untitled'; 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 '
'; } } /** * Date Picker 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.3 */ if ( ! function_exists( 'ot_type_date_picker' ) ) { function ot_type_date_picker( $args = array() ) { /* turns arguments array into variables */ extract( $args ); /* verify a description */ $has_desc = $field_desc ? true : false; /* filter date format */ $date_format = apply_filters( 'ot_type_date_picker_date_format', 'yy-mm-dd', $field_id ); /** * Filter the addition of the readonly attribute. * * @since 2.5.0 * * @param bool $is_readonly Whether to add the 'readonly' attribute. Default 'false'. * @param string $field_id The field ID. */ $is_readonly = apply_filters( 'ot_type_date_picker_readonly', false, $field_id ); /* format setting outer wrapper */ echo '
'; /* date picker JS */ echo ''; /* description */ echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : ''; /* format setting inner wrapper */ echo '
'; /* build date picker */ echo ''; echo '
'; echo '
'; } } /** * Date Time Picker 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.3 */ if ( ! function_exists( 'ot_type_date_time_picker' ) ) { function ot_type_date_time_picker( $args = array() ) { /* turns arguments array into variables */ extract( $args ); /* verify a description */ $has_desc = $field_desc ? true : false; /* filter date format */ $date_format = apply_filters( 'ot_type_date_time_picker_date_format', 'yy-mm-dd', $field_id ); /** * Filter the addition of the readonly attribute. * * @since 2.5.0 * * @param bool $is_readonly Whether to add the 'readonly' attribute. Default 'false'. * @param string $field_id The field ID. */ $is_readonly = apply_filters( 'ot_type_date_time_picker_readonly', false, $field_id ); /* format setting outer wrapper */ echo '
'; /* date time picker JS */ echo ''; /* description */ echo $has_desc ? '
' . htmlspecialchars_decode( $field_desc ) . '
' : ''; /* format setting inner wrapper */ echo '
'; /* build date time picker */ echo ''; echo '
'; echo '
'; } } /** * Dimension Option Type * * See @ot_display_by_type to see the full list of available arguments. * * @param array The options arguments * @return string The markup. * * @access public * @since 2.5.0 */ if ( ! function_exists( 'ot_type_dimension' ) ) { function ot_type_dimension( $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_dimension_fields = apply_filters( 'ot_recognized_dimension_fields', array( 'width', 'height', 'unit' ), $field_id ); /* build width dimension */ if ( in_array( 'width', $ot_recognized_dimension_fields ) ) { $width = isset( $field_value['width'] ) ? esc_attr( $field_value['width'] ) : ''; echo '
'; } /* build height dimension */ if ( in_array( 'height', $ot_recognized_dimension_fields ) ) { $height = isset( $field_value['height'] ) ? esc_attr( $field_value['height'] ) : ''; echo '
'; } /* build unit dropdown */ if ( in_array( 'unit', $ot_recognized_dimension_fields ) ) { echo '
'; echo ''; echo '
'; } echo '
'; echo '
'; } } /** * Gallery option type. * * See @ot_display_by_type to see the full list of available arguments. * * @param array The options arguments * @return string The gallery metabox markup. * * @access public * @since 2.2.0 */ if ( ! function_exists( 'ot_type_gallery' ) ) { function ot_type_gallery( $args = array() ) { // Turns arguments array into variables extract( $args ); // Verify a description $has_desc = $field_desc ? true : false; // Format setting outer wrapper echo ''; } } /** * Google Fonts 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.5.0 */ if ( ! function_exists( 'ot_type_google_fonts' ) ) { function ot_type_google_fonts( $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_google_fonts_fields = apply_filters( 'ot_recognized_google_font_fields', array( 'variants', 'subsets' ), $field_id ); // Set a default to show at least one item. if ( ! is_array( $field_value ) || empty( $field_value ) ) { $field_value = array( array( 'family' => '', 'variants' => array(), 'subsets' => array() ) ); } foreach( $field_value as $key => $value ) { echo '
'; /* build font family */ $family = isset( $value['family'] ) ? $value['family'] : ''; echo '
'; echo '' . __( 'Remove Google Font', 'option-tree' ) . ''; echo ''; echo '
'; /* build font variants */ if ( in_array( 'variants', $ot_recognized_google_fonts_fields ) ) { $variants = isset( $value['variants'] ) ? $value['variants'] : array(); echo '
'; foreach ( ot_recognized_google_font_variants( $field_id, $family ) as $variant_key => $variant ) { echo '

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

'; } echo '
'; } /* build font subsets */ if ( in_array( 'subsets', $ot_recognized_google_fonts_fields ) ) { $subsets = isset( $value['subsets'] ) ? $value['subsets'] : array(); echo '
'; foreach ( ot_recognized_google_font_subsets( $field_id, $family ) as $subset_key => $subset ) { echo '

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

'; } echo '
'; } echo '
'; } echo '
'; /* build font family */ echo '
'; echo '' . __( 'Remove Google Font', 'option-tree' ) . ''; echo ''; echo '
'; /* build font variants */ if ( in_array( 'variants', $ot_recognized_google_fonts_fields ) ) { echo '
'; echo '
'; } /* build font subsets */ if ( in_array( 'subsets', $ot_recognized_google_fonts_fields ) ) { echo '
'; echo '
'; } echo '
'; echo '' . __( 'Add Google Font', 'option-tree' ) . ''; echo '
'; echo '
'; } } /** * JavaScript 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.5.0 */ if ( ! function_exists( 'ot_type_javascript' ) ) { function ot_type_javascript( $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 ''; /* build pre to convert it into ace editor later */ echo '
' . esc_textarea( $field_value ) . '
'; echo '
'; echo '
'; } } /** * Link Color option type. * * See @ot_display_by_type to see the full list of available arguments. * * @param array The options arguments * @return string The markup. * * @access public * @since 2.5.0 */ if ( ! function_exists( 'ot_type_link_color' ) ) { function ot_type_link_color( $args = array() ) { /* turns arguments array into variables */ extract( $args ); /* verify a description */ $has_desc = $field_desc ? true : false; /* format setting outer wrapper */ 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 metabox 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 '
'; } } /** * On/Off option type * * See @ot_display_by_type to see the full list of available arguments. * * @param array The options arguments * @return string The gallery metabox markup. * * @access public * @since 2.2.0 */ if ( ! function_exists( 'ot_type_on_off' ) ) { function ot_type_on_off( $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 '
'; /* Force only two choices, and allowing filtering on the choices value & label */ $field_choices = array( array( /** * Filter the value of the On button. * * @since 2.5.0 * * @param string The On button value. Default 'on'. * @param string $field_id The field ID. * @param string $filter_id For filtering both on/off value with one function. */ 'value' => apply_filters( 'ot_on_off_switch_on_value', 'on', $field_id, 'on' ), /** * Filter the label of the On button. * * @since 2.5.0 * * @param string The On button label. Default 'On'. * @param string $field_id The field ID. * @param string $filter_id For filtering both on/off label with one function. */ 'label' => apply_filters( 'ot_on_off_switch_on_label', __( 'On', 'option-tree' ), $field_id, 'on' ) ), array( /** * Filter the value of the Off button. * * @since 2.5.0 * * @param string The Off button value. Default 'off'. * @param string $field_id The field ID. * @param string $filter_id For filtering both on/off value with one function. */ 'value' => apply_filters( 'ot_on_off_switch_off_value', 'off', $field_id, 'off' ), /** * Filter the label of the Off button. * * @since 2.5.0 * * @param string The Off button label. Default 'Off'. * @param string $field_id The field ID. * @param string $filter_id For filtering both on/off label with one function. */ 'label' => apply_filters( 'ot_on_off_switch_off_label', __( 'Off', 'option-tree' ), $field_id, 'off' ) ) ); /** * Filter the width of the On/Off switch. * * @since 2.5.0 * * @param string The switch width. Default '100px'. * @param string $field_id The field ID. */ $switch_width = apply_filters( 'ot_on_off_switch_width', '100px', $field_id ); echo '
'; /* build radio */ foreach ( (array) $field_choices as $key => $choice ) { 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 ) { $post_title = '' != $my_post->post_title ? $my_post->post_title : 'Untitled'; 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 '
'; } } /** * 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 ) { $post_title = '' != $my_post->post_title ? $my_post->post_title : 'Untitled'; 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 ); /* make radio image source filterable */ $src = apply_filters( 'ot_type_radio_image_src', $src, $field_id ); 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 ) . '
' : ''; /* filter choices array */ $field_choices = apply_filters( 'ot_type_select_choices', $field_choices, $field_id ); /* 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 '
'; } } /** * 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 metabox 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 '
'; } } /** * Social Links 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.4.0 */ if ( ! function_exists( 'ot_type_social_links' ) ) { function ot_type_social_links( $args = array() ) { /* turns arguments array into variables */ extract( $args ); /* Load the default social links */ if ( empty( $field_value ) && apply_filters( 'ot_type_social_links_load_defaults', true, $field_id ) ) { $field_value = apply_filters( 'ot_type_social_links_defaults', array( array( 'name' => __( 'Facebook', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'Twitter', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'Google+', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'LinkedIn', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'Pinterest', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'Youtube', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'Dribbble', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'Github', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'Forrst', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'Digg', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'Delicious', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'Tumblr', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'Skype', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'SoundCloud', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'Vimeo', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'Flickr', 'option-tree' ), 'title' => '', 'href' => '' ), array( 'name' => __( 'VK.com', 'option-tree' ), 'title' => '', 'href' => '' ) ), $field_id ); } /* 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 metabox settings. */ if ( ! isset( $get_option ) ) $get_option = ''; /* build list items */ echo ''; /* button */ echo '' . __( 'Add New', 'option-tree' ) . ''; /* description */ echo '
' . apply_filters( 'ot_social_links_description', __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ), $field_id ) . '
'; echo '
'; echo '
'; } } /** * Spacing 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.5.0 */ if ( ! function_exists( 'ot_type_spacing' ) ) { function ot_type_spacing( $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_spacing_fields = apply_filters( 'ot_recognized_spacing_fields', array( 'top', 'right', 'bottom', 'left', 'unit' ), $field_id ); /* build top spacing */ if ( in_array( 'top', $ot_recognized_spacing_fields ) ) { $top = isset( $field_value['top'] ) ? esc_attr( $field_value['top'] ) : ''; echo '
'; } /* build right spacing */ if ( in_array( 'right', $ot_recognized_spacing_fields ) ) { $right = isset( $field_value['right'] ) ? esc_attr( $field_value['right'] ) : ''; echo '
'; } /* build bottom spacing */ if ( in_array( 'bottom', $ot_recognized_spacing_fields ) ) { $bottom = isset( $field_value['bottom'] ) ? esc_attr( $field_value['bottom'] ) : ''; echo '
'; } /* build left spacing */ if ( in_array( 'left', $ot_recognized_spacing_fields ) ) { $left = isset( $field_value['left'] ) ? esc_attr( $field_value['left'] ) : ''; echo '
'; } /* build unit dropdown */ if ( in_array( 'unit', $ot_recognized_spacing_fields ) ) { echo '
'; echo ''; echo '
'; } echo '
'; echo '
'; } } /** * Tab 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.3.0 */ if ( ! function_exists( 'ot_type_tab' ) ) { function ot_type_tab( $args = array() ) { /* turns arguments array into variables */ extract( $args ); /* format setting outer wrapper */ 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( apply_filters( 'ot_type_taxonomy_checkbox_query', array( 'hide_empty' => false, 'taxonomy' => $taxonomy ), $field_id ) ); /* 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 font color */ if ( in_array( 'font-color', $ot_recognized_typography_fields ) ) { /* build colorpicker */ echo '
'; /* colorpicker JS */ echo ''; /* set background color */ $background_color = isset( $field_value['font-color'] ) ? esc_attr( $field_value['font-color'] ) : ''; /* input */ 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; /* If an attachment ID is stored here fetch its URL and replace the value */ if ( $field_value && wp_attachment_is_image( $field_value ) ) { $attachment_data = wp_get_attachment_image_src( $field_value, 'original' ); /* check for attachment data */ if ( $attachment_data ) { $field_src = $attachment_data[0]; } } /* 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 '
'; /* replace image src */ if ( isset( $field_src ) ) $field_value = $field_src; 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 */