コード例 #1
0
ファイル: themify-utils.php プロジェクト: rinodung/live-theme
function themify_meta_boxes()
{
    global $post, $themify_write_panels, $typenow;
    echo '<div id="themify-meta-box-tabs">';
    echo '<ul class="ilc-htabs themify-tabs-heading">';
    foreach ($themify_write_panels as $write_panel) {
        if (trim($write_panel['pages']) == $typenow) {
            echo '<li><span><a id="' . sanitize_title($write_panel['name']) . 't" href="#' . sanitize_title($write_panel['name']) . '">' . $write_panel['name'] . '</a></span></li>';
        }
    }
    echo '</ul>';
    echo '<div class="ilc-btabs themify-tabs-body">';
    foreach ($themify_write_panels as $write_panel) {
        $pages = explode(",", $write_panel['pages']);
        $check = false;
        foreach ($pages as $page) {
            if (get_post_type($post)) {
                if (get_post_type($post) == $page) {
                    $check = true;
                }
            } else {
                if (trim($page) == 'post' && $_GET['post_type'] == '' || $_GET['post_type'] == trim($page)) {
                    $check = true;
                }
            }
        }
        if ($check) {
            ?>
            <div id="<?php 
            echo sanitize_title($write_panel['name']);
            ?>
" class="ilc-tab themify_write_panel">
            
            <div class="inside">
            	
				<input type="hidden" name="themify_proper_save" value="true" />

                <?php 
            $themify_custom_panel_nonce = wp_create_nonce("themify-custom-panel");
            ?>
                
                <!-- alerts -->
                <div class="alert"></div> 
                <!-- /alerts -->
                
                <?php 
            foreach ($write_panel['options'] as $meta_box) {
                ?>
                    <?php 
                $meta_value = get_post_meta($post->ID, $meta_box['name'], true);
                ?>
                    <?php 
                $toggle_class = '';
                $ext_attr = '';
                $toggle_enable = false;
                if (isset($meta_box['toggle'])) {
                    $toggle_class .= 'themify-toggle ';
                    $toggle_class .= is_array($meta_box['toggle']) ? implode(' ', $meta_box['toggle']) : $meta_box['toggle'];
                }
                if (isset($meta_box['default_toggle']) && $meta_box['default_toggle'] == 'hidden') {
                    $ext_attr = 'style="display:none;"';
                }
                if (isset($meta_box['enable_toggle']) && $meta_box['enable_toggle'] == true) {
                    $toggle_class .= ' enable_toggle';
                    $toggle_enable = true;
                }
                ?>

                    <?php 
                ///////////////////////////////////////////
                // Image Template
                ///////////////////////////////////////////
                if ($meta_box['type'] == 'image') {
                    ?>
					<div class="featimgcontrol">
						<input type="hidden" name="<?php 
                    echo $meta_box['name'];
                    ?>
_noncename" id="<?php 
                    echo $meta_box['name'];
                    ?>
_noncename" value="<?php 
                    echo wp_create_nonce(plugin_basename(__FILE__));
                    ?>
" />
                        <div class="themify_field_row clearfix <?php 
                    echo $toggle_class;
                    ?>
" <?php 
                    echo $ext_attr;
                    ?>
>
                                                  
							<div class="themify_field_title"><?php 
                    echo $meta_box['title'];
                    ?>
</div>
                                
                            	<div class="themify_field">
                                	
                            	<?php 
                    /** Parameters for the uploader @var Array */
                    $featimg_uploader_args = array('tomedia' => true, 'topost' => $post->ID, 'medialib' => true, 'fields' => $meta_box['name']);
                    $themify_featimg_field = themify_is_thumbnail_field($meta_box['name']);
                    if ($themify_featimg_field) {
                        $featimg_uploader_args['featured'] = $meta_box['name'];
                    }
                    if (has_post_thumbnail() && $themify_featimg_field) {
                        $this_attachment_id = get_post_thumbnail_id($post->ID);
                        $thumb = wp_get_attachment_image_src($this_attachment_id, 'thumbnail');
                        $thumb_src = $thumb[0];
                    } elseif (!$themify_featimg_field && ($this_attachment_id = get_post_meta($post->ID, '_' . $meta_box['name'] . '_attach_id', true))) {
                        $thumb = wp_get_attachment_image_src($this_attachment_id, 'thumbnail');
                        $thumb_src = $thumb[0];
                    } else {
                        $thumb_src = $meta_value;
                    }
                    ?>

									<div id="remove-<?php 
                    echo $meta_box['name'];
                    ?>
" class="themify_featimg_remove <?php 
                    if ($thumb_src == '') {
                        echo 'hide';
                    }
                    ?>
">
                		<a data-attachid="<?php 
                    echo get_post_meta($post->ID, '_' . $meta_box['name'] . '_attach_id', true);
                    ?>
" href="#"><?php 
                    _e('Remove image', 'themify');
                    ?>
</a>
                	</div>

									<?php 
                    if ($thumb_src) {
                        $thumb = wp_get_attachment_image_src($this_attachment_id, 'full');
                        if ($thumb[0]) {
                            $full_src = $thumb[0];
                        } else {
                            $full_src = $thumb_src;
                        }
                        echo '<div class="themify_upload_preview" style="display:block;"><a href="' . $full_src . '" target="_blank"><img src="' . $thumb_src . '" width="40"  alt="' . __('Post Image', 'themify') . '" /></a></div>';
                    } else {
                        echo '<div class="themify_upload_preview"></div>';
                    }
                    ?>
									
                            	<!-- Field storing URL -->
                                <input type="hidden" id="<?php 
                    echo $meta_box['name'];
                    ?>
" name="<?php 
                    echo $meta_box['name'];
                    ?>
" value="<?php 
                    echo $meta_value;
                    ?>
" size="55" class="themify_input_field themify_upload_field" />
                                <?php 
                    // Check quota for this blog if multisite
                    if (is_multisite() && !is_upload_space_available()) {
                        echo '<p>' . sprintf(__('Sorry, you have filled your %s MB storage quota so uploading has been disabled.', 'themify'), get_space_allowed()) . '</p>';
                    } else {
                        ?>
                                    <div class="themify_upload_buttons">
                                    	<?php 
                        themify_uploader($meta_box['name'], $featimg_uploader_args);
                        ?>
                                    </div>
                                <?php 
                    }
                    ?>
                          
								<span class="themify_field_description">
									<?php 
                    echo $meta_box['description'];
                    ?>
								</span>
							</div>
                          
                          </div><!--/themify_field_row -->
                          
                          
						<script type="text/javascript">
						jQuery(function($){
                          	$('#remove-<?php 
                    echo $meta_box['name'];
                    ?>
 a').on('click', function(e){
		                    	e.preventDefault();
		                    	
		                    	//Save value of this to use it on the response callback 
		                    	$this = $(this);

		                    	$.post(
									ajaxurl, {
										'action': 'themify_remove_post_image',
										'postid': <?php 
                    echo $post->ID;
                    ?>
,
										<?php 
                    if (!$themify_featimg_field) {
                        echo '\'attach_id\': $this.data(\'attachid\'),';
                    }
                    ?>
										'customfield' : '<?php 
                    echo $meta_box['name'];
                    ?>
',
										'nonce' : '<?php 
                    echo $themify_custom_panel_nonce;
                    ?>
'
									},
									function(data) {
										$this.parent().parent().find('.themify_upload_field').val('');
										$this.parent().parent().find('.themify_upload_preview').fadeOut();
										$('#remove-<?php 
                    echo $meta_box['name'];
                    ?>
').addClass('hide');
									}
								);
		                  	});
						});
						</script>
                          
                    </div><!-- Themify Image END -->
                   	<?php 
                    ///////////////////////////////////////////
                    // Image Size Dropdown Template
                    ///////////////////////////////////////////
                    ?>
                    <?php 
                } else {
                    if ($meta_box['type'] == 'featimgdropdown') {
                        /** Define WP Featured Image sizes + blank + Themify's img.php
                         * @var array */
                        $themify_fi_sizes = array(array('value' => '', 'name' => ''), array('value' => 'thumbnail', 'name' => __('Thumbnail', 'themify')), array('value' => 'medium', 'name' => __('Medium', 'themify')), array('value' => 'large', 'name' => __('Large', 'themify')), array('value' => 'full', 'name' => __('Original Image', 'themify')));
                        ?>
                        <div <?php 
                        if (!themify_check('setting-img_settings_use') || 'hidden' == $meta_box['class']) {
                            echo 'style="display:none"';
                        }
                        ?>
 class="<?php 
                        echo $meta_box['type'];
                        ?>
">
                            <input type="hidden" name="<?php 
                        echo $meta_box['name'];
                        ?>
_noncename" id="<?php 
                        echo $meta_box['name'];
                        ?>
_noncename" value="<?php 
                        echo wp_create_nonce(plugin_basename(__FILE__));
                        ?>
" />
                                <div class="themify_field_row clearfix <?php 
                        echo $toggle_class;
                        ?>
" <?php 
                        echo $ext_attr;
                        ?>
>
        
                                     <div class="themify_field_title"><?php 
                        echo $meta_box['title'];
                        ?>
</div>
                                     
                                     <div class="themify_field">
                                        <select name="<?php 
                        echo $meta_box['name'];
                        ?>
">
                                    <?php 
                        foreach ($themify_fi_sizes as $option) {
                            ?>
                                            <?php 
                            if ($option['value'] == $meta_value) {
                                $selected = "selected='selected'";
                            } else {
                                $selected = "";
                            }
                            ?>
                                             <option value="<?php 
                            echo $option['value'];
                            ?>
" <?php 
                            echo $selected;
                            ?>
><?php 
                            echo $option['name'];
                            ?>
</option>
                                            <?php 
                        }
                        ?>
   
                                        </select>
                                        <span class="themify_field_description"><?php 
                        echo $meta_box['description'];
                        ?>
</span>
                                    </div>
                              </div><!--/themify_field_row -->
                        </div>
                    <?php 
                        ///////////////////////////////////////////
                        // Dropdown Template
                        ///////////////////////////////////////////
                        ?>
                    <?php 
                    } else {
                        if ($meta_box['type'] == 'dropdown') {
                            ?>
                        
                            <input type="hidden" name="<?php 
                            echo $meta_box['name'];
                            ?>
_noncename" id="<?php 
                            echo $meta_box['name'];
                            ?>
_noncename" value="<?php 
                            echo wp_create_nonce(plugin_basename(__FILE__));
                            ?>
" />
                                <div class="themify_field_row clearfix <?php 
                            echo $toggle_class;
                            ?>
" <?php 
                            echo $ext_attr;
                            ?>
>
        
                                     <div class="themify_field_title"><?php 
                            echo $meta_box['title'];
                            ?>
</div>
                                     
                                     <div class="themify_field">
                                        <select name="<?php 
                            echo $meta_box['name'];
                            ?>
">
                                    <?php 
                            foreach ($meta_box['meta'] as $option) {
                                ?>
                                            <?php 
                                if ($option['value'] == $meta_value) {
                                    $selected = "selected='selected'";
                                } else {
                                    $selected = "";
                                }
                                ?>
                                             <option value="<?php 
                                echo $option['value'];
                                ?>
" <?php 
                                echo $selected;
                                ?>
><?php 
                                echo $option['name'];
                                ?>
</option>
                                            <?php 
                            }
                            ?>
   
                                        </select>
                                        <span class="themify_field_description"><?php 
                            echo $meta_box['description'];
                            ?>
</span>
                                    </div>
                                    
                              </div><!--/themify_field_row -->
					<?php 
                            ///////////////////////////////////////////
                            // Info Template
                            ///////////////////////////////////////////
                            ?>
                    <?php 
                        } else {
                            if ($meta_box['type'] == 'post_id_info') {
                                ?>
                    	
                            <div class="themify_field_row clearfix <?php 
                                echo $toggle_class;
                                ?>
" <?php 
                                echo $ext_attr;
                                ?>
>
    
                                <div class="themify_field_title"><?php 
                                echo $meta_box['title'];
                                ?>
</div>
    
                                <div class="themify_field">
                                	<?php 
                                global $post_ID;
                                ?>
                                    <span class="themify_field_description themify_field_info"><?php 
                                printf($meta_box['description'], $post_ID);
                                ?>
</span>
                                </div>
    
                          </div><!--/themify_field_row -->
                    <?php 
                                ///////////////////////////////////////////
                                // Textbox Template
                                ///////////////////////////////////////////
                                ?>
                    <?php 
                            } else {
                                if ($meta_box['type'] == 'textbox') {
                                    ?>
                        
                            <input type="hidden" name="<?php 
                                    echo $meta_box['name'];
                                    ?>
_noncename" id="<?php 
                                    echo $meta_box['name'];
                                    ?>
_noncename" value="<?php 
                                    echo wp_create_nonce(plugin_basename(__FILE__));
                                    ?>
" />
                               
                               <div class="themify_field_row clearfix <?php 
                                    echo $toggle_class;
                                    ?>
" <?php 
                                    echo $ext_attr;
                                    ?>
>
        
                                    <div class="themify_field_title"><?php 
                                    echo $meta_box['title'];
                                    ?>
</div>
        
                                    <div class="themify_field">
                                        <?php 
                                    if ($meta_box['meta']['size'] != '' && $meta_box['meta']['size'] == 'small') {
                                        $class = "small";
                                    } else {
                                        $class = "";
                                    }
                                    ?>
                                        <input type="text" name="<?php 
                                    echo $meta_box['name'];
                                    ?>
" value="<?php 
                                    echo $meta_value;
                                    ?>
" size="55" class="themify_input_field <?php 
                                    echo $class;
                                    ?>
" />
                                        <span class="themify_field_description"><?php 
                                    echo $meta_box['description'];
                                    ?>
</span>
                                    </div>
        
                              </div><!--/themify_field_row -->
                    <?php 
                                    ///////////////////////////////////////////
                                    // Textarea Template
                                    ///////////////////////////////////////////
                                    ?>
                    <?php 
                                } else {
                                    if ($meta_box['type'] == 'textarea') {
                                        ?>
                        
                            <input type="hidden" name="<?php 
                                        echo $meta_box['name'];
                                        ?>
_noncename" id="<?php 
                                        echo $meta_box['name'];
                                        ?>
_noncename" value="<?php 
                                        echo wp_create_nonce(plugin_basename(__FILE__));
                                        ?>
" />
                               
                               <div class="themify_field_row clearfix <?php 
                                        echo $toggle_class;
                                        ?>
" <?php 
                                        echo $ext_attr;
                                        ?>
>
        
                                    <div class="themify_field_title"><?php 
                                        echo $meta_box['title'];
                                        ?>
</div>
        
                                    <div class="themify_field">
                                        <?php 
                                        if ($meta_box['meta']['size'] != '' && $meta_box['meta']['size'] == 'small') {
                                            $class = "small";
                                        } else {
                                            $class = "";
                                        }
                                        ?>
                                        <textarea name="<?php 
                                        echo $meta_box['name'];
                                        ?>
" size="55" rows="4" class="themify_input_field <?php 
                                        echo $class;
                                        ?>
"><?php 
                                        echo $meta_value;
                                        ?>
</textarea>
                                        <span class="themify_field_description"><?php 
                                        echo $meta_box['description'];
                                        ?>
</span>
                                    </div>
        
                              </div><!--/themify_field_row -->
					<?php 
                                        ///////////////////////////////////////////
                                        // Gallery Shortcode Template
                                        ///////////////////////////////////////////
                                        ?>
                    <?php 
                                    } else {
                                        if ($meta_box['type'] == 'gallery_shortcode') {
                                            ?>
                        
                            <input type="hidden" name="<?php 
                                            echo $meta_box['name'];
                                            ?>
_noncename" id="<?php 
                                            echo $meta_box['name'];
                                            ?>
_noncename" value="<?php 
                                            echo wp_create_nonce(plugin_basename(__FILE__));
                                            ?>
" />
                               
                               <div class="themify_field_row clearfix <?php 
                                            echo $toggle_class;
                                            ?>
" <?php 
                                            echo $ext_attr;
                                            ?>
>
        
                                    <div class="themify_field_title"><?php 
                                            echo $meta_box['title'];
                                            ?>
</div>
        
                                    <div class="themify_field">
                                        <?php 
                                            if ($meta_box['meta']['size'] != '' && $meta_box['meta']['size'] == 'small') {
                                                $class = "small";
                                            } else {
                                                $class = "";
                                            }
                                            ?>
                                        <textarea name="<?php 
                                            echo $meta_box['name'];
                                            ?>
" size="55" rows="4" class="themify_input_field themify-gallery-shortcode-input <?php 
                                            echo $class;
                                            ?>
"><?php 
                                            echo $meta_value;
                                            ?>
</textarea>

										<div class="themify-gallery-shortcode-btn">
											<a href="#" class="themify-gallery-shortcode-btn"><?php 
                                            _e('Insert Gallery', 'themify');
                                            ?>
</a>						
										</div>
                                        
                                        <span class="themify_field_description"><?php 
                                            echo $meta_box['description'];
                                            ?>
</span>
                                    </div>
        
                              </div><!--/themify_field_row -->
                    <?php 
                                            ///////////////////////////////////////////
                                            // Checkbox Template
                                            ///////////////////////////////////////////
                                            ?>
                    <?php 
                                        } else {
                                            if ($meta_box['type'] == 'checkbox') {
                                                ?>
                        
                            <input type="hidden" name="<?php 
                                                echo $meta_box['name'];
                                                ?>
_noncename" id="<?php 
                                                echo $meta_box['name'];
                                                ?>
_noncename" value="<?php 
                                                echo wp_create_nonce(plugin_basename(__FILE__));
                                                ?>
" />
                              <div class="themify_field_row clearfix <?php 
                                                echo $toggle_class;
                                                ?>
" <?php 
                                                echo $ext_attr;
                                                ?>
>
        
                                    <div class="themify_field_title"><?php 
                                                echo $meta_box['title'];
                                                ?>
</div>
                                    <?php 
                                                if ($meta_value) {
                                                    $checked = "checked='checked'";
                                                } else {
                                                    $checked = "";
                                                }
                                                ?>
        
                                    <div class="themify_field">
                                        <input type="checkbox" name="<?php 
                                                echo $meta_box['name'];
                                                ?>
" <?php 
                                                echo $checked;
                                                ?>
 class="<?php 
                                                echo $meta_box['name'];
                                                ?>
-toggle-control" data-val="<?php 
                                                echo $meta_box['name'];
                                                ?>
" />
                                        <span class="themify_checkbox_description"><?php 
                                                echo $meta_box['description'];
                                                ?>
</span>
                                    </div>
        
                              </div><!--/themify_field_row -->
        
                    <?php 
                                                ///////////////////////////////////////////
                                                // Layout Template
                                                ///////////////////////////////////////////
                                                ?>
                    <?php 
                                            } else {
                                                if ($meta_box['type'] == 'layout') {
                                                    ?>
                        
                        	<input type="hidden" name="<?php 
                                                    echo $meta_box['name'];
                                                    ?>
_noncename" id="<?php 
                                                    echo $meta_box['name'];
                                                    ?>
_noncename" value="<?php 
                                                    echo wp_create_nonce(plugin_basename(__FILE__));
                                                    ?>
" />
                            
                                <div class="themify_field_row clearfix <?php 
                                                    echo $toggle_class;
                                                    ?>
" <?php 
                                                    echo $ext_attr;
                                                    ?>
> 
                                    <div class="themify_field_title"><?php 
                                                    echo $meta_box['title'];
                                                    ?>
</div>
                                    <div class="themify_field">
                                        <?php 
                                                    foreach ($meta_box['meta'] as $options) {
                                                        ?>
                                        	<?php 
                                                        if (($meta_value == "" || !$meta_value || !isset($meta_value)) && $options['selected']) {
                                                            $meta_value = $options['value'];
                                                        }
                                                        if ($meta_value == $options['value']) {
                                                            $class = "selected";
                                                        } else {
                                                            $class = "";
                                                        }
                                                        ?>
                                            <a href="#" class="preview-icon <?php 
                                                        echo $class;
                                                        ?>
"><img src="<?php 
                                                        echo get_template_directory_uri() . "/" . $options['img'];
                                                        ?>
" <?php 
                                                        echo isset($meta_box['show_title']) ? 'title="' . ucwords(str_replace('-', ' ', $options['value'])) . '"' : '';
                                                        ?>
 alt="<?php 
                                                        echo $options['value'];
                                                        ?>
"  /></a>
                                        <?php 
                                                    }
                                                    ?>
                                        <input type="hidden" name="<?php 
                                                    echo $meta_box['name'];
                                                    ?>
" value="<?php 
                                                    echo $meta_value;
                                                    ?>
" class="val" />
                                        <span class="themify_field_description"><?php 
                                                    echo $meta_box['description'];
                                                    ?>
</span>
                                    </div>
                                </div>
                                    
                    <?php 
                                                    ///////////////////////////////////////////
                                                    // Query Posts Template
                                                    ///////////////////////////////////////////
                                                    ?>
                    <?php 
                                                } else {
                                                    if ($meta_box['type'] == 'query_category') {
                                                        ?>
                                
                             <input type="hidden" name="<?php 
                                                        echo $meta_box['name'];
                                                        ?>
_noncename" id="<?php 
                                                        echo $meta_box['name'];
                                                        ?>
_noncename" value="<?php 
                                                        echo wp_create_nonce(plugin_basename(__FILE__));
                                                        ?>
" />
                              
                                <div class="themify_field_row clearfix <?php 
                                                        echo $toggle_class;
                                                        ?>
" <?php 
                                                        echo $ext_attr;
                                                        ?>
>    
                                    <div class="themify_field_title"><?php 
                                                        echo $meta_box['title'];
                                                        ?>
</div>
                                    <div class="themify_field">
                                        <?php 
                                                        echo preg_replace('/>/', '><option></option>', wp_dropdown_categories(array('taxonomy' => isset($meta_box['meta']['taxonomy']) ? $meta_box['meta']['taxonomy'] : 'category', 'class' => 'query_category_single', 'show_option_all' => __('All Categories', 'themify'), 'hide_empty' => 0, 'echo' => 0, 'name' => $meta_box['name'], 'selected' => $meta_value)), 1);
                                                        ?>
 or 
                                        <input type="text" class="query_category" value="<?php 
                                                        echo $meta_value;
                                                        ?>
" />
                                        <input type="hidden" value="<?php 
                                                        echo $meta_value;
                                                        ?>
" name="<?php 
                                                        echo $meta_box['name'];
                                                        ?>
" class="val" />
                                        <span class="themify_field_description"><?php 
                                                        echo $meta_box['description'];
                                                        ?>
</span>
                                    </div>
                                </div>
                    
                    <?php 
                                                        ///////////////////////////////////////////
                                                        // Sidebar Visibility Template
                                                        ///////////////////////////////////////////
                                                        ?>
                    <?php 
                                                    } else {
                                                        if ($meta_box['type'] == 'sidebar_visibility') {
                                                            ?>
                    
                    		<input type="hidden" name="<?php 
                                                            echo $meta_box['name'];
                                                            ?>
_noncename" id="<?php 
                                                            echo $meta_box['name'];
                                                            ?>
_noncename" value="<?php 
                                                            echo wp_create_nonce(plugin_basename(__FILE__));
                                                            ?>
" />
                            
                                <div class="themify_field_row clearfix <?php 
                                                            echo $toggle_class;
                                                            ?>
" <?php 
                                                            echo $ext_attr;
                                                            ?>
>  
                                    <div class="themify_field_title"><?php 
                                                            echo $meta_box['title'];
                                                            ?>
</div>
                                    <div class="themify_field">
                                    <?php 
                                                            $sidebars = get_option('sidebars_widgets');
                                                            global $wp_registered_sidebars;
                                                            foreach ($sidebars as $sidebar => $val) {
                                                                if ($sidebar != 'wp_inactive_widgets' && $sidebar != 'array_version' && strpos(strtolower($wp_registered_sidebars[$sidebar]['name']), 'sidebar') !== false) {
                                                                    $checked = "";
                                                                    if (get_post_meta($post->ID, $meta_box['name'], true) == "" || !get_post_meta($post->ID, $meta_box['name'], true)) {
                                                                        $checked = "checked='checked'";
                                                                    } else {
                                                                        foreach ($meta_value as $key => $val) {
                                                                            if (str_replace("'", "", $key) == $wp_registered_sidebars[$sidebar]['name']) {
                                                                                $checked = "checked='checked'";
                                                                            }
                                                                        }
                                                                    }
                                                                    ?>
                                        <input type="checkbox" name="<?php 
                                                                    echo $meta_box['name'];
                                                                    ?>
[<?php 
                                                                    echo $wp_registered_sidebars[$sidebar]['name'];
                                                                    ?>
]" class="" <?php 
                                                                    echo $checked;
                                                                    ?>
 /> <?php 
                                                                    echo $wp_registered_sidebars[$sidebar]['name'];
                                                                    ?>
<br />
                                    <?php 
                                                                }
                                                            }
                                                            ?>
                                    <span class="themify_field_description"><?php 
                                                            echo $meta_box['description'];
                                                            ?>
</span>
                                    </div>	
                                </div>
                    
                    <?php 
                                                            ///////////////////////////////////////////
                                                            // Radio Template
                                                            ///////////////////////////////////////////
                                                            ?>
        
                    <?php 
                                                        } else {
                                                            if ($meta_box['type'] == 'radio') {
                                                                ?>

                    	<input type="hidden" name="<?php 
                                                                echo $meta_box['name'];
                                                                ?>
_noncename" id="<?php 
                                                                echo $meta_box['name'];
                                                                ?>
_noncename" value="<?php 
                                                                echo wp_create_nonce(plugin_basename(__FILE__));
                                                                ?>
" />
                      <div class="themify_field_row clearfix <?php 
                                                                echo $toggle_class;
                                                                ?>
" <?php 
                                                                echo $ext_attr;
                                                                ?>
>

                            <div class="themify_field_title"><?php 
                                                                echo $meta_box['title'];
                                                                ?>
</div>
                            
                            <div class="themify_field">
                            	<?php 
                                                                foreach ($meta_box['meta'] as $k => $option) {
                                                                    //$k = ($k == '') ? 0 : $k;
                                                                    if (isset($option['selected']) && $option['selected'] && '' == $meta_value) {
                                                                        $radio_selected = 'checked="checked"';
                                                                    } else {
                                                                        $radio_selected = checked($meta_value, $option['value'], false);
                                                                    }
                                                                    ?>
                            	<input type="radio" name="<?php 
                                                                    echo $meta_box['name'];
                                                                    ?>
" id="<?php 
                                                                    echo $meta_box['name'];
                                                                    ?>
-<?php 
                                                                    echo esc_attr($option['value']);
                                                                    ?>
" value="<?php 
                                                                    echo $option['value'];
                                                                    ?>
" <?php 
                                                                    echo $radio_selected;
                                                                    ?>
 /> <label for="<?php 
                                                                    echo $meta_box['name'];
                                                                    ?>
-<?php 
                                                                    echo esc_attr($option['value']);
                                                                    ?>
" class="selectit"><?php 
                                                                    echo $option['name'];
                                                                    ?>
</label>
                            	<?php 
                                                                }
                                                                ?>
                                <span class="themify_checkbox_description"><?php 
                                                                echo $meta_box['description'];
                                                                ?>
</span>
                            </div>

                      </div><!--/themify_field_row -->

                    <?php 
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                ?>
                
                <?php 
            }
            ?>
            </div>
            </div>
			<?php 
        }
    }
    echo '</div>';
    //end .ilc-btabs
    echo '</div>';
    //end #themify-meta-box-tabs
    echo '<script type="text/javascript">';
    echo 'jQuery(document).ready(function(){';
    echo 'if(jQuery(".ilc-htabs li").length > 1)';
    echo 'ilcTabs({ilctabs  : "#themify-meta-box-tabs"});';
    echo 'else{';
    echo 'jQuery(".ilc-tab").show();';
    echo 'jQuery(".ilc-htabs li").addClass("select");';
    echo '}';
    echo '});';
    echo '</script>';
}
コード例 #2
0
ファイル: themify-utils.php プロジェクト: tchataigner/palette
function themify_meta_field_video($args, $call_before_after = true, $echo = true)
{
    $meta_box = $args['meta_box'];
    $meta_value = $args['meta_value'];
    extract($args, EXTR_OVERWRITE);
    ob_start();
    /** Parameters for the uploader @var Array */
    $featimg_uploader_args = array('tomedia' => true, 'topost' => $post_id, 'medialib' => true, 'fields' => $meta_box['name'], 'formats' => 'mp4,m4v,webm,ogv,wmv,flv', 'type' => 'video');
    ?>

	<div id="<?php 
    echo esc_attr('remove-' . $meta_box['name']);
    ?>
" class="themify_featimg_remove themify_video_remove <?php 
    if ($meta_value == '') {
        echo 'hide';
    }
    ?>
">
		<a href="#"><?php 
    _e('Remove Video', 'themify');
    ?>
</a>
	</div>

	<!-- Field storing URL -->
	<input type="text" id="<?php 
    echo esc_attr($meta_box['name']);
    ?>
" name="<?php 
    echo $meta_box['name'];
    ?>
" value="<?php 
    echo esc_attr($meta_value);
    ?>
" size="55" class="themify_input_field themify_upload_field" />

	<div class="themify_upload_buttons">
		<?php 
    themify_uploader($meta_box['name'], $featimg_uploader_args);
    ?>
	</div>

	<script type="text/javascript">
		jQuery(function($){
			$('#remove-<?php 
    echo esc_js($meta_box['name']);
    ?>
').find('a').on('click', function(e){
				e.preventDefault();
				var $self = $(this).parent();
				$self.parent().find('.themify_upload_field').val('');
				$self.addClass('hide');

				$.post(
					ajaxurl, {
						'action': 'themify_remove_video',
						'postid': <?php 
    echo esc_js($post_id);
    ?>
,
						'customfield' : '<?php 
    echo esc_js($meta_box['name']);
    ?>
',
						'nonce' : '<?php 
    echo esc_js($args['themify_custom_panel_nonce']);
    ?>
'
					},
					function() {
						$self.parent().find('.themify_upload_field').val('');
						$self.addClass('hide');
					}
				);
			});
		});
	</script>
	<?php 
    $html = ob_get_contents();
    ob_end_clean();
    $html .= isset($meta_box['description']) ? themify_meta_field_get_description($meta_box['description']) : '';
    if (isset($meta_box['before']) && $meta_box['before']) {
        $html = $meta_box['before'] . $html;
    }
    if (isset($meta_box['after']) && $meta_box['after']) {
        $html .= $meta_box['after'];
    }
    if ($call_before_after) {
        $html = themify_before_meta_field($args) . $html . themify_after_meta_field();
    }
    $html = $html . '<!-- Themify Video END -->';
    if ($echo) {
        echo $html;
    }
    return $html;
}
コード例 #3
0
ファイル: themify-utils.php プロジェクト: byronmisiva/msv-dev
function themify_meta_boxes()
{
    global $post, $themify_write_panels, $typenow;
    echo '<div id="themify-meta-box-tabs">';
    echo '<ul class="ilc-htabs themify-tabs-heading">';
    foreach ($themify_write_panels as $write_panel) {
        if (trim($write_panel['pages']) == $typenow) {
            $panel_id = isset($write_panel['id']) ? $write_panel['id'] : sanitize_title($write_panel['name']);
            echo '<li><span><a id="' . $panel_id . 't" href="#' . $panel_id . '">' . $write_panel['name'] . '</a></span></li>';
        }
    }
    echo '</ul>';
    echo '<div class="ilc-btabs themify-tabs-body">';
    foreach ($themify_write_panels as $write_panel) {
        $pages = explode(",", $write_panel['pages']);
        $check = false;
        foreach ($pages as $page) {
            if (get_post_type($post)) {
                if (get_post_type($post) == $page) {
                    $check = true;
                }
            } else {
                if (trim($page) == 'post' && $_GET['post_type'] == '' || $_GET['post_type'] == trim($page)) {
                    $check = true;
                }
            }
        }
        if ($check) {
            $panel_id = isset($write_panel['id']) ? $write_panel['id'] : sanitize_title($write_panel['name']);
            ?>
            <div id="<?php 
            echo $panel_id;
            ?>
" class="ilc-tab themify_write_panel">
            
            <div class="inside">
            	
				<input type="hidden" name="themify_proper_save" value="true" />

                <?php 
            $themify_custom_panel_nonce = wp_create_nonce("themify-custom-panel");
            ?>
                
                <!-- alerts -->
                <div class="alert"></div> 
                <!-- /alerts -->
                
                <?php 
            foreach ($write_panel['options'] as $meta_box) {
                if (isset($meta_box['name'])) {
                    $meta_value = get_post_meta($post->ID, $meta_box['name'], true);
                }
                $toggle_class = '';
                $ext_attr = '';
                $toggle_enable = false;
                if (isset($meta_box['toggle'])) {
                    $toggle_class .= 'themify-toggle ';
                    $toggle_class .= is_array($meta_box['toggle']) ? implode(' ', $meta_box['toggle']) : $meta_box['toggle'];
                }
                if (isset($meta_box['default_toggle']) && $meta_box['default_toggle'] == 'hidden') {
                    $ext_attr = 'style="display:none;"';
                }
                if (isset($meta_box['enable_toggle']) && $meta_box['enable_toggle'] == true) {
                    $toggle_class .= ' enable_toggle';
                    $toggle_enable = true;
                }
                ?>

                    <?php 
                ///////////////////////////////////////////
                // Image Template
                ///////////////////////////////////////////
                if ($meta_box['type'] == 'image') {
                    ?>
					<div class="featimgcontrol">
						<input type="hidden" name="<?php 
                    echo $meta_box['name'];
                    ?>
_noncename" id="<?php 
                    echo $meta_box['name'];
                    ?>
_noncename" value="<?php 
                    echo wp_create_nonce(plugin_basename(__FILE__));
                    ?>
" />
                        <div class="themify_field_row clearfix <?php 
                    echo $toggle_class;
                    ?>
" <?php 
                    echo $ext_attr;
                    ?>
>
                                                  
							<div class="themify_field_title"><?php 
                    echo $meta_box['title'];
                    ?>
</div>
                                
                            	<div class="themify_field">
                                	
                            	<?php 
                    /** Parameters for the uploader @var Array */
                    $featimg_uploader_args = array('tomedia' => true, 'topost' => $post->ID, 'medialib' => true, 'fields' => $meta_box['name']);
                    $themify_featimg_field = themify_is_thumbnail_field($meta_box['name']);
                    if ($themify_featimg_field) {
                        $featimg_uploader_args['featured'] = $meta_box['name'];
                    }
                    $this_attachment_id = '';
                    if (has_post_thumbnail() && $themify_featimg_field) {
                        $this_attachment_id = get_post_thumbnail_id($post->ID);
                        $thumb = wp_get_attachment_image_src($this_attachment_id, 'thumbnail');
                        $thumb_src = $thumb[0];
                    } elseif (!$themify_featimg_field && ($this_attachment_id = get_post_meta($post->ID, '_' . $meta_box['name'] . '_attach_id', true))) {
                        $thumb = wp_get_attachment_image_src($this_attachment_id, 'thumbnail');
                        $thumb_src = $thumb[0];
                    } else {
                        $thumb_src = $meta_value;
                    }
                    ?>

									<div id="remove-<?php 
                    echo $meta_box['name'];
                    ?>
" class="themify_featimg_remove <?php 
                    if ($thumb_src == '') {
                        echo 'hide';
                    }
                    ?>
">
                		<a data-attachid="<?php 
                    echo get_post_meta($post->ID, '_' . $meta_box['name'] . '_attach_id', true);
                    ?>
" href="#"><?php 
                    _e('Remove image', 'themify');
                    ?>
</a>
                	</div>

									<?php 
                    if ($thumb_src) {
                        $thumb = wp_get_attachment_image_src($this_attachment_id, 'full');
                        if ($thumb[0]) {
                            $full_src = $thumb[0];
                        } else {
                            $full_src = $thumb_src;
                        }
                        echo '<div class="themify_upload_preview" style="display:block;"><a href="' . $full_src . '" target="_blank"><img src="' . $thumb_src . '" width="40"  alt="' . __('Post Image', 'themify') . '" /></a></div>';
                    } else {
                        echo '<div class="themify_upload_preview"></div>';
                    }
                    ?>
									
                            	<!-- Field storing URL -->
                                <input type="hidden" id="<?php 
                    echo $meta_box['name'];
                    ?>
" name="<?php 
                    echo $meta_box['name'];
                    ?>
" value="<?php 
                    echo $meta_value;
                    ?>
" size="55" class="themify_input_field themify_upload_field" />

								<div class="themify_upload_buttons">
									<?php 
                    themify_uploader($meta_box['name'], $featimg_uploader_args);
                    ?>
								</div>
                          
								<span class="themify_field_description">
									<?php 
                    echo $meta_box['description'];
                    ?>
								</span>
							</div>
                          
                          </div><!--/themify_field_row -->
                          
                          
						<script type="text/javascript">
						jQuery(function($){
                          	$('#remove-<?php 
                    echo $meta_box['name'];
                    ?>
 a').on('click', function(e){
		                    	e.preventDefault();
		                    	
		                    	//Save value of this to use it on the response callback 
		                    	$this = $(this);

		                    	$.post(
									ajaxurl, {
										'action': 'themify_remove_post_image',
										'postid': <?php 
                    echo $post->ID;
                    ?>
,
										<?php 
                    if (!$themify_featimg_field) {
                        echo '\'attach_id\': $this.data(\'attachid\'),';
                    }
                    ?>
										'customfield' : '<?php 
                    echo $meta_box['name'];
                    ?>
',
										'nonce' : '<?php 
                    echo $themify_custom_panel_nonce;
                    ?>
'
									},
									function(data) {
										$this.parent().parent().find('.themify_upload_field').val('');
										$this.parent().parent().find('.themify_upload_preview').fadeOut();
										$('#remove-<?php 
                    echo $meta_box['name'];
                    ?>
').addClass('hide');
									}
								);
		                  	});
						});
						</script>
                          
                    </div><!-- Themify Image END -->
                   	<?php 
                    ///////////////////////////////////////////
                    // Image Size Dropdown Template
                    ///////////////////////////////////////////
                    ?>
                    <?php 
                } else {
                    if ($meta_box['type'] == 'featimgdropdown') {
                        /** Define WP Featured Image sizes + blank + Themify's img.php
                         * @var array */
                        $themify_fi_sizes = array(array('value' => '', 'name' => ''), array('value' => 'thumbnail', 'name' => __('Thumbnail', 'themify')), array('value' => 'medium', 'name' => __('Medium', 'themify')), array('value' => 'large', 'name' => __('Large', 'themify')), array('value' => 'full', 'name' => __('Original Image', 'themify')));
                        ?>
                        <div <?php 
                        if (!themify_check('setting-img_settings_use') || isset($meta_box['class']) && 'hidden' == $meta_box['class']) {
                            echo 'style="display:none"';
                        }
                        ?>
 class="<?php 
                        echo $meta_box['type'];
                        ?>
">
                            <input type="hidden" name="<?php 
                        echo $meta_box['name'];
                        ?>
_noncename" id="<?php 
                        echo $meta_box['name'];
                        ?>
_noncename" value="<?php 
                        echo wp_create_nonce(plugin_basename(__FILE__));
                        ?>
" />
                                <div class="themify_field_row clearfix <?php 
                        echo $toggle_class;
                        ?>
" <?php 
                        echo $ext_attr;
                        ?>
>
        
                                     <div class="themify_field_title"><?php 
                        echo $meta_box['title'];
                        ?>
</div>
                                     
                                     <div class="themify_field">
                                        <select name="<?php 
                        echo $meta_box['name'];
                        ?>
">
                                    <?php 
                        foreach ($themify_fi_sizes as $option) {
                            ?>
                                            <?php 
                            if ($option['value'] == $meta_value) {
                                $selected = "selected='selected'";
                            } else {
                                $selected = "";
                            }
                            ?>
                                             <option value="<?php 
                            echo $option['value'];
                            ?>
" <?php 
                            echo $selected;
                            ?>
><?php 
                            echo $option['name'];
                            ?>
</option>
                                            <?php 
                        }
                        ?>
   
                                        </select>
                                        <span class="themify_field_description"><?php 
                        echo $meta_box['description'];
                        ?>
</span>
                                    </div>
                              </div><!--/themify_field_row -->
                        </div>
					<?php 
                        ///////////////////////////////////////////
                        // Post Meta Checkboxes Template
                        ///////////////////////////////////////////
                        ?>
					<?php 
                    } else {
                        if ($meta_box['type'] == 'postmeta') {
                            ?>

						<input type="hidden" name="<?php 
                            echo $meta_box['name'];
                            ?>
_noncename" id="<?php 
                            echo $meta_box['name'];
                            ?>
_noncename" value="<?php 
                            echo wp_create_nonce(plugin_basename(__FILE__));
                            ?>
" />
						<div class="custom-post-meta-group themify_field_row clearfix <?php 
                            echo $toggle_class;
                            ?>
" <?php 
                            echo $ext_attr;
                            ?>
>

							<div class="themify_field_title"><?php 
                            echo $meta_box['title'];
                            ?>
</div>

							<div class="themify_field">
								<?php 
                            foreach ($meta_box['meta'] as $meta => $name) {
                                $metakey = $meta_box['name'] . '_' . $meta;
                                $meta_class = 'all' != $meta ? 'meta-sub meta-' . $meta : 'meta-all';
                                echo '
									<label for="' . $metakey . '">
										<input type="checkbox" value="no" class="' . $meta_class . '" id="' . $metakey . '" name="' . $metakey . '" /> ' . $name . '
									</label>';
                            }
                            ?>
								<br/>
								<input type="hidden" class="widefat" value="<?php 
                            echo $meta_value;
                            ?>
" id="<?php 
                            echo $meta_box['name'];
                            ?>
" name="<?php 
                            echo $meta_box['name'];
                            ?>
" />

								<span class="themify_field_description"><?php 
                            echo $meta_box['description'];
                            ?>
</span>
							</div>
						</div><!--/themify_field_row -->

					<?php 
                            ///////////////////////////////////////////
                            // Info Template
                            ///////////////////////////////////////////
                        } else {
                            if ($meta_box['type'] == 'post_id_info') {
                                ?>
                    	
                            <div class="themify_field_row clearfix <?php 
                                echo $toggle_class;
                                ?>
" <?php 
                                echo $ext_attr;
                                ?>
>
    
                                <div class="themify_field_title"><?php 
                                echo $meta_box['title'];
                                ?>
</div>
    
                                <div class="themify_field">
                                	<?php 
                                global $post_ID;
                                ?>
                                    <span class="themify_field_description themify_field_info"><?php 
                                printf($meta_box['description'], $post_ID);
                                ?>
</span>
                                </div>
    
                          </div><!--/themify_field_row -->
                    <?php 
                                ///////////////////////////////////////////
                                // Multi Template
                                ///////////////////////////////////////////
                                ?>
                    <?php 
                            } else {
                                if ($meta_box['type'] == 'multi') {
                                    echo themify_before_meta_field(array('meta_box' => $meta_box, 'toggle_class' => $toggle_class, 'ext_attr' => $ext_attr));
                                    foreach ($meta_box['meta']['fields'] as $field) {
                                        call_user_func('themify_meta_field_' . $field['type'], array('meta_box' => $field, 'meta_value' => get_post_meta($post->ID, $field['name'], true), 'call_before_after' => false));
                                        if (!($field === end($meta_box['meta']['fields']))) {
                                            echo $meta_box['meta']['separator'];
                                        }
                                    }
                                    if (isset($meta_box['meta']['description']) && '' != $meta_box['meta']['description']) {
                                        echo '<span class="themify_field_description">' . $meta_box['meta']['description'] . '</span>';
                                    }
                                    echo themify_after_meta_field($meta_box['meta']['after']);
                                    ?>
                     <?php 
                                    ///////////////////////////////////////////
                                    // Color Picker Template
                                    ///////////////////////////////////////////
                                    ?>
                    <?php 
                                } else {
                                    if ($meta_box['type'] == 'color') {
                                        themify_meta_field_color(array('meta_box' => $meta_box, 'meta_value' => $meta_value, 'toggle_class' => $toggle_class, 'ext_attr' => $ext_attr));
                                        ?>
                    <?php 
                                        ///////////////////////////////////////////
                                        // Dropdown Template
                                        ///////////////////////////////////////////
                                        ?>
					<?php 
                                    } else {
                                        if ($meta_box['type'] == 'dropdown') {
                                            themify_meta_field_dropdown(array('meta_box' => $meta_box, 'meta_value' => $meta_value, 'toggle_class' => $toggle_class, 'ext_attr' => $ext_attr));
                                            ?>
					<?php 
                                            ///////////////////////////////////////////
                                            // Dropdown Button Template
                                            ///////////////////////////////////////////
                                            ?>
					<?php 
                                        } else {
                                            if ($meta_box['type'] == 'dropdownbutton') {
                                                themify_meta_field_dropdownbutton(array('meta_box' => $meta_box, 'meta_value' => $meta_value, 'toggle_class' => $toggle_class, 'ext_attr' => $ext_attr));
                                                ?>
                    <?php 
                                                ///////////////////////////////////////////
                                                // Textbox Template
                                                ///////////////////////////////////////////
                                                ?>
                    <?php 
                                            } else {
                                                if ($meta_box['type'] == 'textbox') {
                                                    themify_meta_field_textbox(array('meta_box' => $meta_box, 'meta_value' => $meta_value, 'toggle_class' => $toggle_class, 'ext_attr' => $ext_attr));
                                                    ?>
                    <?php 
                                                    ///////////////////////////////////////////
                                                    // Textarea Template
                                                    ///////////////////////////////////////////
                                                    ?>
                    <?php 
                                                } else {
                                                    if ($meta_box['type'] == 'textarea') {
                                                        themify_meta_field_textarea(array('meta_box' => $meta_box, 'meta_value' => $meta_value, 'toggle_class' => $toggle_class, 'ext_attr' => $ext_attr));
                                                        ?>
					<?php 
                                                        ///////////////////////////////////////////
                                                        // Checkbox Template
                                                        ///////////////////////////////////////////
                                                        ?>
					<?php 
                                                    } else {
                                                        if ($meta_box['type'] == 'checkbox') {
                                                            themify_meta_field_checkbox(array('meta_box' => $meta_box, 'meta_value' => $meta_value, 'toggle_class' => $toggle_class, 'ext_attr' => $ext_attr));
                                                            ?>
					<?php 
                                                            ///////////////////////////////////////////
                                                            // Separator Template
                                                            ///////////////////////////////////////////
                                                            ?>
					<?php 
                                                        } else {
                                                            if ($meta_box['type'] == 'separator') {
                                                                themify_meta_field_separator(array('meta_box' => $meta_box, 'meta_value' => $meta_value, 'toggle_class' => $toggle_class, 'ext_attr' => $ext_attr));
                                                                ?>
					<?php 
                                                                ///////////////////////////////////////////
                                                                // Layout Template
                                                                ///////////////////////////////////////////
                                                                ?>
                    <?php 
                                                            } else {
                                                                if ($meta_box['type'] == 'layout') {
                                                                    themify_meta_field_layout(array('meta_box' => $meta_box, 'meta_value' => $meta_value, 'toggle_class' => $toggle_class, 'ext_attr' => $ext_attr));
                                                                    ?>
					<?php 
                                                                    ///////////////////////////////////////////
                                                                    // Gallery Shortcode Template
                                                                    ///////////////////////////////////////////
                                                                    ?>
                    <?php 
                                                                } else {
                                                                    if ($meta_box['type'] == 'gallery_shortcode') {
                                                                        wp_enqueue_script('gallery-shortcode');
                                                                        ?>
                        
                            <input type="hidden" name="<?php 
                                                                        echo $meta_box['name'];
                                                                        ?>
_noncename" id="<?php 
                                                                        echo $meta_box['name'];
                                                                        ?>
_noncename" value="<?php 
                                                                        echo wp_create_nonce(plugin_basename(__FILE__));
                                                                        ?>
" />
                               
                               <div class="themify_field_row clearfix <?php 
                                                                        echo $toggle_class;
                                                                        ?>
" <?php 
                                                                        echo $ext_attr;
                                                                        ?>
>
        
                                    <div class="themify_field_title"><?php 
                                                                        echo $meta_box['title'];
                                                                        ?>
</div>
        
                                    <div class="themify_field">
                                        <?php 
                                                                        if (isset($meta_box['meta']) && '' != $meta_box['meta']['size'] && 'small' == $meta_box['meta']['size']) {
                                                                            $class = 'small';
                                                                        } else {
                                                                            $class = '';
                                                                        }
                                                                        ?>
                                        <textarea name="<?php 
                                                                        echo $meta_box['name'];
                                                                        ?>
" size="55" rows="4" class="themify_input_field themify-gallery-shortcode-input <?php 
                                                                        echo $class;
                                                                        ?>
"><?php 
                                                                        echo $meta_value;
                                                                        ?>
</textarea>

										<div class="themify-gallery-shortcode-btn">
											<a href="#" class="themify-gallery-shortcode-btn"><?php 
                                                                        _e('Insert Gallery', 'themify');
                                                                        ?>
</a>						
										</div>
                                        
                                        <span class="themify_field_description"><?php 
                                                                        echo $meta_box['description'];
                                                                        ?>
</span>
                                    </div>
        
                              </div><!--/themify_field_row -->
                    <?php 
                                                                        ///////////////////////////////////////////
                                                                        // Query Posts Template
                                                                        ///////////////////////////////////////////
                                                                        ?>
                    <?php 
                                                                    } else {
                                                                        if ($meta_box['type'] == 'query_category') {
                                                                            ?>
                                
						<input type="hidden" name="<?php 
                                                                            echo $meta_box['name'];
                                                                            ?>
_noncename" id="<?php 
                                                                            echo $meta_box['name'];
                                                                            ?>
_noncename" value="<?php 
                                                                            echo wp_create_nonce(plugin_basename(__FILE__));
                                                                            ?>
" />
                              
						<div class="themify_field_row clearfix <?php 
                                                                            echo $toggle_class;
                                                                            ?>
" <?php 
                                                                            echo $ext_attr;
                                                                            ?>
>    
							<div class="themify_field_title"><?php 
                                                                            echo $meta_box['title'];
                                                                            ?>
</div>
							<div class="themify_field">
                                <?php 
                                                                            $terms_tax = isset($meta_box['meta']['taxonomy']) ? $meta_box['meta']['taxonomy'] : 'category';
                                                                            $terms_options = '';
                                                                            $terms_by_tax = get_terms($terms_tax);
                                                                            $terms_list = array();
                                                                            $terms_list['0'] = array('title' => __('All Categories', 'themify'), 'slug' => '0');
                                                                            foreach ($terms_by_tax as $term) {
                                                                                $terms_list[$term->term_id] = array('title' => $term->name, 'slug' => $term->slug);
                                                                            }
                                                                            foreach ($terms_list as $term_id => $term) {
                                                                                $term_selected = '';
                                                                                if (!is_numeric($meta_value)) {
                                                                                    if ($meta_value == $term['slug']) {
                                                                                        $term_selected = 'selected="selected"';
                                                                                    }
                                                                                } else {
                                                                                    if ($meta_value == $term_id) {
                                                                                        $term_selected = 'selected="selected"';
                                                                                    }
                                                                                }
                                                                                $terms_options .= sprintf('<option value="%s" data-termid="%s" %s>%s</option>', $term['slug'], $term_id, $term_selected, $term['title']);
                                                                            }
                                                                            //*/
                                                                            /*$terms_dropdown = wp_dropdown_categories(
                                                                            		array(
                                                                                                      	'taxonomy' => $terms_tax, 
                                                                                                      	'class' => 'query_category_single',
                                                                                                          'show_option_all' => __('All Categories', 'themify'),
                                                                                                          'hide_empty' => 0,
                                                                                                          'echo' => 0,
                                                                                                          'name' => $meta_box['name'],
                                                                                                          'selected' => $meta_value
                                                                            		));
                                                                                                      echo preg_replace('/>/', '><option></option>', $terms_dropdown, 1);//*/
                                                                            ?>
                                <select id="<?php 
                                                                            echo $meta_box['name'];
                                                                            ?>
" class="query_category_single">
									<option></option>
									<?php 
                                                                            echo $terms_options;
                                                                            ?>
                                </select>
                                <?php 
                                                                            _e('or', 'themify');
                                                                            ?>
 
                                <input type="text" class="query_category" value="<?php 
                                                                            echo $meta_value;
                                                                            ?>
" />
                                <input type="hidden" value="<?php 
                                                                            echo $meta_value;
                                                                            ?>
" name="<?php 
                                                                            echo $meta_box['name'];
                                                                            ?>
" class="val" />
                                <span class="themify_field_description"><?php 
                                                                            echo $meta_box['description'];
                                                                            ?>
</span>
							</div>
						</div>
                    
                    <?php 
                                                                            ///////////////////////////////////////////
                                                                            // Sidebar Visibility Template
                                                                            ///////////////////////////////////////////
                                                                            ?>
                    <?php 
                                                                        } else {
                                                                            if ($meta_box['type'] == 'sidebar_visibility') {
                                                                                ?>
                    
                    		<input type="hidden" name="<?php 
                                                                                echo $meta_box['name'];
                                                                                ?>
_noncename" id="<?php 
                                                                                echo $meta_box['name'];
                                                                                ?>
_noncename" value="<?php 
                                                                                echo wp_create_nonce(plugin_basename(__FILE__));
                                                                                ?>
" />
                            
                                <div class="themify_field_row clearfix <?php 
                                                                                echo $toggle_class;
                                                                                ?>
" <?php 
                                                                                echo $ext_attr;
                                                                                ?>
>  
                                    <div class="themify_field_title"><?php 
                                                                                echo $meta_box['title'];
                                                                                ?>
</div>
                                    <div class="themify_field">
                                    <?php 
                                                                                $sidebars = get_option('sidebars_widgets');
                                                                                global $wp_registered_sidebars;
                                                                                foreach ($sidebars as $sidebar => $val) {
                                                                                    if ($sidebar != 'wp_inactive_widgets' && $sidebar != 'array_version' && strpos(strtolower($wp_registered_sidebars[$sidebar]['name']), 'sidebar') !== false) {
                                                                                        $checked = "";
                                                                                        if (get_post_meta($post->ID, $meta_box['name'], true) == "" || !get_post_meta($post->ID, $meta_box['name'], true)) {
                                                                                            $checked = "checked='checked'";
                                                                                        } else {
                                                                                            foreach ($meta_value as $key => $val) {
                                                                                                if (str_replace("'", "", $key) == $wp_registered_sidebars[$sidebar]['name']) {
                                                                                                    $checked = "checked='checked'";
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                        ?>
                                        <input type="checkbox" name="<?php 
                                                                                        echo $meta_box['name'];
                                                                                        ?>
[<?php 
                                                                                        echo $wp_registered_sidebars[$sidebar]['name'];
                                                                                        ?>
]" class="" <?php 
                                                                                        echo $checked;
                                                                                        ?>
 /> <?php 
                                                                                        echo $wp_registered_sidebars[$sidebar]['name'];
                                                                                        ?>
<br />
                                    <?php 
                                                                                    }
                                                                                }
                                                                                ?>
                                    <span class="themify_field_description"><?php 
                                                                                echo $meta_box['description'];
                                                                                ?>
</span>
                                    </div>	
                                </div>
                    
                    <?php 
                                                                                ///////////////////////////////////////////
                                                                                // Radio Template
                                                                                ///////////////////////////////////////////
                                                                                ?>
        
                    <?php 
                                                                            } else {
                                                                                if ($meta_box['type'] == 'radio') {
                                                                                    ?>

                    	<input type="hidden" name="<?php 
                                                                                    echo $meta_box['name'];
                                                                                    ?>
_noncename" id="<?php 
                                                                                    echo $meta_box['name'];
                                                                                    ?>
_noncename" value="<?php 
                                                                                    echo wp_create_nonce(plugin_basename(__FILE__));
                                                                                    ?>
" />

	<div class="themify_field_row clearfix <?php 
                                                                                    echo $toggle_class;
                                                                                    ?>
" <?php 
                                                                                    echo $ext_attr;
                                                                                    ?>
>
	
		<div class="themify_field_title"><?php 
                                                                                    echo $meta_box['title'];
                                                                                    ?>
</div>
		
		<div class="themify_field">
                            	<?php 
                                                                                    foreach ($meta_box['meta'] as $k => $option) {
                                                                                        //$k = ($k == '') ? 0 : $k;
                                                                                        if (isset($option['selected']) && $option['selected'] && '' == $meta_value) {
                                                                                            $radio_selected = 'checked="checked"';
                                                                                        } else {
                                                                                            $radio_selected = checked($meta_value, $option['value'], false);
                                                                                        }
                                                                                        ?>
                            	<input type="radio" name="<?php 
                                                                                        echo $meta_box['name'];
                                                                                        ?>
" id="<?php 
                                                                                        echo $meta_box['name'];
                                                                                        ?>
-<?php 
                                                                                        echo esc_attr($option['value']);
                                                                                        ?>
" value="<?php 
                                                                                        echo $option['value'];
                                                                                        ?>
" <?php 
                                                                                        echo $radio_selected;
                                                                                        ?>
 /> <label for="<?php 
                                                                                        echo $meta_box['name'];
                                                                                        ?>
-<?php 
                                                                                        echo esc_attr($option['value']);
                                                                                        ?>
" class="selectit"><?php 
                                                                                        echo $option['name'];
                                                                                        ?>
</label>
                            	<?php 
                                                                                    }
                                                                                    ?>
                                <span class="themify_checkbox_description"><?php 
                                                                                    echo $meta_box['description'];
                                                                                    ?>
</span>
                            </div>

                      </div><!--/themify_field_row -->

			<?php 
                                                                                    ///////////////////////////////////////////
                                                                                    // Page builder template
                                                                                    ///////////////////////////////////////////
                                                                                    ?>

                    <?php 
                                                                                } else {
                                                                                    if ($meta_box['type'] == 'page_builder') {
                                                                                        do_action('themify_builder_metabox');
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                ?>
                
                <?php 
            }
            ?>
            </div>
            </div>
			<?php 
        }
    }
    echo '</div>';
    //end .ilc-btabs
    echo '</div>';
    //end #themify-meta-box-tabs
}