BuddyPress - Version 1.2.9

Version Description

Compatibility with WordPress 3.2

Download this release

Release Info

Developer johnjamesjacoby
Plugin Icon 128x128 BuddyPress
Version 1.2.9
Comparing to
See all releases

Code changes from version 1.2.7 to 1.2.9

Files changed (68) hide show
  1. bp-activity.php +10 -9
  2. bp-activity/bp-activity-classes.php +9 -3
  3. bp-activity/bp-activity-templatetags.php +1 -1
  4. bp-blogs.php +1 -1
  5. bp-core.php +7 -3
  6. bp-core/bp-core-admin.php +9 -9
  7. bp-core/bp-core-adminbar.php +37 -13
  8. bp-core/bp-core-avatars.php +2 -2
  9. bp-core/bp-core-filters.php +34 -0
  10. bp-core/bp-core-templatetags.php +36 -11
  11. bp-core/bp-core-wpabstraction.php +13 -0
  12. bp-core/images/admin_menu_icon.png +0 -0
  13. bp-forums.php +1 -1
  14. bp-forums/bbpress/bb-admin/admin-base.php +5 -1
  15. bp-forums/bbpress/bb-admin/admin.php +9 -1
  16. bp-forums/bbpress/bb-admin/includes/class.bb-install.php +3 -0
  17. bp-forums/bbpress/bb-admin/includes/defaults.bb-schema.php +43 -27
  18. bp-forums/bbpress/bb-admin/includes/functions.bb-admin.php +21 -2
  19. bp-forums/bbpress/bb-admin/includes/functions.bb-recount.php +262 -0
  20. bp-forums/bbpress/bb-admin/includes/functions.bb-upgrade.php +20 -7
  21. bp-forums/bbpress/bb-admin/index.php +22 -18
  22. bp-forums/bbpress/bb-admin/options-permalinks.php +188 -188
  23. bp-forums/bbpress/bb-admin/tools-recount.php +27 -132
  24. bp-forums/bbpress/bb-cron.php +11 -14
  25. bp-forums/bbpress/bb-includes/backpress/functions.formatting.php +6 -4
  26. bp-forums/bbpress/bb-includes/backpress/functions.kses.php +705 -64
  27. bp-forums/bbpress/bb-includes/class.bp-options.php +0 -3
  28. bp-forums/bbpress/bb-includes/functions.bb-core.php +66 -31
  29. bp-forums/bbpress/bb-includes/functions.bb-deprecated.php +5 -2
  30. bp-forums/bbpress/bb-includes/functions.bb-pluggable.php +15 -14
  31. bp-forums/bbpress/bb-includes/functions.bb-posts.php +1 -0
  32. bp-forums/bbpress/bb-includes/functions.bb-template.php +8 -9
  33. bp-forums/bbpress/bb-includes/functions.bb-users.php +78 -40
  34. bp-forums/bbpress/bb-includes/js/jquery/interface.js +12 -11
  35. bp-forums/bbpress/bb-login.php +104 -60
  36. bp-forums/bbpress/bb-templates/kakumei-blue/style.css +2 -0
  37. bp-forums/bbpress/bb-templates/kakumei/favorites.php +1 -1
  38. bp-forums/bbpress/bb-templates/kakumei/forum.php +2 -2
  39. bp-forums/bbpress/bb-templates/kakumei/front-page.php +2 -2
  40. bp-forums/bbpress/bb-templates/kakumei/post-form.php +2 -2
  41. bp-forums/bbpress/bb-templates/kakumei/style.css +16 -1
  42. bp-forums/bbpress/bb-templates/kakumei/tag-single.php +1 -1
  43. bp-forums/bbpress/bb-templates/kakumei/view.php +2 -2
  44. bp-forums/bbpress/rss.php +1 -1
  45. bp-forums/bp-forums-admin.php +8 -7
  46. bp-forums/bp-forums-bbpress.php +1 -1
  47. bp-friends.php +1 -1
  48. bp-groups.php +14 -3
  49. bp-languages/buddypress.pot +60 -62
  50. bp-loader.php +2 -3
  51. bp-messages.php +1 -1
  52. bp-messages/js/autocomplete/jquery.bgiframe.min.js +4 -8
  53. bp-messages/js/autocomplete/license.bgiframe.txt +20 -0
  54. bp-themes/bp-default/_inc/global.js +20 -18
  55. bp-themes/bp-default/style.css +1 -1
  56. bp-xprofile.php +1 -1
  57. bp-xprofile/bp-xprofile-cssjs.php +13 -4
  58. bp-xprofile/bp-xprofile-filters.php +3 -0
  59. bp-xprofile/bp-xprofile-templatetags.php +3 -3
  60. license.txt +281 -280
  61. readme.txt +11 -8
  62. screenshot-1.gif +0 -0
  63. screenshot-2.gif +0 -0
  64. screenshot-3.gif +0 -0
  65. screenshot-4.gif +0 -0
  66. screenshot-5.gif +0 -0
  67. screenshot-6.gif +0 -0
  68. screenshot-7.gif +0 -0
