_wp_scripts_maybe_doing_it_wrong() WP 4.2.0
Helper function to output a _doing_it_wrong message when applicable.
Эта функция считается внутренней для использования самим ядром. Не рекомендуется использовать эту функцию в своем коде.
Хуков нет.
Возвращает
Null. Ничего.
Использование
_wp_scripts_maybe_doing_it_wrong( $function, $handle );
- $function(строка) (обязательный)
- Function name.
- $handle(строка)
- Name of the script or stylesheet that was registered or enqueued too early.
По умолчанию: ''
Список изменений
С версии 4.2.0 | Введена. |
С версии 5.5.0 | Added the $handle parameter. |
Код _wp_scripts_maybe_doing_it_wrong() wp scripts maybe doing it wrong WP 5.6.2
function _wp_scripts_maybe_doing_it_wrong( $function, $handle = '' ) {
if ( did_action( 'init' ) || did_action( 'wp_enqueue_scripts' )
|| did_action( 'admin_enqueue_scripts' ) || did_action( 'login_enqueue_scripts' )
) {
return;
}
$message = sprintf(
/* translators: 1: wp_enqueue_scripts, 2: admin_enqueue_scripts, 3: login_enqueue_scripts */
__( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>',
'<code>admin_enqueue_scripts</code>',
'<code>login_enqueue_scripts</code>'
);
if ( $handle ) {
$message .= ' ' . sprintf(
/* translators: %s: Name of the script or stylesheet. */
__( 'This notice was triggered by the %s handle.' ),
'<code>' . $handle . '</code>'
);
}
_doing_it_wrong(
$function,
$message,
'3.3.0'
);
}