wp_enqueue_script è stato chiamato in modo errato
-
-
L'avviso sembra abbastanza autoesplicativo.Cosa haiprovatoe cosanon hafunzionato?The `Notice`s seem pretty self explanatory. What have your tried and what didn't it work?
- 1
- 2014-03-06
- s_ha_dum
-
@s_ha_dum Hoprovatomolte cose che hotrovato su Google ... solo ora le soluzioni ditoscho hannofunzionatoperme,e posso accedere almiopannello di amministrazione,ma quello cheposso vedere è che qualcosa va storto con lo stile di caricamento,perchéil carattere ènon lo stesso cheera.Continuo a ricevere questierrori:@s_ha_dum I have tried many things what I have found on Google... just now toscho's solutions worked for me, and I can login to my admin panel, but what I can see is that something goes wrong with loading style, because font is not the same as it was. I keep getting this errors:
- 0
- 2014-03-06
- raiden
-
5 risposta
- voti
-
- 2014-03-06
Disabilitatuttii plugine passa altemapredefinito.Dovrebbeessere sparito ora.
Quindi abilita ogni componente aggiuntivopasso dopopasso,finchéilproblemanon si ripresenta.Ora conosci lafonte,diciamo unplug-in.
Ilpluginprobabilmente chiama
wp_enqueue_script
troppopresto.Trovatutte le occorrenze di quellafunzione,quindi assicurati che siano vincolate ad azioni specifiche:-
wp_register_script()
dovrebbeessere chiamatoper l'azionewp_loaded
-
wp_enqueue_script
su una delle azioni-
wp_enqueue_scripts
, -
admin_enqueue_scripts
, -
customize_controls_enqueue_scripts
o -
login_enqueue_scripts
(vedi questothread per quest'ultimo).
-
Disable all plugins and switch to the default theme. It should be gone now.
Then enable each addon step by step, until the problem comes back. You know the source now, let’s say a plugin.
The plugin calls probably
wp_enqueue_script
too early. Find all occurrences of that function, then make sure they are bound to specific actions:wp_register_script()
should be called for the actionwp_loaded
wp_enqueue_script
on one of the actionswp_enqueue_scripts
,admin_enqueue_scripts
,customize_controls_enqueue_scripts
orlogin_enqueue_scripts
(see this thread for the latter).
-
Ilproblema è chenon riesco ad accedereperché ricevo questo stranoerrore anche coni cookie.L'errore dice che hobloccatoi cookienelmiobrowser,manon li hobloccati ... È così stranoperchétutto quello che hofatto oggi è stato aggiungere alcune righe a style.css,tutto andavabene,ma unpoche ore dopo che ho avuto queglierrori.The problem is that I can't log in becuase I also get this weird error with cookies. Error says, that I have blocked cookies in my browser, but I don't have blocked them... It's so weird because all what I have done today it was adding a few lines to style.css, everything was good, but a few hours after I had those errors.
- 0
- 2014-03-06
- raiden
-
@raiden Quindi rinomina la directory deltuopluginper FTP,fai lo stessoperiltema attualmente attivo.@raiden Then rename your plugin directory per FTP, do the same for the currently active theme.
- 0
- 2014-03-06
- fuxia
-
Oraposso accedere almiopannello ...grazie!ma ora ottengo un altroerrore Avvertenza:non èpossibilemodificare leinformazioni diintestazione -intestazionigiàinviate da (output avviato su wp-includes/functions.php: 3049)in wp-includes/pluggable.php alla riga 896Now I can login to my panel... thank you! but now I get one error more Warning: Cannot modify header information - headers already sent by (output started at wp-includes/functions.php:3049) in wp-includes/pluggable.php on line 896
- 0
- 2014-03-06
- raiden
-
- 2018-06-28
Basato sulla Gregory Schultz soluzione:
Racchiudituttii tuoi scripte stiliin unafunzionee aggancia quellafunzione all'azione
enqueue
di destinazione.function my_admin_scripts() { wp_enqueue_style( 'admin-css', get_stylesheet_directory_uri() . '/admin/css/admin.css' ); wp_enqueue_script( 'admin-js', get_stylesheet_directory_uri() . '/admin/js/admin.js', true ); } add_action( 'admin_enqueue_scripts', 'my_admin_scripts' );
<"
wp_enqueue_scripts
-front-end<"
admin_enqueue_scripts
-pagina di amministrazione<"
login_enqueue_scripts
-pagina di accessoBased on Gregory Schultz's solution:
Wrap all your scripts and styles in a function and hook that function to your target
enqueue
action.function my_admin_scripts() { wp_enqueue_style( 'admin-css', get_stylesheet_directory_uri() . '/admin/css/admin.css' ); wp_enqueue_script( 'admin-js', get_stylesheet_directory_uri() . '/admin/js/admin.js', true ); } add_action( 'admin_enqueue_scripts', 'my_admin_scripts' );
wp_enqueue_scripts
— front-endadmin_enqueue_scripts
— admin pagelogin_enqueue_scripts
— login page -
- 2019-01-23
Ilmotivoper cui ciò sta accadendo èperché questefunzioni vengono chiamate direttamente dalfilefunctions.php,senza usare unafunzione. Scopri quali righein functions.phpnon sono all'interno di unafunzione come questae aggiungile.
Esempioper datepicker:
-Invece di questoin functions.php:
wp_enqueue_script('jquery-ui-datepicker'); wp_enqueue_style('jquery-ui-css', '//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css'); wp_enqueue_style('jquery-ui-css', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
- Aggiungiamo questo
//Definiamo lafunzione: funzione MYTHEME_scripts () { wp_enqueue_script ('jquery-ui-datepicker'); } //Aggiunge lefunzioni all'elenco di caricamento di WP. add_action ('wp_enqueue_scripts','MYTHEME_scripts'); function MYTHEME_styles () { wp_enqueue_style ("jquery-ui-css","//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"); wp_enqueue_style ("jquery-ui-css","//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css"); } //Aggiunge lefunzioni all'elenco di caricamento di WP. add_action ('wp_enqueue_style','MYTHEME_styles');
Spero chefunzioni
The reason why this is happening is because these functions are being called straight from the functions.php file, without using a function. Find out which lines in functions.php aren't inside a function like this, and add them.
Example for datepicker:
-Instead of this in functions.php:
wp_enqueue_script('jquery-ui-datepicker'); wp_enqueue_style('jquery-ui-css', '//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css'); wp_enqueue_style('jquery-ui-css', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
-We add this
// We define the function: function MYTHEME_scripts() { wp_enqueue_script('jquery-ui-datepicker'); } // Add the functions to WP loading list. add_action( 'wp_enqueue_scripts', 'MYTHEME_scripts' ); function MYTHEME_styles() { wp_enqueue_style('jquery-ui-css', '//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css'); wp_enqueue_style('jquery-ui-css', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css'); } // Add the functions to WP loading list. add_action( 'wp_enqueue_style', 'MYTHEME_styles' );
Hope it works
-
- 2018-07-10
Anziché disabilitaretuttii plug-in unoper uno omodificare labase di codicepereseguireil debug,puoi utilizzare Plugin Query Monitor per restringere lafonte di questoerrore.
Quando vedi questoerrore riportatonella console:
wp_register_style è stato chiamatoin modoerrato.Gli scripte gli stili dovrebbero nonessere registrato o accodatofino a quandonon wp_enqueue_scripts, admin_enqueue_scripts o login_enqueue_scripts hooks.Perfavoreguarda Debugin WordPressper ulterioriinformazioni.(Questomessaggio è stato aggiunto nella versione 3.3.0.)
L'ultima colonna (
Component
)ti indicheràilplugin che hagenerato l'errore.Da lìfai una ricerca all'interno di quelplugin (otema)pertrovaree correggereilproblema.Rather than disable all your plugins one by one, or modify your codebase to debug, you can use the Query Monitor plugin to narrow down the source of this error.
When you see this error reported in the console:
wp_register_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.)
The last column (
Component
) will tell you the plugin that is triggering the error. From there do a search inside of that plugin (or theme) to find and patch the issue. -
- 2014-03-06
Significa che ci sono 3 "endpoint"per
wp_enqueue_script()
che sono wp_enqueue_scriptsperilfrontend,login_enqueue_scriptsper la schermata di accesso,admin_enqueue_scriptsperil dashboard di amministrazione. Controlla questo link .Ricevi questoerroreperché
wp_enqueue_script()
è stato chiamatoin modonon corretto.It means there are 3 "endpoints" for
wp_enqueue_script()
which are wp_enqueue_scripts for the frontend, login_enqueue_scripts for the login screen, admin_enqueue_scripts for the admin dashboard. Check this link.You get this error because
wp_enqueue_script()
was called unproperly.-
Capisco cosa c'è,manon so come (implementare?) Questa "La correzione: usa wp_enqueue_scriptsinvece".I understand what's there, but I don't know how to (implement?) this "The fix: Use wp_enqueue_scripts instead."
- 0
- 2014-03-06
- raiden
-
significa che devi solo usare `wp_enqueue_scripts`invece di` wp_print_styles`ma dubito che sia correlato altuo caso.È solo unesempio di risoluzione deiproblemi.Neltuo caso ci sono alcunefunzioninei plugin onei temi che usanoimpropriamente `wp_enqueue_script ()`,quindi ottieni questoerrore ... lamiaipotesi.it means you just have to use `wp_enqueue_scripts` instead of `wp_print_styles` but I doubt it's related to your case. It's just an example of troubleshooting. In your case there are some functions in plugins or theme that misuses `wp_enqueue_script()` so you get this error... my guess.
- 0
- 2014-03-06
- JMau
-
Ricevo l'avviso: wp_register_style è stato chiamatoin modoerrato.Gli scripte gli stilinon dovrebberoessere registrati o accodatifino a quandogli hook wp_enqueue_scripts,admin_enqueue_scripts o login_enqueue_scripts .` Hoinseritotuttii miei scripte stiliin unafunzionee l'avviso è scomparso.I was getting `Notice: wp_register_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks.` I wrapped all my scripts and styles in a function and the notice went away.
- 0
- 2018-05-24
- Gregory Schultz
-
Aparte questo,non ricevoerroriBesides that, I get no errors
- 0
- 2018-05-24
- Gregory Schultz
Non so comema ora ricevo questoerrore:
Questo è ciò che ottengo quandoprovo ad accedere ... Su altri siti,ho solo dueprimierrori. Provo a risolverlomanon ci riesco. Qualche suggerimento?