/**
 * Display the navigation images
 *
 * @param	mixed	$post		(optional) the post (ID or object)
 * @return	none
*/
function fastfood_navigate_images($post = null)
{
    if (!($post = get_post($post))) {
        return;
    }
    if (!wp_attachment_is_image($post->ID)) {
        return;
    }
    $images = fastfood_get_prevnext_images($post->ID);
    if ($images['prev']) {
        $images['prev'] = fastfood_build_link(array('href' => get_attachment_link($images['prev']), 'text' => '<i class="el-icon-chevron-left"></i> ' . wp_get_attachment_image($images['prev'], array(70, 70)), 'class' => 'size-thumbnail', 'rel' => 'prev'));
    }
    if ($images['next']) {
        $images['next'] = fastfood_build_link(array('href' => get_attachment_link($images['next']), 'text' => wp_get_attachment_image($images['next'], array(70, 70)) . '<i class="el-icon-chevron-right"></i>', 'class' => 'size-thumbnail', 'rel' => 'next'));
    }
    ?>
	<div class="img-navi">

		<?php 
    echo $images['prev'];
    ?>
		<span class="img-navi-curimg"><?php 
    echo wp_get_attachment_image($post->ID, array(70, 70));
    ?>
</span>
		<?php 
    echo $images['next'];
    ?>

	</div>
<?php 
}
Beispiel #2
0
    /**
     * The Navigation Buttons
     *
     * @since Fastfood 0.37
     */
    function the_navbuttons($args = '')
    {
        global $post, $paged, $wp_query;
        wp_reset_postdata();
        $is_post = is_single() && !is_attachment() && !fastfood_is_allcat();
        $is_image = is_attachment() && !fastfood_is_allcat();
        $is_page = is_singular() && !is_single() && !is_attachment() && !fastfood_is_allcat();
        $is_singular = is_singular() && !fastfood_is_allcat();
        $defaults = array('print' => 1, 'comment' => 1, 'feed' => 1, 'trackback' => 1, 'home' => 1, 'next_prev' => 1, 'up_down' => 1, 'fixed' => 1);
        $args = wp_parse_args($args, $defaults);
        $buttons = array();
        // ------- Print -------
        if (FastfoodOptions::get_opt('fastfood_navbuttons_print') && $args['print'] && $is_singular) {
            $query_vars['style'] = 'printme';
            if (get_query_var('page')) {
                $query_vars['page'] = esc_html(get_query_var('page'));
            }
            if (get_query_var('cpage')) {
                $query_vars['cpage'] = esc_html(get_query_var('cpage'));
            }
            $buttons['print'] = array('class' => '', 'a_class' => '', 'a_rel' => '', 'a_href' => add_query_arg($query_vars, get_permalink($post->ID)), 'icon_class' => 'el-icon-print', 'tooltip' => __('Print preview', 'fastfood'));
        }
        // ------- Leave a comment -------
        if (FastfoodOptions::get_opt('fastfood_navbuttons_comment') && $args['comment'] && $is_singular && comments_open($post->ID) && !post_password_required()) {
            $buttons['comment'] = array('class' => '', 'a_class' => 'show-comment-form', 'a_rel' => '', 'a_href' => '#respond', 'icon_class' => 'el-icon-comment', 'tooltip' => __('Leave a comment', 'fastfood'));
        }
        // ------- RSS feed -------
        if (FastfoodOptions::get_opt('fastfood_navbuttons_feed') && $args['feed'] && $is_singular && comments_open($post->ID) && !post_password_required()) {
            $buttons['feed'] = array('class' => '', 'a_class' => '', 'a_rel' => '', 'a_href' => get_post_comments_feed_link($post->ID, 'rss2'), 'icon_class' => 'el-icon-rss', 'tooltip' => __('feed for comments on this post', 'fastfood'));
        }
        // ------- Trackback -------
        if (FastfoodOptions::get_opt('fastfood_navbuttons_trackback') && $args['trackback'] && $is_singular && pings_open()) {
            $buttons['trackback'] = array('class' => '', 'a_class' => '', 'a_rel' => 'trackback', 'a_href' => get_trackback_url(), 'icon_class' => 'el-icon-refresh', 'tooltip' => __('Trackback URL', 'fastfood'));
        }
        // ------- Home -------
        if (FastfoodOptions::get_opt('fastfood_navbuttons_home') && $args['home']) {
            $buttons['home'] = array('class' => '', 'a_class' => '', 'a_rel' => '', 'a_href' => home_url(), 'icon_class' => 'el-icon-home', 'tooltip' => __('Home', 'fastfood'));
        }
        // ------- Back to parent post -------
        if ($is_image && !empty($post->post_parent)) {
            $buttons['image'] = array('class' => '', 'a_class' => '', 'a_rel' => 'gallery', 'a_href' => get_permalink($post->post_parent), 'icon_class' => 'el-icon-hand-left', 'tooltip' => sprintf(__('Return to %s', 'fastfood'), get_the_title($post->post_parent)));
        }
        // ------- Previous/Next image -------
        if ($is_image) {
            $images = fastfood_get_prevnext_images($post->ID);
            if ($images['prev']) {
                $buttons['prevpost'] = array('class' => '', 'a_class' => '', 'a_rel' => 'prev', 'a_href' => get_attachment_link($images['prev']), 'icon_class' => 'el-icon-chevron-left', 'tooltip' => __('Previous Image', 'fastfood'));
            }
            if ($images['next']) {
                $buttons['nextpost'] = array('class' => '', 'a_class' => '', 'a_rel' => 'next', 'a_href' => get_attachment_link($images['next']), 'icon_class' => 'el-icon-chevron-right', 'tooltip' => __('Next Image', 'fastfood'));
            }
        }
        // ------- Previous post -------
        if (FastfoodOptions::get_opt('fastfood_navbuttons_nextprev') && $args['next_prev'] && $is_post && get_previous_post()) {
            $buttons['prevpost'] = array('class' => '', 'a_class' => '', 'a_rel' => '', 'a_href' => get_permalink(get_previous_post()), 'icon_class' => 'el-icon-chevron-left', 'tooltip' => sprintf(__('Previous Post', 'fastfood') . ': %s', get_the_title(get_previous_post())));
        }
        // ------- Next post -------
        if (FastfoodOptions::get_opt('fastfood_navbuttons_nextprev') && $args['next_prev'] && $is_post && get_next_post()) {
            $buttons['nextpost'] = array('class' => '', 'a_class' => '', 'a_rel' => '', 'a_href' => get_permalink(get_next_post()), 'icon_class' => 'el-icon-chevron-right', 'tooltip' => sprintf(__('Next Post', 'fastfood') . ': %s', get_the_title(get_next_post())));
        }
        // ------- Older Posts -------
        if (FastfoodOptions::get_opt('fastfood_navbuttons_newold') && $args['next_prev'] && !$is_singular && !fastfood_is_allcat() && get_next_posts_link()) {
            $max_page = $wp_query->max_num_pages;
            $buttons['oldposts'] = array('class' => 'nb-nextprev', 'a_class' => '', 'a_rel' => '', 'a_href' => next_posts($max_page, false), 'icon_class' => 'el-icon-chevron-left', 'tooltip' => __('Older Posts', 'fastfood'));
        }
        // ------- Newer Posts -------
        if (FastfoodOptions::get_opt('fastfood_navbuttons_newold') && $args['next_prev'] && !$is_singular && !fastfood_is_allcat() && get_previous_posts_link()) {
            $buttons['newposts'] = array('class' => 'nb-nextprev', 'a_class' => '', 'a_rel' => '', 'a_href' => previous_posts(false), 'icon_class' => 'el-icon-chevron-right', 'tooltip' => __('Newer Posts', 'fastfood'));
        }
        // ------- Top -------
        if (FastfoodOptions::get_opt('fastfood_navbuttons_topbottom') && $args['up_down']) {
            $buttons['up'] = array('class' => '', 'a_class' => '', 'a_rel' => '', 'a_href' => '#', 'icon_class' => 'el-icon-chevron-up', 'tooltip' => __('Top of page', 'fastfood'));
        }
        // ------- Bottom -------
        if (FastfoodOptions::get_opt('fastfood_navbuttons_topbottom') && $args['up_down']) {
            $buttons['down'] = array('class' => '', 'a_class' => '', 'a_rel' => '', 'a_href' => '#footer', 'icon_class' => 'el-icon-chevron-down', 'tooltip' => __('Bottom of page', 'fastfood'));
        }
        /* custom buttons can be easily added to navbar using filters. eg:
        
        			add_filter( 'fastfood_filter_navbuttons', 'fastfood_add_my_button' );
        
        			function fastfood_add_my_button( $buttons ) {
        				$buttons['my-button'] = array(
        					'class'			=> 'my_button_class',
        					'a_class'		=> 'my_button_anchor_class',
        					'a_rel'			=> 'my_button_anchor_rel',
        					'a_href'		=> 'my_button_anchor_href',
        					'icon_class'	=> 'elusive_icon_class',
        					'tooltip'		=> 'my button tooltip text'
        				);
        				return $buttons;
        			}
        
        		*/
        $buttons = apply_filters('fastfood_filter_navbuttons', $buttons);
        if (!$buttons) {
            return;
        }
        ?>

			<div id="navbuttons">
				<?php 
        foreach ($buttons as $button) {
            $button['class'] = $button['class'] ? ' ' . esc_attr(trim($button['class'])) : '';
            $button['icon_class'] = $button['icon_class'] ? ' ' . esc_attr(trim($button['icon_class'])) : '';
            $button['tooltip'] = esc_html($button['tooltip']);
            ?>

				<div class="minibutton<?php 
            echo $button['class'];
            ?>
">
					<?php 
            echo fastfood_build_link(array('href' => $button['a_href'], 'class' => $button['a_class'], 'rel' => $button['a_rel'], 'text' => '<i class="minib_img' . $button['icon_class'] . '"></i>'));
            ?>
					<span class="nb_tooltip"><?php 
            echo $button['tooltip'];
            ?>
</span>
				</div>

				<?php 
        }
        ?>
			</div><!-- #navbuttons -->

		<?php 
    }