<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][12554] trunk/src: Move Avatars & Cover from xProfile to Members component : step 2</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/12554">12554</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/12554","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>imath</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-02-29 15:33:10 +0000 (Sat, 29 Feb 2020)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Move Avatars & Cover from xProfile to Members component : step 2
Move User Avatar's management from the xProfile User Admin to the Members User Admin class.
See <a href="http://buddypress.trac.wordpress.org/ticket/8156">#8156</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpcorejsavatarjs">trunk/src/bp-core/js/avatar.js</a></li>
<li><a href="#trunksrcbpmembersadmincssadminrtlcss">trunk/src/bp-members/admin/css/admin-rtl.css</a></li>
<li><a href="#trunksrcbpmembersadmincssadmincss">trunk/src/bp-members/admin/css/admin.css</a></li>
<li><a href="#trunksrcbpmembersclassesclassbpmembersadminphp">trunk/src/bp-members/classes/class-bp-members-admin.php</a></li>
<li><a href="#trunksrcbpxprofileclassesclassbpxprofileuseradminphp">trunk/src/bp-xprofile/classes/class-bp-xprofile-user-admin.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpcorejsavatarjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/js/avatar.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/js/avatar.js 2020-02-29 15:28:51 UTC (rev 12553)
+++ trunk/src/bp-core/js/avatar.js 2020-02-29 15:33:10 UTC (rev 12554)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -50,7 +50,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> self.resetViews();
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $( 'body.wp-admin' ).on( 'click', '.bp-xprofile-avatar-user-edit', function() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $( 'body.wp-admin' ).on( 'click', '.bp-members-avatar-user-edit', function() {
</ins><span class="cx" style="display: block; padding: 0 10px"> self.resetViews();
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -78,9 +78,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $( '.main-column p #file' ).remove();
</span><span class="cx" style="display: block; padding: 0 10px"> $( '.main-column p #upload' ).remove();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Admin Extended Profile.
- } else if ( $( '#bp_xprofile_user_admin_avatar a.bp-xprofile-avatar-user-admin' ).length ) {
- $( '#bp_xprofile_user_admin_avatar a.bp-xprofile-avatar-user-admin' ).remove();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Member Admin.
+ } else if ( $( '#bp_members_user_admin_avatar a.bp-members-avatar-user-admin' ).length ) {
+ $( '#bp_members_user_admin_avatar a.bp-members-avatar-user-admin' ).remove();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcbpmembersadmincssadminrtlcss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-members/admin/css/admin-rtl.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-members/admin/css/admin-rtl.css 2020-02-29 15:28:51 UTC (rev 12553)
+++ trunk/src/bp-members/admin/css/admin-rtl.css 2020-02-29 15:33:10 UTC (rev 12554)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -29,8 +29,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> div#community-profile-page li.bp-friends-profile-stats:before,
</span><span class="cx" style="display: block; padding: 0 10px"> div#community-profile-page li.bp-groups-profile-stats:before,
</span><span class="cx" style="display: block; padding: 0 10px"> div#community-profile-page li.bp-blogs-profile-stats:before,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-div#community-profile-page a.bp-xprofile-avatar-user-admin:before,
-div#community-profile-page a.bp-xprofile-avatar-user-edit:before {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+div#community-profile-page a.bp-members-avatar-user-admin:before,
+div#community-profile-page a.bp-members-avatar-user-edit:before {
</ins><span class="cx" style="display: block; padding: 0 10px"> font: 400 20px/1 dashicons;
</span><span class="cx" style="display: block; padding: 0 10px"> speak: none;
</span><span class="cx" style="display: block; padding: 0 10px"> display: inline-block;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -61,25 +61,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> content: "\f120";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-div#community-profile-page a.bp-xprofile-avatar-user-admin:before {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+div#community-profile-page a.bp-members-avatar-user-admin:before {
</ins><span class="cx" style="display: block; padding: 0 10px"> content: "\f182";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-div#community-profile-page a.bp-xprofile-avatar-user-edit:before {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+div#community-profile-page a.bp-members-avatar-user-edit:before {
</ins><span class="cx" style="display: block; padding: 0 10px"> content: "\f107";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+div#community-profile-page div#bp_members_user_admin_avatar div.avatar {
</ins><span class="cx" style="display: block; padding: 0 10px"> width: 150px;
</span><span class="cx" style="display: block; padding: 0 10px"> margin: 0 auto;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar img {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+div#community-profile-page div#bp_members_user_admin_avatar div.avatar img {
</ins><span class="cx" style="display: block; padding: 0 10px"> max-width: 100%;
</span><span class="cx" style="display: block; padding: 0 10px"> height: auto;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-div#community-profile-page div#bp_xprofile_user_admin_avatar a {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+div#community-profile-page div#bp_members_user_admin_avatar a {
</ins><span class="cx" style="display: block; padding: 0 10px"> display: block;
</span><span class="cx" style="display: block; padding: 0 10px"> margin: 1em 0;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcbpmembersadmincssadmincss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-members/admin/css/admin.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-members/admin/css/admin.css 2020-02-29 15:28:51 UTC (rev 12553)
+++ trunk/src/bp-members/admin/css/admin.css 2020-02-29 15:33:10 UTC (rev 12554)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -29,8 +29,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> div#community-profile-page li.bp-friends-profile-stats:before,
</span><span class="cx" style="display: block; padding: 0 10px"> div#community-profile-page li.bp-groups-profile-stats:before,
</span><span class="cx" style="display: block; padding: 0 10px"> div#community-profile-page li.bp-blogs-profile-stats:before,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-div#community-profile-page a.bp-xprofile-avatar-user-admin:before,
-div#community-profile-page a.bp-xprofile-avatar-user-edit:before {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+div#community-profile-page a.bp-members-avatar-user-admin:before,
+div#community-profile-page a.bp-members-avatar-user-edit:before {
</ins><span class="cx" style="display: block; padding: 0 10px"> font: 400 20px/1 dashicons;
</span><span class="cx" style="display: block; padding: 0 10px"> speak: none;
</span><span class="cx" style="display: block; padding: 0 10px"> display: inline-block;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -61,25 +61,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> content: "\f120";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-div#community-profile-page a.bp-xprofile-avatar-user-admin:before {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+div#community-profile-page a.bp-members-avatar-user-admin:before {
</ins><span class="cx" style="display: block; padding: 0 10px"> content: "\f182";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-div#community-profile-page a.bp-xprofile-avatar-user-edit:before {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+div#community-profile-page a.bp-members-avatar-user-edit:before {
</ins><span class="cx" style="display: block; padding: 0 10px"> content: "\f107";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+div#community-profile-page div#bp_members_user_admin_avatar div.avatar {
</ins><span class="cx" style="display: block; padding: 0 10px"> width: 150px;
</span><span class="cx" style="display: block; padding: 0 10px"> margin: 0 auto;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar img {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+div#community-profile-page div#bp_members_user_admin_avatar div.avatar img {
</ins><span class="cx" style="display: block; padding: 0 10px"> max-width: 100%;
</span><span class="cx" style="display: block; padding: 0 10px"> height: auto;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-div#community-profile-page div#bp_xprofile_user_admin_avatar a {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+div#community-profile-page div#bp_members_user_admin_avatar a {
</ins><span class="cx" style="display: block; padding: 0 10px"> display: block;
</span><span class="cx" style="display: block; padding: 0 10px"> margin: 1em 0;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcbpmembersclassesclassbpmembersadminphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-members/classes/class-bp-members-admin.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-members/classes/class-bp-members-admin.php 2020-02-29 15:28:51 UTC (rev 12553)
+++ trunk/src/bp-members/classes/class-bp-members-admin.php 2020-02-29 15:33:10 UTC (rev 12554)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -642,6 +642,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $js = apply_filters( 'bp_members_admin_js', $js );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'bp-members-js', $js, array( 'jquery' ), bp_get_version(), true );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( ! bp_core_get_root_option( 'bp-disable-avatar-uploads' ) && buddypress()->avatar->show_avatars ) {
+ /**
+ * Get Thickbox.
+ *
+ * We cannot simply use add_thickbox() here as WordPress is not playing
+ * nice with Thickbox width/height see https://core.trac.wordpress.org/ticket/17249
+ * Using media-upload might be interesting in the future for the send to editor stuff
+ * and we make sure the tb_window is wide enough
+ */
+ wp_enqueue_style ( 'thickbox' );
+ wp_enqueue_script( 'media-upload' );
+
+ // Get Avatar Uploader.
+ bp_attachments_enqueue_scripts( 'BP_Attachment_Avatar' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -723,6 +739,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * help, and setting up screen options.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.0.0 The `delete_avatar` action is now managed into this method.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function user_admin_load() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -819,16 +836,31 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $display_name = __( 'Member', 'buddypress' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Set the screen id.
+ $screen_id = get_current_screen()->id;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // User Stat metabox.
</span><span class="cx" style="display: block; padding: 0 10px"> add_meta_box(
</span><span class="cx" style="display: block; padding: 0 10px"> 'bp_members_admin_user_stats',
</span><span class="cx" style="display: block; padding: 0 10px"> sprintf( _x( "%s's Stats", 'members user-admin edit screen', 'buddypress' ), $display_name ),
</span><span class="cx" style="display: block; padding: 0 10px"> array( $this, 'user_admin_stats_metabox' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- get_current_screen()->id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $screen_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> sanitize_key( $this->stats_metabox->context ),
</span><span class="cx" style="display: block; padding: 0 10px"> sanitize_key( $this->stats_metabox->priority )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( buddypress()->avatar->show_avatars ) {
+ // Avatar Metabox.
+ add_meta_box(
+ 'bp_members_user_admin_avatar',
+ _x( 'Profile Photo', 'members user-admin edit screen', 'buddypress' ),
+ array( $this, 'user_admin_avatar_metabox' ),
+ $screen_id,
+ 'side',
+ 'low'
+ );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Member Type metabox. Only added if member types have been registered.
</span><span class="cx" style="display: block; padding: 0 10px"> $member_types = bp_get_member_types();
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $member_types ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -836,7 +868,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'bp_members_admin_member_type',
</span><span class="cx" style="display: block; padding: 0 10px"> _x( 'Member Type', 'members user-admin edit screen', 'buddypress' ),
</span><span class="cx" style="display: block; padding: 0 10px"> array( $this, 'user_admin_member_type_metabox' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- get_current_screen()->id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $screen_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'side',
</span><span class="cx" style="display: block; padding: 0 10px"> 'core'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -874,6 +906,22 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> bp_core_redirect( $redirect_to );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Eventually delete avatar.
+ } elseif ( 'delete_avatar' === $doaction ) {
+
+ // Check the nonce.
+ check_admin_referer( 'delete_avatar' );
+
+ $redirect_to = remove_query_arg( '_wpnonce', $redirect_to );
+
+ if ( bp_core_delete_existing_avatar( array( 'item_id' => $user_id ) ) ) {
+ $redirect_to = add_query_arg( 'updated', 'avatar', $redirect_to );
+ } else {
+ $redirect_to = add_query_arg( 'error', 'avatar', $redirect_to );
+ }
+
+ bp_core_redirect( $redirect_to );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Update other stuff once above ones are done.
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->redirect = $redirect_to;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1174,6 +1222,61 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Render the Avatar metabox to moderate inappropriate images.
+ *
+ * @since 6.0.0
+ *
+ * @param WP_User|null $user The WP_User object for the user being edited.
+ */
+ public function user_admin_avatar_metabox( $user = null ) {
+
+ if ( empty( $user->ID ) ) {
+ return;
+ } ?>
+
+ <div class="avatar">
+
+ <?php echo bp_core_fetch_avatar( array(
+ 'item_id' => $user->ID,
+ 'object' => 'user',
+ 'type' => 'full',
+ 'title' => $user->display_name
+ ) ); ?>
+
+ <?php if ( bp_get_user_has_avatar( $user->ID ) ) :
+
+ $query_args = array(
+ 'user_id' => $user->ID,
+ 'action' => 'delete_avatar'
+ );
+
+ if ( ! empty( $_REQUEST['wp_http_referer'] ) ) {
+ $wp_http_referer = wp_unslash( $_REQUEST['wp_http_referer'] );
+ $wp_http_referer = remove_query_arg( array( 'action', 'updated' ), $wp_http_referer );
+ $wp_http_referer = wp_validate_redirect( esc_url_raw( $wp_http_referer ) );
+ $query_args['wp_http_referer'] = urlencode( $wp_http_referer );
+ }
+
+ $community_url = add_query_arg( $query_args, $this->edit_profile_url );
+ $delete_link = wp_nonce_url( $community_url, 'delete_avatar' ); ?>
+
+ <a href="<?php echo esc_url( $delete_link ); ?>" class="bp-members-avatar-user-admin"><?php esc_html_e( 'Delete Profile Photo', 'buddypress' ); ?></a>
+
+ <?php endif;
+
+ // Load the Avatar UI templates if user avatar uploads are enabled.
+ if ( ! bp_core_get_root_option( 'bp-disable-avatar-uploads' ) ) : ?>
+ <a href="#TB_inline?width=800px&height=400px&inlineId=bp-members-avatar-editor" class="thickbox bp-members-avatar-user-edit"><?php esc_html_e( 'Edit Profile Photo', 'buddypress' ); ?></a>
+ <div id="bp-members-avatar-editor" style="display:none;">
+ <?php bp_attachments_get_template_part( 'avatars/index' ); ?>
+ </div>
+ <?php endif; ?>
+
+ </div>
+ <?php
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Render the Member Type metabox.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.2.0
</span></span></pre></div>
<a id="trunksrcbpxprofileclassesclassbpxprofileuseradminphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-xprofile/classes/class-bp-xprofile-user-admin.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-xprofile/classes/class-bp-xprofile-user-admin.php 2020-02-29 15:28:51 UTC (rev 12553)
+++ trunk/src/bp-xprofile/classes/class-bp-xprofile-user-admin.php 2020-02-29 15:33:10 UTC (rev 12554)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -56,48 +56,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> private function setup_actions() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Enqueue scripts.
- add_action( 'bp_members_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 10, 1 );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Register the metabox in Member's community admin profile.
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'bp_members_admin_xprofile_metabox', array( $this, 'register_metaboxes' ), 10, 3 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Saves the profile actions for user ( avatar, profile fields ).
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Saves the profile actions for user ( profile fields ).
</ins><span class="cx" style="display: block; padding: 0 10px"> add_action( 'bp_members_admin_update_user', array( $this, 'user_admin_load' ), 10, 4 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Enqueue needed scripts.
- *
- * @since 2.3.0
- *
- * @param int $screen_id Screen ID being displayed.
- */
- public function enqueue_scripts( $screen_id ) {
- if ( ( false === strpos( $screen_id, 'users_page_bp-profile-edit' )
- && false === strpos( $screen_id, 'profile_page_bp-profile-edit' ) )
- || bp_core_get_root_option( 'bp-disable-avatar-uploads' )
- || ! buddypress()->avatar->show_avatars
- || ! bp_attachments_is_wp_version_supported() ) {
- return;
- }
-
- /**
- * Get Thickbox.
- *
- * We cannot simply use add_thickbox() here as WordPress is not playing
- * nice with Thickbox width/height see https://core.trac.wordpress.org/ticket/17249
- * Using media-upload might be interesting in the future for the send to editor stuff
- * and we make sure the tb_window is wide enough
- */
- wp_enqueue_style ( 'thickbox' );
- wp_enqueue_script( 'media-upload' );
-
- // Get Avatar Uploader.
- bp_attachments_enqueue_scripts( 'BP_Attachment_Avatar' );
- }
-
- /**
</del><span class="cx" style="display: block; padding: 0 10px"> * Register the xProfile metabox on Community Profile admin page.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -155,18 +122,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'core'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- if ( buddypress()->avatar->show_avatars ) {
- // Avatar Metabox.
- add_meta_box(
- 'bp_xprofile_user_admin_avatar',
- _x( 'Profile Photo', 'xprofile user-admin edit screen', 'buddypress' ),
- array( $this, 'user_admin_avatar_metabox' ),
- $screen_id,
- 'side',
- 'low'
- );
- }
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -176,6 +131,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * requests.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.0.0 The `delete_avatar` action is now managed into BP_Members_Admin::user_admin_load().
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $doaction Action being run.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $user_id ID for the user whose profile is being saved.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -184,23 +140,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function user_admin_load( $doaction = '', $user_id = 0, $request = array(), $redirect_to = '' ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Eventually delete avatar.
- if ( 'delete_avatar' === $doaction ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Update profile fields.
+ if ( isset( $_POST['field_ids'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- check_admin_referer( 'delete_avatar' );
-
- $redirect_to = remove_query_arg( '_wpnonce', $redirect_to );
-
- if ( bp_core_delete_existing_avatar( array( 'item_id' => $user_id ) ) ) {
- $redirect_to = add_query_arg( 'updated', 'avatar', $redirect_to );
- } else {
- $redirect_to = add_query_arg( 'error', 'avatar', $redirect_to );
- }
-
- bp_core_redirect( $redirect_to );
-
- } elseif ( isset( $_POST['field_ids'] ) ) {
- // Update profile fields.
</del><span class="cx" style="display: block; padding: 0 10px"> // Check the nonce.
</span><span class="cx" style="display: block; padding: 0 10px"> check_admin_referer( 'edit-bp-profile_' . $user_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -434,60 +376,5 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Render the Avatar metabox to moderate inappropriate images.
- *
- * @since 2.0.0
- *
- * @param WP_User|null $user The WP_User object for the user being edited.
- */
- public function user_admin_avatar_metabox( $user = null ) {
-
- if ( empty( $user->ID ) ) {
- return;
- } ?>
-
- <div class="avatar">
-
- <?php echo bp_core_fetch_avatar( array(
- 'item_id' => $user->ID,
- 'object' => 'user',
- 'type' => 'full',
- 'title' => $user->display_name
- ) ); ?>
-
- <?php if ( bp_get_user_has_avatar( $user->ID ) ) :
-
- $query_args = array(
- 'user_id' => $user->ID,
- 'action' => 'delete_avatar'
- );
-
- if ( ! empty( $_REQUEST['wp_http_referer'] ) ) {
- $wp_http_referer = wp_unslash( $_REQUEST['wp_http_referer'] );
- $wp_http_referer = remove_query_arg( array( 'action', 'updated' ), $wp_http_referer );
- $wp_http_referer = wp_validate_redirect( esc_url_raw( $wp_http_referer ) );
- $query_args['wp_http_referer'] = urlencode( $wp_http_referer );
- }
-
- $community_url = add_query_arg( $query_args, buddypress()->members->admin->edit_profile_url );
- $delete_link = wp_nonce_url( $community_url, 'delete_avatar' ); ?>
-
- <a href="<?php echo esc_url( $delete_link ); ?>" class="bp-xprofile-avatar-user-admin"><?php esc_html_e( 'Delete Profile Photo', 'buddypress' ); ?></a>
-
- <?php endif;
-
- // Load the Avatar UI templates if user avatar uploads are enabled and current WordPress version is supported.
- if ( ! bp_core_get_root_option( 'bp-disable-avatar-uploads' ) && bp_attachments_is_wp_version_supported() ) : ?>
- <a href="#TB_inline?width=800px&height=400px&inlineId=bp-xprofile-avatar-editor" class="thickbox bp-xprofile-avatar-user-edit"><?php esc_html_e( 'Edit Profile Photo', 'buddypress' ); ?></a>
- <div id="bp-xprofile-avatar-editor" style="display:none;">
- <?php bp_attachments_get_template_part( 'avatars/index' ); ?>
- </div>
- <?php endif; ?>
-
- </div>
- <?php
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> endif; // End class_exists check.
</span></span></pre>
</div>
</div>
</body>
</html>