bp_activity_admin_index

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

Description

bp_activity_admin_index(); 

Usage

  1. if ( !function_exists( 'bp_activity_admin_index' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-admin.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_activity_admin_index(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/bp-activity/bp-activity-admin.php  
  1. function bp_activity_admin_index() { 
  2. global $bp_activity_list_table, $plugin_page; 
  3.  
  4. $messages = array(); 
  5.  
  6. // If the user has just made a change to an activity item, build status messages. 
  7. if ( ! empty( $_REQUEST['deleted'] ) || ! empty( $_REQUEST['spammed'] ) || ! empty( $_REQUEST['unspammed'] ) || ! empty( $_REQUEST[error] ) || ! empty( $_REQUEST['updated'] ) ) { 
  8. $deleted = ! empty( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0; 
  9. $errors = ! empty( $_REQUEST[error] ) ? $_REQUEST[error] : ''; 
  10. $spammed = ! empty( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed'] : 0; 
  11. $unspammed = ! empty( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0; 
  12. $updated = ! empty( $_REQUEST['updated'] ) ? (int) $_REQUEST['updated'] : 0; 
  13.  
  14. $errors = array_map( 'absint', explode( ', ', $errors ) ); 
  15.  
  16. // Make sure we don't get any empty values in $errors. 
  17. for ( $i = 0, $errors_count = count( $errors ); $i < $errors_count; $i++ ) { 
  18. if ( 0 === $errors[$i] ) { 
  19. unset( $errors[$i] ); 
  20.  
  21. // Reindex array. 
  22. $errors = array_values( $errors ); 
  23.  
  24. if ( $deleted > 0 ) 
  25. $messages[] = sprintf( _n( '%s activity item has been permanently deleted.', '%s activity items have been permanently deleted.', $deleted, buddypress ), number_format_i18n( $deleted ) ); 
  26.  
  27. if ( ! empty( $errors ) ) { 
  28. if ( 1 == count( $errors ) ) { 
  29. $messages[] = sprintf( __( 'Anerroroccurred when trying to update activity ID #%s.', buddypress ), number_format_i18n( $errors[0] ) ); 
  30.  
  31. } else { 
  32. $error_msg = __( 'Errors occurred when trying to update these activity items:', buddypress ); 
  33. $error_msg .= '<ul class="activity-errors">'; 
  34.  
  35. // Display eacherroras a list item. 
  36. foreach ( $errors as $error ) { 
  37. // Translators: This is a bulleted list of item IDs. 
  38. $error_msg .= '<li>' . sprintf( __( '#%s', buddypress ), number_format_i18n( $error ) ) . '</li>'; 
  39.  
  40. $error_msg .= '</ul>'; 
  41. $messages[] = $error_msg; 
  42.  
  43. if ( $spammed > 0 ) 
  44. $messages[] = sprintf( _n( '%s activity item has been successfully spammed.', '%s activity items have been successfully spammed.', $spammed, buddypress ), number_format_i18n( $spammed ) ); 
  45.  
  46. if ( $unspammed > 0 ) 
  47. $messages[] = sprintf( _n( '%s activity item has been successfully unspammed.', '%s activity items have been successfully unspammed.', $unspammed, buddypress ), number_format_i18n( $unspammed ) ); 
  48.  
  49. if ( $updated > 0 ) 
  50. $messages[] = __( 'The activity item has been updated successfully.', buddypress ); 
  51.  
  52. // Prepare the activity items for display. 
  53. $bp_activity_list_table->prepare_items(); 
  54.  
  55. /** 
  56. * Fires before edit form is displayed so plugins can modify the activity messages. 
  57. * @since 1.6.0 
  58. * @param array $messages Array of messages to display at top of page. 
  59. */ 
  60.  
  61. <div class="wrap"> 
  62. <h1> 
  63. <?php if ( !empty( $_REQUEST['aid'] ) ) : ?> 
  64. <?php printf( __( 'Activity related to ID #%s', buddypress ), number_format_i18n( (int) $_REQUEST['aid'] ) ); ?> 
  65. <?php else : ?> 
  66. <?php _ex( 'Activity', 'Admin SWA page', buddypress ); ?> 
  67. <?php endif; ?> 
  68.  
  69. <?php if ( !empty( $_REQUEST['s'] ) ) : ?> 
  70. <span class="subtitle"><?php printf( __( 'Search results for “%s”', buddypress ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) ); ?></span> 
  71. <?php endif; ?> 
  72. </h1> 
  73.  
  74. <?php // If the user has just made a change to an activity item, display the status messages. ?> 
  75. <?php if ( !empty( $messages ) ) : ?> 
  76. <div id="moderated" class="<?php echo ( ! empty( $_REQUEST[error] ) ) ? error : 'updated'; ?>"><p><?php echo implode( "<br/>\n", $messages ); ?></p></div> 
  77. <?php endif; ?> 
  78.  
  79. <?php // Display each activity on its own row. ?> 
  80. <?php $bp_activity_list_table->views(); ?> 
  81.  
  82. <form id="bp-activities-form" action="" method="get"> 
  83. <?php $bp_activity_list_table->search_box( __( 'Search all Activity', buddypress ), 'bp-activity' ); ?> 
  84. <input type="hidden" name="page" value="<?php echo esc_attr( $plugin_page ); ?>" /> 
  85. <?php $bp_activity_list_table->display(); ?> 
  86. </form> 
  87.  
  88. <?php // This markup is used for the reply form. ?> 
  89. <table style="display: none;"> 
  90. <tr id="bp-activities-container" style="display: none;"> 
  91. <td colspan="4"> 
  92. <form method="get" action=""> 
  93.  
  94. <h3 id="bp-replyhead"><?php _e( 'Reply to Activity', buddypress ); ?></h3> 
  95. <label for="bp-activities" class="screen-reader-text"><?php 
  96. /** translators: accessibility text */ 
  97. _e( 'Reply', buddypress ); 
  98. ?></label> 
  99. <?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, ) ); ?> 
  100.  
  101. <p id="bp-replysubmit" class="submit"> 
  102. <a href="#" class="cancel button-secondary alignleft"><?php _e( 'Cancel', buddypress ); ?></a> 
  103. <a href="#" class="save button-primary alignright"><?php _e( 'Reply', buddypress ); ?></a> 
  104.  
  105. <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> 
  106. <span class="error" style="display:none;"></span> 
  107. <br class="clear" /> 
  108. </p> 
  109.  
  110. <?php wp_nonce_field( 'bp-activity-admin-reply', '_ajax_nonce-bp-activity-admin-reply', false ); ?> 
  111.  
  112. </form> 
  113. </td> 
  114. </tr> 
  115. </table> 
  116. </div> 
  117.  
  118. <?php