| @@ 119-137 (lines=19) @@ | ||
| 116 | * @since 4.0.0 |
|
| 117 | * @return date in YYYY-MM-DD HH:mm:ss format |
|
| 118 | */ |
|
| 119 | public function monitor_get_last_downtime() { |
|
| 120 | // if ( $last_down = get_transient( 'monitor_last_downtime' ) ) { |
|
| 121 | // return $last_down; |
|
| 122 | // } |
|
| 123 | ||
| 124 | $xml = new Jetpack_IXR_Client( array( |
|
| 125 | 'user_id' => get_current_user_id() |
|
| 126 | ) ); |
|
| 127 | ||
| 128 | $xml->query( 'jetpack.monitor.getLastDowntime' ); |
|
| 129 | ||
| 130 | if ( $xml->isError() ) { |
|
| 131 | return new WP_Error( 'monitor-downtime', $xml->getErrorMessage() ); |
|
| 132 | } |
|
| 133 | ||
| 134 | set_transient( 'monitor_last_downtime', $xml->getResponse(), 10 * MINUTE_IN_SECONDS ); |
|
| 135 | ||
| 136 | return $xml->getResponse(); |
|
| 137 | } |
|
| 138 | ||
| 139 | } |
|
| 140 | ||
| @@ 3261-3287 (lines=27) @@ | ||
| 3258 | * @param WP_REST_REQUEST $request The request parameters. |
|
| 3259 | * @return bool|WP_Error |
|
| 3260 | */ |
|
| 3261 | public static function send_mobile_magic_link( $request ) { |
|
| 3262 | $xml = new Jetpack_IXR_Client( |
|
| 3263 | array( |
|
| 3264 | 'user_id' => get_current_user_id(), |
|
| 3265 | ) |
|
| 3266 | ); |
|
| 3267 | ||
| 3268 | $xml->query( 'jetpack.sendMobileMagicLink', array() ); |
|
| 3269 | if ( $xml->isError() ) { |
|
| 3270 | return new WP_Error( |
|
| 3271 | 'error_sending_mobile_magic_link', |
|
| 3272 | sprintf( |
|
| 3273 | '%s: %s', |
|
| 3274 | $xml->getErrorCode(), |
|
| 3275 | $xml->getErrorMessage() |
|
| 3276 | ) |
|
| 3277 | ); |
|
| 3278 | } |
|
| 3279 | ||
| 3280 | $response = $xml->getResponse(); |
|
| 3281 | ||
| 3282 | return rest_ensure_response( |
|
| 3283 | array( |
|
| 3284 | 'code' => 'success', |
|
| 3285 | ) |
|
| 3286 | ); |
|
| 3287 | } |
|
| 3288 | } // class end |
|
| 3289 | ||