deep-web-solutions/wordpress-framework-utilities

View on GitHub
src/includes/Hooks/HooksAdapterInterface.php

Summary

Maintainability
A
1 hr
Test Coverage
<?php

namespace DeepWebSolutions\Framework\Utilities\Hooks;

\defined( 'ABSPATH' ) || exit;

/**
 * Describes the compatibility layer between the framework and the WP hooks API.
 *
 * @since   1.0.0
 * @version 1.0.0
 * @author  Antonius Hegyes <a.hegyes@deep-web-solutions.com>
 * @package DeepWebSolutions\WP-Framework\Utilities\Hooks
 */
interface HooksAdapterInterface {
    /**
     * Registers a new action with the handler.
     *
     * @since    1.0.0
     * @version  1.0.0
     *
     * @param    string         $hook           The name of the WordPress action that is being registered.
     * @param    object|null    $component      A reference to the instance of the object on which the action is defined.
     * @param    string         $callback       The name of the function definition on the $component.
     * @param    int            $priority       Optional. he priority at which the function should be fired. Default is 10.
     * @param    int            $accepted_args  Optional. The number of arguments that should be passed to the $callback. Default is 1.
     */
    public function add_action( string $hook, ?object $component, string $callback, int $priority = 10, int $accepted_args = 1 );

    /**
     * Removes an action from the handler.
     *
     * @since    1.0.0
     * @version  1.0.0
     *
     * @param    string         $hook           The name of the WordPress action that is being deregistered.
     * @param    object|null    $component      A reference to the instance of the object on which the action is defined.
     * @param    string         $callback       The name of the function definition on the $component.
     * @param    int            $priority       Optional. he priority at which the function should be fired. Default is 10.
     */
    public function remove_action( string $hook, ?object $component, string $callback, int $priority = 10 );

    /**
     * Removes all actions from the handler.
     *
     * @since   1.0.0
     * @version 1.0.0
     */
    public function remove_all_actions();

    /**
     * Registers a new filter with the handler.
     *
     * @since   1.0.0
     * @version 1.0.0
     *
     * @param   string          $hook           The name of the WordPress filter that is being registered.
     * @param   object|null     $component      A reference to the instance of the object on which the filter is defined.
     * @param   string          $callback       The name of the function definition on the $component.
     * @param   int             $priority       Optional. he priority at which the function should be fired. Default is 10.
     * @param   int             $accepted_args  Optional. The number of arguments that should be passed to the $callback. Default is 1.
     */
    public function add_filter( string $hook, ?object $component, string $callback, int $priority = 10, int $accepted_args = 1 );

    /**
     * Removes a filter from the handler.
     *
     * @since    1.0.0
     * @version  1.0.0
     *
     * @param    string         $hook           The name of the WordPress filter that is being deregistered.
     * @param    object|null    $component      A reference to the instance of the object on which the filter is defined.
     * @param    string         $callback       The name of the function definition on the $component.
     * @param    int            $priority       Optional. he priority at which the function should be fired. Default is 10.
     */
    public function remove_filter( string $hook, ?object $component, string $callback, int $priority = 10 );

    /**
     * Removes all filters from the handler.
     *
     * @since   1.0.0
     * @version 1.0.0
     */
    public function remove_all_filters();
}