bp-activity.php CHANGED
@@ -98,7 +98,7 @@ function bp_activity_check_installed() {
98
if ( get_site_option( 'bp-activity-db-version' ) < BP_ACTIVITY_DB_VERSION )
99
bp_activity_install();
100
}
101
- add_action( 'admin_menu', 'bp_activity_check_installed' );
102
103
function bp_activity_setup_root_component() {
104
/* Register 'activity' as a root component (for RSS feed use) */
@@ -610,18 +610,19 @@ function bp_activity_get( $args = '' ) {
610
611
function bp_activity_get_specific( $args = '' ) {
612
$defaults = array(
613
- 'activity_ids' => false, // A single activity_id or array of IDs.
614
- 'page' => 1, // page 1 without a per_page will result in no pagination.
615
- 'per_page' => false, // results per page
616
- 'max' => false, // Maximum number of results to return
617
- 'sort' => 'DESC', // sort ASC or DESC
618
- 'display_comments' => false // true or false to display threaded comments for these specific activity items
619
);
620
621
$r = wp_parse_args( $args, $defaults );
622
extract( $r, EXTR_SKIP );
623
624
- return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get_specific( $activity_ids, $max, $page, $per_page, $sort, $display_comments ) );
625
}
626
627
function bp_activity_add( $args = '' ) {
@@ -994,7 +995,7 @@ function bp_activity_get_action( $component_id, $key ) {
994
995
function bp_activity_get_user_favorites( $user_id ) {
996
$my_favs = maybe_unserialize( get_user_meta( $user_id, 'bp_favorite_activities', true ) );
997
- $existing_favs = bp_activity_get_specific( array( 'activity_ids' => $my_favs ) );
998
999
foreach( (array)$existing_favs['activities'] as $fav )
1000
$new_favs[] = $fav->id;
98
if ( get_site_option( 'bp-activity-db-version' ) < BP_ACTIVITY_DB_VERSION )
99
bp_activity_install();
100
}
101
+ add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_activity_check_installed' );
102
103
function bp_activity_setup_root_component() {
104
/* Register 'activity' as a root component (for RSS feed use) */
610
611
function bp_activity_get_specific( $args = '' ) {
612
$defaults = array(
613
+ 'activity_ids' => false, // A single activity_id or array of IDs.
614
+ 'page' => 1, // page 1 without a per_page will result in no pagination.
615
+ 'per_page' => false, // results per page
616
+ 'max' => false, // Maximum number of results to return
617
+ 'sort' => 'DESC', // sort ASC or DESC
618
+ 'display_comments' => false, // true or false to display threaded comments for these specific activity items
619
+ 'show_hidden' => false
620
);
621
622
$r = wp_parse_args( $args, $defaults );
623
extract( $r, EXTR_SKIP );
624
625
+ return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get_specific( $activity_ids, $max, $page, $per_page, $sort, $display_comments, $show_hidden ) );
626
}
627
628
function bp_activity_add( $args = '' ) {
995
996
function bp_activity_get_user_favorites( $user_id ) {
997
$my_favs = maybe_unserialize( get_user_meta( $user_id, 'bp_favorite_activities', true ) );
998
+ $existing_favs = bp_activity_get_specific( array( 'activity_ids' => $my_favs, 'show_hidden' => true ) );
999
1000
foreach( (array)$existing_favs['activities'] as $fav )
1001
$new_favs[] = $fav->id;
bp-activity/bp-activity-classes.php CHANGED
@@ -166,7 +166,7 @@ Class BP_Activity_Activity {
166
return array( 'activities' => $activities, 'total' => (int)$total_activities );
167
}
168
169
- function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) {
170
global $wpdb, $bp;
171
172
if ( is_array( $activity_ids ) )
@@ -183,8 +183,14 @@ Class BP_Activity_Activity {
183
if ( $sort != 'ASC' && $sort != 'DESC' )
184
$sort = 'DESC';
185
186
- $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id IN ({$activity_ids}) ORDER BY date_recorded {$sort} $pag_sql" ) );
187
- $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE id IN ({$activity_ids})" ) );
188
189
if ( $display_comments )
190
$activities = BP_Activity_Activity::append_comments( $activities );
166
return array( 'activities' => $activities, 'total' => (int)$total_activities );
167
}
168
169
+ function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false, $show_hidden = false ) {
170
global $wpdb, $bp;
171
172
if ( is_array( $activity_ids ) )
183
if ( $sort != 'ASC' && $sort != 'DESC' )
184
$sort = 'DESC';
185
186
+ // Hide Hidden Items?
187
+ if ( !$show_hidden )
188
+ $hidden_sql = "AND hide_sitewide = 0";
189
+ else
190
+ $hidden_sql = '';
191
+
192
+ $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id IN ({$activity_ids}) {$hidden_sql} ORDER BY date_recorded {$sort} {$pag_sql}" ) );
193
+ $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE id IN ({$activity_ids}) {$hidden_sql}" ) );
194
195
if ( $display_comments )
196
$activities = BP_Activity_Activity::append_comments( $activities );
bp-activity/bp-activity-templatetags.php CHANGED
@@ -29,7 +29,7 @@ class BP_Activity_Template {
29
30
// Fetch specific activity items based on ID's
31
if ( !empty( $include ) )
32
- $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments ) );
33
// Fetch all activity items
34
else
35
$this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden ) );
29
30
// Fetch specific activity items based on ID's
31
if ( !empty( $include ) )
32
+ $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments, 'show_hidden' => $show_hidden ) );
33
// Fetch all activity items
34
else
35
$this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden ) );
bp-blogs.php CHANGED
@@ -60,7 +60,7 @@ function bp_blogs_check_installed() {
60
bp_blogs_install();
61
}
62
}
63
- add_action( 'admin_menu', 'bp_blogs_check_installed' );
64
65
function bp_blogs_setup_globals() {
66
global $bp, $wpdb;
60
bp_blogs_install();
61
}
62
}
63
+ add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_blogs_check_installed' );
64
65
function bp_blogs_setup_globals() {
66
global $bp, $wpdb;
bp-core.php CHANGED
@@ -284,7 +284,7 @@ function bp_core_check_installed() {
284
if ( get_site_option( 'bp-core-db-version' ) < BP_CORE_DB_VERSION )
285
bp_core_install();
286
}
287
- add_action( 'admin_menu', 'bp_core_check_installed' );
288
289
/**
290
* bp_core_add_admin_menu()
@@ -300,7 +300,11 @@ function bp_core_add_admin_menu() {
300
if ( !is_super_admin() )
301
return false;
302
303
- /* Add the administration tab under the "Site Admin" tab for site administrators */
304
bp_core_add_admin_menu_page( array(
305
'menu_title' => __( 'BuddyPress', 'buddypress' ),
306
'page_title' => __( 'BuddyPress', 'buddypress' ),
@@ -312,7 +316,7 @@ function bp_core_add_admin_menu() {
312
add_submenu_page( 'bp-general-settings', __( 'General Settings', 'buddypress'), __( 'General Settings', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_settings' );
313
add_submenu_page( 'bp-general-settings', __( 'Component Setup', 'buddypress'), __( 'Component Setup', 'buddypress' ), 'manage_options', 'bp-component-setup', 'bp_core_admin_component_setup' );
314
}
315
- add_action( 'admin_menu', 'bp_core_add_admin_menu' );
316
317
/**
318
* bp_core_is_root_component()
284
if ( get_site_option( 'bp-core-db-version' ) < BP_CORE_DB_VERSION )
285
bp_core_install();
286
}
287
+ add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_check_installed' );
288
289
/**
290
* bp_core_add_admin_menu()
300
if ( !is_super_admin() )
301
return false;
302
303
+ // If this is WP 3.1+ and multisite is enabled, only load on the Network Admin
304
+ if ( is_multisite() && function_exists( 'is_network_admin' ) && ! is_network_admin() )
305
+ return false;
306
+
307
+ // Add the administration tab under the "Site Admin" tab for site administrators
308
bp_core_add_admin_menu_page( array(
309
'menu_title' => __( 'BuddyPress', 'buddypress' ),
310
'page_title' => __( 'BuddyPress', 'buddypress' ),
316
add_submenu_page( 'bp-general-settings', __( 'General Settings', 'buddypress'), __( 'General Settings', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_settings' );
317
add_submenu_page( 'bp-general-settings', __( 'Component Setup', 'buddypress'), __( 'Component Setup', 'buddypress' ), 'manage_options', 'bp-component-setup', 'bp_core_admin_component_setup' );
318
}
319
+ add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_add_admin_menu' );
320
321
/**
322
* bp_core_is_root_component()
bp-core/bp-core-admin.php CHANGED
@@ -43,19 +43,19 @@ function bp_core_admin_settings() {
43
<tbody>
44
<?php if ( function_exists( 'xprofile_install' ) ) :?>
45
<tr>
46
- <th scope="row"><?php _e( 'Base profile group name', 'buddypress' ) ?>:</th>
47
<td>
48
<input name="bp-admin[bp-xprofile-base-group-name]" id="bp-xprofile-base-group-name" value="<?php echo get_site_option('bp-xprofile-base-group-name') ?>" />
49
</td>
50
</tr>
51
<tr>
52
- <th scope="row"><?php _e( 'Full Name field name', 'buddypress' ) ?>:</th>
53
<td>
54
<input name="bp-admin[bp-xprofile-fullname-field-name]" id="bp-xprofile-fullname-field-name" value="<?php echo get_site_option('bp-xprofile-fullname-field-name') ?>" />
55
</td>
56
</tr>
57
<tr>
58
- <th scope="row"><?php _e( 'Disable BuddyPress to WordPress profile syncing?', 'buddypress' ) ?>:</th>
59
<td>
60
<input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( (int)get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
61
<input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( !(int)get_site_option( 'bp-disable-profile-sync' ) || '' == get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
@@ -63,21 +63,21 @@ function bp_core_admin_settings() {
63
</tr>
64
<?php endif; ?>
65
<tr>
66
- <th scope="row"><?php _e( 'Hide admin bar for logged out users?', 'buddypress' ) ?>:</th>
67
<td>
68
<input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( (int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
69
<input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( !(int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
70
</td>
71
</tr>
72
<tr>
73
- <th scope="row"><?php _e( 'Disable avatar uploads? (Gravatars will still work)', 'buddypress' ) ?>:</th>
74
<td>
75
<input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( (int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
76
<input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( !(int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
77
</td>
78
</tr>
79
<tr>
80
- <th scope="row"><?php _e( 'Disable user account deletion?', 'buddypress' ) ?>:</th>
81
<td>
82
<input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( (int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
83
<input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( !(int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
@@ -85,7 +85,7 @@ function bp_core_admin_settings() {
85
</tr>
86
<?php if ( function_exists( 'bp_forums_setup') ) : ?>
87
<tr>
88
- <th scope="row"><?php _e( 'Disable global forum directory?', 'buddypress' ) ?>:</th>
89
<td>
90
<input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( (int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
91
<input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( !(int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
@@ -94,7 +94,7 @@ function bp_core_admin_settings() {
94
<?php endif; ?>
95
<?php if ( function_exists( 'bp_activity_install') ) : ?>
96
<tr>
97
- <th scope="row"><?php _e( 'Disable activity stream commenting on blog and forum posts?', 'buddypress' ) ?>:</th>
98
<td>
99
<input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( (int)get_site_option( 'bp-disable-blogforum-comments' ) || false === get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
100
<input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( !(int)get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
@@ -103,7 +103,7 @@ function bp_core_admin_settings() {
103
<?php endif; ?>
104
105
<tr>
106
- <th scope="row"><?php _e( 'Default User Avatar', 'buddypress' ) ?></th>
107
<td>
108
<p><?php _e( 'For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their email address', 'buddypress' ) ?></p>
109
43
<tbody>
44
<?php if ( function_exists( 'xprofile_install' ) ) :?>
45
<tr>
46
+ <th scope="row"><p><?php _e( 'Base profile group name', 'buddypress' ) ?>:</p></th>
47
<td>
48
<input name="bp-admin[bp-xprofile-base-group-name]" id="bp-xprofile-base-group-name" value="<?php echo get_site_option('bp-xprofile-base-group-name') ?>" />
49
</td>
50
</tr>
51
<tr>
52
+ <th scope="row"><p><?php _e( 'Full Name field name', 'buddypress' ) ?>:</p></th>
53
<td>
54
<input name="bp-admin[bp-xprofile-fullname-field-name]" id="bp-xprofile-fullname-field-name" value="<?php echo get_site_option('bp-xprofile-fullname-field-name') ?>" />
55
</td>
56
</tr>
57
<tr>
58
+ <th scope="row"><p><?php _e( 'Disable BuddyPress to WordPress profile syncing?', 'buddypress' ) ?>:</p></th>
59
<td>
60
<input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( (int)get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
61
<input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( !(int)get_site_option( 'bp-disable-profile-sync' ) || '' == get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
63
</tr>
64
<?php endif; ?>
65
<tr>
66
+ <th scope="row"><p><?php _e( 'Hide admin bar for logged out users?', 'buddypress' ) ?>:</p></th>
67
<td>
68
<input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( (int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
69
<input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( !(int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
70
</td>
71
</tr>
72
<tr>
73
+ <th scope="row"><p><?php _e( 'Disable avatar uploads? (Gravatars will still work)', 'buddypress' ) ?>:</p></th>
74
<td>
75
<input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( (int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
76
<input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( !(int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
77
</td>
78
</tr>
79
<tr>
80
+ <th scope="row"><p><?php _e( 'Disable user account deletion?', 'buddypress' ) ?>:</p></th>
81
<td>
82
<input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( (int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
83
<input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( !(int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
85
</tr>
86
<?php if ( function_exists( 'bp_forums_setup') ) : ?>
87
<tr>
88
+ <th scope="row"><p><?php _e( 'Disable global forum directory?', 'buddypress' ) ?>:</p></th>
89
<td>
90
<input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( (int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
91
<input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( !(int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
94
<?php endif; ?>
95
<?php if ( function_exists( 'bp_activity_install') ) : ?>
96
<tr>
97
+ <th scope="row"><p><?php _e( 'Disable activity stream commenting on blog and forum posts?', 'buddypress' ) ?>:</p></th>
98
<td>
99
<input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( (int)get_site_option( 'bp-disable-blogforum-comments' ) || false === get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
100
<input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( !(int)get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
103
<?php endif; ?>
104
105
<tr>
106
+ <th scope="row"><p><?php _e( 'Default User Avatar', 'buddypress' ) ?></p></th>
107
<td>
108
<p><?php _e( 'For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their email address', 'buddypress' ) ?></p>
109
bp-core/bp-core-adminbar.php CHANGED
@@ -273,18 +273,42 @@ function bp_adminbar_random_menu() {
273
<?php
274
}
275
276
- // Actions used to build the admin bar
277
- add_action( 'bp_adminbar_logo', 'bp_adminbar_logo' );
278
- add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu', 2 );
279
- add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
280
- add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6 );
281
- add_action( 'bp_adminbar_menus', 'bp_adminbar_thisblog_menu', 6 );
282
- add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );
283
- add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
284
- add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );
285
-
286
- // Actions used to append admin bar to footer
287
- add_action( 'wp_footer', 'bp_core_admin_bar', 8 );
288
- add_action( 'admin_footer', 'bp_core_admin_bar' );
289
290
?>
273
<?php
274
}
275
276
+ /**
277
+ * Provides fallback support for the WordPress 3.1 admin bar
278
+ *
279
+ * By default, this function turns off the WP 3.1 admin bar in favor of the classic BP BuddyBar.
280
+ * To turn off the BP BuddyBar in favor of WP's admin bar, place the following in wp-config.php:
281
+ * define( 'BP_USE_WP_ADMIN_BAR', true );
282
+ *
283
+ * @package BuddyPress Core
284
+ * @since 1.2.8
285
+ */
286
+ function bp_core_load_admin_bar() {
287
+ global $wp_version;
288
+
289
+ if ( defined( 'BP_USE_WP_ADMIN_BAR' ) && BP_USE_WP_ADMIN_BAR && version_compare( $wp_version, 3.1, '>=' ) ) {
290
+ // TODO: Add BP support to WP admin bar
291
+ return;
292
+ } elseif ( !defined( 'BP_DISABLE_ADMIN_BAR' ) || !BP_DISABLE_ADMIN_BAR ) {
293
+ // Keep the WP admin bar from loading
294
+ if ( function_exists( 'show_admin_bar' ) )
295
+ show_admin_bar( false );
296
+
297
+ // Actions used to build the BP admin bar
298
+ add_action( 'bp_adminbar_logo', 'bp_adminbar_logo' );
299
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu', 2 );
300
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
301
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6 );
302
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_thisblog_menu', 6 );
303
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );
304
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
305
+ add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );
306
+
307
+ // Actions used to append BP admin bar to footer
308
+ add_action( 'wp_footer', 'bp_core_admin_bar', 8 );
309
+ add_action( 'admin_footer', 'bp_core_admin_bar' );
310
+ }
311
+ }
312
+ add_action( 'bp_loaded', 'bp_core_load_admin_bar' );
313
314
?>
bp-core/bp-core-avatars.php CHANGED
@@ -522,7 +522,7 @@ function bp_core_check_avatar_size($file) {
522
}
523
524
function bp_core_check_avatar_type($file) {
525
- if ( ( strlen($file['file']['type']) && !preg_match('/(jpe?g|gif|png)#x2F;', $file['file']['type'] ) ) && !preg_match( '/(jpe?g|gif|png)#x2F;', $file['file']['name'] ) )
526
return false;
527
528
return true;
@@ -567,7 +567,7 @@ function bp_core_avatar_url() {
567
568
// If multisite, and current blog does not match root blog, make adjustments
569
if ( bp_core_is_multisite() && BP_ROOT_BLOG != $current_blog->blog_id )
570
- $upload_dir['baseurl'] = str_replace( get_blog_option( $current_blog->blog_id, 'home' ) , get_blog_option( BP_ROOT_BLOG, 'home' ), $upload_dir['baseurl'] );
571
572
return apply_filters( 'bp_core_avatar_url', $upload_dir['baseurl'] );
573
}
522
}
523
524
function bp_core_check_avatar_type($file) {
525
+ if ( ( !empty( $file['file']['type'] ) && !preg_match('/(jpe?g|gif|png)#x2F;', $file['file']['type'] ) ) || !preg_match( '/(jpe?g|gif|png)#x2F;', $file['file']['name'] ) )
526
return false;
527
528
return true;
567
568
// If multisite, and current blog does not match root blog, make adjustments
569
if ( bp_core_is_multisite() && BP_ROOT_BLOG != $current_blog->blog_id )
570
+ $upload_dir['baseurl'] = trailingslashit( get_blog_option( BP_ROOT_BLOG, 'home' ) ) . get_blog_option( BP_ROOT_BLOG, 'upload_path' );
571
572
return apply_filters( 'bp_core_avatar_url', $upload_dir['baseurl'] );
573
}
bp-core/bp-core-filters.php CHANGED
@@ -1,5 +1,39 @@
1
<?php
2
3
/**
4
* bp_core_email_from_name_filter()
5
*
1
<?php
2
3
+ /**
4
+ * Load additional sign-up sanitization filters on bp_loaded. These are used
5
+ * to prevent XSS in the BuddyPress sign-up process. You can unhook these to
6
+ * allow for customization of your registration fields, however it is highly
7
+ * recommended that you leave these in place for the safety of your network.
8
+ *
9
+ * @since BuddyPress (r4079)
10
+ * @uses add_filter()
11
+ */
12
+ function bp_core_signup_sanitization() {
13
+
14
+ // Filters on sign-up fields
15
+ $fields = array (
16
+ 'bp_get_signup_username_value',
17
+ 'bp_get_signup_email_value',
18
+ 'bp_get_signup_with_blog_value',
19
+ 'bp_get_signup_blog_url_value',
20
+ 'bp_get_signup_blog_title_value',
21
+ 'bp_get_signup_blog_privacy_value',
22
+ 'bp_get_signup_avatar_dir_value',
23
+ );
24
+
25
+ // Add the 'strip_tags' filter to each field
26
+ foreach( $fields as $filter ) {
27
+ add_filter( $filter, 'esc_html', 1 );
28
+ add_filter( $filter, 'wp_filter_kses', 2 );
29
+ add_filter( $filter, 'stripslashes', 3 );
30
+ }
31
+
32
+ // Sanitize email
33
+ add_filter( 'bp_get_signup_email_value', 'sanitize_email' );
34
+ }
35
+ add_action( 'bp_loaded', 'bp_core_signup_sanitization' );
36
+
37
/**
38
* bp_core_email_from_name_filter()
39
*
bp-core/bp-core-templatetags.php CHANGED
@@ -1189,6 +1189,18 @@ function bp_signup_avatar_dir_value() {
1189
function bp_get_signup_avatar_dir_value() {
1190
global $bp;
1191
1192
return apply_filters( 'bp_get_signup_avatar_dir_value', $bp->signup->avatar_dir );
1193
}
1194
@@ -1216,24 +1228,37 @@ function bp_signup_avatar( $args = '' ) {
1216
$r = wp_parse_args( $args, $defaults );
1217
extract( $r, EXTR_SKIP );
1218
1219
- $signup_avatar_dir = ( !empty( $_POST['signup_avatar_dir'] ) ) ? $_POST['signup_avatar_dir'] : $bp->signup->avatar_dir;
1220
1221
- if ( empty( $signup_avatar_dir ) ) {
1222
- if ( empty( $bp->grav_default->user ) ) {
1223
$default_grav = 'wavatar';
1224
- } else if ( 'mystery' == $bp->grav_default->user ) {
1225
$default_grav = BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg';
1226
- } else {
1227
$default_grav = $bp->grav_default->user;
1228
- }
1229
1230
- $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' );
1231
- $gravatar_img = '<img src="' . $gravatar_url . md5( strtolower( $_POST['signup_email'] ) ) . '?d=' . $default_grav . '&amp;s=' . $size . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';
1232
- } else {
1233
- $gravatar_img = bp_core_fetch_avatar( array( 'item_id' => $signup_avatar_dir, 'object' => 'signup', 'avatar_dir' => 'avatars/signups', 'type' => 'full', 'width' => $size, 'height' => $size, 'alt' => $alt, 'class' => $class ) );
1234
}
1235
1236
- return apply_filters( 'bp_get_signup_avatar', $gravatar_img );
1237
}
1238
1239
function bp_signup_allowed() {
1189
function bp_get_signup_avatar_dir_value() {
1190
global $bp;
1191
1192
+ // Check if signup_avatar_dir is passed
1193
+ if ( !empty( $_POST['signup_avatar_dir'] ) )
1194
+ $signup_avatar_dir = $_POST['signup_avatar_dir'];
1195
+
1196
+ // If not, check if global is set
1197
+ elseif ( !empty( $bp->signup->avatar_dir ) )
1198
+ $signup_avatar_dir = $bp->signup->avatar_dir;
1199
+
1200
+ // If not, set false
1201
+ else
1202
+ $signup_avatar_dir = false;
1203
+
1204
return apply_filters( 'bp_get_signup_avatar_dir_value', $bp->signup->avatar_dir );
1205
}
1206
1228
$r = wp_parse_args( $args, $defaults );
1229
extract( $r, EXTR_SKIP );
1230
1231
+ // Avatar DIR is found
1232
+ if ( $signup_avatar_dir = bp_get_signup_avatar_dir_value() ) {
1233
+ $gravatar_img = bp_core_fetch_avatar( array(
1234
+ 'item_id' => $signup_avatar_dir,
1235
+ 'object' => 'signup',
1236
+ 'avatar_dir' => 'avatars/signups',
1237
+ 'type' => 'full',
1238
+ 'width' => $size,
1239
+ 'height' => $size,
1240
+ 'alt' => $alt,
1241
+ 'class' => $class
1242
+ ) );
1243
1244
+ // No avatar DIR was found
1245
+ } else {
1246
+
1247
+ // Set default gravatar type
1248
+ if ( empty( $bp->grav_default->user ) )
1249
$default_grav = 'wavatar';
1250
+ else if ( 'mystery' == $bp->grav_default->user )
1251
$default_grav = BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg';
1252
+ else
1253
$default_grav = $bp->grav_default->user;
1254
1255
+ // Create
1256
+ $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' );
1257
+ $md5_lcase_email = md5( strtolower( bp_get_signup_email_value() ) );
1258
+ $gravatar_img = '<img src="' . $gravatar_url . $md5_lcase_email . '?d=' . $default_grav . '&amp;s=' . $size . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';
1259
}
1260
1261
+ return apply_filters( 'bp_get_signup_avatar', $gravatar_img, $args );
1262
}
1263
1264
function bp_signup_allowed() {
bp-core/bp-core-wpabstraction.php CHANGED
@@ -112,4 +112,17 @@ if ( !function_exists( 'is_site_admin' ) ) {
112
}
113
}
114
115
?>
112
}
113
}
114
115
+ // Added for WordPress 3.1 support
116
+ if ( !function_exists( 'get_dashboard_url' ) ) {
117
+
118
+ /**
119
+ * Make sure the 'network_admin_menu' hook (which is new to 3.1) fires
120
+ * on our reliable friend 'admin_menu'
121
+ */
122
+ function bp_network_admin_menu() {
123
+ do_action( 'network_admin_menu' );
124
+ }
125
+ add_action( 'admin_menu', 'bp_network_admin_menu' );
126
+ }
127
+
128
?>
bp-core/images/admin_menu_icon.png CHANGED
Binary file
bp-forums.php CHANGED
@@ -102,7 +102,7 @@ function bp_forums_add_admin_menu() {
102
/* Add the administration tab under the "Site Admin" tab for site administrators */
103
add_submenu_page( 'bp-general-settings', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" );
104
}
105
- add_action( 'admin_menu', 'bp_forums_add_admin_menu' );
106
107
/* Forum Functions */
108
102
/* Add the administration tab under the "Site Admin" tab for site administrators */
103
add_submenu_page( 'bp-general-settings', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" );
104
}
105
+ add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_forums_add_admin_menu' );
106
107
/* Forum Functions */
108
bp-forums/bbpress/bb-admin/admin-base.php CHANGED
@@ -10,7 +10,11 @@ bb_get_admin_header();
10
11
<?php if ( is_callable($bb_admin_page) ) : call_user_func( $bb_admin_page ); else : ?>
12
13
- <p><?php _e('Nothing to see here.'); ?><p>
14
15
<?php endif; ?>
16
10
11
<?php if ( is_callable($bb_admin_page) ) : call_user_func( $bb_admin_page ); else : ?>
12
13
+ <h2><?php _e( 'Page not found' ); ?></h2>
14
+ <?php
15
+ bb_admin_notice( __( 'There is no administration page at the requested address. Please check the address you entered and try again.' ), 'error' );
16
+ do_action( 'bb_admin_notices' );
17
+ ?>
18
19
<?php endif; ?>
20
bp-forums/bbpress/bb-admin/admin.php CHANGED
@@ -16,8 +16,10 @@ require_once( BB_PATH . 'bb-admin/includes/functions.bb-admin.php' );
16
17
$bb_admin_page = bb_find_filename( $_SERVER['PHP_SELF'] );
18
19
if ( $bb_admin_page == 'admin-base.php' ) {
20
- $bb_admin_page = $_GET['plugin'];
21
}
22
23
wp_enqueue_script( 'common' );
@@ -34,4 +36,10 @@ if ( isset( $_GET['foldmenu'] ) ) {
34
}
35
bb_admin_menu_generator();
36
bb_get_current_admin_menu();
37
?>
16
17
$bb_admin_page = bb_find_filename( $_SERVER['PHP_SELF'] );
18
19
+ $_check_callback = false;
20
if ( $bb_admin_page == 'admin-base.php' ) {
21
+ $bb_admin_page = (string) @$_GET['plugin'];
22
+ $_check_callback = true;
23
}
24
25
wp_enqueue_script( 'common' );
36
}
37
bb_admin_menu_generator();
38
bb_get_current_admin_menu();
39
+
40
+ if ( $_check_callback ) {
41
+ if ( empty( $bb_registered_plugin_callbacks ) || empty( $bb_admin_page ) || !in_array( $bb_admin_page, $bb_registered_plugin_callbacks ) ) {
42
+ unset( $bb_admin_page );
43
+ }
44
+ }
45
?>
bp-forums/bbpress/bb-admin/includes/class.bb-install.php CHANGED
@@ -309,6 +309,9 @@ class BB_Install
309
function get_languages()
310
{
311
foreach ( bb_glob( BB_LANG_DIR . '*.mo' ) as $language ) {
312
$language = str_replace( '.mo', '', basename( $language ) );
313
$this->languages[$language] = $language;
314
}
309
function get_languages()
310
{
311
foreach ( bb_glob( BB_LANG_DIR . '*.mo' ) as $language ) {
312
+ if ( substr( $language, 0, 18 ) === 'continents-cities-' ) {
313
+ continue;
314
+ }
315
$language = str_replace( '.mo', '', basename( $language ) );
316
$this->languages[$language] = $language;
317
}
bp-forums/bbpress/bb-admin/includes/defaults.bb-schema.php CHANGED
@@ -113,33 +113,37 @@ $bb_queries['topics'] = "CREATE TABLE IF NOT EXISTS `$bbdb->topics` (
113
KEY `stickies` (`topic_status`, `topic_sticky`, `topic_time`)
114
);";
115
116
- // users - 'user_login', 'user_nicename' and 'user_registered' indices are inconsistent with WordPress
117
- $bb_queries['users'] = "CREATE TABLE IF NOT EXISTS `$bbdb->users` (
118
- `ID` bigint(20) unsigned NOT NULL auto_increment,
119
- `user_login` varchar(60) NOT NULL default '',
120
- `user_pass` varchar(64) NOT NULL default '',
121
- `user_nicename` varchar(50) NOT NULL default '',
122
- `user_email` varchar(100) NOT NULL default '',
123
- `user_url` varchar(100) NOT NULL default '',
124
- `user_registered` datetime NOT NULL default '0000-00-00 00:00:00',
125
- `user_status` int(11) NOT NULL default 0,
126
- `display_name` varchar(250) NOT NULL default '',
127
- PRIMARY KEY (`ID`),
128
- UNIQUE KEY `user_login` (`user_login`),
129
- UNIQUE KEY `user_nicename` (`user_nicename`),
130
- KEY `user_registered` (`user_registered`)
131
- );";
132
-
133
- // usermeta
134
- $bb_queries['usermeta'] = "CREATE TABLE IF NOT EXISTS `$bbdb->usermeta` (
135
- `umeta_id` bigint(20) NOT NULL auto_increment,
136
- `user_id` bigint(20) NOT NULL default 0,
137
- `meta_key` varchar(255),
138
- `meta_value` longtext,
139
- PRIMARY KEY (`umeta_id`),
140
- KEY `user_id` (`user_id`),
141
- KEY `meta_key` (`meta_key`)
142
- );";
143
144
$bb_queries = apply_filters( 'bb_schema_pre_charset', $bb_queries );
145
@@ -212,6 +216,18 @@ if ( bb_get_option('wp_table_prefix') || ( defined( 'BB_SCHEMA_IGNORE_WP_USERS_K
212
$bb_schema_ignore = false;
213
}
214
215
$bb_schema_ignore = apply_filters( 'bb_schema_ignore', $bb_schema_ignore );
216
217
do_action( 'bb_schema_defined' );
113
KEY `stickies` (`topic_status`, `topic_sticky`, `topic_time`)
114
);";
115
116
+ if ( bb_get_option( 'wp_table_prefix' ) || ( defined( 'BB_SCHEMA_IGNORE_WP_USERS_TABLES' ) && BB_SCHEMA_IGNORE_WP_USERS_TABLES ) ) {
117
+ // Don't add user tables
118
+ } else {
119
+ // users - 'user_login', 'user_nicename' and 'user_registered' indices are inconsistent with WordPress
120
+ $bb_queries['users'] = "CREATE TABLE IF NOT EXISTS `$bbdb->users` (
121
+ `ID` bigint(20) unsigned NOT NULL auto_increment,
122
+ `user_login` varchar(60) NOT NULL default '',
123
+ `user_pass` varchar(64) NOT NULL default '',
124
+ `user_nicename` varchar(50) NOT NULL default '',
125
+ `user_email` varchar(100) NOT NULL default '',
126
+ `user_url` varchar(100) NOT NULL default '',
127
+ `user_registered` datetime NOT NULL default '0000-00-00 00:00:00',
128
+ `user_status` int(11) NOT NULL default 0,
129
+ `display_name` varchar(250) NOT NULL default '',
130
+ PRIMARY KEY (`ID`),
131
+ UNIQUE KEY `user_login` (`user_login`),
132
+ UNIQUE KEY `user_nicename` (`user_nicename`),
133
+ KEY `user_registered` (`user_registered`)
134
+ );";
135
+
136
+ // usermeta
137
+ $bb_queries['usermeta'] = "CREATE TABLE IF NOT EXISTS `$bbdb->usermeta` (
138
+ `umeta_id` bigint(20) NOT NULL auto_increment,
139
+ `user_id` bigint(20) NOT NULL default 0,
140
+ `meta_key` varchar(255),
141
+ `meta_value` longtext,
142
+ PRIMARY KEY (`umeta_id`),
143
+ KEY `user_id` (`user_id`),
144
+ KEY `meta_key` (`meta_key`)
145
+ );";
146
+ }
147
148
$bb_queries = apply_filters( 'bb_schema_pre_charset', $bb_queries );
149
216
$bb_schema_ignore = false;
217
}
218
219
+ if ( bb_get_option('wp_table_prefix') || ( defined( 'BB_SCHEMA_IGNORE_WP_USERS_TABLES' ) && BB_SCHEMA_IGNORE_WP_USERS_TABLES ) ) {
220
+ if ( $bb_schema_ignore ) {
221
+ $bb_schema_ignore['tables'] = array( $bbdb->users, $bbdb->usermeta );
222
+ } else {
223
+ $bb_schema_ignore = array(
224
+ 'tables' => array( $bbdb->users, $bbdb->usermeta ),
225
+ 'columns' => array(),
226
+ 'indices' => array()
227
+ );
228
+ }
229
+ }
230
+
231
$bb_schema_ignore = apply_filters( 'bb_schema_ignore', $bb_schema_ignore );
232
233
do_action( 'bb_schema_defined' );
bp-forums/bbpress/bb-admin/includes/functions.bb-admin.php CHANGED
@@ -117,6 +117,10 @@ function bb_admin_menu_generator()
117
function bb_admin_add_menu( $display_name, $capability, $file_name, $menu_position = false, $class = '', $id = '' )
118
{
119
global $bb_menu;
120
121
if ( $display_name && $capability && $file_name ) {
122
// Get an array of the keys
@@ -164,6 +168,10 @@ function bb_admin_add_menu( $display_name, $capability, $file_name, $menu_positi
164
$plugin_menu_next++;
165
}
166
167
// Add the menu item at the given key
168
$bb_menu[$plugin_menu_next] = array( $display_name, $capability, $file_name, $class, $id );
169
@@ -178,7 +186,15 @@ function bb_admin_add_menu( $display_name, $capability, $file_name, $menu_positi
178
function bb_admin_add_submenu( $display_name, $capability, $file_name, $parent = 'plugins.php' )
179
{
180
global $bb_submenu;
181
if ( $display_name && $capability && $file_name ) {
182
$bb_submenu[$parent][] = array( $display_name, $capability, $file_name );
183
ksort( $bb_submenu );
184
}
@@ -397,10 +413,13 @@ function bb_get_ids_by_role( $role = 'moderator', $sort = 0, $page = 1, $limit =
397
398
function bb_user_row( $user, $role = '', $email = false ) {
399
$actions = "<a href='" . esc_attr( get_user_profile_link( $user->ID ) ) . "'>" . __('View') . "</a>";
400
- if ( bb_current_user_can( 'edit_user', $user_id ) )
401
$actions .= " | <a href='" . esc_attr( get_profile_tab_link( $user->ID, 'edit' ) ) . "'>" . __('Edit') . "</a>";
402
$r = "\t<tr id='user-$user->ID'" . get_alt_class("user-$role") . ">\n";
403
- $r .= "\t\t<td class=\"user\">" . bb_get_avatar( $user->ID, 32 ) . "<span class=\"row-title\"><a href='" . get_user_profile_link( $user->ID ) . "'>" . get_user_name( $user->ID ) . "</a></span><div><span class=\"row-actions\">$actions</span>&nbsp;</div></td>\n";
404
$r .= "\t\t<td><a href='" . get_user_profile_link( $user->ID ) . "'>" . get_user_display_name( $user->ID ) . "</a></td>\n";
405
if ( $email ) {
406
$email = bb_get_user_email( $user->ID );
117
function bb_admin_add_menu( $display_name, $capability, $file_name, $menu_position = false, $class = '', $id = '' )
118
{
119
global $bb_menu;
120
+ global $bb_registered_plugin_callbacks;
121
+ if ( empty( $bb_registered_plugin_callbacks ) ) {
122
+ $bb_registered_plugin_callbacks = array();
123
+ }
124
125
if ( $display_name && $capability && $file_name ) {
126
// Get an array of the keys
168
$plugin_menu_next++;
169
}
170
171
+ if ( strpos( $file_name, '.php' ) === false ) {
172
+ $bb_registered_plugin_callbacks[] = $file_name;
173
+ }
174
+
175
// Add the menu item at the given key
176
$bb_menu[$plugin_menu_next] = array( $display_name, $capability, $file_name, $class, $id );
177
186
function bb_admin_add_submenu( $display_name, $capability, $file_name, $parent = 'plugins.php' )
187
{
188
global $bb_submenu;
189
+ global $bb_registered_plugin_callbacks;
190
+ if ( empty( $bb_registered_plugin_callbacks ) ) {
191
+ $bb_registered_plugin_callbacks = array();
192
+ }
193
+
194
if ( $display_name && $capability && $file_name ) {
195
+ if ( strpos( $file_name, '.php' ) === false ) {
196
+ $bb_registered_plugin_callbacks[] = $file_name;
197
+ }
198
$bb_submenu[$parent][] = array( $display_name, $capability, $file_name );
199
ksort( $bb_submenu );
200
}
413
414
function bb_user_row( $user, $role = '', $email = false ) {
415
$actions = "<a href='" . esc_attr( get_user_profile_link( $user->ID ) ) . "'>" . __('View') . "</a>";
416
+ $title = '';
417
+ if ( bb_current_user_can( 'edit_user', $user_id ) ) {
418
$actions .= " | <a href='" . esc_attr( get_profile_tab_link( $user->ID, 'edit' ) ) . "'>" . __('Edit') . "</a>";
419
+ $title = " title='" . esc_attr( sprintf( __( 'User ID: %d' ), $user->ID ) ) . "'";
420
+ }
421
$r = "\t<tr id='user-$user->ID'" . get_alt_class("user-$role") . ">\n";
422
+ $r .= "\t\t<td class=\"user\">" . bb_get_avatar( $user->ID, 32 ) . "<span class=\"row-title\"><a href='" . get_user_profile_link( $user->ID ) . "'" . $title . ">" . get_user_name( $user->ID ) . "</a></span><div><span class=\"row-actions\">$actions</span>&nbsp;</div></td>\n";
423
$r .= "\t\t<td><a href='" . get_user_profile_link( $user->ID ) . "'>" . get_user_display_name( $user->ID ) . "</a></td>\n";
424
if ( $email ) {
425
$email = bb_get_user_email( $user->ID );
bp-forums/bbpress/bb-admin/includes/functions.bb-recount.php ADDED
@@ -0,0 +1,262 @@
1
+ <?php
2
+
3
+ function bb_recount_topic_posts()
4
+ {
5
+ global $bbdb;
6
+
7
+ $statement = __( 'Counting the number of posts in each topic&hellip; %s' );
8
+ $result = __( 'Failed!' );
9
+
10
+ $sql = "INSERT INTO `$bbdb->topics` (`topic_id`, `topic_posts`) (SELECT `topic_id`, COUNT(`post_status`) as `topic_posts` FROM `$bbdb->posts` WHERE `post_status` = '0' GROUP BY `topic_id`) ON DUPLICATE KEY UPDATE `topic_posts` = VALUES(`topic_posts`);";
11
+ if ( is_wp_error( $bbdb->query( $sql ) ) ) {
12
+ return sprintf( $statement, $result );
13
+ }
14
+
15
+ $result = __( 'Complete!' );
16
+ return sprintf( $statement, $result );
17
+ }
18
+
19
+ function bb_recount_topic_voices()
20
+ {
21
+ global $bbdb;
22
+
23
+ $statement = __( 'Counting the number of voices in each topic&hellip; %s' );
24
+ $result = __( 'Failed!' );
25
+
26
+ $sql_delete = "DELETE FROM `$bbdb->meta` WHERE `object_type` = 'bb_topic' AND `meta_key` = 'voices_count';";
27
+ if ( is_wp_error( $bbdb->query( $sql_delete ) ) ) {
28
+ return sprintf( $statement, $result );
29
+ }
30
+
31
+ $sql = "INSERT INTO `$bbdb->meta` (`object_type`, `object_id`, `meta_key`, `meta_value`) (SELECT 'bb_topic', `topic_id`, 'voices_count', COUNT(DISTINCT `poster_id`) as `meta_value` FROM `$bbdb->posts` WHERE `post_status` = '0' GROUP BY `topic_id`);";
32
+ if ( is_wp_error( $bbdb->query( $sql ) ) ) {
33
+ return sprintf( $statement, $result );
34
+ }
35
+
36
+ $result = __( 'Complete!' );
37
+ return sprintf( $statement, $result );
38
+ }
39
+
40
+ function bb_recount_topic_deleted_posts()
41
+ {
42
+ global $bbdb;
43
+
44
+ $statement = __( 'Counting the number of deleted posts in each topic&hellip; %s' );
45
+ $result = __( 'Failed!' );
46
+
47
+ $sql_delete = "DELETE FROM `$bbdb->meta` WHERE `object_type` = 'bb_topic' AND `meta_key` = 'deleted_posts';";
48
+ if ( is_wp_error( $bbdb->query( $sql_delete ) ) ) {
49
+ return sprintf( $statement, $result );
50
+ }
51
+
52
+ $sql = "INSERT INTO `$bbdb->meta` (`object_type`, `object_id`, `meta_key`, `meta_value`) (SELECT 'bb_topic', `topic_id`, 'deleted_posts', COUNT(`post_status`) as `meta_value` FROM `$bbdb->posts` WHERE `post_status` != '0' GROUP BY `topic_id`);";
53
+ if ( is_wp_error( $bbdb->query( $sql ) ) ) {
54
+ return sprintf( $statement, $result );
55
+ }
56
+
57
+ $result = __( 'Complete!' );
58
+ return sprintf( $statement, $result );
59
+ }
60
+
61
+ function bb_recount_forum_topics()
62
+ {
63
+ global $bbdb;
64
+
65
+ $statement = __( 'Counting the number of topics in each forum&hellip; %s' );
66
+ $result = __( 'Failed!' );
67
+
68
+ $sql = "INSERT INTO `$bbdb->forums` (`forum_id`, `topics`) (SELECT `forum_id`, COUNT(`topic_status`) as `topics` FROM `$bbdb->topics` WHERE `topic_status` = '0' GROUP BY `forum_id`) ON DUPLICATE KEY UPDATE `topics` = VALUES(`topics`);";
69
+ if ( is_wp_error( $bbdb->query( $sql ) ) ) {
70
+ return sprintf( $statement, $result );
71
+ }
72
+
73
+ $result = __( 'Complete!' );
74
+ return sprintf( $statement, $result );
75
+ }
76
+
77
+ function bb_recount_forum_posts()
78
+ {
79
+ global $bbdb;
80
+
81
+ $statement = __( 'Counting the number of posts in each forum&hellip; %s' );
82
+ $result = __( 'Failed!' );
83
+
84
+ $sql = "INSERT INTO `$bbdb->forums` (`forum_id`, `posts`) (SELECT `forum_id`, COUNT(`post_status`) as `posts` FROM `$bbdb->posts` WHERE `post_status` = '0' GROUP BY `forum_id`) ON DUPLICATE KEY UPDATE `posts` = VALUES(`posts`);";
85
+ if ( is_wp_error( $bbdb->query( $sql ) ) ) {
86
+ return sprintf( $statement, $result );
87
+ }
88
+
89
+ $result = __( 'Complete!' );
90
+ return sprintf( $statement, $result );
91
+ }
92
+
93
+ function bb_recount_user_topics_replied()
94
+ {
95
+ global $bbdb;
96
+
97
+ $statement = __( 'Counting the number of topics to which each user has replied&hellip; %s' );
98
+ $result = __( 'Failed!' );
99
+
100
+ $sql_select = "SELECT `poster_id`, COUNT(DISTINCT `topic_id`) as `_count` FROM `$bbdb->posts` WHERE `post_status` = '0' GROUP BY `poster_id`;";
101
+ $insert_rows = $bbdb->get_results( $sql_select );
102
+
103
+ if ( is_wp_error( $insert_rows ) ) {
104
+ return sprintf( $statement, $result );
105
+ }
106
+
107
+ $meta_key = $bbdb->prefix . 'topics_replied';
108
+
109
+ $insert_values = array();
110
+ foreach ( $insert_rows as $insert_row ) {
111
+ $insert_values[] = "('$insert_row->poster_id', '$meta_key', '$insert_row->_count')";
112
+ }
113
+
114
+ if ( !count( $insert_values ) ) {
115
+ return sprintf( $statement, $result );
116
+ }
117
+
118
+ $sql_delete = "DELETE FROM `$bbdb->usermeta` WHERE `meta_key` = '$meta_key';";
119
+ if ( is_wp_error( $bbdb->query( $sql_delete ) ) ) {
120
+ return sprintf( $statement, $result );
121
+ }
122
+
123
+ $insert_values = array_chunk( $insert_values, 10000 );
124
+ foreach ( $insert_values as $chunk ) {
125
+ $chunk = "\n" . join( ",\n", $chunk );
126
+ $sql_insert = "INSERT INTO `$bbdb->usermeta` (`user_id`, `meta_key`, `meta_value`) VALUES $chunk;";
127
+
128
+ if ( is_wp_error( $bbdb->query( $sql_insert ) ) ) {
129
+ return sprintf( $statement, $result );
130
+ }
131
+ }
132
+
133
+ $result = __( 'Complete!' );
134
+ return sprintf( $statement, $result );
135
+ }
136
+
137
+ // TODO - make fast - see #1146
138
+ function bb_recount_topic_tags()
139
+ {
140
+ // Reset tag count to zero
141
+ $bbdb->query( "UPDATE $bbdb->topics SET tag_count = 0" );
142
+
143
+ // Get all tags
144
+ $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag' );
145
+
146
+ if ( !is_wp_error( $terms ) && is_array( $terms ) ) {
147
+ $message = __('Counted topic tags');
148
+ foreach ( $terms as $term ) {
149
+ $topic_ids = bb_get_tagged_topic_ids( $term->term_id );
150
+ if ( !is_wp_error( $topic_ids ) && is_array( $topic_ids ) ) {
151
+ $bbdb->query(
152
+ "UPDATE $bbdb->topics SET tag_count = tag_count + 1 WHERE topic_id IN (" . join( ',', $topic_ids ) . ")"
153
+ );
154
+ }
155
+ unset( $topic_ids );
156
+ }
157
+ }
158
+ unset( $terms, $term );
159
+
160
+ return $message;
161
+ }
162
+
163
+ // TODO - make fast - see #1146
164
+ function bb_recount_tag_topics()
165
+ {
166
+ // Get all tags
167
+ $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag', array( 'hide_empty' => false ) );
168
+
169
+ if ( !is_wp_error( $terms ) && is_array( $terms ) ) {
170
+ $message = __('Counted tagged topics');
171
+ $_terms = array();
172
+ foreach ( $terms as $term ) {
173
+ $_terms[] = $term->term_id;
174
+ }
175
+ if ( count( $_terms ) ) {
176
+ $wp_taxonomy_object->update_term_count( $_terms, 'bb_topic_tag' );
177
+ }
178
+ }
179
+ unset( $term, $_terms );
180
+
181
+ return $message;
182
+ }
183
+
184
+ // TODO - make fast - see #1146
185
+ function bb_recount_tag_delete_empty()
186
+ {
187
+ // Get all tags
188
+ if ( !isset( $terms ) ) {
189
+ $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag', array( 'hide_empty' => false ) );
190
+ }
191
+
192
+ if ( !is_wp_error( $terms ) && is_array( $terms ) ) {
193
+ $message = __('Deleted tags with no topics');
194
+ foreach ( $terms as $term ) {
195
+ $topic_ids = bb_get_tagged_topic_ids( $term->term_id );
196
+ if ( !is_wp_error( $topic_ids ) && is_array( $topic_ids ) ) {
197
+ if ( false === $topic_ids || ( is_array( $topic_ids ) && !count( $topic_ids ) ) ) {
198
+ bb_destroy_tag( $term->term_taxonomy_id );
199
+ }
200
+ }
201
+ unset( $topic_ids );
202
+ }
203
+ }
204
+ unset( $terms, $term );
205
+
206
+ return $message;
207
+ }
208
+
209
+ function bb_recount_clean_favorites()
210
+ {
211
+ global $bbdb;
212
+
213
+ $statement = __( 'Removing deleted topics from user favorites&hellip; %s' );
214
+ $result = __( 'Failed!' );
215
+
216
+ $meta_key = $bbdb->prefix . 'favorites';
217
+
218
+ $users = $bbdb->get_results( "SELECT `user_id`, `meta_value` AS `favorites` FROM `$bbdb->usermeta` WHERE `meta_key` = '$meta_key';" );
219
+ if ( is_wp_error( $users ) ) {
220
+ return sprintf( $statement, $result );
221
+ }
222
+
223
+ $topics = $bbdb->get_col( "SELECT `topic_id` FROM `$bbdb->topics` WHERE `topic_status` = '0';" );
224
+
225
+ if ( is_wp_error( $topics ) ) {
226
+ return sprintf( $statement, $result );
227
+ }
228
+
229
+ $values = array();
230
+ foreach ( $users as $user ) {
231
+ if ( empty( $user->favorites ) || !is_string( $user->favorites ) ) {
232
+ continue;
233
+ }
234
+ $favorites = explode( ',', $user->favorites );
235
+ if ( empty( $favorites ) || !is_array( $favorites ) ) {
236
+ continue;
237
+ }
238
+ $favorites = join( ',', array_intersect( $topics, $favorites ) );
239
+ $values[] = "('$user->user_id', '$meta_key', '$favorites')";
240
+ }
241
+
242
+ if ( !count( $values ) ) {
243
+ return sprintf( $statement, $result );
244
+ }
245
+
246
+ $sql_delete = "DELETE FROM `$bbdb->usermeta` WHERE `meta_key` = '$meta_key';";
247
+ if ( is_wp_error( $bbdb->query( $sql_delete ) ) ) {
248
+ return sprintf( $statement, $result );
249
+ }
250
+
251
+ $values = array_chunk( $values, 10000 );
252
+ foreach ( $values as $chunk ) {
253
+ $chunk = "\n" . join( ",\n", $chunk );
254
+ $sql_insert = "INSERT INTO `$bbdb->usermeta` (`user_id`, `meta_key`, `meta_value`) VALUES $chunk;";
255
+ if ( is_wp_error( $bbdb->query( $sql_insert ) ) ) {
256
+ return sprintf( $statement, $result );
257
+ }
258
+ }
259
+
260
+ $result = __( 'Complete!' );
261
+ return sprintf( $statement, $result );
262
+ }
bp-forums/bbpress/bb-admin/includes/functions.bb-upgrade.php CHANGED
@@ -9,16 +9,25 @@ function bb_install() {
9
return array_filter($alterations);
10
}
11
12
- function bb_upgrade_all() {
13
- if ( !ini_get('safe_mode') )
14
set_time_limit(600);
15
16
$bb_upgrade = array();
17
18
// Pre DB Delta
19
- $bb_upgrade['messages'][] = bb_upgrade_160(); // Break blocked users
20
- $bb_upgrade['messages'][] = bb_upgrade_170(); // Escaping in usermeta
21
- $bb_upgrade['messages'][] = bb_upgrade_180(); // Delete users for real
22
$bb_upgrade['messages'][] = bb_upgrade_190(); // Move topic_resolved to topicmeta
23
$bb_upgrade['messages'][] = bb_upgrade_200(); // Indices
24
$bb_upgrade['messages'][] = bb_upgrade_210(); // Convert text slugs to varchar slugs
@@ -37,13 +46,17 @@ function bb_upgrade_all() {
37
// Post DB Delta
38
$bb_upgrade['messages'][] = bb_upgrade_1000(); // Make forum and topic slugs
39
$bb_upgrade['messages'][] = bb_upgrade_1010(); // Make sure all forums have a valid parent
40
- $bb_upgrade['messages'][] = bb_upgrade_1020(); // Add a user_nicename to existing users
41
$bb_upgrade['messages'][] = bb_upgrade_1030(); // Move admin_email option to from_email
42
$bb_upgrade['messages'][] = bb_upgrade_1040(); // Activate Akismet and bozo plugins and convert active plugins to new convention on upgrade only
43
$bb_upgrade['messages'][] = bb_upgrade_1050(); // Update active theme if present
44
$bb_upgrade['messages'][] = bb_upgrade_1070(); // trim whitespace from raw_tag
45
$bb_upgrade['messages'][] = bb_upgrade_1080(); // Convert tags to taxonomy
46
- $bb_upgrade['messages'][] = bb_upgrade_1090(); // Add display names
47
$bb_upgrade['messages'][] = bb_upgrade_1100(); // Replace forum_stickies index with stickies (#876)
48
$bb_upgrade['messages'][] = bb_upgrade_1110(); // Create plugin directory (#1083)
49
$bb_upgrade['messages'][] = bb_upgrade_1120(); // Create theme directory (#1083)
9
return array_filter($alterations);
10
}
11
12
+ function bb_upgrade_all()
13
+ {
14
+ if ( !ini_get( 'safe_mode' ) ) {
15
set_time_limit(600);
16
+ }
17
+
18
+ $_do_user_operations = true;
19
+ if ( bb_get_option( 'wp_table_prefix' ) || ( defined( 'BB_SCHEMA_IGNORE_WP_USERS_TABLES' ) && BB_SCHEMA_IGNORE_WP_USERS_TABLES ) ) {
20
+ $_do_user_operations = false;
21
+ }
22
23
$bb_upgrade = array();
24
25
// Pre DB Delta
26
+ if ( $_do_user_operations ) {
27
+ $bb_upgrade['messages'][] = bb_upgrade_160(); // Break blocked users
28
+ $bb_upgrade['messages'][] = bb_upgrade_170(); // Escaping in usermeta
29
+ $bb_upgrade['messages'][] = bb_upgrade_180(); // Delete users for real
30
+ }
31
$bb_upgrade['messages'][] = bb_upgrade_190(); // Move topic_resolved to topicmeta
32
$bb_upgrade['messages'][] = bb_upgrade_200(); // Indices
33
$bb_upgrade['messages'][] = bb_upgrade_210(); // Convert text slugs to varchar slugs
46
// Post DB Delta
47
$bb_upgrade['messages'][] = bb_upgrade_1000(); // Make forum and topic slugs
48
$bb_upgrade['messages'][] = bb_upgrade_1010(); // Make sure all forums have a valid parent
49
+ if ( $_do_user_operations ) {
50
+ $bb_upgrade['messages'][] = bb_upgrade_1020(); // Add a user_nicename to existing users
51
+ }
52
$bb_upgrade['messages'][] = bb_upgrade_1030(); // Move admin_email option to from_email
53
$bb_upgrade['messages'][] = bb_upgrade_1040(); // Activate Akismet and bozo plugins and convert active plugins to new convention on upgrade only
54
$bb_upgrade['messages'][] = bb_upgrade_1050(); // Update active theme if present
55
$bb_upgrade['messages'][] = bb_upgrade_1070(); // trim whitespace from raw_tag
56
$bb_upgrade['messages'][] = bb_upgrade_1080(); // Convert tags to taxonomy
57
+ if ( $_do_user_operations ) {
58
+ $bb_upgrade['messages'][] = bb_upgrade_1090(); // Add display names
59
+ }
60
$bb_upgrade['messages'][] = bb_upgrade_1100(); // Replace forum_stickies index with stickies (#876)
61
$bb_upgrade['messages'][] = bb_upgrade_1110(); // Create plugin directory (#1083)
62
$bb_upgrade['messages'][] = bb_upgrade_1120(); // Create theme directory (#1083)
bp-forums/bbpress/bb-admin/index.php CHANGED
@@ -29,6 +29,14 @@ $rn_users_average = sprintf(__ngettext('<span>%d</span> user', '<span>%d</span>
29
$rn_topic_tags_average = bb_get_topic_tags_per_day();
30
$rn_topic_tags_average = sprintf(__ngettext('<span>%d</span> tag', '<span>%d</span> tags', $rn_topic_tags_average), $rn_topic_tags_average);
31
32
$bb_admin_body_class = ' bb-admin-dashboard';
33
34
bb_get_admin_header();
@@ -48,28 +56,24 @@ bb_get_admin_header();
48
<th><?php _e( 'Per Day' ); ?></th>
49
</tr>
50
</thead>
51
<tbody>
52
<tr>
53
- <td><?php echo $rn_forums; ?></td>
54
- <td>-</td>
55
- </tr>
56
- <tr>
57
- <td><?php echo $rn_topics; ?></td>
58
- <td><?php echo $rn_topics_average; ?></td>
59
- </tr>
60
- <tr>
61
- <td><?php echo $rn_posts; ?></td>
62
- <td><?php echo $rn_posts_average; ?></td>
63
- </tr>
64
- <tr>
65
- <td><?php echo $rn_topic_tags; ?></td>
66
- <td><?php echo $rn_topic_tags_average; ?></td>
67
- </tr>
68
- <tr>
69
- <td><?php echo $rn_users; ?></td>
70
- <td><?php echo $rn_users_average; ?></td>
71
</tr>
72
</tbody>
73
</table>
74
</div>
75
29
$rn_topic_tags_average = bb_get_topic_tags_per_day();
30
$rn_topic_tags_average = sprintf(__ngettext('<span>%d</span> tag', '<span>%d</span> tags', $rn_topic_tags_average), $rn_topic_tags_average);
31
32
+ $rn = apply_filters( 'bb_admin_right_now', array(
33
+ 'forums' => array( $rn_forums, '-' ),
34
+ 'topics' => array( $rn_topics, $rn_topics_average ),
35
+ 'posts' => array( $rn_posts, $rn_posts_average ),
36
+ 'topic_tags' => array( $rn_topic_tags, $rn_topic_tags_average ),
37
+ 'users' => array( $rn_users, $rn_users_average )
38
+ ) );
39
+
40
$bb_admin_body_class = ' bb-admin-dashboard';
41
42
bb_get_admin_header();
56
<th><?php _e( 'Per Day' ); ?></th>
57
</tr>
58
</thead>
59
+ <?php
60
+ if ( !empty( $rn ) && is_array( $rn ) ) {
61
+ ?>
62
<tbody>
63
+ <?php
64
+ foreach ( $rn as $rn_row ) {
65
+ ?>
66
<tr>
67
+ <td><?php echo $rn_row[0]; ?></td>
68
+ <td><?php echo $rn_row[1]; ?></td>
69
</tr>
70
+ <?php
71
+ }
72
+ ?>
73
</tbody>
74
+ <?php
75
+ }
76
+ ?>
77
</table>
78
</div>
79
bp-forums/bbpress/bb-admin/options-permalinks.php CHANGED
@@ -1,188 +1,188 @@
1
- <?php
2
-
3
- require_once('admin.php');
4
-
5
- $file_source = BB_PATH . 'bb-admin/includes/defaults.bb-htaccess.php';
6
- $file_target = BB_PATH . '.htaccess';
7
- include( $file_source );
8
- $file_source_rules = $_rules; // This is a string
9
-
10
- if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && $_POST['action'] == 'update') {
11
-
12
- bb_check_admin_referer( 'options-permalinks-update' );
13
-
14
- foreach ( (array) $_POST as $option => $value ) {
15
- if ( !in_array( $option, array('_wpnonce', '_wp_http_referer', 'action', 'submit') ) ) {
16
- $option = trim( $option );
17
- $value = is_array( $value ) ? $value : trim( $value );
18
- $value = stripslashes_deep( $value );
19
- if ( $value ) {
20
- bb_update_option( $option, $value );
21
- } else {
22
- bb_delete_option( $option );
23
- }
24
- }
25
- }
26
-
27
- $mod_rewrite = (string) bb_get_option( 'mod_rewrite' );
28
-
29
- $goback = remove_query_arg( array( 'updated', 'notapache', 'notmodrewrite' ), wp_get_referer() );
30
-
31
- // Make sure mod_rewrite is possible on the server
32
- if ( !$is_apache ) {
33
- bb_delete_option( 'mod_rewrite_writable' );
34
- $goback = add_query_arg( 'notapache', 'true', $goback );
35
- bb_safe_redirect( $goback );
36
- exit;
37
- } elseif ( '0' !== $mod_rewrite && !apache_mod_loaded( 'mod_rewrite', true ) ) {
38
- bb_delete_option( 'mod_rewrite_writable' );
39
- bb_update_option( 'mod_rewrite', '0' );
40
- $goback = add_query_arg( 'notmodrewrite', 'true', $goback );
41
- bb_safe_redirect( $goback );
42
- exit;
43
- }
44
-
45
- $file_target_rules = array();
46
-
47
- $file_target_exists = false;
48
- $file_target_writable = true;
49
- if ( file_exists( $file_target ) ) {
50
- if ( is_readable( $file_target ) ) {
51
- $file_target_rules = explode( "\n", implode( '', file( $file_target ) ) );
52
- }
53
- $file_target_exists = true;
54
- if ( !is_writable( $file_target ) ) {
55
- $file_target_writable = false;
56
- }
57
- } else {
58
- $file_target_dir = dirname( $file_target );
59
- if ( file_exists( $file_target_dir ) ) {
60
- if ( !is_writable( $file_target_dir ) || !is_dir( $file_target_dir ) ) {
61
- $file_target_writable = false;
62
- }
63
- } else {
64
- $file_target_writable = false;
65
- }
66
- }
67
-
68
- // Strip out existing bbPress rules
69
- $_keep_rule = true;
70
- $_kept_rules = array();
71
- foreach ( $file_target_rules as $_rule ) {
72
- if ( false !== strpos( $_rule, '# BEGIN bbPress' ) ) {
73
- $_keep_rule = false;
74
- continue;
75
- } elseif ( false !== strpos( $_rule, '# END bbPress' ) ) {
76
- $_keep_rule = true;
77
- continue;
78
- }
79
- if ( $_keep_rule ) {
80
- $_kept_rules[] = $_rule;
81
- }
82
- }
83
-
84
- $file_target_rules = join( "\n", $_kept_rules ) . "\n" . $file_source_rules;
85
-
86
- $file_target_written = 0;
87
- if ( $file_target_writable ) {
88
- // Open the file for writing - rewrites the whole file
89
- if ( $file_target_handle = fopen( $file_target, 'w' ) ) {
90
- if ( fwrite( $file_target_handle, $file_target_rules ) ) {
91
- $file_target_written = 1;
92
- }
93
- // Close the file
94
- fclose( $file_target_handle );
95
- @chmod( $file_target, 0666 );
96
- }
97
- }
98
-
99
- bb_update_option( 'mod_rewrite_writable', $file_target_writable );
100
- $goback = add_query_arg( 'updated', 'true', $goback );
101
- bb_safe_redirect( $goback );
102
- exit;
103
- }
104
-
105
- if ( $is_apache && bb_get_option( 'mod_rewrite' ) && !bb_get_option( 'mod_rewrite_writable' ) ) {
106
- $manual_instructions = true;
107
- }
108
-
109
- if ( !empty( $_GET['notmodrewrite'] ) ) {
110
- $manual_instructions = false;
111
- bb_admin_notice( __( '<strong>It appears that your server does not support custom permalink structures.</strong>' ), 'error' );
112
- }
113
-
114
- if ( !empty( $_GET['notapache'] ) ) {
115
- $manual_instructions = false;
116
- bb_admin_notice( __( '<strong>Rewriting on webservers other than Apache using mod_rewrite is currently unsupported, but we won&#8217;t stop you from trying.</strong>' ), 'error' );
117
- }
118
-
119
- if ( !empty( $_GET['updated'] ) ) {
120
- if ( $manual_instructions ) {
121
- bb_admin_notice( __( '<strong>You should update your .htaccess now.</strong>' ) );
122
- } else {
123
- bb_admin_notice( __( '<strong>Permalink structure updated.</strong>' ) );
124
- }
125
- }
126
-
127
- $permalink_options = array(
128
- 'mod_rewrite' => array(
129
- 'title' => __( 'Permalink type' ),
130
- 'type' => 'radio',
131
- 'options' => array(
132
- '0' => sprintf( __( '<span>None</span> <code>%s</code>' ), bb_get_uri( 'forums.php', array( 'id' => 1 ), BB_URI_CONTEXT_TEXT ) ),
133
- '1' => sprintf( __( '<span>Numeric</span> <code>%s</code>' ), bb_get_uri( 'forums/1', null, BB_URI_CONTEXT_TEXT ) ),
134
- 'slugs' => sprintf( __( '<span>Name based</span> <code>%s</code>' ), bb_get_uri( '/forums/first-forum', null, BB_URI_CONTEXT_TEXT ) )
135
- )
136
- )
137
- );
138
-
139
- $bb_admin_body_class = ' bb-admin-settings';
140
-
141
- bb_get_admin_header();
142
-
143
- ?>
144
-
145
- <div class="wrap">
146
-
147
- <h2><?php _e( 'Permalink Settings' ); ?></h2>
148
- <?php do_action( 'bb_admin_notices' ); ?>
149
-
150
- <form class="settings" method="post" action="<?php bb_uri( 'bb-admin/options-permalinks.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN ); ?>">
151
- <fieldset>
152
- <p>
153
- <?php _e( 'By default bbPress uses web URLs which have question marks and lots of numbers in them, however bbPress offers you the ability to choose an alternative URL structure for your permalinks. This can improve the aesthetics, usability, and forward-compatibility of your links.' ); ?>
154
- </p>
155
- <?php
156
- foreach ( $permalink_options as $option => $args ) {
157
- bb_option_form_element( $option, $args );
158
- }
159
- ?>
160
- </fieldset>
161
- <fieldset class="submit">
162
- <?php bb_nonce_field( 'options-permalinks-update' ); ?>
163
- <input type="hidden" name="action" value="update" />
164
- <input class="submit" type="submit" name="submit" value="<?php _e('Save Changes') ?>" />
165
- </fieldset>
166
- </form>
167
-
168
- <?php
169
- if ( $manual_instructions ) {
170
- ?>
171
- <form class="settings" method="post" action="<?php bb_uri( 'bb-admin/options-permalinks.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN ); ?>">
172
- <fieldset>
173
- <p>
174
- <?php _e( 'If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn&#8217;t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.' ); ?>
175
- </p>
176
- <textarea dir="ltr" id="rewrite-rules" class="readonly" readonly="readonly" rows="6"><?php echo esc_html( trim( $file_source_rules ) ); ?></textarea>
177
- </fieldset>
178
- </form>
179
-
180
- <?php
181
- }
182
- ?>
183
-
184
- </div>
185
-
186
- <?php
187
-
188
- bb_get_admin_footer();
1
+ <?php
2
+
3
+ require_once('admin.php');
4
+
5
+ $file_source = BB_PATH . 'bb-admin/includes/defaults.bb-htaccess.php';
6
+ $file_target = BB_PATH . '.htaccess';
7
+ include( $file_source );
8
+ $file_source_rules = $_rules; // This is a string
9
+
10
+ if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && $_POST['action'] == 'update') {
11
+
12
+ bb_check_admin_referer( 'options-permalinks-update' );
13
+
14
+ foreach ( (array) $_POST as $option => $value ) {
15
+ if ( !in_array( $option, array('_wpnonce', '_wp_http_referer', 'action', 'submit') ) ) {
16
+ $option = trim( $option );
17
+ $value = is_array( $value ) ? $value : trim( $value );
18
+ $value = stripslashes_deep( $value );
19
+ if ( $value ) {
20
+ bb_update_option( $option, $value );
21
+ } else {
22
+ bb_delete_option( $option );
23
+ }
24
+ }
25
+ }
26
+
27
+ $mod_rewrite = (string) bb_get_option( 'mod_rewrite' );
28
+
29
+ $goback = remove_query_arg( array( 'updated', 'notapache', 'notmodrewrite' ), wp_get_referer() );
30
+
31
+ // Make sure mod_rewrite is possible on the server
32
+ if ( !$is_apache ) {
33
+ bb_delete_option( 'mod_rewrite_writable' );
34
+ $goback = add_query_arg( 'notapache', 'true', $goback );
35
+ bb_safe_redirect( $goback );
36
+ exit;
37
+ } elseif ( '0' !== $mod_rewrite && !apache_mod_loaded( 'mod_rewrite', true ) ) {
38
+ bb_delete_option( 'mod_rewrite_writable' );
39
+ bb_update_option( 'mod_rewrite', '0' );
40
+ $goback = add_query_arg( 'notmodrewrite', 'true', $goback );
41
+ bb_safe_redirect( $goback );
42
+ exit;
43
+ }
44
+
45
+ $file_target_rules = array();
46
+
47
+ $file_target_exists = false;
48
+ $file_target_writable = true;
49
+ if ( file_exists( $file_target ) ) {
50
+ if ( is_readable( $file_target ) ) {
51
+ $file_target_rules = explode( "\n", implode( '', file( $file_target ) ) );
52
+ }
53
+ $file_target_exists = true;
54
+ if ( !is_writable( $file_target ) ) {
55
+ $file_target_writable = false;
56
+ }
57
+ } else {
58
+ $file_target_dir = dirname( $file_target );
59
+ if ( file_exists( $file_target_dir ) ) {
60
+ if ( !is_writable( $file_target_dir ) || !is_dir( $file_target_dir ) ) {
61
+ $file_target_writable = false;
62
+ }
63
+ } else {
64
+ $file_target_writable = false;
65
+ }
66
+ }
67
+
68
+ // Strip out existing bbPress rules
69
+ $_keep_rule = true;
70
+ $_kept_rules = array();
71
+ foreach ( $file_target_rules as $_rule ) {
72
+ if ( false !== strpos( $_rule, '# BEGIN bbPress' ) ) {
73
+ $_keep_rule = false;
74
+ continue;
75
+ } elseif ( false !== strpos( $_rule, '# END bbPress' ) ) {
76
+ $_keep_rule = true;
77
+ continue;
78
+ }
79
+ if ( $_keep_rule ) {
80
+ $_kept_rules[] = $_rule;
81
+ }
82
+ }
83
+
84
+ $file_target_rules = join( "\n", $_kept_rules ) . "\n" . $file_source_rules;
85
+
86
+ $file_target_written = 0;
87
+ if ( $file_target_writable ) {
88
+ // Open the file for writing - rewrites the whole file
89
+ if ( $file_target_handle = fopen( $file_target, 'w' ) ) {
90
+ if ( fwrite( $file_target_handle, $file_target_rules ) ) {
91
+ $file_target_written = 1;
92
+ }
93
+ // Close the file
94
+ fclose( $file_target_handle );
95
+ @chmod( $file_target, 0666 );
96
+ }
97
+ }
98
+
99
+ bb_update_option( 'mod_rewrite_writable', $file_target_writable );
100
+ $goback = add_query_arg( 'updated', 'true', $goback );
101
+ bb_safe_redirect( $goback );
102
+ exit;
103
+ }
104
+
105
+ if ( $is_apache && bb_get_option( 'mod_rewrite' ) && !bb_get_option( 'mod_rewrite_writable' ) ) {
106
+ $manual_instructions = true;
107
+ }
108
+
109
+ if ( !empty( $_GET['notmodrewrite'] ) ) {
110
+ $manual_instructions = false;
111
+ bb_admin_notice( __( '<strong>It appears that your server does not support custom permalink structures.</strong>' ), 'error' );
112
+ }
113
+
114
+ if ( !empty( $_GET['notapache'] ) ) {
115
+ $manual_instructions = false;
116
+ bb_admin_notice( __( '<strong>Rewriting on webservers other than Apache using mod_rewrite is currently unsupported, but we won&#8217;t stop you from trying.</strong>' ), 'error' );
117
+ }
118
+
119
+ if ( !empty( $_GET['updated'] ) ) {
120
+ if ( $manual_instructions ) {
121
+ bb_admin_notice( __( '<strong>You should update your .htaccess now.</strong>' ) );
122
+ } else {
123
+ bb_admin_notice( __( '<strong>Permalink structure updated.</strong>' ) );
124
+ }
125
+ }
126
+
127
+ $permalink_options = array(
128
+ 'mod_rewrite' => array(
129
+ 'title' => __( 'Permalink type' ),
130
+ 'type' => 'radio',
131
+ 'options' => array(
132
+ '0' => sprintf( __( '<span>None</span> <code>%s</code>' ), bb_get_uri( 'forums.php', array( 'id' => 1 ), BB_URI_CONTEXT_TEXT ) ),
133
+ '1' => sprintf( __( '<span>Numeric</span> <code>%s</code>' ), bb_get_uri( 'forums/1', null, BB_URI_CONTEXT_TEXT ) ),
134
+ 'slugs' => sprintf( __( '<span>Name based</span> <code>%s</code>' ), bb_get_uri( '/forums/first-forum', null, BB_URI_CONTEXT_TEXT ) )
135
+ )
136
+ )
137
+ );
138
+
139
+ $bb_admin_body_class = ' bb-admin-settings';
140
+
141
+ bb_get_admin_header();
142
+
143
+ ?>
144
+
145
+ <div class="wrap">
146
+
147
+ <h2><?php _e( 'Permalink Settings' ); ?></h2>
148
+ <?php do_action( 'bb_admin_notices' ); ?>
149
+
150
+ <form class="settings" method="post" action="<?php bb_uri( 'bb-admin/options-permalinks.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN ); ?>">
151
+ <fieldset>
152
+ <p>
153
+ <?php _e( 'By default bbPress uses web URLs which have question marks and lots of numbers in them, however bbPress offers you the ability to choose an alternative URL structure for your permalinks. This can improve the aesthetics, usability, and forward-compatibility of your links.' ); ?>
154
+ </p>
155
+ <?php
156
+ foreach ( $permalink_options as $option => $args ) {
157
+ bb_option_form_element( $option, $args );
158
+ }
159
+ ?>
160
+ </fieldset>
161
+ <fieldset class="submit">
162
+ <?php bb_nonce_field( 'options-permalinks-update' ); ?>
163
+ <input type="hidden" name="action" value="update" />
164
+ <input class="submit" type="submit" name="submit" value="<?php _e('Save Changes') ?>" />
165
+ </fieldset>
166
+ </form>
167
+
168
+ <?php
169
+ if ( $manual_instructions ) {
170
+ ?>
171
+ <form class="settings" method="post" action="<?php bb_uri( 'bb-admin/options-permalinks.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN ); ?>">
172
+ <fieldset>
173
+ <p>
174
+ <?php _e( 'If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn&#8217;t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.' ); ?>
175
+ </p>
176
+ <textarea dir="ltr" id="rewrite-rules" class="readonly" readonly="readonly" rows="6"><?php echo esc_html( trim( $file_source_rules ) ); ?></textarea>
177
+ </fieldset>
178
+ </form>
179
+
180
+ <?php
181
+ }
182
+ ?>
183
+
184
+ </div>
185
+
186
+ <?php
187
+
188
+ bb_get_admin_footer();
bp-forums/bbpress/bb-admin/tools-recount.php CHANGED
@@ -1,164 +1,59 @@
1
<?php
2
- require_once('admin.php');
3
4
if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) ) {
5
bb_check_admin_referer( 'do-counts' );
6
7
$messages = array();
8
- if ( isset($_POST['topic-posts']) && 1 == $_POST['topic-posts'] ) {
9
- if ( $topics = (array) $bbdb->get_results("SELECT topic_id, COUNT(post_id) AS count FROM $bbdb->posts WHERE post_status = '0' GROUP BY topic_id") ) {
10
- $messages[] = __('Counted posts');
11
- foreach ($topics as $topic) {
12
- $topic_id = (int) $topic->topic_id;
13
- $bbdb->query( $bbdb->prepare( "UPDATE $bbdb->topics SET topic_posts = %s WHERE topic_id = %s" ), $topic->count, $topic_id );
14
- }
15
- unset($topics, $topic, $topic_id);
16
- }
17
- }
18
19
- if ( isset($_POST['topic-voices']) && 1 == $_POST['topic-voices'] ) {
20
- if ( $topics = (array) $bbdb->get_results("SELECT topic_id FROM $bbdb->topics ORDER BY topic_id") ) {
21
- $messages[] = __('Counted voices');
22
- foreach ($topics as $topic) {
23
- $topic_id = (int) $topic->topic_id;
24
- if ( $voices = $bbdb->get_col( $bbdb->prepare( "SELECT DISTINCT poster_id FROM $bbdb->posts WHERE topic_id = %s AND post_status = '0';", $topic_id ) ) ) {
25
- $voices = count( $voices );
26
- bb_update_topicmeta( $topic_id, 'voices_count', $voices );
27
- }
28
- }
29
- unset($topics, $topic, $topic_id);
30
- }
31
}
32
33
- if ( isset($_POST['topic-deleted-posts']) && 1 == $_POST['topic-deleted-posts'] ) {
34
- $old = (array) $bbdb->get_col("SELECT object_id FROM $bbdb->meta WHERE object_type = 'bb_topics' AND meta_key = 'deleted_posts'");
35
- $old = array_flip($old);
36
- if ( $topics = (array) $bbdb->get_results("SELECT topic_id, COUNT(post_id) AS count FROM $bbdb->posts WHERE post_status != '0' GROUP BY topic_id") ) {
37
- $messages[] = __('Counting deleted posts&#8230;');
38
- foreach ( $topics as $topic ) {
39
- bb_update_topicmeta( $topic->topic_id, 'deleted_posts', $topic->count );
40
- unset($old[$topic->topic_id]);
41
- }
42
- unset($topics, $topic);
43
- }
44
- if ( $old ) {
45
- $old = join(',', array_flip($old));
46
- $bbdb->query("DELETE FROM $bbdb->meta WHERE object_type = 'bb_topic' AND object_id IN ($old) AND meta_key = 'deleted_posts'");
47
- $messages[] = __('&#8230;counted deleted posts');
48
- } else {
49
- $messages[] = __('&#8230;no deleted posts to count');
50
- }
51
}
52
53
- if ( isset($_POST['forums']) && 1 == $_POST['forums'] ) {
54
- if ( $all_forums = (array) $bbdb->get_col("SELECT forum_id FROM $bbdb->forums") ) {
55
- $messages[] = __('Counted forum topics and posts');
56
- $all_forums = array_flip( $all_forums );
57
- $forums = $bbdb->get_results("SELECT forum_id, COUNT(topic_id) AS topic_count, SUM(topic_posts) AS post_count FROM $bbdb->topics WHERE topic_status = 0 GROUP BY forum_id");
58
- foreach ( (array) $forums as $forum ) {
59
- $bbdb->query("UPDATE $bbdb->forums SET topics = '$forum->topic_count', posts = '$forum->post_count' WHERE forum_id = '$forum->forum_id'");
60
- unset($all_forums[$forum->forum_id]);
61
- }
62
- if ( $all_forums ) {
63
- $all_forums = implode(',', array_flip( $all_forums ) );
64
- $bbdb->query("UPDATE $bbdb->forums SET topics = 0, posts = 0 WHERE forum_id IN ($all_forums)");
65
- }
66
- unset($all_forums, $forums, $forum);
67
- }
68
}
69
70
- if ( isset($_POST['topics-replied']) && 1 == $_POST['topics-replied'] ) {
71
- if ( $users = (array) $bbdb->get_col("SELECT ID FROM $bbdb->users") ) {
72
- $messages[] = __('Counted topics to which each user has replied');
73
- foreach ( $users as $user )
74
- bb_update_topics_replied( $user );
75
- unset($users, $user);
76
- }
77
}
78
79
- if ( isset($_POST['topic-tag-count']) && 1 == $_POST['topic-tag-count'] ) {
80
- // Reset tag count to zero
81
- $bbdb->query( "UPDATE $bbdb->topics SET tag_count = 0" );
82
-
83
- // Get all tags
84
- $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag' );
85
-
86
- if ( !is_wp_error( $terms ) && is_array( $terms ) ) {
87
- $messages[] = __('Counted topic tags');
88
- foreach ( $terms as $term ) {
89
- $topic_ids = bb_get_tagged_topic_ids( $term->term_id );
90
- if ( !is_wp_error( $topic_ids ) && is_array( $topic_ids ) ) {
91
- $bbdb->query(
92
- "UPDATE $bbdb->topics SET tag_count = tag_count + 1 WHERE topic_id IN (" . join( ',', $topic_ids ) . ")"
93
- );
94
- }
95
- unset( $topic_ids );
96
- }
97
- }
98
- unset( $terms, $term );
99
}
100
101
- if ( isset($_POST['tags-tag-count']) && 1 == $_POST['tags-tag-count'] ) {
102
- // Get all tags
103
- $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag', array( 'hide_empty' => false ) );
104
-
105
- if ( !is_wp_error( $terms ) && is_array( $terms ) ) {
106
- $messages[] = __('Counted tagged topics');
107
- $_terms = array();
108
- foreach ( $terms as $term ) {
109
- $_terms[] = $term->term_id;
110
- }
111
- if ( count( $_terms ) ) {
112
- $wp_taxonomy_object->update_term_count( $_terms, 'bb_topic_tag' );
113
- }
114
- }
115
- unset( $term, $_terms );
116
}
117
118
- if ( isset($_POST['tags-delete-empty']) && 1 == $_POST['tags-delete-empty'] ) {
119
- // Get all tags
120
- if ( !isset( $terms ) ) {
121
- $terms = $wp_taxonomy_object->get_terms( 'bb_topic_tag', array( 'hide_empty' => false ) );
122
- }
123
124
- if ( !is_wp_error( $terms ) && is_array( $terms ) ) {
125
- $messages[] = __('Deleted tags with no topics');
126
- foreach ( $terms as $term ) {
127
- $topic_ids = bb_get_tagged_topic_ids( $term->term_id );
128
- if ( !is_wp_error( $topic_ids ) && is_array( $topic_ids ) ) {
129
- if ( false === $topic_ids || ( is_array( $topic_ids ) && !count( $topic_ids ) ) ) {
130
- bb_destroy_tag( $term->term_taxonomy_id );
131
- }
132
- }
133
- unset( $topic_ids );
134
- }
135
- }
136
- unset( $terms, $term );
137
}
138
139
- if ( isset($_POST['clean-favorites']) && 1 == $_POST['clean-favorites'] ) {
140
- $favorites_key = $bbdb->prefix . 'favorites';
141
- if ( $users = $bbdb->get_results("SELECT user_id AS id, meta_value AS favorites FROM $bbdb->usermeta WHERE meta_key = '" . $favorites_key . "'") ) {
142
- $messages[] = __('Removed deleted topics from users\' favorites');
143
- $topics = $bbdb->get_col("SELECT topic_id FROM $bbdb->topics WHERE topic_status = '0'");
144
- foreach ( $users as $user ) {
145
- foreach ( explode(',', $user->favorites) as $favorite ) {
146
- if ( !in_array($favorite, $topics) ) {
147
- bb_remove_user_favorite( $user->id, $favorite );
148
- }
149
- }
150
- }
151
- unset($topics, $users, $user, $favorite);
152
- }
153
}
154
155
bb_recount_list();
156
foreach ( (array) $recount_list as $item ) {
157
if ( isset($item[2]) && isset($_POST[$item[0]]) && 1 == $_POST[$item[0]] && is_callable($item[2]) ) {
158
- call_user_func( $item[2] );
159
}
160
}
161
-
162
if ( count( $messages ) ) {
163
$messages = join( '</p>' . "\n" . '<p>', $messages );
164
bb_admin_notice( $messages );
1
<?php
2
+ require_once( 'admin.php' );
3
+ require_once( 'includes/functions.bb-recount.php' );
4
5
if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) ) {
6
bb_check_admin_referer( 'do-counts' );
7
8
+ // Stores messages
9
$messages = array();
10
11
+ if ( !empty( $_POST['topic-posts'] ) ) {
12
+ $messages[] = bb_recount_topic_posts();
13
}
14
15
+ if ( !empty( $_POST['topic-voices'] ) ) {
16
+ $messages[] = bb_recount_topic_voices();
17
}
18
19
+ if ( !empty( $_POST['topic-deleted-posts'] ) ) {
20
+ $messages[] = bb_recount_topic_deleted_posts();
21
}
22
23
+ if ( !empty( $_POST['forums'] ) ) {
24
+ $messages[] = bb_recount_forum_topics();
25
+ $messages[] = bb_recount_forum_posts();
26
}
27
28
+ if ( !empty( $_POST['topics-replied'] ) ) {
29
+ $messages[] = bb_recount_user_topics_replied();
30
}
31
32
+ if ( !empty( $_POST['topic-tag-count'] ) ) {
33
+ $messages[] = bb_recount_topic_tags();
34
}
35
36
+ if ( !empty( $_POST['tags-tag-count'] ) ) {
37
+ $messages[] = bb_recount_tag_topics();
38
+ }
39
40
+ if ( !empty( $_POST['tags-delete-empty'] ) ) {
41
+ $messages[] = bb_recount_tag_delete_empty();
42
}
43
44
+ if ( !empty( $_POST['clean-favorites'] ) ) {
45
+ $messages[] = bb_recount_clean_favorites();
46
}
47
48
bb_recount_list();
49
foreach ( (array) $recount_list as $item ) {
50
if ( isset($item[2]) && isset($_POST[$item[0]]) && 1 == $_POST[$item[0]] && is_callable($item[2]) ) {
51
+ $messages[] = call_user_func( $item[2] );
52
}
53
}
54
+
55
+ wp_cache_flush();
56
+
57
if ( count( $messages ) ) {
58
$messages = join( '</p>' . "\n" . '<p>', $messages );
59
bb_admin_notice( $messages );
bp-forums/bbpress/bb-cron.php CHANGED
@@ -11,6 +11,10 @@
11
12
ignore_user_abort( true );
13
14
/**
15
* Tell bbPress we are doing the CRON task.
16
*
@@ -21,24 +25,19 @@ define( 'DOING_CRON', true );
21
/** Setup bbPress environment */
22
require_once( './bb-load.php' );
23
24
- if ( $_GET['check'] != backpress_get_option( 'cron_check' ) ) {
25
- exit;
26
- }
27
-
28
- if ( bb_get_option( 'doing_cron' ) > time() ) {
29
- exit;
30
}
31
32
- bb_update_option( 'doing_cron', time() + 30 );
33
-
34
- $crons = _get_cron_array();
35
$keys = array_keys( $crons );
36
- if ( !is_array( $crons ) || $keys[0] > time() ) {
37
- return;
38
}
39
40
foreach ( $crons as $timestamp => $cronhooks ) {
41
- if ( $timestamp > time() ) {
42
break;
43
}
44
foreach ( $cronhooks as $hook => $keys ) {
@@ -53,5 +52,3 @@ foreach ( $crons as $timestamp => $cronhooks ) {
53
}
54
}
55
}
56
-
57
- bb_update_option( 'doing_cron', 0 );
11
12
ignore_user_abort( true );
13
14
+ if ( !empty( $_POST ) || defined( 'DOING_AJAX' ) || defined( 'DOING_CRON' ) ) {
15
+ die();
16
+ }
17
+
18
/**
19
* Tell bbPress we are doing the CRON task.
20
*
25
/** Setup bbPress environment */
26
require_once( './bb-load.php' );
27
28
+ if ( false === $crons = _get_cron_array() ) {
29
+ die();
30
}
31
32
$keys = array_keys( $crons );
33
+ $local_time = time();
34
+
35
+ if ( !is_array( $crons ) || ( isset($keys[0]) && $keys[0] > $local_time ) ) {
36
+ die();
37
}
38
39
foreach ( $crons as $timestamp => $cronhooks ) {
40
+ if ( $timestamp > $local_time ) {
41
break;
42
}
43
foreach ( $cronhooks as $hook => $keys ) {
52
}
53
}
54
}
bp-forums/bbpress/bb-includes/backpress/functions.formatting.php CHANGED
@@ -1489,14 +1489,15 @@ if ( !function_exists('clean_url') ) :
1489
*
1490
* @param string $url The URL to be cleaned.
1491
* @param array $protocols Optional. An array of acceptable protocols.
1492
- * Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' if not set.
1493
* @param string $context Optional. How the URL will be used. Default is 'display'.
1494
* @return string The cleaned $url after the 'cleaned_url' filter is applied.
1495
*/
1496
function clean_url( $url, $protocols = null, $context = 'display' ) {
1497
$original_url = $url;
1498
1499
- if ('' == $url) return $url;
1500
$url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
1501
$strip = array('%0d', '%0a', '%0D', '%0A');
1502
$url = _deep_replace($strip, $url);
@@ -1511,12 +1512,13 @@ function clean_url( $url, $protocols = null, $context = 'display' ) {
1511
1512
// Replace ampersands and single quotes only when displaying.
1513
if ( 'display' == $context ) {
1514
- $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url);
1515
$url = str_replace( "'", '&#039;', $url );
1516
}
1517
1518
if ( !is_array($protocols) )
1519
- $protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet');
1520
if ( wp_kses_bad_protocol( $url, $protocols ) != $url )
1521
return '';
1522
1489
*
1490
* @param string $url The URL to be cleaned.
1491
* @param array $protocols Optional. An array of acceptable protocols.
1492
+ * Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn' if not set.
1493
* @param string $context Optional. How the URL will be used. Default is 'display'.
1494
* @return string The cleaned $url after the 'cleaned_url' filter is applied.
1495
*/
1496
function clean_url( $url, $protocols = null, $context = 'display' ) {
1497
$original_url = $url;
1498
1499
+ if ( '' == $url )
1500
+ return $url;
1501
$url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
1502
$strip = array('%0d', '%0a', '%0D', '%0A');
1503
$url = _deep_replace($strip, $url);
1512
1513
// Replace ampersands and single quotes only when displaying.
1514
if ( 'display' == $context ) {
1515
+ $url = wp_kses_normalize_entities( $url );
1516
+ $url = str_replace( '&amp;', '&#038;', $url );
1517
$url = str_replace( "'", '&#039;', $url );
1518
}
1519
1520
if ( !is_array($protocols) )
1521
+ $protocols = array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn');
1522
if ( wp_kses_bad_protocol( $url, $protocols ) != $url )
1523
return '';
1524
bp-forums/bbpress/bb-includes/backpress/functions.kses.php CHANGED
@@ -1,30 +1,485 @@
1
<?php
2
- // Last sync [WP11537]
3
4
/**
5
- * HTML/XHTML filter that only allows some elements and attributes
6
*
7
* Added wp_ prefix to avoid conflicts with existing kses users
8
*
9
* @version 0.2.2
10
* @copyright (C) 2002, 2003, 2005
11
- * @author Ulf Harnhammar <metaur@users.sourceforge.net>
12
*
13
* @package External
14
* @subpackage KSES
15
*
16
- * @internal
17
- * *** CONTACT INFORMATION ***
18
- * E-mail: metaur at users dot sourceforge dot net
19
- * Web page: http://sourceforge.net/projects/kses
20
- * Paper mail: Ulf Harnhammar
21
- * Ymergatan 17 C
22
- * 753 25 Uppsala
23
- * SWEDEN
24
- *
25
- * [kses strips evil scripts!]
26
*/
27
28
29
/**
30
* Filters content and keeps only allowable HTML elements.
@@ -35,9 +490,9 @@
35
* call this function.
36
*
37
* The default allowed protocols are 'http', 'https', 'ftp', 'mailto', 'news',
38
- * 'irc', 'gopher', 'nntp', 'feed', and finally 'telnet. This covers all common
39
- * link protocols, except for 'javascript' which should not be allowed for
40
- * untrusted users.
41
*
42
* @since 1.0.0
43
*
@@ -46,7 +501,8 @@
46
* @param array $allowed_protocols Optional. Allowed protocol in links.
47
* @return string Filtered content with only allowed HTML elements
48
*/
49
- function wp_kses($string, $allowed_html, $allowed_protocols = array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet')) {
50
$string = wp_kses_no_null($string);
51
$string = wp_kses_js_entities($string);
52
$string = wp_kses_normalize_entities($string);
@@ -100,8 +556,18 @@ function wp_kses_split($string, $allowed_html, $allowed_protocols) {
100
global $pass_allowed_html, $pass_allowed_protocols;
101
$pass_allowed_html = $allowed_html;
102
$pass_allowed_protocols = $allowed_protocols;
103
- return preg_replace_callback('%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%',
104
- create_function('$match', 'global $pass_allowed_html, $pass_allowed_protocols; return wp_kses_split2($match[1], $pass_allowed_html, $pass_allowed_protocols);'), $string);
105
}
106
107
/**
@@ -186,7 +652,7 @@ function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) {
186
# Is there a closing XHTML slash at the end of the attributes?
187
188
$xhtml_slash = '';
189
- if (preg_match('%\s/\s*$%', $attr))
190
$xhtml_slash = ' /';
191
192
# Are any attributes allowed at all for this element?
@@ -224,6 +690,19 @@ function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) {
224
break;
225
}
226
227
if ($ok)
228
$attr2 .= ' '.$arreach['whole']; # it passed them
229
} # if !is_array($current)
@@ -299,11 +778,11 @@ function wp_kses_hair($attr, $allowed_protocols) {
299
300
case 2 : # attribute value, a URL after href= for instance
301
302
- if (preg_match('/^"([^"]*)"(\s+|$)/', $attr, $match))
303
# "value"
304
{
305
$thisval = $match[1];
306
- if ( in_array($attrname, $uris) )
307
$thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
308
309
if(FALSE === array_key_exists($attrname, $attrarr)) {
@@ -315,11 +794,11 @@ function wp_kses_hair($attr, $allowed_protocols) {
315
break;
316
}
317
318
- if (preg_match("/^'([^']*)'(\s+|$)/", $attr, $match))
319
# 'value'
320
{
321
$thisval = $match[1];
322
- if ( in_array($attrname, $uris) )
323
$thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
324
325
if(FALSE === array_key_exists($attrname, $attrarr)) {
@@ -331,11 +810,11 @@ function wp_kses_hair($attr, $allowed_protocols) {
331
break;
332
}
333
334
- if (preg_match("%^([^\s\"']+)(\s+|$)%", $attr, $match))
335
# value
336
{
337
$thisval = $match[1];
338
- if ( in_array($attrname, $uris) )
339
$thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
340
341
if(FALSE === array_key_exists($attrname, $attrarr)) {
@@ -374,10 +853,10 @@ function wp_kses_hair($attr, $allowed_protocols) {
374
* @since 1.0.0
375
*
376
* @param string $value Attribute value
377
- * @param string $vless Whether the value is valueless or not. Use 'y' or 'n'
378
* @param string $checkname What $checkvalue is checking for.
379
* @param mixed $checkvalue What constraint the value should pass
380
- * @return bool Whether check passes (true) or not (false)
381
*/
382
function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue) {
383
$ok = true;
@@ -453,7 +932,6 @@ function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue) {
453
*/
454
function wp_kses_bad_protocol($string, $allowed_protocols) {
455
$string = wp_kses_no_null($string);
456
- $string = preg_replace('/\xad+/', '', $string); # deals with Opera "feature"
457
$string2 = $string.'a';
458
459
while ($string != $string2) {
@@ -559,14 +1037,9 @@ function wp_kses_html_error($string) {
559
* @return string Sanitized content
560
*/
561
function wp_kses_bad_protocol_once($string, $allowed_protocols) {
562
- global $_kses_allowed_protocols;
563
- $_kses_allowed_protocols = $allowed_protocols;
564
-
565
- $string2 = preg_split('/:|&#58;|&#x3a;/i', $string, 2);
566
- if ( isset($string2[1]) && !preg_match('%/\?%', $string2[0]) )
567
- $string = wp_kses_bad_protocol_once2($string2[0]) . trim($string2[1]);
568
- else
569
- $string = preg_replace_callback('/^((&[^;]*;|[\sA-Za-z0-9])*)'.'(:|&#58;|&#[Xx]3[Aa];)\s*/', 'wp_kses_bad_protocol_once2', $string);
570
571
return $string;
572
}
@@ -580,31 +1053,19 @@ function wp_kses_bad_protocol_once($string, $allowed_protocols) {
580
* @access private
581
* @since 1.0.0
582
*
583
- * @param mixed $matches string or preg_replace_callback() matches array to check for bad protocols
584
* @return string Sanitized content
585
*/
586
- function wp_kses_bad_protocol_once2($matches) {
587
- global $_kses_allowed_protocols;
588
-
589
- if ( is_array($matches) ) {
590
- if ( ! isset($matches[1]) || empty($matches[1]) )
591
- return '';
592
-
593
- $string = $matches[1];
594
- } else {
595
- $string = $matches;
596
- }
597
-
598
$string2 = wp_kses_decode_entities($string);
599
$string2 = preg_replace('/\s/', '', $string2);
600
$string2 = wp_kses_no_null($string2);
601
- $string2 = preg_replace('/\xad+/', '', $string2);
602
- # deals with Opera "feature"
603
$string2 = strtolower($string2);
604
605
$allowed = false;
606
- foreach ( (array) $_kses_allowed_protocols as $one_protocol)
607
- if (strtolower($one_protocol) == $string2) {
608
$allowed = true;
609
break;
610
}
@@ -633,13 +1094,34 @@ function wp_kses_normalize_entities($string) {
633
634
# Change back the allowed entities in our entity whitelist
635
636
- $string = preg_replace('/&amp;([A-Za-z][A-Za-z0-9]{0,19});/', '&\\1;', $string);
637
- $string = preg_replace_callback('/&amp;#0*([0-9]{1,5});/', 'wp_kses_normalize_entities2', $string);
638
- $string = preg_replace_callback('/&amp;#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', 'wp_kses_normalize_entities3', $string);
639
640
return $string;
641
}
642
643
/**
644
* Callback for wp_kses_normalize_entities() regular expression.
645
*
@@ -653,11 +1135,18 @@ function wp_kses_normalize_entities($string) {
653
* @return string Correctly encoded entity
654
*/
655
function wp_kses_normalize_entities2($matches) {
656
- if ( ! isset($matches[1]) || empty($matches[1]) )
657
return '';
658
659
$i = $matches[1];
660
- return ( ( ! valid_unicode($i) ) || ($i > 65535) ? "&amp;#$i;" : "&#$i;" );
661
}
662
663
/**
@@ -672,11 +1161,11 @@ function wp_kses_normalize_entities2($matches) {
672
* @return string Correctly encoded entity
673
*/
674
function wp_kses_normalize_entities3($matches) {
675
- if ( ! isset($matches[2]) || empty($matches[2]) )
676
return '';
677
678
- $hexchars = $matches[2];
679
- return ( ( ! valid_unicode(hexdec($hexchars)) ) ? "&amp;#x$hexchars;" : "&#x$hexchars;" );
680
}
681
682
/**
@@ -705,8 +1194,160 @@ function valid_unicode($i) {
705
* @return string Content after decoded entities
706
*/
707
function wp_kses_decode_entities($string) {
708
- $string = preg_replace_callback('/&#([0-9]+);/', create_function('$match', 'return chr($match[1]);'), $string);
709
- $string = preg_replace_callback('/&#[Xx]([0-9A-Fa-f]+);/', create_function('$match', 'return chr(hexdec($match[1]));'), $string);
710
711
return $string;
712
}