Ejemplo n.º 1
0
		function wm_shortcode_posts( $atts, $content = null ) {
			extract( shortcode_atts( array(
				'align'          => 'left',
				'category'       => null,
				'columns'        => 4,
				'count'          => 4,
				'desc_size'      => 4,
				'excerpt_length' => 20,
				'order'          => 'new',
				'scroll'         => 0,
				'scroll_stack'   => false,
				'thumb'          => true,
				), $atts )
				);

			$out = '';

			$imgSize = ( wm_option( 'general-projects-image-ratio' ) ) ? ( 'mobile-' . wm_option( 'general-projects-image-ratio' ) ) : ( 'mobile-ratio-169' );

			//validation
			$align         = ( 'right' === trim( $align ) ) ? ( trim( $align ) ) : ( 'left' );
			$cols          = ( 0 < absint( $columns ) && 7 > absint( $columns ) ) ? ( absint( $columns ) ) : ( 4 );
			$colsDesc      = ( 1 < absint( $desc_size ) && 7 > absint( $desc_size ) ) ? ( absint( $desc_size ) ) : ( 4 );
			$count         = ( $count ) ? ( absint( $count ) ) : ( 4 );
			$orderMethod   = array(
					'all'    => array( 'new', 'old', 'name', 'random' ),
					'new'    => array( 'date', 'DESC' ),
					'old'    => array( 'date', 'ASC' ),
					'name'   => array( 'title', 'ASC' ),
					'random' => array( 'rand', '' )
				);
			$order         = ( in_array( trim( $order ), $orderMethod['all'] ) ) ? ( $orderMethod[trim( $order )] ) : ( $orderMethod['new'] );
			$thumb         = ( $thumb ) ? ( ' has-thumbs' ) : ( false );
			$excerptLength = ( isset( $excerpt_length ) ) ? ( absint( $excerpt_length ) ) : ( 10 );

			$classScroll = array( '', '', '' );
			if ( $scroll && 999 < absint( $scroll ) )
				$classScroll = array( ' scrollable auto', absint( $scroll ), ' auto-scroll' );
			elseif ( $scroll )
				$classScroll = array( ' scrollable', '', ' manual-scroll' );
			if ( $scroll && $scroll_stack )
				$classScroll[0] .= ' stack';

			if ( $category )
				if ( is_numeric( $category ) ) {
					$category = absint( $category );
				} else {
					$category = get_term_by( 'slug', sanitize_title( $category ), 'category' );
					$category = ( $category && isset( $category->term_id ) ) ? ( $category->term_id ) : ( null );
				}
			else
				$category = null;

			//get the posts
			wp_reset_query();

			$queryArgs = array(
					'posts_per_page'      => $count,
					'ignore_sticky_posts' => 1,
					'cat'                 => $category,
					'orderby'             => $order[0],
					'order'               => $order[1],
					'tax_query'           => array( array(
						'taxonomy' => 'post_format',
						'field'    => 'slug',
						'terms'    => array( 'post-format-quote', 'post-format-status' ),
						'operator' => 'NOT IN',
						) )
				);

			$posts = new WP_Query( $queryArgs );

			if ( $posts->have_posts() ) {

				$i    = $row = 0;
				$out .= '<div class="wrap-posts-shortcode clearfix apply-top-margin' . $thumb . $classScroll[2] . '">';

				if ( $content ) {
				//if description (shortcode content)
					$out .= ( 'right' === $align ) ? ( '<div class="column col-' . ( $colsDesc - 1 ) . $colsDesc . '"><div class="wrap-posts' . $classScroll[0] . '" data-time="' . $classScroll[1] . '" data-columns="' . $cols . '">' ) : ( '<div class="column col-1' . $colsDesc . ' wrap-description">' . do_shortcode( $content ) . '</div><div class="column col-' . ( $colsDesc - 1 ) . $colsDesc . ' last"><div class="wrap-posts' . $classScroll[0] . '" data-time="' . $classScroll[1] . '" data-columns="' . $cols . '">' ); //if description on the right - open posts container and inner container only ELSE output content column and open posts container
				} else {
				//if no description (no shortcode content)
					$out .= '<div class="wrap-posts' . $classScroll[0] . '" data-time="' . $classScroll[1] . '" data-columns="' . $cols . '">';
				}

					$out .= ( ! $classScroll[0] ) ? ( '<div class="row">' ) : ( '' );

					while ( $posts->have_posts() ) : //output post content
						$posts->the_post();

						//setting excerpt text
						if ( 0 < $excerptLength ) {
							$excerptText = $posts->post->post_excerpt . $posts->post->post_content;
							if ( has_post_format( 'audio' ) || has_post_format( 'video' ) ) {
								$mediaURL = '';
								//search for the first URL in content
								preg_match( '/http(.*)/', strip_tags( $excerptText ), $matches );
								if ( isset( $matches[0] ) )
									$mediaURL = trim( $matches[0] );
								//remove <a> tag containing URL
								$excerptText = preg_replace( '/<a(.*?)>http(.*?)<\/a>/', '', $excerptText );
								//remove any video URL left in content
								if ( $mediaURL )
									$excerptText = str_replace( array( $mediaURL, $mediaURL . ' ', ' ' . $mediaURL ), '', $excerptText );
							}
							$excerptText = wp_trim_words( strip_tags( $excerptText ), $excerptLength, '&hellip;' );
						} else {
							$excerptText = '';
						}

						$postOutput  = array(
								'cats'     => ( ! wm_option( 'blog-disable-cats' ) ) ? ( get_the_category_list( ', ' ) ) : ( '' ),
								'comments' => ( ! wm_option( 'blog-disable-comments-count' ) ) ? ( '<a href="' . get_comments_link() . '" class="comments-count" title="' . __( 'Comments: ', 'lespaul_domain' ) . get_comments_number() . '">' . get_comments_number() . '</a>' ) : ( '' ),
								'date'     => '<time datetime="' . esc_attr( get_the_date( 'c' ) ) . '">' . esc_html( get_the_date() ) . '</time>',
								'thumb'    => wm_thumb( array(
										'class'       => 'post-thumb',
										'size'        => $imgSize,
										'list'        => true,
										'placeholder' => true,
										'overlay'     => __( 'Read more', 'lespaul_domain' ),
									) ),
								'title'    => '<h3 class="post-title text-element"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>',
								'excerpt'  => $excerptText,
								'more'     => ' | ' . wm_more( 'nobtn' )
							);

						if  ( ! $classScroll[0] ) {
							$row  = ( ++$i % $cols === 1 ) ? ( $row + 1 ) : ( $row );
							$out .= ( $i % $cols === 1 && 1 < $row ) ? ( '</div><div class="row">' ) : ( '' );
						}

						$out   .= '<article class="column col-1' . $cols . ' no-margin">';
							$out .= ( $thumb ) ? ( $postOutput['thumb'] ) : ( '' );
							$out .= '<div class="text">';
								$out .= '<div class="text-element post-categories">' . $postOutput['cats'] . '</div>';
								$out .= $postOutput['title'];
								$out .= '<div class="text-element post-date post-comments">' . $postOutput['date'] . $postOutput['comments'] . '</div>';
								$out .= '<div class="post-excerpt text-element">' . $postOutput['excerpt'] . '</div>';
							$out .= '</div>';
						$out   .= '</article>';
					endwhile;

					$out .=  ( ! $classScroll[0] ) ? ( '</div>' ) : ( '' );

				if ( $content ) {
				//if description (shortcode content)
					$out .= ( 'right' === $align ) ? ( '</div></div><div class="column col-1' . $colsDesc . ' last wrap-description">' . do_shortcode( $content ) . '</div>' ) : ( '</div></div>' ); //if description on the right - close posts container and its inner container and output content column ELSE just close posts container and its inner container
				} else {
				//if no description (no shortcode content)
					$out .= '</div>';
				}

				$out .= '</div>';

			}
			wp_reset_query();

			if ( $classScroll[0] )
				wp_enqueue_script( 'bxslider' );

			return $out;
		}
