layout_content($layout_content);
}
else{
if(!empty($post_grid_layout_content[$layout_content])){
$layout = $post_grid_layout_content[$layout_content];
}
else{
$layout = array();
}
}
$html_content = '';
$html.='
';
foreach($layout as $item_id=>$item_info){
$item_key = $item_info['key'];
if(!empty($item_info['char_limit'])){
$char_limit = $item_info['char_limit'];
}
if(!empty($item_info['link_target'])){
$link_target = $item_info['link_target'];
}
else{
$link_target = '';
}
if($item_key=='title'){
$html_content.='
';
$html_content.= apply_filters('post_grid_filter_grid_item_title',wp_trim_words(get_the_title(), $char_limit,''));
$html_content.='
';
}
elseif($item_key=='title_link'){
$html_content.= '
'.apply_filters('post_grid_filter_grid_item_title',wp_trim_words(get_the_title(), $char_limit,'')).'';
}
elseif($item_key=='content'){
$html_content.='
';
$the_content = get_the_content();
$html_content.= apply_filters('post_grid_filter_grid_item_content', $the_content);
//$html_content.= apply_filters( 'the_content', get_the_content() );
$html_content.='
';
}
elseif($item_key=='read_more'){
if(!empty($item_info['read_more_text'])){
$read_more_text = $item_info['read_more_text'];
}
else{
$read_more_text = apply_filters('post_grid_filter_grid_item_read_more', __('Read more.', post_grid_textdomain));
}
$html_content.= '
'.$read_more_text.'';
}
elseif($item_key=='thumb'){
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'full' );
$thumb_url = $thumb['0'];
$html_content.='
';
if(!empty($thumb_url)){
$html_content.= '
![]('.$thumb_url.')
';
}
$html_content.='
';
}
elseif($item_key=='thumb_link'){
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'full' );
$thumb_url = $thumb['0'];
$html_content.='
';
if(!empty($thumb_url)){
$html_content.= '
![]('.$thumb_url.')
';
}
$html_content.='
';
}
elseif($item_key=='excerpt'){
$html_content.='
';
//var_dump(get_the_excerpt());
$the_content = get_the_excerpt();
$excerpt_removed_shortcode = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', strip_shortcodes($the_content));
$html_content.= apply_filters('post_grid_filter_grid_item_excerpt',wp_trim_words($excerpt_removed_shortcode, $char_limit,''));
//$html_content.= wp_trim_words(get_the_excerpt(), $char_limit,'');
$html_content.='
';
}
elseif($item_key=='excerpt_read_more'){
$html_content.='
';
$read_more_text = apply_filters('post_grid_filter_grid_item_read_more', __('Read more.', post_grid_textdomain));
$html_content.= wp_trim_words(strip_shortcodes(get_the_excerpt()), $char_limit,'').'
'.$read_more_text.'';
$html_content.='
';
}
elseif($item_key=='post_date'){
$html_content.='
';
$html_content.= apply_filters('post_grid_filter_grid_item_post_date', get_the_date());
//$html_content.= get_the_date();
$html_content.='
';
}
elseif($item_key=='author'){
$html_content.='
';
$html_content.= apply_filters('post_grid_filter_grid_item_author', get_the_author());
//$html_content.= get_the_author();
$html_content.='
';
}
elseif($item_key=='author_link'){
//$html_content.='
';
}
elseif($item_key=='categories'){
$html_content.='
';
$categories = get_the_category();
$separator = ' ';
$output = '';
if ( ! empty( $categories ) ) {
foreach( $categories as $category ) {
$html_content .= '
' . esc_html( $category->name ) . '' . $separator;
}
$html_content.= trim( $output, $separator );
}
$html_content.='
';
}
elseif($item_key=='tags'){
$html_content.='
';
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag){
$html_content.= '
'.$tag->name . ' ';
}
}
$html_content.='
';
}
elseif($item_key=='comments_count'){
$html_content.='
';
$comments_number = get_comments_number( get_the_ID() );
if(comments_open()){
if ( $comments_number == 0 ) {
$html_content.= __('No Comments',post_grid_textdomain);
} elseif ( $comments_number > 1 ) {
$html_content.= $comments_number . __(' Comments',post_grid_textdomain);
} else {
$html_content.= __('1 Comment',post_grid_textdomain);
}
}
$html_content.='
';
}
elseif($item_key=='comments'){
$html_content.='
';
$html_content.= '';
$comments_count = wp_count_comments(get_the_ID());
$total_comments = $comments_count->approved;
//var_dump(get_the_ID());
if($total_comments <= 0)
{
$html_content.= '';
}
else
{
$comments = get_comments(array(
'post_id' => get_the_ID(),
'status' => 'approve',
'number' => 5,
'order' => 'ASC',
));
if(empty($comments))
{
$html_content.= '';
}
else
{
$html_content.= '';
}
}
$html_content.='
';
}
elseif($item_key=='wc_full_price'){
$html_content.='
';
$is_product = get_post_type( get_the_ID() );
$active_plugins = get_option('active_plugins');
if(in_array( 'woocommerce/woocommerce.php', (array) $active_plugins ) && $is_product=='product'){
global $woocommerce, $product;
$full_price = $product->get_price_html();
$html_content.=$full_price;
}
$html_content.='
';
}
elseif($item_key=='wc_add_to_cart'){
$html_content.='
';
$is_product = get_post_type( get_the_ID() );
$active_plugins = get_option('active_plugins');
if(in_array( 'woocommerce/woocommerce.php', (array) $active_plugins ) && $is_product=='product'){
global $woocommerce, $product;
$add_to_cart = do_shortcode('[add_to_cart show_price="false" id="'.get_the_ID().'"]');
$html_content.= $add_to_cart;
}
$html_content.='
';
}
elseif($item_key=='edd_price'){
$html_content.='
';
$is_download = get_post_type( get_the_ID() );
$active_plugins = get_option('active_plugins');
if(in_array( 'easy-digital-downloads/easy-digital-downloads.php', (array) $active_plugins ) && $is_download=='download'){
$edd_price = edd_price(get_the_ID(),false);
$html_content.= $edd_price;
}
$html_content.='
';
}
elseif($item_key=='edd_add_to_cart'){
$html_content.='
';
$is_download = get_post_type( get_the_ID() );
$active_plugins = get_option('active_plugins');
if(in_array( 'easy-digital-downloads/easy-digital-downloads.php', (array) $active_plugins ) && $is_download=='download'){
$purchase_link = do_shortcode('[purchase_link id="'.get_the_ID().'" text="'.__('Add to Cart','post_grid_textdomain').'" style="button"]' );
$html_content.= $purchase_link;
}
$html_content.='
';
}
elseif($item_key=='share_button'){
$html_content.='
';
$html_share_buttons = '';
$html_share_buttons.= '
';
$html_content.= apply_filters('post_grid_filter_share_buttons',$html_share_buttons);
$html_content.='
';
}
elseif($item_key=='hr'){
$html_content.= '
';
}
else{
$html_content.= '';
}
}
$html.= apply_filters('post_grid_filter_html_content', $html_content);
$html.='
'; // .layer-content
'.$comment_content.'
'; $html_content.= '