Atenção!

Este artigo contém código PHP e JavaScript e destina-se a desenvolvedores. Oferecemos este código como uma cortesia, mas não fornecemos suporte para personalizações de código ou desenvolvimento de terceiros.

Para orientação extra, consulte o tutorial do WPBeginner sobre como adicionar código personalizado.

Dispensar

Descrição

The wpforms_frontend_js_header_force_load filter allows forcing the load of JavaScript assets in the header instead of the footer for WPForms.

Parâmetros

$in_footer
(bool) (Optional) Determines whether to print the script in the footer, default is false.

Fonte

wpforms/includes/functions/forms.php

Mais Informações

This filter is applied to determine whether WPForms JavaScript files should be loaded in the header or footer of the page. By default, the filter is called with false, which means scripts would be loaded in the footer. Returning true from the filter would cause scripts to be loaded in the header.

Note: This filter is specific to JavaScript assets and does not affect CSS loading.

Exemplo

/**
 * Force WPForms JavaScript to load in the header.
 *
 * @link https://wpforms.com/developers/wpforms_frontend_js_header_force_load
 *
 * @param bool $in_footer Whether to load scripts in the footer.
 * @return bool
 */

add_filter( 'wpforms_frontend_js_header_force_load', '__return_true' );