| Conditions | 4 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | function validate_input( $user_id ) { |
||
| 16 | $input = $this->input(); |
||
| 17 | if ( ! isset( $user_id ) ) { |
||
| 18 | return new WP_Error( 'input_error', __( 'user_id is required', 'jetpack' ) ); |
||
| 19 | } |
||
| 20 | $this->user_id = $user_id; |
||
| 21 | if ( Jetpack::is_user_connected( $this->user_id ) ) { |
||
| 22 | return new WP_Error( 'user_already_connected', __( 'The user is already connected', 'jetpack' ) ); |
||
| 23 | } |
||
| 24 | if ( ! isset( $input['user_token'] ) ) { |
||
| 25 | return new WP_Error( 'input_error', __( 'user_token is required', 'jetpack' ) ); |
||
| 26 | } |
||
| 27 | $this->user_token = sanitize_text_field( $input[ 'user_token'] ); |
||
| 28 | return parent::validate_input( $user_id ); |
||
| 29 | } |
||
| 30 | |||
| 32 |