示例#1
0
function dt_morphsearchform()
{
    ob_start();
    ?>
	<div class="morphsearch" id="morphsearch">
		<form class="morphsearch-form" method="get"  action="<?php 
    echo esc_url(home_url('/'));
    ?>
" role="form">
			<input type="search" name="s" placeholder="<?php 
    esc_html__('Search...', 'ticketbox');
    ?>
" class="morphsearch-input">
			<button type="submit" class="morphsearch-submit"></button>
		</form>
		<div class="morphsearch-content<?php 
    echo defined('WOOCOMMERCE_VERSION') ? ' has-3colum' : '';
    ?>
">
			<?php 
    if (defined('WOOCOMMERCE_VERSION')) {
        ?>
			<div class="dummy-column">
				<h2><?php 
        esc_html_e('Product', 'ticketbox');
        ?>
</h2>
				<?php 
        $query_args = array('posts_per_page' => 6, 'post_status' => 'publish', 'post_type' => 'product', 'no_found_rows' => 1, 'orderby' => 'date', 'order' => 'DESC');
        $query_args['meta_query'] = WC()->query->get_meta_query();
        $r = new WP_Query($query_args);
        if ($r->have_posts()) {
            while ($r->have_posts()) {
                $r->the_post();
                global $product;
                ?>
						<a href="<?php 
                the_permalink();
                ?>
" class="dummy-media-object">
							<?php 
                echo dt_echo($product->get_image('dt-thumbnail-square'));
                ?>
							<div>
								<h3><?php 
                echo dt_echo($product->get_title());
                ?>
</h3>
								<?php 
                if (!empty($show_rating)) {
                    echo dt_echo($product->get_rating_html());
                }
                ?>
								<div class="price">
									<?php 
                echo dt_echo($product->get_price_html());
                ?>
								</div>
							</div>
						</a>
						<?php 
            }
        }
        wp_reset_query();
        ?>
			</div>
			<?php 
    }
    ?>
			<div class="dummy-column">
				<h2><?php 
    esc_html_e('Popular', 'ticketbox');
    ?>
</h2>
				<?php 
    $re = new WP_Query(array('posts_per_page' => 6, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'meta_key' => "_thumbnail_id", 'orderby' => 'comment_count', 'order' => 'DESC'));
    if ($re->have_posts()) {
        ?>
				<?php 
        while ($re->have_posts()) {
            $re->the_post();
            ?>
				<a href="<?php 
            the_permalink();
            ?>
" class="dummy-media-object">
					<?php 
            the_post_thumbnail('dt-thumbnail-square');
            ?>
					<div>
						<h3><?php 
            the_title();
            ?>
</h3>
						<?php 
            echo '<span>' . sprintf(esc_html_e('%s Comment', 'ticketbox'), get_comments_number()) . '</span>';
            ?>
					</div>
				</a>
				<?php 
        }
        ?>
				<?php 
    }
    wp_reset_query();
    ?>
			</div>
			<div class="dummy-column">
				<h2><?php 
    esc_html_e('Recent', 'ticketbox');
    ?>
</h2>
				<?php 
    $rc = new WP_Query(array('posts_per_page' => 6, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'meta_key' => "_thumbnail_id"));
    if ($rc->have_posts()) {
        ?>
				<?php 
        while ($rc->have_posts()) {
            $rc->the_post();
            ?>
				<a href="<?php 
            the_permalink();
            ?>
" class="dummy-media-object">
					<?php 
            the_post_thumbnail('dt-thumbnail-square');
            ?>
					<div>
						<h3><?php 
            the_title();
            ?>
</h3>
						<span>
							<time datetime="<?php 
            echo get_the_date('Y-m-d\\TH:i:sP');
            ?>
"><?php 
            echo get_the_date('M j, Y');
            ?>
</time>
						</span>
					</div>
				</a>
				<?php 
        }
        ?>
				<?php 
    }
    wp_reset_query();
    ?>
			</div>
		</div>
		<span class="morphsearch-close"></span>
	</div>
	<div class="morphsearch-overlay"></div>
	<?php 
    return ob_get_clean();
}
示例#2
0
function dt_render_meta_boxes($post, $meta_box)
{
    $args = $meta_box['args'];
    if (!defined('DT_META_BOX_NONCE')) {
        define('DT_META_BOX_NONCE', 1);
        wp_nonce_field('dt_meta_box_nonce', 'dt_meta_box_nonce', false);
    }
    if (!is_array($args)) {
        return false;
    }
    echo '<div class="dt-metaboxes">';
    if (isset($args['description']) && $args['description'] != '') {
        echo '<p>' . $args['description'] . '</p>';
    }
    $count = 0;
    foreach ($args['fields'] as $field) {
        if (!isset($field['type'])) {
            continue;
        }
        $field['name'] = isset($field['name']) ? $field['name'] : '';
        $field['name'] = strstr($field['name'], '_dt_') ? sanitize_title($field['name']) : '_dt_' . sanitize_title($field['name']);
        $value = get_post_meta($post->ID, $field['name'], true);
        $field['value'] = isset($field['value']) ? $field['value'] : '';
        if ($value !== '' && $value !== null && $value !== array() && $value !== false) {
            $field['value'] = $value;
        }
        $field['id'] = isset($field['id']) ? $field['id'] : $field['name'];
        $field['description'] = isset($field['description']) ? $field['description'] : '';
        $field['label'] = isset($field['label']) ? $field['label'] : '';
        $field['placeholder'] = isset($field['placeholder']) ? $field['placeholder'] : $field['label'];
        $field['name'] = 'dt_meta[' . $field['name'] . ']';
        if (isset($field['callback']) && !empty($field['callback'])) {
            call_user_func($field['callback'], $post, $field);
        } else {
            switch ($field['type']) {
                case 'heading':
                    echo '<h4>' . $field['heading'] . '</h4>';
                    break;
                    break;
                case 'hr':
                    echo '<div style="margin-top:20px;margin-bottom:20px;">';
                    echo '<hr>';
                    echo '</div>';
                    break;
                case 'text':
                    echo '<div  class="dt-meta-box-field ' . esc_attr($field['id']) . '_field"><label for="' . esc_attr($field['id']) . '">' . esc_html($field['label']) . '</label><input type="text" name="' . esc_attr($field['name']) . '" id="' . esc_attr($field['id']) . '" value="' . esc_attr($field['value']) . '" placeholder="' . esc_attr($field['placeholder']) . '" style="width: 99%;" /> ';
                    if (!empty($field['description'])) {
                        echo '<span class="description">' . dt_echo($field['description']) . '</span>';
                    }
                    if (isset($field['hidden']) && $field['hidden'] == true) {
                        $field['name'] = 'dt_meta[' . $field['name'] . '_hidden]';
                        echo '<input type="hidden" name="' . esc_attr($field['name']) . '" value="' . esc_attr($field['value']) . '">';
                    }
                    echo '</div>';
                    break;
                case 'color':
                    wp_enqueue_style('wp-color-picker');
                    wp_enqueue_script('wp-color-picker');
                    echo '<div  class="dt-meta-box-field ' . esc_attr($field['id']) . '_field"><label for="' . esc_attr($field['id']) . '">' . esc_html($field['label']) . '</label><input type="text" name="' . esc_attr($field['name']) . '" id="' . esc_attr($field['id']) . '" value="' . esc_attr($field['value']) . '" placeholder="' . esc_attr($field['placeholder']) . '" /> ';
                    if (!empty($field['description'])) {
                        echo '<span class="description">' . dt_echo($field['description']) . '</span>';
                    }
                    echo '<script type="text/javascript">
						jQuery(document).ready(function($){
						    $("#' . esc_attr($field['id']) . '").wpColorPicker();
						});
					 </script>
					';
                    echo '</div>';
                    break;
                case 'textarea':
                    echo '<div  class="dt-meta-box-field ' . esc_attr($field['id']) . '_field"><label for="' . esc_attr($field['id']) . '">' . esc_html($field['label']) . '</label><textarea name="' . esc_attr($field['name']) . '" id="' . esc_attr($field['id']) . '" placeholder="' . esc_attr($field['placeholder']) . '" rows="5" cols="20" style="width: 99%;">' . esc_textarea($field['value']) . '</textarea> ';
                    if (!empty($field['description'])) {
                        echo '<span class="description">' . dt_echo($field['description']) . '</span>';
                    }
                    echo '</div>';
                    break;
                case 'checkbox':
                    $field['cbvalue'] = isset($field['cbvalue']) ? $field['cbvalue'] : '1';
                    echo '<div  class="dt-meta-box-field ' . esc_attr($field['id']) . '_field"><label for="' . esc_attr($field['id']) . '"><strong>' . esc_html($field['label']) . '</strong></label><input type="checkbox" name="' . esc_attr($field['name']) . '" id="' . esc_attr($field['id']) . '" value="0"  checked="checked" style="display:none" /><input class="checkbox" type="checkbox" name="' . esc_attr($field['name']) . '" id="' . esc_attr($field['id']) . '" value="' . esc_attr($field['cbvalue']) . '" ' . checked($field['value'], $field['cbvalue'], false) . ' /> ';
                    if (!empty($field['description'])) {
                        echo '<span class="description">' . dt_echo($field['description']) . '</span>';
                    }
                    echo '</div>';
                    break;
                case 'categories':
                    echo '<div  class="dt-meta-box-field ' . esc_attr($field['id']) . '_field"><label for="' . esc_attr($field['id']) . '">' . esc_html($field['label']) . '</label>';
                    wp_dropdown_categories(array('name' => esc_attr($field['name']), 'id' => esc_attr($field['id']), 'hierarchical' => 1, 'selected' => $field['value']));
                    echo '</div>';
                    break;
                case 'widgetised_sidebars':
                    $sidebars = $GLOBALS['wp_registered_sidebars'];
                    echo '<div  class="dt-meta-box-field ' . esc_attr($field['id']) . '_field"><label for="' . esc_attr($field['id']) . '">' . esc_html($field['label']) . '</label><select id="' . esc_attr($field['id']) . '" name="' . esc_attr($field['name']) . '">';
                    echo '<option value=""' . $selected . '>' . __('Select a sidebar...', 'dawnthemes') . '</option>';
                    foreach ($sidebars as $sidebar) {
                        $selected = '';
                        if ($sidebar["id"] == $field['value']) {
                            $selected = ' selected="selected"';
                        }
                        $sidebar_name = $sidebar["name"];
                        echo '<option value="' . $sidebar["id"] . '"' . $selected . '>' . $sidebar_name . '</option>';
                    }
                    echo '</select> ';
                    if (!empty($field['description'])) {
                        echo '<span class="description">' . dt_echo($field['description']) . '</span>';
                    }
                    echo '</div>';
                    break;
                    break;
                case 'select':
                    $field['options'] = isset($field['options']) ? $field['options'] : array();
                    echo '<div  class="dt-meta-box-field ' . esc_attr($field['id']) . '_field"><label for="' . esc_attr($field['id']) . '">' . esc_html($field['label']) . '</label><select id="' . esc_attr($field['id']) . '" name="' . esc_attr($field['name']) . '">';
                    foreach ($field['options'] as $key => $value) {
                        echo '<option value="' . esc_attr($key) . '" ' . selected(esc_attr($field['value']), esc_attr($key), false) . '>' . esc_html($value) . '</option>';
                    }
                    echo '</select> ';
                    if (!empty($field['description'])) {
                        echo '<span class="description">' . dt_echo($field['description']) . '</span>';
                    }
                    echo '</div>';
                    break;
                case 'radio':
                    $field['options'] = isset($field['options']) ? $field['options'] : array();
                    echo '<fieldset ' . $data_dependency . ' class="form-field ' . esc_attr($field['id']) . '_field"><legend>' . esc_html($field['label']) . '</legend><ul>';
                    foreach ($field['options'] as $key => $value) {
                        echo '<li><label><input
					        		name="' . esc_attr($field['name']) . '"
					        		value="' . esc_attr($key) . '"
					        		type="radio"
									class="radio"
					        		' . checked(esc_attr($field['value']), esc_attr($key), false) . '
					        		/> ' . esc_html($value) . '</label>
					    	</li>';
                    }
                    echo '</ul>';
                    if (!empty($field['description'])) {
                        echo '<span class="description">' . dt_echo($field['description']) . '</span>';
                    }
                    echo '</fieldset>';
                    break;
                case 'gallery':
                    if (function_exists('wp_enqueue_media')) {
                        wp_enqueue_media();
                    } else {
                        wp_enqueue_style('thickbox');
                        wp_enqueue_script('media-upload');
                        wp_enqueue_script('thickbox');
                    }
                    if (!defined('_DT_META_GALLERY_JS')) {
                        define('_DT_META_GALLERY_JS', 1);
                        ?>
					<script type="text/javascript">
						jQuery(document).ready(function($) {
							$('.dt-meta-gallery-select').on('click',function(e){
								e.stopPropagation();
								e.preventDefault();
								
								var $this = $(this),
									dt_meta_gallery_list = $this.closest('.dt-meta-box-field').find('.dt-meta-gallery-list'),
									dt_meta_gallery_frame,
									dt_meta_gallery_ids = $this.closest('.dt-meta-box-field').find('#dt_meta_gallery_ids'),
									_ids = dt_meta_gallery_ids.val();
	
								if(dt_meta_gallery_frame){
									dt_meta_gallery_frame.open();
									return false;
								}
								
								dt_meta_gallery_frame = wp.media({
									title: '<?php 
                        echo __('Add Images to Gallery', 'dawnthemes');
                        ?>
',
									button: {
										text: '<?php 
                        echo __('Add to Gallery', 'dawnthemes');
                        ?>
',
									},
									library: { type: 'image' },
									multiple: true
								});
	
								dt_meta_gallery_frame.on('select',function(){
									var selection = dt_meta_gallery_frame.state().get('selection');
									selection.map( function( attachment ) {
										attachment = attachment.toJSON();
										if ( attachment.id ) {
											_ids = _ids ? _ids + "," + attachment.id : attachment.id;
											dt_meta_gallery_list.append('\
												<li data-id="' + attachment.id +'">\
													<div class="thumbnail">\
														<div class="centered">\
															<img src="' + attachment.url + '" />\
														</div>\
														<a href="#" title="<?php 
                        echo __('Delete', 'dawnthemes');
                        ?>
"><?php 
                        echo __('x', 'dawnthemes');
                        ?>
</a></li>\
													</div>\
												</li>'
											);
										}
										dt_meta_gallery_ids.val( dt_trim(_ids,',') );
										dt_meta_gallery_fn();
									});
								});
	
								dt_meta_gallery_frame.open();
							});
							var dt_meta_gallery_fn = function(){
								if($('.dt-meta-gallery-list').length){
									$('.dt-meta-gallery-list').each(function(){
										var $this = $(this);
										$this.sortable({
											items: 'li',
											cursor: 'move',
											forcePlaceholderSize: true,
											forceHelperSize: false,
											helper: 'clone',
											opacity: 0.65,
											placeholder: 'li-placeholder',
											start:function(event,ui){
												ui.item.css('background-color','#f6f6f6');
											},
											update: function(event, ui) {
												var _ids = '';
												$this.find('li').each(function() {
													var _id = $(this).data( 'id' );
													_ids = _ids + _id + ',';
												});
									
												$this.closest('.dt-meta-box-field').find('#dt_meta_gallery_ids').val( dt_trim(_ids,',') );
											}
										});
	
										$this.find('a').on( 'click',function(e) {
											e.stopPropagation();
											e.preventDefault();
											$(this).closest('li').remove();
											var _ids = '';
											$this.find('li').each(function() {
												var _id = $(this).data( 'id' );
												_ids = _ids + _id + ',';
											});
	
											$this.closest('.dt-meta-box-field').find('#dt_meta_gallery_ids').val( dt_trim(_ids,',') );
	
											return false;
										});
										
									});
								}
							}
							dt_meta_gallery_fn();
						});
					</script>
					<?php 
                    }
                    echo '<div  class="dt-meta-box-field ' . esc_attr($field['id']) . '_field">';
                    echo '<label for="' . esc_attr($field['id']) . '">' . esc_html($field['label']) . '</label>';
                    echo '<div class="dt-meta-gallery-wrap"><ul class="dt-meta-gallery-list">';
                    if ($field['value']) {
                        $value_arr = explode(',', $field['value']);
                        if (!empty($value_arr) && is_array($value_arr)) {
                            foreach ($value_arr as $attachment_id) {
                                if ($attachment_id) {
                                    ?>
								<li data-id="<?php 
                                    echo esc_attr($attachment_id);
                                    ?>
">
									<div class="thumbnail">
										<div class="centered">
											<?php 
                                    echo wp_get_attachment_image($attachment_id, array(120, 120));
                                    ?>
						
										</div>
										<a title="<?php 
                                    echo __('Delete', 'dawnthemes');
                                    ?>
" href="#"><?php 
                                    echo __('x', 'dawnthemes');
                                    ?>
</a>
									</div>						
								</li>
							<?php 
                                }
                            }
                        }
                    }
                    echo '</ul></div>';
                    echo '<input type="hidden" name="' . $field['name'] . '" id="dt_meta_gallery_ids" value="' . $field['value'] . '" />';
                    echo '<input type="button" class="button button-primary dt-meta-gallery-select" name="' . $field['id'] . '_button_upload" id="' . $field['id'] . '_upload" value="' . __('Add Gallery Images', 'dawnthemes') . '" /> ';
                    if (!empty($field['description'])) {
                        echo '<span class="description">' . dt_echo($field['description']) . '</span>';
                    }
                    echo '</div>';
                    break;
                case 'media':
                    if (function_exists('wp_enqueue_media')) {
                        wp_enqueue_media();
                    } else {
                        wp_enqueue_style('thickbox');
                        wp_enqueue_script('media-upload');
                        wp_enqueue_script('thickbox');
                    }
                    $btn_text = !empty($field['value']) ? __('Change Media', 'dawnthemes') : __('Select Media', 'dawnthemes');
                    echo '<div  class="dt-meta-box-field ' . esc_attr($field['id']) . '_field">';
                    echo '<label for="' . esc_attr($field['id']) . '">' . esc_html($field['label']) . '</label>';
                    echo '<input type="text" name="' . esc_attr($field['name']) . '" id="' . esc_attr($field['id']) . '" value="' . esc_attr($field['value']) . '" placeholder="' . esc_attr($field['placeholder']) . '" style="width: 99%;margin-bottom:5px" />';
                    echo '<input type="button" class="button button-primary" name="' . $field['id'] . '_button_upload" id="' . $field['id'] . '_upload" value="' . $btn_text . '" /> ';
                    echo '<input type="button" class="button" name="' . $field['id'] . '_button_clear" id="' . $field['id'] . '_clear" value="' . __('Clear', 'dawnthemes') . '" />';
                    if (!empty($field['description'])) {
                        echo '<span class="description">' . dt_echo($field['description']) . '</span>';
                    }
                    echo '</div>';
                    ?>
					<script type="text/javascript">
						jQuery(document).ready(function($) {
							<?php 
                    if (empty($field['value'])) {
                        ?>
 $('#<?php 
                        echo esc_attr($field['id']);
                        ?>
_clear').css('display', 'none'); <?php 
                    }
                    ?>
							$('#<?php 
                    echo esc_attr($field['id']);
                    ?>
_upload').on('click', function(event) {
								event.preventDefault();
								var $this = $(this);
		
								// if media frame exists, reopen
								if(dt_<?php 
                    echo esc_attr($field['id']);
                    ?>
_media_frame) {
									dt_<?php 
                    echo esc_attr($field['id']);
                    ?>
_media_frame.open();
					                return;
					            }
		
								// create new media frame
								// I decided to create new frame every time to control the selected images
								var dt_<?php 
                    echo esc_attr($field['id']);
                    ?>
_media_frame = wp.media.frames.wp_media_frame = wp.media({
									title: "<?php 
                    echo __('Select or Upload your Media', 'dawnthemes');
                    ?>
",
									button: {
										text: "<?php 
                    echo __('Select', 'dawnthemes');
                    ?>
"
									},
									library: { type: 'video,audio' },
									multiple: false
								});
		
								// when image selected, run callback
								dt_<?php 
                    echo esc_attr($field['id']);
                    ?>
_media_frame.on('select', function(){
									var attachment = dt_<?php 
                    echo esc_attr($field['id']);
                    ?>
_media_frame.state().get('selection').first().toJSON();
									$this.closest('.dt-meta-box-field').find('input#<?php 
                    echo esc_attr($field['id']);
                    ?>
').val(attachment.url);
									
									$this.attr('value', '<?php 
                    echo __('Change Media', 'dawnthemes');
                    ?>
');
									$('#<?php 
                    echo esc_attr($field['id']);
                    ?>
_clear').css('display', 'inline-block');
								});
		
								// open media frame
								dt_<?php 
                    echo esc_attr($field['id']);
                    ?>
_media_frame.open();
							});
		
							$('#<?php 
                    echo esc_attr($field['id']);
                    ?>
_clear').on('click', function(event) {
								var $this = $(this);
								$this.hide();
								$('#<?php 
                    echo esc_attr($field['id']);
                    ?>
_upload').attr('value', '<?php 
                    echo __('Select Media', 'dawnthemes');
                    ?>
');
								$this.closest('.dt-meta-box-field').find('#<?php 
                    echo esc_attr($field['id']);
                    ?>
').val('');
							});
						});
					</script>
					<?php 
                    break;
                case 'image':
                    if (function_exists('wp_enqueue_media')) {
                        wp_enqueue_media();
                    } else {
                        wp_enqueue_style('thickbox');
                        wp_enqueue_script('media-upload');
                        wp_enqueue_script('thickbox');
                    }
                    $image_id = $field['value'];
                    $image = wp_get_attachment_image($image_id, array(120, 120));
                    $output = !empty($image_id) ? $image : '';
                    $btn_text = !empty($image_id) ? __('Change Image', 'dawnthemes') : __('Select Image', 'dawnthemes');
                    echo '<div  class="dt-meta-box-field ' . esc_attr($field['id']) . '_field">';
                    echo '<label for="' . esc_attr($field['id']) . '">' . esc_html($field['label']) . '</label>';
                    echo '<div class="dt-meta-image-thumb">' . $output . '</div>';
                    echo '<input type="hidden" name="' . $field['name'] . '" id="' . $field['id'] . '" value="' . $field['value'] . '" />';
                    echo '<input type="button" class="button button-primary" name="' . $field['id'] . '_button_upload" id="' . $field['id'] . '_upload" value="' . $btn_text . '" /> ';
                    echo '<input type="button" class="button" name="' . $field['id'] . '_button_clear" id="' . $field['id'] . '_clear" value="' . __('Clear Image', 'dawnthemes') . '" />';
                    if (!empty($field['description'])) {
                        echo '<span class="description">' . dt_echo($field['description']) . '</span>';
                    }
                    ?>
					<script type="text/javascript">
						jQuery(document).ready(function($) {
							<?php 
                    if (empty($field['value'])) {
                        ?>
 $('#<?php 
                        echo esc_attr($field['id']);
                        ?>
_clear').css('display', 'none'); <?php 
                    }
                    ?>
							$('#<?php 
                    echo esc_attr($field['id']);
                    ?>
_upload').on('click', function(event) {
								event.preventDefault();
								var $this = $(this);
		
								// if media frame exists, reopen
								if(dt_<?php 
                    echo esc_attr($field['id']);
                    ?>
_image_frame) {
									dt_<?php 
                    echo esc_attr($field['id']);
                    ?>
_image_frame.open();
					                return;
					            }
		
								// create new media frame
								// I decided to create new frame every time to control the selected images
								var dt_<?php 
                    echo esc_attr($field['id']);
                    ?>
_image_frame = wp.media.frames.wp_media_frame = wp.media({
									title: "<?php 
                    echo __('Select or Upload your Image', 'dawnthemes');
                    ?>
",
									button: {
										text: "<?php 
                    echo __('Select', 'dawnthemes');
                    ?>
"
									},
									library: { type: 'image' },
									multiple: false
								});
		
								// when open media frame, add the selected image
								dt_<?php 
                    echo esc_attr($field['id']);
                    ?>
_image_frame.on('open',function() {
									var selected_id = $this.closest('.dt-meta-box-field').find('#<?php 
                    echo esc_attr($field['id']);
                    ?>
').val();
									if (!selected_id)
										return;
									var selection = dt_<?php 
                    echo esc_attr($field['id']);
                    ?>
_image_frame.state().get('selection');
									var attachment = wp.media.attachment(selected_id);
									attachment.fetch();
									selection.add( attachment ? [ attachment ] : [] );
								});
		
								// when image selected, run callback
								dt_<?php 
                    echo esc_attr($field['id']);
                    ?>
_image_frame.on('select', function(){
									var attachment = dt_<?php 
                    echo esc_attr($field['id']);
                    ?>
_image_frame.state().get('selection').first().toJSON();
									$this.closest('.dt-meta-box-field').find('input#<?php 
                    echo esc_attr($field['id']);
                    ?>
').val(attachment.id);
									var thumbnail = $this.closest('.dt-meta-box-field').find('.dt-meta-image-thumb');
									thumbnail.html('');
									thumbnail.append('<img src="' + attachment.url + '" alt="" />');
		
									$this.attr('value', '<?php 
                    echo __('Change Image', 'dawnthemes');
                    ?>
');
									$('#<?php 
                    echo esc_attr($field['id']);
                    ?>
_clear').css('display', 'inline-block');
								});
		
								// open media frame
								dt_<?php 
                    echo esc_attr($field['id']);
                    ?>
_image_frame.open();
							});
		
							$('#<?php 
                    echo esc_attr($field['id']);
                    ?>
_clear').on('click', function(event) {
								var $this = $(this);
								$this.hide();
								$('#<?php 
                    echo esc_attr($field['id']);
                    ?>
_upload').attr('value', '<?php 
                    echo __('Select Image', 'dawnthemes');
                    ?>
');
								$this.closest('.dt-meta-box-field').find('input#<?php 
                    echo esc_attr($field['id']);
                    ?>
').val('');
								$this.closest('.dt-meta-box-field').find('.dt-meta-image-thumb').html('');
							});
						});
					</script>
								
					<?php 
                    echo '</div>';
                    break;
            }
        }
    }
    echo '</div>';
}
示例#3
0
        public function option_page()
        {
            ?>
<div class="clear"></div>
<div class="wrap">
	<input type="hidden" id="security" name="security"
		value="<?php 
            echo wp_create_nonce('dt_theme_option_ajax_security');
            ?>
" />
	<form method="post" action="options.php" enctype="multipart/form-data">
				<?php 
            settings_fields(self::$_option_name);
            ?>
				<div class="dt-opt-header">
			<div class="dt-opt-heading">
				<h2><?php 
            echo DT_THEME_NAME;
            ?>
 <span><?php 
            echo DT_THEME_VERSION;
            ?>
</span>
				</h2>
				<a target="_blank"
					href="http://dawnthemes.com/<?php 
            echo basename(get_template_directory());
            ?>
/document"><?php 
            _e('Online Document', 'dawnthemes');
            ?>
</a>
			</div>
		</div>
		<div class="clear"></div>
		<div class="dt-opt-actions">
			<em style="float: left; margin-top: 5px;"><?php 
            echo esc_html('Theme customizations are done here. Happy styling!', 'dawnthemes');
            ?>
</em>
			<button id="dt-opt-submit" name="dt_opt_save" class="button-primary"
				type="submit"><?php 
            echo esc_html__('Save All Change', 'dawnthemes');
            ?>
</button>
		</div>
		<div class="clear"></div>
		<div id="dt-opt-tab" class="dt-opt-wrap">
			<div class="dt-opt-sidebar">
				<ul id="dt-opt-menu" class="dt-opt-menu">
							<?php 
            $i = 0;
            ?>
							<?php 
            foreach ((array) $this->_sections as $key => $sections) {
                ?>
								<li <?php 
                echo $i == 0 ? ' class="current"' : '';
                ?>
><a
						href="#<?php 
                echo esc_attr($key);
                ?>
"
						title="<?php 
                echo esc_attr($sections['title']);
                ?>
"><?php 
                echo isset($sections['icon']) ? '<i class="' . $sections['icon'] . '"></i> ' : '';
                echo esc_html($sections['title']);
                ?>
</a>
					</li>
							<?php 
                $i++;
                ?>
							<?php 
            }
            ?>
						</ul>
			</div>
			<div id="dt-opt-content" class="dt-opt-content">
						<?php 
            $i = 0;
            ?>
						<?php 
            foreach ((array) $this->_sections as $key => $sections) {
                ?>
							<div id=<?php 
                echo esc_attr($key);
                ?>
 class="dt-opt-section"
					<?php 
                echo $i == 0 ? ' style="display:block"' : '';
                ?>
>
					<h3><?php 
                echo esc_html($sections['title']);
                ?>
</h3>
								<?php 
                if (isset($sections['desc'])) {
                    ?>
								<div class="dt-opt-section-desc">
									<?php 
                    echo dt_echo($sections['desc']);
                    ?>
								</div>
								<?php 
                }
                ?>
								<table class="form-table">
						<tbody>
										<?php 
                foreach ((array) $sections['fields'] as $field) {
                    ?>
										<tr>
											<?php 
                    if (!empty($field['label'])) {
                        ?>
											<th scope="row">
									<div class="dt-opt-label">
													<?php 
                        echo esc_html($field['label']);
                        ?>
													<?php 
                        if (!empty($field['desc'])) {
                            ?>
													<span class="description"><?php 
                            echo dt_echo($field['desc']);
                            ?>
</span>
													<?php 
                        }
                        ?>
												</div>
								</th>
											<?php 
                    }
                    ?>
											<td <?php 
                    if (empty($field['label'])) {
                        ?>
 colspan="2"
									<?php 
                    }
                    ?>
>
									<div class="dt-opt-field-wrap">
													<?php 
                    if (isset($field['callback'])) {
                        call_user_func($field['callback'], $field);
                    }
                    ?>
													<?php 
                    echo dt_echo($this->_render_field($field));
                    ?>
												</div>
								</td>
							</tr>
										<?php 
                }
                ?>
									</tbody>
					</table>
				</div>
						<?php 
                $i++;
                ?>
						<?php 
            }
            ?>
					</div>
		</div>
		<div class="clear"></div>
		<div class="dt-opt-actions2">
			<button id="dt-opt-submit2" name="dt_opt_save" class="button-primary"
				type="submit"><?php 
            echo esc_html__('Save All Change', 'dawnthemes');
            ?>
</button>
			<button id="dt-opt-reset"
				name="<?php 
            echo self::$_option_name;
            ?>
[dt_opt_reset]" class="button"
				type="submit"><?php 
            echo esc_html__('Reset Options', 'dawnthemes');
            ?>
</button>
		</div>
		<div class="clear"></div>
	</form>
</div>
<?php 
        }
示例#4
0
 /**
  * Ajax search
  */
 public function search()
 {
     if (empty($_REQUEST['s'])) {
         die;
     }
     $output = "";
     $args = array('post_type' => 'any', 'post_status' => 'publish', 'post_password' => '', 'suppress_filters' => false, 'numberposts' => 4, 's' => $_REQUEST['s']);
     $args = apply_filters('dt_search_query_args', $args);
     $posts = get_posts($args);
     if (empty($posts)) {
         $output .= '<div class="no-result">';
         $output .= esc_html__('No results matched!', 'dawnthemes');
         $output .= '</div>';
     } else {
         $post_types = array();
         $post_types_object = array();
         foreach ($posts as $post) {
             $post_types[$post->post_type][] = $post;
             if (empty($post_types_object[$post->post_type])) {
                 $post_types_object[$post->post_type] = get_post_type_object($post->post_type);
             }
         }
         $output .= '<div class="searchform-result-list">';
         foreach ($post_types as $ptype => $post_type) {
             if (isset($post_types_object[$ptype]->labels->name)) {
                 $output .= '<h3 class="search-object"><span>' . $post_types_object[$ptype]->labels->name . '</span></h3>';
             } else {
                 $output .= "<hr>";
             }
             foreach ($post_type as $post) {
                 $format = get_post_format($post->ID);
                 if (get_the_post_thumbnail($post->ID, 'thumbnail')) {
                     $image = get_the_post_thumbnail($post->ID, 'thumbnail');
                 } else {
                     if ($format == 'video') {
                         $image = "<i class='fa fa-file-video-o'></i>";
                     } elseif ($format == 'image' || $format == 'gallery') {
                         $image = "<i class='fa fa-file-image-o'></i>";
                     } else {
                         $image = "<i class='fa fa-file-text-o'></i>";
                     }
                 }
                 $excerpt = "";
                 if (!empty($post->post_content)) {
                     $excerpt = wp_html_excerpt(strip_shortcodes($post->post_content), 30, "...");
                 }
                 $link = apply_filters('dt_search_item_url', get_permalink($post->ID));
                 $output .= '<div class="search-entry">';
                 $output .= '<div class="search-image">' . $image . '</div>';
                 $output .= '<div class="search-content">';
                 $output .= '<h4 class="search-title">';
                 $output .= '<a href="' . $link . '">';
                 $output .= get_the_title($post->ID);
                 $output .= '</a>';
                 $output .= '</h4>';
                 $output .= '<span class="search-excerpt">';
                 $output .= $excerpt;
                 $output .= '</span>';
                 $output .= '</div>';
                 $output .= '</div>';
             }
         }
         $output .= '</div>';
         $output .= '<div class="search-view-all"><a href="' . home_url('?s=' . $_REQUEST['s']) . '">' . esc_html__('View all results', 'dawnthemes') . '</a>';
     }
     $output = apply_filters('dt_ajax_search_form_result', $output);
     echo dt_echo($output);
     die;
 }