=$limit) { array_pop($excerpt); $excerpt = implode(" ",$excerpt).'...'; } else { $excerpt = implode(" ",$excerpt); } $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt); return $excerpt; } register_activation_hook( __FILE__, 'lptw_recent_posts_activate' ); /* add price table editor metabox */ add_action( 'add_meta_boxes', 'lptw_recent_posts_options' ); function lptw_recent_posts_options () { add_meta_box( 'lptw_recent_posts_options', __( 'Advanced Recent Posts Options', 'lptw_recent_posts_domain' ), 'lptw_recent_posts_options_box_content', 'post', 'normal', 'default' ); } function lptw_recent_posts_options_box_content ( $post ) { // Add a nonce field so we can check for it later. wp_nonce_field( 'lptw_recent_posts_options_box', 'lptw_recent_posts_meta_box_nonce' ); $value = get_post_meta( $post->ID, 'featured_post', true ); if ($value == 'on') {$checked = 'checked="checked"';} else {$checked = '';} echo '
'; echo ''.__( 'Featured post displays larger than the other posts in Grid Layout', 'lptw_recent_posts_domain' ).'
'; } function lptw_recent_posts_options_save_meta_box_data( $post_id ) { /* * We need to verify this came from our screen and with proper authorization, * because the save_post action can be triggered at other times. */ // Check if our nonce is set. if ( ! isset( $_POST['lptw_recent_posts_meta_box_nonce'] ) ) { return; } // Verify that the nonce is valid. if ( ! wp_verify_nonce( $_POST['lptw_recent_posts_meta_box_nonce'], 'lptw_recent_posts_options_box' ) ) { return; } // If this is an autosave, our form has not been submitted, so we don't want to do anything. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Check the user's permissions. if ( isset( $_POST['post_type'] ) && 'post' == $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_id ) ) { return; } } else { if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } } /* OK, it's safe for us to save the data now. */ // Sanitize user input. $my_data = sanitize_text_field( $_POST['featured_post'] ); // Update the meta field in the database. update_post_meta( $post_id, 'featured_post', $my_data ); } add_action( 'save_post', 'lptw_recent_posts_options_save_meta_box_data' ); /** -------------------------------------- Fluid Images Widget -------------------------------------- **/ // Creating the widget with fluid images class lptw_recent_posts_fluid_images_widget extends WP_Widget { function __construct() { $widget_ops = array('classname' => 'lptw_recent_posts_fluid_images_widget', 'description' => __( "Your site’s most recent Posts. Displays big fluid images, post date ant title.", 'lptw_recent_posts_domain') ); parent::__construct('lptw-fluid-images-recent-posts', __('Recent Posts Widget (Fluid Images)', 'lptw_recent_posts_domain'), $widget_ops); $this->alt_option_name = 'lptw_widget_fluid_images_recent_entries'; add_action( 'save_post', array($this, 'flush_widget_cache') ); add_action( 'deleted_post', array($this, 'flush_widget_cache') ); add_action( 'switch_theme', array($this, 'flush_widget_cache') ); } // Creating widget front-end // This is where the action happens public function widget($args, $instance) { $cache = array(); if ( ! $this->is_preview() ) { $cache = wp_cache_get( 'lptw_recent_posts_fluid_images_widget', 'widget' ); } if ( ! is_array( $cache ) ) { $cache = array(); } if ( ! isset( $args['widget_id'] ) ) { $args['widget_id'] = $this->id; } if ( isset( $cache[ $args['widget_id'] ] ) ) { echo $cache[ $args['widget_id'] ]; return; } ob_start(); $show_widget_title = isset( $instance['show_widget_title'] ) ? $instance['show_widget_title'] : true; $exclude_current_post = isset( $instance['exclude_current_post'] ) ? $instance['exclude_current_post'] : true; $no_thumbnails = isset( $instance['no_thumbnails'] ) ? $instance['no_thumbnails'] : false; $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts', 'lptw_recent_posts_domain' ); $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; if ( ! $number ) {$number = 5;} $reverse_post_order = isset( $instance['reverse_post_order'] ) ? $instance['reverse_post_order'] : false; $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : true; $date_format = isset( $instance['date_format'] ) ? $instance['date_format'] : 'm/d/Y'; $time_format = isset( $instance['time_format'] ) ? $instance['time_format'] : 'g:i a'; $show_time = isset( $instance['show_time'] ) ? $instance['show_time'] : true; $show_time_before = isset( $instance['show_time_before'] ) ? $instance['show_time_before'] : true; $show_post_title = isset( $instance['show_post_title'] ) ? $instance['show_post_title'] : true; $show_title_before = isset( $instance['show_title_before'] ) ? $instance['show_title_before'] : true; $color_scheme = isset( $instance['color_scheme'] ) ? $instance['color_scheme'] : 'light'; $post_category = isset( $instance['post_category'] ) ? $instance['post_category'] : array(); if (!empty($post_category)) { $post_category_str = implode (',', $post_category); } $authors = isset( $instance['authors'] ) ? $instance['authors'] : array(); $post_type = isset( $instance['post_type'] ) ? $instance['post_type'] : 'post'; /* don't show post in recent if it shows in page */ global $post; if (!empty($post) && $exclude_current_post == true) { $exclude_post = array( $post->ID ); } if ( $post_type != 'post' ) { if (!empty($post_category)) { $tax_query = array('relation' => 'AND'); $taxonomies = get_object_taxonomies($post_type); if (!empty($taxonomies)) { foreach ($taxonomies as $taxonomy) { $tax_array = array('taxonomy' => $taxonomy, 'field' => 'term_id', 'include_children' => false, 'terms' => $post_category); array_push ($tax_query, $tax_array); } } } else { $tax_query = ''; } $post_category = ''; } if ($no_thumbnails == 'on') { $meta_key = '_thumbnail_id'; } else { $meta_key = ''; } $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'post_type' => $post_type, 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'post__not_in' => $exclude_post, 'author__in' => $authors, 'category__in' => $post_category, 'tax_query' => $tax_query, 'order' => 'DESC', 'orderby' => 'date', 'meta_key' => $meta_key ) ) ); if ($r->have_posts()) : if ($reverse_post_order == 'true') { $r->posts = array_reverse($r->posts); } ?> is_preview() ) { $cache[ $args['widget_id'] ] = ob_get_flush(); wp_cache_set( 'lptw_recent_posts_fluid_images_widget', $cache, 'widget' ); } else { ob_end_flush(); } } /* --------------------------------- Widget Backend --------------------------------- */ public function form( $instance ) { if ( isset( $instance[ 'title' ] ) ) { $title = esc_attr( $instance[ 'title' ]) ; } else { $title = __( 'Recent posts', 'lptw_recent_posts_domain' ); } if ( isset( $instance[ 'show_widget_title' ] ) ) { $show_widget_title = (bool) $instance[ 'show_widget_title' ]; } else { $show_widget_title = true; } if ( isset( $instance[ 'exclude_current_post' ] ) ) { $exclude_current_post = (bool) $instance[ 'exclude_current_post' ]; } else { $exclude_current_post = true; } if ( isset( $instance[ 'no_thumbnails' ] ) ) { $no_thumbnails = (bool) $instance[ 'no_thumbnails' ]; } else { $no_thumbnails = false; } if ( isset( $instance[ 'number' ] ) ) { $number = absint( $instance[ 'number' ] ); } else { $number = 5; } if ( isset( $instance[ 'reverse_post_order' ] ) ) { $reverse_post_order = (bool) $instance[ 'reverse_post_order' ]; } else { $reverse_post_order = false; } if ( isset( $instance[ 'show_post_title' ] ) ) { $show_post_title = (bool) $instance[ 'show_post_title' ]; } else { $show_post_title = true; } if ( isset( $instance[ 'show_title_before' ] ) ) { $show_title_before = (bool) $instance[ 'show_title_before' ]; } else { $show_title_before = false; } if ( isset( $instance[ 'show_date' ] ) ) { $show_date = (bool) $instance[ 'show_date' ]; } else { $show_date = false; } if ( isset( $instance[ 'date_format' ] ) ) { $date_format = $instance[ 'date_format' ]; } else { $date_format = 'm/d/Y'; } if ( isset( $instance[ 'time_format' ] ) ) { $time_format = $instance[ 'time_format' ]; } else { $time_format = 'g:i a'; } if ( isset( $instance[ 'show_time' ] ) ) { $show_time = (bool) $instance[ 'show_time' ]; } else { $show_time = false; } if ( isset( $instance[ 'show_time_before' ] ) ) { $show_time_before = (bool) $instance[ 'show_time_before' ]; } else { $show_time_before = false; } if ( isset( $instance[ 'color_scheme' ] ) ) { $color_scheme = $instance[ 'color_scheme' ] ; } else { $color_scheme = 'light'; } if ( isset( $instance[ 'post_category' ] ) ) { $post_category = $instance[ 'post_category' ]; } if ( isset( $instance[ 'authors' ] ) ) { $authors = $instance[ 'authors' ]; } if ( isset( $instance[ 'post_type' ] ) ) { $post_type = $instance[ 'post_type' ]; } else { $post_type = 'post_type'; } // Widget admin form ?>
id="get_field_id( 'show_widget_title' ); ?>" name="get_field_name( 'show_widget_title' ); ?>" />
If none of the categories is selected - will be displayed posts from all categories.
id="get_field_id( 'no_thumbnails' ); ?>" name="get_field_name( 'no_thumbnails' ); ?>" />
id="get_field_id( 'exclude_current_post' ); ?>" name="get_field_name( 'exclude_current_post' ); ?>" />
id="get_field_id( 'reverse_post_order' ); ?>" name="get_field_name( 'reverse_post_order' ); ?>" />
id="get_field_id( 'show_date' ); ?>" name="get_field_name( 'show_date' ); ?>" />
id="get_field_id( 'show_time' ); ?>" name="get_field_name( 'show_time' ); ?>" />
id="get_field_id( 'show_time_before' ); ?>" name="get_field_name( 'show_time_before' ); ?>" />
id="get_field_id( 'show_post_title' ); ?>" name="get_field_name( 'show_post_title' ); ?>" />
id="get_field_id( 'show_title_before' ); ?>" name="get_field_name( 'show_title_before' ); ?>" />
flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['lptw_widget_fluid_images_recent_entries']) ) delete_option('lptw_widget_fluid_images_recent_entries'); return $instance; } public function flush_widget_cache() { wp_cache_delete('lptw_recent_posts_fluid_images_widget', 'widget'); } } // Class wpb_widget ends here /** -------------------------------------- Small Thumbnails Widget -------------------------------------- **/ // Creating the widget with small thumbnails class lptw_recent_posts_thumbnails_widget extends WP_Widget { function __construct() { $widget_ops = array('classname' => 'lptw_recent_posts_thumbnails_widget', 'description' => __( "Your site’s most recent Posts. Displays small thumbnails, post date and title.", 'lptw_recent_posts_domain') ); parent::__construct('lptw-thumbnails-recent-posts', __('Recent Posts Widget (Thumbnails)', 'lptw_recent_posts_domain'), $widget_ops); $this->alt_option_name = 'lptw_widget_thumbnails_recent_entries'; add_action( 'save_post', array($this, 'flush_widget_cache') ); add_action( 'deleted_post', array($this, 'flush_widget_cache') ); add_action( 'switch_theme', array($this, 'flush_widget_cache') ); } // Creating widget front-end // This is where the action happens public function widget($args, $instance) { $cache = array(); if ( ! $this->is_preview() ) { $cache = wp_cache_get( 'lptw_recent_posts_thumbnails_widget', 'widget' ); } if ( ! is_array( $cache ) ) { $cache = array(); } if ( ! isset( $args['widget_id'] ) ) { $args['widget_id'] = $this->id; } if ( isset( $cache[ $args['widget_id'] ] ) ) { echo $cache[ $args['widget_id'] ]; return; } ob_start(); $show_widget_title = isset( $instance['show_widget_title'] ) ? $instance['show_widget_title'] : true; $exclude_current_post = isset( $instance['exclude_current_post'] ) ? $instance['exclude_current_post'] : true; $no_thumbnails = isset( $instance['no_thumbnails'] ) ? $instance['no_thumbnails'] : false; $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts', 'lptw_recent_posts_domain' ); $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5; if ( ! $number ) {$number = 5;} if ( isset( $instance[ 'reverse_post_order' ] ) ) { $reverse_post_order = (bool) $instance[ 'reverse_post_order' ]; } else { $reverse_post_order = false; } $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : true; $date_format = isset( $instance['date_format'] ) ? $instance['date_format'] : 'm/d/Y'; $time_format = isset( $instance['time_format'] ) ? $instance['time_format'] : 'g:i a'; $show_time = isset( $instance['show_time'] ) ? $instance['show_time'] : true; $show_time_before = isset( $instance['show_time_before'] ) ? $instance['show_time_before'] : true; $show_post_title = isset( $instance['show_post_title'] ) ? $instance['show_post_title'] : true; $show_title_before = isset( $instance['show_title_before'] ) ? $instance['show_title_before'] : false; $post_category = isset( $instance['post_category'] ) ? $instance['post_category'] : array(); $authors = isset( $instance['authors'] ) ? $instance['authors'] : array(); $post_type = isset( $instance['post_type'] ) ? $instance['post_type'] : 'post'; /* don't show post in recent if it shows in page */ global $post; if (!empty($post) && $exclude_current_post == true) { $exclude_post = array( $post->ID ); } if ( $post_type != 'post' ) { if (!empty($post_category)) { $tax_query = array('relation' => 'AND'); $taxonomies = get_object_taxonomies($post_type); if (!empty($taxonomies)) { foreach ($taxonomies as $taxonomy) { $tax_array = array('taxonomy' => $taxonomy, 'field' => 'term_id', 'include_children' => false, 'terms' => $post_category); array_push ($tax_query, $tax_array); } } } else { $tax_query = ''; } $post_category = ''; } if ($no_thumbnails == 'on') { $meta_key = '_thumbnail_id'; } else { $meta_key = ''; } $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'post_type' => $post_type, 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'post__not_in' => $exclude_post, 'author__in' => $authors, 'category__in' => $post_category, 'tax_query' => $tax_query, 'order' => 'DESC', 'orderby' => 'date', 'meta_key' => $meta_key ) ) ); if ($r->have_posts()) : if ($reverse_post_order == 'true') { $r->posts = array_reverse($r->posts); } ?> is_preview() ) { $cache[ $args['widget_id'] ] = ob_get_flush(); wp_cache_set( 'lptw_recent_posts_thumbnails_widget', $cache, 'widget' ); } else { ob_end_flush(); } } /* --------------------------------- Widget Backend --------------------------------- */ public function form( $instance ) { if ( isset( $instance[ 'title' ] ) ) { $title = esc_attr( $instance[ 'title' ]) ; } else { $title = __( 'Recent posts', 'lptw_recent_posts_domain' ); } if ( isset( $instance[ 'show_widget_title' ] ) ) { $show_widget_title = (bool) $instance[ 'show_widget_title' ]; } else { $show_widget_title = true; } if ( isset( $instance[ 'exclude_current_post' ] ) ) { $exclude_current_post = (bool) $instance[ 'exclude_current_post' ]; } else { $exclude_current_post = true; } if ( isset( $instance[ 'no_thumbnails' ] ) ) { $no_thumbnails = (bool) $instance[ 'no_thumbnails' ]; } else { $no_thumbnails = false; } if ( isset( $instance[ 'number' ] ) ) { $number = absint( $instance[ 'number' ] ); } else { $number = 5; } if ( isset( $instance[ 'reverse_post_order' ] ) ) { $reverse_post_order = (bool) $instance[ 'reverse_post_order' ]; } else { $reverse_post_order = false; } if ( isset( $instance[ 'show_post_title' ] ) ) { $show_post_title = (bool) $instance[ 'show_post_title' ]; } else { $show_post_title = true; } if ( isset( $instance[ 'show_title_before' ] ) ) { $show_title_before = (bool) $instance[ 'show_title_before' ]; } else { $show_title_before = false; } if ( isset( $instance[ 'show_date' ] ) ) { $show_date = (bool) $instance[ 'show_date' ]; } else { $show_date = false; } if ( isset( $instance[ 'date_format' ] ) ) { $date_format = $instance[ 'date_format' ]; } else { $date_format = 'd.m.Y'; } if ( isset( $instance[ 'time_format' ] ) ) { $time_format = $instance[ 'time_format' ]; } else { $time_format = 'H:i'; } if ( isset( $instance[ 'show_time' ] ) ) { $show_time = (bool) $instance[ 'show_time' ]; } else { $show_time = false; } if ( isset( $instance[ 'show_time_before' ] ) ) { $show_time_before = (bool) $instance[ 'show_time_before' ]; } else { $show_time_before = false; } if ( isset( $instance[ 'post_category' ] ) ) { $post_category = $instance[ 'post_category' ]; } if ( isset( $instance[ 'authors' ] ) ) { $authors = $instance[ 'authors' ]; } if ( isset( $instance[ 'post_type' ] ) ) { $post_type = $instance[ 'post_type' ]; } else { $post_type = 'post_type'; } // Widget admin form ?>
id="get_field_id( 'show_widget_title' ); ?>" name="get_field_name( 'show_widget_title' ); ?>" />
If none of the categories is selected - will be displayed posts from all categories.
id="get_field_id( 'no_thumbnails' ); ?>" name="get_field_name( 'no_thumbnails' ); ?>" />
id="get_field_id( 'exclude_current_post' ); ?>" name="get_field_name( 'exclude_current_post' ); ?>" />
id="get_field_id( 'reverse_post_order' ); ?>" name="get_field_name( 'reverse_post_order' ); ?>" />
id="get_field_id( 'show_date' ); ?>" name="get_field_name( 'show_date' ); ?>" />
id="get_field_id( 'show_time' ); ?>" name="get_field_name( 'show_time' ); ?>" />
id="get_field_id( 'show_time_before' ); ?>" name="get_field_name( 'show_time_before' ); ?>" />
id="get_field_id( 'show_post_title' ); ?>" name="get_field_name( 'show_post_title' ); ?>" />
id="get_field_id( 'show_title_before' ); ?>" name="get_field_name( 'show_title_before' ); ?>" />
flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['lptw_widget_thumbnails_recent_entries']) ) delete_option('lptw_widget_thumbnails_recent_entries'); return $instance; } public function flush_widget_cache() { wp_cache_delete('lptw_recent_posts_thumbnails_widget', 'widget'); } } // Class wpb_widget ends here // Register and load the widget function lptw_recent_posts_load_widget() { register_widget( 'lptw_recent_posts_fluid_images_widget' ); register_widget( 'lptw_recent_posts_thumbnails_widget' ); } add_action( 'widgets_init', 'lptw_recent_posts_load_widget' ); function lptw_create_element_style ($style_args) { if ( is_array($style_args) ) { $element_style = 'style = "'; foreach ( $style_args as $argument ) { $element_style .= $argument . ' '; } $element_style .= '"'; return $element_style; } else { return; } } /** -------------------------------------- Shortcode -------------------------------------- **/ function lptw_display_recent_posts ( $atts ) { $default_posts_per_page = get_option( 'posts_per_page', '10' ); $a = shortcode_atts( array( 'post_type' => 'post', 'category_id' => '', 'authors_id' => '', 'post_parent' => '0', 'posts_per_page' => $default_posts_per_page, 'exclude_posts' => '', 'thumbnail_size' => 'thumbnail', 'random_thumbnail' => 'false', 'layout' => 'basic', 'color_scheme' => 'no-overlay', 'show_date' => 'true', 'fluid_images' => 'false', 'columns' => '1', 'height' => '', 'featured_height' => '400', 'min_height' => '400', 'width' => '300', 'date_format' => 'd.m.Y', 'time_format' => 'H:i', 'show_time' => 'true', 'show_time_before' => 'true', 'show_date_before_title' => 'true', 'order' => 'DESC', 'orderby' => 'date', 'reverse_post_order' => 'false', 'background_color' => '#4CAF50', 'text_color' => '#ffffff', 'no_thumbnails' => 'hide', 'space_hor' => 10, 'space_ver' => 10, 'tags_id' => '', 'tags_exclude' => 'false', 'override_colors' => 'false', 'excerpt_show' => 'true', 'excerpt_lenght' => '35', 'ignore_more_tag' => 'false' ), $atts ); if ($a['no_thumbnails'] == 'hide') { $meta_key = '_thumbnail_id'; } else { $meta_key = ''; } if (!empty($a['exclude_posts'])) { $exclude_post = explode(',', $a['exclude_posts']); } else { $exclude_post = ''; } if ( strpos($a['authors_id'], ',') !== false ) { $authors_id = array_map('intval', explode(',', $a['authors_id'])); } else { $authors_id = (integer) $a['authors_id']; } if ( strpos($a['category_id'], ',') !== false ) { $post_category = array_map('intval', explode(',', $a['category_id'])); } else { $post_category = (integer) $a['category_id']; } $tax_query = ''; if ( $a['post_type'] != 'post' && !empty($post_category) ) { $tax_query = array('relation' => 'AND'); $taxonomies = get_object_taxonomies($a['post_type']); if (!empty($taxonomies)) { foreach ($taxonomies as $taxonomy) { $tax_array = array('taxonomy' => $taxonomy, 'field' => 'term_id', 'terms' => $post_category, 'include_children' => false); array_push ($tax_query, $tax_array); } } $post_category = ''; } if ( strpos($a['tags_id'], ',') !== false ) { $post_tags = array_map('intval', explode(',', $a['tags_id'])); } else { $post_tags = (integer) $a['tags_id']; } if ( $a['post_type'] != 'post' ) { $post_tags = ''; } if ( $a['tags_exclude'] == 'true' ) { $tags_type = 'tag__not_in'; } else { $tags_type = 'tag__in'; } $lptw_shortcode_query_args = array( 'post_type' => $a['post_type'], 'posts_per_page' => $a['posts_per_page'], 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'post__not_in' => $exclude_post, 'author__in' => $authors_id, 'category__in' => $post_category, $tags_type => $post_tags, 'tax_query' => $tax_query, 'order' => $a['order'], 'orderby' => $a['orderby'], 'meta_key' => $meta_key ); $lptw_shortcode_query = new WP_Query( $lptw_shortcode_query_args ); if( $lptw_shortcode_query->have_posts() ) { if ($a['reverse_post_order'] == 'true') { $lptw_shortcode_query->posts = array_reverse($lptw_shortcode_query->posts); } $i=1; $content = ''; switch ($a['layout']) { case 'basic': $content .= '';
echo $lptw_shortcode_query->post->ID;
echo $lptw_shortcode_query->post->post_excerpt;
echo '';
*/
$element_style_args = Array();
if ($a['width'] != '' && $a['fluid_images'] != 'true') {$element_style_args[] = 'width:'.$a['width'].'px;';}
if ($a['height'] != '' && $a['fluid_images'] != 'true') {$element_style_args[] = 'height:'.$a['height'].'px;';}
if ($a['fluid_images'] == 'true') {
$column_style = 'lptw-columns-'.$a['columns'];
}
else {
$column_style = 'lptw-columns-fixed';
}
$post_id = get_the_ID();
$post_date = get_the_date($a['date_format']);
$post_time = get_the_date($a['time_format']);
if ($a['show_time'] == 'true' && $a['show_time_before'] == 'true') { $post_date_time = $post_time . ' ' . $post_date; }
else if ( $a['show_time'] == 'true' && $a['show_time_before'] != 'true' ) { $post_date_time = $post_date . ' ' . $post_time; }
else { $post_date_time = $post_date; }
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), $a['thumbnail_size'] );
$url = $thumb['0'];
if (!$url && $a['random_thumbnail'] == 'true') {
$thumb_posts = get_posts(array('orderby' => 'rand', 'category' => $a['category_id'], 'numberposts' => 1, 'meta_key' => '_thumbnail_id'));
foreach( $thumb_posts as $rand_post ) {
$rand_post_id = $rand_post->ID;
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($rand_post_id), $a['thumbnail_size'] );
$url = $thumb['0'];
}
}
if ( $a['columns'] > 1 && $a['layout'] != 'grid-medium' ) {
if (($i % $a['columns']) == 0) {
$element_style_args[] = 'padding-bottom: '.$a['space_ver'].'px;';
}
elseif (($i % $a['columns']) == 1 && $a['fluid_images'] != 'true') {
$element_style_args[] = 'padding-right: '.$a['space_hor'].'px;';
$element_style_args[] = 'padding-bottom: '.$a['space_ver'].'px;';
$element_style_args[] = 'clear: left;';
}
else {
$element_style_args[] = 'padding-right: '.$a['space_hor'].'px;';
$element_style_args[] = 'padding-bottom: '.$a['space_ver'].'px;';
}
} else if ( $a['columns'] == 1 && $a['layout'] != 'grid-medium' ) { $element_style_args[] = 'padding-bottom: '.$a['space_ver'].'px;'; }
else { $element_style_args[] = 'margin-bottom: '.$a['space_ver'].'px;'; }
/* start layouts output */
/* basic layout - one or tho columns, fixed or adaptive width */
if ($a['layout'] == 'basic' ) {
$content .= '