Ejemplo n.º 2
0
 function wm_content_or_excerpt($post, $content_filters = true)
 {
     //Helper variables
     $output = $link = '';
     //Requirements check
     if (!$post || !is_object($post) || !isset($post->post_content) || !isset($post->ID)) {
         return;
     }
     //Preparing output
     if (false !== stripos($post->post_content, '<!--more-->')) {
         //Display excerpt until <!--more--> tag
         //Helper variables
         //Required for <!--more--> tag to work
         global $more;
         $more = 0;
         $output .= '<div class="more-tag-excerpt">';
         if (!post_password_required()) {
             if (has_excerpt()) {
                 $output .= wm_excerpt();
             }
             $output .= $content_filters ? apply_filters('wmhook_content_filters', get_the_content('')) : get_the_content('');
         } else {
             $output .= '<strong>' . __('Password protected', 'wm_domain') . '</strong>';
         }
         $output .= '</div>';
         $link = get_permalink() . '#more-' . $post->ID;
     } else {
         //Display excerpt only
         $output .= wm_excerpt();
         $link = get_permalink();
     }
     if ($output) {
         $output .= '<p class="more-link-container">';
         $output .= wm_more(array('link' => $link));
         $output .= '</p>';
     }
     //Output
     return apply_filters('wmhook_wm_content_or_excerpt_output', $output);
 }
Ejemplo n.º 3
0
			$titleWithImage = '';
			if ( has_post_thumbnail()) {
				$titleWithImage .= '<a href="' . get_permalink() . '" title="' . esc_attr( get_the_title() ) . '" class="alignright frame">';
				$titleWithImage .= get_the_post_thumbnail( null, 'widget' );
				$titleWithImage .= '</a>';
			}
			$titleWithImage .= '<a href="' . get_permalink() . '">';
			$titleWithImage .= get_the_title();
			$titleWithImage .= '</a>';

			$out .= '<article>';
			$out .= '<div class="article-content"><span class="numbering' . $orderClass . '">' . $order . '</span>';
			$out .= '<h2 class="post-title">' . $titleWithImage . '</h2>';
			if ( get_the_excerpt() )
				$out .= '<div class="excerpt"><p>' . strip_tags( apply_filters( 'convert_chars', strip_shortcodes( get_the_excerpt() ) ) ) . '</p><p>' . wm_more( 'nobtn', false ) . '</p></div>';
			$out .= '</div>';
			$out .= ( 'page' === $post->post_type ) ? ( wm_meta( array( 'permalink' ), null, 'footer', false ) ) : ( wm_meta( null, null, 'footer', false ) );
			$out .= '</article>';

			//the actual output
			if ( $out && $countOK ) {
				echo '<div class="search-item' . $even . '">' . $out . '</div>';

				$even = ( $even ) ? ( '' ) : ( ' even' );

				$order++;
			}
		endwhile;
		?>