[wp-trac] [WordPress Trac] #35688: Introduce Taxonomy Supports Infrastructure

WordPress Trac noreply at wordpress.org
Mon Feb 1 13:38:28 UTC 2016


#35688: Introduce Taxonomy Supports Infrastructure
-------------------------+-----------------------------
 Reporter:  isoftware    |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Taxonomy     |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 Following the release of 4.4 that included the much anticipated term meta
 functionality It would be great to add taxonomy supports in order to
 manage taxonomy related features.

 This would bring taxonomies in sync with post type supports and theme
 supports functionality.

 '''Core functions that need to be introduces are:'''
 {{{
         /**
          * Register support of certain features for a taxonomy.
          *
          * @param string          $taxonomy The taxonomy from which to add
 the feature.
          * @param string|array $feature   The feature being added, accepts
 an array of
          *                                feature strings or a single
 string.
          * @return void
          */
         function add_taxonomy_support( $taxonomy, $feature ) {
                 global $_wp_taxonomy_features;

                 $features = (array) $feature;
                 foreach ( $features as $feature ) {
                         if ( 2 === func_num_args() ) {
                                 $_wp_taxonomy_features[ $taxonomy ][
 $feature ] = true;
                         } else {
                                 $_wp_taxonomy_features[ $taxonomy ][
 $feature ] = array_slice( func_get_args(), 2 );
                         }
                 }
         }
 }}}

 {{{
         /**
          * Remove support for a feature from a taxonomy.
          *
          * @param string $taxonomy The taxonomy from which to remove the
 feature.
          * @param string $feature  The feature being removed.
          * @return void
          */
         function remove_taxonomy_support( $taxonomy, $feature ) {
                 global $_wp_taxonomy_features;

                 if ( isset( $_wp_taxonomy_features[ $taxonomy ][ $feature
 ] ) ) {
                         unset( $_wp_taxonomy_features[ $taxonomy ][
 $feature ]);
                 }
         }
 }}}

 {{{
         /**
          * Get all the taxonomy features
          *
          * @param string $taxonomy The taxonomy.
          * @return array The taxonomy supported features.
          */
         function get_all_taxonomy_supports( $taxonomy ) {
                 global $_wp_taxonomy_features;

                 if ( isset( $_wp_taxonomy_features[ $taxonomy ] ) ) {
                         return $_wp_taxonomy_features[ $taxonomy ];
                 }
                 return array();
         }
 }}}

 {{{
         /**
          * Determine whether a taxonomy's supports the specified feature.
          *
          * @param string $taxonomy The taxonomy being checked.
          * @param string $feature     The feature being checked.
          * @return bool True if the taxonomy supports the specified
 feature; Otherwise False.
          */
         function taxonomy_supports( $taxonomy, $feature ) {
                 global $_wp_taxonomy_features;

                 return (isset($_wp_taxonomy_features[ $taxonomy ][
 $feature ] ) );
         }
 }}}

 '''Core functions that need to be extended are:'''

 {{{
 register_taxonomy( $taxonomy, $object_type, $args=array()) {
       $defaults = array(
              ...
              'support' =>array()
       );
 ...
        if ( ! empty( $args['supports'] ) ) {
                 add_taxonomy_support( $taxonomy, $args['supports'] );
                 unset( $args['supports'] );
         }
    ...
 }

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35688>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list