config = $config; } /** * Hook registration into init. * * @return void */ public function register_hooks() { add_action( 'init', array( $this, 'register' ) ); } /** * Register the taxonomy against every managed post type. * * @return void */ public function register() { $post_types = $this->config->managed_post_types(); if ( empty( $post_types ) ) { $post_types = array( 'post', 'page' ); } register_taxonomy( self::TAXONOMY, $post_types, array( 'labels' => array( 'name' => __( 'Workflow Flags', 'ost-editorial-workflow' ), 'singular_name' => __( 'Workflow Flag', 'ost-editorial-workflow' ), 'menu_name' => __( 'Workflow Flags', 'ost-editorial-workflow' ), ), 'public' => false, 'publicly_queryable' => false, // Hierarchical => a checkbox list of the predefined flags (not free-text tags). 'hierarchical' => true, 'show_ui' => true, 'show_in_menu' => false, 'show_in_rest' => true, 'show_admin_column' => true, 'rewrite' => false, ) ); } /** * Insert the default flag terms (idempotent). Called on activation. * * @return void */ public function insert_default_terms() { $terms = array( 'policy' => __( 'Policy', 'ost-editorial-workflow' ), 'legal' => __( 'Legal', 'ost-editorial-workflow' ), 'compliance' => __( 'Compliance', 'ost-editorial-workflow' ), 'urgent' => __( 'Urgent', 'ost-editorial-workflow' ), ); foreach ( $terms as $slug => $label ) { if ( ! term_exists( $slug, self::TAXONOMY ) ) { wp_insert_term( $label, self::TAXONOMY, array( 'slug' => $slug ) ); } } } }