Version Description
- Released 2019-06-11
- New REST API endpoint for changing profile pictures.
Download this release
Release Info
Developer | ronalfy |
Plugin | User Profile Picture |
Version | 2.2.8 |
Comparing to | |
See all releases |
Code changes from version 2.2.7 to 2.2.8
- metronet-profile-picture.php +53 -2
- readme.txt +8 -1
metronet-profile-picture.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: User Profile Picture
|
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/metronet-profile-picture/
|
5 |
Description: Use the native WP uploader on your user profile page.
|
6 |
Author: Ronald Huereca
|
7 |
-
Version: 2.2.
|
8 |
Requires at least: 3.5
|
9 |
Author URI: https://www.mediaron.com
|
10 |
Contributors: ronalfy
|
@@ -12,7 +12,7 @@ Text Domain: metronet-profile-picture
|
|
12 |
Domain Path: /languages
|
13 |
*/
|
14 |
|
15 |
-
define( 'METRONET_PROFILE_PICTURE_VERSION', '2.2.
|
16 |
|
17 |
/**
|
18 |
* Main Class for User Profile Picture
|
@@ -728,6 +728,14 @@ class Metronet_Profile_Picture {
|
|
728 |
'callback' => array( $this, 'rest_api_put_profile' ),
|
729 |
)
|
730 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
731 |
register_rest_route(
|
732 |
'mpp/v2',
|
733 |
'/get_users',
|
@@ -830,6 +838,49 @@ class Metronet_Profile_Picture {
|
|
830 |
return $return;
|
831 |
}
|
832 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
833 |
/**
|
834 |
* rest_api_put_profile()
|
835 |
*
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/metronet-profile-picture/
|
5 |
Description: Use the native WP uploader on your user profile page.
|
6 |
Author: Ronald Huereca
|
7 |
+
Version: 2.2.8
|
8 |
Requires at least: 3.5
|
9 |
Author URI: https://www.mediaron.com
|
10 |
Contributors: ronalfy
|
12 |
Domain Path: /languages
|
13 |
*/
|
14 |
|
15 |
+
define( 'METRONET_PROFILE_PICTURE_VERSION', '2.2.8' );
|
16 |
|
17 |
/**
|
18 |
* Main Class for User Profile Picture
|
728 |
'callback' => array( $this, 'rest_api_put_profile' ),
|
729 |
)
|
730 |
);
|
731 |
+
register_rest_route(
|
732 |
+
'mpp/v2',
|
733 |
+
'/profile-image/change',
|
734 |
+
array(
|
735 |
+
'methods' => 'POST',
|
736 |
+
'callback' => array( $this, 'rest_api_change_profile_image' ),
|
737 |
+
)
|
738 |
+
);
|
739 |
register_rest_route(
|
740 |
'mpp/v2',
|
741 |
'/get_users',
|
838 |
return $return;
|
839 |
}
|
840 |
|
841 |
+
/**
|
842 |
+
* rest_api_change_profile_image()
|
843 |
+
*
|
844 |
+
* Changes a profile image for a user.
|
845 |
+
*
|
846 |
+
* @param array $request WP REST API array
|
847 |
+
*
|
848 |
+
* @return json image URLs matched to sizes
|
849 |
+
**/
|
850 |
+
public function rest_api_change_profile_image( $request ) {
|
851 |
+
|
852 |
+
$user_id = (int) $request['user_id'];
|
853 |
+
$media_id = (int) $request['media_id'];
|
854 |
+
|
855 |
+
if ( ! $user_id ) {
|
856 |
+
return new WP_Error( 'mpp_no_user', __( 'User not found.', 'metronet-profile-picture' ), array( 'status' => 403 ) );
|
857 |
+
}
|
858 |
+
|
859 |
+
if ( ! current_user_can( 'upload_files', $user_id ) ) {
|
860 |
+
return new WP_Error( 'mpp_insufficient_privs', __( 'You must be able to upload files.', 'metronet-profile-picture' ), array( 'status' => 403 ) );
|
861 |
+
}
|
862 |
+
|
863 |
+
$post_id = $this->get_post_id( $user_id );
|
864 |
+
|
865 |
+
//Save user meta
|
866 |
+
update_user_option( $user_id, 'metronet_post_id', $post_id );
|
867 |
+
update_user_option( $user_id, 'metronet_image_id', $media_id ); //Added via this thread (Props Solinx) - https://wordpress.org/support/topic/storing-image-id-directly-as-user-meta-data
|
868 |
+
|
869 |
+
set_post_thumbnail( $post_id, $media_id );
|
870 |
+
|
871 |
+
$attachment_url = wp_get_attachment_url( $media_id );
|
872 |
+
|
873 |
+
return array(
|
874 |
+
'24' => wp_get_attachment_image_url( $media_id, 'profile_24', false, '' ),
|
875 |
+
'48' => wp_get_attachment_image_url( $media_id, 'profile_48', false, '' ),
|
876 |
+
'96' => wp_get_attachment_image_url( $media_id, 'profile_96', false, '' ),
|
877 |
+
'150' => wp_get_attachment_image_url( $media_id, 'profile_150', false, '' ),
|
878 |
+
'300' => wp_get_attachment_image_url( $media_id, 'profile_300', false, '' ),
|
879 |
+
'thumbnail' => wp_get_attachment_image_url( $media_id, 'thumbnail', false, '' ),
|
880 |
+
'full' => $attachment_url,
|
881 |
+
);
|
882 |
+
}
|
883 |
+
|
884 |
/**
|
885 |
* rest_api_put_profile()
|
886 |
*
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: ronalfy, Alaadiaa
|
|
3 |
Tags: users, user profile, gravatar, avatar, blocks, block
|
4 |
Requires at least: 3.5
|
5 |
Tested up to: 5.2
|
6 |
-
Stable tag: 2.2.
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -124,6 +124,10 @@ Yes, but you'll have to set a new profile image per site. This is currently a l
|
|
124 |
|
125 |
== Changelog ==
|
126 |
|
|
|
|
|
|
|
|
|
127 |
= 2.2.7 =
|
128 |
* Released 2019-06-11
|
129 |
* Fixing permissions in REST API
|
@@ -307,6 +311,9 @@ Yes, but you'll have to set a new profile image per site. This is currently a l
|
|
307 |
|
308 |
== Upgrade Notice ==
|
309 |
|
|
|
|
|
|
|
310 |
= 2.2.7 =
|
311 |
Fixing permissions in REST API.
|
312 |
|
3 |
Tags: users, user profile, gravatar, avatar, blocks, block
|
4 |
Requires at least: 3.5
|
5 |
Tested up to: 5.2
|
6 |
+
Stable tag: 2.2.8
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
124 |
|
125 |
== Changelog ==
|
126 |
|
127 |
+
= 2.2.8 =
|
128 |
+
* Released 2019-06-11
|
129 |
+
* New REST API endpoint for changing profile pictures.
|
130 |
+
|
131 |
= 2.2.7 =
|
132 |
* Released 2019-06-11
|
133 |
* Fixing permissions in REST API
|
311 |
|
312 |
== Upgrade Notice ==
|
313 |
|
314 |
+
= 2.2.8 =
|
315 |
+
New REST API endpoint for changing profile pictures.
|
316 |
+
|
317 |
= 2.2.7 =
|
318 |
Fixing permissions in REST API.
|
319 |
|