Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#35688 closed enhancement (duplicate)

Introduce Taxonomy Supports Infrastructure

Reported by: isoftware's profile isoftware Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords:
Focuses: Cc:

Description

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'] );
	}
   ...
}

Change History (3)

#2 @chriscct7
9 years ago

  • Version trunk deleted

#3 @boonebgorges
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi @isoftware - Thanks for the ticket. I'm going to mark as a duplicate of #32642. Please join the discussion there.

Note: See TracTickets for help on using tickets.