mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Allow registering post image support per post type. fixes #11364
git-svn-id: https://develop.svn.wordpress.org/trunk@12350 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1320,9 +1320,14 @@ function add_custom_image_header($header_callback, $admin_header_callback) {
|
||||
*/
|
||||
function add_theme_support( $feature ) {
|
||||
global $_wp_theme_features;
|
||||
|
||||
if ( 'post-thumbnails' == $feature ) // This was changed during 2.9 beta. I'll be nice and not break things.
|
||||
$feature = 'post-images';
|
||||
$_wp_theme_features[$feature] = true;
|
||||
|
||||
if ( func_num_args() == 1 )
|
||||
$_wp_theme_features[$feature] = true;
|
||||
else
|
||||
$_wp_theme_features[$feature] = array_slice( func_get_args(), 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1336,7 +1341,33 @@ function add_theme_support( $feature ) {
|
||||
|
||||
function current_theme_supports( $feature ) {
|
||||
global $_wp_theme_features;
|
||||
return ( isset( $_wp_theme_features[$feature] ) && $_wp_theme_features[$feature] );
|
||||
|
||||
if ( !isset( $_wp_theme_features[$feature] ) )
|
||||
return false;
|
||||
|
||||
// If no args passed then no extra checks need be performed
|
||||
if ( func_num_args() <= 1 )
|
||||
return true;
|
||||
|
||||
$args = array_slice( func_get_args(), 1 );
|
||||
|
||||
// @todo Allow pluggable arg checking
|
||||
switch ( $feature ) {
|
||||
case 'post-images':
|
||||
// post-thumbnails can be registered for only certain content/post types by passing
|
||||
// an array of types to add_theme_support(). If no array was passed, then
|
||||
// any type is accepted
|
||||
if ( true === $_wp_theme_features[$feature] ) // Registered for all types
|
||||
return true;
|
||||
$content_type = $args[0];
|
||||
if ( in_array($content_type, $_wp_theme_features[$feature][0]) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user