From d26b3ce9ca8d837a24ee764c64ef314762754e2c Mon Sep 17 00:00:00 2001 From: Jason Bahl Date: Thu, 27 Jul 2023 13:58:05 -0600 Subject: [PATCH] - update hook/filter names to use a "namespace" style of naming with forward slashes --- access-functions.php | 2 +- src/AcfGraphQLFieldType.php | 6 +++--- src/FieldConfig.php | 6 +++--- src/FieldTypeRegistry.php | 6 +++--- src/LocationRules/LocationRules.php | 2 +- src/ThirdParty/AcfExtended/AcfExtended.php | 6 +++--- src/Utils.php | 6 +++--- src/WPGraphQLAcf.php | 5 ++--- 8 files changed, 19 insertions(+), 20 deletions(-) diff --git a/access-functions.php b/access-functions.php index 5a63ff0..74f1069 100644 --- a/access-functions.php +++ b/access-functions.php @@ -8,7 +8,7 @@ */ function register_graphql_acf_field_type( string $acf_field_type, $config = [] ): void { - add_action( 'wpgraphql_acf_register_field_types', static function ( \WPGraphQL\Acf\FieldTypeRegistry $registry ) use ( $acf_field_type, $config ) { + add_action( 'wpgraphql/acf/register_field_types', static function ( \WPGraphQL\Acf\FieldTypeRegistry $registry ) use ( $acf_field_type, $config ) { $registry->register_field_type( $acf_field_type, $config ); } ); diff --git a/src/AcfGraphQLFieldType.php b/src/AcfGraphQLFieldType.php index bd0b666..9ca049b 100644 --- a/src/AcfGraphQLFieldType.php +++ b/src/AcfGraphQLFieldType.php @@ -167,7 +167,7 @@ public function get_admin_field_settings( array $field, Settings $settings ) { ], ]; - $default_admin_settings = apply_filters( 'wpgraphql_acf_field_type_default_admin_settings', $default_admin_settings ); + $default_admin_settings = apply_filters( 'wpgraphql/acf/field_type_default_admin_settings', $default_admin_settings ); // Get the admin fields for the field type $admin_fields = $this->get_admin_fields( $field, $default_admin_settings, $settings ); @@ -179,7 +179,7 @@ public function get_admin_field_settings( array $field, Settings $settings ) { } } - return apply_filters( 'wpgraphql_acf_field_type_admin_settings', $admin_fields ); + return apply_filters( 'wpgraphql/acf/field_type_admin_settings', $admin_fields ); } @@ -250,7 +250,7 @@ protected function set_excluded_admin_field_settings():void { * @return array */ public function get_excluded_admin_field_settings(): array { - return apply_filters( 'wpgraphql_acf_excluded_admin_field_settings', $this->excluded_admin_field_settings ); + return apply_filters( 'wpgraphql/acf/excluded_admin_field_settings', $this->excluded_admin_field_settings ); } /** diff --git a/src/FieldConfig.php b/src/FieldConfig.php index e415dfe..bc1cbe0 100644 --- a/src/FieldConfig.php +++ b/src/FieldConfig.php @@ -268,7 +268,7 @@ public function get_graphql_field_config():?array { * @param array|null $field_config The field config array passed to the schema registration * @param \WPGraphQL\Acf\FieldConfig $instance Instance of the FieldConfig class */ - return apply_filters( 'wpgraphql_acf_get_graphql_field_config', $field_config, $this ); + return apply_filters( 'wpgraphql/acf/get_graphql_field_config', $field_config, $this ); } /** @@ -364,7 +364,7 @@ public function resolve_field( $root, array $args, AppContext $context, ResolveI * @param array $acf_field The ACF Field config * @param bool $format Whether to apply formatting to the field */ - $value = apply_filters( 'wpgraphql_acf_pre_resolve_acf_field', null, $root, $node_id, $field_config, $should_format_value ); + $value = apply_filters( 'wpgraphql/acf/pre_resolve_acf_field', null, $root, $node_id, $field_config, $should_format_value ); // If the filter has returned a value, we can return the value that was returned. if ( null !== $value ) { @@ -387,7 +387,7 @@ public function resolve_field( $root, array $args, AppContext $context, ResolveI * @param mixed $root The Root node or obect of the field being resolved * @param mixed $node_id The ID of the node being resolved */ - return apply_filters( 'wpgraphql_acf_field_value', $value, $field_config, $root, $node_id ); + return apply_filters( 'wpgraphql/acf/field_value', $value, $field_config, $root, $node_id ); } diff --git a/src/FieldTypeRegistry.php b/src/FieldTypeRegistry.php index 8dcbf1d..dd50acf 100644 --- a/src/FieldTypeRegistry.php +++ b/src/FieldTypeRegistry.php @@ -51,10 +51,10 @@ public function __construct() { $this->register_acf_field_types(); // Initialize the Field Type Registry - do_action( 'wpgraphql_acf_registry_init', $this ); + do_action( 'wpgraphql/acf/registry_init', $this ); // Initialize the Field Type Registry - do_action( 'wpgraphql_acf_register_field_types', $this ); + do_action( 'wpgraphql/acf/register_field_types', $this ); } @@ -109,7 +109,7 @@ protected function register_acf_field_types(): void { * @return array */ public function get_registered_field_types(): array { - return apply_filters( 'wpgraphql_acf_get_registered_field_types', $this->registered_field_types ); + return apply_filters( 'wpgraphql/acf/get_registered_field_types', $this->registered_field_types ); } /** diff --git a/src/LocationRules/LocationRules.php b/src/LocationRules/LocationRules.php index c52457c..28ce99c 100644 --- a/src/LocationRules/LocationRules.php +++ b/src/LocationRules/LocationRules.php @@ -342,7 +342,7 @@ public function determine_rules( string $field_group_name, string $param, string // If a built-in location rule could not be matched, // Custom rules (from extensions, etc) can hook in here and apply their // rules to the WPGraphQL Schema - do_action( 'wpgraphql_acf_match_location_rule', $field_group_name, $param, $operator, $value, $this ); + do_action( 'wpgraphql/acf/match_location_rule', $field_group_name, $param, $operator, $value, $this ); break; } diff --git a/src/ThirdParty/AcfExtended/AcfExtended.php b/src/ThirdParty/AcfExtended/AcfExtended.php index 68fb5b6..a657e82 100644 --- a/src/ThirdParty/AcfExtended/AcfExtended.php +++ b/src/ThirdParty/AcfExtended/AcfExtended.php @@ -33,9 +33,9 @@ public function init(): void { } // ACF Extended Pro - add_filter( 'wpgraphql_acf_should_field_group_show_in_graphql', [ $this, 'filter_out_acfe_dynamic_groups' ], 10, 2 ); + add_filter( 'wpgraphql/acf/should_field_group_show_in_graphql', [ $this, 'filter_out_acfe_dynamic_groups' ], 10, 2 ); add_action( 'graphql_register_types', [ $this, 'register_initial_types' ] ); - add_action( 'wpgraphql_acf_registry_init', [ $this, 'register_field_types' ] ); + add_action( 'wpgraphql/acf/registry_init', [ $this, 'register_field_types' ] ); } @@ -49,7 +49,7 @@ public static function is_acfe_active(): bool { $is_active = class_exists( 'ACFE' ) || defined( 'TESTS_ACF_EXTENDED_IS_ACTIVE' ); // Filter the response. This is helpful for test environments to mock tests as if the plugin were active - return (bool) apply_filters( 'wpgraphql_acf_is_acfe_active', $is_active ); + return (bool) apply_filters( 'wpgraphql/acf/is_acfe_active', $is_active ); } /** diff --git a/src/Utils.php b/src/Utils.php index ceb9f39..422877d 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -27,7 +27,7 @@ public static function get_node_acf_id( $node ) { /** * If a value is returned from this filter, */ - $pre_get_node_acf_id = apply_filters( 'wpgraphql_acf_pre_get_node_acf_id', null, $node ); + $pre_get_node_acf_id = apply_filters( 'wpgraphql/acf/pre_get_node_acf_id', null, $node ); if ( null !== $pre_get_node_acf_id ) { return $pre_get_node_acf_id; @@ -130,7 +130,7 @@ public static function get_supported_acf_fields_types(): array { * * @param array $supported_fields */ - return apply_filters( 'wpgraphql_acf_supported_field_types', $registered_field_names ); + return apply_filters( 'wpgraphql/acf/supported_field_types', $registered_field_names ); } /** @@ -264,7 +264,7 @@ public static function should_field_group_show_in_graphql( array $acf_field_grou $should = false; } - return (bool) apply_filters( 'wpgraphql_acf_should_field_group_show_in_graphql', $should, $acf_field_group ); + return (bool) apply_filters( 'wpgraphql/acf/should_field_group_show_in_graphql', $should, $acf_field_group ); } diff --git a/src/WPGraphQLAcf.php b/src/WPGraphQLAcf.php index 2bd820a..8136d5d 100644 --- a/src/WPGraphQLAcf.php +++ b/src/WPGraphQLAcf.php @@ -3,7 +3,6 @@ use WPGraphQL\Registry\TypeRegistry; use WPGraphQL\Acf\Admin\PostTypeRegistration; -use WPGraphQL\Acf\Admin\Settings; use WPGraphQL\Acf\Admin\TaxonomyRegistration; use WPGraphQL\Acf\Registry; use WPGraphQL\Acf\ThirdParty; @@ -33,7 +32,7 @@ public function init(): void { return; } - add_action( 'wpgraphql_acf_init', [ $this, 'init_third_party_support' ] ); + add_action( 'wpgraphql/acf/init', [ $this, 'init_third_party_support' ] ); add_action( 'admin_init', [ $this, 'init_admin_settings' ] ); add_action( 'after_setup_theme', [ $this, 'cpt_tax_registration' ] ); add_action( 'graphql_register_types', [ $this, 'init_registry' ] ); @@ -41,7 +40,7 @@ public function init(): void { add_filter( 'graphql_data_loaders', [ $this, 'register_loaders' ], 10, 2 ); add_filter( 'graphql_resolve_node_type', [ $this, 'resolve_acf_options_page_node' ], 10, 2 ); - do_action( 'wpgraphql_acf_init' ); + do_action( 'wpgraphql/acf/init' ); }