/** * 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['mtheme_nonce']) && !wp_verify_nonce($_POST['mtheme_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(MTHEME_PREFIX, '', $option['id']), 'saveData'), $option['slug']); } else { call_user_func(array(str_replace(MTHEME_PREFIX, '', $option['id']), 'saveData')); } } if ($option['type'] == 'checkbox' && !isset($_POST['_' . $post->post_type . '_' . $option['id']])) { self::updatePostMeta($ID, $post->post_type . '_' . $option['id'], 'false'); } else { if (isset($_POST['_' . $post->post_type . '_' . $option['id']])) { $_POST['_' . $post->post_type . '_' . $option['id']] = str_replace('"', "'", $_POST['_' . $post->post_type . '_' . $option['id']]); self::updatePostMeta($ID, $post->post_type . '_' . $option['id'], mtheme_stripslashes($_POST['_' . $post->post_type . '_' . $option['id']])); } } } } } } }
/** * Renders field option * * @access public * @param array $field * @return string */ public static function renderField($field) { $out = '<div class="mtheme-form-item mtheme-option" id="' . $field['form'] . '_' . $field['id'] . '">'; $out .= '<a href="#" class="mtheme-button mtheme-remove-button mtheme-trigger" title="' . __('Remove', 'mtheme') . '" data-action="mtheme_form_remove" data-element="' . $field['form'] . '_' . $field['id'] . '"></a>'; $out .= MthemeInterface::renderOption(array('id' => $field['form'] . '_' . $field['id'] . '_value', 'type' => 'hidden', 'value' => $field['form'], 'wrap' => false, 'after' => '<a href="#" class="mtheme-button mtheme-add-button mtheme-trigger" title="' . __('Add', 'mtheme') . '" data-action="mtheme_form_add" data-element="' . $field['form'] . '_' . $field['id'] . '" data-value="' . $field['form'] . '_' . $field['id'] . '_value"></a>')); if ($field['form'] == 'section') { $out .= MthemeInterface::renderOption(array('name' => __('Menu link type', 'mtheme'), 'id' => __CLASS__ . '[' . $field['form'] . '][fields][' . $field['id'] . '][name]', 'type' => 'select', 'options' => array('internal' => __('Menu Link - Internal', 'mtheme'), 'external' => __('Menu Link - External', 'mtheme')), 'attributes' => array('placeholder' => __('Section link type', 'mtheme')), 'value' => isset(self::$data[$field['form']]['fields'][$field['id']]['name']) ? self::$data[$field['form']]['fields'][$field['id']]['name'] : '', 'wrap' => true, 'group' => 'multiple')); $out .= MthemeInterface::renderOption(array('name' => __('Menu Heading', 'mtheme'), 'id' => __CLASS__ . '[' . $field['form'] . '][fields][' . $field['id'] . '][menu_heading]', 'type' => 'text', 'attributes' => array('placeholder' => __('Menu Heading', 'mtheme')), 'value' => isset(self::$data[$field['form']]['fields'][$field['id']]['menu_heading']) ? mtheme_stripslashes(self::$data[$field['form']]['fields'][$field['id']]['menu_heading']) : '', 'wrap' => true, 'group' => 'multiple', 'description' => 'If Menu heading is empty, only section has to added in the page')); $out .= MthemeInterface::renderOption(array('name' => __('External menu link', 'mtheme'), 'id' => __CLASS__ . '[' . $field['form'] . '][fields][' . $field['id'] . '][external_link]', 'type' => 'text', 'attributes' => array('placeholder' => __('External menu link', 'mtheme')), 'value' => isset(self::$data[$field['form']]['fields'][$field['id']]['external_link']) ? self::$data[$field['form']]['fields'][$field['id']]['external_link'] : '', 'wrap' => true, 'group' => 'multiple', 'description' => 'Please enter external link. Only menu link has get display')); $out .= MthemeInterface::renderOption(array('name' => __('Internal Section Content', 'mtheme'), 'id' => __CLASS__ . '[' . $field['form'] . '][fields][' . $field['id'] . '][content]', 'type' => 'textarea', 'attributes' => array('placeholder' => __('Section Content', 'mtheme')), 'value' => isset(self::$data[$field['form']]['fields'][$field['id']]['content']) ? self::$data[$field['form']]['fields'][$field['id']]['content'] : '', 'wrap' => true, 'group' => 'multiple', 'description' => 'Please enter section shortcodes.')); } else { $out .= MthemeInterface::renderOption(array('id' => __CLASS__ . '[' . $field['form'] . '][fields][' . $field['id'] . '][name]', 'type' => 'text', 'attributes' => array('placeholder' => __('Field Name', 'mtheme')), 'value' => isset(self::$data[$field['form']]['fields'][$field['id']]['name']) ? mtheme_stripslashes(self::$data[$field['form']]['fields'][$field['id']]['name']) : '', 'wrap' => false)); $out .= MthemeInterface::renderOption(array('id' => __CLASS__ . '[' . $field['form'] . '][fields][' . $field['id'] . '][label]', 'type' => 'text', 'attributes' => array('placeholder' => __('Field label', 'mtheme')), 'value' => isset(self::$data[$field['form']]['fields'][$field['id']]['label']) ? mtheme_stripslashes(self::$data[$field['form']]['fields'][$field['id']]['label']) : '', 'wrap' => false)); $out .= MthemeInterface::renderOption(array('id' => __CLASS__ . '[' . $field['form'] . '][fields][' . $field['id'] . '][type]', 'type' => 'select', 'options' => array('text' => __('String', 'mtheme'), 'number' => __('Number', 'mtheme'), 'email' => __('Email', 'mtheme'), 'select' => __('Select', 'mtheme')), 'value' => isset(self::$data[$field['form']]['fields'][$field['id']]['type']) ? self::$data[$field['form']]['fields'][$field['id']]['type'] : '', 'wrap' => false)); $out .= MthemeInterface::renderOption(array('id' => __CLASS__ . '[' . $field['form'] . '][fields][' . $field['id'] . '][required]', 'type' => 'select', 'options' => array('yes' => __('Required', 'mtheme'), 'no' => __('Not Required', 'mtheme')), 'value' => isset(self::$data[$field['form']]['fields'][$field['id']]['required']) ? self::$data[$field['form']]['fields'][$field['id']]['required'] : '', 'wrap' => false)); $out .= MthemeInterface::renderOption(array('id' => __CLASS__ . '[' . $field['form'] . '][fields][' . $field['id'] . '][options]', 'type' => 'text', 'attributes' => array('placeholder' => __('Placeholder or options for select-field', 'mtheme')), '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) { /*var_dump($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="' . MTHEME_PREFIX . $option['parent']['id'] . '" '; $parent .= 'data-value="' . $option['parent']['value'] . '"'; } if (isset($option['group']) && $option['group'] == 'multiple') { $out .= '<div class="mtheme-multiple-option mtheme-' . str_replace('_', '-', $option['type']) . '" ' . $parent . '>'; } else { $out .= '<div class="mtheme-option mtheme-' . str_replace('_', '-', $option['type']) . '" ' . $parent . '>'; } if (isset($option['name']) && $option['type'] != 'checkbox') { $out .= '<h3 class="mtheme-option-title">' . $option['name'] . '</h3>'; } } //option before if (isset($option['before'])) { $out .= $option['before']; } //option description if (isset($option['description'])) { $out .= '<div class="mtheme-tooltip"><div class="mtheme-tooltip-icon"></div><div class="mtheme-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'] = mtheme_stripslashes(get_option($option['id'])); if (($option['value'] === false || $option['value'] == '') && isset($option['default'])) { $option['value'] = mtheme_stripslashes($option['default']); } } else { if (isset($option['default'])) { $option['value'] = mtheme_stripslashes($option['default']); } } } switch ($option['type']) { //text field case 'text': if (isset($option['defendency'])) { $attributes .= ' data-defendency-show="' . $option['defendency']['show'] . '" data-defendency-set="' . $option['defendency']['base'] . '_' . $option['defendency']['id'] . '_' . $option['defendency']['value'] . '" data-parent="' . $option['defendency']['parent'] . '" '; } $out .= '<input type="text" id="' . $option['id'] . '" name="' . $option['id'] . '" value="' . $option['value'] . '" ' . $attributes . ' />'; break; //number field //number field case 'number': if (isset($option['defendency'])) { $attributes .= ' data-defendency-show="' . $option['defendency']['show'] . '" data-defendency-set="' . $option['defendency']['base'] . '_' . $option['defendency']['id'] . '_' . $option['defendency']['value'] . '" data-parent="' . $option['defendency']['parent'] . '" '; } $out .= '<input type="text" maxlength="12" onkeypress="return isNumberKey(event)" id="' . $option['id'] . '" name="' . $option['id'] . '" value="' . $option['value'] . '" ' . $attributes . ' />'; break; //date field //date field case 'date': if (isset($option['defendency'])) { $attributes .= ' data-defendency-show="' . $option['defendency']['show'] . '" data-defendency-set="' . $option['defendency']['base'] . '_' . $option['defendency']['id'] . '_' . $option['defendency']['value'] . '" data-parent="' . $option['defendency']['parent'] . '" '; } $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; //icon_picker field //icon_picker field case 'icon_picker': if (isset($option['defendency'])) { $attributes .= ' data-defendency-show="' . $option['defendency']['show'] . '" data-defendency-set="' . $option['defendency']['base'] . '_' . $option['defendency']['id'] . '_' . $option['defendency']['value'] . '" data-parent="' . $option['defendency']['parent'] . '" '; } $v = ""; if (isset($option['value']) && !empty($option['value'])) { $v = explode('|', $option['value']); $v = $v[0] . ' ' . $v[1]; } $out .= '<input class="regular-text" type="hidden" id="' . $option['id'] . '" name="' . $option['id'] . '" value="' . $option['value'] . '"/>'; $out .= '<div id="mtheme_icon_picker_' . $option['id'] . '" data-target="#' . $option['id'] . '" class="button icon-picker ' . $v . '" ' . $attributes . ' ></div>'; break; //message field //message field case 'textarea': if (isset($option['defendency'])) { $attributes .= ' data-defendency-show="' . $option['defendency']['show'] . '" data-defendency-set="' . $option['defendency']['base'] . '_' . $option['defendency']['id'] . '_' . $option['defendency']['value'] . '" data-parent="' . $option['defendency']['parent'] . '" '; } $out .= '<textarea id="' . $option['id'] . '" name="' . $option['id'] . '" ' . $attributes . '>' . $option['value'] . '</textarea>'; break; //checkbox //checkbox case 'checkbox': if (isset($option['default']) && empty($option['value'])) { $option['value'] = $option['default']; } /*var_dump($option);*/ if (isset($option['defendency'])) { $attributes .= ' data-defendency-show="' . $option['defendency']['show'] . '" data-defendency-set="' . $option['defendency']['base'] . '_' . $option['defendency']['id'] . '_' . $option['defendency']['value'] . '" data-parent="' . $option['defendency']['parent'] . '" '; } if (isset($option['defendency-set'])) { $attributes .= ' data-defendency="' . $option['defendency-set'] . '" '; } $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': if (isset($option['defendency'])) { $attributes .= ' data-defendency-show="' . $option['defendency']['show'] . '" data-defendency-set="' . $option['defendency']['base'] . '_' . $option['defendency']['id'] . '_' . $option['defendency']['value'] . '" data-parent="' . $option['defendency']['parent'] . '" '; } $out .= '<input name="' . $option['id'] . '" id="' . $option['id'] . '" type="text" value="' . $option['value'] . '" class="mtheme-colorpicker" ' . $attributes . ' />'; break; //uploader //uploader case 'uploader': if (isset($option['defendency'])) { $attributes .= ' data-defendency-show="' . $option['defendency']['show'] . '" data-defendency-set="' . $option['defendency']['base'] . '_' . $option['defendency']['id'] . '_' . $option['defendency']['value'] . '" data-parent="' . $option['defendency']['parent'] . '" '; } $out .= '<input name="' . $option['id'] . '" id="' . $option['id'] . '" type="text" value="' . $option['value'] . '" ' . $attributes . ' />'; $out .= '<a class="button mtheme-upload-button">' . __('Browse', 'mtheme') . '</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="mtheme-clone-pane"><input type="hidden" id="' . $option['id'] . '" name="' . $option['id'] . '" value="" />'; foreach ($option['value'] as $key => $field) { $out .= '<div class="mtheme-clone-item" id="' . $option['id'] . '_' . $key . '">'; $out .= '<a href="#" class="mtheme-button mtheme-remove-button mtheme-trigger" data-element="' . $option['id'] . '_' . $key . '" title="' . __('Remove', 'mtheme') . '"></a>'; $out .= '<a href="#" class="mtheme-button mtheme-clone-button mtheme-trigger" data-element="' . $option['id'] . '_' . $key . '" data-value="' . $key . '" title="' . __('Add', 'mtheme') . '"></a>'; $out .= MthemeInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][title]', 'type' => 'text', 'value' => mtheme_value($field, 'title'), 'wrap' => false, 'attributes' => array('placeholder' => __('Title', 'mtheme')))); $out .= MthemeInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][type]', 'type' => 'select', 'value' => mtheme_value($field, 'type'), 'wrap' => false, 'options' => array('document' => __('Document', 'mtheme'), 'audio' => __('Audio', 'mtheme'), 'video' => __('Video', 'mtheme')))); $out .= MthemeInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][status]', 'type' => 'select', 'value' => mtheme_value($field, 'status'), 'wrap' => false, 'options' => array('file' => __('File', 'mtheme'), 'link' => __('Link', 'mtheme')))); $out .= MthemeInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][url]', 'type' => 'uploader', 'value' => mtheme_value($field, 'url'), 'attributes' => array('placeholder' => 'URL'))); $out .= '</div>'; } $out .= '</div>'; break; //images selector //images selector case 'select_image': if (isset($option['defendency'])) { $attributes .= ' data-defendency-show="' . $option['defendency']['show'] . '" data-defendency-set="' . $option['defendency']['base'] . '_' . $option['defendency']['id'] . '_' . $option['defendency']['value'] . '" data-parent="' . $option['defendency']['parent'] . '" '; } 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['default']) && empty($option['value'])) { $option['value'] = $option['default']; } if (isset($option['defendency'])) { $attributes .= ' data-defendency-show="' . $option['defendency']['show'] . '" data-defendency-set="' . $option['defendency']['base'] . '_' . $option['defendency']['id'] . '_' . $option['defendency']['value'] . '" data-parent="' . $option['defendency']['parent'] . '" '; } if (isset($option['defendency-set'])) { $attributes .= ' data-defendency="' . $option['defendency-set'] . '" '; } $out .= '<select id="' . $option['id'] . '" name="' . $option['id'] . '" ' . $attributes . ' autocomplete="off">'; 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 = MthemeCore::$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': if (isset($option['defendency'])) { $attributes .= ' data-defendency-show="' . $option['defendency']['show'] . '" data-defendency-set="' . $option['defendency']['base'] . '_' . $option['defendency']['id'] . '_' . $option['defendency']['value'] . '" data-parent="' . $option['defendency']['parent'] . '" '; } $atts = array('numberposts' => -1, 'post_type' => $option['post_type'], 'post_status' => array('publish', 'future', 'pending', 'draft'), 'orderby' => 'title', 'order' => 'ASC'); 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', 'mtheme') . '</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; //multiple posts dropdown //multiple posts dropdown case 'select_multiple_post': global $post; $data = get_post_meta($post->ID, $option['input_id'], false); echo '<div class="custom-mtheme-option">'; echo '<ul id="' . $option['input_id'] . '_items">'; $c = 0; if (!empty($data)) { foreach ((array) $data as $p) { echo ajax_show_multiple_select($c, $option, $p); $c++; } } echo '</ul>'; ?> <span class="add_<?php echo esc_attr($option['input_id']); ?> button"><?php echo __('Add', 'mtheme'); ?> </span> <script> var $ =jQuery.noConflict(); $(document).ready(function() { var count = <?php echo esc_attr($c - 1); ?> ; $(".add_<?php echo esc_attr($option['input_id']); ?> ").click(function() { count = count + 1; $('#<?php echo esc_attr($option['input_id'] . '_items'); ?> ').append('<?php echo ajax_show_multiple_select('count', $option); ?> '.replace(/count/g, count)); return false; }); $(".remove_<?php echo esc_attr($option['input_id']); ?> ").live('click', function() { $(this).parent().remove(); }); }); </script> <style>#<?php echo esc_attr($option['input_id'] . '_items'); ?> {list-style: none;}</style> <?php echo '</div>'; 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': if (isset($option['defendency'])) { $attributes .= ' data-defendency-show="' . $option['defendency']['show'] . '" data-defendency-set="' . $option['defendency']['base'] . '_' . $option['defendency']['id'] . '_' . $option['defendency']['value'] . '" data-parent="' . $option['defendency']['parent'] . '" '; } $args = array('hide_empty' => 0, 'echo' => 0, 'selected' => $option['value'], 'show_option_all' => __('None', 'mtheme'), '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 .= '<div' . $attributes . '>'; $out .= wp_dropdown_categories($args); $out .= '</div>'; break; //range slider //range slider case 'slider': $out .= '<div class="mtheme-slider-controls"></div><div class="mtheme-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; /*section_menu*/ /*section_menu*/ case 'section_menu': if (empty($option['value']) || !is_array($option['value'])) { $option['value'] = array('s' . uniqid() => array('title' => '', 'type' => '')); } $out .= '<div class="mtheme-clone-pane"><input type="hidden" id="' . $option['id'] . '" name="' . $option['id'] . '" value="" />'; foreach ($option['value'] as $key => $field) { $out .= '<div class="mtheme-clone-item" id="' . $option['id'] . '_' . $key . '">'; $out .= '<a href="#" class="mtheme-button mtheme-remove-button mtheme-trigger" data-element="' . $option['id'] . '_' . $key . '" title="' . __('Remove', 'mtheme') . '"></a>'; $out .= '<a href="#" class="mtheme-button mtheme-clone-button mtheme-trigger" data-value="' . $key . '" title="' . __('Add', 'mtheme') . '"></a>'; $out .= MthemeInterface::renderOption(array('name' => __('Menu link type', 'mtheme'), 'id' => $option['id'] . '[' . $key . '][name]', 'type' => 'select', 'options' => array('internal' => __('Menu Link - Internal', 'mtheme'), 'external' => __('Menu Link - External', 'mtheme')), 'attributes' => array('placeholder' => __('Section link type', 'mtheme')), 'value' => htmlspecialchars(mtheme_value($field, 'name')), 'wrap' => true, 'group' => 'multiple', 'default' => 'internal')); $out .= MthemeInterface::renderOption(array('name' => __('Menu Heading', 'mtheme'), 'id' => $option['id'] . '[' . $key . '][menu_heading]', 'type' => 'text', 'attributes' => array('placeholder' => __('Menu Heading', 'mtheme')), 'value' => htmlspecialchars(mtheme_value($field, 'menu_heading')), 'wrap' => true, 'group' => 'multiple', 'description' => 'If Menu heading is empty, only section has to added in the page')); $out .= MthemeInterface::renderOption(array('name' => __('External menu link', 'mtheme'), 'id' => $option['id'] . '[' . $key . '][external_link]', 'type' => 'text', 'attributes' => array('placeholder' => __('External menu link', 'mtheme')), 'value' => htmlspecialchars(mtheme_value($field, 'external_link')), 'wrap' => true, 'group' => 'multiple', 'description' => 'Please enter external link. Only menu link has get display')); $out .= MthemeInterface::renderOption(array('name' => __('Internal Section Content', 'mtheme'), 'id' => $option['id'] . '[' . $key . '][content]', 'type' => 'textarea', 'attributes' => array('placeholder' => __('Section Content', 'mtheme')), 'value' => htmlspecialchars(mtheme_value($field, 'content')), 'wrap' => true, 'group' => 'multiple', 'description' => 'Please enter section shortcodes.')); $out .= '</div>'; } $out .= '</div>'; break; /*schedule*/ /*schedule*/ case 'schedule': if (empty($option['value']) || !is_array($option['value'])) { $option['value'] = array('s' . uniqid() => array('title' => '', 'type' => '')); } $out .= '<div class="mtheme-clone-pane"><input type="hidden" id="' . $option['id'] . '" name="' . $option['id'] . '" value="" />'; foreach ($option['value'] as $key => $field) { $out .= '<div class="mtheme-clone-item" id="' . $option['id'] . '_' . $key . '">'; $out .= '<a href="#" class="mtheme-button mtheme-remove-button mtheme-trigger" data-element="' . $option['id'] . '_' . $key . '" title="' . __('Remove', 'mtheme') . '"></a>'; $out .= '<a href="#" class="mtheme-button mtheme-clone-button mtheme-trigger" data-value="' . $key . '" title="' . __('Add', 'mtheme') . '"></a>'; $out .= MthemeInterface::renderOption(array('name' => __('Accordion Active', 'mtheme'), 'id' => $option['id'] . '[' . $key . '][active]', 'type' => 'select', 'value' => htmlspecialchars(mtheme_value($field, 'active')), 'options' => array('no' => __('Accordion Active - NO', 'mtheme'), 'yes' => __('Accordion Active - Yes', 'mtheme')), 'wrap' => true, 'group' => 'multiple', 'description' => 'Is Accordion Active?', 'default' => 'no')); $out .= MthemeInterface::renderOption(array('name' => __('Event Title', 'mtheme'), 'id' => $option['id'] . '[' . $key . '][title]', 'type' => 'text', 'value' => htmlspecialchars(mtheme_value($field, 'title')), 'wrap' => false, 'attributes' => array('placeholder' => __('Event Title', 'mtheme')), 'wrap' => true, 'group' => 'multiple', 'description' => 'Please enter Event Title.')); $out .= MthemeInterface::renderOption(array('name' => __('Event Time', 'mtheme'), 'id' => $option['id'] . '[' . $key . '][time]', 'type' => 'text', 'value' => htmlspecialchars(mtheme_value($field, 'time')), 'wrap' => false, 'attributes' => array('placeholder' => __('Event Time', 'mtheme')), 'wrap' => true, 'group' => 'multiple', 'description' => 'Please enter Event Time.')); $out .= MthemeInterface::renderOption(array('name' => __('Speaker Name', 'mtheme'), 'id' => $option['id'] . '[' . $key . '][speaker]', 'type' => 'text', 'value' => htmlspecialchars(mtheme_value($field, 'speaker')), 'wrap' => false, 'attributes' => array('placeholder' => __('Event Speaker Name', 'mtheme')), 'wrap' => true, 'group' => 'multiple', 'description' => 'Please enter Event Speaker Name.')); $out .= MthemeInterface::renderOption(array('name' => __('Speaker Designation', 'mtheme'), 'id' => $option['id'] . '[' . $key . '][designation]', 'type' => 'text', 'value' => htmlspecialchars(mtheme_value($field, 'designation')), 'wrap' => false, 'attributes' => array('placeholder' => __('Event Speaker Designation', 'mtheme')), 'wrap' => true, 'group' => 'multiple', 'description' => 'Please enter Event Speaker Name.')); $out .= MthemeInterface::renderOption(array('name' => __('Event Venue', 'mtheme'), 'id' => $option['id'] . '[' . $key . '][venue]', 'type' => 'text', 'value' => htmlspecialchars(mtheme_value($field, 'venue')), 'wrap' => false, 'attributes' => array('placeholder' => __('Event Venue', 'mtheme')), 'wrap' => true, 'group' => 'multiple', 'description' => 'Please enter Event Venue.')); $out .= MthemeInterface::renderOption(array('name' => __('Description', 'mtheme'), 'id' => $option['id'] . '[' . $key . '][description]', 'type' => 'textarea', 'value' => htmlspecialchars(mtheme_value($field, 'description')), 'wrap' => false, 'attributes' => array('placeholder' => __('Event Description', 'mtheme')), 'wrap' => true, 'group' => 'multiple', 'description' => 'Please enter Event Description.')); $out .= '</div>'; } $out .= '</div>'; break; /*external_link*/ /*external_link*/ case 'external_link': if (empty($option['value']) || !is_array($option['value'])) { $option['value'] = array('el' . uniqid() => array('title' => '', 'type' => '')); } $out .= '<div class="mtheme-clone-pane"><input type="hidden" id="' . $option['id'] . '" name="' . $option['id'] . '" value="" />'; foreach ($option['value'] as $key => $field) { $out .= '<div class="mtheme-clone-item" id="' . $option['id'] . '_' . $key . '">'; $out .= '<a href="#" class="mtheme-button mtheme-remove-button mtheme-trigger" data-element="' . $option['id'] . '_' . $key . '" title="' . __('Remove', 'mtheme') . '"></a>'; $out .= '<a href="#" class="mtheme-button mtheme-clone-button mtheme-trigger" data-value="' . $key . '" title="' . __('Add', 'mtheme') . '"></a>'; $out .= MthemeInterface::renderOption(array('name' => __('External Link Title', 'mtheme'), 'id' => $option['id'] . '[' . $key . '][el_link_title]', 'type' => 'text', 'value' => htmlspecialchars(mtheme_value($field, 'el_link_title')), 'wrap' => true, 'attributes' => array('placeholder' => __('External Link Title', 'mtheme')), 'group' => 'multiple', 'description' => 'External Link Title')); $out .= MthemeInterface::renderOption(array('name' => __('External Link URL', 'mtheme'), 'id' => $option['id'] . '[' . $key . '][el_link_url]', 'type' => 'text', 'value' => htmlspecialchars(mtheme_value($field, 'el_link_url')), 'wrap' => true, 'attributes' => array('placeholder' => __('External Link URL', 'mtheme')), 'group' => 'multiple', 'description' => 'External Link URL')); $out .= '</div>'; } $out .= '</div>'; break; //users manager //users manager case 'users': $users = MthemeCore::getUserRelations(0, $post->ID, $post->post_type); $out .= '<div class="mtheme-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', 'mtheme') . '" /></div>'; if (!empty($users)) { $out .= '<div class="mtheme-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', 'mtheme') . '" /></div>'; } break; //module settings //module settings case 'module': $out .= '<div class="' . substr(strtolower(implode('-', preg_split('/(?=[A-Z])/', str_replace(MTHEME_PREFIX, '', $option['id'])))), 1) . '">'; if (isset($option['slug'])) { $out .= call_user_func(array(str_replace(MTHEME_PREFIX, '', $option['id']), 'renderSettings'), $option['slug']); } else { $out .= call_user_func(array(str_replace(MTHEME_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 mtheme_add_string($key, $type, $string) { $name = $key . '-' . $type; $string = mtheme_stripslashes($string); $strings = array(); include MTHEME_PATH . 'strings.php'; if (!isset($strings[$name])) { $string = str_replace("'", "’", $string); $file = @fopen(MTHEME_PATH . 'strings.php', 'a'); if ($file !== false) { fwrite($file, "\r\n" . '$strings' . "['" . $name . "']=__('" . $string . "', 'mtheme');"); fclose($file); } } }