WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #36666, comment 14


Ignore:
Timestamp:
04/30/2016 09:26:17 PM (5 years ago)
Author:
jmichaelward
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #36666, comment 14

    initial v1  
    1111Ticket [https://core.trac.wordpress.org/ticket/22080 #22080] perpetuated this thinking a bit, as we simply exited if theme support was already set. What if, instead, we just never saved `theme_support` as a boolean?
    1212
    13 My latest patch (36666.4.diff) updates `add_theme_support` to set `$args` to the value of `get_post_types_by_support( 'thumbnail'` )` if either `$args` or `$_wp_theme_features[ 'post-thumbnails' ]` is set to `true`. From then on, any post type that registers and adds theme support for post thumbnails will have its post type pushed to the array, as before. In addition, post thumbnail support can be removed in functions.php, as long as the function is called during the same action (or later) in which a post type's support was added. So, in the case of WooCommerce, post thumbnail support for products can be removed in `after_setup_theme` (but not before), and in the case of other custom post types, `remove_theme_support` must be called in `init` for it to work. Otherwise, it just fails silently.
     13My latest patch (36666.4.diff) updates `add_theme_support` to set `$args` to the value of `get_post_types_by_support( 'thumbnail')` if either `$args` or `$_wp_theme_features[ 'post-thumbnails' ]` is set to `true`. From then on, any post type that registers and adds theme support for post thumbnails will have its post type pushed to the array, as before. In addition, post thumbnail support can be removed in functions.php, as long as the function is called during the same action (or later) in which a post type's support was added. So, in the case of WooCommerce, post thumbnail support for products can be removed in `after_setup_theme` (but not before), and in the case of other custom post types, `remove_theme_support` must be called in `init` for it to work. Otherwise, it just fails silently.
    1414
    1515Also, since HTML5, Post Formats, and Post Thumbnails would ultimately run the same kind of check, I decided to take @flixos90's previous advice and put everything back into a single switch, because it's far more streamlined.