function themerex_options_show_field($field, $value = null) { global $THEMEREX_flags, $themerex_options_delimiter, $themerex_options_data; // Set start field value if ($value !== null) { $field['val'] = $value; } if (!isset($field['val']) || $field['val'] == '') { $field['val'] = 'inherit'; } if (!empty($field['subset'])) { $sbs = get_theme_option($field['subset'], '', $themerex_options_data); $field['val'] = isset($field['val'][$sbs]) ? $field['val'][$sbs] : ''; } if (empty($field['id'])) { $field['id'] = 'themerex_options_id_' . str_replace('.', '', mt_rand()); } if (!isset($field['title'])) { $field['title'] = ''; } // Divider after field $divider = !isset($field['divider']) || $field['divider'] ? ' themerex_options_divider' : ''; $padding = ''; if (array_key_exists('padding', $field)) { $padding = $field['padding'] == true ? ' themerex_options_padding' : ''; } // Setup default parameters if ($field['type'] == 'media') { if (!isset($field['before'])) { $field['before'] = array('title' => __('Choose image', 'themerex'), 'action' => 'media_upload', 'type' => 'image', 'multiple' => false, 'linked_field' => '', 'captions' => array('choose' => __('Choose image', 'themerex'), 'update' => __('Select image', 'themerex'))); } if (!isset($field['after'])) { $field['after'] = array('icon' => 'iconadmin-cancel', 'action' => 'media_reset'); } } // Buttons before and after field $before = $after = $buttons_classes = ''; if (!empty($field['before'])) { list($before, $class) = themerex_options_action_button($field['before'], 'before'); $buttons_classes .= $class; } if (!empty($field['after'])) { list($after, $class) = themerex_options_action_button($field['after'], 'after'); $buttons_classes .= $class; } if (in_array($field['type'], array('list', 'select', 'fonts')) || $field['type'] == 'socials' && (empty($field['style']) || $field['style'] == 'icons')) { $buttons_classes .= ' themerex_options_button_after_small'; } // Is it inherit field? $inherit = is_inherit_option($field['val']) ? 'inherit' : ''; // Is it cloneable field? $cloneable = isset($field['cloneable']) && $field['cloneable']; // Prepare field if (!$cloneable) { $field['val'] = array($field['val']); } else { if (!is_array($field['val'])) { $field['val'] = array($field['val']); } else { if ($field['type'] == 'socials' && (!isset($field['val'][0]) || !is_array($field['val'][0]))) { $field['val'] = array($field['val']); } } } // Field container if (themerex_options_is_group($field['type'])) { // Close nested containers if (empty($field['start']) && (!in_array($field['type'], array('group', 'toggle')) || !empty($field['end']))) { echo themerex_options_close_nested_groups($field['type'], !empty($field['end'])); if (!empty($field['end'])) { return; } } } else { // Start field layout if ($field['type'] != 'hidden') { echo '<div class="themerex_options_field' . ' themerex_options_field_' . (in_array($field['type'], array('list', 'fonts')) ? 'select' : $field['type']) . (in_array($field['type'], array('media', 'fonts', 'list', 'select', 'socials', 'date', 'time')) ? ' themerex_options_field_text' : '') . ($field['type'] == 'socials' && !empty($field['style']) && $field['style'] == 'images' ? ' themerex_options_field_images' : '') . ($field['type'] == 'socials' && (empty($field['style']) || $field['style'] == 'icons') ? ' themerex_options_field_icons' : '') . (isset($field['dir']) && $field['dir'] == 'vertical' ? ' themerex_options_vertical' : '') . (!empty($field['multiple']) ? ' themerex_options_multiple' : '') . (isset($field['size']) ? ' themerex_options_size_' . $field['size'] : '') . (isset($field['class']) ? ' ' . $field['class'] : '') . $divider . $padding . '">' . "\n"; echo '<label class="themerex_options_field_label' . (!empty($THEMEREX_flags['add_inherit']) && isset($field['std']) ? ' themerex_options_field_label_inherit' : '') . '" for="' . $field['id'] . '">' . $field['title'] . (!empty($THEMEREX_flags['add_inherit']) && isset($field['std']) ? '<span id="' . $field['id'] . '_inherit" class="themerex_options_button_inherit' . ($inherit ? '' : ' themerex_options_inherit_off') . '" title="' . __('Unlock this field', 'themerex') . '"></span>' : '') . '</label>' . "\n"; echo '<div class="themerex_options_field_content' . $buttons_classes . ($cloneable ? ' themerex_options_cloneable_area' : '') . '">' . "\n"; } } // Parse field type foreach ($field['val'] as $clone_num => $clone_val) { if ($cloneable) { echo '<div class="themerex_options_cloneable_item">' . '<span class="themerex_options_input_button themerex_options_clone_button themerex_options_clone_button_del">-</span>'; } switch ($field['type']) { case 'group': echo '<fieldset id="' . $field['id'] . '" class="themerex_options_container themerex_options_group themerex_options_content' . $divider . $padding . '">'; if (!empty($field['title'])) { echo '<legend>' . (!empty($field['icon']) ? '<span class="' . $field['icon'] . '"></span>' : '') . $field['title'] . '</legend>' . "\n"; } array_push($THEMEREX_flags['nesting'], 'group'); break; case 'toggle': array_push($THEMEREX_flags['nesting'], 'toggle'); echo '<div id="' . $field['id'] . '" class="themerex_options_container themerex_options_toggle' . $divider . $padding . '">'; echo '<h3 id="' . $field['id'] . '_title"' . ' class="themerex_options_toggle_header' . (empty($field['closed']) ? ' ui-state-active' : '') . '"' . (!empty($field['action']) ? ' onclick="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . '>' . (!empty($field['icon']) ? '<span class="themerex_options_toggle_header_icon ' . $field['icon'] . '"></span>' : '') . $field['title'] . '<span class="themerex_options_toggle_header_marker iconadmin-left-open"></span>' . '</h3>' . '<div class="themerex_options_content themerex_options_toggle_content"' . (!empty($field['closed']) ? ' style="display:none;"' : '') . '>'; break; case 'accordion': array_push($THEMEREX_flags['nesting'], 'accordion'); if (!empty($field['start'])) { echo '<div id="' . $field['start'] . '" class="themerex_options_container themerex_options_accordion' . $divider . $padding . '">'; } echo '<div id="' . $field['id'] . '" class="themerex_options_accordion_item">' . '<h3 id="' . $field['id'] . '_title"' . ' class="themerex_options_accordion_header"' . (!empty($field['action']) ? ' onclick="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . '>' . (!empty($field['icon']) ? '<span class="themerex_options_accordion_header_icon ' . $field['icon'] . '"></span>' : '') . $field['title'] . '<span class="themerex_options_accordion_header_marker iconadmin-left-open"></span>' . '</h3>' . '<div id="' . $field['id'] . '_content" class="themerex_options_content themerex_options_accordion_content">'; break; case 'tab': array_push($THEMEREX_flags['nesting'], 'tab'); if (!empty($field['start'])) { echo '<div id="' . $field['start'] . '" class="themerex_options_container themerex_options_tab' . $divider . $padding . '">' . '<ul>' . themerex_options_collect_tabs($field['type'], $field['start']) . '</ul>'; } echo '<div id="' . $field['id'] . '_content" class="themerex_options_content themerex_options_tab_content">'; break; case 'partition': array_push($THEMEREX_flags['nesting'], 'partition'); if (!empty($field['start'])) { echo '<div id="' . $field['start'] . '" class="themerex_options_container themerex_options_partition' . $divider . $padding . '">' . '<ul>' . themerex_options_collect_tabs($field['type'], $field['start']) . '</ul>'; } echo '<div id="' . $field['id'] . '_content" class="themerex_options_content themerex_options_partition_content">'; break; case 'hidden': echo '<input class="themerex_options_input themerex_options_input_hidden" name="' . $field['id'] . '" id="' . $field['id'] . '" type="hidden" value="' . htmlspecialchars(is_inherit_option($clone_val) ? '' : $clone_val) . '" />'; break; case 'date': if (isset($field['style']) && $field['style'] == 'inline') { echo '<div class="themerex_options_input_date" id="' . $field['id'] . '_calendar"' . ' data-format="' . (!empty($field['format']) ? $field['format'] : 'yy-mm-dd') . '"' . ' data-months="' . (!empty($field['months']) ? max(1, min(3, $field['months'])) : 1) . '"' . ' data-linked-field="' . (!empty($data['linked_field']) ? $data['linked_field'] : $field['id']) . '"' . '></div>' . '<input id="' . $field['id'] . '"' . ' name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' type="hidden"' . ' value="' . htmlspecialchars(is_inherit_option($clone_val) ? '' : $clone_val) . '"' . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />'; } else { echo '<input class="themerex_options_input themerex_options_input_date' . (!empty($field['mask']) ? ' themerex_options_input_masked' : '') . '"' . ' name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' id="' . $field['id'] . '"' . ' type="text"' . ' value="' . htmlspecialchars(is_inherit_option($clone_val) ? '' : $clone_val) . '"' . ' data-format="' . (!empty($field['format']) ? $field['format'] : 'yy-mm-dd') . '"' . ' data-months="' . (!empty($field['months']) ? max(1, min(3, $field['months'])) : 1) . '"' . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />' . $before . $after; } break; case 'text': echo '<input class="themerex_options_input themerex_options_input_text' . (!empty($field['mask']) ? ' themerex_options_input_masked' : '') . '"' . ' name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' id="' . $field['id'] . '"' . ' type="text"' . ' value="' . htmlspecialchars(is_inherit_option($clone_val) ? '' : $clone_val) . '"' . (!empty($field['mask']) ? ' data-mask="' . $field['mask'] . '"' : '') . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />' . $before . $after; break; case 'textarea': $cols = isset($field['cols']) && $field['cols'] > 10 ? $field['cols'] : '40'; $rows = isset($field['rows']) && $field['rows'] > 1 ? $field['rows'] : '8'; echo '<textarea class="themerex_options_input themerex_options_input_textarea"' . ' name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' id="' . $field['id'] . '"' . ' cols="' . $cols . '"' . ' rows="' . $rows . '"' . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . '>' . htmlspecialchars(is_inherit_option($clone_val) ? '' : $clone_val) . '</textarea>'; break; case 'editor': $cols = isset($field['cols']) && $field['cols'] > 10 ? $field['cols'] : '40'; $rows = isset($field['rows']) && $field['rows'] > 1 ? $field['rows'] : '10'; wp_editor(is_inherit_option($clone_val) ? '' : $clone_val, $field['id'] . ($cloneable ? '[]' : ''), array('wpautop' => false, 'textarea_rows' => $rows)); break; case 'spinner': echo '<input class="themerex_options_input themerex_options_input_spinner' . (!empty($field['mask']) ? ' themerex_options_input_masked' : '') . '" name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' id="' . $field['id'] . '"' . ' type="text"' . ' value="' . htmlspecialchars(is_inherit_option($clone_val) ? '' : $clone_val) . '"' . (!empty($field['mask']) ? ' data-mask="' . $field['mask'] . '"' : '') . (isset($field['min']) ? ' data-min="' . $field['min'] . '"' : '') . (isset($field['max']) ? ' data-max="' . $field['max'] . '"' : '') . (!empty($field['increment']) ? ' data-increment="' . $field['increment'] . '"' : '') . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />' . '<span class="themerex_options_arrows"><span class="themerex_options_arrow_up iconadmin-up-dir"></span><span class="themerex_options_arrow_down iconadmin-down-dir"></span></span>'; break; case 'tags': if (!is_inherit_option($clone_val)) { $tags = explode($themerex_options_delimiter, $clone_val); if (count($tags) > 0) { foreach ($tags as $tag) { if (empty($tag)) { continue; } echo '<span class="themerex_options_tag iconadmin-cancel">' . $tag . '</span>'; } } } echo '<input class="themerex_options_input_tags"' . ' type="text"' . ' value=""' . ' />' . '<input name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' type="hidden"' . ' value="' . htmlspecialchars(is_inherit_option($clone_val) ? '' : $clone_val) . '"' . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />'; break; case "checkbox": echo '<input type="checkbox" class="themerex_options_input themerex_options_input_checkbox"' . ' name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' id="' . $field['id'] . '"' . ' value="true"' . ($clone_val == 'true' ? ' checked="checked"' : '') . (!empty($field['disabled']) ? ' readonly="readonly"' : '') . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />' . '<label for="' . $field['id'] . '" class="' . (!empty($field['disabled']) ? 'themerex_options_state_disabled' : '') . ($clone_val == 'true' ? ' themerex_options_state_checked' : '') . '"><span class="themerex_options_input_checkbox_image iconadmin-check"></span>' . (!empty($field['label']) ? $field['label'] : $field['title']) . '</label>'; break; case "radio": foreach ($field['options'] as $key => $title) { echo '<span class="themerex_options_radioitem">' . '<input class="themerex_options_input themerex_options_input_radio" type="radio"' . ' name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' value="' . $key . '"' . ($clone_val == $key ? ' checked="checked"' : '') . ' id="' . $field['id'] . '_' . $key . '"' . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />' . '<label for="' . $field['id'] . '_' . $key . '"' . ($clone_val == $key ? ' class="themerex_options_state_checked"' : '') . '><span class="themerex_options_input_radio_image iconadmin-circle-empty' . ($clone_val == $key ? ' iconadmin-dot-circled' : '') . '"></span>' . $title . '</label></span>'; } break; case "switch": $opt = array(); foreach ($field['options'] as $key => $title) { $opt[] = array('key' => $key, 'title' => $title); if (count($opt) == 2) { break; } } echo '<input name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' type="hidden"' . ' value="' . htmlspecialchars(is_inherit_option($clone_val) || empty($clone_val) ? $opt[0]['key'] : $clone_val) . '"' . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />' . '<span class="themerex_options_switch' . ($clone_val == $opt[1]['key'] ? ' themerex_options_state_off' : '') . '"><span class="themerex_options_switch_inner iconadmin-circle"><span class="themerex_options_switch_val1" data-value="' . $opt[0]['key'] . '">' . $opt[0]['title'] . '</span><span class="themerex_options_switch_val2" data-value="' . $opt[1]['key'] . '">' . $opt[1]['title'] . '</span></span></span>'; break; case 'media': echo '<input class="themerex_options_input themerex_options_input_text themerex_options_input_media"' . ' name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' id="' . $field['id'] . '"' . ' type="text"' . ' value="' . htmlspecialchars(is_inherit_option($clone_val) ? '' : $clone_val) . '"' . (!isset($field['readonly']) || $field['readonly'] ? ' readonly="readonly"' : '') . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />' . $before . $after; if (!empty($clone_val) && !is_inherit_option($clone_val)) { $info = pathinfo($clone_val); echo '<a class="themerex_options_image_preview" target="_blank" href="' . $clone_val . '">' . (themerex_strpos('jpg,png,gif', $info['extension']) !== false ? '<img src="' . $clone_val . '" alt="" />' : '<span>' . $info['basename'] . '</span>') . '</a>'; } break; case 'button': list($button, $class) = themerex_options_action_button($field, 'button'); echo $button; break; case 'range': echo '<div class="themerex_options_input_range" data-step="' . (!empty($field['step']) ? $field['step'] : 1) . '">'; echo '<span class="themerex_options_range_scale"><span class="themerex_options_range_scale_filled"></span></span>'; if (themerex_strpos($clone_val, $themerex_options_delimiter) === false) { $clone_val = max($field['min'], intval($clone_val)); } if (themerex_strpos($field['std'], $themerex_options_delimiter) !== false && themerex_strpos($clone_val, $themerex_options_delimiter) === false) { $clone_val = $field['min'] . ',' . $clone_val; } $sliders = explode($themerex_options_delimiter, $clone_val); foreach ($sliders as $s) { echo '<span class="themerex_options_range_slider"><span class="themerex_options_range_slider_value">' . intval($s) . '</span><span class="themerex_options_range_slider_button"></span></span>'; } echo '<span class="themerex_options_range_min">' . $field['min'] . '</span><span class="themerex_options_range_max">' . $field['max'] . '</span>'; echo '<input name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' type="hidden"' . ' value="' . htmlspecialchars(is_inherit_option($clone_val) ? '' : $clone_val) . '"' . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />'; echo '</div>'; break; case "checklist": foreach ($field['options'] as $key => $title) { echo '<span class="themerex_options_listitem' . (themerex_strpos($themerex_options_delimiter . $clone_val . $themerex_options_delimiter, $themerex_options_delimiter . $key . $themerex_options_delimiter) !== false ? ' themerex_options_state_checked' : '') . '"' . ' data-value="' . $key . '"' . '>' . htmlspecialchars($title) . '</span>'; } echo '<input name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' type="hidden"' . ' value="' . htmlspecialchars(is_inherit_option($clone_val) ? '' : $clone_val) . '"' . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />'; break; case 'fonts': foreach ($field['options'] as $key => $title) { $field['options'][$key] = $key; } case 'list': case 'select': if (!isset($field['options']) && !empty($field['from']) && !empty($field['to'])) { $field['options'] = array(); for ($i = $field['from']; $i <= $field['to']; $i += !empty($field['step']) ? $field['step'] : 1) { $field['options'][$i] = $i; } } list($list, $caption) = themerex_options_menu_list($field, $clone_val); if (empty($field['style']) || $field['style'] == 'select') { echo '<input class="themerex_options_input themerex_options_input_select" type="text" value="' . $caption . '"' . ' readonly="readonly"' . ' />' . $before . '<span class="themerex_options_field_after themerex_options_with_action iconadmin-down-open" onclick="themerex_options_action_show_menu(this);return false;"></span>'; } echo $list; echo '<input name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' type="hidden"' . ' value="' . htmlspecialchars(is_inherit_option($clone_val) ? '' : $clone_val) . '"' . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />'; break; case 'images': list($list, $caption) = themerex_options_menu_list($field, $clone_val); if (empty($field['style']) || $field['style'] == 'select') { echo '<div class="themerex_options_caption_image iconadmin-down-open">' . '<span style="background-image: url(' . $caption . ')"></span>' . '</div>'; } echo $list; echo '<input name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' type="hidden"' . ' value="' . htmlspecialchars(is_inherit_option($clone_val) ? '' : $clone_val) . '"' . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />'; break; case 'icons': if (isset($field['css']) && $field['css'] != '' && file_exists($field['css'])) { $field['options'] = parseIconsClasses($field['css']); } list($list, $caption) = themerex_options_menu_list($field, $clone_val); if (empty($field['style']) || $field['style'] == 'select') { echo '<div class="themerex_options_caption_icon iconadmin-down-open"><span class="' . $caption . '"></span></div>'; } echo $list; echo '<input name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' type="hidden"' . ' value="' . htmlspecialchars(is_inherit_option($clone_val) ? '' : $clone_val) . '"' . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />'; break; case 'socials': if (!is_array($clone_val)) { $clone_val = array('url' => '', 'icon' => ''); } list($list, $caption) = themerex_options_menu_list($field, $clone_val); if (empty($field['style']) || $field['style'] == 'icons') { list($after, $class) = themerex_options_action_button(array('action' => empty($field['style']) || $field['style'] == 'icons' ? 'select_icon' : '', 'icon' => (empty($field['style']) || $field['style'] == 'icons') && !empty($clone_val['icon']) ? $clone_val['icon'] : 'iconadmin-users-1'), 'after'); } else { $after = ''; } echo '<input class="themerex_options_input themerex_options_input_text themerex_options_input_socials' . (!empty($field['mask']) ? ' themerex_options_input_masked' : '') . '"' . ' name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' id="' . $field['id'] . '"' . ' type="text" value="' . htmlspecialchars(is_inherit_option($clone_val['url']) ? '' : $clone_val['url']) . '"' . (!empty($field['mask']) ? ' data-mask="' . $field['mask'] . '"' : '') . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />' . $after; if (!empty($field['style']) && $field['style'] == 'images') { echo '<div class="themerex_options_caption_image iconadmin-down-open">' . '<span style="background-image: url(' . $caption . ')"></span>' . '</div>'; } echo $list; echo '<input name="' . $field['id'] . '_icon' . ($cloneable ? '[]' : '') . '" type="hidden" value="' . htmlspecialchars(is_inherit_option($clone_val['icon']) ? '' : $clone_val['icon']) . '" />'; break; case "color": echo '<input class="themerex_options_input themerex_options_input_color"' . ' name="' . $field['id'] . ($cloneable ? '[]' : '') . '"' . ' id="' . $field['id'] . '"' . ' type="text"' . ' value="' . (is_inherit_option($clone_val) ? '' : $clone_val) . '"' . (!empty($field['action']) ? ' onchange="themerex_options_action_' . $field['action'] . '(this);return false;"' : '') . ' />'; break; default: if (function_exists('show_custom_field')) { echo show_custom_field($field, $clone_val); } } if ($cloneable) { echo '<input type="hidden" name="' . $field['id'] . '_numbers[]" value="' . $clone_num . '" />' . '</div>'; } } if (!themerex_options_is_group($field['type']) && $field['type'] != 'hidden') { if ($cloneable) { echo '<div class="themerex_options_input_button themerex_options_clone_button themerex_options_clone_button_add">' . __('+ Add item', 'themerex') . '</div>'; } if (!empty($THEMEREX_flags['add_inherit']) && isset($field['std'])) { echo '<div class="themerex_options_content_inherit"' . ($inherit ? '' : ' style="display:none;"') . '><div>' . __('Inherit', 'themerex') . '</div><input type="hidden" name="' . $field['id'] . '_inherit" value="' . $inherit . '" /></div>'; } echo '</div>'; if (!empty($field['desc'])) { echo '<div class="themerex_options_desc">' . $field['desc'] . '</div>' . "\n"; } echo '</div>' . "\n"; } }
function getIconsList($prepend_inherit = false) { $list = array(); if ($prepend_inherit) { $list['inherit'] = __("Inherit", 'themerex'); } return array_merge($list, parseIconsClasses(themerex_get_file_dir("/css/fontello/css/fontello-codes.css"))); }
function getIconsList($prepend_inherit = false) { $list = array(); if ($prepend_inherit) { $list['inherit'] = __("Inherit", 'themerex'); } return array_merge($list, parseIconsClasses(get_template_directory() . "/includes/fontello/css/fontello-codes.css")); }
function theme_options_show_field($field, $value = null, &$flags) { if ($value !== null) { $field['val'] = $value; } if (!isset($field['val']) || $field['val'] == '') { $field['val'] = 'default'; } if ($flags['inherit'] && isset($field['options']) && is_array($field['options'])) { $field['options'] = themerex_array_merge(array('default' => 'Inherit'), $field['options']); } if (isset($flags['radio_as_select']) && $flags['radio_as_select'] && $field['type'] == 'radio') { $field['type'] = 'select'; } if (isset($flags['clear_shortname']) && $flags['clear_shortname'] && isset($field['id'])) { $field['id'] = get_option_name($field['id']); } $menu = ''; $output = ''; $name_hook = str_replace(" ", "-", preg_replace("[^A-Za-z0-9]", "", themerex_strtolower($field['name']))); if (isset($flags['heading_as_tabs']) && $flags['heading_as_tabs'] && $field['type'] == 'heading') { $field['type'] = 'group'; $field['tab'] = $name_hook; $field['tabs'] = array($name_hook => $field['name']); } if (in_array($field['type'], array('group', 'groupend', 'heading')) && $flags['group_opened']) { $output .= '</div>'; if (!$flags['tabs_opened']) { $output .= '</div>'; } else { if (in_array($field['type'], array('groupend', 'heading'))) { $output .= '</div>'; $flags['tabs_opened'] = false; } } $flags['group_opened'] = false; } if ($field['type'] == 'group') { $flags['group_opened'] = true; if (isset($field['tabs'])) { if (!isset($flags['heading_as_tabs']) || !$flags['heading_as_tabs']) { $output .= '<div class="opt_tabs"' . (isset($field['std']) ? ' id="' . $field['std'] . '"' : '') . '><ul>'; } foreach ($field['tabs'] as $id => $title) { if (!isset($flags['heading_as_tabs']) || !$flags['heading_as_tabs']) { $output .= '<li id="tab_' . $id . '"><a href="#content_' . $id . '">' . $title . '</a></li>'; } else { $menu .= '<li id="tab_' . $id . '"><a href="#content_' . $id . '">' . $title . '</a></li>'; } } if (!isset($flags['heading_as_tabs']) || !$flags['heading_as_tabs']) { $output .= '</ul>'; } $flags['tabs_opened'] = true; } if (isset($field['tab'])) { $output .= '<div class="opt_group opt_content" id="content_' . $field['tab'] . '">'; } else { $output .= '<div class="opt_group' . (isset($field['tabs']) ? ' opt_tabs' : '') . '"' . (isset($field['std']) ? ' id="' . $field['std'] . '"' : '') . '>'; $output .= '<h3 class="toggle">' . $field['name'] . '</h3><div class="opt_content' . (isset($field['closed']) && $field['closed'] ? ' closed' : '') . '">'; } } if (!in_array($field['type'], array("heading", "hidden", "group", "groupend"))) { $class = ''; if (isset($field['class'])) { $class = $field['class']; } $output .= '<div class="section section-' . str_replace(array('list', 'range'), array('select', 'select'), $field['type']) . ' ' . $class . '">' . "\n"; $output .= '<h3 class="heading">' . $field['name'] . '</h3>' . "\n"; $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n"; } if (isset($field['enable'])) { $tmp = explode('|', $field['val']); $field['val'] = $tmp[0]; if (isset($tmp[1])) { $field['enable'] = $tmp[1]; } } switch ($field['type']) { case 'hidden': $output .= '<input class="of-input" name="' . $field['id'] . '" id="' . $field['id'] . '" type="' . $field['type'] . '" value="' . htmlspecialchars($field['val'] == 'default' ? '' : $field['val']) . '" />'; break; case 'text': $inc = isset($field['increment']) && $field['increment']; if ($inc) { $arr = explode(',', $field['val']); $output .= '<div class="of-increment-area">'; } else { $arr = array($field['val']); } for ($i = 0; $i < count($arr); $i++) { $sb = explode('|', $arr[$i]); if (count($sb) == 1) { $sb[1] = $i + 1; } $output .= ($inc ? '<div class="of-increment-item"><input type="hidden" name="' . $field['id'] . '_numbers[]" value="' . $sb[1] . '" />' : '') . '<input class="of-input' . ($inc ? ' of-incremented' : '') . '" name="' . $field['id'] . ($inc ? '[]' : '') . '" id="' . $field['id'] . '" type="' . $field['type'] . '" value="' . htmlspecialchars($sb[0] == 'default' ? '' : $sb[0]) . '" />' . ($inc ? '<a href="#" class="of-increment-button of-increment-del">-</a></div>' : ''); } if ($inc) { $output .= '</div><a href="#" class="of-increment-button of-increment-add">' . __('+ Add item', 'themerex') . '</a>'; } break; case 'textarea': $cols = isset($field['cols']) && $field['cols'] > 10 ? $field['cols'] : '40'; $rows = isset($field['rows']) && $field['rows'] > 1 ? $field['rows'] : '8'; $output .= '<textarea class="of-input" name="' . $field['id'] . '" id="' . $field['id'] . '" cols="' . $cols . '" rows="' . $rows . '">' . htmlspecialchars($field['val'] == 'default' ? '' : $field['val']) . '</textarea>'; break; case 'select': $multiple = isset($field['multiple']) && $field['multiple']; $output .= '<select class="of-input" name="' . $field['id'] . ($multiple ? '[]' : '') . '" id="' . $field['id'] . '"' . (isset($field['size']) ? ' size="' . $field['size'] . '"' : '') . ($multiple ? ' multiple="multiple"' : '') . '>'; foreach ($field['options'] as $k => $option) { if (is_array($option)) { $title = isset($option['name']) ? $option['name'] : (isset($option['title']) ? $option['title'] : $k); } else { $title = $option; } $output .= '<option' . ($multiple ? in_array($k, explode(',', $field['val'])) : $field['val'] == $k ? ' selected="selected"' : '') . ' value="' . $k . '">' . htmlspecialchars($title) . '</option>'; } $output .= '</select>'; break; case 'checklist': $multiple = isset($field['multiple']) && $field['multiple']; $i = 0; $id = $field['id']; $output .= '<ul class="checklist">'; foreach ($field['options'] as $k => $val) { $i++; $output .= '<li>'; $output .= '<input type="' . ($multiple ? 'checkbox' : 'radio') . '" value="' . $k . '" name="' . $id . ($multiple ? '[]' : '') . '" id="' . $id . $i . '"' . (in_array($k, explode(',', $field['val'])) ? ' checked="checked"' : '') . '><label for="' . $id . $i . '">' . $val . '</label>'; $output .= '</li>'; } $output .= '</ul>'; break; case 'list': $output .= '<select class="of-input" name="' . $field['id'] . '" id="' . $field['id'] . '">'; foreach ($field['options'] as $option) { $output .= '<option' . ($field['val'] == $option ? ' selected="selected"' : '') . ' value="' . $option . '">' . htmlspecialchars($option) . '</option>'; } $output .= '</select>'; break; case 'range': $output .= '<select class="of-input" name="' . $field['id'] . '" id="' . $field['id'] . '">'; $output .= '<option value="default">Inherit</option>'; for ($i = $field['from']; $i <= $field['to']; $i++) { $output .= '<option value="' . $i . '" ' . ($field['val'] == $i ? ' selected="selected"' : '') . '>' . $i . '</option>'; } $output .= '</select>'; break; case 'fontsize': $output .= '<select class="of-typography of-typography-size" name="' . $field['id'] . '" id="' . $field['id'] . '_size">'; for ($i = 9; $i < 71; $i++) { $output .= '<option value="' . $i . '" ' . ($field['val'] == $i ? ' selected="selected"' : '') . '>' . $i . 'px</option>'; } $output .= '</select>'; break; case "radio": foreach ($field['options'] as $key => $option) { $output .= '<input class="of-input of-radio" type="radio" name="' . $field['id'] . '" value="' . $key . '" ' . ($field['val'] == $key ? ' checked="checked"' : '') . ' id="' . $field['id'] . '_' . $key . '" /><label for="' . $field['id'] . '_' . $key . '">' . $option . '</label>' . (isset($field['style']) && $field['style'] == 'vertical' ? '<br />' : ''); } break; case "checkbox": $output .= '<input type="checkbox" class="checkbox of-input" name="' . $field['id'] . '" id="' . $field['id'] . '" value="true" ' . ($field['val'] == 'true' ? ' checked="checked"' : '') . ' /><label for="' . $field['id'] . '">' . $field['name'] . '</label>'; break; case "upload": case "upload_min": case "mediamanager": $upload = $field['val'] == 'default' ? '' : $field['val']; if (!empty($upload)) { $hide = ''; } else { $hide = 'hide'; } $output .= '<input class="of-input" name="' . $field['id'] . '" id="' . $field['id'] . '_upload" value="' . $upload . '" type="' . ($field['type'] == 'upload_min' ? 'hidden' : 'text') . '" />' . '<div class="upload_button_div">' . '<span class="button image_' . ($field['type'] == 'mediamanager' ? 'media' : 'upload') . '_button" id="' . $field['id'] . '"' . ($field['type'] == 'mediamanager' ? ' data-choose="' . (isset($field['multiple']) && $field['multiple'] ? __('Choose Images', 'themerex') : __('Choose Image', 'themerex')) . '"' . ' data-update="' . (isset($field['multiple']) && $field['multiple'] ? __('Add to Gallery', 'themerex') : __('Choose Image', 'themerex')) . '"' . ' data-multiple="' . (isset($field['multiple']) && $field['multiple'] ? 'true' : 'false') . '"' . ' data-linked-field="' . $field['id'] . '_upload"' : '') . '>' . __('Upload Image', 'themerex') . '</span>' . '<span class="button image_reset_button ' . $hide . '" id="reset_' . $field['id'] . '"' . (empty($upload) ? ' style="display:none;"' : '') . '>' . __('Remove', 'themerex') . '</span>' . '</div>' . "\n"; // . '<div class="clear"></div>' . "\n"; if (!empty($upload)) { $output .= '<a class="of-uploaded-image" target="_blank" href="' . $upload . '">'; $ext = pathinfo($upload, PATHINFO_EXTENSION); if (in_array(themerex_strtolower($ext), array('jpg', 'png', 'gif'))) { $output .= '<img class="of-option-image" id="image_' . $field['id'] . '" src="' . $upload . '" alt="" />'; } else { $fname = pathinfo($upload, PATHINFO_BASENAME); $output .= '<span id="image_' . $field['id'] . '">' . $fname . '</span>'; } $output .= '</a>'; $output .= '<div class="clear"></div>' . "\n"; } break; case "color": $output .= '<input class="of-color colorSelector" name="' . $field['id'] . '" id="' . $field['id'] . '" type="text" value="' . ($field['val'] == 'default' ? '' : $field['val']) . '" />'; break; case "images": $output .= '<input type="hidden" value="' . $field['val'] . '" name="' . $field['id'] . '" />'; $i = 0; foreach ($field['options'] as $key => $option) { $i++; $selected = ''; if ($field['val'] == $key || $i == 1 && $field['val'] == '') { $selected = 'of-radio-img-selected'; } $output .= '<span>'; if ($key == 'default') { $option = get_template_directory_uri() . '/images/spacer.png'; } $output .= '<img src="' . $option . '" data-icon="' . $key . '" alt="" class="of-radio-img-img ' . $selected . '" />'; $output .= '</span>'; } break; case "icons": $i = 0; if (isset($field['css']) && $field['css'] != '' && file_exists($field['css'])) { $field['options'] = parseIconsClasses($field['css']); } $output .= '</div>'; $output .= '<input type="hidden" value="' . $field['val'] . '" name="' . $field['id'] . '" />'; foreach ($field['options'] as $option) { $i++; $selected = ''; if ($field['val'] == $option || $i == 1 && $field['val'] == '') { $selected = 'of-radio-icon-selected'; } $output .= '<span>'; $output .= '<span class="of-radio-icon-icon ' . $option . ' ' . $selected . '" data-icon="' . $option . '"></span>'; $output .= '</span>'; } $output .= '<div>'; break; case 'socials': $arr = explode(',', $field['val']); $output .= '<div class="of-increment-area of-socials-area">'; for ($i = 0; $i < count($arr); $i++) { $sb = explode('|', $arr[$i]); if (count($sb) == 1) { $sb[1] = $i + 1; } if (count($sb) == 2) { $sb[2] = ''; } $j = 0; $icons = ''; $button = ''; foreach ($field['options'] as $k => $option) { $j++; $selected = ''; if ($sb[2] == $k || $j == 1 && $sb[2] == '') { $selected = 'of-radio-img-selected'; $button = $option; } $icons .= '<span>'; //$output .= '<span class="of-radio-icon-icon '. $option . ' ' . $selected .'" onClick="document.getElementById(\'of-radio-icon-'. $field['id'] . $j.'\').checked = true;"></span>'; $icons .= '<img src="' . $option . '" data-icon="' . $k . '" alt="" class="of-radio-img-img ' . $selected . '" />'; $icons .= '</span>'; } $output .= '<div class="of-increment-item"><input type="hidden" name="' . $field['id'] . '_numbers[]" value="' . $sb[1] . '" />' . '<input class="of-input of-incremented" name="' . $field['id'] . '[]" id="' . $field['id'] . '" type="text" value="' . htmlspecialchars($sb[0] == 'default' ? '' : $sb[0]) . '" />' . '<a href="#" class="of-socials-button"><img src="' . $button . '" alt="" /></a>' . '<a href="#" class="of-increment-button of-increment-del">-</a>' . '<div class="of-socials-icons">' . '<input type="hidden" value="' . $sb[2] . '" name="' . $field['id'] . '_icons[]" />' . $icons . '</div></div>'; } $output .= '</div><a href="#" class="of-increment-button of-increment-add">' . __('+ Add item', 'themerex') . '</a>'; break; case "info": $default = $field['std']; $output .= '<div class="info">' . $default . '</div>'; break; case "heading": if ($flags['heading_opened']) { $output .= '</div>' . "\n"; } $jquery_click_hook = "of-option-" . $name_hook; $menu .= '<li><a title="' . $field['name'] . '" href="#' . $jquery_click_hook . '">' . $field['name'] . '</a></li>'; $output .= '<div class="group" id="' . $jquery_click_hook . '"><h2>' . $field['name'] . '</h2>' . "\n"; $flags['heading_opened'] = true; break; default: if (function_exists('show_custom_field')) { $output .= show_custom_field($field, $field['val']); } } if (!in_array($field['type'], array("heading", "hidden", "group", "groupend"))) { //$output .= $field['type']!='checklist' ? '<br/>' : ''; if (!isset($field['desc'])) { $descr = ''; } else { $descr = $field['desc']; } if (isset($field['enable'])) { $output .= '<input type="checkbox" class="checkbox of-enable of-input" name="' . $field['id'] . '_enable" id="' . $field['id'] . '_enable" value="1" ' . ($field['enable'] == '1' ? ' checked="checked"' : '') . ' />'; } $output .= '</div><div class="explain">' . $descr . '</div>' . "\n"; $output .= '<div class="clear"> </div></div></div>' . "\n"; } return array($output, $menu); }