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 '<div class="format-setting type-radio-image ' . ($has_desc ? 'has-desc' : 'no-desc') . '">'; /* description */ echo $has_desc ? '<div class="description">' . htmlspecialchars_decode($field_desc) . '</div>' : ''; /* format setting inner wrapper */ echo '<div class="format-setting-inner">'; /** * 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); /** * Filter the image attributes. * * @since 2.5.3 * * @param string $attributes The image attributes. * @param string $field_id The field ID. * @param array $choice The choice. */ $attributes = apply_filters('ot_type_radio_image_attributes', '', $field_id, $choice); echo '<div class="option-tree-ui-radio-images">'; echo '<p style="display:none"><input type="radio" name="' . esc_attr($field_name) . '" id="' . esc_attr($field_id) . '-' . esc_attr($key) . '" value="' . esc_attr($choice['value']) . '"' . checked($field_value, $choice['value'], false) . ' class="option-tree-ui-radio option-tree-ui-images" /><label for="' . esc_attr($field_id) . '-' . esc_attr($key) . '">' . esc_attr($choice['label']) . '</label></p>'; echo '<img ' . $attributes . ' src="' . esc_url($src) . '" alt="' . esc_attr($choice['label']) . '" title="' . esc_attr($choice['label']) . '" class="option-tree-ui-radio-image ' . esc_attr($field_class) . ($field_value == $choice['value'] ? ' option-tree-ui-radio-image-selected' : '') . '" />'; echo '</div>'; } echo '</div>'; echo '</div>'; }
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 '<div class="format-setting type-radio-image ' . ($has_desc ? 'has-desc' : 'no-desc') . '">'; /* description */ echo $has_desc ? '<div class="description">' . htmlspecialchars_decode($field_desc) . '</div>' : ''; /* format setting inner wrapper */ echo '<div class="format-setting-inner">'; /** * load the default filterable images if nothing * has been set in the choices array. */ if (empty($field_choices)) { $field_choices = ot_radio_images($field_id); } /* build radio image */ foreach ((array) $field_choices as $key => $choice) { echo '<div class="option-tree-ui-radio-images">'; echo '<p style="display:none"><input type="radio" name="' . esc_attr($field_name) . '" id="' . esc_attr($field_id) . '-' . esc_attr($key) . '" value="' . esc_attr($choice['value']) . '"' . checked($field_value, $choice['value'], false) . ' class="option-tree-ui-radio option-tree-ui-images" /><label for="' . esc_attr($field_id) . '-' . esc_attr($key) . '">' . esc_attr($choice['label']) . '</label></p>'; echo '<img src="' . esc_url($choice['src']) . '" alt="' . esc_attr($choice['label']) . '" title="' . esc_attr($choice['label']) . '" class="option-tree-ui-radio-image ' . esc_attr($field_class) . ($field_value == $choice['value'] ? ' option-tree-ui-radio-image-selected' : '') . '" />'; echo '</div>'; } echo '</div>'; echo '</div>'; }
function ot_type_radio_image($args = array()) { /* turns arguments array into variables */ extract($args); /* format setting outer wrapper */ echo '<div class="format-setting type-radio-image">'; /* format setting inner wrapper */ echo '<div class="format-setting-inner">'; /** * 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 '<div class="option-tree-ui-radio-images">'; echo '<p style="display:none"><input type="radio" name="' . esc_attr($field_name) . '" id="' . esc_attr($field_id) . '-' . esc_attr($key) . '" value="' . esc_attr($choice['value']) . '"' . checked($field_value, $choice['value'], false) . ' class="option-tree-ui-radio option-tree-ui-images" /><label for="' . esc_attr($field_id) . '-' . esc_attr($key) . '">' . esc_attr($choice['label']) . '</label></p>'; echo '<img src="' . esc_url($src) . '" alt="' . esc_attr($choice['label']) . '" title="' . esc_attr($choice['label']) . '" class="option-tree-ui-radio-image ' . esc_attr($field_class) . ($field_value == $choice['value'] ? ' option-tree-ui-radio-image-selected' : '') . '" />'; echo '</div>'; } echo '</div>'; echo '</div>'; }