@@ -846,14 +846,26 @@ public function process_images( WP_REST_Request $request ): array {
846846 * @param string $content The content to process.
847847 */
848848 public function process_cpt ( $ content , $ cpt_blocks , $ style ) {
849+ $ valid_cpt_block_names = [
850+ 'kadence/header ' ,
851+ 'kadence/navigation ' ,
852+ 'kadence/advanced-form ' ,
853+ 'kadence/query ' ,
854+ 'kadence/query-card ' ,
855+ ];
856+ $ valid_cpt_block_post_types = [
857+ 'kadence_header ' ,
858+ 'kadence_navigation ' ,
859+ 'kadence_form ' ,
860+ 'kadence_query ' ,
861+ 'kadence_query_card ' ,
862+ ];
863+
864+
849865 foreach ( $ cpt_blocks as $ cpt_block_name => $ cpt_block_content ) {
850- switch ( $ cpt_block_name ) {
851- case 'kadence/header ' :
852- case 'kadence/navigation ' :
853- case 'kadence/advanced-form ' :
854- case 'kadence/query ' :
855- case 'kadence/query-card ' :
856- foreach ( $ cpt_block_content as $ cpt_key => $ cpt_data ) {
866+ if ( in_array ( $ cpt_block_name , $ valid_cpt_block_names ) ) {
867+ foreach ( $ cpt_block_content as $ cpt_key => $ cpt_data ) {
868+ if ( in_array ( $ cpt_data ['post_type ' ], $ valid_cpt_block_post_types ) ) {
857869 $ old_id = $ cpt_data ['ID ' ];
858870 $ id_map = [];
859871 if ( ! empty ( $ cpt_data ['inner_posts ' ] ) && is_array ( $ cpt_data ['inner_posts ' ] ) ) {
@@ -872,7 +884,7 @@ public function process_cpt( $content, $cpt_blocks, $style ) {
872884 $ content = $ this ->update_block_ids ( $ content , $ new_id_map );
873885 }
874886 }
875- break ;
887+ }
876888 }
877889 }
878890 return $ content ;
@@ -922,7 +934,7 @@ public function install_single_cpt( $cpt_data, $id_map = [], $style = 'light' )
922934 'post_type ' => $ cpt_data ['post_type ' ],
923935 'post_title ' => $ title ,
924936 'post_content ' => '' ,
925- 'post_status ' => ' publish ' ,
937+ 'post_status ' => current_user_can ( ' publish_posts ' ) ? ' publish ' : ' pending ' ,
926938 ],
927939 true
928940 );
0 commit comments