From 30c63e447988ff24abf8b62af4d478fe59f3bca3 Mon Sep 17 00:00:00 2001 From: Keith Solomon Date: Wed, 13 May 2026 15:35:56 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8feature:=20Add=20ACF=20admin=20field?= =?UTF-8?q?=20group=20support=20with=20plugin=20fallback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .vscode/settings.json | 10 +++++++++- aa-events.php | 2 +- includes/acf-fields.php | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a79ebc0..36a70d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ notes/ phpcs-results.txt +tests/ diff --git a/.vscode/settings.json b/.vscode/settings.json index 36281d1..75358cb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,6 +3,14 @@ "tree.indentGuidesStroke": "#3d92ec", "activityBar.background": "#123509", "titleBar.activeBackground": "#1A4A0D", - "titleBar.activeForeground": "#F5FDF3" + "titleBar.activeForeground": "#F5FDF3", + "titleBar.inactiveBackground": "#123509", + "titleBar.inactiveForeground": "#F5FDF3", + "statusBar.background": "#123509", + "statusBar.foreground": "#F5FDF3", + "statusBar.debuggingBackground": "#123509", + "statusBar.debuggingForeground": "#F5FDF3", + "statusBar.noFolderBackground": "#123509", + "statusBar.noFolderForeground": "#F5FDF3" } } diff --git a/aa-events.php b/aa-events.php index 053fe91..776243a 100644 --- a/aa-events.php +++ b/aa-events.php @@ -3,7 +3,7 @@ * Plugin Name: AA Events * Plugin URI: https://github.com/automattic/aa-events * Description: An Events management plugin for WordPress, with accessible calendar (WCAG 2.2AA) and card grid views. - * Version: 1.0.0 + * Version: 1.1.0 * Author: Keith Solomon * Author URI: https://vincentdesign.ca * License: GPL-2.0+ diff --git a/includes/acf-fields.php b/includes/acf-fields.php index 9eadef1..812e989 100644 --- a/includes/acf-fields.php +++ b/includes/acf-fields.php @@ -9,10 +9,48 @@ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } +/** + * Check whether an ACF field group created in the admin targets the event post type. + * + * @return bool True if an external field group is assigned to events. + */ +function events_has_admin_field_group() { + if ( ! function_exists( 'acf_get_field_groups' ) ) { + return false; + } + + $groups = acf_get_field_groups( array( 'post_type' => 'event' ) ); + + foreach ( $groups as $group ) { + if ( isset( $group['active'] ) && ! $group['active'] ) { + continue; + } + + if ( + isset( $group['key'], $group['local'] ) + && 'group_61b0c5f5a3e7e' === $group['key'] + && 'php' === $group['local'] + ) { + continue; + } + + return true; + } + + return false; +} + /** * Register the ACF field group. + * + * Skips registration when an admin-created field group is already + * assigned to the event post type, allowing full editorial control. */ function events_register_acf_fields() { + if ( events_has_admin_field_group() ) { + return; + } + if ( function_exists( 'acf_add_local_field_group' ) ) : acf_add_local_field_group(