Last active
November 2, 2018 07:54
-
-
Save kurudrive/503d2a1f836ff1de3a8b134fd30ad78f to your computer and use it in GitHub Desktop.
WordPressでremove_actionが効かない時の対処メモ ref: https://qiita.com/kurudrive/items/729c2ce8d7ac5026759e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'after_setup_theme', 'my_remove_action' ); | |
function my_remove_action() { | |
remove_action( 'wp_enqueue_scripts', '外すアクション', 10, 2 ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my_action_function() { | |
echo '<pre>これが消えたら成功</pre>'; | |
// 実行する処理 | |
} | |
add_action( 'wp_enqueue_scripts', 'my_action_function' ); | |
echo '━━━━━━━━━━ この後で remove が読み込まれる必要がある ━━━━━━━━━━'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
━━━━━━━━━━ この後で remove が読み込まれる必要がある ━━━━━━━━━━ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment