Skip to content

Commit 5fdf02c

Browse files
authored
Move post type / taxonomy registration
To make things like pods-framework/pods-export-code#4 easier to accomplish.
1 parent 06484ab commit 5fdf02c

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

classes/PodsInit.php

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -882,9 +882,6 @@ public function setup_content_types( $force = false ) {
882882
$ct_post_types = $options['post_types'];
883883
$options = $options['options'];
884884

885-
$options = apply_filters( 'pods_register_taxonomy_' . $taxonomy, $options, $taxonomy );
886-
$options = apply_filters( 'pods_register_taxonomy', $options, $taxonomy );
887-
888885
$options = self::object_label_fix( $options, 'taxonomy' );
889886

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

908+
/**
909+
* Allow filtering of taxonomy options per taxonomy.
910+
*
911+
* @param array $options Taxonomy options
912+
* @param string $taxonomy Taxonomy name
913+
* @param array $ct_post_types Associated Post Types
914+
*/
915+
$options = apply_filters( 'pods_register_taxonomy_' . $taxonomy, $options, $taxonomy, $ct_post_types );
916+
917+
/**
918+
* Allow filtering of taxonomy options.
919+
*
920+
* @param array $options Taxonomy options
921+
* @param string $taxonomy Taxonomy name
922+
* @param array $ct_post_types Associated post types
923+
*/
924+
$options = apply_filters( 'pods_register_taxonomy', $options, $taxonomy, $ct_post_types );
925+
911926
register_taxonomy( $taxonomy, $ct_post_types, $options );
912927

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

929-
$options = apply_filters( 'pods_register_post_type_' . $post_type, $options, $post_type );
930-
$options = apply_filters( 'pods_register_post_type', $options, $post_type );
931-
932944
$options = self::object_label_fix( $options, 'post_type' );
933945

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

958+
/**
959+
* Allow filtering of post type options per post type.
960+
*
961+
* @param array $options Post type options
962+
* @param string $post_type Post type name
963+
*/
964+
$options = apply_filters( 'pods_register_post_type_' . $post_type, $options, $post_type );
965+
966+
/**
967+
* Allow filtering of post type options.
968+
*
969+
* @param array $options Post type options
970+
* @param string $post_type Post type name
971+
*/
972+
$options = apply_filters( 'pods_register_post_type', $options, $post_type );
973+
946974
register_post_type( $post_type, $options );
947975

948976
// Register post format taxonomy for this post type

0 commit comments

Comments
 (0)