[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BuddyPress Activity component admin screen. 4 * 5 * Props to WordPress core for the Comments admin screen, and its contextual 6 * help text, on which this implementation is heavily based. 7 * 8 * @package BuddyPress 9 * @subpackage ActivityAdmin 10 * @since 1.6.0 11 */ 12 13 // Exit if accessed directly. 14 defined( 'ABSPATH' ) || exit; 15 16 // Include WP's list table class. 17 if ( !class_exists( 'WP_List_Table' ) ) require( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); 18 19 // Per_page screen option. Has to be hooked in extremely early. 20 if ( is_admin() && ! empty( $_REQUEST['page'] ) && 'bp-activity' == $_REQUEST['page'] ) 21 add_filter( 'set-screen-option', 'bp_activity_admin_screen_options', 10, 3 ); 22 23 /** 24 * Register the Activity component admin screen. 25 * 26 * @since 1.6.0 27 */ 28 function bp_activity_add_admin_menu() { 29 30 // Add our screen. 31 $hook = add_menu_page( 32 _x( 'Activity', 'Admin Dashboard SWA page title', 'buddypress' ), 33 _x( 'Activity', 'Admin Dashboard SWA menu', 'buddypress' ), 34 'bp_moderate', 35 'bp-activity', 36 'bp_activity_admin', 37 'div' 38 ); 39 40 // Hook into early actions to load custom CSS and our init handler. 41 add_action( "load-$hook", 'bp_activity_admin_load' ); 42 } 43 add_action( bp_core_admin_hook(), 'bp_activity_add_admin_menu' ); 44 45 /** 46 * Add activity component to custom menus array. 47 * 48 * Several BuddyPress components have top-level menu items in the Dashboard, 49 * which all appear together in the middle of the Dashboard menu. This function 50 * adds the Activity page to the array of these menu items. 51 * 52 * @since 1.7.0 53 * 54 * @param array $custom_menus The list of top-level BP menu items. 55 * @return array $custom_menus List of top-level BP menu items, with Activity added. 56 */ 57 function bp_activity_admin_menu_order( $custom_menus = array() ) { 58 array_push( $custom_menus, 'bp-activity' ); 59 return $custom_menus; 60 } 61 add_filter( 'bp_admin_menu_order', 'bp_activity_admin_menu_order' ); 62 63 /** 64 * AJAX receiver for Activity replies via the admin screen. 65 * 66 * Processes requests to add new activity comments, and echoes HTML for a new 67 * table row. 68 * 69 * @since 1.6.0 70 */ 71 function bp_activity_admin_reply() { 72 // Check nonce. 73 check_ajax_referer( 'bp-activity-admin-reply', '_ajax_nonce-bp-activity-admin-reply' ); 74 75 $parent_id = ! empty( $_REQUEST['parent_id'] ) ? (int) $_REQUEST['parent_id'] : 0; 76 $root_id = ! empty( $_REQUEST['root_id'] ) ? (int) $_REQUEST['root_id'] : 0; 77 78 // $parent_id is required. 79 if ( empty( $parent_id ) ) 80 die( '-1' ); 81 82 // If $root_id not set (e.g. for root items), use $parent_id. 83 if ( empty( $root_id ) ) 84 $root_id = $parent_id; 85 86 // Check that a reply has been entered. 87 if ( empty( $_REQUEST['content'] ) ) 88 die( __( 'Error: Please type a reply.', 'buddypress' ) ); 89 90 // Check parent activity exists. 91 $parent_activity = new BP_Activity_Activity( $parent_id ); 92 if ( empty( $parent_activity->component ) ) 93 die( __( 'Error: The item you are trying to reply to cannot be found, or it has been deleted.', 'buddypress' ) ); 94 95 // @todo: Check if user is allowed to create new activity items 96 // if ( ! current_user_can( 'bp_new_activity' ) ) 97 if ( ! bp_current_user_can( 'bp_moderate' ) ) 98 die( '-1' ); 99 100 // Add new activity comment. 101 $new_activity_id = bp_activity_new_comment( array( 102 'activity_id' => $root_id, // ID of the root activity item. 103 'content' => $_REQUEST['content'], 104 'parent_id' => $parent_id, // ID of a parent comment. 105 ) ); 106 107 // Fetch the new activity item, as we need it to create table markup to return. 108 $new_activity = new BP_Activity_Activity( $new_activity_id ); 109 110 // This needs to be set for the BP_Activity_List_Table constructor to work. 111 set_current_screen( 'toplevel_page_bp-activity' ); 112 113 // Set up an output buffer. 114 ob_start(); 115 $list_table = new BP_Activity_List_Table(); 116 $list_table->single_row( (array) $new_activity ); 117 118 // Get table markup. 119 $response = array( 120 'data' => ob_get_contents(), 121 'id' => $new_activity_id, 122 'position' => -1, 123 'what' => 'bp_activity', 124 ); 125 ob_end_clean(); 126 127 // Send response. 128 $r = new WP_Ajax_Response(); 129 $r->add( $response ); 130 $r->send(); 131 132 exit(); 133 } 134 add_action( 'wp_ajax_bp-activity-admin-reply', 'bp_activity_admin_reply' ); 135 136 /** 137 * Handle save/update of screen options for the Activity component admin screen. 138 * 139 * @since 1.6.0 140 * 141 * @param string $value Will always be false unless another plugin filters it first. 142 * @param string $option Screen option name. 143 * @param string $new_value Screen option form value. 144 * @return string|int Option value. False to abandon update. 145 */ 146 function bp_activity_admin_screen_options( $value, $option, $new_value ) { 147 if ( 'toplevel_page_bp_activity_per_page' != $option && 'toplevel_page_bp_activity_network_per_page' != $option ) 148 return $value; 149 150 // Per page. 151 $new_value = (int) $new_value; 152 if ( $new_value < 1 || $new_value > 999 ) 153 return $value; 154 155 return $new_value; 156 } 157 158 /** 159 * Hide the advanced edit meta boxes by default, so we don't clutter the screen. 160 * 161 * @since 1.6.0 162 * 163 * @param array $hidden Array of items to hide. 164 * @param WP_Screen $screen Screen identifier. 165 * @return array Hidden Meta Boxes. 166 */ 167 function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) { 168 if ( empty( $screen->id ) || 'toplevel_page_bp-activity' !== $screen->id && 'toplevel_page_bp-activity-network' !== $screen->id ) { 169 return $hidden; 170 } 171 172 // Hide the primary link meta box by default. 173 $hidden = array_merge( (array) $hidden, array( 'bp_activity_itemids', 'bp_activity_link', 'bp_activity_type', 'bp_activity_userid', ) ); 174 175 /** 176 * Filters default hidden metaboxes so plugins can alter list. 177 * 178 * @since 1.6.0 179 * 180 * @param array $hidden Default metaboxes to hide. 181 * @param WP_Screen $screen Screen identifier. 182 */ 183 return apply_filters( 'bp_hide_meta_boxes', array_unique( $hidden ), $screen ); 184 } 185 add_filter( 'default_hidden_meta_boxes', 'bp_activity_admin_edit_hidden_metaboxes', 10, 2 ); 186 187 /** 188 * Set up the Activity admin page. 189 * 190 * Does the following: 191 * - Register contextual help and screen options for this admin page. 192 * - Enqueues scripts and styles. 193 * - Catches POST and GET requests related to Activity. 194 * 195 * @since 1.6.0 196 * 197 * @global object $bp BuddyPress global settings. 198 * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table. 199 */ 200 function bp_activity_admin_load() { 201 global $bp_activity_list_table; 202 203 $bp = buddypress(); 204 $doaction = bp_admin_list_table_current_bulk_action(); 205 $min = bp_core_get_minified_asset_suffix(); 206 207 /** 208 * Fires at top of Activity admin page. 209 * 210 * @since 1.6.0 211 * 212 * @param string $doaction Current $_GET action being performed in admin screen. 213 */ 214 do_action( 'bp_activity_admin_load', $doaction ); 215 216 // Edit screen. 217 if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) ) { 218 // Columns screen option. 219 add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) ); 220 221 get_current_screen()->add_help_tab( array( 222 'id' => 'bp-activity-edit-overview', 223 'title' => __( 'Overview', 'buddypress' ), 224 'content' => 225 '<p>' . __( 'You edit activities made on your site similar to the way you edit a comment. This is useful if you need to change which page the activity links to, or when you notice that the author has made a typographical error.', 'buddypress' ) . '</p>' . 226 '<p>' . __( 'The two big editing areas for the activity title and content are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Primary Item/Secondary Item, Link, Type, Author ID) or to choose a 1- or 2-column layout for this screen.', 'buddypress' ) . '</p>' . 227 '<p>' . __( 'You can also moderate the activity from this screen using the Status box, where you can also change the timestamp of the activity.', 'buddypress' ) . '</p>' 228 ) ); 229 230 get_current_screen()->add_help_tab( array( 231 'id' => 'bp-activity-edit-advanced', 232 'title' => __( 'Item, Link, Type', 'buddypress' ), 233 'content' => 234 '<p>' . __( '<strong>Primary Item/Secondary Item</strong> - These identify the object that created the activity. For example, the fields could reference a comment left on a specific site. Some types of activity may only use one, or none, of these fields.', 'buddypress' ) . '</p>' . 235 '<p>' . __( '<strong>Link</strong> - Used by some types of activity (blog posts and comments) to store a link back to the original content.', 'buddypress' ) . '</p>' . 236 '<p>' . __( '<strong>Type</strong> - Each distinct kind of activity has its own type. For example, <code>created_group</code> is used when a group is created and <code>joined_group</code> is used when a user joins a group.', 'buddypress' ) . '</p>' . 237 '<p>' . __( 'For information about when and how BuddyPress uses all of these settings, see the Managing Activity link in the panel to the side.', 'buddypress' ) . '</p>' 238 ) ); 239 240 // Help panel - sidebar links. 241 get_current_screen()->set_help_sidebar( 242 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . 243 '<p>' . __( '<a href="https://codex.buddypress.org/administrator-guide/activity-stream-management-panels/">Managing Activity</a>', 'buddypress' ) . '</p>' . 244 '<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>' 245 ); 246 247 // Register metaboxes for the edit screen. 248 add_meta_box( 'submitdiv', _x( 'Status', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_status', get_current_screen()->id, 'side', 'core' ); 249 add_meta_box( 'bp_activity_itemids', _x( 'Primary Item/Secondary Item', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_itemids', get_current_screen()->id, 'normal', 'core' ); 250 add_meta_box( 'bp_activity_link', _x( 'Link', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_link', get_current_screen()->id, 'normal', 'core' ); 251 add_meta_box( 'bp_activity_type', _x( 'Type', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_type', get_current_screen()->id, 'normal', 'core' ); 252 add_meta_box( 'bp_activity_userid', _x( 'Author ID', 'activity admin edit screen', 'buddypress' ), 'bp_activity_admin_edit_metabox_userid', get_current_screen()->id, 'normal', 'core' ); 253 254 /** 255 * Fires after the registration of all of the default activity meta boxes. 256 * 257 * @since 2.4.0 258 */ 259 do_action( 'bp_activity_admin_meta_boxes' ); 260 261 // Enqueue JavaScript files. 262 wp_enqueue_script( 'postbox' ); 263 wp_enqueue_script( 'dashboard' ); 264 wp_enqueue_script( 'comment' ); 265 266 // Index screen. 267 } else { 268 // Create the Activity screen list table. 269 $bp_activity_list_table = new BP_Activity_List_Table(); 270 271 // The per_page screen option. 272 add_screen_option( 'per_page', array( 'label' => _x( 'Activity', 'Activity items per page (screen options)', 'buddypress' )) ); 273 274 // Help panel - overview text. 275 get_current_screen()->add_help_tab( array( 276 'id' => 'bp-activity-overview', 277 'title' => __( 'Overview', 'buddypress' ), 278 'content' => 279 '<p>' . __( 'You can manage activities made on your site similar to the way you manage comments and other content. This screen is customizable in the same ways as other management screens, and you can act on activities using the on-hover action links or the Bulk Actions.', 'buddypress' ) . '</p>' . 280 '<p>' . __( 'There are many different types of activities. Some are generated automatically by BuddyPress and other plugins, and some are entered directly by a user in the form of status update. To help manage the different activity types, use the filter dropdown box to switch between them.', 'buddypress' ) . '</p>' 281 ) ); 282 283 // Help panel - moderation text. 284 get_current_screen()->add_help_tab( array( 285 'id' => 'bp-activity-moderating', 286 'title' => __( 'Moderating Activity', 'buddypress' ), 287 'content' => 288 '<p>' . __( 'In the <strong>Activity</strong> column, above each activity it says “Submitted on,” followed by the date and time the activity item was generated on your site. Clicking on the date/time link will take you to that activity on your live site. Hovering over any activity gives you options to reply, edit, spam mark, or delete that activity.', 'buddypress' ) . '</p>' . 289 '<p>' . __( "In the <strong>In Response To</strong> column, if the activity was in reply to another activity, it shows that activity's author's picture and name, and a link to that activity on your live site. If there is a small bubble, the number in it shows how many other activities are related to this one; these are usually comments. Clicking the bubble will filter the activity screen to show only related activity items.", 'buddypress' ) . '</p>' 290 ) ); 291 292 // Help panel - sidebar links. 293 get_current_screen()->set_help_sidebar( 294 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . 295 '<p>' . __( '<a href="https://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>' 296 ); 297 298 // Add accessible hidden heading and text for Activity screen pagination. 299 get_current_screen()->set_screen_reader_content( array( 300 /* translators: accessibility text */ 301 'heading_pagination' => __( 'Activity list navigation', 'buddypress' ), 302 ) ); 303 304 } 305 306 // Enqueue CSS and JavaScript. 307 wp_enqueue_script( 'bp_activity_admin_js', $bp->plugin_url . "bp-activity/admin/js/admin{$min}.js", array( 'jquery', 'wp-ajax-response' ), bp_get_version(), true ); 308 wp_localize_script( 'bp_activity_admin_js', 'bp_activity_admin_vars', array( 309 'page' => get_current_screen()->id 310 ) ); 311 wp_enqueue_style( 'bp_activity_admin_css', $bp->plugin_url . "bp-activity/admin/css/admin{$min}.css", array(), bp_get_version() ); 312 313 wp_style_add_data( 'bp_activity_admin_css', 'rtl', 'replace' ); 314 if ( $min ) { 315 wp_style_add_data( 'bp_activity_admin_css', 'suffix', $min ); 316 } 317 318 /** 319 * Fires after the activity js and style has been enqueued. 320 * 321 * @since 2.4.0 322 */ 323 do_action( 'bp_activity_admin_enqueue_scripts' ); 324 325 // Handle spam/un-spam/delete of activities. 326 if ( ! empty( $doaction ) && ! in_array( $doaction, array( '-1', 'edit', 'save', 'delete', 'bulk_delete' ) ) ) { 327 328 // Build redirection URL. 329 $redirect_to = remove_query_arg( array( 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), wp_get_referer() ); 330 $redirect_to = add_query_arg( 'paged', $bp_activity_list_table->get_pagenum(), $redirect_to ); 331 332 // Get activity IDs. 333 $activity_ids = wp_parse_id_list( $_REQUEST['aid'] ); 334 335 /** 336 * Filters list of IDs being spammed/un-spammed/deleted. 337 * 338 * @since 1.6.0 339 * 340 * @param array $activity_ids Activity IDs to spam/un-spam/delete. 341 */ 342 $activity_ids = apply_filters( 'bp_activity_admin_action_activity_ids', $activity_ids ); 343 344 // Is this a bulk request? 345 if ( 'bulk_' == substr( $doaction, 0, 5 ) && ! empty( $_REQUEST['aid'] ) ) { 346 // Check this is a valid form submission. 347 check_admin_referer( 'bulk-activities' ); 348 349 // Trim 'bulk_' off the action name to avoid duplicating a ton of code. 350 $doaction = substr( $doaction, 5 ); 351 352 // This is a request to delete single or multiple item. 353 } elseif ( 'do_delete' === $doaction && ! empty( $_REQUEST['aid'] ) ) { 354 check_admin_referer( 'bp-activities-delete' ); 355 356 // This is a request to spam, or un-spam, a single item. 357 } elseif ( !empty( $_REQUEST['aid'] ) ) { 358 359 // Check this is a valid form submission. 360 check_admin_referer( 'spam-activity_' . $activity_ids[0] ); 361 } 362 363 // Initialize counters for how many of each type of item we perform an action on. 364 $deleted = $spammed = $unspammed = 0; 365 366 // Store any errors that occurs when updating the database items. 367 $errors = array(); 368 369 // "We'd like to shoot the monster, could you move, please?" 370 foreach ( $activity_ids as $activity_id ) { 371 // @todo: Check the permissions on each 372 // if ( ! current_user_can( 'bp_edit_activity', $activity_id ) ) 373 // continue; 374 // Get the activity from the database. 375 $activity = new BP_Activity_Activity( $activity_id ); 376 if ( empty( $activity->component ) ) { 377 $errors[] = $activity_id; 378 continue; 379 } 380 381 switch ( $doaction ) { 382 case 'do_delete' : 383 if ( 'activity_comment' === $activity->type ) { 384 $delete_result = bp_activity_delete_comment( $activity->item_id, $activity->id ); 385 } else { 386 $delete_result = bp_activity_delete( array( 'id' => $activity->id ) ); 387 } 388 389 if ( ! $delete_result ) { 390 $errors[] = $activity->id; 391 } else { 392 $deleted++; 393 } 394 break; 395 396 case 'ham' : 397 /** 398 * Remove moderation and disallowed keyword checks in case we want to ham an activity 399 * which contains one of these listed keys. 400 */ 401 remove_action( 'bp_activity_before_save', 'bp_activity_check_moderation_keys', 2 ); 402 remove_action( 'bp_activity_before_save', 'bp_activity_check_disallowed_keys', 2 ); 403 404 bp_activity_mark_as_ham( $activity ); 405 $result = $activity->save(); 406 407 // Check for any error during activity save. 408 if ( ! $result ) { 409 $errors[] = $activity->id; 410 } else { 411 $unspammed++; 412 } 413 break; 414 415 case 'spam' : 416 bp_activity_mark_as_spam( $activity ); 417 $result = $activity->save(); 418 419 // Check for any error during activity save. 420 if ( ! $result ) { 421 $errors[] = $activity->id; 422 } else { 423 $spammed++; 424 } 425 break; 426 427 default: 428 break; 429 } 430 431 // Release memory. 432 unset( $activity ); 433 } 434 435 /** 436 * Fires before redirect for plugins to do something with activity. 437 * 438 * Passes an activity array counts how many were spam, not spam, deleted, and IDs that were errors. 439 * 440 * @since 1.6.0 441 * 442 * @param array $value Array holding spam, not spam, deleted counts, error IDs. 443 * @param string $redirect_to URL to redirect to. 444 * @param array $activity_ids Original array of activity IDs. 445 */ 446 do_action( 'bp_activity_admin_action_after', array( $spammed, $unspammed, $deleted, $errors ), $redirect_to, $activity_ids ); 447 448 // Add arguments to the redirect URL so that on page reload, we can easily display what we've just done. 449 if ( $spammed ) { 450 $redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to ); 451 } 452 453 if ( $unspammed ) { 454 $redirect_to = add_query_arg( 'unspammed', $unspammed, $redirect_to ); 455 } 456 457 if ( $deleted ) { 458 $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to ); 459 } 460 461 // If an error occurred, pass back the activity ID that failed. 462 if ( ! empty( $errors ) ) { 463 $redirect_to = add_query_arg( 'error', implode ( ',', array_map( 'absint', $errors ) ), $redirect_to ); 464 } 465 466 /** 467 * Filters redirect URL after activity spamming/un-spamming/deletion occurs. 468 * 469 * @since 1.6.0 470 * 471 * @param string $redirect_to URL to redirect to. 472 */ 473 wp_redirect( apply_filters( 'bp_activity_admin_action_redirect', $redirect_to ) ); 474 exit; 475 476 477 // Save the edit. 478 } elseif ( $doaction && 'save' == $doaction ) { 479 // Build redirection URL. 480 $redirect_to = remove_query_arg( array( 'action', 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] ); 481 482 // Get activity ID. 483 $activity_id = (int) $_REQUEST['aid']; 484 485 // Check this is a valid form submission. 486 check_admin_referer( 'edit-activity_' . $activity_id ); 487 488 // Get the activity from the database. 489 $activity = new BP_Activity_Activity( $activity_id ); 490 491 // If the activity doesn't exist, just redirect back to the index. 492 if ( empty( $activity->component ) ) { 493 wp_redirect( $redirect_to ); 494 exit; 495 } 496 497 // Check the form for the updated properties. 498 // Store any error that occurs when updating the database item. 499 $error = 0; 500 501 // Activity spam status. 502 $prev_spam_status = $new_spam_status = false; 503 if ( ! empty( $_POST['activity_status'] ) ) { 504 $prev_spam_status = $activity->is_spam; 505 $new_spam_status = ( 'spam' == $_POST['activity_status'] ) ? true : false; 506 } 507 508 // Activity action. 509 if ( isset( $_POST['bp-activities-action'] ) ) 510 $activity->action = $_POST['bp-activities-action']; 511 512 // Activity content. 513 if ( isset( $_POST['bp-activities-content'] ) ) 514 $activity->content = $_POST['bp-activities-content']; 515 516 // Activity primary link. 517 if ( ! empty( $_POST['bp-activities-link'] ) ) 518 $activity->primary_link = $_POST['bp-activities-link']; 519 520 // Activity user ID. 521 if ( ! empty( $_POST['bp-activities-userid'] ) ) 522 $activity->user_id = (int) $_POST['bp-activities-userid']; 523 524 // Activity item primary ID. 525 if ( isset( $_POST['bp-activities-primaryid'] ) ) 526 $activity->item_id = (int) $_POST['bp-activities-primaryid']; 527 528 // Activity item secondary ID. 529 if ( isset( $_POST['bp-activities-secondaryid'] ) ) 530 $activity->secondary_item_id = (int) $_POST['bp-activities-secondaryid']; 531 532 // Activity type. 533 if ( ! empty( $_POST['bp-activities-type'] ) ) { 534 $actions = bp_activity_admin_get_activity_actions(); 535 536 // Check that the new type is a registered activity type. 537 if ( in_array( $_POST['bp-activities-type'], $actions ) ) { 538 $activity->type = $_POST['bp-activities-type']; 539 } 540 } 541 542 // Activity timestamp. 543 if ( ! empty( $_POST['aa'] ) && ! empty( $_POST['mm'] ) && ! empty( $_POST['jj'] ) && ! empty( $_POST['hh'] ) && ! empty( $_POST['mn'] ) && ! empty( $_POST['ss'] ) ) { 544 $aa = $_POST['aa']; 545 $mm = $_POST['mm']; 546 $jj = $_POST['jj']; 547 $hh = $_POST['hh']; 548 $mn = $_POST['mn']; 549 $ss = $_POST['ss']; 550 $aa = ( $aa <= 0 ) ? date( 'Y' ) : $aa; 551 $mm = ( $mm <= 0 ) ? date( 'n' ) : $mm; 552 $jj = ( $jj > 31 ) ? 31 : $jj; 553 $jj = ( $jj <= 0 ) ? date( 'j' ) : $jj; 554 $hh = ( $hh > 23 ) ? $hh -24 : $hh; 555 $mn = ( $mn > 59 ) ? $mn -60 : $mn; 556 $ss = ( $ss > 59 ) ? $ss -60 : $ss; 557 558 // Reconstruct the date into a timestamp. 559 $gmt_date = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); 560 561 $activity->date_recorded = $gmt_date; 562 } 563 564 // Has the spam status has changed? 565 if ( $new_spam_status != $prev_spam_status ) { 566 if ( $new_spam_status ) 567 bp_activity_mark_as_spam( $activity ); 568 else 569 bp_activity_mark_as_ham( $activity ); 570 } 571 572 // Save. 573 $result = $activity->save(); 574 575 // Clear the activity stream first page cache, in case this activity's timestamp was changed. 576 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' ); 577 578 // Check for any error during activity save. 579 if ( false === $result ) 580 $error = $activity->id; 581 582 /** 583 * Fires before redirect so plugins can do something first on save action. 584 * 585 * @since 1.6.0 586 * 587 * @param array $value Array holding activity object and ID that holds error. 588 */ 589 do_action_ref_array( 'bp_activity_admin_edit_after', array( &$activity, $error ) ); 590 591 // If an error occurred, pass back the activity ID that failed. 592 if ( $error ) 593 $redirect_to = add_query_arg( 'error', $error, $redirect_to ); 594 else 595 $redirect_to = add_query_arg( 'updated', $activity->id, $redirect_to ); 596 597 /** 598 * Filters URL to redirect to after saving. 599 * 600 * @since 1.6.0 601 * 602 * @param string $redirect_to URL to redirect to. 603 */ 604 wp_redirect( apply_filters( 'bp_activity_admin_edit_redirect', $redirect_to ) ); 605 exit; 606 607 608 // If a referrer and a nonce is supplied, but no action, redirect back. 609 } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { 610 wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) ); 611 exit; 612 } 613 } 614 615 /** 616 * Output the Activity component admin screens. 617 * 618 * @since 1.6.0 619 */ 620 function bp_activity_admin() { 621 // Decide whether to load the index or edit screen. 622 $doaction = bp_admin_list_table_current_bulk_action(); 623 624 // Display the single activity edit screen. 625 if ( 'edit' === $doaction && ! empty( $_GET['aid'] ) ) { 626 bp_activity_admin_edit(); 627 628 // Display the activty delete confirmation screen. 629 } elseif ( in_array( $doaction, array( 'bulk_delete', 'delete' ) ) && ! empty( $_GET['aid'] ) ) { 630 bp_activity_admin_delete(); 631 632 // Otherwise, display the Activity index screen. 633 } else { 634 bp_activity_admin_index(); 635 } 636 } 637 638 /** 639 * Display the Activity delete confirmation screen. 640 * 641 * @since 7.0.0 642 */ 643 function bp_activity_admin_delete() { 644 645 if ( ! bp_current_user_can( 'bp_moderate' ) ) { 646 die( '-1' ); 647 } 648 649 $activity_ids = isset( $_REQUEST['aid'] ) ? $_REQUEST['aid'] : 0; 650 651 if ( ! is_array( $activity_ids ) ) { 652 $activity_ids = explode( ',', $activity_ids ); 653 } 654 655 $activities = bp_activity_get( array( 656 'in' => $activity_ids, 657 'show_hidden' => true, 658 'spam' => 'all', 659 'display_comments' => 0, 660 'per_page' => null 661 ) ); 662 663 // Create a new list of activity ids, based on those that actually exist. 664 $aids = array(); 665 foreach ( $activities['activities'] as $activity ) { 666 $aids[] = $activity->id; 667 } 668 669 $base_url = remove_query_arg( array( 'action', 'action2', 'paged', 's', '_wpnonce', 'aid' ), $_SERVER['REQUEST_URI'] ); ?> 670 671 <div class="wrap"> 672 <h1 class="wp-heading-inline"><?php esc_html_e( 'Delete Activities', 'buddypress' ) ?></h1> 673 <hr class="wp-header-end"> 674 675 <p><?php esc_html_e( 'You are about to delete the following activities:', 'buddypress' ) ?></p> 676 677 <ul class="bp-activity-delete-list"> 678 <?php foreach ( $activities['activities'] as $activity ) : ?> 679 <li> 680 <?php 681 $actions = bp_activity_admin_get_activity_actions(); 682 683 if ( isset( $actions[ $activity->type ] ) ) { 684 $activity_type = $actions[ $activity->type ]; 685 } else { 686 /* translators: %s: the name of the activity type */ 687 $activity_type = sprintf( __( 'Unregistered action - %s', 'buddypress' ), $activity->type ); 688 } 689 690 printf( 691 /* translators: 1: activity type. 2: activity author. 3: activity date and time. */ 692 __( '"%1$s" activity submitted by %2$s on %3$s', 'buddypress' ), 693 esc_html( $activity_type ), 694 bp_core_get_userlink( $activity->user_id ), 695 sprintf( 696 '<a href="%1$s">%2$s</a>', 697 esc_url( bp_activity_get_permalink( $activity->id, $activity ) ), 698 date_i18n( bp_get_option( 'date_format' ), strtotime( $activity->date_recorded ) ) 699 ) 700 ); 701 ?> 702 </li> 703 <?php endforeach; ?> 704 </ul> 705 706 <p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ) ?></strong></p> 707 708 <a class="button-primary" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'do_delete', 'aid' => implode( ',', $aids ) ), $base_url ), 'bp-activities-delete' ) ); ?>"><?php esc_html_e( 'Delete Permanently', 'buddypress' ) ?></a> 709 <a class="button" href="<?php echo esc_attr( $base_url ); ?>"><?php esc_html_e( 'Cancel', 'buddypress' ) ?></a> 710 </div> 711 712 <?php 713 } 714 715 716 /** 717 * Display the single activity edit screen. 718 * 719 * @since 1.6.0 720 */ 721 function bp_activity_admin_edit() { 722 723 // @todo: Check if user is allowed to edit activity items 724 // if ( ! current_user_can( 'bp_edit_activity' ) ) 725 if ( ! is_super_admin() ) 726 die( '-1' ); 727 728 // Get the activity from the database. 729 $activity = bp_activity_get( array( 730 'in' => ! empty( $_REQUEST['aid'] ) ? (int) $_REQUEST['aid'] : 0, 731 'max' => 1, 732 'show_hidden' => true, 733 'spam' => 'all', 734 'display_comments' => 0 735 ) ); 736 737 if ( ! empty( $activity['activities'][0] ) ) { 738 $activity = $activity['activities'][0]; 739 740 // Workaround to use WP's touch_time() without duplicating that function. 741 $GLOBALS['comment'] = new stdClass; 742 $GLOBALS['comment']->comment_date = $activity->date_recorded; 743 } else { 744 $activity = ''; 745 } 746 747 // Construct URL for form. 748 $form_url = remove_query_arg( array( 'action', 'deleted', 'error', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] ); 749 $form_url = add_query_arg( 'action', 'save', $form_url ); 750 751 /** 752 * Fires before activity edit form is displays so plugins can modify the activity. 753 * 754 * @since 1.6.0 755 * 756 * @param array $value Array holding single activity object that was passed by reference. 757 */ 758 do_action_ref_array( 'bp_activity_admin_edit', array( &$activity ) ); ?> 759 760 <div class="wrap"> 761 <h1 class="wp-heading-inline"> 762 <?php 763 /* translators: %s: the activity ID */ 764 printf( __( 'Editing Activity (ID #%s)', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); 765 ?> 766 </h1> 767 768 <hr class="wp-header-end"> 769 770 <?php if ( ! empty( $activity ) ) : ?> 771 772 <form action="<?php echo esc_url( $form_url ); ?>" id="bp-activities-edit-form" method="post"> 773 <div id="poststuff"> 774 775 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> 776 <div id="post-body-content"> 777 <div id="postdiv"> 778 <div id="bp_activity_action" class="activitybox"> 779 <h2><?php _e( 'Action', 'buddypress' ); ?></h2> 780 <div class="inside"> 781 <label for="bp-activities-action" class="screen-reader-text"><?php 782 /* translators: accessibility text */ 783 _e( 'Edit activity action', 'buddypress' ); 784 ?></label> 785 <?php wp_editor( stripslashes( $activity->action ), 'bp-activities-action', array( 'media_buttons' => false, 'textarea_rows' => 7, 'teeny' => true, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ) ) ); ?> 786 </div> 787 </div> 788 789 <div id="bp_activity_content" class="activitybox"> 790 <h2><?php _e( 'Content', 'buddypress' ); ?></h2> 791 <div class="inside"> 792 <label for="bp-activities-content" class="screen-reader-text"><?php 793 /* translators: accessibility text */ 794 _e( 'Edit activity content', 'buddypress' ); 795 ?></label> 796 <?php wp_editor( stripslashes( $activity->content ), 'bp-activities-content', array( 'media_buttons' => false, 'teeny' => true, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ) ) ); ?> 797 </div> 798 </div> 799 </div> 800 </div><!-- #post-body-content --> 801 802 <div id="postbox-container-1" class="postbox-container"> 803 <?php do_meta_boxes( get_current_screen()->id, 'side', $activity ); ?> 804 </div> 805 806 <div id="postbox-container-2" class="postbox-container"> 807 <?php do_meta_boxes( get_current_screen()->id, 'normal', $activity ); ?> 808 <?php do_meta_boxes( get_current_screen()->id, 'advanced', $activity ); ?> 809 </div> 810 </div><!-- #post-body --> 811 812 </div><!-- #poststuff --> 813 <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> 814 <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> 815 <?php wp_nonce_field( 'edit-activity_' . $activity->id ); ?> 816 </form> 817 818 <?php else : ?> 819 820 <p><?php 821 printf( 822 '%1$s <a href="%2$s">%3$s</a>', 823 __( 'No activity found with this ID.', 'buddypress' ), 824 esc_url( bp_get_admin_url( 'admin.php?page=bp-activity' ) ), 825 __( 'Go back and try again.', 'buddypress' ) 826 ); 827 ?></p> 828 829 <?php endif; ?> 830 831 </div><!-- .wrap --> 832 833 <?php 834 } 835 836 /** 837 * Status metabox for the Activity admin edit screen. 838 * 839 * @since 1.6.0 840 * 841 * @param object $item Activity item. 842 */ 843 function bp_activity_admin_edit_metabox_status( $item ) { 844 $base_url = add_query_arg( array( 845 'page' => 'bp-activity', 846 'aid' => $item->id 847 ), bp_get_admin_url( 'admin.php' ) ); 848 ?> 849 850 <div class="submitbox" id="submitcomment"> 851 852 <div id="minor-publishing"> 853 <div id="minor-publishing-actions"> 854 <div id="preview-action"> 855 <a class="button preview" href="<?php echo esc_attr( bp_activity_get_permalink( $item->id, $item ) ); ?>" target="_blank"><?php _e( 'View Activity', 'buddypress' ); ?></a> 856 </div> 857 858 <div class="clear"></div> 859 </div><!-- #minor-publishing-actions --> 860 861 <div id="misc-publishing-actions"> 862 <div class="misc-pub-section" id="comment-status-radio"> 863 <label class="approved" for="activity-status-approved"><input type="radio" name="activity_status" id="activity-status-approved" value="ham" <?php checked( $item->is_spam, 0 ); ?>><?php _e( 'Approved', 'buddypress' ); ?></label><br /> 864 <label class="spam" for="activity-status-spam"><input type="radio" name="activity_status" id="activity-status-spam" value="spam" <?php checked( $item->is_spam, 1 ); ?>><?php _e( 'Spam', 'buddypress' ); ?></label> 865 </div> 866 867 <div class="misc-pub-section curtime misc-pub-section-last"> 868 <?php 869 // Translators: Publish box date format, see http://php.net/date. 870 $datef = __( 'M j, Y @ G:i', 'buddypress' ); 871 $date = date_i18n( $datef, strtotime( $item->date_recorded ) ); 872 ?> 873 <span id="timestamp"> 874 <?php 875 /* translators: %s: the date the activity was submitted on */ 876 printf( __( 'Submitted on: %s', 'buddypress' ), '<strong>' . $date . '</strong>' ); 877 ?> 878 </span> <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e( 'Edit', 'buddypress' ); ?></a> 879 880 <div id='timestampdiv' class='hide-if-js'> 881 <?php touch_time( 1, 0, 5 ); ?> 882 </div><!-- #timestampdiv --> 883 </div> 884 </div> <!-- #misc-publishing-actions --> 885 886 <div class="clear"></div> 887 </div><!-- #minor-publishing --> 888 889 <div id="major-publishing-actions"> 890 <div id="delete-action"> 891 <a class="submitdelete deletion" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'action', 'delete', $base_url ), 'bp-activities-delete' ) ); ?>"><?php esc_html_e( 'Delete Permanently', 'buddypress' ) ?></a> 892 </div> 893 894 <div id="publishing-action"> 895 <?php submit_button( __( 'Update', 'buddypress' ), 'primary', 'save', false ); ?> 896 </div> 897 <div class="clear"></div> 898 </div><!-- #major-publishing-actions --> 899 900 </div><!-- #submitcomment --> 901 902 <?php 903 } 904 905 /** 906 * Primary link metabox for the Activity admin edit screen. 907 * 908 * @since 1.6.0 909 * 910 * @param object $item Activity item. 911 */ 912 function bp_activity_admin_edit_metabox_link( $item ) { 913 ?> 914 915 <label class="screen-reader-text" for="bp-activities-link"><?php 916 /* translators: accessibility text */ 917 _e( 'Link', 'buddypress' ); 918 ?></label> 919 <input type="url" name="bp-activities-link" id="bp-activities-link" value="<?php echo esc_url( $item->primary_link ); ?>" aria-describedby="bp-activities-link-description" /> 920 <p id="bp-activities-link-description"><?php _e( 'Activity generated by posts and comments uses the link field for a permalink back to the content item.', 'buddypress' ); ?></p> 921 922 <?php 923 } 924 925 /** 926 * User ID metabox for the Activity admin edit screen. 927 * 928 * @since 1.6.0 929 * 930 * @param object $item Activity item. 931 */ 932 function bp_activity_admin_edit_metabox_userid( $item ) { 933 ?> 934 935 <label class="screen-reader-text" for="bp-activities-userid"><?php 936 /* translators: accessibility text */ 937 _e( 'Author ID', 'buddypress' ); 938 ?></label> 939 <input type="number" name="bp-activities-userid" id="bp-activities-userid" value="<?php echo esc_attr( $item->user_id ); ?>" min="1" /> 940 941 <?php 942 } 943 944 /** 945 * Get flattened array of all registered activity actions. 946 * 947 * Format is [activity_type] => Pretty name for activity type. 948 * 949 * @since 2.0.0 950 * 951 * @return array $actions 952 */ 953 function bp_activity_admin_get_activity_actions() { 954 $actions = array(); 955 956 // Walk through the registered actions, and build an array of actions/values. 957 foreach ( bp_activity_get_actions() as $action ) { 958 $action = array_values( (array) $action ); 959 960 for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) { 961 /** 962 * Don't take in account: 963 * - a mis-named Friends activity type from before BP 1.6, 964 * - The Group's component 'activity_update' one as the Activity component is using it. 965 */ 966 if ( 'friends_register_activity_action' === $action[$i]['key'] || 'bp_groups_format_activity_action_group_activity_update' === $action[$i]['format_callback'] ) { 967 continue; 968 } 969 970 $actions[ $action[$i]['key'] ] = $action[$i]['value']; 971 } 972 } 973 974 // Sort array by the human-readable value. 975 natsort( $actions ); 976 977 return $actions; 978 } 979 980 /** 981 * Activity type metabox for the Activity admin edit screen. 982 * 983 * @since 1.6.0 984 * 985 * @param object $item Activity item. 986 */ 987 function bp_activity_admin_edit_metabox_type( $item ) { 988 $bp = buddypress(); 989 990 $actions = array(); 991 $selected = $item->type; 992 993 // Walk through the registered actions, and build an array of actions/values. 994 foreach ( bp_activity_get_actions() as $action ) { 995 $action = array_values( (array) $action ); 996 997 for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) { 998 /** 999 * Don't take in account: 1000 * - a mis-named Friends activity type from before BP 1.6, 1001 * - The Group's component 'activity_update' one as the Activity component is using it. 1002 */ 1003 if ( 'friends_register_activity_action' === $action[$i]['key'] || 'bp_groups_format_activity_action_group_activity_update' === $action[$i]['format_callback'] ) { 1004 continue; 1005 } 1006 1007 $actions[ $action[$i]['key'] ] = $action[$i]['value']; 1008 } 1009 } 1010 1011 // Sort array by the human-readable value. 1012 natsort( $actions ); 1013 1014 /* 1015 * If the activity type is not registered properly (eg, a plugin has 1016 * not called bp_activity_set_action()), add the raw type to the end 1017 * of the list. 1018 */ 1019 if ( ! isset( $actions[ $selected ] ) ) { 1020 _doing_it_wrong( 1021 __FUNCTION__, 1022 sprintf( 1023 /* translators: %s: the name of the activity type */ 1024 __( 'This activity item has a type (%s) that is not registered using bp_activity_set_action(), so no label is available.', 'buddypress' ), 1025 $selected 1026 ), 1027 '2.0.0' 1028 ); 1029 1030 $actions[ $selected ] = $selected; 1031 } 1032 1033 ?> 1034 1035 <label for="bp-activities-type" class="screen-reader-text"><?php 1036 /* translators: accessibility text */ 1037 esc_html_e( 'Select activity type', 'buddypress' ); 1038 ?></label> 1039 <select name="bp-activities-type" id="bp-activities-type"> 1040 <?php foreach ( $actions as $k => $v ) : ?> 1041 <option value="<?php echo esc_attr( $k ); ?>" <?php selected( $k, $selected ); ?>><?php echo esc_html( $v ); ?></option> 1042 <?php endforeach; ?> 1043 </select> 1044 1045 <?php 1046 } 1047 1048 /** 1049 * Primary item ID/Secondary item ID metabox for the Activity admin edit screen. 1050 * 1051 * @since 1.6.0 1052 * 1053 * @param object $item Activity item. 1054 */ 1055 function bp_activity_admin_edit_metabox_itemids( $item ) { 1056 ?> 1057 1058 <label for="bp-activities-primaryid"><?php _e( 'Primary Item ID', 'buddypress' ); ?></label> 1059 <input type="number" name="bp-activities-primaryid" id="bp-activities-primaryid" value="<?php echo esc_attr( $item->item_id ); ?>" min="0" /> 1060 <br /> 1061 1062 <label for="bp-activities-secondaryid"><?php _e( 'Secondary Item ID', 'buddypress' ); ?></label> 1063 <input type="number" name="bp-activities-secondaryid" id="bp-activities-secondaryid" value="<?php echo esc_attr( $item->secondary_item_id ); ?>" min="0" /> 1064 1065 <p><?php _e( 'These identify the object that created this activity. For example, the fields could reference a pair of site and comment IDs.', 'buddypress' ); ?></p> 1066 1067 <?php 1068 } 1069 1070 /** 1071 * Display the Activity admin index screen, which contains a list of all the activities. 1072 * 1073 * @since 1.6.0 1074 * 1075 * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table. 1076 * @global string $plugin_page The current plugin page. 1077 */ 1078 function bp_activity_admin_index() { 1079 global $bp_activity_list_table, $plugin_page; 1080 1081 $messages = array(); 1082 1083 // If the user has just made a change to an activity item, build status messages. 1084 if ( ! empty( $_REQUEST['deleted'] ) || ! empty( $_REQUEST['spammed'] ) || ! empty( $_REQUEST['unspammed'] ) || ! empty( $_REQUEST['error'] ) || ! empty( $_REQUEST['updated'] ) ) { 1085 $deleted = ! empty( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0; 1086 $errors = ! empty( $_REQUEST['error'] ) ? $_REQUEST['error'] : ''; 1087 $spammed = ! empty( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed'] : 0; 1088 $unspammed = ! empty( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0; 1089 $updated = ! empty( $_REQUEST['updated'] ) ? (int) $_REQUEST['updated'] : 0; 1090 1091 $errors = array_map( 'absint', explode( ',', $errors ) ); 1092 1093 // Make sure we don't get any empty values in $errors. 1094 for ( $i = 0, $errors_count = count( $errors ); $i < $errors_count; $i++ ) { 1095 if ( 0 === $errors[$i] ) { 1096 unset( $errors[$i] ); 1097 } 1098 } 1099 1100 // Reindex array. 1101 $errors = array_values( $errors ); 1102 1103 if ( $deleted > 0 ) { 1104 /* translators: %s: the number of permanently deleted activities */ 1105 $messages[] = sprintf( _n( '%s activity item has been permanently deleted.', '%s activity items have been permanently deleted.', $deleted, 'buddypress' ), number_format_i18n( $deleted ) ); 1106 } 1107 1108 if ( ! empty( $errors ) ) { 1109 if ( 1 == count( $errors ) ) { 1110 /* translators: %s: the ID of the activity which errored during an update */ 1111 $messages[] = sprintf( __( 'An error occurred when trying to update activity ID #%s.', 'buddypress' ), number_format_i18n( $errors[0] ) ); 1112 1113 } else { 1114 $error_msg = __( 'Errors occurred when trying to update these activity items:', 'buddypress' ); 1115 $error_msg .= '<ul class="activity-errors">'; 1116 1117 // Display each error as a list item. 1118 foreach ( $errors as $error ) { 1119 /* Translators: %s: the activity ID */ 1120 $error_msg .= '<li>' . sprintf( __( '#%s', 'buddypress' ), number_format_i18n( $error ) ) . '</li>'; 1121 } 1122 1123 $error_msg .= '</ul>'; 1124 $messages[] = $error_msg; 1125 } 1126 } 1127 1128 if ( $spammed > 0 ) { 1129 /* translators: %s: the number of activities successfully marked as spam */ 1130 $messages[] = sprintf( _n( '%s activity item has been successfully spammed.', '%s activity items have been successfully spammed.', $spammed, 'buddypress' ), number_format_i18n( $spammed ) ); 1131 } 1132 1133 if ( $unspammed > 0 ) { 1134 /* translators: %s: the number of activities successfully marked as ham */ 1135 $messages[] = sprintf( _n( '%s activity item has been successfully unspammed.', '%s activity items have been successfully unspammed.', $unspammed, 'buddypress' ), number_format_i18n( $unspammed ) ); 1136 } 1137 1138 if ( $updated > 0 ) { 1139 $messages[] = __( 'The activity item has been updated successfully.', 'buddypress' ); 1140 } 1141 } 1142 1143 // Prepare the activity items for display. 1144 $bp_activity_list_table->prepare_items(); 1145 1146 /** 1147 * Fires before edit form is displayed so plugins can modify the activity messages. 1148 * 1149 * @since 1.6.0 1150 * 1151 * @param array $messages Array of messages to display at top of page. 1152 */ 1153 do_action( 'bp_activity_admin_index', $messages ); ?> 1154 1155 <div class="wrap"> 1156 <h1 class="wp-heading-inline"> 1157 <?php if ( !empty( $_REQUEST['aid'] ) ) : ?> 1158 <?php 1159 /* translators: %s: the activity ID */ 1160 printf( __( 'Activity related to ID #%s', 'buddypress' ), number_format_i18n( (int) $_REQUEST['aid'] ) ); 1161 ?> 1162 <?php else : ?> 1163 <?php _ex( 'Activity', 'Admin SWA page', 'buddypress' ); ?> 1164 <?php endif; ?> 1165 1166 <?php if ( !empty( $_REQUEST['s'] ) ) : ?> 1167 <span class="subtitle"> 1168 <?php 1169 /* translators: %s: the activity search terms */ 1170 printf( __( 'Search results for “%s”', 'buddypress' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) ); 1171 ?> 1172 </span> 1173 <?php endif; ?> 1174 </h1> 1175 1176 <hr class="wp-header-end"> 1177 1178 <?php // If the user has just made a change to an activity item, display the status messages. ?> 1179 <?php if ( !empty( $messages ) ) : ?> 1180 <div id="moderated" class="<?php echo ( ! empty( $_REQUEST['error'] ) ) ? 'error' : 'updated'; ?> notice is-dismissible"><p><?php echo implode( "<br/>\n", $messages ); ?></p></div> 1181 <?php endif; ?> 1182 1183 <?php // Display each activity on its own row. ?> 1184 <?php $bp_activity_list_table->views(); ?> 1185 1186 <form id="bp-activities-form" action="" method="get"> 1187 <?php $bp_activity_list_table->search_box( __( 'Search all Activity', 'buddypress' ), 'bp-activity' ); ?> 1188 <input type="hidden" name="page" value="<?php echo esc_attr( $plugin_page ); ?>" /> 1189 <?php $bp_activity_list_table->display(); ?> 1190 </form> 1191 1192 <?php // This markup is used for the reply form. ?> 1193 <table style="display: none;"> 1194 <tr id="bp-activities-container" style="display: none;"> 1195 <td colspan="4"> 1196 <form method="get" action=""> 1197 1198 <h3 id="bp-replyhead"><?php _e( 'Reply to Activity', 'buddypress' ); ?></h3> 1199 <label for="bp-activities" class="screen-reader-text"><?php 1200 /* translators: accessibility text */ 1201 _e( 'Reply', 'buddypress' ); 1202 ?></label> 1203 <?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, ) ); ?> 1204 1205 <p id="bp-replysubmit" class="submit"> 1206 <a href="#" class="cancel button-secondary alignleft"><?php _e( 'Cancel', 'buddypress' ); ?></a> 1207 <a href="#" class="save button-primary alignright"><?php _e( 'Reply', 'buddypress' ); ?></a> 1208 1209 <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> 1210 <span class="error" style="display:none;"></span> 1211 <br class="clear" /> 1212 </p> 1213 1214 <?php wp_nonce_field( 'bp-activity-admin-reply', '_ajax_nonce-bp-activity-admin-reply', false ); ?> 1215 1216 </form> 1217 </td> 1218 </tr> 1219 </table> 1220 </div> 1221 1222 <?php 1223 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:57 2024 | Cross-referenced by PHPXref 0.7.1 |