function wp_thumbnails_handler($atts) { $def = "null"; extract(shortcode_atts(array('type' => 'random', 'num' => $def, 'width' => $def, 'height' => $def, 'id' => $def, 'media' => $def, 'thumb' => $def, 'order' => $def), $atts)); $args = "display=false"; if ($num != $def) { $args .= "&num={$num}"; } if ($width != $def) { $args .= "&width={$width}"; if ($height != $def) { $args .= "&height={$height}"; } } if ($id != $def) { $args .= "&id={$id}"; } if ($media != $def) { $args .= "&media={$media}"; if ($thumb != $def) { $args .= "&thumb={$thumb}"; } } if ($order != $def) { $args .= "&order={$order}"; } if ($type == 'random') { return wp_thumbnails_for_random_posts($args); } else { if ($type == 'recent') { return wp_thumbnails_for_recent_posts($args); } else { if ($type == 'popular') { return wp_thumbnails_for_popular_posts($args); } else { if ($type == 'related') { return wp_thumbnails_for_related_posts($args); } else { if ($type == 'single') { return wp_thumbnails_for_single_post($args); } else { if ($type == 'category') { return wp_thumbnails_for_category($args); } else { if ($type == 'tag') { return wp_thumbnails_for_tag($args); } } } } } } } }
function wp_thumbnails_posts_auto($content) { $options = get_option('thumbnails_anywhere_options'); if (is_single()) { $output = ""; if ($options["auto_random"] == "true") { $thumbnails = wp_thumbnails_for_random_posts('display=false'); if ($thumbnails) { $output .= '<div id="sssaaas">' . $options["auto_random_title"] . $thumbnails . "</div>"; } } if ($options["auto_related"] == "true") { $thumbnails = wp_thumbnails_for_related_posts('display=false'); if ($thumbnails) { $output .= '<div id="sssaaas">' . $options["auto_related_title"] . $thumbnails . "</div>"; } } if ($options["auto_single"] == "true") { $thumbnails = wp_thumbnails_for_single_post('display=false&wrap=false'); if ($thumbnails) { $output .= '<div id="sssaaas">' . $options["auto_single_title"] . $thumbnails . "</div>"; } } $content = $content . $output; } return $content; }
function wp_thumbnails_for_homepage_auto_excerpt($excerpt) { $auto = get_option('thumbnails_anywhere_options'); if (is_home() && $auto['auto_home'] == "true" || is_category() && $auto['auto_category'] == "true" || is_search() && $auto['auto_search'] == "true" || is_tag() && $auto['auto_tag_page'] == "true") { $style = "single"; if (is_home()) { $style = $auto['auto_home_style']; } else { if (is_category()) { $style = $auto['auto_cat_style']; } else { if (is_tag()) { $style = $auto['auto_tag_style']; } else { if (is_search()) { $style = $auto['auto_search_style']; } } } } if ($style == "multiple") { $thumbnail = wp_thumbnails_for_single_post('display=false'); } else { if ($style == "smart") { $thumbnail = wp_thumbnails_for_smart_homepage('display=false'); } else { $thumbnail = wp_thumbnails_for_homepage('display=false'); } } //当前的 filter 也就是 $wp_current_filter 数组中的最后一个,end() 操作数组指针返回数组中最后一个值。 //global $wp_current_filter; //echo "current filters in auto_excerpt: ".end( $wp_current_filter )."<br>"; return $thumbnail . $excerpt; } else { return $excerpt; } }