public function add_form_fields() {
		$html_name       = esc_attr( papi_get_page_type_key() );
		$taxonomy        = papi_get_qs( 'taxonomy' );
		$taxonomy_object = get_taxonomy( $taxonomy );

		// Get only the taxonomy types that has the taxonomy.
		$taxonomy_types = array_filter( $this->taxonomy_types, function ( $taxonomy_type ) use ( $taxonomy ) {
			return in_array( $taxonomy, $taxonomy_type->taxonomy, true ) && $taxonomy_type->display( $taxonomy );
		} );
		$taxonomy_types = array_values( $taxonomy_types );

		// Do not display empty select if no taxonomy types.
		if ( empty( $taxonomy_types ) ) {
			return;
		}

		// Prepare taxonomy types with standard taxonomy type.
		$taxonomy_types = $this->prepare_taxonomy_types( $taxonomy_types );

		// Render a dropdown if more than one taxonomy types
		// exists on the taxonomy.
		if ( count( $taxonomy_types ) > 1 ):
			?>
			<div class="form-field">
				<label for="<?php echo esc_attr( $html_name ); ?>">
					<?php echo esc_html( sprintf( __( '%s type', 'papi' ), $taxonomy_object->labels->singular_name ) ); ?>
				</label>
				<select name="<?php echo esc_attr( $html_name ); ?>" id="<?php echo esc_attr( $html_name ); ?>" data-papi-page-type-key="true">
					<?php
					foreach ( $taxonomy_types as $taxonomy_type ) {
						papi_render_html_tag( 'option', [
							'data-redirect' => $taxonomy_type->redirect_after_create,
							'value'         => esc_attr( $taxonomy_type->get_id() ),
							esc_html( $taxonomy_type->name )
						] );
					}
					?>
				</select>
			</div>
			<?php
		else:
			papi_render_html_tag( 'input', [
				'data-redirect'           => $taxonomy_types[0]->redirect_after_create,
				'data-papi-page-type-key' => true,
				'name'                    => esc_attr( $html_name ),
				'type'                    => 'hidden',
				'value'                   => esc_attr( $taxonomy_types[0]->get_id() )
			] );
		endif;
	}
public function add_form_fields() {
		$html_name       = esc_attr( papi_get_page_type_key() );
		$taxonomy        = papi_get_qs( 'taxonomy' );
		$taxonomy_object = get_taxonomy( $taxonomy );

		// Get only the taxonomy types that has the taxonomy.
		$taxonomy_types = array_filter( $this->taxonomy_types, function ( $taxonomy_type ) use ( $taxonomy ) {
			return in_array( $taxonomy, $taxonomy_type->taxonomy, true ) && $taxonomy_type->display( $taxonomy );
		} );
		$taxonomy_types = array_values( $taxonomy_types );

		// Do not display empty select if no taxonomy types.
		if ( empty( $taxonomy_types ) ) {
			return;
		}

		// Prepare taxonomy types with standard taxonomy type.
		$taxonomy_types = $this->prepare_taxonomy_types( $taxonomy_types );

		// Render a dropdown if more than one taxonomy types
		// exists on the taxonomy.
		if ( count( $taxonomy_types ) > 1 ):
			?>
			<div class="form-field">
				<label for="<?php echo esc_attr( $html_name ); ?>">
					<?php echo esc_html( sprintf( __( '%s type', 'papi' ), $taxonomy_object->labels->singular_name ) ); ?>
				</label>
				<select name="<?php echo esc_attr( $html_name ); ?>" id="<?php echo esc_attr( $html_name ); ?>" data-papi-page-type-key="true">
					<?php
					foreach ( $taxonomy_types as $taxonomy_type ) {
						papi_render_html_tag( 'option', [
							'data-redirect' => $taxonomy_type->redirect_after_create,
							'value'         => esc_attr( $taxonomy_type->get_id() ),
							esc_html( $taxonomy_type->name )
						] );
					}
					?>
				</select>
			</div>
			<?php
		else:
			papi_render_html_tag( 'input', [
				'data-redirect'           => $taxonomy_types[0]->redirect_after_create,
				'data-papi-page-type-key' => true,
				'name'                    => esc_attr( $html_name ),
				'type'                    => 'hidden',
				'value'                   => esc_attr( $taxonomy_types[0]->get_id() )
			] );
		endif;
	}
public function add_form_fields ( ) { $ html_name = esc_attr ( papi_get_page_type_key ( ) ) ; $ taxonomy = papi_get_qs ( 'taxonomy' ) ; $ taxonomy_object = get_taxonomy ( $ taxonomy ) ; // Get only the taxonomy types that has the taxonomy. $ taxonomy_types = array_filter ( $ this -> taxonomy_types , function ( $ taxonomy_type ) use ( $ taxonomy ) { return in_array ( $ taxonomy , $ taxonomy_type -> taxonomy , true ) && $ taxonomy_type -> display ( $ taxonomy ) ; } ) ; $ taxonomy_types = array_values ( $ taxonomy_types ) ; // Do not display empty select if no taxonomy types. if ( empty ( $ taxonomy_types ) ) { return ; } // Prepare taxonomy types with standard taxonomy type. $ taxonomy_types = $ this -> prepare_taxonomy_types ( $ taxonomy_types ) ; // Render a dropdown if more than one taxonomy types // exists on the taxonomy. if ( count ( $ taxonomy_types ) > 1 ) : ?>
			<div class="form-field">
				<label for="<?php echo esc_attr ( $ html_name ) ; ?>">
					<?php echo esc_html ( sprintf ( __ ( '%s type' , 'papi' ) , $ taxonomy_object -> labels -> singular_name ) ) ; ?>
				</label>
				<select name="<?php echo esc_attr ( $ html_name ) ; ?>" id="<?php echo esc_attr ( $ html_name ) ; ?>" data-papi-page-type-key="true">
					<?php foreach ( $ taxonomy_types as $ taxonomy_type ) { papi_render_html_tag ( 'option' , [ 'data-redirect' => $ taxonomy_type -> redirect_after_create , 'value' => esc_attr ( $ taxonomy_type -> get_id ( ) ) , esc_html ( $ taxonomy_type -> name ) ] ) ; } ?>
				</select>
			</div>
			<?php else : papi_render_html_tag ( 'input' , [ 'data-redirect' => $ taxonomy_types [ 0 ] -> redirect_after_create , 'data-papi-page-type-key' => true , 'name' => esc_attr ( $ html_name ) , 'type' => 'hidden' , 'value' => esc_attr ( $ taxonomy_types [ 0 ] -> get_id ( ) ) ] ) ; endif ; }
Add form fields to edit tags page.
Add form fields to edit tags page .