_wp_scripts_maybe_doing_it_wrong

The timeline below displays how wordpress function _wp_scripts_maybe_doing_it_wrong has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

/**
 * Helper function to output a _doing_it_wrong message when applicable.
 *
 * @ignore
 * @since 4.2.0
 * @since 5.5.0 Added the `$handle` parameter.
 *
 * @param string $function_name Function name.
 * @param string $handle        Optional. Name of the script or stylesheet that was
 *                              registered or enqueued too early. Default empty.
 */
function _wp_scripts_maybe_doing_it_wrong($function_name, $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_name, $message, '3.3.0');
}

WordPress Version: 5.5

/**
 * Helper function to output a _doing_it_wrong message when applicable.
 *
 * @ignore
 * @since 4.2.0
 * @since 5.5.0 Added the `$handle` parameter.
 *
 * @param string $function Function name.
 * @param string $handle   Optional. Name of the script or stylesheet that was
 *                         registered or enqueued too early. Default empty.
 */
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');
}

WordPress Version: 4.7

/**
 * Helper function to output a _doing_it_wrong message when applicable.
 *
 * @ignore
 * @since 4.2.0
 *
 * @param string $function Function name.
 */
function _wp_scripts_maybe_doing_it_wrong($function)
{
    if (did_action('init') || did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts') || did_action('login_enqueue_scripts')) {
        return;
    }
    _doing_it_wrong($function, 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>'
    ), '3.3.0');
}

WordPress Version: 4.6

/**
 * Helper function to output a _doing_it_wrong message when applicable.
 *
 * @ignore
 * @since 4.2.0
 *
 * @param string $function Function name.
 */
function _wp_scripts_maybe_doing_it_wrong($function)
{
    if (did_action('init')) {
        return;
    }
    _doing_it_wrong($function, sprintf(__('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>'), '3.3.0');
}

WordPress Version: 4.2

/**
 * Helper function to output a _doing_it_wrong message when applicable.
 *
 * @ignore
 * @since 4.2.0
 *
 * @param string $function Function name.
 */
function _wp_scripts_maybe_doing_it_wrong($function)
{
    if (did_action('init')) {
        return;
    }
    _doing_it_wrong($function, sprintf(__('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>'), '3.3');
}