93devs/terra

This class helps to filter post taxonomies via ajax

dev-master 2022-06-14 15:16 UTC

This package is auto-updated.

Last update: 2024-09-19 14:06:22 UTC


README

v1.0.1

Terra is a rewrite of the 93digital Lama utility class. The class implements dynamic filtering functionality in WordPress and allows users to quickly filter index/archive pages for custom post types using taxonomies and other custom filters.

NOTE: php >= 7.2 is required, earlier versions are not supported.

Installation

Composer

From your theme root, run the following command in your terminal to install Terra with Composer

$ composer require 93devs/terra:dev-master

Then, in your functions.php add the following:

$GLOBALS['terra'] = new \Nine3\Terra();

If you have used Lama for the project you're working on you will need to remove it and any initialisations for it, namely \Nine3\Lama::init(); as the two tools cannot work side by side.

Luna

Current Luna theme has Terra instantiated by default so you don't need to do anything. If you need to add Terra hooks, the place to do that is: /inc/hooks/class-luna-terra-hooks.php

If you're using an older version of Luna which doesn't have Terra baked in you will need to create a new class file in /inc, (this is where you will also add any Terra actions or filters) eg:

class Luna_Terra {
	public function __construct() {
		$GLOBALS['terra'] = new \Nine3\Terra();
	}
}

Then just instantiate the class in /inc/class-luna.php like so: $this->terra = new Luna_Terra();

Development

npm is needed to compile the JS file.

npm install

Build the JS

npm run build

Debug

When debugging is enabled in WordPress Terra automatically outputs in the debug.log file, the following information:

  • the $args array parameters passed to the WP_Query (when performing the ajax request)
  • the template that is trying to load for each element found

Alternatively it's possible to set the constant TERRA_DEBUG to true to output that information inside the wp-content/terra.log file, add the following line to your starter theme/plugin:

define( 'TERRA_DEBUG', true );