function form($instance)
    {
        $instance = wp_parse_args((array) $instance, array('number' => '6', 'order' => 'registered', 'title' => ''));
        ?>
		<p>
			<label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title', 'mtheme');
        ?>
:</label>
			<input class="widefat" type="text" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" value="<?php 
        echo $instance['title'];
        ?>
" />
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('number');
        ?>
"><?php 
        _e('Number', 'mtheme');
        ?>
:</label>
			<input class="widefat" type="number" id="<?php 
        echo $this->get_field_id('number');
        ?>
" name="<?php 
        echo $this->get_field_name('number');
        ?>
" value="<?php 
        echo $instance['number'];
        ?>
" />
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('order');
        ?>
"><?php 
        _e('Order', 'mtheme');
        ?>
:</label>
			<?php 
        echo MthemeInterface::renderOption(array('id' => $this->get_field_name('order'), 'type' => 'select', 'value' => $instance['order'], 'wrap' => false, 'options' => array('registered' => __('Date', 'mtheme'), 'display_name' => __('Name', 'mtheme'), 'post_count' => __('Activity', 'mtheme')), 'attributes' => array('class' => 'widefat')));
        ?>
		</p>
	<?php 
    }
Exemple #2
0
				<button type="button" class="navbar-toggle" data-toggle="collapse" 
					 data-target="#example-navbar-collapse">
					 <span class="sr-only">Toggle navigation</span>
					 <span class="icon-bar"></span>
					 <span class="icon-bar"></span>
					 <span class="icon-bar"></span>
				</button>		
				<a class="navbar-brand" href="<?php 
    echo SITE_URL;
    ?>
"><img src="<?php 
    echo MthemeCore::getOption("site_logo", "");
    ?>
" alt=""/></a>
		   </div>
		   <?php 
    $slug = 'main_menu';
    ?>
		   <div class="collapse navbar-collapse" id="example-navbar-collapse">
			  <?php 
    MthemeInterface::renderSiteMenu($slug);
    ?>
		   </div>
		</nav>
	</div>
</div>
<!--/HEADER-->
<?php 
}
?>
	
Exemple #3
0
 /**
  * Inits component on action
  *
  * @access public
  * @return void
  */
 public function __call($component, $args)
 {
     if (isset(self::$components[$component])) {
         foreach (self::$components[$component] as $item) {
             switch ($component) {
                 case 'supports':
                     add_theme_support($item);
                     break;
                 case 'rewrite_rules':
                     self::rewriteRule($item);
                     break;
                 case 'user_roles':
                     add_role($item['role'], $item['name'], $item['capabilities']);
                     break;
                 case 'custom_menus':
                     register_nav_menu($item['slug'], $item['name']);
                     break;
                 case 'image_sizes':
                     add_image_size($item['name'], $item['width'], $item['height'], $item['crop']);
                     break;
                 case 'admin_scripts':
                     self::enqueueScript($item);
                     break;
                 case 'admin_styles':
                     self::enqueueStyle($item);
                     break;
                 case 'user_header_scripts':
                     self::enqueueScript($item);
                     break;
                 case 'user_footer_scripts':
                     self::enqueueScript($item, true);
                     break;
                 case 'user_styles':
                     self::enqueueStyle($item);
                     break;
                 case 'widget_areas':
                     register_sidebar($item);
                     break;
                 case 'post_types':
                     register_post_type($item['id'], $item);
                     break;
                 case 'taxonomies':
                     register_taxonomy($item['taxonomy'], $item['object_type'], $item['settings']);
                     break;
                 case 'meta_boxes':
                     if (isset($item['template']) && $item['page'] == 'page') {
                         $template_file = '';
                         if (isset($_GET['post'])) {
                             $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];
                             $template_file = get_post_meta($post_id, '_wp_page_template', TRUE);
                         }
                         if ($template_file == $item['template']) {
                             add_meta_box($item['id'], $item['title'], array('MthemeInterface', 'renderMetabox'), $item['page'], $item['context'], $item['priority'], array('ID' => $item['id']));
                         }
                     } else {
                         add_meta_box($item['id'], $item['title'], array('MthemeInterface', 'renderMetabox'), $item['page'], $item['context'], $item['priority'], array('ID' => $item['id']));
                     }
                     break;
                 case 'texa_meta':
                     MthemeInterface::renderTaxmeta($item['cat_type']);
                     break;
             }
         }
     }
 }
Exemple #4
0
								<div class="category">
									<?php 
        the_category(', ');
        ?>
								</div>			
							</div>
						</div>
					</article>
				
				<?php 
    }
    ?>
				<div class="post-pagination">	
					<?php 
    MthemeInterface::renderPagination();
    if (MthemeInterface::isRenderPagination()) {
        paginate_comments_links();
    }
    ?>
				</div>			
				<?php 
} else {
    ?>
						<article>
							<div class="post-content clearfix">
								<p class="blog-text" style="padding: 10px 30px; margin-bottom: 5%;">
									<?php 
    esc_html_e("SORRY, No Results Found for ", 'mtheme');
    ?>
 " <?php 
    echo get_search_query();
    /**
     * 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;
    }
 /**
  * Renders sidebar option
  *
  * @access public
  * @param array $sidebar
  * @return string
  */
 public static function renderSidebar($sidebar)
 {
     $out = '<div class="mtheme-sidebar-item mtheme-option" id="' . $sidebar['id'] . '">';
     $out .= '<h3 class="mtheme-sidebar-title">' . $sidebar['name'] . '</h3>';
     $out .= '<a href="#" class="mtheme-button mtheme-remove-button mtheme-trigger" title="' . __('Remove', 'mtheme') . '" data-action="mtheme_sidebar_remove" data-element="' . $sidebar['id'] . '"></a>';
     //sidebar name
     $out .= mthemeInterface::renderOption(array('type' => 'hidden', 'id' => __CLASS__ . '[' . $sidebar['id'] . '][name]', 'value' => $sidebar['name']));
     //pages list
     $pages = get_pages();
     foreach ($pages as $page) {
         $items[$page->ID] = $page->post_title;
     }
     $out .= MthemeInterface::renderOption(array('name' => __('Pages', 'mtheme'), 'id' => __CLASS__ . '[' . $sidebar['id'] . '][pages][]', 'type' => 'select', 'options' => $items, 'attributes' => array('multiple' => 'multiple'), 'value' => isset(self::$data[$sidebar['id']]['pages']) ? self::$data[$sidebar['id']]['pages'] : ''));
     //categories list
     $items = array();
     $categories = get_categories();
     foreach ($categories as $category) {
         $items[$category->term_id] = $category->name;
     }
     $out .= MthemeInterface::renderOption(array('name' => __('Categories', 'mtheme'), 'id' => __CLASS__ . '[' . $sidebar['id'] . '][categories][]', 'type' => 'select', 'options' => $items, 'attributes' => array('multiple' => 'multiple'), 'value' => isset(self::$data[$sidebar['id']]['categories']) ? self::$data[$sidebar['id']]['categories'] : ''));
     $out .= '</div>';
     return $out;
 }
Exemple #7
0
			<h1 class="mtheme-page-title"><?php 
_e('Theme Options', 'mtheme');
?>
</h1>
			<input type="submit" name="<?php 
echo MTHEME_PREFIX;
?>
save_options" value="<?php 
_e('Save Changes', 'mtheme');
?>
" class="mtheme-button disabled mtheme-save-button" />
		</div>
		<div class="mtheme-content">
			<div class="mtheme-menu">
				<?php 
MthemeInterface::renderMenu();
?>
			</div>
			<div class="mtheme-sections">
				
				<?php 
self::renderSections();
?>
				
			</div>
		</div>	
		<div class="mtheme-footer">
			<input type="submit" name="<?php 
echo MTHEME_PREFIX;
?>
reset_options" value="<?php 
Exemple #8
0
 /**
  * Submits form data
  *
  * @access public
  * @return void
  */
 public static function submitData()
 {
     self::refresh();
     parse_str($_POST['data'], $data);
     /*var_dump($data);die();*/
     if (isset($data['slug']) && self::isActive($data['slug'])) {
         foreach (self::$data[$data['slug']]['fields'] as $field) {
             $ID = mtheme_sanitize_key($field['name']);
             $field['name'] = mtheme_get_string($ID, 'name', $field['name']);
             $field['optional'] = mtheme_get_string($ID, 'options', $field['options']);
             if (empty($data[$ID]) && $field['required'] == 'yes' && $field['type'] != 'select') {
                 MthemeInterface::$messages[] = $field['name'] . ' ' . __('is required', 'mtheme');
             } else {
                 if ($field['type'] == 'number' && !is_numeric($data[$ID])) {
                     MthemeInterface::$messages[] = $field['name'] . ' ' . __('can only contain numbers', 'mtheme');
                 }
                 if ($field['type'] == 'email' && !is_email($data[$ID])) {
                     MthemeInterface::$messages[] = __('You have entered an invalid email address', 'mtheme');
                 }
             }
         }
         if (isset(self::$data[$data['slug']]['captcha'])) {
             session_start();
             $posted_code = md5($data['captcha']);
             $session_code = $_SESSION['captcha'];
             if ($session_code != $posted_code) {
                 MthemeInterface::$messages[] = __('The verification code is incorrect', 'mtheme');
             }
         }
         if (!empty(MthemeInterface::$messages)) {
             MthemeInterface::renderMessages();
         } else {
             $admin_email = MthemeCore::getOption('reg_admin_email');
             if (empty($admin_email)) {
                 $admin_email = get_option('admin_email');
             }
             $subject = __('Contact', 'mtheme');
             $message = 'Dear Admin,<br/>';
             foreach (self::$data[$data['slug']]['fields'] as $field) {
                 $ID = mtheme_sanitize_key($field['name']);
                 $field['name'] = mtheme_get_string($ID, 'name', $field['name']);
                 if ($field['type'] == 'select') {
                     $field['options'] = mtheme_get_string($ID, 'options', $field['options']);
                     $items = explode(',', $field['options']);
                     if (isset($items[$data[$ID] - 1])) {
                         $data[$ID] = $items[$data[$ID] - 1];
                     } else {
                         $data[$ID] = '&ndash;';
                     }
                 }
                 $message .= $field['name'] . ': ' . $data[$ID] . '<br />';
             }
             if (mtheme_mail($admin_email, $subject, $message) && isset(self::$data[$data['slug']]['message'])) {
                 $message = mtheme_get_string($data['slug'], 'message', self::$data[$data['slug']]['message']);
                 if (empty($message)) {
                     MthemeInterface::$messages[] = 'Your message has been sent.';
                 } else {
                     MthemeInterface::$messages[] = $message;
                 }
                 MthemeInterface::renderMessages(true);
             } else {
                 MthemeInterface::$messages[] = "Email could not send.";
                 MthemeInterface::renderMessages();
             }
         }
     }
     die;
 }
 /**
  * Renders module settings
  *
  * @access public
  * @return string
  */
 public static function renderSettings()
 {
     $out = '<table><tbody>';
     //render options
     if (isset(self::$data['options'])) {
         $option['value'] = '';
         if (isset($option['default'])) {
             $option['value'] = $option['default'];
         }
         foreach (self::$data['options'] as $option) {
             $out .= '<tr>';
             $out .= '<th><h4 class="mtheme-shortcode-title">' . $option['name'] . '</h4></th>';
             $out .= '<td>' . MthemeInterface::renderOption($option) . '</td>';
             $out .= '</tr>';
         }
     }
     //render clone
     if (isset(self::$data['clone'])) {
         $ID = 'a' . uniqid();
         $out .= '<tr><td colspan="2"><div class="mtheme-shortcode-pane"><div class="mtheme-shortcode-clone" id="' . $ID . '">';
         $out .= '<div class="mtheme-shortcode-pattern hidden">' . self::$data['clone']['shortcode'] . '</div>';
         $out .= '<div class="mtheme-shortcode-value hidden"></div>';
         $out .= '<a href="#" class="mtheme-button mtheme-remove-button mtheme-trigger" data-element="' . $ID . '" title="' . __('Remove', 'mtheme') . '"></a>';
         $out .= '<a href="#" class="mtheme-button mtheme-clone-button mtheme-trigger" data-element="' . $ID . '" data-value="' . $ID . '" title="' . __('Add', 'mtheme') . '"></a>';
         foreach (self::$data['clone']['options'] as $option) {
             $out .= MthemeInterface::renderOption($option);
         }
         $out .= '</div></div></td></tr>';
     }
     $out .= '<tr><th></th><td><div class="mtheme-option mtheme-submit"><input type="submit" class="mtheme-button" value="' . __('Insert Shortcode', 'mtheme') . '" /></div></td></tr>';
     $out .= '</tbody></table>';
     $out .= '<div class="mtheme-shortcode-pattern hidden">' . self::$data['shortcode'] . '</div>';
     $out .= '<div class="mtheme-shortcode-value hidden"></div>';
     return $out;
 }