← All changes
|
json-endpoints/jetpack/class.jetpack-json-api-user-create-endpoint.php
+9
-4
12.3.2
→
16.3-a.7
View file →
| @@ -1,10 +1,17 @@ | ||
| 1 | 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | 2 | |
| 3 | +use Automattic\Jetpack\Connection\Utils; | |
| 3 | 4 | use Automattic\Jetpack\Constants; |
| 4 | 5 | |
| 6 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 7 | + exit( 0 ); | |
| 8 | +} | |
| 9 | + | |
| 5 | 10 | /** |
| 6 | 11 | * User create endpoint class. |
| 12 | + * | |
| 13 | + * @phan-constructor-used-for-side-effects | |
| 7 | 14 | */ |
| 8 | 15 | class Jetpack_JSON_API_User_Create_Endpoint extends Jetpack_JSON_API_Endpoint { |
| 9 | 16 | |
| 10 | 17 | /** |
| @@ -57,9 +64,8 @@ | ||
| 57 | 64 | * |
| 58 | 65 | * @return object|false |
| 59 | 66 | */ |
| 60 | 67 | public function create_or_get_user() { |
| 61 | - require_once JETPACK__PLUGIN_DIR . 'modules/sso/class.jetpack-sso-helpers.php'; | |
| 62 | 68 | // Check for an existing user |
| 63 | 69 | $user = get_user_by( 'email', $this->user_data['email'] ); |
| 64 | 70 | $roles = (array) $this->user_data['roles']; |
| 65 | 71 | $role = array_pop( $roles ); |
| @@ -72,12 +78,12 @@ | ||
| 72 | 78 | if ( ! $user ) { |
| 73 | 79 | // We modify the input here to mimick the same call structure of the update user endpoint. |
| 74 | 80 | $this->user_data = (object) $this->user_data; |
| 75 | 81 | $this->user_data->role = $role; |
| 76 | - $this->user_data->url = isset( $this->user_data->URL ) ? $this->user_data->URL : ''; | |
| 82 | + $this->user_data->url = $this->user_data->URL ?? ''; | |
| 77 | 83 | $this->user_data->display_name = $this->user_data->name; |
| 78 | 84 | $this->user_data->description = ''; |
| 79 | - $user = Jetpack_SSO_Helpers::generate_user( $this->user_data ); | |
| 85 | + $user = Utils::generate_user( $this->user_data ); | |
| 80 | 86 | } |
| 81 | 87 | |
| 82 | 88 | if ( is_multisite() ) { |
| 83 | 89 | add_user_to_blog( get_current_blog_id(), $user->ID, $role ); |
| @@ -106,6 +112,5 @@ | ||
| 106 | 112 | } |
| 107 | 113 | |
| 108 | 114 | return $the_user; |
| 109 | 115 | } |
| 110 | - | |
| 111 | 116 | } |