GC_Embed::register_handler()

最后更新于:2021-11-27 14:41:09

GC_Embed::register_handler( string$id, string$regex, callable$callback, int$priority=10)

Registers an embed handler.

参数

$id

(string) (Required) An internal ID/name for the handler. Needs to be unique.

$regex

(string) (Required) The regex that will be used to see if this handler should be used for a URL.

$callback

(callable) (Required) The callback function that will be called if the regex is matched.

$priority

(int) (Optional) Used to specify the order in which the registered handlers will be tested. Lower numbers correspond with earlier testing, and handlers with the same priority are tested in the order in which they were added to the action.

Default value: 10

源文件

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

	public function register_handler( $id, $regex, $callback, $priority = 10 ) {
		$this->handlers[ $priority ][ $id ] = array(
			'regex'    => $regex,
			'callback' => $callback,
		);
	}