Create a composer.json in your plugin root or mu-plugins
{
"require": {
"megumi/wp-ajaxonomy": "*"
}
}
Place the following code into your plugin.
require_once dirname( __FILE__ ) . '/vendor/autoload.php';
Then:
$ composer install
Megumi\WP\Ajaxonomy
has same parameters with register_taxonomy()
.
<?php
/*
Plugin Name: My Music Library
Version: 0.1-alpha
Description: PLUGIN DESCRIPTION HERE
Author: YOUR NAME HERE
Author URI: YOUR SITE HERE
Plugin URI: PLUGIN SITE HERE
Text Domain: ajax-taxonomy
Domain Path: /languages
*/
require_once dirname( __FILE__ ) . '/vendor/autoload.php';
add_action( 'plugins_loaded', function(){
$args = array(
'label' => 'Music',
);
$tax = new Megumi\WP\Ajaxonomy( 'music', 'post', $args );
$tax->set_order = 'ASC';
$tax->set_order = 'slug'; // Default is `slug`
$tax->register();
} );
Then: