GC_Hook::remove_filter()

最后更新于:2021-11-27 21:32:41

GC_Hook::remove_filter( string$hook_name, callable$callback, int$priority)

Removes a callback function from a filter hook.

参数

$hook_name

(string) (Required) The filter hook to which the function to be removed is hooked.

$callback

(callable) (Required) The callback to be removed from running when the filter is applied.

$priority

(int) (Required) The exact priority used when adding the original filter callback.

响应

(bool) Whether the callback existed before it was removed.

源文件

文件: gc-includes/class-gc-hook.php

	public function remove_filter( $hook_name, $callback, $priority ) {
		$function_key = _gc_filter_build_unique_id( $hook_name, $callback, $priority );

		$exists = isset( $this->callbacks[ $priority ][ $function_key ] );

		if ( $exists ) {
			unset( $this->callbacks[ $priority ][ $function_key ] );

			if ( ! $this->callbacks[ $priority ] ) {
				unset( $this->callbacks[ $priority ] );

				if ( $this->nesting_level > 0 ) {
					$this->resort_active_iterations();
				}
			}
		}

		return $exists;
	}