1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
<?php
class Papi_Taxonomy_Type extends Papi_Entry_Type {
public $fill_labels = false;
public $labels = [];
public $redirect_after_create = false;
public $taxonomy = '';
public $type = 'taxonomy';
public function display( $taxonomy ) {
return true;
}
public function get_labels() {
if ( ! $this->fill_labels ) {
return $this->labels;
}
return array_merge( $this->labels, [
'add_new_item' => sprintf( '%s %s', __( 'Add New', 'papi' ), $this->name ),
'edit_item' => sprintf( '%s %s', __( 'Edit', 'papi' ), $this->name ),
'view_item' => sprintf( '%s %s', __( 'View', 'papi' ), $this->name )
] );
}
protected function setup_actions() {
foreach ( $this->taxonomy as $taxonomy ) {
if ( is_string( $taxonomy ) && taxonomy_exists( $taxonomy ) ) {
add_action( $taxonomy . '_edit_form', [$this, 'edit_form'] );
}
}
}
public function edit_form() {
?>
<div id="papi-hidden-editor" class="hide-if-js">
<?php wp_editor( '', 'papiHiddenEditor' ); ?>
</div>
<div id="poststuff">
<div id="post-body">
<?php
foreach ( $this->boxes as $box ) {
do_meta_boxes(
$box->id,
'normal',
null
);
}
?>
</div>
</div>
<?php
}
protected function setup_meta_data() {
parent::setup_meta_data();
$this->taxonomy = papi_to_array( $this->taxonomy );
}
}