WP HOOKS
filtrod 6.7.0

pre_attachment_url_to_postid

Args 2Plik wp-includes/media.phpDokumentacja WP ↗

Opis — z kodu źródłowego

Filters the attachment ID to allow short-circuit the function.

Allows plugins to short-circuit attachment ID lookups. Plugins making use of this function should return:

  • 0 (integer) to indicate the attachment is not found, - attachment ID (integer) to indicate the attachment ID found, - null to indicate WordPress should proceed with the lookup. Warning: The post ID may be null or zero, both of which cast to a boolean false. For information about casting to booleans see the {@link https://www.php.net/manual/en/language.types.boolean.php PHP documentation}. Use the === operator for testing the post ID when developing filters using this hook.

Parametry

ParametrTypOpis
$post_idint | nullThe result of the post ID lookup. Null to indicate no lookup has been attempted. Default null.
$urlstringThe URL being looked up.

Wywołanie

Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'pre_attachment_url_to_postid', 'twoja_funkcja', 10, 2 );

function twoja_funkcja($param_1, $param_2) {
	// Twój kod
}

Popularne w tej kategorii