/** * Renders field option * * @access public * @param array $field * @return string */ public static function renderField($field) { $out = '<div class="themex-form-item themex-option" id="' . $field['form'] . '_' . $field['id'] . '">'; $out .= '<a href="#" class="themex-button themex-remove-button themex-trigger" title="' . __('Remove', 'makery') . '" data-action="themex_form_remove" data-element="' . $field['form'] . '_' . $field['id'] . '"></a>'; $out .= ThemexInterface::renderOption(array('id' => $field['form'] . '_' . $field['id'] . '_value', 'type' => 'hidden', 'value' => $field['form'], 'wrap' => false, 'after' => '<a href="#" class="themex-button themex-add-button themex-trigger" title="' . __('Add', 'makery') . '" data-action="themex_form_add" data-element="' . $field['form'] . '_' . $field['id'] . '" data-value="' . $field['form'] . '_' . $field['id'] . '_value"></a>')); $out .= ThemexInterface::renderOption(array('id' => __CLASS__ . '[' . $field['form'] . '][fields][' . $field['id'] . '][name]', 'type' => 'text', 'attributes' => array('placeholder' => __('Name', 'makery')), 'value' => isset(self::$data[$field['form']]['fields'][$field['id']]['name']) ? themex_stripslashes(self::$data[$field['form']]['fields'][$field['id']]['name']) : '', 'wrap' => false)); $out .= ThemexInterface::renderOption(array('id' => __CLASS__ . '[' . $field['form'] . '][fields][' . $field['id'] . '][type]', 'type' => 'select', 'options' => array('text' => __('String', 'makery'), 'select' => __('Select', 'makery')), 'value' => isset(self::$data[$field['form']]['fields'][$field['id']]['type']) ? self::$data[$field['form']]['fields'][$field['id']]['type'] : '', 'wrap' => false)); $out .= ThemexInterface::renderOption(array('id' => __CLASS__ . '[' . $field['form'] . '][fields][' . $field['id'] . '][options]', 'type' => 'text', 'attributes' => array('placeholder' => __('Options', 'makery')), 'value' => isset(self::$data[$field['form']]['fields'][$field['id']]['options']) ? self::$data[$field['form']]['fields'][$field['id']]['options'] : '', 'wrap' => false)); $out .= '</div>'; return $out; }
/** * Renders option * * @access public * @param array $option * @return string */ public static function renderOption($option) { global $post, $wp_registered_sidebars, $wp_locale; $out = ''; //option wrapper if (!isset($option['wrap']) || $option['wrap']) { $parent = ''; if (isset($option['parent'])) { $parent = 'data-parent="' . THEMEX_PREFIX . $option['parent']['id'] . '" '; $parent .= 'data-value="' . $option['parent']['value'] . '"'; } $out .= '<div class="themex-option themex-' . str_replace('_', '-', $option['type']) . '" ' . $parent . '>'; if (isset($option['name']) && $option['type'] != 'checkbox') { $out .= '<h3 class="themex-option-title">' . $option['name'] . '</h3>'; } } //option before if (isset($option['before'])) { $out .= $option['before']; } //option description if (isset($option['description'])) { $out .= '<div class="themex-tooltip"><div class="themex-tooltip-icon"></div><div class="themex-tooltip-text">' . $option['description'] . '</div></div>'; } //option attributes $attributes = ''; if (isset($option['attributes'])) { foreach ($option['attributes'] as $name => $value) { $attributes .= $name . '="' . $value . '" '; } } //option value if (!isset($option['value'])) { $option['value'] = ''; if (isset($option['id'])) { $option['value'] = themex_stripslashes(get_option($option['id'])); if (($option['value'] === false || $option['value'] == '') && isset($option['default'])) { $option['value'] = themex_stripslashes($option['default']); } } else { if (isset($option['default'])) { $option['value'] = themex_stripslashes($option['default']); } } } switch ($option['type']) { //text field case 'text': $out .= '<input type="text" id="' . $option['id'] . '" name="' . $option['id'] . '" value="' . $option['value'] . '" ' . $attributes . ' />'; break; //number field //number field case 'number': $out .= '<input type="number" id="' . $option['id'] . '" name="' . $option['id'] . '" value="' . abs(intval($option['value'])) . '" ' . $attributes . ' />'; break; //date field //date field case 'date': $out .= '<input type="text" id="' . $option['id'] . '" name="' . $option['id'] . '" value="' . $option['value'] . '" class="date-field" ' . $attributes . ' />'; break; //hidden field //hidden field case 'hidden': $out .= '<input type="hidden" id="' . $option['id'] . '" name="' . $option['id'] . '" value="' . $option['value'] . '" ' . $attributes . ' />'; break; //message field //message field case 'textarea': $out .= '<textarea id="' . $option['id'] . '" name="' . $option['id'] . '" ' . $attributes . '>' . $option['value'] . '</textarea>'; break; //checkbox //checkbox case 'checkbox': $checked = ''; if ($option['value'] == 'true') { $checked = 'checked="checked"'; } $out .= '<input type="checkbox" id="' . $option['id'] . '" name="' . $option['id'] . '" value="true" ' . $checked . ' ' . $attributes . ' />'; if (isset($option['name'])) { $out .= '<label for="' . $option['id'] . '">' . $option['name'] . '</label>'; } break; //colorpicker //colorpicker case 'color': $out .= '<input name="' . $option['id'] . '" id="' . $option['id'] . '" type="text" value="' . $option['value'] . '" class="themex-colorpicker" />'; break; //uploader //uploader case 'uploader': $out .= '<input name="' . $option['id'] . '" id="' . $option['id'] . '" type="text" value="' . $option['value'] . '" ' . $attributes . ' />'; $out .= '<a class="button themex-upload-button">' . __('Browse', 'academy') . '</a>'; break; //multiple uploader //multiple uploader case 'attachments': if (empty($option['value']) || !is_array($option['value'])) { $option['value'] = array('a' . uniqid() => array('title' => '', 'url' => '', 'type' => '')); } $out .= '<div class="themex-clone-pane"><input type="hidden" id="' . $option['id'] . '" name="' . $option['id'] . '" value="" />'; foreach ($option['value'] as $key => $field) { $out .= '<div class="themex-clone-item" id="' . $option['id'] . '_' . $key . '">'; $out .= '<a href="#" class="themex-button themex-remove-button themex-trigger" data-element="' . $option['id'] . '_' . $key . '" title="' . __('Remove', 'academy') . '"></a>'; $out .= '<a href="#" class="themex-button themex-clone-button themex-trigger" data-element="' . $option['id'] . '_' . $key . '" data-value="' . $key . '" title="' . __('Add', 'academy') . '"></a>'; $out .= ThemexInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][title]', 'type' => 'text', 'value' => themex_value($field, 'title'), 'wrap' => false, 'attributes' => array('placeholder' => __('Title', 'academy')))); $out .= ThemexInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][type]', 'type' => 'select', 'value' => themex_value($field, 'type'), 'wrap' => false, 'options' => array('document' => __('Document', 'academy'), 'audio' => __('Audio', 'academy'), 'video' => __('Video', 'academy')))); $out .= ThemexInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][status]', 'type' => 'select', 'value' => themex_value($field, 'status'), 'wrap' => false, 'options' => array('file' => __('File', 'academy'), 'link' => __('Link', 'academy')))); $out .= ThemexInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][url]', 'type' => 'uploader', 'value' => themex_value($field, 'url'), 'attributes' => array('placeholder' => 'URL'))); $out .= '</div>'; } $out .= '</div>'; break; //images selector //images selector case 'select_image': foreach ($option['options'] as $name => $src) { $out .= '<image src="' . $src . '" '; if ($name == $option['value']) { $out .= 'class="current"'; } $out .= ' data-value="' . $name . '" />'; } $out .= '<input type="hidden" name="' . $option['id'] . '" id="' . $option['id'] . '" value="' . $option['value'] . '" ' . $attributes . ' />'; break; //custom dropdown //custom dropdown case 'select': $out .= '<select id="' . $option['id'] . '" name="' . $option['id'] . '" ' . $attributes . '>'; if (isset($option['options'])) { foreach ($option['options'] as $name => $title) { $selected = ''; if ($option['value'] != '' && ($name == $option['value'] || is_array($option['value']) && in_array($name, $option['value']))) { $selected = 'selected="selected"'; } $out .= '<option value="' . $name . '" ' . $selected . '>' . $title . '</option>'; } } $out .= '</select>'; break; //fonts dropdown //fonts dropdown case 'select_font': $options = ThemexCore::$components['fonts']; asort($options); $out .= self::renderOption(array('id' => $option['id'], 'type' => 'select', 'wrap' => false, 'default' => $option['value'], 'options' => $options)); break; //pages dropdown //pages dropdown case 'select_page': $args = array('selected' => $option['value'], 'echo' => 0, 'name' => $option['id'], 'id' => $option['id']); $out .= wp_dropdown_pages($args); break; //posts dropdown //posts dropdown case 'select_post': $atts = array('numberposts' => -1, 'post_type' => $option['post_type'], 'post_status' => array('publish', 'future', 'pending', 'draft'), 'orderby' => 'title', 'order' => 'ASC'); if (isset($post) && isset($post->ID)) { $atts['exclude'] = array($post->ID); if ($option['post_type'] == 'lesson' && $post->post_type == 'lesson') { $course = ThemexCore::getPostRelations($post->ID, 0, 'lesson_course', true); $atts['include'] = array_diff(ThemexCore::getPostRelations(0, $course, 'lesson_course'), array($post->ID)); } } if ($option['post_type'] != 'product' && !current_user_can('manage_options')) { $atts['author'] = get_current_user_id(); } $items = get_posts($atts); $out .= '<select id="' . $option['id'] . '" name="' . $option['id'] . '" ' . $attributes . '>'; $out .= '<option value="0">' . __('None', 'academy') . '</option>'; foreach ($items as $item) { $selected = ''; if ($item->ID == $option['value']) { $selected = 'selected="selected"'; } $out .= '<option value="' . $item->ID . '" ' . $selected . '>' . $item->post_title . '</option>'; } $out .= '</select>'; break; //sidebars dropdown //sidebars dropdown case 'select_sidebar': $sidebars = array(); foreach ($wp_registered_sidebars as $sidebar) { $sidebars[$sidebar['name']] = $sidebar['name']; } $out .= self::renderOption(array('id' => $option['id'], 'type' => 'select', 'wrap' => false, 'options' => $sidebars)); break; //categories dropdown //categories dropdown case 'select_category': $args = array('hide_empty' => 0, 'echo' => 0, 'selected' => $option['value'], 'show_option_all' => __('None', 'academy'), 'hierarchical' => 0, 'name' => $option['id'], 'id' => $option['id'], 'depth' => 0, 'tab_index' => 0, 'taxonomy' => $option['taxonomy'], 'hide_if_empty' => false); if (isset($option['attributes'])) { $args['class'] = $option['attributes']['class']; } $out .= wp_dropdown_categories($args); break; //range slider //range slider case 'slider': $out .= '<div class="themex-slider-controls"></div><div class="themex-slider-value"></div>'; $out .= '<input type="hidden" class="slider-max" value="' . $option['max_value'] . '" />'; $out .= '<input type="hidden" class="slider-min" value="' . $option['min_value'] . '" />'; $out .= '<input type="hidden" class="slider-unit" value="' . $option['unit'] . '" />'; $out .= '<input type="hidden" class="slider-value" name="' . $option['id'] . '" id="' . $option['id'] . '" value="' . $option['value'] . '" />'; break; //quiz questions //quiz questions case 'questions': if (empty($option['value']) || !is_array($option['value'])) { $option['value'] = array('q' . uniqid() => array('title' => '', 'type' => '')); } $out .= '<div class="themex-clone-pane"><input type="hidden" id="' . $option['id'] . '" name="' . $option['id'] . '" value="" />'; foreach ($option['value'] as $key => $field) { $out .= '<div class="themex-clone-item" id="' . $option['id'] . '_' . $key . '">'; $out .= '<a href="#" class="themex-button themex-remove-button themex-trigger" data-element="' . $option['id'] . '_' . $key . '" title="' . __('Remove', 'academy') . '"></a>'; $out .= '<a href="#" class="themex-button themex-clone-button themex-trigger" data-value="' . $key . '" title="' . __('Add', 'academy') . '"></a>'; $out .= ThemexInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][title]', 'type' => 'text', 'value' => htmlspecialchars(themex_value($field, 'title')), 'wrap' => false, 'attributes' => array('placeholder' => __('Question', 'academy')))); $out .= ThemexInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][type]', 'type' => 'select', 'value' => themex_value($field, 'type'), 'wrap' => false, 'options' => array('single' => __('Single Choice', 'academy'), 'multiple' => __('Multiple Choice', 'academy'), 'string' => __('Short Answer', 'academy')))); if (!isset($field['answers']) || empty($field['answers'])) { $field['answers'] = array('a' . uniqid() => array('title' => '')); } foreach ($field['answers'] as $index => $answer) { $out .= '<div class="themex-clone-item clearfix" id="' . $option['id'] . '_' . $key . '_' . $index . '">'; $out .= '<a href="#" class="themex-button themex-remove-button themex-trigger" data-element="' . $option['id'] . '_' . $key . '_' . $index . '" title="' . __('Remove', 'academy') . '"></a>'; $out .= '<a href="#" class="themex-button themex-clone-button themex-trigger" data-element="' . $option['id'] . '_' . $key . '_' . $index . '" data-value="' . $index . '" title="' . __('Add', 'academy') . '"></a>'; $out .= ThemexInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][answers][' . $index . '][title]', 'type' => 'text', 'value' => htmlspecialchars(themex_value($answer, 'title')), 'wrap' => false, 'attributes' => array('placeholder' => __('Answer', 'academy')))); $out .= ThemexInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][answers][' . $index . '][result]', 'type' => 'checkbox', 'value' => themex_value($answer, 'result'), 'wrap' => false)); $out .= '</div>'; } $out .= '</div>'; } $out .= '</div>'; break; //users manager //users manager case 'users': $users = ThemexCore::getUserRelations(0, $post->ID, $post->post_type); $out .= '<div class="themex-row clearfix">'; $out .= wp_dropdown_users(array('echo' => false, 'exclude' => $users, 'name' => 'add_user_id', 'id' => 'add_user_id')); $out .= '<input type="submit" name="add_user" class="button" value="' . __('Add', 'academy') . '" /></div>'; if (!empty($users)) { $out .= '<div class="themex-row clearfix">'; $out .= wp_dropdown_users(array('echo' => false, 'include' => $users, 'name' => 'remove_user_id', 'id' => 'remove_user_id')); $out .= '<input type="submit" name="remove_user" class="button" value="' . __('Remove', 'academy') . '" /></div>'; } break; //module settings //module settings case 'module': $out .= '<div class="' . substr(strtolower(implode('-', preg_split('/(?=[A-Z])/', str_replace(THEMEX_PREFIX, '', $option['id'])))), 1) . '">'; if (isset($option['slug'])) { $out .= call_user_func(array(str_replace(THEMEX_PREFIX, '', $option['id']), 'renderSettings'), $option['slug']); } else { $out .= call_user_func(array(str_replace(THEMEX_PREFIX, '', $option['id']), 'renderSettings')); } $out .= '</div>'; break; } //option after if (isset($option['after'])) { $out .= $option['after']; } //wrap option if (!isset($option['wrap']) || $option['wrap']) { $out .= '</div>'; } return $out; }
/** * Adds static string * * @param string $key * @param string $type * @param string $string * @return void */ function themex_add_string($key, $type, $string) { $name = $key . '-' . $type; $string = themex_stripslashes($string); $strings = array(); include THEMEX_PATH . 'strings.php'; if (!isset($strings[$name])) { $string = str_replace("'", "’", $string); $file = @fopen(THEMEX_PATH . 'strings.php', 'a'); if ($file !== false) { fwrite($file, "\r\n" . '$strings' . "['" . $name . "']=__('" . $string . "', 'academy');"); fclose($file); } } }
<?php $counter = 0; foreach (ThemexLesson::$data['quiz']['questions'] as $key => $question) { $counter++; ?> <div class="quiz-question <?php echo $question['type']; ?> "> <div class="question-title"> <div class="question-number"><?php echo $counter; ?> </div> <h4 class="nomargin"><?php echo do_shortcode(themex_stripslashes($question['title'])); ?> </h4> </div> <?php ThemexLesson::renderAnswers($key, $question); ?> </div> <?php } ?> <input type="hidden" name="course_action" value="complete_course" /> <input type="hidden" name="lesson_action" value="complete_quiz" /> <input type="hidden" name="course_id" value="<?php echo ThemexCourse::$data['ID']; ?>
/** * Saves post meta * * @access public * @param int $ID * @return void */ public static function savePost($ID) { global $post; //check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $ID; } //verify nonce if (isset($_POST['themex_nonce']) && !wp_verify_nonce($_POST['themex_nonce'], $ID)) { return $ID; } //check permissions if (isset($_POST['post_type']) && $_POST['post_type'] == 'page') { if (!current_user_can('edit_page', $ID)) { return $ID; } } else { if (!current_user_can('edit_post', $ID)) { return $ID; } } //save post meta if (isset(self::$components['meta_boxes']) && isset($post)) { foreach (self::$components['meta_boxes'] as $meta_box) { if ($meta_box['page'] == $post->post_type) { foreach ($meta_box['options'] as $option) { if ($option['type'] == 'module') { if (isset($option['slug'])) { call_user_func(array(str_replace(THEMEX_PREFIX, '', $option['id']), 'saveData'), $option['slug']); } else { call_user_func(array(str_replace(THEMEX_PREFIX, '', $option['id']), 'saveData')); } } else { if (isset($_POST['_' . THEMEX_PREFIX . $option['id']])) { self::updatePostMeta($ID, $option['id'], themex_stripslashes($_POST['_' . THEMEX_PREFIX . $option['id']])); } } } } } } }
/** * Renders messages * * @access public * @param array $messages * @param bool $success * @return void */ public static function renderMessages($success = false) { $out = ''; $class = 'error'; if ($success) { $class = 'success'; } if (isset(self::$messages)) { $out .= '<ul class="' . $class . '">'; foreach (self::$messages as $message) { $out .= '<li>' . $message . '</li>'; } $out .= '</ul>'; } if (isset($_COOKIE[THEMEX_PREFIX . 'messages'])) { $out = themex_stripslashes($_COOKIE[THEMEX_PREFIX . 'messages']); } echo $out; }
/** * Renders option * * @access public * @param array $option * @return string */ public static function renderOption($option) { global $post, $wp_registered_sidebars, $wp_locale; $out = ''; //option wrapper if (!isset($option['wrap']) || $option['wrap']) { $parent = ''; if (isset($option['parent'])) { $parent = 'data-parent="' . THEMEX_PREFIX . $option['parent']['id'] . '" '; $parent .= 'data-value="' . $option['parent']['value'] . '"'; } $out .= '<div class="themex-option themex-' . str_replace('_', '-', $option['type']) . '" ' . $parent . '>'; if (isset($option['name']) && $option['type'] != 'checkbox') { $out .= '<h3 class="themex-option-title">' . $option['name'] . '</h3>'; } } //option before if (isset($option['before'])) { $out .= $option['before']; } //option description if (isset($option['description'])) { $out .= '<div class="themex-tooltip"><div class="themex-tooltip-icon"></div><div class="themex-tooltip-text">' . $option['description'] . '</div></div>'; } //option attributes $attributes = ''; if (isset($option['attributes'])) { foreach ($option['attributes'] as $name => $value) { $attributes .= $name . '="' . $value . '" '; } } //option value if (!isset($option['value'])) { $option['value'] = ''; if (isset($option['id'])) { $option['value'] = themex_stripslashes(get_option($option['id'])); if (($option['value'] === false || $option['value'] == '') && isset($option['default'])) { $option['value'] = themex_stripslashes($option['default']); } } else { if (isset($option['default'])) { $option['value'] = themex_stripslashes($option['default']); } } } switch ($option['type']) { //text field case 'text': $out .= '<input type="text" id="' . $option['id'] . '" name="' . $option['id'] . '" value="' . $option['value'] . '" ' . $attributes . ' />'; break; //number field //number field case 'number': $out .= '<input type="number" id="' . $option['id'] . '" name="' . $option['id'] . '" value="' . abs(intval($option['value'])) . '" ' . $attributes . ' />'; break; //date field //date field case 'date': $out .= '<input type="text" id="' . $option['id'] . '" name="' . $option['id'] . '" value="' . $option['value'] . '" class="date-field" ' . $attributes . ' />'; break; //hidden field //hidden field case 'hidden': $out .= '<input type="hidden" id="' . $option['id'] . '" name="' . $option['id'] . '" value="' . $option['value'] . '" ' . $attributes . ' />'; break; //message field //message field case 'textarea': $out .= '<textarea id="' . $option['id'] . '" name="' . $option['id'] . '" ' . $attributes . '>' . $option['value'] . '</textarea>'; break; //visual editor //visual editor case 'editor': ob_start(); self::renderEditor($option['id'], $option['value']); $out = ob_get_contents(); ob_end_clean(); break; //checkbox //checkbox case 'checkbox': $checked = ''; if ($option['value'] == 'true') { $checked = 'checked="checked"'; } $out .= '<input type="checkbox" id="' . $option['id'] . '" name="' . $option['id'] . '" value="true" ' . $checked . ' ' . $attributes . ' />'; if (isset($option['name'])) { $out .= '<label for="' . $option['id'] . '">' . $option['name'] . '</label>'; } break; //colorpicker //colorpicker case 'color': $out .= '<input name="' . $option['id'] . '" id="' . $option['id'] . '" type="text" value="' . $option['value'] . '" class="themex-colorpicker" />'; break; //uploader //uploader case 'uploader': $out .= '<input name="' . $option['id'] . '" id="' . $option['id'] . '" type="text" value="' . $option['value'] . '" ' . $attributes . ' />'; $out .= '<a class="button themex-upload-button">' . __('Browse', 'makery') . '</a>'; break; //images selector //images selector case 'select_image': foreach ($option['options'] as $name => $src) { $out .= '<image src="' . $src . '" '; if ($name == $option['value']) { $out .= 'class="current"'; } $out .= ' data-value="' . $name . '" />'; } $out .= '<input type="hidden" name="' . $option['id'] . '" id="' . $option['id'] . '" value="' . $option['value'] . '" ' . $attributes . ' />'; break; //custom dropdown //custom dropdown case 'select': if (isset($option['attributes']['multiple'])) { $option['id'] .= '[]'; } $out .= '<select id="' . $option['id'] . '" name="' . $option['id'] . '" ' . $attributes . '>'; if (isset($option['options'])) { foreach ($option['options'] as $name => $title) { $selected = ''; if ($option['value'] != '' && ($name == $option['value'] || is_array($option['value']) && in_array($name, $option['value']))) { $selected = 'selected="selected"'; } $out .= '<option value="' . $name . '" ' . $selected . '>' . $title . '</option>'; } } $out .= '</select>'; break; //fonts dropdown //fonts dropdown case 'select_font': $options = ThemexCore::$components['fonts']; asort($options); $out .= self::renderOption(array('id' => $option['id'], 'type' => 'select', 'wrap' => false, 'default' => $option['value'], 'options' => $options)); break; //countries dropdown //countries dropdown case 'select_country': $options = ThemexCore::$components['countries']; $options = array_merge(array('0' => '–'), $options); $out .= self::renderOption(array('id' => $option['id'], 'type' => 'select', 'wrap' => false, 'default' => $option['value'], 'options' => $options)); break; //pages dropdown //pages dropdown case 'select_page': $args = array('selected' => $option['value'], 'echo' => 0, 'name' => $option['id'], 'id' => $option['id']); $out .= wp_dropdown_pages($args); break; //posts dropdown //posts dropdown case 'select_post': $atts = array('numberposts' => -1, 'post_type' => $option['post_type'], 'post_status' => array('publish', 'future', 'pending', 'draft'), 'orderby' => 'title', 'order' => 'ASC'); if (isset($post) && isset($post->ID)) { $atts['exclude'] = array($post->ID); } if ($option['post_type'] != 'product' && !current_user_can('manage_options')) { $atts['author'] = get_current_user_id(); } $items = get_posts($atts); $out .= '<select id="' . $option['id'] . '" name="' . $option['id'] . '" ' . $attributes . '>'; $out .= '<option value="0">–</option>'; foreach ($items as $item) { $selected = ''; if ($item->ID == $option['value']) { $selected = 'selected="selected"'; } $out .= '<option value="' . $item->ID . '" ' . $selected . '>' . $item->post_title . '</option>'; } $out .= '</select>'; break; //sidebars dropdown //sidebars dropdown case 'select_sidebar': $sidebars = array(); foreach ($wp_registered_sidebars as $sidebar) { $sidebars[$sidebar['name']] = $sidebar['name']; } $out .= self::renderOption(array('id' => $option['id'], 'type' => 'select', 'wrap' => false, 'options' => $sidebars)); break; //categories dropdown //categories dropdown case 'select_category': $args = array('hide_empty' => 0, 'echo' => 0, 'selected' => $option['value'], 'show_option_all' => '–', 'hierarchical' => true, 'name' => $option['id'], 'id' => $option['id'], 'taxonomy' => $option['taxonomy'], 'orderby' => 'NAME'); if (isset($option['attributes'])) { $args['class'] = $option['attributes']['class']; } $out .= wp_dropdown_categories($args); break; //range slider //range slider case 'slider': $out .= '<div class="themex-slider-controls"></div><div class="themex-slider-value"></div>'; $out .= '<input type="hidden" class="slider-max" value="' . $option['max_value'] . '" />'; $out .= '<input type="hidden" class="slider-min" value="' . $option['min_value'] . '" />'; $out .= '<input type="hidden" class="slider-unit" value="' . $option['unit'] . '" />'; $out .= '<input type="hidden" class="slider-value" name="' . $option['id'] . '" id="' . $option['id'] . '" value="' . $option['value'] . '" />'; break; //module settings //module settings case 'module': $out .= '<div class="' . substr(strtolower(implode('-', preg_split('/(?=[A-Z])/', str_replace(THEMEX_PREFIX, '', $option['id'])))), 1) . '">'; if (isset($option['slug'])) { $out .= call_user_func(array(str_replace(THEMEX_PREFIX, '', $option['id']), 'renderSettings'), $option['slug']); } else { $out .= call_user_func(array(str_replace(THEMEX_PREFIX, '', $option['id']), 'renderSettings')); } $out .= '</div>'; break; } //option after if (isset($option['after'])) { $out .= $option['after']; } //wrap option if (!isset($option['wrap']) || $option['wrap']) { $out .= '</div>'; } return $out; }