Ejemplo n.º 1
0
function jhp_main_image_meta_box($post)
{
    $image = jhp_get_main_image($post, 150, 150, true);
    $id = jhp_get_main_image_id($post);
    ?>
	<p style="display: block; float: right">
		<?php 
    tj_register_custom_media_button('jhp_main_image', 'Main Image', true, false, 150, 150);
    ?>
		<a class="add-image button thickbox" onclick="return false;" title="Add Image" href="media-upload.php?button=jhp_main_image&amp;type=image&amp;TB_iframe=true&amp;width=640&amp;height=197">
			<?php 
    echo $image ? 'Change' : 'Add';
    ?>
 Main Image
		</a>
		<input type="hidden" name="jhp_main_image" id="jhp_main_image" value="<?php 
    echo jhp_get_main_image_id($post);
    ?>
" />
	</p>
	
	<div style="padding: 0 10px; float: left;" id="jhp_main_image_container">
		<?php 
    if ($image) {
        ?>
			<span class="image-wrapper" id="<?php 
        echo $id;
        ?>
"><img src="<?php 
        echo $image;
        ?>
" />
			<a class="delete_custom_image" rel="jhp_main_image:<?php 
        echo $id;
        ?>
">Delete</a> | </span>
		<?php 
    } else {
        ?>
			<p class="empty-message">No Main Image Added <?php 
        if ($url = jhp_get_url($post)) {
            ?>
| <a href="<?php 
            echo $url;
            ?>
" target="_blank">Screenshot your site now</a><?php 
        }
        ?>
</p>
		<?php 
    }
    ?>
	</div>
	<div style="clear: both;" /></div>
	<?php 
}
    function widget($args, $instance)
    {
        extract($args, EXTR_SKIP);
        extract($instance);
        $height = (int) $height;
        echo $before_widget;
        ?>
		<div id="jh-portfolio-main-image">
			<?php 
        if ($image = jhp_get_main_image(null, $width, $height, $height ? true : false)) {
            ?>
			    <img id="main-image" src="<?php 
            echo $image;
            ?>
" />
			<?php 
        }
        ?>
		</div>	
		<?php 
        echo $after_widget;
    }
    function widget($args, $instance)
    {
        global $jh_portfolio, $post, $wp_query;
        $post_backup = $post;
        $wp_query_backup = $wp_query;
        extract($args, EXTR_SKIP);
        extract($instance);
        echo $before_widget;
        //Modify the global jh_portfolio to respect the order in the widget
        $query_vars = $jh_portfolio->query_vars;
        $query_vars['orderby'] = $sort_by;
        $jh_portfolio = new WP_Query($query_vars);
        $orig = $jh_portfolio;
        ?>
		<div id="jh-portfolio-selector">
			<?php 
        foreach (get_terms('jh-portfolio-category') as $cat) {
            ?>
				<?php 
            $jh_portfolio = new WP_Query(array('taxonomy' => 'jh-portfolio-category', 'term' => $cat->slug, 'showposts' => -1, 'orderby' => $sort_by, 'post_type' => 'jh-portfolio'));
            ?>
				<ul id="<?php 
            echo $cat->slug;
            ?>
">
					<li><strong><?php 
            echo $cat->name;
            ?>
</strong></li>
					<?php 
            while ($jh_portfolio->have_posts()) {
                $jh_portfolio->the_post();
                global $post;
                ?>
						<li><a class="<?php 
                if ($orig->post->ID == get_the_id()) {
                    echo 'active';
                }
                ?>
" href="<?php 
                the_permalink();
                ?>
" rel="<?php 
                echo get_the_id();
                ?>
"><?php 
                echo $post->post_title;
                ?>
</a></li>
					<?php 
            }
            ?>
				</ul>
			<?php 
        }
        ?>
			
			
			<?php 
        if ($show_main_image) {
            ?>
				<div id="main-image-holder">
					<?php 
            if ($image = jhp_get_main_image(null, $width, $height)) {
                ?>
						<img id="main-image" src="<?php 
                echo $image;
                ?>
" />
					<?php 
            }
            ?>
				</div>
			<?php 
        }
        ?>
		</div>	
		<?php 
        $jh_portfolio = $orig;
        ?>
		<?php 
        echo $after_widget;
        //restore old data
        $post = $post_backup;
        $wp_query = $wp_query_backup;
    }