Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/93digital/terra

A dynamic filtering and pagination framework for WordPress archive pages.
https://github.com/93digital/terra

javascript php wordpress

Last synced: about 2 months ago
JSON representation

A dynamic filtering and pagination framework for WordPress archive pages.

Awesome Lists containing this project

README

        

# Terra

***v1.0.1***

Terra is a rewrite of the 93digital [Lama](https://93digital.gitlab.io/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](https://getcomposer.org/)

```bash
$ composer require 93devs/terra:dev-master
```

Then, in your `functions.php` add the following:

```php
$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:

```php
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](https://www.npmjs.com/) is needed to compile the JS file.

```bash
npm install
```

### Build the JS

```bash
npm run build
```

## Debug

When [debugging is enabled](https://codex.wordpress.org/Debugging_in_WordPress) in WordPress Terra automatically outputs in the `debug.log` file, the following information:

- the [\$args](docs/HOOKS-FILTERS.md#5) array parameters passed to the WP_Query (when performing the ajax request)
- the [template](docs/USAGE.md#3) 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:

```php
define( 'TERRA_DEBUG', true );
```