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


Generates Image Radio @param array $args Field settings
function themify_meta_field_image_radio( $args ) {
	$meta_box = $args['meta_box'];
	$meta_value = $args['meta_value'];
	extract( $args, EXTR_OVERWRITE );
	$html = '';
	foreach ( $meta_box['meta'] as $option ) {
		if ( ( '' == $meta_value || ! $meta_value || ! isset( $meta_value ) ) && ( isset( $option['selected'] ) && $option['selected'] ) ) {
			$meta_value = $option['value'];
		}
		if ( $meta_value == $option['value'] ) {
			$class = 'selected';
		} else {
			$class = '';
		}
		if(isset($meta_box['show_title'])){
			$title = isset( $option['title'] )? $option['title']: ucwords( str_replace( '-', ' ', $option['value'] ) );
		} else {
			$title = '';
		}
		$img_src = ( '' != parse_url( $option['img'], PHP_URL_SCHEME) ) ? $option['img'] : get_template_directory_uri() . '/' . $option['img'];
		$rid = $meta_box['name'] . '-' . esc_attr( $option['value'] );
		$html .= sprintf('
		<div class="tm-radio-option">
			<input type="radio" name="%s" id="%s" value="%s" %s />
			<label for="%s"><img src="%s" alt="%s"/></label>
			<span class="tm-option-title">%s</span>
		</div>
		',
			$meta_box['name'], $rid, $option['value'], checked( $meta_value, $option['value'], false ),
			$rid,
			$img_src, $title, $title
		);
	}
	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_image_radio ( $ args ) { $ meta_box = $ args [ 'meta_box' ] ; $ meta_value = $ args [ 'meta_value' ] ; extract ( $ args , EXTR_OVERWRITE ) ; $ html = '' ; foreach ( $ meta_box [ 'meta' ] as $ option ) { if ( ( '' == $ meta_value || ! $ meta_value || ! isset ( $ meta_value ) ) && ( isset ( $ option [ 'selected' ] ) && $ option [ 'selected' ] ) ) { $ meta_value = $ option [ 'value' ] ; } if ( $ meta_value == $ option [ 'value' ] ) { $ class = 'selected' ; } else { $ class = '' ; } if ( isset ( $ meta_box [ 'show_title' ] ) ) { $ title = isset ( $ option [ 'title' ] ) ? $ option [ 'title' ] : ucwords ( str_replace ( '-' , ' ' , $ option [ 'value' ] ) ) ; } else { $ title = '' ; } $ img_src = ( '' != parse_url ( $ option [ 'img' ] , PHP_URL_SCHEME ) ) ? $ option [ 'img' ] : get_template_directory_uri ( ) . '/' . $ option [ 'img' ] ; $ rid = $ meta_box [ 'name' ] . '-' . esc_attr ( $ option [ 'value' ] ) ; $ html .= sprintf ( '
		<div class="tm-radio-option">
			<input type="radio" name="%s" id="%s" value="%s" %s />
			<label for="%s"><img src="%s" alt="%s"/></label>
			<span class="tm-option-title">%s</span>
		</div>
		' , $ meta_box [ 'name' ] , $ rid , $ option [ 'value' ] , checked ( $ meta_value , $ option [ 'value' ] , false ) , $ rid , $ img_src , $ title , $ title ) ; } 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 Image Radio
 @param array $args Field settings
Generates Image Radio @param array $args Field settings
// Check image src whether absolute url or relative url