function wp_rp_generate_related_posts_list_items($related_posts, $selected_related_posts) { $options = wp_rp_get_options(); $platform_options = wp_rp_get_platform_options(); $output = ""; $statistics_enabled = $options['ctr_dashboard_enabled']; $limit = $options['max_related_posts']; $inserted_urls = array(); // Used to prevent duplicates $special_urls = array(); foreach ($selected_related_posts as $post) { if (property_exists($post, 'post_url') && $post->post_url) { $special_urls[$post->post_url] = true; } } $default_post_type = empty($selected_related_posts) ? 'none' : 'empty'; $image_size = $platform_options['theme_name'] == 'pinterest.css' ? 'full' : 'thumbnail'; for ($i = 0; $i < $limit; $i++) { $related_post = wp_rp_get_next_post($related_posts, $selected_related_posts, $inserted_urls, $special_urls, $default_post_type); if (!$related_post) { break; } if (property_exists($related_post, 'type')) { $post_type = $related_post->type; } else { $post_type = $default_post_type; } if (in_array($post_type, array('empty', 'none'))) { $post_id = 'in-' . $related_post->ID; } else { $post_id = 'ex-' . $related_post->ID; } $data_attrs = ''; if ($statistics_enabled) { $data_attrs .= 'data-position="' . $i . '" data-poid="' . $post_id . '" data-post-type="' . $post_type . '" '; } $output .= '<li ' . $data_attrs . '>'; $post_url = property_exists($related_post, 'post_url') ? $related_post->post_url : get_permalink($related_post->ID); $img = wp_rp_get_post_thumbnail_img($related_post, $image_size); if ($img) { $output .= '<a href="' . $post_url . '" class="wp_rp_thumbnail">' . $img . '</a>'; } if ($platform_options["display_publish_date"]) { $dateformat = get_option('date_format'); $output .= '<small class="wp_rp_publish_date">' . mysql2date($dateformat, $related_post->post_date) . '</small> '; //$output .= mysql2date($dateformat, $related_post->post_date) . " -- "; } $output .= '<a href="' . $post_url . '" class="wp_rp_title">' . wptexturize($related_post->post_title) . '</a>'; if ($platform_options["display_comment_count"] && property_exists($related_post, 'comment_count')) { $output .= '<small class="wp_rp_comments_count"> (' . $related_post->comment_count . ')</small><br />'; } if ($platform_options["display_excerpt"]) { $excerpt_max_length = $platform_options["excerpt_max_length"]; $excerpt = ''; if ($related_post->post_excerpt) { $excerpt = strip_shortcodes(strip_tags($related_post->post_excerpt)); } if (!$excerpt) { $excerpt = strip_shortcodes(strip_tags($related_post->post_content)); } if ($excerpt) { if (strlen($excerpt) > $excerpt_max_length) { $excerpt = wp_rp_text_shorten($excerpt, $excerpt_max_length); } $output .= ' <small class="wp_rp_excerpt">' . $excerpt . '</small>'; } } $output .= '</li>'; } return $output; }
function wp_rp_process_latest_post_thumbnails() { $latest_posts = get_posts(array('numberposts' => WP_RP_THUMBNAILS_NUM_PREGENERATED_POSTS)); foreach ($latest_posts as $post) { wp_rp_get_post_thumbnail_img($post); } }