Skip to:
Content

BuddyPress.org

Ticket #5938: bp-activity-screens-5938.diff

File bp-activity-screens-5938.diff, 11.1 KB (added by tw2113, 10 years ago)
  • src/bp-activity/bp-activity-screens.php

     
    1717/**
    1818 * Load the Activity directory.
    1919 *
    20  * @since BuddyPress (1.5)
     20 * @since BuddyPress (1.5.0)
    2121 *
    2222 * @uses bp_displayed_user_id()
    2323 * @uses bp_is_activity_component()
     
    3131        if ( bp_is_activity_directory() ) {
    3232                bp_update_is_directory( true, 'activity' );
    3333
     34                /**
     35                 * Fires right before the loading of the Activity directory screen template file.
     36                 *
     37                 * @since BuddyPress (1.5.0)
     38                 */
    3439                do_action( 'bp_activity_screen_index' );
    3540
     41                /**
     42                 * Filters the template to load for the Activity directory screen.
     43                 *
     44                 * @since BuddyPress (1.5.0)
     45                 *
     46                 * @param string $template Path to the activity template to load.
     47                 */
    3648                bp_core_load_template( apply_filters( 'bp_activity_screen_index', 'activity/index' ) );
    3749        }
    3850}
     
    4153/**
    4254 * Load the 'My Activity' page.
    4355 *
    44  * @since BuddyPress (1.0)
     56 * @since BuddyPress (1.0.0)
    4557 *
    4658 * @uses do_action() To call the 'bp_activity_screen_my_activity' hook.
    4759 * @uses bp_core_load_template()
     
    4860 * @uses apply_filters() To call the 'bp_activity_template_my_activity' hook.
    4961 */
    5062function bp_activity_screen_my_activity() {
     63
     64        /**
     65         * Fires right before the loading of the "My Activity" screen template file.
     66         *
     67         * @since BuddyPress (1.0.0)
     68         */
    5169        do_action( 'bp_activity_screen_my_activity' );
     70
     71        /**
     72         * Filters the template to load for the "My Activity" screen.
     73         *
     74         * @since BuddyPress (1.0.0)
     75         *
     76         * @param string $template Path to the activity template to load.
     77         */
    5278        bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'members/single/home' ) );
    5379}
    5480
     
    5581/**
    5682 * Load the 'My Friends' activity page.
    5783 *
    58  * @since BuddyPress (1.0)
     84 * @since BuddyPress (1.0.0)
    5985 *
    6086 * @uses bp_is_active()
    6187 * @uses bp_update_is_item_admin()
     
    6995                return false;
    7096
    7197        bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
     98
     99        /**
     100         * Fires right before the loading of the "My Friends" screen template file.
     101         *
     102         * @since BuddyPress (1.2.0)
     103         */
    72104        do_action( 'bp_activity_screen_friends' );
     105
     106        /**
     107         * Filters the template to load for the "My Friends" screen.
     108         *
     109         * @since BuddyPress (1.0.0)
     110         *
     111         * @param string $template Path to the activity template to load.
     112         */
    73113        bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'members/single/home' ) );
    74114}
    75115
     
    76116/**
    77117 * Load the 'My Groups' activity page.
    78118 *
    79  * @since BuddyPress (1.2)
     119 * @since BuddyPress (1.2.0)
    80120 *
    81121 * @uses bp_is_active()
    82122 * @uses bp_update_is_item_admin()
     
    90130                return false;
    91131
    92132        bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
     133
     134        /**
     135         * Fires right before the loading of the "My Groups" screen template file.
     136         *
     137         * @since BuddyPress (1.2.0)
     138         */
    93139        do_action( 'bp_activity_screen_groups' );
     140
     141        /**
     142         * Filters the template to load for the "My Groups" screen.
     143         *
     144         * @since BuddyPress (1.2.0)
     145         *
     146         * @param string $template Path to the activity template to load.
     147         */
    94148        bp_core_load_template( apply_filters( 'bp_activity_template_groups_activity', 'members/single/home' ) );
    95149}
    96150
     
    97151/**
    98152 * Load the 'Favorites' activity page.
    99153 *
    100  * @since BuddyPress (1.2)
     154 * @since BuddyPress (1.2.0)
    101155 *
    102156 * @uses bp_update_is_item_admin()
    103157 * @uses bp_current_user_can()
     
    107161 */
    108162function bp_activity_screen_favorites() {
    109163        bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
     164
     165        /**
     166         * Fires right before the loading of the "Favorites" screen template file.
     167         *
     168         * @since BuddyPress (1.2.0)
     169         */
    110170        do_action( 'bp_activity_screen_favorites' );
     171
     172        /**
     173         * Filters the template to load for the "Favorites" screen.
     174         *
     175         * @since BuddyPress (1.2.0)
     176         *
     177         * @param string $template Path to the activity template to load.
     178         */
    111179        bp_core_load_template( apply_filters( 'bp_activity_template_favorite_activity', 'members/single/home' ) );
    112180}
    113181
     
    114182/**
    115183 * Load the 'Mentions' activity page.
    116184 *
    117  * @since BuddyPress (1.2)
     185 * @since BuddyPress (1.2.0)
    118186 *
    119187 * @uses bp_update_is_item_admin()
    120188 * @uses bp_current_user_can()
     
    124192 */
    125193function bp_activity_screen_mentions() {
    126194        bp_update_is_item_admin( bp_current_user_can( 'bp_moderate' ), 'activity' );
     195
     196        /**
     197         * Fires right before the loading of the "Mentions" screen template file.
     198         *
     199         * @since BuddyPress (1.2.0)
     200         */
    127201        do_action( 'bp_activity_screen_mentions' );
     202
     203        /**
     204         * Filters the template to load for the "Mentions" screen.
     205         *
     206         * @since BuddyPress (1.2.0)
     207         *
     208         * @param string $template Path to the activity template to load.
     209         */
    128210        bp_core_load_template( apply_filters( 'bp_activity_template_mention_activity', 'members/single/home' ) );
    129211}
    130212
     
    131213/**
    132214 * Reset the logged-in user's new mentions data when he visits his mentions screen.
    133215 *
    134  * @since BuddyPress (1.5)
     216 * @since BuddyPress (1.5.0)
    135217 *
    136218 * @uses bp_is_my_profile()
    137219 * @uses bp_activity_clear_new_mentions()
     
    146228/**
    147229 * Load the page for a single activity item.
    148230 *
    149  * @since BuddyPress (1.2)
     231 * @since BuddyPress (1.2.0)
    150232 *
    151233 * @global object $bp BuddyPress global settings
    152234 * @uses bp_is_activity_component()
     
    218300                }
    219301        }
    220302
    221         // Allow access to be filtered
     303        /**
     304         * Filters the access permission for a single activity view.
     305         *
     306         * @since BuddyPress (1.2.0)
     307         *
     308         * @param array $access Array holding the current $has_access value and current activity item instance.
     309         */
    222310        $has_access = apply_filters_ref_array( 'bp_activity_permalink_access', array( $has_access, &$activity ) );
    223311
    224         // Allow additional code execution
     312        /**
     313         * Fires before the loading of a single activity template file.
     314         *
     315         * @since BuddyPress (1.2.0)
     316         *
     317         * @param BP_Activity_Activity $activity Object representing the current activity item being displayed.
     318         * @param bool $has_access Whether or not the current user has access to view activity.
     319         */
    225320        do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access );
    226321
    227322        // Access is specifically disallowed
     
    244339                bp_core_redirect( $url );
    245340        }
    246341
     342        /**
     343         * Filters the template to load for a single activity screen.
     344         *
     345         * @since BuddyPress (1.0.0)
     346         *
     347         * @param string $template Path to the activity template to load.
     348         */
    247349        bp_core_load_template( apply_filters( 'bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink' ) );
    248350}
    249351add_action( 'bp_screens', 'bp_activity_screen_single_activity_permalink' );
     
    251353/**
    252354 * Add activity notifications settings to the notifications settings page.
    253355 *
    254  * @since BuddyPress (1.2)
     356 * @since BuddyPress (1.2.0)
    255357 *
    256358 * @uses bp_get_user_meta()
    257359 * @uses bp_core_get_username()
     
    298400                                <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php checked( $reply, 'no', true ) ?>/></td>
    299401                        </tr>
    300402
    301                         <?php do_action( 'bp_activity_screen_notification_settings' ) ?>
     403                        <?php
     404
     405                        /**
     406                         * Fires inside the closing </tbody> tag for activity screen notification settings.
     407                         *
     408                         * @since BuddyPress (1.2.0)
     409                         */
     410                        do_action( 'bp_activity_screen_notification_settings' ) ?>
    302411                </tbody>
    303412        </table>
    304413
     
    314423 * This class sets up the necessary theme compatability actions to safely output
    315424 * activity template parts to the_title and the_content areas of a theme.
    316425 *
    317  * @since BuddyPress (1.7)
     426 * @since BuddyPress (1.7.0)
    318427 */
    319428class BP_Activity_Theme_Compat {
    320429
     
    321430        /**
    322431         * Set up the activity component theme compatibility.
    323432         *
    324          * @since BuddyPress (1.7)
     433         * @since BuddyPress (1.7.0)
    325434         */
    326435        public function __construct() {
    327436                add_action( 'bp_setup_theme_compat', array( $this, 'is_activity' ) );
     
    330439        /**
    331440         * Set up the theme compatibility hooks, if we're looking at an activity page.
    332441         *
    333          * @since BuddyPress (1.7)
     442         * @since BuddyPress (1.7.0)
    334443         */
    335444        public function is_activity() {
    336445
     
    342451                if ( ! bp_displayed_user_id() && ! bp_current_action() ) {
    343452                        bp_update_is_directory( true, 'activity' );
    344453
     454                        /** This action is documented in bp-activity/bp-activity-screens.php */
    345455                        do_action( 'bp_activity_screen_index' );
    346456
    347457                        add_filter( 'bp_get_buddypress_template',                array( $this, 'directory_template_hierarchy' ) );
     
    363473         *
    364474         * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
    365475         *
    366          * @since BuddyPress (1.8)
     476         * @since BuddyPress (1.8.0)
    367477         *
    368478         * @param string $templates The templates from bp_get_theme_compat_templates().
    369479         * @return array $templates Array of custom templates to look for.
    370480         */
    371481        public function directory_template_hierarchy( $templates ) {
    372                 // Setup our templates based on priority
     482
     483                /**
     484                 * Filters the template hierarchy for the activity directory page.
     485                 *
     486                 * @since BuddyPress (1.8.0)
     487                 *
     488                 * @param array $index-directory Array holding template names to be merged into template list.
     489                 */
    373490                $new_templates = apply_filters( 'bp_template_hierarchy_activity_directory', array(
    374491                        'activity/index-directory.php'
    375492                ) );
     
    384501        /**
    385502         * Update the global $post with directory data.
    386503         *
    387          * @since BuddyPress (1.7)
     504         * @since BuddyPress (1.7.0)
    388505         */
    389506        public function directory_dummy_post() {
    390507                bp_theme_compat_reset_post( array(
     
    403520        /**
    404521         * Filter the_content with the groups index template part.
    405522         *
    406          * @since BuddyPress (1.7)
     523         * @since BuddyPress (1.7.0)
    407524         */
    408525        public function directory_content() {
    409526                return bp_buffer_template_part( 'activity/index', null, false );
     
    416533         *
    417534         * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
    418535         *
    419          * @since BuddyPress (1.8)
     536         * @since BuddyPress (1.8.0)
    420537         *
    421538         * @param string $templates The templates from bp_get_theme_compat_templates().
    422539         * @return array $templates Array of custom templates to look for.
    423540         */
    424541        public function single_template_hierarchy( $templates ) {
    425                 // Setup our templates based on priority
     542
     543                /**
     544                 * Filters the template hierarchy for the activity permalink pages.
     545                 *
     546                 * @since BuddyPress (1.8.0)
     547                 *
     548                 * @param array $index Array holding template names to be merged into template list.
     549                 */
    426550                $new_templates = apply_filters( 'bp_template_hierarchy_activity_single_item', array(
    427551                        'activity/single/index.php'
    428552                ) );
     
    437561        /**
    438562         * Update the global $post with the displayed user's data.
    439563         *
    440          * @since BuddyPress (1.7)
     564         * @since BuddyPress (1.7.0)
    441565         */
    442566        public function single_dummy_post() {
    443567                bp_theme_compat_reset_post( array(
     
    456580        /**
    457581         * Filter the_content with the members' activity permalink template part.
    458582         *
    459          * @since BuddyPress (1.7)
     583         * @since BuddyPress (1.7.0)
    460584         */
    461585        public function single_dummy_content() {
    462586                return bp_buffer_template_part( 'activity/single/home', null, false );