示例#1
0
文件: loop.php 项目: 2030449c/farkol
            ?>
</a></span>
				<?php 
        }
        ?>

			</p>
		</div><!-- .post-meta -->

		<?php 
        if (has_post_thumbnail()) {
            ?>
		<div class="post-thumb">
		  <?php 
            $post_id = get_the_ID();
            echo PC_Utility::get_responsive_slider_image($post_id, 'post-thumbnail');
            /* Show post thumbnail image, if one exists. */
            ?>
		</div> <!-- .post-thumb -->
		<?php 
        }
        ?>

			<?php 
        global $more;
        $more = 0;
        the_content(' ' . __('Read More', 'presscoders'));
        wp_link_pages(array('before' => '<div class="page-link">', 'after' => '</div>'));
        ?>
		</div> <!-- .post-content -->
    public static function blog_style_recent_posts_widget_loop($args = array())
    {
        ?>

		<div id="post-<?php 
        the_ID();
        ?>
" <?php 
        post_class();
        ?>
>

			<div class="post-aside">
			<p class="post-date"><?php 
        the_time('M');
        ?>
<br /><?php 
        the_time('j');
        ?>
</p>

			<p class="author">By <?php 
        the_author_posts_link();
        ?>
</p>
			</div>
			
			<div class="post-content">

			<?php 
        $post_title = get_the_title();
        ?>
			<?php 
        if (!empty($post_title)) {
            ?>
			<h2 class="entry-title"><a href="<?php 
            the_permalink();
            ?>
" rel="bookmark"><?php 
            the_title();
            ?>
</a></h2>
			<?php 
        } else {
            ?>
			<h2 class="entry-title"><a href="<?php 
            the_permalink();
            ?>
" rel="bookmark">(no title)</a></h2>
			<?php 
        }
        ?>

            <div class="post-meta">
                <?php 
        PC_Hooks::pc_post_meta();
        /* Framework hook wrapper */
        ?>
                <p>
					<span class="categories">Category: <?php 
        the_category(', ');
        ?>
</span>

					<?php 
        the_tags('<span class="tags">Tags: ', ', ', '</span>');
        ?>

					<?php 
        if (comments_open()) {
            ?>
					<span class="comments"><a href="<?php 
            the_permalink();
            ?>
#comments" title="<?php 
            the_title_attribute();
            ?>
"><?php 
            comments_number('Leave a Comment', '1 Comment', '% Comments');
            ?>
</a></span>
					<?php 
        }
        ?>
				</p>
            </div><!-- .post-meta -->

			<?php 
        if ($args['spt']) {
            ?>

			<?php 
            if (has_post_thumbnail()) {
                ?>
            <div class="post-thumb">
              <?php 
                $post_id = get_the_ID();
                echo PC_Utility::get_responsive_slider_image($post_id, 'post-thumbnail');
                /* Show post thumbnail image, if one exists. */
                ?>
            </div> <!-- .post-thumb -->
			<?php 
            }
            ?>

			<?php 
        }
        ?>

                <?php 
        global $more;
        $more = 0;
        the_content(' ' . $args['read_more']);
        wp_link_pages(array('before' => '<div class="page-link">', 'after' => '</div>'));
        ?>
            </div> <!-- .post-content -->

        </div> <!-- .post -->

    <?php 
    }
    function widget($args, $instance)
    {
        extract($args);
        $delay_speed = $instance['delay_speed'];
        $transition_speed = $instance['transition_speed'];
        $number_items = $instance['number_items'];
        $slider_groups = $instance['slider_groups'];
        $randomize = $instance['randomize'];
        $fi_post_link = $instance['fi_post_link'];
        $autoplay = $instance['autoplay'];
        $smooth_height = $instance['smooth_height'];
        $animation_loop = $instance['animation_loop'];
        $transition_effect = $instance['transition_effect'];
        /* */
        if (empty($slider_groups)) {
            $slider_groups = '';
        }
        $order = $randomize ? 'rand' : 'date';
        $autoplay_slides = $autoplay ? 'true' : 'false';
        $smooth_height = $smooth_height ? 'true' : 'false';
        $auto_animation_loop = $animation_loop ? 'true' : 'false';
        $r = new WP_Query(array('post_type' => 'portfolio', 'orderby' => $order, 'showposts' => $number_items, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'tax_query' => array(array('taxonomy' => 'portfolio_group', 'field' => 'id', 'terms' => $slider_groups))));
        if ($r->have_posts()) {
            // There is at least one post to show
            global $pc_is_front_page;
            global $pc_post_id;
            // need the post id to check for the sidebars per post/page feature
            global $wp_registered_sidebars;
            // global widget areas array
            global $pc_global_column_layout;
            // ***********************************************************
            // **     DETERMINE WIDGET AREA LOCATION AND WIDTH TYPE     **
            // ***********************************************************
            $widget_area = null;
            $sidebars_widgets = wp_get_sidebars_widgets();
            // Try to get the widget area the widget belongs to
            foreach ($sidebars_widgets as $sidebar => $widgets) {
                if ('wp_inactive_widgets' == $sidebar) {
                    continue;
                }
                // Ignore inactive widgets
                if (is_array($widgets)) {
                    if (in_array($this->id, $widgets)) {
                        $widget_area = $sidebar;
                    }
                }
            }
            // If widget instance exists in a widget area
            if ($widget_area) {
                // find the widget area width
                if (isset($wp_registered_sidebars[$widget_area]['width'])) {
                    $widget_area_width = $wp_registered_sidebars[$widget_area]['width'];
                    $width_default = 0;
                    // for debugging
                } else {
                    $widget_area_width = 'normal';
                    $width_default = 1;
                    // for debugging
                }
            }
            // *******************************************************
            // **     SET THE THUMBNAIL SIZE USED BY THE WIDGET     **
            // *******************************************************
            // add code to enter the correct classname, and slider thumbnail size, depending on the column layout and the widget area width
            if ($widget_area_width == 'full') {
                $slider_thumb_size = 'slider_content_full';
            } elseif ($widget_area_width == 'wide') {
                // check page layout to see if the page layout is twothirds, or full width
                $layout_num = (int) substr($pc_global_column_layout, 0, 1);
                if ($layout_num == 1) {
                    // full width layout
                    $slider_thumb_size = 'slider_content_full';
                } elseif ($layout_num == 2) {
                    // 2 column layout
                    $slider_thumb_size = 'slider_content_twothirds';
                } else {
                    // else assume 3 column layout
                    $slider_thumb_size = 'slider_content_third';
                }
            } else {
                // assume widget area width is 'normal'
                $slider_thumb_size = 'slider_content_third';
            }
            ?>

		<?php 
            echo $before_widget;
            ?>

			<script type="text/javascript">
				
				jQuery(window).load(function() {
					jQuery('.flexslider_<?php 
            echo $this->id;
            ?>
').flexslider({
						  animation: '<?php 
            echo $transition_effect;
            ?>
',
						  animationLoop: <?php 
            echo $auto_animation_loop;
            ?>
,
						  pauseOnAction: true,
						  slideshow: <?php 
            echo $autoplay_slides;
            ?>
,
						  pauseOnHover: true,
						  slideshowSpeed: <?php 
            echo $delay_speed;
            ?>
,
						  animationSpeed: <?php 
            echo $transition_speed;
            ?>
,
						  controlsContainer: ".flex-container_<?php 
            echo $this->id;
            ?>
",
						  smoothHeight: <?php 
            echo $smooth_height;
            ?>
,
						  multipleKeyboard: true,
						  start: function(slider) {
							<?php 
            // Add any 'start' callback code via a theme specific utility function cb
            if (method_exists('PC_TS_Utility', 'portfolio_slider_jquery_start_cb')) {
                echo PC_TS_Utility::portfolio_slider_jquery_start_cb();
            }
            ?>
						  },
						  before: function(slider) {
							// Add code here (via theme specific callback function)
						  },
						  after: function(slider) {
							// Add code here (via theme specific callback function)
						  }
					});
				});

			</script>

			<div class="flex-container flex-container_<?php 
            echo $this->id;
            ?>
">

				<div class="flexslider flexslider_<?php 
            echo $this->id;
            ?>
">
					<ul class="slides slides_<?php 
            echo $this->id;
            ?>
">

						<?php 
            while ($r->have_posts()) {
                $r->the_post();
                ?>

							<?php 
                /* Image */
                $post_id = get_the_ID();
                $featured_image = PC_Utility::get_responsive_slider_image($post_id, $slider_thumb_size);
                //$show_title = get_post_meta($post_id, '_'.PC_THEME_NAME_SLUG.'_slide_cpt_show_title',true);
                $title = get_the_title();
                //($show_title == 0) ? get_the_title() : null;
                $portfolio_fi_url = trim(get_post_meta($post_id, '_' . PC_THEME_NAME_SLUG . '_portfolio_cpt_fi_link', true));
                $portfolio_title_url = trim(get_post_meta($post_id, '_' . PC_THEME_NAME_SLUG . '_portfolio_cpt_title_link', true));
                $post_thumbnail_id = get_post_thumbnail_id($post_id);
                $featured_image_src_arr = wp_get_attachment_image_src($post_thumbnail_id, 'full');
                /* Portfolio featured image link. */
                if ($fi_post_link) {
                    /* Override default PF CPT behavior and link FI to post url by default. */
                    $featured_image_src = get_permalink($post_id);
                    $featured_image = '<a href="' . $featured_image_src . '">' . $featured_image . '</a>';
                } else {
                    if (empty($portfolio_fi_url)) {
                        if ($featured_image && is_array($featured_image_src_arr)) {
                            $featured_image_src = $featured_image_src_arr[0];
                            $featured_image = '<a href="' . $featured_image_src . '">' . $featured_image . '</a>';
                        }
                    } else {
                        if ($portfolio_fi_url != 'http://none') {
                            $featured_image = '<a href="' . $portfolio_fi_url . '">' . $featured_image . '</a>';
                        }
                    }
                }
                /* Portfolio title link. */
                if (empty($portfolio_title_url)) {
                    $pl = get_permalink($post_id);
                    $title = '<a href="' . $pl . '">' . $title . '</a>';
                } else {
                    if ($portfolio_title_url != 'http://none') {
                        $title = '<a href="' . $portfolio_title_url . '">' . $title . '</a>';
                    }
                }
                if (!empty($title)) {
                    $title = '<h3 class="portfolio-title">' . $title . '</h3>';
                }
                $content = wpautop(do_shortcode(get_the_content()));
                ?>

							<?php 
                /* Allow optional theme specific slider structure to be defined. */
                if (method_exists('PC_TS_Utility', 'custom_portfolio_slider_li_structure')) {
                    $args = array('title' => $title, 'featured_image' => $featured_image, 'content' => $content, 'post_id' => $post_id);
                    PC_TS_Utility::custom_portfolio_slider_li_structure($args);
                    /* Otherwise use the default structure. */
                } else {
                    ?>

									<li>
										<?php 
                    echo '<div class="portfolio-slide-content">';
                    echo $title;
                    //if($show_title == 0) echo $title;
                    if (!empty($featured_image)) {
                        echo $featured_image;
                    }
                    if (!empty($content)) {
                        echo $content;
                    }
                    echo '</div>';
                    ?>
									</li>

							<?php 
                }
                ?>

						<?php 
            }
            ?>

					</ul>
				</div>

			</div>

		<?php 
            echo $after_widget;
            ?>

		<?php 
            /* Reset the global $the_post as this query will have stomped on it. */
            wp_reset_postdata();
        } else {
            echo "<div>No slider items to show. Please select a group that contains some items!</div>";
        }
    }