PHP code example of wecodemore / termlimit

1. Go to this page and download the library: Download wecodemore/termlimit 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/ */

    

wecodemore / termlimit example snippets



/** Plugin Name: Term Limit config */

// Apply a minimum of 3 and a limit of 6 terms
add_filter( 'wcm-term.limit', function( Array $limit )
{
    return range( 3, 6 );
} );

// Apply the limit to the following post types
add_filter( 'wcm-term.types', function( Array $types )
{
    return [ 'post', 'my-custom-post-type', ];
} );

class MyCustomTaxonomy extends AbstractTaxon implements TaxonInterface
{
	public function __construct()
	{
		$this->append( explode( ",", filter_var(
			$_POST['tax_input']['custom_terms'],
			FILTER_SANITIZE_STRING,
			[ FILTER_NULL_ON_FAILURE, ]
		) ) );
	}
}


/** Plugin Name: (Debug) Dump $_POST during save_post */
add_action( 'save_post', function()
{
	exit( var_dump( $_POST ) );
} );