Skip to content

Instantly share code, notes, and snippets.

@kurudrive
Last active November 2, 2018 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurudrive/503d2a1f836ff1de3a8b134fd30ad78f to your computer and use it in GitHub Desktop.
Save kurudrive/503d2a1f836ff1de3a8b134fd30ad78f to your computer and use it in GitHub Desktop.
WordPressでremove_actionが効かない時の対処メモ ref: https://qiita.com/kurudrive/items/729c2ce8d7ac5026759e
add_action( 'after_setup_theme', 'my_remove_action' );
function my_remove_action() {
remove_action( 'wp_enqueue_scripts', '外すアクション', 10, 2 );
}
function my_action_function() {
echo '<pre>これが消えたら成功</pre>';
// 実行する処理
}
add_action( 'wp_enqueue_scripts', 'my_action_function' );
echo '━━━━━━━━━━ この後で remove が読み込まれる必要がある ━━━━━━━━━━';
function my_remove_function() {
echo '<pre>今から消すよ!</pre>';
$return = remove_action( 'wp_enqueue_scripts', 'my_action_function' );
// 削除成功したら 1 が返る
print '<pre style="text-align:left">';
print_r( $return );
print '</pre>';
}
// ここの add_action の実行タイミングが鍵になる
add_action( 'after_setup_theme', 'my_remove_function' );
━━━━━━━━━━ この後で remove が読み込まれる必要がある ━━━━━━━━━━
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment