danlapteacru/facetwp-local-json

Saves FacetWP facets, templates and settings as .json files within your theme.

0.1.0 2024-07-29 06:59 UTC

README

FacetWP Local JSON is a WordPress plugin that allows you to store FacetWP facets, templates and settings as .json file and keep them in your source code repository.

Packagist Version PHP from Packagist Packagist Downloads GitHub License Hire Me

Minimum Requirements

  • PHP v8.1
  • WordPress v6.1
  • FacetWP v4.0

Installation

Composer (Recommended)

composer require danlapteacru/facetwp-local-json

WP-CLI

wp plugin install facetwp-local-json --activate

wordpress.org plugins directory

Download from https://wordpress.org/plugins/facetwp-local-json and install it manually or via WordPress admin panel.

Hooks

facetwp_local_json_settings

Filter the settings that are stored in the .json file.

Example:

add_filter(
    'facetwp_local_json_settings', 
    fn (array $settings): array => [
        ...$settings,
        $settings['general']['auto_refresh'] = true,
    ],
);

facetwp_local_json_storage_path

Filter the path where the .json files are stored. Default is wp-content/themes/your-theme/plugins/facetwp/local-json/settings.json.

Example:

add_filter(
    'facetwp_local_json_storage_path', 
    fn (): string => get_theme_file_path('facetwp/settings.json'),
);

Constants

FACETWP_LOCAL_JSON_STORAGE_PATH

Define the path where the .json files are store in your wp-config.php file.

Example:

define('FACETWP_LOCAL_JSON_STORAGE_PATH', get_theme_file_path('facetwp/settings.json'));

FACETWP_LOCAL_JSON_FORCE_ENABLE

Force enable/disable the FacetWP Local JSON features.

Example:

define('FACETWP_LOCAL_JSON_FORCE_ENABLE', true);

TODO

  • Add support for WPML and Polylang.
  • Option to select which facets, templates and settings to store in the .json file.
  • Tests.
  • Documentation.

Credits

FacetWP Local JSON is created by Dan Lapteacru.

Full list of contributors can be found here.

License

FacetWP Local JSON is released under the MIT License.