2016-04-06 3 views
0

私はパスワード強度メーターを削除したいです(私はそれがwoocommerceであり、wordpressベースではありません)。私は1つの例外を除いて、魅力のように動作するこのためのスニペットを持っています。これは2番目のスニペットと競合し、このスクリプトのデキューを防ぎます。下記の第一スニペット:他のfunctons.phpスニペットのwp_enqueue_scriptsのアクションのためにデキュースクリプトが失敗する

// Remove password strength meter from checkout, registration and password recovery. 
function wc_ninja_remove_password_strength() { 
    if (wp_script_is('wc-password-strength-meter', 'enqueued')) { 
     wp_dequeue_script('wc-password-strength-meter');  
    } 
} 
add_action('wp_print_scripts', 'wc_ninja_remove_password_strength'); 

私は、追加のアドオンを持っているとwp_print_scriptsとwp_print_head_scriptsと私の第二のスニペットの機能でアクションを削除しますが、テストで、私は、問題の原因となったものを分離し、私はこれらのみを示しています。

// Move render-blocking JavaScript. 
function custom_clean_head() {  
    remove_action('wp_head', 'wp_enqueue_scripts', 1); 
    add_action('wp_footer', 'wp_enqueue_scripts', 5); 
} 
add_action('wp_enqueue_scripts', 'custom_clean_head', 9999999); 

私はスクリプトの登録を解除しようとしましたが、パスワード強度メーターは消えましたが、ページロード時に膨大な量のjavascriptエラーが発生しました。

+0

あなたは、追加しようと、このような優先順位チューニングしている: 'add_action( 'wp_print_scripts'、 'wc_ninja_remove_password_strength'、100);' – LoicTheAztec

+0

私は、問題はあなたの第二の抜粋であると思います。最初のスニペットをすべて削除して、JSエラーがまだ表示されているかどうかテストしましたか? –

+0

'add_action( 'wp_print_scripts'、 'wc_ninja_remove_password_strength'、100);'しようとしました(実際には優先度100がデフォルトです)、動作しませんでした。 JSエラーは、1番目のスニペットでスクリプトを登録解除すると表示されます。他のものがなくても実行されれば、それらのどれも正常に動作します私は 'wp_print_scripts'を' wp_head'で置き換えようとしましたが、成功しませんでした。 –

答えて

0

解決策を見つけたので、wp_print_scriptswp_enqueue_scriptsに置き換えて、1番目のスニペットの最後の行に置き換えてください。

Wordpress 3.3(4年以上前)wp_print_scriptsは、私がやったようにwp_enqueue_scriptsに置き換えられてはいけません。

https://codex.wordpress.org/Plugin_API/Action_Reference/wp_print_scripts

// Remove password strength meter from checkout, registration and password recovery. 
function wc_ninja_remove_password_strength() { 
    if (wp_script_is('wc-password-strength-meter', 'enqueued')) { 
     wp_dequeue_script('wc-password-strength-meter');  
    } 
} 
add_action('wp_enqueue_scripts', 'wc_ninja_remove_password_strength');  
関連する問題