Ticket #5197: 5197.02.patch
File 5197.02.patch, 55.0 KB (added by , 11 years ago) |
---|
-
bp-blogs/bp-blogs-functions.php
diff --git bp-blogs/bp-blogs-functions.php bp-blogs/bp-blogs-functions.php index d032cfb..8bd441c 100644
function bp_blogs_remove_data( $user_id ) { 970 970 add_action( 'wpmu_delete_user', 'bp_blogs_remove_data' ); 971 971 add_action( 'delete_user', 'bp_blogs_remove_data' ); 972 972 add_action( 'bp_make_spam_user', 'bp_blogs_remove_data' ); 973 974 /** 975 * Display the number of blogs in user's Admin Profile. 976 * 977 * @param int $user_id the ID of user displayed. 978 * @return string HTML for stats output. 979 */ 980 function bp_blogs_admin_profile_stats( $user_id = 0 ) { 981 if ( ! is_multisite() ) 982 return false; 983 984 if ( $blogs_amount = bp_blogs_total_blogs_for_user( $user_id ) ) { 985 ?> 986 <li><div class="dashicons dashicons-blogs"></div> <?php printf( _n( '1 site', '<strong>%s</strong> sites', $blogs_amount, 'buddypress' ), $blogs_amount );?></li> 987 <?php 988 } 989 } 990 add_action( 'bp_members_admin_user_stats', 'bp_blogs_admin_profile_stats', 12, 1 ); -
bp-friends/bp-friends-functions.php
diff --git bp-friends/bp-friends-functions.php bp-friends/bp-friends-functions.php index 859654b..d450d8a 100644
function friends_remove_data( $user_id ) { 546 546 add_action( 'wpmu_delete_user', 'friends_remove_data' ); 547 547 add_action( 'delete_user', 'friends_remove_data' ); 548 548 add_action( 'bp_make_spam_user', 'friends_remove_data' ); 549 550 /** 551 * Display the number of friends in user's Admin Profile. 552 * 553 * @param int $user_id The ID of user displayed. 554 * @return string HTML for stats output. 555 */ 556 function friends_admin_profile_stats( $user_id = 0 ) { 557 if ( $friends_amount = friends_get_total_friend_count( $user_id ) ) { 558 ?> 559 <li><div class="dashicons dashicons-friends"></div> <?php printf( _n( '1 friend', '<strong>%s</strong> friends', $friends_amount, 'buddypress' ), $friends_amount );?></li> 560 <?php 561 } 562 } 563 add_action( 'bp_members_admin_user_stats', 'friends_admin_profile_stats', 10, 1 ); -
bp-groups/bp-groups-functions.php
diff --git bp-groups/bp-groups-functions.php bp-groups/bp-groups-functions.php index 072bdd8..4686b61 100644
function groups_remove_data_for_user( $user_id ) { 1056 1056 add_action( 'wpmu_delete_user', 'groups_remove_data_for_user' ); 1057 1057 add_action( 'delete_user', 'groups_remove_data_for_user' ); 1058 1058 add_action( 'bp_make_spam_user', 'groups_remove_data_for_user' ); 1059 1060 1061 /** 1062 * Display the number of groups in user's Admin Profile. 1063 * 1064 * @param int $user_id The ID of user displayed. 1065 * @return string HTML for stats output. 1066 */ 1067 function groups_admin_profile_stats( $user_id = 0 ) { 1068 if ( $groups_amount = bp_get_total_group_count_for_user( $user_id ) ) { 1069 ?> 1070 <li><div class="dashicons dashicons-groups"></div> <?php printf( _n( '1 group', '<strong>%s</strong> groups', $groups_amount, 'buddypress' ), $groups_amount );?></li> 1071 <?php 1072 } 1073 } 1074 add_action( 'bp_members_admin_user_stats', 'groups_admin_profile_stats', 11, 1 ); -
new file p-members/admin/css/admin.css
diff --git bp-members/admin/css/admin.css bp-members/admin/css/admin.css new file mode 100644 index 0000000..32eef85
- + 1 /**** BP Members Profile Administration Screens ****/ 2 3 div#profile-page.wrap form#your-profile { 4 position:relative; 5 } 6 7 div#profile-page.wrap form#your-profile h3:first-of-type { 8 margin-top:6em; 9 } 10 11 div#profile-page.wrap form#your-profile ul#profile-nav { 12 position:absolute; 13 top:-6em; 14 border-bottom:solid 1px #ccc; 15 width:100%; 16 } 17 18 div#community-profile-page h2:first-of-type { 19 margin-bottom:1em; 20 } 21 22 div#community-profile-page h2.profile-section { 23 border-bottom:dotted 1px #ccc; 24 } 25 26 div#community-profile-page ul#profile-nav { 27 border-bottom:solid 1px #ccc; 28 width:100%; 29 margin-top:1em; 30 margin-bottom:1em; 31 padding:1em 0; 32 padding-bottom: 0; 33 height:2.4em; 34 } 35 36 form#your-profile ul#profile-nav li, 37 div#community-profile-page ul#profile-nav li { 38 margin-left:0.4em; 39 float:left; 40 font-weight: bold; 41 font-size: 15px; 42 line-height: 24px; 43 } 44 45 form#your-profile ul#profile-nav li a, 46 div#community-profile-page ul#profile-nav li a { 47 text-decoration: none; 48 color:#888; 49 } 50 51 form#your-profile ul#profile-nav li a:hover, 52 form#your-profile ul#profile-nav li.nav-tab-active a, 53 div#community-profile-page ul#profile-nav li a:hover, 54 div#community-profile-page ul#profile-nav li.nav-tab-active a { 55 text-decoration: none; 56 color:#000; 57 } 58 59 div#community-profile-page div.dashicons-last-active:before { 60 content: "\f130"; 61 } 62 63 div#community-profile-page div.dashicons-friends:before { 64 content: "\f454"; 65 } 66 67 div#community-profile-page div.dashicons-groups:before { 68 content: "\f456"; 69 } 70 71 div#community-profile-page div.dashicons-blogs:before { 72 content: "\f120"; 73 } 74 75 div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar { 76 width:150px; 77 margin:0 auto; 78 } 79 80 div#community-profile-page div#bp_xprofile_user_admin_avatar a { 81 display:block; 82 margin:1em 0; 83 text-decoration:none; 84 color:#888; 85 } 86 87 div#community-profile-page p.not-activated { 88 margin:1em 1em 0; 89 color:red; 90 } 91 92 div#community-profile-page .form-table td.admin-field-visibility-td { 93 padding:5px 5px 15px 5px; 94 } 95 96 div#community-profile-page .form-table tr.admin-field-visibility-tr { 97 border-bottom:dotted 1px #ccc; 98 } 99 100 div#community-profile-page .form-table tr.admin-field-visibility-tr:last-child{ 101 border:none; 102 } 103 104 div#community-profile-page .field-visibility-settings legend, 105 div#community-profile-page .field-visibility-settings-notoggle { 106 font-size: 14px; 107 font-style: italic; 108 color:#666; 109 } 110 111 div#community-profile-page .field-visibility-settings ul { 112 margin:0; 113 font-size: 13px; 114 } 115 116 div#community-profile-page .field-visibility-settings ul li { 117 display:inline-block; 118 margin-right:1em; 119 } -
new file p-members/admin/css/admin.min.css
diff --git bp-members/admin/css/admin.min.css bp-members/admin/css/admin.min.css new file mode 100644 index 0000000..238ff55
- + 1 div#profile-page.wrap form#your-profile{position:relative}div#profile-page.wrap form#your-profile h3:first-of-type{margin-top:6em}div#profile-page.wrap form#your-profile ul#profile-nav{position:absolute;top:-6em;border-bottom:solid 1px #ccc;width:100%}div#community-profile-page h2:first-of-type{margin-bottom:1em}div#community-profile-page h2.profile-section{border-bottom:dotted 1px #ccc}div#community-profile-page ul#profile-nav{border-bottom:solid 1px #ccc;width:100%;margin-top:1em;margin-bottom:1em;padding:1em 0;padding-bottom:0;height:2.4em}div#community-profile-page ul#profile-nav li,form#your-profile ul#profile-nav li{margin-left:.4em;float:left;font-weight:700;font-size:15px;line-height:24px}div#community-profile-page ul#profile-nav li a,form#your-profile ul#profile-nav li a{text-decoration:none;color:#888}div#community-profile-page ul#profile-nav li a:hover,div#community-profile-page ul#profile-nav li.nav-tab-active a,form#your-profile ul#profile-nav li a:hover,form#your-profile ul#profile-nav li.nav-tab-active a{text-decoration:none;color:#000}div#community-profile-page div.dashicons-last-active:before{content:"\f130"}div#community-profile-page div.dashicons-friends:before{content:"\f454"}div#community-profile-page div.dashicons-groups:before{content:"\f456"}div#community-profile-page div.dashicons-blogs:before{content:"\f120"}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar{width:150px;margin:0 auto}div#community-profile-page div#bp_xprofile_user_admin_avatar a{display:block;margin:1em 0;text-decoration:none;color:#888}div#community-profile-page p.not-activated{margin:1em 1em 0;color:red}div#community-profile-page .form-table td.admin-field-visibility-td{padding:5px 5px 15px}div#community-profile-page .form-table tr.admin-field-visibility-tr{border-bottom:dotted 1px #ccc}div#community-profile-page .form-table tr.admin-field-visibility-tr:last-child{border:0}div#community-profile-page .field-visibility-settings legend,div#community-profile-page .field-visibility-settings-notoggle{font-size:14px;font-style:italic;color:#666}div#community-profile-page .field-visibility-settings ul{margin:0;font-size:13px}div#community-profile-page .field-visibility-settings ul li{display:inline-block;margin-right:1em} 2 No newline at end of file -
new file p-members/admin/js/admin.js
diff --git bp-members/admin/js/admin.js bp-members/admin/js/admin.js new file mode 100644 index 0000000..df95205
- + 1 (function( $ ) { 2 3 /** Profile Visibility Settings *********************************/ 4 $('.field-visibility-settings').hide(); 5 $('.visibility-toggle-link').on( 'click', function( event ) { 6 7 event.preventDefault(); 8 9 var toggle_div = $(this).parent(); 10 11 $(toggle_div).fadeOut( 600, function(){ 12 $(toggle_div).siblings('.field-visibility-settings').slideDown(400); 13 }); 14 15 } ); 16 17 $('.field-visibility-settings-close').on( 'click', function( event ) { 18 19 event.preventDefault(); 20 21 var settings_div = $(this).parent(); 22 var vis_setting_text = settings_div.find('input:checked').parent().text(); 23 24 settings_div.slideUp( 400, function() { 25 settings_div.siblings('.field-visibility-settings-toggle').fadeIn(800); 26 settings_div.siblings('.field-visibility-settings-toggle').children('.current-visibility-level').html(vis_setting_text); 27 } ); 28 29 return false; 30 } ); 31 32 })(jQuery); 33 34 35 function clear(container) { 36 if( !document.getElementById(container) ) return; 37 38 var container = document.getElementById(container); 39 40 if ( radioButtons = container.getElementsByTagName('INPUT') ) { 41 for(var i=0; i<radioButtons.length; i++) { 42 radioButtons[i].checked = ''; 43 } 44 } 45 46 if ( options = container.getElementsByTagName('OPTION') ) { 47 for(var i=0; i<options.length; i++) { 48 options[i].selected = false; 49 } 50 } 51 52 return; 53 } 54 No newline at end of file -
new file p-members/admin/js/admin.min.js
diff --git bp-members/admin/js/admin.min.js bp-members/admin/js/admin.min.js new file mode 100644 index 0000000..8284f9b
- + 1 function clear(e){if(!document.getElementById(e))return;var e=document.getElementById(e);if(radioButtons=e.getElementsByTagName("INPUT")){for(var t=0;t<radioButtons.length;t++){radioButtons[t].checked=""}}if(options=e.getElementsByTagName("OPTION")){for(var t=0;t<options.length;t++){options[t].selected=false}}return}(function(e){e(".field-visibility-settings").hide();e(".visibility-toggle-link").on("click",function(t){t.preventDefault();var n=e(this).parent();e(n).fadeOut(600,function(){e(n).siblings(".field-visibility-settings").slideDown(400)})});e(".field-visibility-settings-close").on("click",function(t){t.preventDefault();var n=e(this).parent();var r=n.find("input:checked").parent().text();n.slideUp(400,function(){n.siblings(".field-visibility-settings-toggle").fadeIn(800);n.siblings(".field-visibility-settings-toggle").children(".current-visibility-level").html(r)});return false})})(jQuery) 2 No newline at end of file -
new file p-members/bp-members-admin.php
diff --git bp-members/bp-members-admin.php bp-members/bp-members-admin.php new file mode 100644 index 0000000..237712e
- + 1 <?php 2 // Exit if accessed directly 3 if ( !defined( 'ABSPATH' ) ) exit; 4 5 if ( !class_exists( 'BP_Members_Admin' ) ) : 6 /** 7 * Load Members admin area. 8 * 9 * @package BuddyPress 10 * @subpackage membersAdministration 11 * 12 * @since BuddyPress (2.0.0) 13 */ 14 class BP_Members_Admin { 15 16 /** Directory *************************************************************/ 17 18 /** 19 * Path to the BP Members Admin directory. 20 * 21 * @var string $admin_dir 22 */ 23 public $admin_dir = ''; 24 25 /** URLs ******************************************************************/ 26 27 /** 28 * URL to the BP Members Admin directory. 29 * 30 * @var string $admin_url 31 */ 32 public $admin_url = ''; 33 34 /** 35 * URL to the BP Members Admin CSS directory. 36 * 37 * @var string $css_url 38 */ 39 public $css_url = ''; 40 41 /** 42 * URL to the BP Members Admin JS directory. 43 * 44 * @var string 45 */ 46 public $js_url = ''; 47 48 /** Other *****************************************************************/ 49 50 /** 51 * Screen id for edit user's profile page. 52 * 53 * @access public 54 * @var string 55 */ 56 public $user_page = ''; 57 58 /** 59 * Constructor method. 60 * 61 * @access public 62 * @since BuddyPress (2.0.0) 63 */ 64 public function __construct() { 65 $this->setup_globals(); 66 $this->setup_actions(); 67 } 68 69 /** 70 * Set admin-related globals. 71 * 72 * @access private 73 * @since BuddyPress (2.0.0) 74 */ 75 private function setup_globals() { 76 $bp = buddypress(); 77 78 // Paths and URLs 79 $this->admin_dir = trailingslashit( $bp->plugin_dir . 'bp-members/admin' ); // Admin path 80 $this->admin_url = trailingslashit( $bp->plugin_url . 'bp-members/admin' ); // Admin URL 81 $this->css_url = trailingslashit( $this->admin_url . 'css' ); // Admin CSS URL 82 $this->js_url = trailingslashit( $this->admin_url . 'js' ); // Admin CSS URL 83 84 // The Edit Profile Screen id 85 $this->user_page = ''; 86 87 // The screen ids to load specific css for 88 $this->screen_id = array(); 89 90 // The stats metabox default position 91 $this->stats_metabox = new StdClass(); 92 93 // The WordPress edit user url 94 $this->edit_url = bp_get_admin_url( 'user-edit.php' ); 95 96 // BuddyPress edit user's profile url 97 $this->edit_profile_url = add_query_arg( 'page', 'bp-profile-edit', bp_get_admin_url( 'users.php' ) ); 98 } 99 100 /** 101 * Set admin-related actions and filters. 102 * 103 * @since BuddyPress (2.0.0) 104 */ 105 private function setup_actions() { 106 107 /** Actions ***************************************************/ 108 109 // Add some page specific output to the <head> 110 add_action( 'bp_admin_head', array( $this, 'admin_head' ), 999 ); 111 112 // Add menu item to all users menu 113 add_action( bp_core_admin_hook(), array( $this, 'admin_menus' ), 5 ); 114 115 // Enqueue all admin JS and CSS 116 add_action( 'bp_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 117 118 // Create the Profile Navigation (WordPress/Community) 119 add_action( 'edit_user_profile', array( $this, 'profile_nav' ), 99, 1 ); 120 121 122 /** Filters ***************************************************/ 123 124 // Add a row action to users listing 125 add_filter( bp_core_do_network_admin() ? 'ms_user_row_actions' : 'user_row_actions', array( $this, 'row_actions' ), 10, 2 ); 126 127 } 128 129 /** 130 * Create the All Users > Edit Profile submenu. 131 * 132 * @access public 133 * @since BuddyPress (2.0.0) 134 * 135 * @uses add_users_page() To add the Edit Profile page in Users section. 136 */ 137 public function admin_menus() { 138 139 // Manage user's profile 140 $hook = $this->user_page = add_users_page( 141 __( 'Edit Profile', 'buddypress' ), 142 __( 'Edit Profile', 'buddypress' ), 143 'bp_moderate', 144 'bp-profile-edit', 145 array( &$this, 'user_admin' ) 146 ); 147 148 $edit_page = 'user-edit'; 149 150 if ( bp_core_do_network_admin() ) { 151 $edit_page .= '-network'; 152 $this->user_page .= '-network'; 153 } 154 155 $this->screen_id = array( $edit_page, $this->user_page ); 156 157 add_action( "admin_head-$hook", array( $this, 'modify_admin_menu_highlight' ) ); 158 add_action( "load-$hook", array( $this, 'user_admin_load' ) ); 159 160 } 161 162 /** 163 * Add some specific styling to the Edit User and Edit User's Profile page. 164 * 165 * @since BuddyPress (2.0.0) 166 */ 167 public function enqueue_scripts() { 168 if ( ! in_array( get_current_screen()->id, $this->screen_id ) ) { 169 return; 170 } 171 172 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 173 174 $css = $this->css_url . "admin{$min}.css"; 175 $css = apply_filters( 'bp_members_admin_css', $css ); 176 wp_enqueue_style( 'bp-members-css', $css, array(), bp_get_version() ); 177 178 $js = $this->js_url . "admin{$min}.js"; 179 $js = apply_filters( 'bp_members_admin_js', $js ); 180 wp_enqueue_script( 'bp-members-js', $js, array( 'jquery' ), bp_get_version(), true ); 181 182 // Plugins may want to hook here to load some css/js 183 do_action( 'bp_members_admin_enqueue_scripts', get_current_screen()->id, $this->screen_id ); 184 } 185 186 /** 187 * Create the Profile navigation in Edit User & Edit Profile pages. 188 * 189 * @since BuddyPress (2.0.0) 190 */ 191 public function profile_nav( $user = null, $active = 'WordPress' ) { 192 193 if ( empty( $user->ID ) ) { 194 return; 195 } 196 197 $query_args = array( 'user_id' => $user->ID ); 198 199 if ( ! empty( $_REQUEST['wp_http_referer'] ) ) { 200 $query_args['wp_http_referer'] = urlencode( wp_unslash( $_REQUEST['wp_http_referer'] ) ); 201 } 202 203 $community_url = add_query_arg( $query_args, $this->edit_profile_url ); 204 $wordpress_url = add_query_arg( $query_args, $this->edit_url ); 205 206 $bp_active = false; 207 $wp_active = ' nav-tab-active'; 208 if ( 'BuddyPress' == $active ) { 209 $bp_active = ' nav-tab-active'; 210 $wp_active = false; 211 } 212 213 ?> 214 <ul id="profile-nav" class="nav-tab-wrapper"> 215 <li class="nav-tab<?php echo $wp_active;?>"><a href="<?php echo $wordpress_url;?>"><?php _e( 'WordPress Profile' ); ?></a></li> 216 <li class="nav-tab<?php echo $bp_active;?>"><a href="<?php echo $community_url;?>"><?php _e( 'Community Profile' ); ?></a></li> 217 </ul> 218 <?php 219 } 220 221 /** 222 * Highlight the Users menu if on Edit Profile pages. 223 * 224 * @since BuddyPress (2.0.0) 225 */ 226 public function modify_admin_menu_highlight() { 227 global $plugin_page, $submenu_file; 228 229 // Only Show the All users menu 230 if ( 'bp-profile-edit' == $plugin_page ) { 231 $submenu_file = 'users.php'; 232 } 233 } 234 235 /** 236 * Remove the Edit Profile submenu page. 237 * 238 * @since BuddyPress (2.0.0) 239 */ 240 public function admin_head() { 241 // Remove submenu to force using Profile Navigation 242 remove_submenu_page( 'users.php', 'bp-profile-edit' ); 243 } 244 245 /** 246 * Set up the user's profile admin page. 247 * 248 * Loaded before the page is rendered, this function does all initial 249 * setup, including: processing form requests, registering contextual 250 * help, and setting up screen options. 251 * 252 * @since BuddyPress (2.0.0) 253 */ 254 public function user_admin_load() { 255 256 if ( ! $user_id = intval( $_GET['user_id'] ) ) { 257 wp_die( __( 'No users were found', 'buddypress' ) ); 258 } 259 260 $bp = buddypress(); 261 262 // Build redirection URL 263 $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham', 'delete_avatar' ), $_SERVER['REQUEST_URI'] ); 264 $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : false; 265 266 if ( ! empty( $_REQUEST['user_status'] ) ) { 267 $spam = ( 'spam' == $_REQUEST['user_status'] ) ? true : false ; 268 269 if ( $spam != bp_is_user_spammer( $user_id ) ) { 270 $doaction = $_REQUEST['user_status']; 271 } 272 } 273 274 // Call an action for plugins to hook in early 275 do_action_ref_array( 'bp_members_admin_load', array( $doaction, $_REQUEST ) ); 276 277 // Prepare the display of the Community Profile screen 278 if ( ! in_array( $doaction, array( 'update', 'delete_avatar', 'spam', 'ham' ) ) ) { 279 add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) ); 280 281 get_current_screen()->add_help_tab( array( 282 'id' => 'bp-profile-edit-overview', 283 'title' => __( 'Overview', 'buddypress' ), 284 'content' => 285 '<p>' . __( 'This is the admin view of a user's profile.', 'buddypress' ) . '</p>' . 286 '<p>' . __( 'You can edit the different fields of his extended profile from the main metabox', 'buddypress' ) . '</p>' . 287 '<p>' . __( 'You can get some interesting informations about him on right side metaboxes', 'buddypress' ) . '</p>' 288 ) ); 289 290 // Help panel - sidebar links 291 get_current_screen()->set_help_sidebar( 292 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . 293 '<p>' . __( '<a href="http://codex.buddypress.org/buddypress-site-administration/managing-user-profiles/">Managing Profiles</a>', 'buddypress' ) . '</p>' . 294 '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>' 295 ); 296 297 // Register metaboxes for the edit screen. 298 add_meta_box( 'submitdiv', _x( 'Status', 'members user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_status_metabox' ), get_current_screen()->id, 'side', 'core' ); 299 300 // In case xprofile is not active 301 $this->stats_metabox->context = 'normal'; 302 $this->stats_metabox->priority = 'core'; 303 304 /** 305 * xProfile Hooks to load the profile fields if component is active 306 * Plugins should not use this hook, please use 'bp_members_admin_user_metaboxes' instead 307 */ 308 do_action_ref_array( 'bp_members_admin_xprofile_metabox', array( $user_id, get_current_screen()->id, $this->stats_metabox ) ); 309 310 // If xProfile is inactive, difficult to know what's profile we're on 311 $display_name = false; 312 if ( 'normal' == $this->stats_metabox->context ) { 313 $display_name = ' - ' . esc_html( bp_core_get_user_displayname( $user_id ) ); 314 } 315 316 // User Stat metabox 317 add_meta_box( 'bp_members_admin_user_stats', _x( 'Stats' . $display_name, 'members user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_stats_metabox' ), get_current_screen()->id, $this->stats_metabox->context, $this->stats_metabox->priority ); 318 319 // Custom metabox ? 320 do_action( 'bp_members_admin_user_metaboxes' ); 321 322 // Enqueue javascripts 323 wp_enqueue_script( 'postbox' ); 324 wp_enqueue_script( 'dashboard' ); 325 wp_enqueue_script( 'comment' ); 326 327 // Spam or Ham user 328 } else if ( in_array( $doaction, array( 'spam', 'ham' ) ) ) { 329 330 check_admin_referer( 'edit-bp-profile_' . $user_id ); 331 332 if ( bp_core_process_spammer_status( $user_id, $doaction ) ) { 333 $redirect_to = add_query_arg( 'updated', $doaction, $redirect_to ); 334 } else { 335 $redirect_to = add_query_arg( 'error', $doaction, $redirect_to ); 336 } 337 338 bp_core_redirect( $redirect_to ); 339 340 // Update other stuff once above ones are done 341 } else { 342 $this->redirect = $redirect_to; 343 344 do_action_ref_array( 'bp_members_admin_update_user', array( $doaction, $user_id, $_REQUEST, $this->redirect ) ); 345 346 bp_core_redirect( $this->redirect ); 347 } 348 } 349 350 /** 351 * Display the user's profile. 352 * 353 * @since BuddyPress (2.0.0) 354 */ 355 public function user_admin() { 356 357 if ( ! current_user_can( 'bp_moderate' ) ) { 358 die( '-1' ); 359 } 360 361 $user = get_user_to_edit( $_GET['user_id'] ); 362 363 // Construct URL for form 364 $form_url = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham' ), $_SERVER['REQUEST_URI'] ); 365 $form_url = add_query_arg( 'action', 'update', $form_url ); 366 $wp_http_referer = remove_query_arg( array( 'action', 'updated' ), $_REQUEST['wp_http_referer'] ); 367 368 // Prepare notice for admin 369 $notice = array(); 370 371 if ( ! empty( $_REQUEST['updated'] ) ) { 372 switch ( $_REQUEST['updated'] ) { 373 case 'avatar': 374 $notice = array( 375 'class' => 'updated', 376 'message' => __( 'Avatar was deleted successfully!', 'buddypress' ) 377 ); 378 break; 379 case 'ham' : 380 $notice = array( 381 'class' => 'updated', 382 'message' => __( 'User removed as spammer.', 'buddypress' ) 383 ); 384 break; 385 case 'spam' : 386 $notice = array( 387 'class' => 'updated', 388 'message' => __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) 389 ); 390 break; 391 case 1 : 392 $notice = array( 393 'class' => 'updated', 394 'message' => __( 'Profile updated.', 'buddypress' ) 395 ); 396 break; 397 } 398 } 399 400 if ( ! empty( $_REQUEST['error'] ) ) { 401 switch ( $_REQUEST['error'] ) { 402 case 'avatar': 403 $notice = array( 404 'class' => 'error', 405 'message' => __( 'There was a problem deleting that avatar, please try again.', 'buddypress' ) 406 ); 407 break; 408 case 'ham' : 409 $notice = array( 410 'class' => 'error', 411 'message' => __( 'User could not be removed as spammer.', 'buddypress' ) 412 ); 413 break; 414 case 'spam' : 415 $notice = array( 416 'class' => 'error', 417 'message' => __( 'User could not be marked as spammer.', 'buddypress' ) 418 ); 419 break; 420 case 1 : 421 $notice = array( 422 'class' => 'error', 423 'message' => __( 'An error occured while trying to update the profile.', 'buddypress' ) 424 ); 425 break; 426 case 2: 427 $notice = array( 428 'class' => 'error', 429 'message' => __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ) 430 ); 431 break; 432 case 3: 433 $notice = array( 434 'class' => 'error', 435 'message' => __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' ) 436 ); 437 break; 438 } 439 } 440 441 if ( ! empty( $notice ) ) : 442 if ( 'updated' === $notice['class'] ) : ?> 443 <div id="message" class="<?php echo esc_attr( $notice['class'] ); ?>"> 444 <?php else: ?> 445 <div class="<?php echo esc_attr( $notice['class'] ); ?>"> 446 <?php endif; ?> 447 <p><?php echo $notice['message']; ?></p> 448 <?php if ( !empty( $wp_http_referer ) && ( 'updated' === $notice['class'] ) ) : ?> 449 <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e( '← Back to Users', 'buddypress' ); ?></a></p> 450 <?php endif; ?> 451 </div> 452 <?php endif; ?> 453 454 <div class="wrap" id="community-profile-page"> 455 <?php screen_icon( 'users' ); ?> 456 <h2> 457 <?php 458 _e( 'Edit User', 'buddypress' ); 459 if ( current_user_can( 'create_users' ) ) { ?> 460 <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user', 'buddypress' ); ?></a> 461 <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> 462 <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user', 'buddypress' ); ?></a> 463 <?php } 464 ?> 465 </h2> 466 467 <?php if ( ! empty( $user ) ) : 468 469 $this->profile_nav( $user, 'BuddyPress' ); ?> 470 471 <form action="<?php echo esc_attr( $form_url ); ?>" id="your-profile" method="post"> 472 <div id="poststuff"> 473 474 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> 475 <div id="post-body-content"> 476 </div><!-- #post-body-content --> 477 478 <div id="postbox-container-1" class="postbox-container"> 479 <?php do_meta_boxes( get_current_screen()->id, 'side', $user ); ?> 480 </div> 481 482 <div id="postbox-container-2" class="postbox-container"> 483 <?php do_meta_boxes( get_current_screen()->id, 'normal', $user ); ?> 484 <?php do_meta_boxes( get_current_screen()->id, 'advanced', $user ); ?> 485 </div> 486 </div><!-- #post-body --> 487 488 </div><!-- #poststuff --> 489 490 <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> 491 <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> 492 <?php wp_nonce_field( 'edit-bp-profile_' . $user->ID ); ?> 493 494 </form> 495 496 <?php else : ?> 497 <p><?php printf( __( 'No user found with this ID. <a href="%s">Go back and try again</a>.', 'buddypress' ), esc_url( bp_get_admin_url( 'users.php' ) ) ); ?></p> 498 <?php endif; ?> 499 500 </div><!-- .wrap --> 501 <?php 502 } 503 504 /** 505 * Render the Status metabox for user's profile screen. 506 * 507 * Actions are: 508 * - Update profile fields if xProfile component is active 509 * - Spam/Unspam user 510 * 511 * @since BuddyPress (2.0.0) 512 * 513 * @param WP_User $user The WP_User object to be edited. 514 */ 515 public function user_admin_status_metabox( $user = null ) { 516 517 // bail if no user id or if the user has not activated his account yet.. 518 if ( empty( $user->ID ) ) { 519 return; 520 } 521 522 523 if ( ( isset( $user->user_status ) && 2 == $user->user_status ) ) { 524 echo '<p class="not-activated">' . sprintf( 'User has not activated his account yet', 'buddypress' ) . '</p><br/>'; 525 return; 526 } 527 ?> 528 529 <div class="submitbox" id="submitcomment"> 530 <div id="minor-publishing"> 531 <div id="minor-publishing-actions"> 532 <div id="preview-action"> 533 <a class="button preview" href="<?php echo esc_attr( bp_core_get_user_domain( $user->ID ) ); ?>" target="_blank"><?php _e( 'View Profile', 'buddypress' ); ?></a> 534 </div> 535 536 <div class="clear"></div> 537 </div><!-- #minor-publishing-actions --> 538 539 <div id="misc-publishing-actions"> 540 <div class="misc-pub-section" id="comment-status-radio"> 541 <label class="approved"><input type="radio" name="user_status" value="ham" <?php checked( bp_is_user_spammer( $user->ID ), false ); ?>><?php _e( 'Active', 'buddypress' ); ?></label><br /> 542 <label class="spam"><input type="radio" name="user_status" value="spam" <?php checked( bp_is_user_spammer( $user->ID ), true ); ?>><?php _e( 'Spammer', 'buddypress' ); ?></label> 543 </div> 544 545 <div class="misc-pub-section curtime misc-pub-section-last"> 546 <?php 547 // translators: Publish box date format, see http://php.net/date 548 $datef = __( 'M j, Y @ G:i', 'buddypress' ); 549 $date = date_i18n( $datef, strtotime( $user->user_registered ) ); 550 ?> 551 <span id="timestamp"><?php printf( __( 'Registered on: <strong>%1$s</strong>', 'buddypress' ), $date ); ?></span> 552 </div> 553 </div> <!-- #misc-publishing-actions --> 554 555 <div class="clear"></div> 556 </div><!-- #minor-publishing --> 557 558 <div id="major-publishing-actions"> 559 <div id="publishing-action"> 560 <?php submit_button( __( 'Update Profile', 'buddypress' ), 'primary', 'save', false, array( 'tabindex' => '4' ) ); ?> 561 </div> 562 <div class="clear"></div> 563 </div><!-- #major-publishing-actions --> 564 565 </div><!-- #submitcomment --> 566 567 <?php 568 } 569 570 /** 571 * Render the fallback metabox in case a user has been marked as a spammer. 572 * 573 * @since BuddyPress (2.0.0) 574 * 575 * @param WP_User $user The WP_User object to be edited. 576 */ 577 public function user_admin_spammer_metabox( $user = null ) { 578 ?> 579 <p><?php printf( __( '%s has been marked as a spammer, this user's BuddyPress datas were removed', 'buddypress' ), bp_core_get_user_displayname( $user->ID ) ) ;?></p> 580 <?php 581 } 582 583 /** 584 * Render the Stats metabox to moderate inappropriate images. 585 * 586 * @since BuddyPress (2.0.0) 587 * 588 * @param WP_User $user The WP_User object to be edited. 589 */ 590 public function user_admin_stats_metabox( $user = null ) { 591 592 if ( empty( $user->ID ) ) { 593 return; 594 } 595 596 // If account is not activated last activity is the time user registered 597 if ( isset( $user->user_status ) && 2 == $user->user_status ) { 598 $last_active = $user->user_registered; 599 // Account is activated, getting user's last activity 600 } else { 601 $last_active = bp_get_user_last_activity( $user->ID ); 602 } 603 604 $datef = __( 'M j, Y @ G:i', 'buddypress' ); 605 $date = date_i18n( $datef, strtotime( $last_active ) ); ?> 606 607 <ul> 608 <li><div class="dashicons dashicons-last-active"></div> <?php printf( __( 'Last active: <strong>%1$s</strong>', 'buddypress' ), $date ); ?></li> 609 610 <?php 611 // Loading other stats only if user has activated his account 612 if ( empty( $user->user_status ) ) { 613 do_action( 'bp_members_admin_user_stats', $user->ID, $user ); 614 } 615 ?> 616 </ul> 617 <?php 618 } 619 620 /** 621 * Add a link to Profile in Users listing row actions. 622 * 623 * @since BuddyPress (2.0.0) 624 * 625 * @param array $actions WordPress row actions (edit, delete). 626 * @param object $user The object for the user row. 627 * @return array Merged actions. 628 */ 629 public function row_actions( $actions = '', $user = null ) { 630 631 $edit_profile = add_query_arg( array( 632 'user_id' => $user->ID, 633 'wp_http_referer' => urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 634 ), $this->edit_profile_url ); 635 636 $edit_action = $actions['edit']; 637 unset( $actions['edit'] ); 638 639 $new_edit_actions = array( 640 'edit' => $edit_action, 641 'edit-profile' => '<a href="' . esc_url( $edit_profile ) . '">' . __( 'Profile', 'buddypress' ) . '</a>' 642 ); 643 644 return array_merge( $new_edit_actions, $actions ); 645 } 646 647 } 648 endif; // class_exists check 649 650 /** 651 * Setup BP Members Admin. 652 * 653 * @since BuddyPress (2.0.0) 654 * 655 * @uses buddypress() to get BuddyPress main instance 656 */ 657 function bp_members_admin() { 658 buddypress()->members->admin = new BP_Members_Admin(); 659 } 660 661 // Load the BP Members admin 662 if ( is_admin() ) { 663 add_action( 'bp_init', 'bp_members_admin' ); 664 } -
bp-members/bp-members-functions.php
diff --git bp-members/bp-members-functions.php bp-members/bp-members-functions.php index 795c228..d7744fa 100644
function bp_core_process_spammer_status( $user_id, $status ) { 563 563 remove_action( 'make_spam_user', 'bp_core_mark_user_spam_admin' ); 564 564 remove_action( 'make_ham_user', 'bp_core_mark_user_ham_admin' ); 565 565 566 // Determine if we are on an admin page 567 $is_admin = is_admin(); 568 if ( $is_admin && ! defined( 'DOING_AJAX' ) ) { 569 $is_admin = (bool) ( buddypress()->members->admin->user_page !== get_current_screen()->id ); 570 } 571 566 572 // When marking as spam in the Dashboard, these actions are handled by WordPress 567 if ( ! is_admin()) {573 if ( ! $is_admin ) { 568 574 569 575 // Get the blogs for the user 570 576 $blogs = get_blogs_of_user( $user_id, true ); -
bp-members/bp-members-loader.php
diff --git bp-members/bp-members-loader.php bp-members/bp-members-loader.php index d87683d..c654240 100644
class BP_Members_Component extends BP_Component { 45 45 'functions', 46 46 'notifications', 47 47 ); 48 49 if ( is_admin() ) { 50 $includes[] = 'admin'; 51 } 52 48 53 parent::includes( $includes ); 49 54 } 50 55 -
bp-xprofile/bp-xprofile-admin.php
diff --git bp-xprofile/bp-xprofile-admin.php bp-xprofile/bp-xprofile-admin.php index 95151ea..a658e4a 100644
function xprofile_admin_field( $admin_field, $admin_group, $class = '' ) { 466 466 467 467 <?php 468 468 } 469 470 if ( ! class_exists( 'BP_XProfile_User_Admin' ) ) : 471 /** 472 * Load xProfile Profile admin area. 473 * 474 * @package BuddyPress 475 * @subpackage xProfileAdministration 476 * 477 * @since BuddyPress (2.0.0) 478 */ 479 class BP_XProfile_User_Admin { 480 481 /** 482 * Constructor method. 483 * 484 * @since BuddyPress (2.0.0) 485 */ 486 public function __construct() { 487 $this->setup_actions(); 488 } 489 490 /** 491 * Set admin-related actions and filters. 492 * 493 * @since BuddyPress (2.0.0) 494 */ 495 private function setup_actions() { 496 497 /** Actions ***************************************************/ 498 499 // Register the metabox in Member's community admin profile 500 add_action( 'bp_members_admin_xprofile_metabox', array( $this, 'register_metaboxes' ), 10, 3 ); 501 502 // Saves the profile actions for user ( avatar, profile fields ) 503 add_action( 'bp_members_admin_update_user', array( $this, 'user_admin_load' ), 10, 4 ); 504 505 } 506 507 /** 508 * Register the xProfile metabox on Community Profile admin page. 509 * 510 * @since BuddyPress (2.0.0) 511 * 512 * @param int $user_id ID of the user being edited. 513 * @param string $screen_id Screen ID to load the metabox in. 514 * @param object $stats_metabox Context and priority for the stats metabox. 515 */ 516 public function register_metaboxes( $user_id = 0, $screen_id = '', $stats_metabox = null ) { 517 518 if ( empty( $screen_id ) ) { 519 $screen_id = buddypress()->members->admin->user_page; 520 } 521 522 if ( empty( $stats_metabox ) ) { 523 $stats_metabox = new StdClass(); 524 } 525 526 // Moving the Stats Metabox 527 $stats_metabox->context = 'side'; 528 $stats_metabox->priority = 'low'; 529 530 // Each Group of fields will have his own metabox 531 if ( false == bp_is_user_spammer( $user_id ) && bp_has_profile( array( 'fetch_fields' => false ) ) ) { 532 while ( bp_profile_groups() ) : bp_the_profile_group(); 533 add_meta_box( 'bp_xprofile_user_admin_fields_' . bp_get_the_profile_group_slug(), bp_get_the_profile_group_name(), array( &$this, 'user_admin_profile_metaboxes' ), $screen_id, 'normal', 'core', array( 'profile_group_id' => bp_get_the_profile_group_id() ) ); 534 endwhile; 535 536 // if a user has been mark as a spammer, his BuddyPress datas are removed ! 537 } else { 538 add_meta_box( 'bp_xprofile_user_admin_empty_profile', _x( 'User marked as a spammer', 'xprofile user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_spammer_metabox' ), $screen_id, 'normal', 'core' ); 539 } 540 541 // Avatar Metabox 542 add_meta_box( 'bp_xprofile_user_admin_avatar', _x( 'Avatar', 'xprofile user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_avatar_metabox' ), $screen_id, 'side', 'low' ); 543 544 } 545 546 /** 547 * Save the profile fields in Members community profile page. 548 * 549 * Loaded before the page is rendered, this function is processing form 550 * requests. 551 * 552 * @since BuddyPress (2.0.0) 553 */ 554 public function user_admin_load( $doaction = '', $user_id = 0, $request = array(), $redirect_to = '' ) { 555 556 // Eventually delete avatar 557 if ( 'delete_avatar' == $doaction ) { 558 559 check_admin_referer( 'delete_avatar' ); 560 561 $redirect_to = remove_query_arg( '_wpnonce', $redirect_to ); 562 563 if ( bp_core_delete_existing_avatar( array( 'item_id' => $user_id ) ) ) { 564 $redirect_to = add_query_arg( 'updated', 'avatar', $redirect_to ); 565 } else { 566 $redirect_to = add_query_arg( 'error', 'avatar', $redirect_to ); 567 } 568 569 bp_core_redirect( $redirect_to ); 570 571 // Update profile fields 572 } else { 573 // Check to see if any new information has been submitted 574 if ( isset( $_POST['field_ids'] ) ) { 575 576 // Check the nonce 577 check_admin_referer( 'edit-bp-profile_' . $user_id ); 578 579 // Check we have field ID's 580 if ( empty( $_POST['field_ids'] ) ) { 581 $redirect_to = add_query_arg( 'error', '1', $redirect_to ); 582 bp_core_redirect( $redirect_to ); 583 } 584 585 $merge_ids = ''; 586 foreach ( $_POST['field_ids'] as $ids ) { 587 $merge_ids .= $ids . ','; 588 } 589 590 // Explode the posted field IDs into an array so we know which 591 // fields have been submitted 592 $posted_field_ids = array_filter( wp_parse_id_list( $merge_ids ) ); 593 $is_required = array(); 594 595 // Loop through the posted fields formatting any datebox values 596 // then validate the field 597 foreach ( (array) $posted_field_ids as $field_id ) { 598 if ( ! isset( $_POST['field_' . $field_id] ) ) { 599 if ( ! empty( $_POST['field_' . $field_id . '_day'] ) && ! empty( $_POST['field_' . $field_id . '_month'] ) && ! empty( $_POST['field_' . $field_id . '_year'] ) ) { 600 // Concatenate the values 601 $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year']; 602 603 // Turn the concatenated value into a timestamp 604 $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) ); 605 } 606 } 607 608 $is_required[ $field_id ] = xprofile_check_is_required_field( $field_id ); 609 if ( $is_required[ $field_id ] && empty( $_POST['field_' . $field_id] ) ) { 610 $redirect_to = add_query_arg( 'error', '2', $redirect_to ); 611 bp_core_redirect( $redirect_to ); 612 } 613 } 614 615 // Set the errors var 616 $errors = false; 617 var_dump( $posted_field_ids ); die(); 618 // Now we've checked for required fields, lets save the values. 619 foreach ( (array) $posted_field_ids as $field_id ) { 620 621 // Certain types of fields (checkboxes, multiselects) may come through empty. Save them as an empty array so that they don't get overwritten by the default on the next edit. 622 if ( empty( $_POST['field_' . $field_id] ) ) { 623 $value = array(); 624 } else { 625 $value = $_POST['field_' . $field_id]; 626 } 627 628 if ( ! xprofile_set_field_data( $field_id, $user_id, $value, $is_required[ $field_id ] ) ) { 629 $errors = true; 630 } else { 631 do_action( 'xprofile_profile_field_data_updated', $field_id, $value ); 632 } 633 634 // Save the visibility level 635 $visibility_level = ! empty( $_POST['field_' . $field_id . '_visibility'] ) ? $_POST['field_' . $field_id . '_visibility'] : 'public'; 636 xprofile_set_field_visibility_level( $field_id, $user_id, $visibility_level ); 637 } 638 639 do_action( 'xprofile_updated_profile', $user_id, $posted_field_ids, $errors ); 640 641 // Set the feedback messages 642 if ( ! empty( $errors ) ) { 643 $redirect_to = add_query_arg( 'error', '3', $redirect_to ); 644 } else { 645 $redirect_to = add_query_arg( 'updated', '1', $redirect_to ); 646 } 647 648 bp_core_redirect( $redirect_to ); 649 } 650 } 651 } 652 653 /** 654 * Render the xprofile metabox for Community Profile screen. 655 * 656 * @since BuddyPress (2.0.0) 657 * 658 * @param WP_User $user The WP_User object for the user being edited. 659 */ 660 public function user_admin_profile_metaboxes( $user = null, $args = array() ) { 661 662 if ( empty( $user->ID ) ) { 663 return; 664 } 665 666 $r = bp_parse_args( $args['args'], array( 667 'profile_group_id' => 0, 668 'user_id' => $user->ID 669 ), 'bp_xprofile_user_admin_profile_loop_args' ); 670 671 // We really need these args 672 if ( empty( $r['profile_group_id'] ) || empty( $r['user_id'] ) ) { 673 return; 674 } 675 676 if ( bp_has_profile( $r ) ) : 677 678 while ( bp_profile_groups() ) : bp_the_profile_group(); ?> 679 680 <p class="description"><?php bp_the_profile_group_description(); ?></p> 681 682 <table class="form-table"> 683 <tbody> 684 685 <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> 686 687 <tr> 688 689 <?php if ( 'textbox' === bp_get_the_profile_field_type() ) : ?> 690 691 <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> 692 <td> 693 <input type="text" name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" value="<?php bp_the_profile_field_edit_value(); ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>/> 694 <span class="description"><?php bp_the_profile_field_description(); ?></span> 695 </td> 696 697 <?php endif; ?> 698 699 <?php if ( 'textarea' === bp_get_the_profile_field_type() ) : ?> 700 701 <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> 702 <td> 703 <textarea rows="5" cols="40" name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>><?php bp_the_profile_field_edit_value(); ?></textarea> 704 <p class="description"><?php bp_the_profile_field_description(); ?></p> 705 </td> 706 707 <?php endif; ?> 708 709 <?php if ( 'selectbox' === bp_get_the_profile_field_type() ) : ?> 710 711 <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> 712 <td> 713 <select name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> 714 <?php bp_the_profile_field_options( array( 'user_id' => $r['user_id'], ) ); ?> 715 </select> 716 <span class="description"><?php bp_the_profile_field_description(); ?></span> 717 </td> 718 719 <?php endif; ?> 720 721 <?php if ( 'multiselectbox' === bp_get_the_profile_field_type() ) : ?> 722 723 <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> 724 <td> 725 <select name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" multiple="multiple" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> 726 727 <?php bp_the_profile_field_options( array( 'user_id' => $r['user_id'], ) ); ?> 728 729 </select> 730 731 732 <?php if ( !bp_get_the_profile_field_is_required() ) : ?> 733 734 <p><a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name(); ?>' );"><?php _e( 'Clear', 'buddypress' ); ?></a></p> 735 736 <?php endif; ?> 737 <p class="description"><?php bp_the_profile_field_description(); ?></p> 738 </td> 739 740 <?php endif; ?> 741 742 <?php if ( 'radio' === bp_get_the_profile_field_type() ) : ?> 743 744 <th> 745 <span class="label"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></span> 746 </th> 747 <td> 748 <fieldset> 749 <legend class="screen-reader-text"><span><?php bp_the_profile_field_name(); ?></span></legend> 750 <?php bp_the_profile_field_options( array( 'user_id' => $r['user_id'], ) ); ?> 751 </fieldset> 752 753 <?php if ( !bp_get_the_profile_field_is_required() ) : ?> 754 755 <p><a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name(); ?>' );"><?php _e( 'Clear', 'buddypress' ); ?></a></p> 756 757 <?php endif; ?> 758 <p class="description"><?php bp_the_profile_field_description(); ?></p> 759 </td> 760 761 <?php endif; ?> 762 763 <?php if ( 'checkbox' === bp_get_the_profile_field_type() ) : ?> 764 765 <th> 766 <span class="label"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></span> 767 </th> 768 <td> 769 <?php bp_the_profile_field_options( array( 'user_id' => $r['user_id'], ) ); ?> 770 <p class="description"><?php bp_the_profile_field_description(); ?></p> 771 </td> 772 773 <?php endif; ?> 774 775 <?php if ( 'datebox' === bp_get_the_profile_field_type() ) : ?> 776 777 <th> 778 <label for="<?php bp_the_profile_field_input_name(); ?>_day"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label> 779 </th> 780 <td> 781 <select name="<?php bp_the_profile_field_input_name(); ?>_day" id="<?php bp_the_profile_field_input_name(); ?>_day" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> 782 783 <?php bp_the_profile_field_options( array( 'user_id' => $r['user_id'], 'type' => 'day', ) ); ?> 784 785 </select> 786 787 <select name="<?php bp_the_profile_field_input_name(); ?>_month" id="<?php bp_the_profile_field_input_name(); ?>_month" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> 788 789 <?php bp_the_profile_field_options( array( 'user_id' => $r['user_id'], 'type' => 'month', ) ); ?> 790 791 </select> 792 793 <select name="<?php bp_the_profile_field_input_name(); ?>_year" id="<?php bp_the_profile_field_input_name(); ?>_year" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> 794 795 <?php bp_the_profile_field_options( array( 'user_id' => $r['user_id'], 'type' => 'year', ) ); ?> 796 797 </select> 798 <p class="description"><?php bp_the_profile_field_description(); ?></p> 799 </td> 800 801 <?php endif; ?> 802 803 </tr> 804 805 <tr class="admin-field-visibility-tr"> 806 <td class="admin-field-visibility-td"> </td> 807 <td class="admin-field-visibility-td"> 808 809 <?php do_action( 'bp_custom_profile_edit_fields_pre_visibility' ); ?> 810 811 <?php if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?> 812 <p class="description field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>"> 813 <?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?> <a href="#" class="visibility-toggle-link"><?php _e( 'Change', 'buddypress' ); ?></a> 814 </p> 815 816 <div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id() ?>"> 817 <fieldset> 818 <legend><?php _e( 'Who can see this field?', 'buddypress' ) ?></legend> 819 820 <?php bp_profile_visibility_radio_buttons() ?> 821 822 </fieldset> 823 <a class="field-visibility-settings-close" href="#"><?php _e( 'Close', 'buddypress' ) ?></a> 824 </div> 825 <?php else : ?> 826 <div class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>"> 827 <?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?> 828 </div> 829 <?php endif ?> 830 831 </td> 832 </tr> 833 834 <?php endwhile; ?> 835 </tbody> 836 837 </table> 838 <input type="hidden" name="field_ids[]" id="field_ids_<?php bp_the_profile_group_slug(); ?>" value="<?php bp_the_profile_group_field_ids(); ?>" /> 839 <?php endwhile; 840 endif; 841 } 842 843 /** 844 * Render the fallback metabox in case a user has been marked as a spammer. 845 * 846 * @since BuddyPress (2.0.0) 847 * 848 * @param WP_User $user The WP_User object for the user being edited. 849 */ 850 public function user_admin_spammer_metabox( $user = null ) { 851 ?> 852 <p><?php printf( __( '%s has been marked as a spammer, this user's BuddyPress datas were removed', 'buddypress' ), bp_core_get_user_displayname( $user->ID ) ) ;?></p> 853 <?php 854 } 855 856 /** 857 * Render the Avatar metabox to moderate inappropriate images. 858 * 859 * @since BuddyPress (2.0.0) 860 * 861 * @param WP_User $user The WP_User object for the user being edited. 862 */ 863 public function user_admin_avatar_metabox( $user = null ) { 864 865 if ( empty( $user->ID ) ) { 866 return; 867 } 868 869 $args = array( 870 'item_id' => $user->ID, 871 'object' => 'user', 872 'type' => 'full', 873 'title' => $user->display_name 874 ); 875 876 ?> 877 878 <div class="avatar"> 879 880 <?php echo bp_core_fetch_avatar( $args ); ?> 881 882 <?php if ( bp_get_user_has_avatar( $user->ID ) ) : 883 884 $query_args = array( 885 'user_id' => $user->ID, 886 'action' => 'delete_avatar' 887 ); 888 889 if ( ! empty( $_REQUEST['wp_http_referer'] ) ) 890 $query_args['wp_http_referer'] = urlencode( wp_unslash( $_REQUEST['wp_http_referer'] ) ); 891 892 $community_url = add_query_arg( $query_args, buddypress()->members->admin->edit_profile_url ); 893 $delete_link = wp_nonce_url( $community_url, 'delete_avatar' ); ?> 894 895 <a href="<?php echo esc_url( $delete_link ); ?>" title="<?php _e( 'Delete Avatar', 'buddypress' ); ?>"><span class="dashicons dashicons dashicons-trash"></span> <?php _e( 'Delete Avatar', 'buddypress' ); ?></a></li> 896 897 <?php endif; ?> 898 899 </div> 900 <?php 901 } 902 903 } 904 endif; // class_exists check 905 906 /** 907 * Setup xProfile User Admin. 908 * 909 * @since BuddyPress (2.0.0) 910 * 911 * @uses buddypress() to get BuddyPress main instance 912 */ 913 function xprofile_user_admin() { 914 buddypress()->profile->admin = new BP_XProfile_User_Admin(); 915 } 916 917 // Load the xprofile user admin 918 if ( is_admin() ) { 919 add_action( 'bp_init', 'xprofile_user_admin', 11 ); 920 } -
bp-xprofile/bp-xprofile-filters.php
diff --git bp-xprofile/bp-xprofile-filters.php bp-xprofile/bp-xprofile-filters.php index bde9c50..05641fa 100644
add_filter( 'comments_array', 'xprofile_filter_comments', 10, 2 ); 247 247 function bp_xprofile_filter_user_query_populate_extras( BP_User_Query $user_query, $user_ids_sql ) { 248 248 global $bp, $wpdb; 249 249 250 if ( bp_is_active( 'xprofile' ) ) { 251 $fullname_field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", bp_xprofile_fullname_field_name() ) ); 252 $user_id_names = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, value as fullname FROM {$bp->profile->table_name_data} WHERE user_id IN ({$user_ids_sql}) AND field_id = %d", $fullname_field_id ) ); 253 254 // Loop through names and override each user's fullname 255 foreach ( $user_id_names as $user ) { 256 if ( isset( $user_query->results[ $user->user_id ] ) ) { 257 $user_query->results[ $user->user_id ]->fullname = $user->fullname; 258 } 250 if ( ! bp_is_active( 'xprofile' ) ) { 251 return; 252 } 253 254 $fullname_field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", bp_xprofile_fullname_field_name() ) ); 255 $user_id_names = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, value as fullname FROM {$bp->profile->table_name_data} WHERE user_id IN ({$user_ids_sql}) AND field_id = %d", $fullname_field_id ) ); 256 257 // Loop through names and override each user's fullname 258 foreach ( $user_id_names as $user ) { 259 if ( isset( $user_query->results[ $user->user_id ] ) ) { 260 $user_query->results[ $user->user_id ]->fullname = $user->fullname; 259 261 } 260 262 } 261 263 } 262 264 add_filter( 'bp_user_query_populate_extras', 'bp_xprofile_filter_user_query_populate_extras', 2, 2 ); 265 266 /** 267 * Filter radio profile fields output in administration screens. 268 * 269 * @since BuddyPress (2.0.0) 270 * 271 * @param string $output 272 * @param object $option 273 * @param integer $field_id 274 * @param boolean $selected 275 * @return string HTML output. 276 */ 277 function bp_xprofile_admin_format_radio( $output = '', $option = null, $field_id = 0, $selected = false ) { 278 if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { 279 $output = '<label><input' . $selected . ' type="radio" name="field_' . absint( $field_id ) . '" id="option_' . esc_attr( $option->id ) . '" value="' . esc_attr( stripslashes( $option->name ) ) . '"> ' . esc_attr( stripslashes( $option->name ) ) . '</label><br/>'; 280 } 281 282 return $output; 283 } 284 add_filter( 'bp_get_the_profile_field_options_radio', 'bp_xprofile_admin_format_radio', 10, 4 ); 285 286 /** 287 * Filter checkbox profile fields output in administration screens. 288 * 289 * @since BuddyPress (2.0.0) 290 * 291 * @param string $output 292 * @param object $option 293 * @param integer $field_id 294 * @param boolean $selected 295 * @param integer $k 296 * @return string HTML output. 297 */ 298 function bp_xprofile_admin_format_checkbox( $output= '', $option = null, $field_id = 0, $selected = false, $k = 0 ) { 299 if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { 300 $output = '<label><input' . $selected . ' type="checkbox" name="field_' . absint( $field_id ) . '[]" id="field_' . esc_attr( $option->id ) . '_' . absint( $k ) . '" value="' . esc_attr( stripslashes( $option->name ) ) . '"> ' . esc_attr( stripslashes( $option->name ) ) . '</label><br/>'; 301 } 302 303 return $output; 304 } 305 add_filter( 'bp_get_the_profile_field_options_checkbox', 'bp_xprofile_admin_format_checkbox', 10, 5 ); -
bp-xprofile/bp-xprofile-template.php
diff --git bp-xprofile/bp-xprofile-template.php bp-xprofile/bp-xprofile-template.php index 4f684dc..4bd59c7 100644
class BP_XProfile_Data_Template { 51 51 function next_group() { 52 52 $this->current_group++; 53 53 54 $this->group = $this->groups[$this->current_group]; 55 $this->group->fields = apply_filters( 'xprofile_group_fields', $this->group->fields, $this->group->id ); 56 $this->field_count = count( $this->group->fields ); 54 $this->group = $this->groups[$this->current_group]; 55 $this->field_count = 0; 56 57 if( ! empty( $this->group->fields ) ) { 58 $this->group->fields = apply_filters( 'xprofile_group_fields', $this->group->fields, $this->group->id ); 59 $this->field_count = count( $this->group->fields ); 60 } 57 61 58 62 return $this->group; 59 63 }