WordPress.org

Make WordPress Core

Changeset 12134


Ignore:
Timestamp:
11/01/2009 10:10:06 AM (12 years ago)
Author:
westi
Message:

Introduce require_if_theme_supports(), move post thumbnails functions to there own include and only included them if the theme supports them. See #10928 and [12132]

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post-template.php

    r12105 r12134  
    882882
    883883//
    884 // Post images
    885 //
    886 
    887 function has_post_image( $post_id = NULL ) {
    888     global $id;
    889     $post_id = ( NULL === $post_id ) ? $id : $post_id;
    890     return !! get_post_image_id( $post_id );
    891 }
    892 
    893 function get_post_image_id( $post_id = NULL ) {
    894     global $id;
    895     $post_id = ( NULL === $post_id ) ? $id : $post_id;
    896     return get_post_meta( $post_id, '_thumbnail_id', true );
    897 }
    898 
    899 function the_post_image( $size = 'thumbnail', $attr = '' ) {
    900     echo get_the_post_image( NULL, $size, $attr );
    901 }
    902 
    903 function get_the_post_image( $post_id = NULL, $size = 'thumbnail', $attr = '' ) {
    904     global $id;
    905     $post_id = ( NULL === $post_id ) ? $id : $post_id;
    906     $post_image_id = get_post_image_id( $post_id );
    907     $size = apply_filters( 'post_image_size', $size );
    908     if ( $post_image_id ) {
    909         do_action( 'begin_fetch_post_image_html', $post_id, $post_image_id, $size ); // for "Just In Time" filtering of all of wp_get_attachment_image()'s filters
    910         $html = wp_get_attachment_image( $post_image_id, $size, false, $attr );
    911         do_action( 'end_fetch_post_image_html', $post_id, $post_image_id, $size );
    912     } else {
    913         $html = '';
    914     }
    915     return apply_filters( 'post_image_html', $html, $post_id, $post_image_id );
    916 }
    917 
    918 //
    919884// Attachments
    920885//
  • trunk/wp-includes/theme.php

    r12132 r12134  
    13061306/**
    13071307 * Allows a theme to register its support of a certain feature
     1308 *
     1309 * Must be called in the themes functions.php file to work.
    13081310 *
    13091311 * @author Mark Jaquith
     
    13301332}
    13311333
     1334/**
     1335 * Checks a theme's support for a given feature before loading the functions which implement it.
     1336 *
     1337 * @author Peter Westwood
     1338 * @since 2.9
     1339 * @param string $feature the feature being checked
     1340 * @param string $include the file containing the functions that implement the feature
     1341 */
     1342function require_if_theme_supports( $feature, $include) {
     1343    if ( current_theme_supports( $feature ) )
     1344        require ( $include );
     1345}
     1346
    13321347?>
  • trunk/wp-settings.php

    r12128 r12134  
    688688    include(TEMPLATEPATH . '/functions.php');
    689689
     690// Load in support for template functions which the theme supports
     691require_if_theme_supports( 'post-thumbnails', ABSPATH . WPINC . '/post-image-template.php' );
     692
    690693/**
    691694 * Runs just before PHP shuts down execution.
Note: See TracChangeset for help on using the changeset viewer.