Last active
February 19, 2017 05:14
-
-
Save chwnam/936453488f5883788bd5 to your computer and use it in GitHub Desktop.
워드프레스의 등록된 훅을 덤프해보는 예제입니다. 실습용 소스라서 수정을 해야 합니다.
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
<?php | |
/* | |
Plugin Name: hookdump-<author> | |
Description: hookdump example by <author> | |
Author: <your name> | |
*/ | |
/* adds admin menu */ | |
add_action( 'admin_menu', '<author>_add_admin_menu' ); | |
/* our customized action hook */ | |
add_action( 'hookdump_<author>', ... ); | |
/* admin_menu action callback */ | |
function <author>_add_admin_menu() { | |
add_menu_page( | |
'hookdump-<author>', | |
'hookdump-<author>', | |
'manage_options', | |
'hookdump-<author>', | |
'<author>_admin_menu_page_callback' | |
); | |
} | |
/* add_menu_page callback */ | |
function <author>_admin_menu_page_callback() { | |
if( function_exists( 'dump_all_hooks' ) ) { | |
dump_all_hooks(); | |
} else { | |
echo '<p>My master plugin is not activated.</p>'; | |
} | |
do_action( 'hookdump_<author>' ); | |
} | |
/* our callback function might be here....*/ | |
function ...() { | |
echo "<div>Wow! There are so many hooks in the WordPress!</div>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment