[wp-trac] [WordPress Trac] #22080: add_theme_support should merge post-thumbnail post types by default (currently stomps)

WordPress Trac noreply at wordpress.org
Sun Apr 24 22:41:31 UTC 2016


#22080: add_theme_support should merge post-thumbnail post types by default
(currently stomps)
-------------------------------------+-----------------------------
 Reporter:  alexkingorg              |       Owner:
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  Future Release
Component:  Post Thumbnails          |     Version:  2.9
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-refresh  |     Focuses:
-------------------------------------+-----------------------------

Comment (by jmichaelward):

 I'm digging back into this issue, and I think some conversation is
 warranted with regard to exactly how this functionality should work before
 moving forward with any potential code fixes. The original issue and my
 response six months ago may not be entirely evident, so I'm hoping to
 provide a bit more clarity here so we can confirm whether this is in fact
 an issue at all and instead desired functionality by the
 `add_theme_support()` mechanism.

 The Codex states that, as of version 2.9, developers can indicate that
 they wish to add post thumbnails support to their theme.
 [https://core.trac.wordpress.org/ticket/22080#comment:5 As Alex King
 reported four years ago], they can do so by either writing
 `add_theme_support( 'post-thumbnails' );` in their `functions.php` file,
 or by optionally passing an array of post types they wish to support.

 [https://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
 According to the Codex], users "can optionally pass a second argument with
 an array of the Post Types for which you want to enable this feature.".

 When adding theme support without this optional array, there are no
 issues. However, when an array is passed, WordPress is told only to
 support post thumbnails for the provided post types.

 To the original issue submission,
 [https://core.trac.wordpress.org/ticket/22080#comment:2 @scribu asked],
 "...more importantly, why are you calling add_theme_support() from a
 plugin? It makes zero sense to me." Naturally, plugins such as WooCommerce
 desire to do exactly this, so they can provide post thumbnail supports for
 their product pages. Unfortunately, they're activating post thumbnails for
 all post types (without passing a parameter), when I believe their
 intention is to add theme support only for their product post type, but
 that's merely a related issue, though it may be a byproduct of this one.

 In WooCommerce's case, because they activate post thumbnails for all post
 types, developers don't need to add support for them to their theme at
 all. '''But this is actually the crux of the issue.''' A less-experienced
 developer may read the Codex and opt to pass an array of post types that
 don't include those that WooCommerce (or other third-party plugin
 developers) registered, and thus, override the post type support for all
 post types in which it was previously enabled.

 At this point, there is a question of intent. A developer who calls, for
 instance, `add_theme_support( 'post-thumbnails, array( 'post' ) );` may in
 fact be intending to disable post thumbnails for all other post types
 where it was previously supported, but as
 [https://core.trac.wordpress.org/ticket/22080#comment:9 @scribu
 indicated], there is another method to do that:
 `remove_post_type_support()`.

 I agree with @nacin's assessment that intent here is key, particularly
 when we're working with plugins that register post types outside of the
 theme (and if we're wanting to continue to promote user's ability to
 switch between themes without losing their content, this is important).
 Toward that end, `add_theme_support()` needs to correctly add support for
 a post type when an array is passed, and not squash any previously-added
 types, such as WooCommerce's thumbnail support for product.
 `remove_post_type_support()` works as it should, and if a developer adds
 it to their functions.php file, it's clear that their intent was to remove
 thumbnail support for that type (again, such as for WooCommerce's product
 post type).

 Thus, I propose updating `add_theme_support()` to build an array of post
 types that support post thumbnails, and will take on the work of doing so
 once I hear feedback from others.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/22080#comment:28>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list