Skip to:
Content

BuddyPress.org

Changeset 9641


Ignore:
Timestamp:
03/24/2015 06:19:49 AM (7 years ago)
Author:
tw2113
Message:

Adds hooks documentation to bp-core-component.php and bp-core-dependency.php.

See #5940.

Location:
trunk/src/bp-core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-component.php

    r9351 r9641  
    223223        ) );
    224224
    225         // Slug used for permalink URI chunk after root
     225        /**
     226         * Filters the slug to be used for the permalink URI chunk after root.
     227         *
     228         * @since BuddyPress (1.5.0)
     229         *
     230         * @param string $value Slug to use in permalink URI chunk.
     231         */
    226232        $this->slug                  = apply_filters( 'bp_' . $this->id . '_slug',                  $r['slug']                  );
    227233
    228         // Slug used for root directory
     234        /**
     235         * Filters the slug used for root directory.
     236         *
     237         * @since BuddyPress (1.5.0)
     238         *
     239         * @param string $value Root directory slug.
     240         */
    229241        $this->root_slug             = apply_filters( 'bp_' . $this->id . '_root_slug',             $r['root_slug']             );
    230242
    231         // Does this component have a top-level directory?
     243        /**
     244         * Filters the component's top-level directory if available.
     245         *
     246         * @since BuddyPress (1.5.0)
     247         *
     248         * @param bool $value Whether or not there is a top-level directory.
     249         */
    232250        $this->has_directory         = apply_filters( 'bp_' . $this->id . '_has_directory',         $r['has_directory']         );
    233251
    234         // Does this component have a top-level directory?
     252        /**
     253         * Filters the component's directory title.
     254         *
     255         * @since BuddyPress (2.0.0)
     256         *
     257         * @param string $value Title to use for the directory.
     258         */
    235259        $this->directory_title       = apply_filters( 'bp_' . $this->id . '_directory_title',       $r['directory_title']         );
    236260
    237         // Search string
     261        /**
     262         * Filters the placeholder text for search inputs for component.
     263         *
     264         * @since BuddyPress (1.5.0)
     265         *
     266         * @param string $value Name to use in search input placeholders.
     267         */
    238268        $this->search_string         = apply_filters( 'bp_' . $this->id . '_search_string',         $r['search_string']         );
    239269
    240         // Notifications callback
     270        /**
     271         * Filters the callable function that formats the component's notifications.
     272         *
     273         * @since BuddyPress (1.5.0)
     274         *
     275         * @param string $value Function callback.
     276         */
    241277        $this->notification_callback = apply_filters( 'bp_' . $this->id . '_notification_callback', $r['notification_callback'] );
    242278
     
    256292        buddypress()->loaded_components[$this->slug] = $this->id;
    257293
    258         // Call action
     294        /**
     295         * Fires at the end of the setup_globals method inside BP_Component.
     296         *
     297         * This is a dynamic hook that is based on the component string ID.
     298         *
     299         * @since BuddyPress (1.5.0)
     300         */
    259301        do_action( 'bp_' . $this->id . '_setup_globals' );
    260302    }
     
    321363        }
    322364
    323         // Call action
     365        /**
     366         * Fires at the end of the includes method inside BP_Component.
     367         *
     368         * This is a dynamic hook that is based on the component string ID.
     369         *
     370         * @since BuddyPress (1.5.0)
     371         */
    324372        do_action( 'bp_' . $this->id . '_includes' );
    325373    }
     
    381429        add_action( 'bp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10 );
    382430
    383         // Additional actions can be attached here
     431        /**
     432         * Fires at the end of the setup_actions method inside BP_Component.
     433         *
     434         * This is a dynamic hook that is based on the component string ID.
     435         *
     436         * @since BuddyPress (1.5.0)
     437         */
    384438        do_action( 'bp_' . $this->id . '_setup_actions' );
    385439    }
     
    420474        }
    421475
    422         // Call action
     476        /**
     477         * Fires at the end of the setup_nav method inside BP_Component.
     478         *
     479         * This is a dynamic hook that is based on the component string ID.
     480         *
     481         * @since BuddyPress (1.5.0)
     482         */
    423483        do_action( 'bp_' . $this->id . '_setup_nav' );
    424484    }
     
    448508        }
    449509
    450         // Filter the passed admin nav
     510        /**
     511         * Filters the admin navigation passed into setup_admin_bar.
     512         *
     513         * This is a dynamic hook that is based on the component string ID.
     514         *
     515         * @since BuddyPress (1.9.0)
     516         *
     517         * @param array $wp_admin_nav Array of navigation items to add.
     518         */
    451519        $wp_admin_nav = apply_filters( 'bp_' . $this->id . '_admin_nav', $wp_admin_nav );
    452520
     
    466534        }
    467535
    468         // Call action
     536        /**
     537         * Fires at the end of the setup_admin_bar method inside BP_Component.
     538         *
     539         * This is a dynamic hook that is based on the component string ID.
     540         *
     541         * @since BuddyPress (1.5.0)
     542         */
    469543        do_action( 'bp_' . $this->id . '_setup_admin_bar' );
    470544    }
     
    478552     */
    479553    public function setup_title() {
     554
     555        /**
     556         * Fires in the setup_title method inside BP_Component.
     557         *
     558         * This is a dynamic hook that is based on the component string ID.
     559         *
     560         * @since BuddyPress (1.5.0)
     561         */
    480562        do_action(  'bp_' . $this->id . '_setup_title' );
    481563    }
     
    489571     */
    490572    public function setup_cache_groups() {
     573
     574        /**
     575         * Fires in the setup_cache_groups method inside BP_Component.
     576         *
     577         * This is a dynamic hook that is based on the component string ID.
     578         *
     579         * @since BuddyPress (2.2.0)
     580         */
    491581        do_action( 'bp_' . $this->id . '_setup_cache_groups' );
    492582    }
     
    501591    public function register_global_tables( $tables = array() ) {
    502592
    503         // This filter allows for component-specific filtering of table names
    504         // To filter *all* tables, use the 'bp_core_get_table_prefix' filter instead
     593        /**
     594         * Filters the global tables for the component, so that it may use WordPress' database API.
     595         *
     596         * This is a dynamic hook that is based on the component string ID.
     597         * It allows for component-specific filtering of table names. To filter
     598         * *all* tables, use the 'bp_core_get_table_prefix' filter instead.
     599         *
     600         * @since BuddyPress (1.6.0)
     601         */
    505602        $tables = apply_filters( 'bp_' . $this->id . '_global_tables', $tables );
    506603
     
    515612        }
    516613
     614        /**
     615         * Fires at the end of the register_global_tables method inside BP_Component.
     616         *
     617         * This is a dynamic hook that is based on the component string ID.
     618         *
     619         * @since BuddyPress (2.0.0)
     620         */
    517621        do_action( 'bp_' . $this->id . '_register_global_tables' );
    518622    }
     
    531635        global $wpdb;
    532636
    533         // This filter allows for component-specific filtering of table names
    534         // To filter *all* tables, use the 'bp_core_get_table_prefix' filter instead
     637        /**
     638         * Filters the global meta_tables for the component.
     639         *
     640         * This is a dynamic hook that is based on the component string ID.
     641         * It allows for component-specific filtering of table names. To filter
     642         * *all* tables, use the 'bp_core_get_table_prefix' filter instead.
     643         *
     644         * @since BuddyPress (2.0.0)
     645         */
    535646        $tables = apply_filters( 'bp_' . $this->id . '_meta_tables', $tables );
    536647
     
    548659        }
    549660
     661        /**
     662         * Fires at the end of the register_meta_tables method inside BP_Component.
     663         *
     664         * This is a dynamic hook that is based on the component string ID.
     665         *
     666         * @since BuddyPress (2.0.0)
     667         */
    550668        do_action( 'bp_' . $this->id . '_register_meta_tables' );
    551669    }
     
    559677     */
    560678    public function register_post_types() {
     679
     680        /**
     681         * Fires in the register_post_types method inside BP_Component.
     682         *
     683         * This is a dynamic hook that is based on the component string ID.
     684         *
     685         * @since BuddyPress (1.5.0)
     686         */
    561687        do_action( 'bp_' . $this->id . '_register_post_types' );
    562688    }
     
    570696     */
    571697    public function register_taxonomies() {
     698
     699        /**
     700         * Fires in the register_taxonomies method inside BP_Component.
     701         *
     702         * This is a dynamic hook that is based on the component string ID.
     703         *
     704         * @since BuddyPress (1.5.0)
     705         */
    572706        do_action( 'bp_' . $this->id . '_register_taxonomies' );
    573707    }
     
    581715     */
    582716    public function add_rewrite_tags() {
     717
     718        /**
     719         * Fires in the add_rewrite_tags method inside BP_Component.
     720         *
     721         * This is a dynamic hook that is based on the component string ID.
     722         *
     723         * @since BuddyPress (1.5.0)
     724         */
    583725        do_action( 'bp_' . $this->id . '_add_rewrite_tags' );
    584726    }
     
    592734     */
    593735    public function add_rewrite_rules() {
     736
     737        /**
     738         * Fires in the add_rewrite_rules method inside BP_Component.
     739         *
     740         * This is a dynamic hook that is based on the component string ID.
     741         *
     742         * @since BuddyPress (1.9.0)
     743         */
    594744        do_action( 'bp_' . $this->id . '_add_rewrite_rules' );
    595745    }
     
    603753     */
    604754    public function add_permastructs() {
     755
     756        /**
     757         * Fires in the add_permastructs method inside BP_Component.
     758         *
     759         * This is a dynamic hook that is based on the component string ID.
     760         *
     761         * @since BuddyPress (1.9.0)
     762         */
    605763        do_action( 'bp_' . $this->id . '_add_permastructs' );
    606764    }
     
    615773     */
    616774    public function parse_query( $query ) {
     775
     776        /**
     777         * Fires in the parse_query method inside BP_Component.
     778         *
     779         * This is a dynamic hook that is based on the component string ID.
     780         *
     781         * @since BuddyPress (1.9.0)
     782         *
     783         * @param object $query Main WP_Query object. Passed by reference.
     784         */
    617785        do_action_ref_array( 'bp_' . $this->id . '_parse_query', array( &$query ) );
    618786    }
     
    626794     */
    627795    public function generate_rewrite_rules() {
     796
     797        /**
     798         * Fires in the generate_rewrite_rules method inside BP_Component.
     799         *
     800         * This is a dynamic hook that is based on the component string ID.
     801         *
     802         * @since BuddyPress (1.5.0)
     803         */
    628804        do_action( 'bp_' . $this->id . '_generate_rewrite_rules' );
    629805    }
  • trunk/src/bp-core/bp-core-dependency.php

    r9604 r9641  
    2222 */
    2323function bp_include() {
     24
     25    /**
     26     * Fires inside the 'bp_include' function, where plugins should include files.
     27     *
     28     * @since BuddyPress (1.2.5)
     29     */
    2430    do_action( 'bp_include' );
    2531}
     
    2935 */
    3036function bp_setup_components() {
     37
     38    /**
     39     * Fires inside the 'bp_setup_components' function, where plugins should initialize components.
     40     *
     41     * @since BuddyPress (1.6.0)
     42     */
    3143    do_action( 'bp_setup_components' );
    3244}
     
    3648 */
    3749function bp_setup_canonical_stack() {
     50
     51    /**
     52     * Fires inside the 'bp_setup_canonical_stack' function, where plugins should set up their canonical URL.
     53     *
     54     * @since BuddyPress (2.1.0)
     55     */
    3856    do_action( 'bp_setup_canonical_stack' );
    3957}
     
    4563 */
    4664function bp_register_taxonomies() {
     65
     66    /**
     67     * Fires inside the 'bp_register_taxonomies' function, where plugins should register taxonomies.
     68     *
     69     * @since BuddyPress (2.2.0)
     70     */
    4771    do_action( 'bp_register_taxonomies' );
    4872}
     
    5276 */
    5377function bp_setup_globals() {
     78
     79    /**
     80     * Fires inside the 'bp_setup_globals' function, where plugins should initialize global settings.
     81     *
     82     * @since BuddyPress (1.2.0)
     83     */
    5484    do_action( 'bp_setup_globals' );
    5585}
     
    5989 */
    6090function bp_setup_nav() {
     91
     92    /**
     93     * Fires inside the 'bp_setup_nav' function, where plugins should register their navigation items.
     94     *
     95     * @since BuddyPress (1.2.0)
     96     */
    6197    do_action( 'bp_setup_nav' );
    6298}
     
    66102 */
    67103function bp_setup_admin_bar() {
    68     if ( bp_use_wp_admin_bar() )
     104    if ( bp_use_wp_admin_bar() ) {
     105
     106        /**
     107         * Fires inside the 'bp_setup_admin_bar' function, where plugins should add items to the WP admin bar.
     108         *
     109         * This hook will only fire if bp_use_wp_admin_bar() returns true.
     110         *
     111         * @since BuddyPress (1.5.0)
     112         */
    69113        do_action( 'bp_setup_admin_bar' );
     114    }
    70115}
    71116
     
    74119 */
    75120function bp_setup_title() {
     121
     122    /**
     123     * Fires inside the 'bp_setup_title' function, where plugins should modify the page title.
     124     *
     125     * @since BuddyPress (1.5.0)
     126     */
    76127    do_action( 'bp_setup_title' );
    77128}
     
    81132 */
    82133function bp_setup_widgets() {
     134
     135    /**
     136     * Fires inside the 'bp_register_widgets' function, where plugins should register widgets.
     137     *
     138     * @since BuddyPress (1.2.0)
     139     */
    83140    do_action( 'bp_register_widgets' );
    84141}
     
    90147 */
    91148function bp_setup_cache_groups() {
     149
     150    /**
     151     * Fires inside the 'bp_setup_cache_groups' function, where cache groups are registered.
     152     *
     153     * @since BuddyPress (2.2.0)
     154     */
    92155    do_action( 'bp_setup_cache_groups' );
    93156}
     
    112175    }
    113176
     177    /**
     178     * Fires to set up the current user setup process.
     179     *
     180     * @since BuddyPress (1.7.0)
     181     */
    114182    do_action( 'bp_setup_current_user' );
    115183}
     
    119187 */
    120188function bp_init() {
     189
     190    /**
     191     * Fires inside the 'bp_init' function, BuddyPress' main initialization hook.
     192     *
     193     * @since BuddyPress (1.2.0)
     194     */
    121195    do_action( 'bp_init' );
    122196}
     
    128202 */
    129203function bp_loaded() {
     204
     205    /**
     206     * Fires inside the 'bp_loaded' function, which fires after BP's core plugin files have been loaded.
     207     *
     208     * @since BuddyPress (1.2.5)
     209     */
    130210    do_action( 'bp_loaded' );
    131211}
     
    137217 */
    138218function bp_ready() {
     219
     220    /**
     221     * Fires inside the 'bp_ready' function, which runs after BP is set up and the page is about to render.
     222     *
     223     * @since BuddyPress (1.6.0)
     224     */
    139225    do_action( 'bp_ready' );
    140226}
     
    147233 */
    148234function bp_actions() {
     235
     236    /**
     237     * Fires inside the 'bp_actions' function, which runs just before rendering.
     238     *
     239     * @since BuddyPress (1.5.0)
     240     */
    149241    do_action( 'bp_actions' );
    150242}
     
    157249 */
    158250function bp_screens() {
     251
     252    /**
     253     * Fires inside the 'bp_screens' function, which runs just before rendering.
     254     *
     255     * Runs just after 'bp_actions'. Use this hook to attach your template loaders.
     256     *
     257     * @since BuddyPress (1.5.0)
     258     */
    159259    do_action( 'bp_screens' );
    160260}
     
    166266 */
    167267function bp_widgets_init() {
     268
     269    /**
     270     * Fires inside the 'bp_widgets_init' function, which runs after widgets have been set up.
     271     *
     272     * Hooked to 'widgets_init'.
     273     *
     274     * @since BuddyPress (1.6.0)
     275     */
    168276    do_action ( 'bp_widgets_init' );
    169277}
     
    192300 */
    193301function bp_template_redirect() {
     302
     303    /**
     304     * Fires inside the 'bp_template_redirect' function.
     305     *
     306     * @since BuddyPress (1.6.0)
     307     */
    194308    do_action( 'bp_template_redirect' );
    195309}
     
    207321 */
    208322function bp_register_theme_directory() {
     323
     324    /**
     325     * Fires inside the 'bp_register_theme_directory' function.
     326     *
     327     * The main action used registering theme directories.
     328     *
     329     * @since BuddyPress (1.7.0)
     330     */
    209331    do_action( 'bp_register_theme_directory' );
    210332}
     
    220342 */
    221343function bp_register_theme_packages() {
     344
     345    /**
     346     * Fires inside the 'bp_register_theme_packages' function.
     347     *
     348     * @since BuddyPress (1.7.0)
     349     */
    222350    do_action( 'bp_register_theme_packages' );
    223351}
     
    231359 */
    232360function bp_enqueue_scripts() {
     361
     362    /**
     363     * Fires inside the 'bp_enqueue_scripts' function, where BP enqueues its CSS and JS.
     364     *
     365     * @since BuddyPress (1.6.0)
     366     */
    233367    do_action ( 'bp_enqueue_scripts' );
    234368}
     
    242376 */
    243377function bp_add_rewrite_tags() {
     378
     379    /**
     380     * Fires inside the 'bp_add_rewrite_tags' function, where BP adds its custom rewrite tags.
     381     *
     382     * @since BuddyPress (1.8.0)
     383     */
    244384    do_action( 'bp_add_rewrite_tags' );
    245385}
     
    253393 */
    254394function bp_add_rewrite_rules() {
     395
     396    /**
     397     * Fires inside the 'bp_add_rewrite_rules' function, where BP adds its custom rewrite rules.
     398     *
     399     * @since BuddyPress (1.9.0)
     400     */
    255401    do_action( 'bp_add_rewrite_rules' );
    256402}
     
    264410 */
    265411function bp_add_permastructs() {
     412
     413    /**
     414     * Fires inside the 'bp_add_permastructs' function, where BP adds its BP-specific permalink structure.
     415     *
     416     * @since BuddyPress (1.9.0)
     417     */
    266418    do_action( 'bp_add_permastructs' );
    267419}
     
    278430 */
    279431function bp_setup_theme() {
     432
     433    /**
     434     * Fires inside the 'bp_setup_theme' function.
     435     *
     436     * @since BuddyPress (1.6.0)
     437     */
    280438    do_action ( 'bp_setup_theme' );
    281439}
     
    296454 */
    297455function bp_after_setup_theme() {
     456
     457    /**
     458     * Fires inside the 'bp_after_setup_theme' function.
     459     *
     460     * @since BuddyPress (1.7.0)
     461     */
    298462    do_action ( 'bp_after_setup_theme' );
    299463}
     
    312476 */
    313477function bp_request( $query_vars = array() ) {
     478
     479    /**
     480     * Filters the query_vars for the current request.
     481     *
     482     * @since BuddyPress (1.7.0)
     483     *
     484     * @param array $query_vars Array of query variables.
     485     */
    314486    return apply_filters( 'bp_request', $query_vars );
    315487}
     
    322494 * @param string $redirect_to See 'login_redirect'.
    323495 * @param string $redirect_to_raw See 'login_redirect'.
    324  * @param string $user See 'login_redirect'.
     496 * @param bool   $user See 'login_redirect'.
     497 *
     498 * @return string
    325499 */
    326500function bp_login_redirect( $redirect_to = '', $redirect_to_raw = '', $user = false ) {
     501
     502    /**
     503     * Filters the URL to redirect to after login.
     504     *
     505     * @since BuddyPress (1.7.0)
     506     *
     507     * @param string           $redirect_to     The redirect destination URL.
     508     * @param string           $redirect_to_raw The requested redirect destination URL passed as a parameter.
     509     * @param WP_User|WP_Error $user            WP_User object if login was successful, WP_Error object otherwise.
     510     */
    327511    return apply_filters( 'bp_login_redirect', $redirect_to, $redirect_to_raw, $user );
    328512}
     
    341525 */
    342526function bp_template_include( $template = '' ) {
     527
     528    /**
     529     * Filters the template to use with template_include.
     530     *
     531     * @since BuddyPress (1.6.0)
     532     *
     533     * @param string $template The path of the template to include.
     534     */
    343535    return apply_filters( 'bp_template_include', $template );
    344536}
    345537
    346538/**
    347  * Fire the 'bp_generate_rewrite_rules' filter, where BP generates its rewrite rules.
     539 * Fire the 'bp_generate_rewrite_rules' action, where BP generates its rewrite rules.
    348540 *
    349541 * @since BuddyPress (1.7.0)
     
    354546 */
    355547function bp_generate_rewrite_rules( $wp_rewrite ) {
     548
     549    /**
     550     * Fires inside the 'bp_generate_rewrite_rules' function.
     551     *
     552     * @since BuddyPress (1.7.0)
     553     *
     554     * @param WP_Rewrite $wp_rewrite WP_Rewrite object. Passed by reference.
     555     */
    356556    do_action_ref_array( 'bp_generate_rewrite_rules', array( &$wp_rewrite ) );
    357557}
     
    367567 */
    368568function bp_allowed_themes( $themes ) {
     569
     570    /**
     571     * Filters the allowed themes list for BuddyPress-specific themes.
     572     *
     573     * @since BuddyPress (1.7.0)
     574     *
     575     * @param string $template The path of the template to include.
     576     */
    369577    return apply_filters( 'bp_allowed_themes', $themes );
    370578}
     
    393601    $action = sanitize_key( $_POST['action'] );
    394602
    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.
     603    /**
     604     * Fires at the end of the bp_post_request function.
     605     *
     606     * This dynamic action is probably the one you want to use. It narrows down
     607     * the scope of the 'action' without needing to check it in your function.
     608     *
     609     * @since BuddyPress (1.9.0)
     610     */
    397611    do_action( 'bp_post_request_' . $action );
    398612
    399     // Use this static action if you don't mind checking the 'action' yourself.
     613    /**
     614     * Fires at the end of the bp_post_request function.
     615     *
     616     * Use this static action if you don't mind checking the 'action' yourself.
     617     *
     618     * @since BuddyPress (1.9.0)
     619     *
     620     * @param string $action The action being run.
     621     */
    400622    do_action( 'bp_post_request',   $action );
    401623}
     
    422644    $action = sanitize_key( $_GET['action'] );
    423645
    424     // This dynamic action is probably the one you want to use. It narrows down
    425     // the scope of the 'action' without needing to check it in your function.
     646    /**
     647     * Fires at the end of the bp_get_request function.
     648     *
     649     * This dynamic action is probably the one you want to use. It narrows down
     650     * the scope of the 'action' without needing to check it in your function.
     651     *
     652     * @since BuddyPress (1.9.0)
     653     */
    426654    do_action( 'bp_get_request_' . $action );
    427655
    428     // Use this static action if you don't mind checking the 'action' yourself.
     656    /**
     657     * Fires at the end of the bp_get_request function.
     658     *
     659     * Use this static action if you don't mind checking the 'action' yourself.
     660     *
     661     * @since BuddyPress (1.9.0)
     662     *
     663     * @param string $action The action being run.
     664     */
    429665    do_action( 'bp_get_request',   $action );
    430666}
Note: See TracChangeset for help on using the changeset viewer.