return string */ public function get_request_uri_base() { $request_uri = $this->get_raw_request_uri(); if ( ! $request_uri ) { return ''; } $request_uri = explode( '?', $request_uri ); return reset( $request_uri ); } /** * Get the request URI. The query string is sorted and some parameters are removed. * * @since 3.3 * @access public * @author Grégory Viguier * * @return string */ public function get_clean_request_uri() { $request_uri = $this->get_request_uri_base(); if ( ! $request_uri ) { return ''; } $query_string = $this->get_query_string(); if ( ! $query_string ) { return $request_uri; } return $request_uri . '?' . $query_string; } /** * Get the request method. * * @since 3.3 * @access public * @author Grégory Viguier * * @return string */ public function get_request_method() { if ( '' === $this->config->get_server_input( 'REQUEST_METHOD', '' ) ) { return ''; } return strtoupper( $this->config->get_server_input( 'REQUEST_METHOD' ) ); } /** ----------------------------------------------------------------------------------------- */ /** QUERY STRING ============================================================================ */ /** ----------------------------------------------------------------------------------------- */ /** * Get the query string as an array. Parameters are sorted and some are removed. * * @since 3.3 * @access public * @author Grégory Viguier * * @return array */ public function get_query_params() { if ( ! self::$get ) { return []; } // Remove some parameters. $params = array_diff_key( self::$get, $this->config->get_config( 'cache_ignored_parameters' ) ); if ( $params ) { ksort( $params ); } return $params; } /** * Get the query string with sorted parameters, and some other removed. * * @since 3.3 * @access public * @author Grégory Viguier * * @return string */ public function get_query_string() { return http_build_query( $this->get_query_params() ); } /** ----------------------------------------------------------------------------------------- */ /** PROPERTY GETTERS ======================================================================== */ /** ----------------------------------------------------------------------------------------- */ /** * Get the `cookies` property. * * @since 3.3 * @access public * @author Grégory Viguier * * @return array */ public function get_cookies() { return self::$cookies; } /** * Get the `post` property. * * @since 3.3 * @access public * @author Grégory Viguier * * @return array */ public function get_post() { return self::$post; } /** * Get the `get` property. * * @since 3.3 * @access public * @author Grégory Viguier * * @return array */ public function get_get() { return self::$get; } /** ----------------------------------------------------------------------------------------- */ /** ERRORS ================================================================================== */ /** ----------------------------------------------------------------------------------------- */ /** * Set an "error". * * @since 3.3 * @access protected * @author Grégory Viguier * * @param string $message A message. * @param array $data Related data. */ protected function set_error( $message, $data = [] ) { $this->last_error = [ 'message' => $message, 'data' => (array) $data, ]; } /** * Get the last "error". * * @since 3.3 * @access public * @author Grégory Viguier * * @return array */ public function get_last_error() { return array_merge( [ 'message' => '', 'data' => [], ], (array) $this->last_error ); } }