web/wp-content/plugins/bbpress/includes/admin/actions.php
changeset 196 5e8dcbe22c24
equal deleted inserted replaced
195:c7c0fbc09788 196:5e8dcbe22c24
       
     1 <?php
       
     2 
       
     3 /**
       
     4  * bbPress Admin Actions
       
     5  *
       
     6  * @package bbPress
       
     7  * @subpackage Admin
       
     8  *
       
     9  * This file contains the actions that are used through-out bbPress Admin. They
       
    10  * are consolidated here to make searching for them easier, and to help developers
       
    11  * understand at a glance the order in which things occur.
       
    12  *
       
    13  * There are a few common places that additional actions can currently be found
       
    14  *
       
    15  *  - bbPress: In {@link bbPress::setup_actions()} in bbpress.php
       
    16  *  - Admin: More in {@link BBP_Admin::setup_actions()} in admin.php
       
    17  *
       
    18  * @see bbp-core-actions.php
       
    19  * @see bbp-core-filters.php
       
    20  */
       
    21 
       
    22 // Exit if accessed directly
       
    23 if ( !defined( 'ABSPATH' ) ) exit;
       
    24 
       
    25 /**
       
    26  * Attach bbPress to WordPress
       
    27  *
       
    28  * bbPress uses its own internal actions to help aid in third-party plugin
       
    29  * development, and to limit the amount of potential future code changes when
       
    30  * updates to WordPress core occur.
       
    31  *
       
    32  * These actions exist to create the concept of 'plugin dependencies'. They
       
    33  * provide a safe way for plugins to execute code *only* when bbPress is
       
    34  * installed and activated, without needing to do complicated guesswork.
       
    35  *
       
    36  * For more information on how this works, see the 'Plugin Dependency' section
       
    37  * near the bottom of this file.
       
    38  *
       
    39  *           v--WordPress Actions       v--bbPress Sub-actions
       
    40  */
       
    41 add_action( 'admin_menu',              'bbp_admin_menu'                    );
       
    42 add_action( 'admin_init',              'bbp_admin_init'                    );
       
    43 add_action( 'admin_head',              'bbp_admin_head'                    );
       
    44 add_action( 'admin_notices',           'bbp_admin_notices'                 );
       
    45 add_action( 'custom_menu_order',       'bbp_admin_custom_menu_order'       );
       
    46 add_action( 'menu_order',              'bbp_admin_menu_order'              );
       
    47 add_action( 'wpmu_new_blog',           'bbp_new_site',               10, 6 );
       
    48 
       
    49 // Hook on to admin_init
       
    50 add_action( 'bbp_admin_init', 'bbp_admin_forums'                );
       
    51 add_action( 'bbp_admin_init', 'bbp_admin_topics'                );
       
    52 add_action( 'bbp_admin_init', 'bbp_admin_replies'               );
       
    53 add_action( 'bbp_admin_init', 'bbp_setup_updater',          999 );
       
    54 add_action( 'bbp_admin_init', 'bbp_register_importers'          );
       
    55 add_action( 'bbp_admin_init', 'bbp_register_admin_style'        );
       
    56 add_action( 'bbp_admin_init', 'bbp_register_admin_settings'     );
       
    57 add_action( 'bbp_admin_init', 'bbp_do_activation_redirect', 1   );
       
    58 
       
    59 // Initialize the admin area
       
    60 add_action( 'bbp_init', 'bbp_admin' );
       
    61 
       
    62 // Reset the menu order
       
    63 add_action( 'bbp_admin_menu', 'bbp_admin_separator' );
       
    64 
       
    65 // Activation
       
    66 add_action( 'bbp_activation', 'bbp_delete_rewrite_rules'    );
       
    67 
       
    68 // Deactivation
       
    69 add_action( 'bbp_deactivation', 'bbp_remove_caps'          );
       
    70 add_action( 'bbp_deactivation', 'bbp_delete_rewrite_rules' );
       
    71 
       
    72 // New Site
       
    73 add_action( 'bbp_new_site', 'bbp_create_initial_content', 8 );
       
    74 
       
    75 // Contextual Helpers
       
    76 add_action( 'load-settings_page_bbpress', 'bbp_admin_settings_help' );
       
    77 
       
    78 // Handle submission of Tools pages
       
    79 add_action( 'load-tools_page_bbp-repair', 'bbp_admin_repair_handler' );
       
    80 add_action( 'load-tools_page_bbp-reset',  'bbp_admin_reset_handler'  );
       
    81 
       
    82 // Add sample permalink filter
       
    83 add_filter( 'post_type_link', 'bbp_filter_sample_permalink', 10, 4 );
       
    84 
       
    85 /**
       
    86  * When a new site is created in a multisite installation, run the activation
       
    87  * routine on that site
       
    88  *
       
    89  * @since bbPress (r3283)
       
    90  *
       
    91  * @param int $blog_id
       
    92  * @param int $user_id
       
    93  * @param string $domain
       
    94  * @param string $path
       
    95  * @param int $site_id
       
    96  * @param array() $meta
       
    97  */
       
    98 function bbp_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
       
    99 
       
   100 	// Bail if plugin is not network activated
       
   101 	if ( ! is_plugin_active_for_network( bbpress()->basename ) )
       
   102 		return;
       
   103 
       
   104 	// Switch to the new blog
       
   105 	switch_to_blog( $blog_id );
       
   106 
       
   107 	// Do the bbPress activation routine
       
   108 	do_action( 'bbp_new_site', $blog_id, $user_id, $domain, $path, $site_id, $meta );
       
   109 
       
   110 	// restore original blog
       
   111 	restore_current_blog();
       
   112 }
       
   113 
       
   114 /** Sub-Actions ***************************************************************/
       
   115 
       
   116 /**
       
   117  * Piggy back admin_init action
       
   118  *
       
   119  * @since bbPress (r3766)
       
   120  * @uses do_action() Calls 'bbp_admin_init'
       
   121  */
       
   122 function bbp_admin_init() {
       
   123 	do_action( 'bbp_admin_init' );
       
   124 }
       
   125 
       
   126 /**
       
   127  * Piggy back admin_menu action
       
   128  *
       
   129  * @since bbPress (r3766)
       
   130  * @uses do_action() Calls 'bbp_admin_menu'
       
   131  */
       
   132 function bbp_admin_menu() {
       
   133 	do_action( 'bbp_admin_menu' );
       
   134 }
       
   135 
       
   136 /**
       
   137  * Piggy back admin_head action
       
   138  *
       
   139  * @since bbPress (r3766)
       
   140  * @uses do_action() Calls 'bbp_admin_head'
       
   141  */
       
   142 function bbp_admin_head() {
       
   143 	do_action( 'bbp_admin_head' );
       
   144 }
       
   145 
       
   146 /**
       
   147  * Piggy back admin_notices action
       
   148  *
       
   149  * @since bbPress (r3766)
       
   150  * @uses do_action() Calls 'bbp_admin_notices'
       
   151  */
       
   152 function bbp_admin_notices() {
       
   153 	do_action( 'bbp_admin_notices' );
       
   154 }
       
   155 
       
   156 /**
       
   157  * Dedicated action to register bbPress importers
       
   158  *
       
   159  * @since bbPress (r3766)
       
   160  * @uses do_action() Calls 'bbp_admin_notices'
       
   161  */
       
   162 function bbp_register_importers() {
       
   163 	do_action( 'bbp_register_importers' );
       
   164 }
       
   165 
       
   166 /**
       
   167  * Dedicated action to register admin styles
       
   168  *
       
   169  * @since bbPress (r3766)
       
   170  * @uses do_action() Calls 'bbp_admin_notices'
       
   171  */
       
   172 function bbp_register_admin_style() {
       
   173 	do_action( 'bbp_register_admin_style' );
       
   174 }
       
   175 
       
   176 /**
       
   177  * Dedicated action to register admin settings
       
   178  *
       
   179  * @since bbPress (r3766)
       
   180  * @uses do_action() Calls 'bbp_register_admin_settings'
       
   181  */
       
   182 function bbp_register_admin_settings() {
       
   183 	do_action( 'bbp_register_admin_settings' );
       
   184 }