Download the PHP package spock/shadow-taxonomies without Composer

On this page you can find all versions of the php package spock/shadow-taxonomies. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package shadow-taxonomies

Shadow Taxonomy

A WordPress Composer library for creating relationships between custom post types using shadow taxonomies.

Introduction

One of the hardest things to do in WordPress is creating relationships between two different post types. Often this is accomplished by saving relationship data in post meta. However this leads to expensive meta queries, which are generally one of the poorest performing queries you can make in WordPress.

Metadata can also be a pain to keep synced. For example, when posts are deleted, what happens to the post meta saved on a separate post type?

Shadow Taxonomy solves this by using WordPress taxonomies as the relationship layer. Instead of meta queries, you get performant taxonomy queries and a built-in checkbox UI on the post edit screen for free.

What is a Shadow Taxonomy?

A shadow taxonomy is a custom WordPress taxonomy that automatically mirrors a specific post type. Anytime a post in that post type is created, updated, or deleted, the associated shadow taxonomy term is also created, updated, and deleted.

This library manages the entire lifecycle of the shadow terms, keeping your taxonomy in sync with its associated post type.

Installation

Requirements: PHP >= 7.2, WordPress

Usage

Step One: Create the Shadow Taxonomy

Here we are creating a normal custom taxonomy. In this example we are creating a taxonomy to mirror a CPT called Services, so by convention the shadow taxonomy is named services-tax.

Because we want to link Services to another post type called Staff, this taxonomy is registered on the Staff CPT post edit screen.

The taxonomy is not made public so that nobody manually edits the terms. The library handles creating, updating, and deleting the shadow taxonomy terms to keep everything in sync.

Step Two: Create the Association

This one line creates the shadow taxonomy link. The first argument is the custom post type slug, and the second is the shadow taxonomy slug. Place this immediately after the register_taxonomy call.

Combined Helper

Use register_shadow_taxonomy to register the taxonomy and establish the relationship in a single call:

API

get_the_posts

Fetch the associated posts for a given post ID. Returns an array of WP_Post objects or false if none are found.

get_associated_term

Get the shadow term for a given post. Accepts a WP_Post object or post ID. Returns a WP_Term object or false.

get_associated_post

Get the shadow post for a given term. Returns a WP_Post object or false.

get_meta_key

Build the meta key used to store shadow relationships. $type is either 'term_id' or 'post_id'.

Hooks

The library fires the following actions:

WP-CLI Commands

The library includes WP-CLI commands for managing shadow taxonomies on existing sites with existing data.

sync

Syncs all posts in the given post type to shadow terms, and removes any orphan terms.

sync-terms

Like sync, but also repairs missing metadata on both the post and term side.

deep-sync

Creates shadow terms for posts missing both the shadow meta key and a matching term by slug.

check

Checks if a specific post or term has a valid shadow association.

Options

License

GPL-2.0+


All versions of shadow-taxonomies with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package spock/shadow-taxonomies contains the following files

Loading the files please wait ...