Skip to content

Commit

Permalink
- update hook/filter names to use a "namespace" style of naming with …
Browse files Browse the repository at this point in the history
…forward slashes
  • Loading branch information
jasonbahl committed Jul 27, 2023
1 parent bfd4463 commit d26b3ce
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion access-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
} );

Expand Down
6 changes: 3 additions & 3 deletions src/AcfGraphQLFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 );

}

Expand Down Expand Up @@ -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 );
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/FieldConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand Down Expand Up @@ -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 ) {
Expand All @@ -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 );

}

Expand Down
6 changes: 3 additions & 3 deletions src/FieldTypeRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}


Expand Down Expand Up @@ -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 );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/LocationRules/LocationRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
Expand Down
6 changes: 3 additions & 3 deletions src/ThirdParty/AcfExtended/AcfExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ] );

}

Expand All @@ -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 );
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
}

/**
Expand Down Expand Up @@ -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 );

}

Expand Down
5 changes: 2 additions & 3 deletions src/WPGraphQLAcf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -33,15 +32,15 @@ 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' ] );

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' );

}

Expand Down

0 comments on commit d26b3ce

Please sign in to comment.