[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

/src/includes/core/ -> sub-actions.php (source)

   1  <?php
   2  
   3  /**
   4   * Plugin Dependency
   5   *
   6   * The purpose of the following hooks is to mimic the behavior of something
   7   * called 'plugin dependency' which enables a plugin to have plugins of their
   8   * own in a safe and reliable way.
   9   *
  10   * We do this in bbPress by mirroring existing WordPress hooks in many places
  11   * allowing dependant plugins to hook into the bbPress specific ones, thus
  12   * guaranteeing proper code execution only when bbPress is active.
  13   *
  14   * The following functions are wrappers for hooks, allowing them to be
  15   * manually called and/or piggy-backed on top of other hooks if needed.
  16   *
  17   * @package bbPress
  18   * @subpackage Core
  19   *
  20   * @todo use anonymous functions when PHP minimum requirement allows (5.3)
  21   */
  22  
  23  /** Activation Actions ********************************************************/
  24  
  25  /**
  26   * Runs on bbPress activation
  27   *
  28   * @since 2.0.0 bbPress (r2509)
  29   */
  30  function bbp_activation() {
  31      do_action( 'bbp_activation' );
  32  }
  33  
  34  /**
  35   * Runs on bbPress deactivation
  36   *
  37   * @since 2.0.0 bbPress (r2509)
  38   */
  39  function bbp_deactivation() {
  40      do_action( 'bbp_deactivation' );
  41  }
  42  
  43  /**
  44   * Runs when uninstalling bbPress
  45   *
  46   * @since 2.0.0 bbPress (r2509)
  47   */
  48  function bbp_uninstall() {
  49      do_action( 'bbp_uninstall' );
  50  }
  51  
  52  /** Main Actions **************************************************************/
  53  
  54  /**
  55   * Main action responsible for constants, globals, and includes
  56   *
  57   * @since 2.0.0 bbPress (r2599)
  58   */
  59  function bbp_loaded() {
  60      do_action( 'bbp_loaded' );
  61  }
  62  
  63  /**
  64   * Setup constants
  65   *
  66   * @since 2.0.0 bbPress (r2599)
  67   */
  68  function bbp_constants() {
  69      do_action( 'bbp_constants' );
  70  }
  71  
  72  /**
  73   * Setup globals BEFORE includes
  74   *
  75   * @since 2.0.0 bbPress (r2599)
  76   */
  77  function bbp_boot_strap_globals() {
  78      do_action( 'bbp_boot_strap_globals' );
  79  }
  80  
  81  /**
  82   * Include files
  83   *
  84   * @since 2.0.0 bbPress (r2599)
  85   */
  86  function bbp_includes() {
  87      do_action( 'bbp_includes' );
  88  }
  89  
  90  /**
  91   * Setup globals AFTER includes
  92   *
  93   * @since 2.0.0 bbPress (r2599)
  94   */
  95  function bbp_setup_globals() {
  96      do_action( 'bbp_setup_globals' );
  97  }
  98  
  99  /**
 100   * Register any objects before anything is initialized
 101   *
 102   * @since 2.2.0 bbPress (r4180)
 103   */
 104  function bbp_register() {
 105      do_action( 'bbp_register' );
 106  }
 107  
 108  /**
 109   * Initialize any code after everything has been loaded
 110   *
 111   * @since 2.0.0 bbPress (r2599)
 112   */
 113  function bbp_init() {
 114      do_action( 'bbp_init' );
 115  }
 116  
 117  /**
 118   * Initialize roles
 119   *
 120   * @since 2.6.0 bbPress (r6106)
 121   *
 122   * @param WP_Roles $wp_roles The array of WP_Role objects that was initialized
 123   */
 124  function bbp_roles_init( $wp_roles ) {
 125      do_action( 'bbp_roles_init', $wp_roles );
 126  }
 127  
 128  /**
 129   * Initialize widgets
 130   *
 131   * @since 2.0.0 bbPress (r3389)
 132   */
 133  function bbp_widgets_init() {
 134      do_action( 'bbp_widgets_init' );
 135  }
 136  
 137  /**
 138   * Setup the currently logged-in user
 139   *
 140   * @link https://bbpress.trac.wordpress.org/ticket/2309
 141   * @link https://core.trac.wordpress.org/ticket/24169
 142   *
 143   * @since 2.0.0 bbPress (r2695)
 144   */
 145  function bbp_setup_current_user() {
 146      do_action( 'bbp_setup_current_user' );
 147  }
 148  
 149  /**
 150   * Setup the user engagements strategy
 151   *
 152   * @since 2.6.0 bbPress (r6875)
 153   */
 154  function bbp_setup_engagements() {
 155      do_action( 'bbp_setup_engagements' );
 156  }
 157  
 158  /** Supplemental Actions ******************************************************/
 159  
 160  /**
 161   * Load translations for current language
 162   *
 163   * @since 2.0.0 bbPress (r2599)
 164   */
 165  function bbp_load_textdomain() {
 166      do_action( 'bbp_load_textdomain' );
 167  }
 168  
 169  /**
 170   * Setup the post types
 171   *
 172   * @since 2.0.0 bbPress (r2464)
 173   */
 174  function bbp_register_post_types() {
 175      do_action( 'bbp_register_post_types' );
 176  }
 177  
 178  /**
 179   * Setup the post statuses
 180   *
 181   * @since 2.0.0 bbPress (r2727)
 182   */
 183  function bbp_register_post_statuses() {
 184      do_action( 'bbp_register_post_statuses' );
 185  }
 186  
 187  /**
 188   * Register the built in bbPress taxonomies
 189   *
 190   * @since 2.0.0 bbPress (r2464)
 191   */
 192  function bbp_register_taxonomies() {
 193      do_action( 'bbp_register_taxonomies' );
 194  }
 195  
 196  /**
 197   * Register the default bbPress views
 198   *
 199   * @since 2.0.0 bbPress (r2789)
 200   */
 201  function bbp_register_views() {
 202      do_action( 'bbp_register_views' );
 203  }
 204  
 205  /**
 206   * Register the default bbPress shortcodes
 207   *
 208   * @since 2.2.0 bbPress (r4211)
 209   */
 210  function bbp_register_shortcodes() {
 211      do_action( 'bbp_register_shortcodes' );
 212  }
 213  
 214  /**
 215   * Register the default bbPress meta-data
 216   *
 217   * @since 2.6.0 bbPress (r46300)
 218   */
 219  function bbp_register_meta() {
 220      do_action( 'bbp_register_meta' );
 221  }
 222  
 223  /**
 224   * Enqueue bbPress specific CSS and JS
 225   *
 226   * @since 2.0.0 bbPress (r3373)
 227   */
 228  function bbp_enqueue_scripts() {
 229      do_action( 'bbp_enqueue_scripts' );
 230  }
 231  
 232  /**
 233   * Add the bbPress-specific rewrite tags
 234   *
 235   * @since 2.0.0 bbPress (r2753)
 236   */
 237  function bbp_add_rewrite_tags() {
 238      do_action( 'bbp_add_rewrite_tags' );
 239  }
 240  
 241  /**
 242   * Add the bbPress-specific rewrite rules
 243   *
 244   * @since 2.4.0 bbPress (r4918)
 245   */
 246  function bbp_add_rewrite_rules() {
 247      do_action( 'bbp_add_rewrite_rules' );
 248  }
 249  
 250  /**
 251   * Add the bbPress-specific permalink structures
 252   *
 253   * @since 2.4.0 bbPress (r4918)
 254   */
 255  function bbp_add_permastructs() {
 256      do_action( 'bbp_add_permastructs' );
 257  }
 258  
 259  /**
 260   * Add the bbPress-specific login forum action
 261   *
 262   * @since 2.0.0 bbPress (r2753)
 263   */
 264  function bbp_login_form_login() {
 265      do_action( 'bbp_login_form_login' );
 266  }
 267  
 268  
 269  /**
 270   * Add the bbPress-specific post status transition action
 271   *
 272   * @since 2.6.0 bbPress (r6792)
 273   *
 274   * @param string  $new_status New post status
 275   * @param string  $old_status Old post status
 276   * @param WP_Post $post       Post object
 277   */
 278  function bbp_transition_post_status( $new_status = '', $old_status = '', $post = false ) {
 279  
 280      // Get bbPress post types
 281      $post_type = get_post_type( $post );
 282      $types     = bbp_get_post_types();
 283  
 284      // Bail if post is not a bbPress post type
 285      if ( ! in_array( $post_type, $types, true ) ) {
 286          return;
 287      }
 288  
 289      // Do the action
 290      do_action( 'bbp_transition_post_status', $new_status, $old_status, $post );
 291  }
 292  
 293  /** User Actions **************************************************************/
 294  
 295  /**
 296   * The main action for hooking into when a user account is updated
 297   *
 298   * @since 2.2.0 bbPress (r4304)
 299   *
 300   * @param int $user_id ID of user being edited
 301   * @param array $old_user_data The old, unmodified user data
 302   */
 303  function bbp_profile_update( $user_id = 0, $old_user_data = array() ) {
 304      do_action( 'bbp_profile_update', $user_id, $old_user_data );
 305  }
 306  
 307  /**
 308   * The main action for hooking into a user being registered
 309   *
 310   * @since 2.2.0 bbPress (r4304)
 311   *
 312   * @param int $user_id ID of user being edited
 313   */
 314  function bbp_user_register( $user_id = 0 ) {
 315      do_action( 'bbp_user_register', $user_id );
 316  }
 317  
 318  /** Final Action **************************************************************/
 319  
 320  /**
 321   * bbPress has loaded and initialized everything, and is okay to go
 322   *
 323   * @since 2.0.0 bbPress (r2618)
 324   */
 325  function bbp_ready() {
 326      do_action( 'bbp_ready' );
 327  }
 328  
 329  /** Theme Permissions *********************************************************/
 330  
 331  /**
 332   * The main action used for redirecting bbPress theme actions that are not
 333   * permitted by the current_user
 334   *
 335   * @since 2.1.0 bbPress (r3605)
 336   */
 337  function bbp_template_redirect() {
 338      do_action( 'bbp_template_redirect' );
 339  }
 340  
 341  /** Theme Helpers *************************************************************/
 342  
 343  /**
 344   * The main action used for executing code before the theme has been setup
 345   *
 346   * @since 2.1.0 bbPress (r3829)
 347   */
 348  function bbp_register_theme_packages() {
 349      do_action( 'bbp_register_theme_packages' );
 350  }
 351  
 352  /**
 353   * The main action used for executing code before the theme has been setup
 354   *
 355   * @since 2.1.0 bbPress (r3732)
 356   */
 357  function bbp_setup_theme() {
 358      do_action( 'bbp_setup_theme' );
 359  }
 360  
 361  /**
 362   * The main action used for executing code after the theme has been setup
 363   *
 364   * @since 2.1.0 bbPress (r3732)
 365   */
 366  function bbp_after_setup_theme() {
 367      do_action( 'bbp_after_setup_theme' );
 368  }
 369  
 370  /**
 371   * The main action used for handling theme-side POST requests
 372   *
 373   * @since 2.3.0 bbPress (r4550)
 374   */
 375  function bbp_post_request() {
 376  
 377      // Bail if not a POST action
 378      if ( ! bbp_is_post_request() ) {
 379          return;
 380      }
 381  
 382      // Bail if no action
 383      if ( empty( $_POST['action'] ) ) {
 384          return;
 385      }
 386  
 387      // Sanitize the POST action
 388      $action = sanitize_key( $_POST['action'] );
 389  
 390      // Bail if action was totally invalid
 391      if ( empty( $action ) ) {
 392          return;
 393      }
 394  
 395      // This dynamic action is probably the one you want to use. It narrows down
 396      // the scope of the 'action' without needing to check it in your function.
 397      do_action( 'bbp_post_request_' . $action );
 398  
 399      // Use this static action if you don't mind checking the 'action' yourself.
 400      do_action( 'bbp_post_request',   $action );
 401  }
 402  
 403  /**
 404   * The main action used for handling theme-side GET requests
 405   *
 406   * @since 2.3.0 bbPress (r4550)
 407   */
 408  function bbp_get_request() {
 409  
 410      // Bail if not a POST action
 411      if ( ! bbp_is_get_request() ) {
 412          return;
 413      }
 414  
 415      // Bail if no action
 416      if ( empty( $_GET['action'] ) ) {
 417          return;
 418      }
 419  
 420      // Sanitize the GET action
 421      $action = sanitize_key( $_GET['action'] );
 422  
 423      // Bail if action was totally invalid
 424      if ( empty( $action ) ) {
 425          return;
 426      }
 427  
 428      // This dynamic action is probably the one you want to use. It narrows down
 429      // the scope of the 'action' without needing to check it in your function.
 430      do_action( 'bbp_get_request_' . $action );
 431  
 432      // Use this static action if you don't mind checking the 'action' yourself.
 433      do_action( 'bbp_get_request',   $action );
 434  }
 435  
 436  /** Filters *******************************************************************/
 437  
 438  /**
 439   * Filter the plugin locale and domain.
 440   *
 441   * @since 2.2.0 bbPress (r4213)
 442   *
 443   * @param string $locale
 444   * @param string $domain
 445   */
 446  function bbp_plugin_locale( $locale = '', $domain = '' ) {
 447  
 448      // Filter & return
 449      return apply_filters( 'bbp_plugin_locale', $locale, $domain );
 450  }
 451  
 452  /**
 453   * Piggy back filter for WordPress's 'request' filter
 454   *
 455   * @since 2.1.0 bbPress (r3758)
 456   *
 457   * @param array $query_vars
 458   * @return array
 459   */
 460  function bbp_request( $query_vars = array() ) {
 461  
 462      // Filter & return
 463      return apply_filters( 'bbp_request', $query_vars );
 464  }
 465  
 466  /**
 467   * The main filter used for theme compatibility and displaying custom bbPress
 468   * theme files.
 469   *
 470   * @since 2.0.0 bbPress (r3311)
 471   *
 472   * @param string $template
 473   * @return string Template file to use
 474   */
 475  function bbp_template_include( $template = '' ) {
 476  
 477      // Filter & return
 478      return apply_filters( 'bbp_template_include', $template );
 479  }
 480  
 481  /**
 482   * Generate bbPress-specific rewrite rules
 483   *
 484   * @since 2.0.0 bbPress (r2688)
 485   *
 486   * @deprecated 2.4.0 bbPress (r4918)
 487   *
 488   * @param WP_Rewrite $wp_rewrite
 489   */
 490  function bbp_generate_rewrite_rules( $wp_rewrite ) {
 491      do_action_ref_array( 'bbp_generate_rewrite_rules', array( &$wp_rewrite ) );
 492  }
 493  
 494  /**
 495   * Filter the allowed themes list for bbPress specific themes
 496   *
 497   * @since 2.0.0 bbPress (r2944)
 498   *
 499   * @param array $themes
 500   *
 501   * @return array Array of allowed themes
 502   */
 503  function bbp_allowed_themes( $themes ) {
 504  
 505      // Filter & return
 506      return (array) apply_filters( 'bbp_allowed_themes', $themes );
 507  }
 508  
 509  /**
 510   * Maps forum/topic/reply caps to built in WordPress caps
 511   *
 512   * @since 2.0.0 bbPress (r2593)
 513   *
 514   * @param array $caps Capabilities for meta capability
 515   * @param string $cap Capability name
 516   * @param int $user_id User id
 517   * @param array $args Arguments
 518   *
 519   * @return array Array of capabilities
 520   */
 521  function bbp_map_meta_caps( $caps = array(), $cap = '', $user_id = 0, $args = array() ) {
 522  
 523      // Filter & return
 524      return (array) apply_filters( 'bbp_map_meta_caps', $caps, $cap, $user_id, $args );
 525  }


Generated: Sat Sep 21 01:01:35 2019 Cross-referenced by PHPXref 0.7.1