PHP code example of outstand / term-selector

1. Go to this page and download the library: Download outstand/term-selector library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

outstand / term-selector example snippets


register_taxonomy(
	'region',
	'post',
	[
		// ...
		'capabilities' => [
			'edit_terms' => 'manage_options',
		],
	]
);

register_taxonomy(
	'region',
	'post',
	[
		'hierarchical'              => false,
		'show_ui'                   => true,
		'show_in_rest'              => true,
		'use_hierarchical_selector' => true,
	]
);

add_filter(
	'outstand_term_selector_taxonomies',
	function ( $slugs ) {
		$slugs[] = 'post_tag';
		return array_values( array_diff( $slugs, [ 'region' ] ) );
	}
);

register_taxonomy(
	'difficulty',
	'post',
	[
		'hierarchical'       => true,
		'show_ui'            => true,
		'show_in_rest'       => true,
		'use_radio_selector' => true,
	]
);

add_filter(
	'outstand_term_selector_radio_taxonomies',
	function ( $slugs ) {
		$slugs[] = 'category';
		return $slugs;
	}
);

add_filter(
	'outstand_term_selector_radio_show_clear',
	function ( $show, $taxonomy ) {
		return 'difficulty' === $taxonomy ? false : $show;
	},
	10,
	2
);