Skip to content

Latest commit

 

History

History
195 lines (130 loc) · 7.03 KB

File metadata and controls

195 lines (130 loc) · 7.03 KB

Actions & Filters

Table of Contents

Action Hooks

Activation / Deactivation

snapwp_helper/activate

Runs when the plugin is activated.

do_action( 'snapwp_helper/activate' );

GraphQL Type Registration

snapwp_helper/graphql/init/register_types

Fires before any GraphQL types are registered.

do_action( 'snapwp_helper/graphql/init/register_types' );

snapwp_helper/graphql/init/after_register_types

Fires after all GraphQL types are registered.

do_action( 'snapwp_helper/graphql/init/after_register_types' );

Lifecycle

snapwp_helper/init

Runs when the plugin is initialized.

do_action( 'snapwp_helper/init', \SnapWP\Helper\Main $instance );
Parameters
  • $instance (\SnapWP\Helper\Main): The main plugin class instance.

Filter Hooks

GraphQL

snapwp_helper/graphql/init/registered_{type}_classes

Filters the list of registered classes for a specific GraphQL Type. Classes must implement the SnapWP\Helper\Interfaces\GraphQLType interface.

{type} can be one of the following:

  • enum : Enum Type
  • input : Input Type
  • interface : Interface Type
  • object : Object Type
  • field : Fields on an Existing Type
  • connection : Relay-compliant Connection Type
  • mutation : Mutation Type
apply_filters( 'snapwp_helper/graphql/init/registered_enum_classes', array $registered_classes );
apply_filters( 'snapwp_helper/graphql/init/registered_input_classes', array $registered_classes );
apply_filters( 'snapwp_helper/graphql/init/registered_interface_classes', array $registered_classes );
apply_filters( 'snapwp_helper/graphql/init/registered_object_classes', array $registered_classes );
apply_filters( 'snapwp_helper/graphql/init/registered_field_classes', array $registered_classes );
apply_filters( 'snapwp_helper/graphql/init/registered_connection_classes', array $registered_classes );
apply_filters( 'snapwp_helper/graphql/init/registered_mutation_classes', array $registered_classes );
Parameters
  • $registered_classes (class-string<\SnapWP\Helper\Interfaces\GraphQLType>[]): An array of fully-qualified GraphQL Type class-names.

snapwp_helper/graphql/resolve_template_uri

When this filter return anything other than null, it will be used as a resolved node and the execution will be skipped. This is to be used in extensions to resolve their own templates which might not use WordPress permalink structure.

apply_filters( 'snapwp_helper/graphql/resolve_template_uri', mixed|null $node, string $uri, \WPGraphQL\AppContext $context, \WP $wp, array|string $extra_query_vars );
Parameters
  • $node (mixed|null): The node, defaults to nothing.
  • $uri (string): The URI being searched.
  • $content (\WPGraphQL\AppContext): The app context.
  • $wp (\WP object): The WP object instance.
  • $extra_query_vars (array<string, mixed>|string): Any extra query vars to consider.

Lifecycle

snapwp_helper/init/module_classes

Filters the list of module classes to be loaded.

apply_filters( 'snapwp_helper/init/module_classes', array $module_classes );
Parameters
  • $module_classes (class-string<\SnapWP\Helper\Interfaces\Module>[]): An array of fully-qualified Module class-names to load.

snapwp_helper/dependencies/registered_dependencies

Filters the array of external dependencies (e.g. WordPress plugins) required by the plugin.

apply_filters( 'snapwp_helper/dependencies/registered_dependencies', array $dependencies );
Parameters
  • $dependencies (array): An array of dependencies. Each element in the array is an associative array with the following keys
    • slug (string): A unique slug to identify the dependency. E.g. Plugin slug.
    • name (string): The pretty name of the dependency used in the admin notice.
    • check_callback (callable(): true|\WP_Error): A callable that returns true if the dependency is met, or a WP_Error object (with an explicit error message) if the dependency is not met.

Environment Variables

snapwp_helper/env/variables

This filter allows you to modify the list of environment variables used by SnapWP's frontend framework.

apply_filters( 'snapwp_helper/env/variables', array $variables );
Parameters
  • $variables (array<string,array{description:string,default:string,required:bool}>): This array contains the details of the environment variables, keyed to the variable name. Each item provides the following information:

    • description (string): A brief explanation of what the variable controls or configures.
    • default (string): The default value assigned to the variable if not set explicitly.
    • required (bool): Whether the variable is mandatory for proper functionality.

Plugin Updater

snapwp_helper/plugin_updater/plugins

Filters the list of plugins to be updated using the Plugin Updater.

apply_filters( 'snapwp_helper/plugin_updater/plugins', array $plugins );
Parameters
  • $plugins (array{slug, update_uri}[]): An array of plugins to be checked for updates. Each element in the array is an associative array with the following keys:

    • slug (string): The qualified plugin slug with its folder. E.g. 'wp-graphql-my-plugin/wp-graphql-my-plugin.php'.
    • update_uri (string): The URI used to check for plugin updates.

Admin Screen

snapwp_helper/admin/capability

Filters the capability required to access the SnapWP Helper admin screen and make any dashboard-related changes.

apply_filters( 'snapwp_helper/admin/capability', string $capability );
Parameters
  • $capability (string): The capability required to access the SnapWP Helper admin screen and make any dashboard-related changes. Default is manage_options.