Ticket #5328: 5328.02.diff
File 5328.02.diff, 26.9 KB (added by , 11 years ago) |
---|
-
bp-activity/bp-activity-classes.php
diff --git bp-activity/bp-activity-classes.php bp-activity/bp-activity-classes.php index 1d506c3..200eec8 100644
class BP_Activity_Activity { 1114 1114 1115 1115 $filter_sql = array(); 1116 1116 1117 if ( ! empty( $filter_array['user_id'] ) ) {1117 if ( ! empty( $filter_array['user_id'] ) ) { 1118 1118 $user_sql = BP_Activity_Activity::get_in_operator_sql( 'a.user_id', $filter_array['user_id'] ); 1119 if ( ! empty( $user_sql ) )1119 if ( ! empty( $user_sql ) ) 1120 1120 $filter_sql[] = $user_sql; 1121 1121 } 1122 1122 1123 if ( ! empty( $filter_array['object'] ) ) {1123 if ( ! empty( $filter_array['object'] ) ) { 1124 1124 $object_sql = BP_Activity_Activity::get_in_operator_sql( 'a.component', $filter_array['object'] ); 1125 if ( ! empty( $object_sql ) )1125 if ( ! empty( $object_sql ) ) 1126 1126 $filter_sql[] = $object_sql; 1127 1127 } 1128 1128 1129 if ( ! empty( $filter_array['action'] ) ) {1129 if ( ! empty( $filter_array['action'] ) ) { 1130 1130 $action_sql = BP_Activity_Activity::get_in_operator_sql( 'a.type', $filter_array['action'] ); 1131 1131 if ( ! empty( $action_sql ) ) 1132 1132 $filter_sql[] = $action_sql; 1133 1133 } 1134 1134 1135 if ( ! empty( $filter_array['primary_id'] ) ) {1135 if ( ! empty( $filter_array['primary_id'] ) ) { 1136 1136 $pid_sql = BP_Activity_Activity::get_in_operator_sql( 'a.item_id', $filter_array['primary_id'] ); 1137 if ( ! empty( $pid_sql ) )1137 if ( ! empty( $pid_sql ) ) 1138 1138 $filter_sql[] = $pid_sql; 1139 1139 } 1140 1140 1141 if ( ! empty( $filter_array['secondary_id'] ) ) {1141 if ( ! empty( $filter_array['secondary_id'] ) ) { 1142 1142 $sid_sql = BP_Activity_Activity::get_in_operator_sql( 'a.secondary_item_id', $filter_array['secondary_id'] ); 1143 if ( ! empty( $sid_sql ) )1143 if ( ! empty( $sid_sql ) ) 1144 1144 $filter_sql[] = $sid_sql; 1145 1145 } 1146 1146 1147 if ( ! empty( $filter_array['id'] ) ) { 1148 $sid_sql = absint( $filter_array['id'] ); 1149 $filter_sql[] = "a.id > {$sid_sql}"; 1150 } 1151 1147 1152 if ( empty( $filter_sql ) ) 1148 1153 return false; 1149 1154 … … class BP_Activity_Activity { 1154 1159 * Get the date/time of last recorded activity. 1155 1160 * 1156 1161 * @since BuddyPress (1.2) 1157 * 1162 * 1163 * @param array $args 1158 1164 * @return string ISO timestamp. 1159 1165 */ 1160 public static function get_last_updated( ) {1166 public static function get_last_updated( $args = array() ) { 1161 1167 global $bp, $wpdb; 1162 1168 1163 return $wpdb->get_var( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded DESC LIMIT 1" ); 1169 $r = bp_parse_args( $args, 1170 array( 1171 'field_name' => 'date_recorded', 1172 'search_terms' => false, 1173 'filter' => false, // See self::get_filter_sql() 1174 'display_comments' => 'threaded', // or stream or false 1175 'show_hidden' => false, // Show items marked hide_sitewide 1176 ), 1177 'activity_last_updated' 1178 ); 1179 extract( $r ); 1180 1181 if ( 'id' != $field_name ) { 1182 return $wpdb->get_var( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded DESC LIMIT 1" ); 1183 } 1184 1185 $select_sql = "SELECT a.id FROM {$bp->activity->table_name} a"; 1186 $order_sql = "ORDER BY a.id DESC"; 1187 $limit_sql = "LIMIT 1"; 1188 $exclude_types = array(); 1189 1190 $where_conditions['spam_sql'] = 'a.is_spam = 0'; 1191 1192 // Searching 1193 if ( $search_terms ) { 1194 $search_terms = esc_sql( $search_terms ); 1195 $where_conditions['search_sql'] = "a.content LIKE '%%" . esc_sql( like_escape( $search_terms ) ) . "%%'"; 1196 } 1197 // Filtering 1198 if ( $filter && $filter_sql = BP_Activity_Activity::get_filter_sql( $filter ) ) 1199 $where_conditions['filter_sql'] = $filter_sql; 1200 1201 if ( ! $show_hidden ) 1202 $where_conditions['hidden_sql'] = "a.hide_sitewide = 0"; 1203 1204 if ( empty( $filter_array['action'] ) ) 1205 $exclude_types[] = 'last_activity'; 1206 1207 if ( false === $display_comments || 'threaded' === $display_comments ) 1208 $exclude_types[] = 'activity_comment'; 1209 1210 if ( ! empty( $exclude_types ) && $excluded_type = BP_Activity_Activity::get_in_operator_sql( 'a.type', $exclude_types ) ) { 1211 $excluded_type = str_replace( 'a.type IN', 'a.type NOT IN', $excluded_type ); 1212 $where_conditions[] = $excluded_type; 1213 } 1214 1215 // Filter the where conditions 1216 $where_conditions = apply_filters( 'bp_activity_get_last_updated_recorded_where', $where_conditions, $r ); 1217 1218 // Join the where conditions together 1219 $where_sql = 'WHERE ' . join( ' AND ', $where_conditions ); 1220 1221 $last_updated = $wpdb->get_var( apply_filters( 'bp_activity_get_last_updated_sql', "{$select_sql} {$where_sql} {$order_sql} {$limit_sql}", $select_sql, $where_sql, $order_sql ) ); 1222 1223 return absint( $last_updated ); 1164 1224 } 1165 1225 1166 1226 /** -
bp-activity/bp-activity-filters.php
diff --git bp-activity/bp-activity-filters.php bp-activity/bp-activity-filters.php index 603924f..ccbf9ab 100644
function bp_activity_truncate_entry( $text ) { 376 376 377 377 return apply_filters( 'bp_activity_truncate_entry', $excerpt, $text, $append_text ); 378 378 } 379 380 /** 381 * Include extra javascript dependencies for activity component. 382 * 383 * @since BuddyPress (2.0.0) 384 * 385 * @uses bp_activity_do_heartbeat() to check if heartbeat is required 386 * 387 * @param array $js_handles The original dependencies. 388 * @return array $js_handles The new dependencies. 389 */ 390 function bp_activity_get_js_dependencies( $js_handles = array() ) { 391 if ( bp_activity_do_heartbeat() ) { 392 $js_handles[] = 'heartbeat'; 393 } 394 395 return $js_handles; 396 } 397 add_filter( 'bp_core_get_js_dependencies', 'bp_activity_get_js_dependencies', 10, 1 ); 398 399 /** 400 * Adds a just-posted class to avoid some mess in activity ajax pagination 401 * 402 * @since BuddyPress (2.0.0) 403 * @param string $classes 404 * @return string $classes 405 */ 406 function bp_activity_newest_class( $classes = '' ) { 407 $new_update_id = buddypress()->activity->new_update_id; 408 409 if ( $new_update_id == bp_get_activity_id() ) 410 $classes .= ' new-update'; 411 412 $classes .= ' just-posted'; 413 return $classes; 414 } 415 416 /** 417 * Uses WordPress Heartbeat API to check for latest activity update in BP Activity Admin screen 418 * 419 * @since BuddyPress (2.0.0) 420 * 421 * @uses bp_activity_get_last_updated() to get the recorded date of the last activity 422 * @param array $response 423 * @param array $data 424 * @return array $response 425 */ 426 function bp_activity_heartbeat_last_recorded( $response = array(), $data = array() ) { 427 $bp = buddypress(); 428 429 if ( isset( $data['bp_last_activity_update'] ) && 'bp_activity_heartbeat_front' == $data['bp_last_activity_update']['id'] ) { 430 $filter = array(); 431 $show_hidden = false; 432 433 if ( ! empty( $data['bp_last_activity_update']['action'] ) && '-1' != $data['bp_last_activity_update']['action'] ) 434 $filter['action'] = $data['bp_last_activity_update']['action']; 435 436 if ( ! empty( $data['bp_last_activity_update']['scope'] ) && 'all' != $data['bp_last_activity_update']['scope'] ) 437 $filter['object'] = $data['bp_last_activity_update']['scope']; 438 439 // Group filtering 440 if ( ! empty( $bp->groups->current_group ) ) { 441 $filter['object'] = $bp->groups->id; 442 $filter['primary_id'] = $bp->groups->current_group->id; 443 444 if ( ( 'public' != $bp->groups->current_group->status ) && ( groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) || bp_current_user_can( 'bp_moderate' ) ) ) 445 $show_hidden = true; 446 } 447 448 $response['last_id_recorded'] = bp_activity_get_last_updated( 449 array( 450 'field_name' => 'id', 451 'search_terms' => $data['bp_last_activity_update']['search'], 452 'filter' => $filter, 453 'show_hidden' => $show_hidden 454 ) ); 455 } 456 457 return $response; 458 } 459 add_filter( 'heartbeat_received', 'bp_activity_heartbeat_last_recorded', 10, 2 ); 460 add_filter( 'heartbeat_nopriv_received', 'bp_activity_heartbeat_last_recorded', 10, 2 ); 461 462 /** 463 * Changes the pulse of the WP HeartBeat API where needed 464 * 465 * The filter should be initialized elsewhere to avoid the long check 466 * 467 * @since BuddyPress (2.0.0) 468 * 469 * @param array $settings HeartBeat settings 470 * @return array HeartBeat settings 471 */ 472 function bp_activity_heartbeat_settings( $settings = array() ) { 473 if ( bp_activity_do_heartbeat() ) 474 $settings['interval'] = apply_filters( 'bp_activity_heartbeat_pulse', 15 ); 475 476 return $settings; 477 } 478 add_filter( 'heartbeat_settings', 'bp_activity_heartbeat_settings', 10, 1 ); -
bp-activity/bp-activity-functions.php
diff --git bp-activity/bp-activity-functions.php bp-activity/bp-activity-functions.php index 2a69a5c..1fd37d6 100644
function bp_activity_check_exists_by_content( $content ) { 508 508 * @uses BP_Activity_Activity::get_last_updated() {@link BP_Activity_Activity} 509 509 * @uses apply_filters() To call the 'bp_activity_get_last_updated' hook. 510 510 * 511 * @param array $args 511 512 * @return string Date last updated. 512 513 */ 513 function bp_activity_get_last_updated( ) {514 return apply_filters( 'bp_activity_get_last_updated', BP_Activity_Activity::get_last_updated( ) );514 function bp_activity_get_last_updated( $args = array() ) { 515 return apply_filters( 'bp_activity_get_last_updated', BP_Activity_Activity::get_last_updated( $args ) ); 515 516 } 516 517 517 518 /** … … function bp_embed_activity_cache( $cache, $id, $cachekey ) { 1845 1846 function bp_embed_activity_save_cache( $cache, $cachekey, $id ) { 1846 1847 bp_activity_update_meta( $id, $cachekey, $cache ); 1847 1848 } 1849 1850 1851 /** 1852 * Should we use HeartBeat to refresh activities every 15 s. 1853 * 1854 * @since BuddyPress (2.0.0) 1855 * 1856 * @uses bp_is_activity_heartbeat_active() to check if heatbeat setting is on 1857 * @uses bp_is_activity_directory() to check if the current page is the activity directory 1858 * @uses bp_is_active() to check if the group component is active 1859 * @uses bp_is_group_activity() to check if on a single group, the current page is the group activities 1860 * @uses bp_is_group_home() to check if the current page is a single group home page 1861 * @return bool True on success, false on failure. 1862 */ 1863 function bp_activity_do_heartbeat() { 1864 $retval = false; 1865 1866 if ( ! bp_is_activity_heartbeat_active() ) 1867 return $retval; 1868 1869 if ( bp_is_activity_directory() ) 1870 $retval = true; 1871 1872 if ( bp_is_active( 'groups') ) { 1873 // If no custom front, then activities are loaded in group's home 1874 $has_custom_front = bp_locate_template( array( 'groups/single/front.php' ), false, true ); 1875 1876 if ( bp_is_group_activity() || ( ! $has_custom_front && bp_is_group_home() ) ) 1877 $retval = true; 1878 } 1879 1880 return $retval; 1881 } -
bp-activity/bp-activity-screens.php
diff --git bp-activity/bp-activity-screens.php bp-activity/bp-activity-screens.php index 787e247..cd0b679 100644
if ( !defined( 'ABSPATH' ) ) exit; 28 28 * @uses apply_filters() To call the 'bp_activity_screen_index' hook. 29 29 */ 30 30 function bp_activity_screen_index() { 31 if ( !bp_displayed_user_id() && bp_is_activity_component() && !bp_current_action() ) {31 if ( bp_is_activity_directory() ) { 32 32 bp_update_is_directory( true, 'activity' ); 33 33 34 34 do_action( 'bp_activity_screen_index' ); -
bp-activity/bp-activity-template.php
diff --git bp-activity/bp-activity-template.php bp-activity/bp-activity-template.php index c574302..3b50620 100644
function bp_has_activities( $args = '' ) { 515 515 'action' => false, // action to filter on e.g. activity_update, new_forum_post, profile_updated 516 516 'primary_id' => $primary_id, // object ID to filter on e.g. a group_id or forum_id or blog_id etc. 517 517 'secondary_id' => false, // secondary object ID to filter on e.g. a post_id 518 'id' => false, // activity id to get newer updates 518 519 519 520 'meta_query' => false, // filter on activity meta. See WP_Meta_Query for format 520 521 … … function bp_has_activities( $args = '' ) { 532 533 $display_comments = false; 533 534 } 534 535 536 // reset pagination to get all new activities 537 if ( ! empty( $id ) ) 538 $page = 0; 539 535 540 if ( empty( $search_terms ) && ! empty( $_REQUEST['s'] ) ) 536 541 $search_terms = $_REQUEST['s']; 537 542 … … function bp_has_activities( $args = '' ) { 603 608 // into bp-custom.php or your theme's functions.php 604 609 if ( isset( $_GET['afilter'] ) && apply_filters( 'bp_activity_enable_afilter_support', false ) ) 605 610 $filter = array( 'object' => $_GET['afilter'] ); 606 else if ( ! empty( $user_id ) || !empty( $object ) || !empty( $action ) || !empty( $primary_id ) || !empty( $secondary_id ) )607 $filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id );611 else if ( ! empty( $user_id ) || ! empty( $object ) || ! empty( $action ) || ! empty( $primary_id ) || ! empty( $secondary_id ) || ! empty( $id ) ) 612 $filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id, 'id' => $id ); 608 613 else 609 614 $filter = false; 610 615 … … function bp_activity_pagination_links() { 737 742 function bp_activity_has_more_items() { 738 743 global $activities_template; 739 744 740 $remaining_pages = floor( ( $activities_template->total_activity_count - 1 ) / ( $activities_template->pag_num * $activities_template->pag_page ) ); 745 $remaining_pages = 0; 746 747 if ( ! empty( $activities_template->pag_page ) ) { 748 $remaining_pages = floor( ( $activities_template->total_activity_count - 1 ) / ( $activities_template->pag_num * $activities_template->pag_page ) ); 749 } 750 741 751 $has_more_items = (int) $remaining_pages ? true : false; 742 752 743 753 return apply_filters( 'bp_activity_has_more_items', $has_more_items ); -
bp-core/admin/bp-core-settings.php
diff --git bp-core/admin/bp-core-settings.php bp-core/admin/bp-core-settings.php index 01ed8c5..f9901eb 100644
function bp_admin_setting_callback_blogforum_comments() { 104 104 } 105 105 106 106 /** 107 * Allow Heartbeat to refresh activity stream 108 * 109 * @since BuddyPress (2.0.0) 110 */ 111 function bp_admin_setting_callback_heartbeat() { 112 ?> 113 114 <input id="_bp_enable_heartbeat_refresh" name="_bp_enable_heartbeat_refresh" type="checkbox" value="1" <?php checked( bp_is_activity_heartbeat_active( false ) ); ?> /> 115 <label for="_bp_enable_heartbeat_refresh"><?php _e( 'Allow activity stream to be refreshed every 15 seconds', 'buddypress' ); ?></label> 116 117 <?php 118 } 119 120 /** 107 121 * Sanitization for _bp_force_buddyvar 108 122 * 109 123 * If upgraded to 1.6 and you chose to keep the BuddyBar, a checkbox asks if you want to switch to -
bp-core/bp-core-admin.php
diff --git bp-core/bp-core-admin.php bp-core/bp-core-admin.php index 9e45be9..4020355 100644
class BP_Admin { 330 330 add_settings_field( 'bp-disable-blogforum-comments', __( 'Blog & Forum Comments', 'buddypress' ), 'bp_admin_setting_callback_blogforum_comments', 'buddypress', 'bp_activity' ); 331 331 register_setting( 'buddypress', 'bp-disable-blogforum-comments', 'bp_admin_sanitize_callback_blogforum_comments' ); 332 332 333 // Activity Heartbeat refresh 334 add_settings_field( '_bp_enable_heartbeat_refresh', __( 'Activity auto-refresh', 'buddypress' ), 'bp_admin_setting_callback_heartbeat', 'buddypress', 'bp_activity' ); 335 register_setting( 'buddypress', '_bp_enable_heartbeat_refresh', 'intval' ); 336 333 337 // Allow activity akismet 334 338 if ( is_plugin_active( 'akismet/akismet.php' ) && defined( 'AKISMET_VERSION' ) ) { 335 339 add_settings_field( '_bp_enable_akismet', __( 'Akismet', 'buddypress' ), 'bp_admin_setting_callback_activity_akismet', 'buddypress', 'bp_activity' ); -
bp-core/bp-core-functions.php
diff --git bp-core/bp-core-functions.php bp-core/bp-core-functions.php index ccea74b..bfa783f 100644
function bp_nav_menu_get_item_url( $slug ) { 1852 1852 1853 1853 return $nav_item_url; 1854 1854 } 1855 1856 /** 1857 * Get the javascript dependencies for buddypress.js 1858 * 1859 * @since BuddyPress (2.0.0) 1860 * 1861 * @uses apply_filters() to allow other component to load extra dependencies 1862 * @return array the javascript dependencies. 1863 */ 1864 function bp_core_get_js_dependencies() { 1865 return apply_filters( 'bp_core_get_js_dependencies', array( 'jquery' ) ); 1866 } 1867 -
bp-core/bp-core-options.php
diff --git bp-core/bp-core-options.php bp-core/bp-core-options.php index 8225fa2..f658141 100644
function bp_is_akismet_active( $default = true ) { 559 559 } 560 560 561 561 /** 562 * Check whether Activity Heartbeat refresh is enabled. 563 * 564 * @since BuddyPress (2.0.0) 565 * 566 * @uses bp_get_option() To get the Heartbeat option. 567 * 568 * @param bool $default Optional. Fallback value if not found in the database. 569 * Default: false. 570 * @return bool True if Heartbeat refresh is enabled, otherwise false. 571 */ 572 function bp_is_activity_heartbeat_active( $default = false ) { 573 return (bool) apply_filters( 'bp_is_activity_heartbeat_active', (bool) bp_get_option( '_bp_enable_heartbeat_refresh', $default ) ); 574 } 575 576 /** 562 577 * Get the current theme package ID. 563 578 * 564 579 * @since BuddyPress (1.7.0) -
bp-core/bp-core-template.php
diff --git bp-core/bp-core-template.php bp-core/bp-core-template.php index 51c1b38..c25a6d5 100644
function bp_is_current_component_core() { 1491 1491 /** Activity ******************************************************************/ 1492 1492 1493 1493 /** 1494 * Is the current page the activity directory ? 1495 * 1496 * @since BuddyPress (2.0.0) 1497 * 1498 * @return True if the current page is the activity directory. 1499 */ 1500 function bp_is_activity_directory() { 1501 if( ! bp_displayed_user_id() && bp_is_activity_component() && ! bp_current_action() ) 1502 return true; 1503 1504 return false; 1505 } 1506 1507 /** 1494 1508 * Is the current page a single activity item permalink? 1495 1509 * 1496 1510 * @return True if the current page is a single activity item permalink. -
bp-templates/bp-legacy/buddypress-functions.php
diff --git bp-templates/bp-legacy/buddypress-functions.php bp-templates/bp-legacy/buddypress-functions.php index 0cb3153..1613cf8 100644
class BP_Legacy extends BP_Theme_Compat { 145 145 146 146 // Activity 147 147 'activity_get_older_updates' => 'bp_legacy_theme_activity_template_loader', 148 'activity_get_newer_updates' => 'bp_legacy_theme_activity_template_loader', 148 149 'activity_mark_fav' => 'bp_legacy_theme_mark_activity_favorite', 149 150 'activity_mark_unfav' => 'bp_legacy_theme_unmark_activity_favorite', 150 151 'activity_widget_filter' => 'bp_legacy_theme_activity_template_loader', … … class BP_Legacy extends BP_Theme_Compat { 223 224 // Enqueue the global JS, if found - AJAX will not work 224 225 // without it 225 226 if ( isset( $asset['location'], $asset['handle'] ) ) { 226 wp_enqueue_script( $asset['handle'], $asset['location'], array( 'jquery'), $this->version );227 wp_enqueue_script( $asset['handle'], $asset['location'], bp_core_get_js_dependencies(), $this->version ); 227 228 } 228 229 229 230 // Add words that we need to use in JS to the end of the page … … class BP_Legacy extends BP_Theme_Compat { 242 243 'show_x_comments' => __( 'Show all %d comments', 'buddypress' ), 243 244 'unsaved_changes' => __( 'Your profile has unsaved changes. If you leave the page, the changes will be lost.', 'buddypress' ), 244 245 'view' => __( 'View', 'buddypress' ), 246 'newest' => __( 'Load Newest', 'buddypress' ), 245 247 ); 246 248 wp_localize_script( $asset['handle'], 'BP_DTheme', $params ); 247 249 … … function bp_legacy_theme_ajax_querystring( $query_string, $object ) { 480 482 $qs[] = 'exclude=' . implode( ',', $just_posted ); 481 483 } 482 484 485 // to get newest activities 486 if ( ! empty( $_POST['id'] ) ) 487 $qs[] = 'id=' . intval( $_POST['id'] ); 488 483 489 $object_search_text = bp_get_search_default_text( $object ); 484 490 if ( ! empty( $_POST['search_terms'] ) && $object_search_text != $_POST['search_terms'] && 'false' != $_POST['search_terms'] && 'undefined' != $_POST['search_terms'] ) 485 491 $qs[] = 'search_terms=' . $_POST['search_terms']; … … function bp_legacy_theme_activity_template_loader() { 594 600 break; 595 601 } 596 602 603 // are we loading the newest updates ? 604 $is_newest_request = ! empty( $_POST['action'] ) && 'activity_get_newer_updates' == $_POST['action']; 605 606 if ( $is_newest_request ) 607 add_filter( 'bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1 ); 608 597 609 // Buffer the loop in the template to a var for JS to spit out. 598 610 ob_start(); 599 611 bp_get_template_part( 'activity/activity-loop' ); … … function bp_legacy_theme_activity_template_loader() { 601 613 $result['feed_url'] = apply_filters( 'bp_legacy_theme_activity_feed_url', $feed_url, $scope ); 602 614 ob_end_clean(); 603 615 616 if ( $is_newest_request ) 617 remove_filter( 'bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1 ); 618 604 619 exit( json_encode( $result ) ); 605 620 } 606 621 … … function bp_legacy_theme_activity_template_loader() { 611 626 * @since BuddyPress (1.2) 612 627 */ 613 628 function bp_legacy_theme_post_update() { 629 $bp = buddypress(); 630 614 631 // Bail if not a POST action 615 632 if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) 616 633 return; … … function bp_legacy_theme_post_update() { 639 656 if ( empty( $activity_id ) ) 640 657 exit( '-1<div id="message" class="error"><p>' . __( 'There was a problem posting your update, please try again.', 'buddypress' ) . '</p></div>' ); 641 658 642 if ( bp_has_activities ( 'include=' . $activity_id ) ) { 659 if ( ! empty( $_POST['id'] ) && $last_id = absint( $_POST['id'] ) ) { 660 $activity_args = array( 'id' => $last_id ); 661 $bp->activity->new_update_id = $activity_id; 662 add_filter( 'bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1 ); 663 } else { 664 $activity_args = array( 'include' => $activity_id ); 665 } 666 667 if ( bp_has_activities ( $activity_args ) ) { 643 668 while ( bp_activities() ) { 644 669 bp_the_activity(); 645 670 bp_get_template_part( 'activity/entry' ); 646 671 } 647 672 } 648 673 674 if ( ! empty( $last_id ) ) { 675 remove_filter( 'bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1 ); 676 } 677 649 678 exit; 650 679 } 651 680 -
bp-templates/bp-legacy/css/buddypress.css
diff --git bp-templates/bp-legacy/css/buddypress.css bp-templates/bp-legacy/css/buddypress.css index 81dd03f..e343077 100644
body.activity-permalink #buddypress .activity-content blockquote { 290 290 margin-left: 1em; 291 291 white-space: nowrap; 292 292 } 293 #buddypress .activity-list li.load-more { 293 #buddypress .activity-list li.load-more, 294 #buddypress .activity-list li.load-newest { 294 295 background: #f0f0f0; 295 296 font-size: 110%; 296 297 margin: 15px 0; 297 298 padding: 10px 15px; 298 299 text-align: center; 299 300 } 300 #buddypress .activity-list li.load-more a { 301 #buddypress .activity-list li.load-more a, 302 #buddypress .activity-list li.load-newest a { 301 303 color: #4D4D4D; 302 304 } 303 305 -
bp-templates/bp-legacy/js/buddypress.js
diff --git bp-templates/bp-legacy/js/buddypress.js bp-templates/bp-legacy/js/buddypress.js index 350193e..f0b9e2d 100644
jq(document).ready( function() { 53 53 if ( $whats_new_form.hasClass("submitted") ) { 54 54 $whats_new_form.removeClass("submitted"); 55 55 } 56 57 /* If the scope is not all, the activity update can temporarly be displayed 58 in the wrong tab which can be annoying with the load newest feature */ 59 if ( jq( '#activity-all' ).length ) { 60 61 if ( ! jq( '#activity-all' ).hasClass( 'selected' ) ) { 62 // reset to everyting 63 jq( '#activity-filter-select select' ).val( '-1' ); 64 jq( '#activity-all a' ).trigger( "click" ); 65 } else if ( '-1' != jq( '#activity-filter-select select' ).val() ) { 66 jq( '#activity-filter-select select' ).val( '-1' ); 67 jq( '#activity-filter-select select' ).trigger( 'change' ); 68 } 69 } 56 70 }); 57 71 58 72 /* On blur, shrink if it's empty */ … … jq(document).ready( function() { 71 85 72 86 /* New posts */ 73 87 jq("#aw-whats-new-submit").on( 'click', function() { 74 var button = jq(this);88 var last_displayed_id, button = jq(this); 75 89 var form = button.closest("form#whats-new-form"); 76 90 77 91 form.children().each( function() { … … jq(document).ready( function() { 89 103 var object = ''; 90 104 var item_id = jq("#whats-new-post-in").val(); 91 105 var content = jq("#whats-new").val(); 106 var firstrow = jq( '#buddypress ul.activity-list li' ).first(); 107 108 if ( firstrow.hasClass( 'load-newest' ) ) { 109 last_displayed_id = firstrow.next().prop( 'id' ).replace( 'activity-','' ); 110 } else { 111 last_displayed_id = firstrow.prop( 'id' ).replace( 'activity-','' ); 112 } 92 113 93 114 /* Set object for non-profile posts */ 94 115 if ( item_id > 0 ) { … … jq(document).ready( function() { 102 123 'content': content, 103 124 'object': object, 104 125 'item_id': item_id, 126 'id': last_displayed_id, 105 127 '_bp_as_nonce': jq('#_bp_as_nonce').val() || '' 106 128 }, 107 129 function(response) { … … jq(document).ready( function() { 123 145 jq("div.activity").append( '<ul id="activity-stream" class="activity-list item-list">' ); 124 146 } 125 147 148 if ( firstrow.hasClass( 'load-newest' ) ) 149 firstrow.remove(); 150 126 151 jq("#activity-stream").prepend(response); 127 jq("#activity-stream li:first").addClass('new-update just-posted'); 152 153 if ( ! last_displayed_id ) 154 jq("#activity-stream li:first").addClass('new-update just-posted'); 128 155 129 156 if ( 0 != jq("#latest-update").length ) { 130 157 var l = jq("#activity-stream li.new-update .activity-content .activity-inner p").html(); … … jq(document).ready( function() { 351 378 352 379 return false; 353 380 } 381 382 /* Load newest updates at the top of the list */ 383 if ( target.parent().hasClass('load-newest') ) { 384 385 event.preventDefault(); 386 last_displayed_id = target.parent().next().prop( 'id' ).replace( 'activity-','' ); 387 388 jq( '#buddypress li.load-newest' ).addClass( 'loading' ); 389 390 jq.post( ajaxurl, { 391 action: 'activity_get_newer_updates', 392 'cookie': bp_get_cookies(), 393 'page':-1, 394 'id': last_displayed_id 395 }, 396 function(response) 397 { 398 jq( '#buddypress li.load-newest' ).removeClass( 'loading' ); 399 jq( '#buddypress ul.activity-list' ).prepend( response.contents ); 400 401 target.parent().hide(); 402 }, 'json' ); 403 } 354 404 }); 355 405 356 406 // Activity "Read More" links … … jq(document).ready( function() { 1345 1395 /* if js is enabled then replace the no-js class by a js one */ 1346 1396 if( jq('body').hasClass('no-js') ) 1347 1397 jq('body').attr('class', jq('body').attr('class').replace( /no-js/,'js' ) ); 1398 1399 /* Activity HeartBeat */ 1400 jq( document ).on( 'heartbeat-send', function( e, data ) { 1401 data['bp_last_activity_update'] = { 1402 'id' : 'bp_activity_heartbeat_front', 1403 'action': jq.cookie('bp-activity-filter'), 1404 'search' : '', 1405 'scope' : jq.cookie('bp-activity-scope') 1406 } 1407 }); 1408 1409 jq(document).on( 'heartbeat-tick', function(e, data) { 1410 1411 // Only proceed if we have a last recorded date 1412 if ( ! data['last_id_recorded'] ) 1413 return; 1414 1415 // the first row is the oldest activity 1416 var firstrow = jq( '#buddypress ul.activity-list li' ).first(); 1417 1418 if ( firstrow.hasClass( 'load-newest' ) ) 1419 return; 1420 1421 var last_displayed_id = firstrow.prop( 'id' ).replace( 'activity-','' ); 1422 1423 if ( Number( data['last_id_recorded'] ) > Number( last_displayed_id ) ) { 1424 jq( '#buddypress ul.activity-list' ).prepend( '<li class="load-newest"><a href="#newest">' + BP_DTheme.newest + '</a></li>' ); 1425 } 1426 1427 }); 1348 1428 1349 1429 }); 1350 1430