wordpress/wp-content/themes/basic/themify/themify-metabox/includes/themify-field-types.php
/**
 * Generates layout field
 *
 * @param array $args Field settings
 *
 * @since 1.3.2
 * @return string
 */
Generates layout field
@param array $args Field settings


Generates layout field @param array $args Field settings
function themify_meta_field_layout( $args ) {
	$meta_box = $args['meta_box'];
	$meta_value = $args['meta_value'];
	extract( $args, EXTR_OVERWRITE );
	$ops_html = '';
	foreach ( $meta_box['meta'] as $options ) {
		if ( ( '' == $meta_value || !$meta_value || !isset($meta_value)) && ( isset( $options['selected'] ) && $options['selected'] ) ) {
			$meta_value = $options['value'];
		}
		if ( $meta_value == $options['value'] ) {
			$class = 'selected';
		} else {
			$class = '';
		}
		if(isset($meta_box['show_title'])){
			$title = isset($options['title'])? $options['title']: ucwords(str_replace('-', ' ', $options['value']));
		} else {
			$title = '';
		}
		$img_src = ( '' != parse_url( $options['img'], PHP_URL_SCHEME) ) ? $options['img'] : get_template_directory_uri() . '/' . $options['img'];
		$ops_html .= sprintf('<a href="#" class="preview-icon %s"><img src="%s" alt="%s" %s /><span class="tm-option-title">%s</span></a>',
			$class, esc_url( $img_src ), esc_attr( $options['value'] ),
			isset($meta_box['size'])? 'width="'.esc_attr( $meta_box['size'][0] ).'" height="'.esc_attr( $meta_box['size'][1] ).'"': '',
			$title
		);
	}
	$html = sprintf('%s<input type="hidden" name="%s" value="%s" class="val" />',
		$ops_html, esc_attr( $meta_box['name'] ), esc_attr( $meta_value ));
	if(isset($meta_box['label']) && '' != $meta_box['label'])
		$html = sprintf('<label for="%s">%s %s</label>', esc_attr( $meta_box['name'] ), $html, esc_attr( $meta_box['label'] ));
	$html .= isset( $meta_box['description'] )? themify_meta_field_get_description($meta_box['description']) : '';
	if( isset( $meta_box['before'] ) ) $html = $meta_box['before'] . $html;
	if( isset( $meta_box['after'] ) )  $html .= $meta_box['after'];
	echo $html;
}
function themify_meta_field_layout ( $ args ) { $ meta_box = $ args [ 'meta_box' ] ; $ meta_value = $ args [ 'meta_value' ] ; extract ( $ args , EXTR_OVERWRITE ) ; $ ops_html = '' ; foreach ( $ meta_box [ 'meta' ] as $ options ) { if ( ( '' == $ meta_value || ! $ meta_value || ! isset ( $ meta_value ) ) && ( isset ( $ options [ 'selected' ] ) && $ options [ 'selected' ] ) ) { $ meta_value = $ options [ 'value' ] ; } if ( $ meta_value == $ options [ 'value' ] ) { $ class = 'selected' ; } else { $ class = '' ; } if ( isset ( $ meta_box [ 'show_title' ] ) ) { $ title = isset ( $ options [ 'title' ] ) ? $ options [ 'title' ] : ucwords ( str_replace ( '-' , ' ' , $ options [ 'value' ] ) ) ; } else { $ title = '' ; } $ img_src = ( '' != parse_url ( $ options [ 'img' ] , PHP_URL_SCHEME ) ) ? $ options [ 'img' ] : get_template_directory_uri ( ) . '/' . $ options [ 'img' ] ; $ ops_html .= sprintf ( '<a href="#" class="preview-icon %s"><img src="%s" alt="%s" %s /><span class="tm-option-title">%s</span></a>' , $ class , esc_url ( $ img_src ) , esc_attr ( $ options [ 'value' ] ) , isset ( $ meta_box [ 'size' ] ) ? 'width="' . esc_attr ( $ meta_box [ 'size' ] [ 0 ] ) . '" height="' . esc_attr ( $ meta_box [ 'size' ] [ 1 ] ) . '"' : '' , $ title ) ; } $ html = sprintf ( '%s<input type="hidden" name="%s" value="%s" class="val" />' , $ ops_html , esc_attr ( $ meta_box [ 'name' ] ) , esc_attr ( $ meta_value ) ) ; if ( isset ( $ meta_box [ 'label' ] ) && '' != $ meta_box [ 'label' ] ) $ html = sprintf ( '<label for="%s">%s %s</label>' , esc_attr ( $ meta_box [ 'name' ] ) , $ html , esc_attr ( $ meta_box [ 'label' ] ) ) ; $ html .= isset ( $ meta_box [ 'description' ] ) ? themify_meta_field_get_description ( $ meta_box [ 'description' ] ) : '' ; if ( isset ( $ meta_box [ 'before' ] ) ) $ html = $ meta_box [ 'before' ] . $ html ; if ( isset ( $ meta_box [ 'after' ] ) ) $ html .= $ meta_box [ 'after' ] ; echo $ html ; }
Generates layout field
 @param array $args Field settings
Generates layout field @param array $args Field settings
// Check image src whether absolute url or relative url