verify_capability(); if ( $error ) { return $error; } $url = esc_url_raw( $request->get_param( 'url' ) ); $status = sanitize_text_field( $request->get_param( 'status' ) ); $page = new Page_Entry([ 'by' => 'url', 'value' => $url, ]); // Prevent creating duplicate entry if ( ! $page->exists() ) { return $this->respond_error_json( [ 'message' => 'Failed to update page', 'code' => 'page_not_found', ] ); } $page->update_status( $status ); return $this->respond_success_json( [ 'message' => 'Page updated successfully', 'data' => $page->to_json(), ] ); } catch ( Throwable $t ) { return $this->respond_error_json( [ 'message' => $t->getMessage(), 'code' => 'internal_server_error', ] ); } } }