acf_maybe_add_action()ACF 5.3.2

acf_maybe_add_action

This function will determine if the action has already run before adding / calling the function

@type    function

Хуков нет.

Возвращает

$post_id. (int)

Использование

acf_maybe_add_action( $tag, $function_to_add, $priority, $accepted_args );
$tag (обязательный)
-
$function_to_add (обязательный)
-
$priority **
-
По умолчанию: 10
$accepted_args **
-
По умолчанию: 1

Список изменений

С версии 5.3.2 Введена.

Код acf_maybe_add_action() ACF 5.10.2

function acf_maybe_add_action( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) {

	// if action has already run, execute it
	// - if currently doing action, allow $tag to be added as per usual to allow $priority ordering needed for 3rd party asset compatibility
	if ( did_action( $tag ) && ! doing_action( $tag ) ) {

		call_user_func( $function_to_add );

		// if action has not yet run, add it
	} else {

		add_action( $tag, $function_to_add, $priority, $accepted_args );

	}

}