Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move post type / taxonomy registration #4498

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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