bp_activity_admin_index()

Display the Activity admin index screen, which contains a list of all the activities.

Description

Source

File: bp-activity/bp-activity-admin.php

1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
function bp_activity_admin_index() {
    global $bp_activity_list_table, $plugin_page;
 
    $messages = array();
 
    // If the user has just made a change to an activity item, build status messages.
    if ( ! empty( $_REQUEST['deleted'] ) || ! empty( $_REQUEST['spammed'] ) || ! empty( $_REQUEST['unspammed'] ) || ! empty( $_REQUEST['error'] ) || ! empty( $_REQUEST['updated'] ) ) {
        $deleted   = ! empty( $_REQUEST['deleted']   ) ? (int) $_REQUEST['deleted']   : 0;
        $errors    = ! empty( $_REQUEST['error']     ) ? $_REQUEST['error']           : '';
        $spammed   = ! empty( $_REQUEST['spammed']   ) ? (int) $_REQUEST['spammed']   : 0;
        $unspammed = ! empty( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0;
        $updated   = ! empty( $_REQUEST['updated']   ) ? (int) $_REQUEST['updated']   : 0;
 
        $errors = array_map( 'absint', explode( ',', $errors ) );
 
        // Make sure we don't get any empty values in $errors.
        for ( $i = 0, $errors_count = count( $errors ); $i < $errors_count; $i++ ) {
            if ( 0 === $errors[$i] ) {
                unset( $errors[$i] );
            }
        }
 
        // Reindex array.
        $errors = array_values( $errors );
 
        if ( $deleted > 0 )
            $messages[] = sprintf( _n( '%s activity item has been permanently deleted.', '%s activity items have been permanently deleted.', $deleted, 'buddyboss' ), number_format_i18n( $deleted ) );
 
        if ( ! empty( $errors ) ) {
            if ( 1 == count( $errors ) ) {
                $messages[] = sprintf( __( 'An error occurred when trying to update activity ID #%s.', 'buddyboss' ), number_format_i18n( $errors[0] ) );
 
            } else {
                $error_msg  = __( 'Errors occurred when trying to update these activity items:', 'buddyboss' );
                $error_msg .= '<ul class="activity-errors">';
 
                // Display each error as a list item.
                foreach ( $errors as $error ) {
                    // Translators: This is a bulleted list of item IDs.
                    $error_msg .= '<li>' . sprintf( __( '#%s', 'buddyboss' ), number_format_i18n( $error ) ) . '</li>';
                }
 
                $error_msg  .= '</ul>';
                $messages[] = $error_msg;
            }
        }
 
        if ( $spammed > 0 )
            $messages[] = sprintf( _n( '%s activity item has been successfully spammed.', '%s activity items have been successfully spammed.', $spammed, 'buddyboss' ), number_format_i18n( $spammed ) );
 
        if ( $unspammed > 0 )
            $messages[] = sprintf( _n( '%s activity item has been successfully unspammed.', '%s activity items have been successfully unspammed.', $unspammed, 'buddyboss' ), number_format_i18n( $unspammed ) );
 
        if ( $updated > 0 )
            $messages[] = __( 'The activity item has been updated successfully.', 'buddyboss' );
    }
 
    // Prepare the activity items for display.
    $bp_activity_list_table->prepare_items();
 
    /**
     * Fires before edit form is displayed so plugins can modify the activity messages.
     *
     * @since BuddyPress 1.6.0
     *
     * @param array $messages Array of messages to display at top of page.
     */
    do_action( 'bp_activity_admin_index', $messages ); ?>
 
    <div class="wrap">
        <h1>
            <?php if ( !empty( $_REQUEST['aid'] ) ) : ?>
                <?php printf( __( 'Activity related to ID #%s', 'buddyboss' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?>
            <?php else : ?>
                <?php _e( 'Activity', 'buddyboss' ); ?>
            <?php endif; ?>
 
            <?php if ( !empty( $_REQUEST['s'] ) ) : ?>
                <span class="subtitle"><?php printf( __( 'Search results for "%s"', 'buddyboss' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) ); ?></span>
            <?php endif; ?>
        </h1>
 
        <?php // If the user has just made a change to an activity item, display the status messages. ?>
        <?php if ( !empty( $messages ) ) : ?>
            <div id="moderated" class="<?php echo ( ! empty( $_REQUEST['error'] ) ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "<br/>\n", $messages ); ?></p></div>
        <?php endif; ?>
 
        <?php // Display each activity on its own row. ?>
        <?php $bp_activity_list_table->views(); ?>
 
        <form id="bp-activities-form" action="" method="get">
            <?php $bp_activity_list_table->search_box( __( 'Search all Activity', 'buddyboss' ), 'bp-activity' ); ?>
            <input type="hidden" name="page" value="<?php echo esc_attr( $plugin_page ); ?>" />
            <?php $bp_activity_list_table->display(); ?>
        </form>
 
        <?php // This markup is used for the reply form. ?>
        <table style="display: none;">
            <tr id="bp-activities-container" style="display: none;">
                <td colspan="4">
                    <form method="get" action="">
 
                        <h3 id="bp-replyhead"><?php _e( 'Reply to Activity', 'buddyboss' ); ?></h3>
                        <label for="bp-activities" class="screen-reader-text"><?php
                            /* translators: accessibility text */
                            _e( 'Reply', 'buddyboss' );
                        ?></label>
                        <?php wp_editor( '', 'bp-activities', array( 'dfw' => false, 'media_buttons' => false, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ), 'tinymce' => false, ) ); ?>
 
                        <p id="bp-replysubmit" class="submit">
                            <a href="#" class="cancel button-secondary alignleft"><?php _e( 'Cancel', 'buddyboss' ); ?></a>
                            <a href="#" class="save button-primary alignright"><?php _e( 'Reply', 'buddyboss' ); ?></a>
 
                            <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
                            <span class="error" style="display:none;"></span>
                            <br class="clear" />
                        </p>
 
                        <?php wp_nonce_field( 'bp-activity-admin-reply', '_ajax_nonce-bp-activity-admin-reply', false ); ?>
 
                    </form>
                </td>
            </tr>
        </table>
    </div>
 
<?php
}

Changelog

Changelog
Version Description
BuddyPress 1.6.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.