namespace . $this->version; register_rest_route( $namespace, '/reset/', array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => array( $this, 'reset' ), 'permission_callback' => array( $this, 'update_settings_permission' ), ) ); } /** * Get edit options permissions. * * @return bool */ public function update_settings_permission() { return current_user_can( 'manage_options' ); } /** * Reset settings. * * @param WP_REST_Request $request request object. * * @return mixed */ public function reset( WP_REST_Request $request ) { delete_option( 'generate_settings' ); delete_option( 'generate_dynamic_css_output' ); delete_option( 'generate_dynamic_css_cached_version' ); return $this->success( __( 'Settings reset.', 'generatepress' ) ); } /** * Success rest. * * @param mixed $response response data. * @return mixed */ public function success( $response ) { return new WP_REST_Response( array( 'success' => true, 'response' => $response, ), 200 ); } /** * Failed rest. * * @param mixed $response response data. * @return mixed */ public function failed( $response ) { return new WP_REST_Response( array( 'success' => false, 'response' => $response, ), 200 ); } /** * Error rest. * * @param mixed $code error code. * @param mixed $response response data. * @return mixed */ public function error( $code, $response ) { return new WP_REST_Response( array( 'error' => true, 'success' => false, 'error_code' => $code, 'response' => $response, ), 401 ); } } GeneratePress_Rest::get_instance();