Giter VIP home page Giter VIP logo

taxonomy_single_term's Introduction

Taxonomy_Single_Term

Version: 0.2.4

Taxonomies in WordPress are super powerful. The purpose of taxonomies is to create relationships among post types. Unfortunately the UI doesn't effectively enforce limiting to a single term.

This library helps you remove and replace the built-in taxonomy metabox with a radio or select metabox.

Read more: How To: Replace WordPress Default Taxonomy Metabox with a Radio Select Metabox

Usage

  1. Include the class.taxonomy-single-term.php file from within your plugin or theme
  2. Initialize the class (update the taxonomy slug with your own): $custom_tax_mb = new Taxonomy_Single_Term( 'custom-tax-slug' );

Optional

    • Second parameter is an array of post_types,
    • The third parameter is either 'radio', or 'select' (defaulting to radio). To use a select type on the foo post_type: $custom_tax_mb = new Taxonomy_Single_Term( 'custom-tax-slug', array( 'foo' ), 'select' );
    • The fourth parameter is the default to select for posts that have not had the taxonomy set. This defaults to the system default option where available and falls back to none where not.
  1. Update optional class properties like:
// Priority of the metabox placement.
$custom_tax_mb->set( 'priority', 'low' );

// 'normal' to move it under the post content.
$custom_tax_mb->set( 'context', 'normal' );

// Custom title for your metabox
$custom_tax_mb->set( 'metabox_title', __( 'Custom Metabox Title', 'yourtheme' ) );

// Makes a selection required.
$custom_tax_mb->set( 'force_selection', true );

// Will keep radio elements from indenting for child-terms.
$custom_tax_mb->set( 'indented', false );

// Allows adding of new terms from the metabox
$custom_tax_mb->set( 'allow_new_terms', true );

// set default
$custom_tax_mb->set( 'default', 'default-slug' ); // or
$custom_tax_mb->set( 'default', 'Default Name' ); // or
$custom_tax_mb->set( 'default', 123 ); // default term_id

Change Log

0.2.4

  • Make Taxonomy_Single_Term::term_fields_list() more versatile.
  • Escape attributes. Props @rnaby, #25.
  • Fix some issues with the selected functionality. See #24.

0.2.3

  • Add hooks to the metabox, taxonomy_single_term_metabox_bottom and taxonomy_single_term_metabox_top.

0.2.2

0.2.1

  • Add setter method. Props @JustinSainton
  • Add getter magic method for retrieving properties

0.2.0

  • Ability to choose Select elements vs Radios. Props @jchristopher
  • Rename plugin. Props @jchristopher
  • Optional allow_new_terms parameter to include a new-term add button in the metabox. Props @jchristopher

0.1.4

  • Bulk editing now works as expected. A singular term will be saved against the post.

0.1.3

  • Adds footer JS on post listing pages that transforms quick-edit inputs to radios.

taxonomy_single_term's People

Contributors

binarykitten avatar blobaugh avatar carlfj avatar codemascot avatar figureone avatar gregrickaby avatar jchristopher avatar jtsternberg avatar justinsainton avatar mallowcat avatar michaelcurry avatar vvmsoft avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.