Skip to content

Commit

Permalink
Move post type / taxonomy registration
Browse files Browse the repository at this point in the history
To make things like pods-framework/pods-export-code#4 easier to accomplish.
  • Loading branch information
sc0ttkclark authored Oct 6, 2017
1 parent 06484ab commit 5fdf02c
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions classes/PodsInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -882,9 +882,6 @@ public function setup_content_types( $force = false ) {
$ct_post_types = $options['post_types'];
$options = $options['options'];

$options = apply_filters( 'pods_register_taxonomy_' . $taxonomy, $options, $taxonomy );
$options = apply_filters( 'pods_register_taxonomy', $options, $taxonomy );

$options = self::object_label_fix( $options, 'taxonomy' );

/**
Expand All @@ -908,6 +905,24 @@ public function setup_content_types( $force = false ) {
pods_debug( array( $taxonomy, $ct_post_types, $options ) );
}

/**
* Allow filtering of taxonomy options per taxonomy.
*
* @param array $options Taxonomy options
* @param string $taxonomy Taxonomy name
* @param array $ct_post_types Associated Post Types
*/
$options = apply_filters( 'pods_register_taxonomy_' . $taxonomy, $options, $taxonomy, $ct_post_types );

/**
* Allow filtering of taxonomy options.
*
* @param array $options Taxonomy options
* @param string $taxonomy Taxonomy name
* @param array $ct_post_types Associated post types
*/
$options = apply_filters( 'pods_register_taxonomy', $options, $taxonomy, $ct_post_types );

register_taxonomy( $taxonomy, $ct_post_types, $options );

if ( ! empty( $options['show_in_rest'] ) ) {
Expand All @@ -926,9 +941,6 @@ public function setup_content_types( $force = false ) {
continue;
}

$options = apply_filters( 'pods_register_post_type_' . $post_type, $options, $post_type );
$options = apply_filters( 'pods_register_post_type', $options, $post_type );

$options = self::object_label_fix( $options, 'post_type' );

// Max length for post types are 20 characters
Expand All @@ -943,6 +955,22 @@ public function setup_content_types( $force = false ) {
pods_debug( array( $post_type, $options ) );
}

/**
* Allow filtering of post type options per post type.
*
* @param array $options Post type options
* @param string $post_type Post type name
*/
$options = apply_filters( 'pods_register_post_type_' . $post_type, $options, $post_type );

/**
* Allow filtering of post type options.
*
* @param array $options Post type options
* @param string $post_type Post type name
*/
$options = apply_filters( 'pods_register_post_type', $options, $post_type );

register_post_type( $post_type, $options );

// Register post format taxonomy for this post type
Expand Down

0 comments on commit 5fdf02c

Please sign in to comment.