diff --git a/wp-includes/post-image-template.php b/wp-includes/post-image-template.php new file mode 100644 index 0000000000..10bec133f6 --- /dev/null +++ b/wp-includes/post-image-template.php @@ -0,0 +1,43 @@ + \ No newline at end of file diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 19f4019487..ef59d4bacd 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -880,41 +880,6 @@ function walk_page_dropdown_tree() { return call_user_func_array(array(&$walker, 'walk'), $args); } -// -// Post images -// - -function has_post_image( $post_id = NULL ) { - global $id; - $post_id = ( NULL === $post_id ) ? $id : $post_id; - return !! get_post_image_id( $post_id ); -} - -function get_post_image_id( $post_id = NULL ) { - global $id; - $post_id = ( NULL === $post_id ) ? $id : $post_id; - return get_post_meta( $post_id, '_thumbnail_id', true ); -} - -function the_post_image( $size = 'thumbnail', $attr = '' ) { - echo get_the_post_image( NULL, $size, $attr ); -} - -function get_the_post_image( $post_id = NULL, $size = 'thumbnail', $attr = '' ) { - global $id; - $post_id = ( NULL === $post_id ) ? $id : $post_id; - $post_image_id = get_post_image_id( $post_id ); - $size = apply_filters( 'post_image_size', $size ); - if ( $post_image_id ) { - 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 - $html = wp_get_attachment_image( $post_image_id, $size, false, $attr ); - do_action( 'end_fetch_post_image_html', $post_id, $post_image_id, $size ); - } else { - $html = ''; - } - return apply_filters( 'post_image_html', $html, $post_id, $post_image_id ); -} - // // Attachments // diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 8dd2ada6e8..f92c2ab2ad 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1305,6 +1305,8 @@ function add_custom_image_header($header_callback, $admin_header_callback) { /** * Allows a theme to register its support of a certain feature + * + * Must be called in the themes functions.php file to work. * * @author Mark Jaquith * @since 2.9 @@ -1329,4 +1331,17 @@ function current_theme_supports( $feature ) { return ( isset( $_wp_theme_features[$feature] ) && $_wp_theme_features[$feature] ); } +/** + * Checks a theme's support for a given feature before loading the functions which implement it. + * + * @author Peter Westwood + * @since 2.9 + * @param string $feature the feature being checked + * @param string $include the file containing the functions that implement the feature + */ +function require_if_theme_supports( $feature, $include) { + if ( current_theme_supports( $feature ) ) + require ( $include ); +} + ?> diff --git a/wp-settings.php b/wp-settings.php index 47d5735b6d..f2f6dad4bf 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -687,6 +687,9 @@ if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists(STYLESHEETPATH . '/functions if ( file_exists(TEMPLATEPATH . '/functions.php') ) include(TEMPLATEPATH . '/functions.php'); +// Load in support for template functions which the theme supports +require_if_theme_supports( 'post-thumbnails', ABSPATH . WPINC . '/post-image-template.php' ); + /** * Runs just before PHP shuts down execution. *