การเปิด และปิด Hook บันทึกส่วนตัว
การเปิดใช้งาน
register_activation_hook( __FILE__, ‘pluginprefix_function_to_run’ );
ตัวอย่าง
/** * Register the "book" custom post type */ function pluginprefix_setup_post_type() { register_post_type( 'book', ['public' => true ] ); } add_action( 'init', 'pluginprefix_setup_post_type' ); /** * Activate the plugin. */ function pluginprefix_activate() { // Trigger our function that registers the custom post type plugin. pluginprefix_setup_post_type(); // Clear the permalinks after the post type has been registered. flush_rewrite_rules(); } register_activation_hook( __FILE__, 'pluginprefix_activate' );
การปิดใช้งาน
register_deactivation_hook( __FILE__, ‘pluginprefix_function_to_run’ );