Skip to content

Commit

Permalink
Merge pull request #4498 from pods-framework/feature/improve-register…
Browse files Browse the repository at this point in the history
…-filters-for-export-purpose

Move post type / taxonomy registration
  • Loading branch information
sc0ttkclark authored Oct 6, 2017
2 parents 06484ab + 131b0e9 commit 92d935e
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 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 @@ -904,8 +901,26 @@ public function setup_content_types( $force = false ) {
$options['rewrite']['slug'] = _x( $options['rewrite']['slug'], 'URL taxonomy slug', 'pods' );
}

/**
* 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 );

if ( 1 == pods_var( 'pods_debug_register', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) {
pods_debug( array( $taxonomy, $ct_post_types, $options ) );
pods_debug( array( 'register_taxonomy', compact( 'taxonomy', 'ct_post_types', 'options' ) ) );
}

register_taxonomy( $taxonomy, $ct_post_types, $options );
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 @@ -939,8 +951,24 @@ public function setup_content_types( $force = false ) {
$options['rewrite']['slug'] = _x( $options['rewrite']['slug'], 'URL slug', 'pods' );
}

/**
* 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 );

if ( 1 == pods_var( 'pods_debug_register', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) {
pods_debug( array( $post_type, $options ) );
pods_debug( array( 'register_post_type', compact( 'post_type', 'options' ) ) );
}

register_post_type( $post_type, $options );
Expand Down

0 comments on commit 92d935e

Please sign in to comment.