From 5db2295cac351c04ce705e0e31de7e6d45f85421 Mon Sep 17 00:00:00 2001 From: Tetrakern <26898880+Tetrakern@users.noreply.github.com> Date: Tue, 15 Aug 2023 12:29:17 +0200 Subject: [PATCH] Add constant to enable ACF on frontend --- INSTALLATION.md | 1 + functions.php | 5 +++++ includes/functions/_acf.php | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/INSTALLATION.md b/INSTALLATION.md index e009309d..7c5f0737 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -787,3 +787,4 @@ define( 'CONSTANT_NAME', value ); | FICTIONEER_DISABLE_ACF_JSON_IMPORT | boolean | Whether to disable the ACF JSON field import. Dangerous. Default `false`. | FICTIONEER_ENABLE_STICKY_CARDS | boolean | Whether to allow sticky cards. Expensive. Default `true`. | FICTIONEER_ENABLE_STORY_DATA_META_CACHE | boolean | Whether to "cache" story data in a meta field. Default `true`. +| FICTIONEER_ENABLE_FRONTEND_ACF | boolean | Whether to load ACF on the frontend. Default `false`. diff --git a/functions.php b/functions.php index 79520dd8..897c90c8 100644 --- a/functions.php +++ b/functions.php @@ -304,6 +304,11 @@ if ( ! defined( 'FICTIONEER_ENABLE_STORY_DATA_META_CACHE' ) ) { define( 'FICTIONEER_ENABLE_STORY_DATA_META_CACHE', true ); } +// Boolean: Enable ACF on frontend +if ( ! defined( 'FICTIONEER_ENABLE_FRONTEND_ACF' ) ) { + define( 'FICTIONEER_ENABLE_FRONTEND_ACF', false ); +} + // ============================================================================= // GLOBAL // ============================================================================= diff --git a/includes/functions/_acf.php b/includes/functions/_acf.php index 74df2e28..cb392058 100644 --- a/includes/functions/_acf.php +++ b/includes/functions/_acf.php @@ -48,7 +48,7 @@ function fictioneer_acf_json_save_point( $path ) { // LOAD ACF PLUGIN FROM THEME IF NOT INSTALLED (ADMIN ONLY) // ============================================================================= -if ( ! class_exists('acf') && is_admin() ) { +if ( ! class_exists('acf') && ( is_admin() || FICTIONEER_ENABLE_FRONTEND_ACF ) ) { // Define path and URL to the ACF plugin. define( 'FICTIONEER_ACF_PATH', get_template_directory() . '/includes/acf/' ); define( 'FICTIONEER_ACF_URL', get_template_directory_uri() . '/includes/acf/' );