{"id":12178587,"date":"2025-04-02T12:14:17","date_gmt":"2025-04-02T10:14:17","guid":{"rendered":"https:\/\/it.wordpress.org\/support\/topic\/problema-wordpress-environment-setup-class\/"},"modified":"2025-04-02T12:14:17","modified_gmt":"2025-04-02T10:14:17","slug":"problema-wordpress-environment-setup-class","status":"publish","type":"topic","link":"https:\/\/it.wordpress.org\/support\/topic\/problema-wordpress-environment-setup-class\/","title":{"rendered":"Problema WordPress environment setup class"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Quando provo ad accedere al mio sito web mi da il seguente errore:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\/** * WordPress environment setup class. * * @package WordPress * @since 2.0.0 *\/ #[AllowDynamicProperties] class WP { \/** * Public query variables. * * Long list of public query variables. * * @since 2.0.0 * @var string[] *\/ public $public_query_vars = array( &#8216;m&#8217;, &#8216;p&#8217;, &#8216;posts&#8217;, &#8216;w&#8217;, &#8216;cat&#8217;, &#8216;withcomments&#8217;, &#8216;withoutcomments&#8217;, &#8216;s&#8217;, &#8216;search&#8217;, &#8216;exact&#8217;, &#8216;sentence&#8217;, &#8216;calendar&#8217;, &#8216;page&#8217;, &#8216;paged&#8217;, &#8216;more&#8217;, &#8216;tb&#8217;, &#8216;pb&#8217;, &#8216;author&#8217;, &#8216;order&#8217;, &#8216;orderby&#8217;, &#8216;year&#8217;, &#8216;monthnum&#8217;, &#8216;day&#8217;, &#8216;hour&#8217;, &#8216;minute&#8217;, &#8216;second&#8217;, &#8216;name&#8217;, &#8216;category_name&#8217;, &#8216;tag&#8217;, &#8216;feed&#8217;, &#8216;author_name&#8217;, &#8216;pagename&#8217;, &#8216;page_id&#8217;, &#8216;error&#8217;, &#8216;attachment&#8217;, &#8216;attachment_id&#8217;, &#8216;subpost&#8217;, &#8216;subpost_id&#8217;, &#8216;preview&#8217;, &#8216;robots&#8217;, &#8216;favicon&#8217;, &#8216;taxonomy&#8217;, &#8216;term&#8217;, &#8216;cpage&#8217;, &#8216;post_type&#8217;, &#8216;embed&#8217; ); \/** * Private query variables. * * Long list of private query variables. * * @since 2.0.0 * @var string[] *\/ public $private_query_vars = array( &#8216;offset&#8217;, &#8216;posts_per_page&#8217;, &#8216;posts_per_archive_page&#8217;, &#8216;showposts&#8217;, &#8216;nopaging&#8217;, &#8216;post_type&#8217;, &#8216;post_status&#8217;, &#8216;category__in&#8217;, &#8216;category__not_in&#8217;, &#8216;category__and&#8217;, &#8216;tag__in&#8217;, &#8216;tag__not_in&#8217;, &#8216;tag__and&#8217;, &#8216;tag_slug__in&#8217;, &#8216;tag_slug__and&#8217;, &#8216;tag_id&#8217;, &#8216;post_mime_type&#8217;, &#8216;perm&#8217;, &#8216;comments_per_page&#8217;, &#8216;post__in&#8217;, &#8216;post__not_in&#8217;, &#8216;post_parent&#8217;, &#8216;post_parent__in&#8217;, &#8216;post_parent__not_in&#8217;, &#8216;title&#8217;, &#8216;fields&#8217; ); \/** * Extra query variables set by the user. * * @since 2.1.0 * @var array *\/ public $extra_query_vars = array(); \/** * Query variables for setting up the WordPress Query Loop. * * @since 2.0.0 * @var array *\/ public $query_vars = array(); \/** * String parsed to set the query variables. * * @since 2.0.0 * @var string *\/ public $query_string = &#8221;; \/** * The request path, e.g. 2015\/05\/06. * * @since 2.0.0 * @var string *\/ public $request = &#8221;; \/** * Rewrite rule the request matched. * * @since 2.0.0 * @var string *\/ public $matched_rule = &#8221;; \/** * Rewrite query the request matched. * * @since 2.0.0 * @var string *\/ public $matched_query = &#8221;; \/** * Whether already did the permalink. * * @since 2.0.0 * @var bool *\/ public $did_permalink = false; \/** * Adds a query variable to the list of public query variables. * * @since 2.1.0 * * @param string $qv Query variable name. *\/ public function add_query_var( $qv ) { if ( ! in_array( $qv, $this-&gt;public_query_vars, true ) ) { $this-&gt;public_query_vars[] = $qv; } } \/** * Removes a query variable from a list of public query variables. * * @since 4.5.0 * * @param string $name Query variable name. *\/ public function remove_query_var( $name ) { $this-&gt;public_query_vars = array_diff( $this-&gt;public_query_vars, array( $name ) ); } \/** * Sets the value of a query variable. * * @since 2.3.0 * * @param string $key Query variable name. * @param mixed $value Query variable value. *\/ public function set_query_var( $key, $value ) { $this-&gt;query_vars[ $key ] = $value; } \/** * Parses the request to find the correct WordPress query. * * Sets up the query variables based on the request. There are also many * filters and actions that can be used to further manipulate the result. * * @since 2.0.0 * @since 6.0.0 A return value was added. * * @global WP_Rewrite $wp_rewrite WordPress rewrite component. * * @param array|string $extra_query_vars Set the extra query variables. * @return bool Whether the request was parsed. *\/ public function parse_request( $extra_query_vars = &#8221; ) { global $wp_rewrite; \/** * Filters whether to parse the request. * * @since 3.5.0 * * @param bool $bool Whether or not to parse the request. Default true. * @param WP $wp Current WordPress environment instance. * @param array|string $extra_query_vars Extra passed query variables. *\/ if ( ! apply_filters( &#8216;do_parse_request&#8217;, true, $this, $extra_query_vars ) ) { return false; } $this-&gt;query_vars = array(); $post_type_query_vars = array(); if ( is_array( $extra_query_vars ) ) { $this-&gt;extra_query_vars = &amp; $extra_query_vars; } elseif ( ! empty( $extra_query_vars ) ) { parse_str( $extra_query_vars, $this-&gt;extra_query_vars ); } \/\/ Process PATH_INFO, REQUEST_URI, and 404 for permalinks. \/\/ Fetch the rewrite rules. $rewrite = $wp_rewrite-&gt;wp_rewrite_rules(); if ( ! empty( $rewrite ) ) { \/\/ If we match a rewrite rule, this will be cleared. $error = &#8216;404&#8217;; $this-&gt;did_permalink = true; $pathinfo = isset( $_SERVER[&#8216;PATH_INFO&#8217;] ) ? $_SERVER[&#8216;PATH_INFO&#8217;] : &#8221;; list( $pathinfo ) = explode( &#8216;?&#8217;, $pathinfo ); $pathinfo = str_replace( &#8216;%&#8217;, &#8216;%25&#8217;, $pathinfo ); list( $req_uri ) = explode( &#8216;?&#8217;, $_SERVER[&#8216;REQUEST_URI&#8217;] ); $self = $_SERVER[&#8216;PHP_SELF&#8217;]; $home_path = parse_url( home_url(), PHP_URL_PATH ); $home_path_regex = &#8221;; if ( is_string( $home_path ) &amp;&amp; &#8221; !== $home_path ) { $home_path = trim( $home_path, &#8216;\/&#8217; ); $home_path_regex = sprintf( &#8216;|^%s|i&#8217;, preg_quote( $home_path, &#8216;|&#8217; ) ); } \/* * Trim path info from the end and the leading home path from the front. * For path info requests, this leaves us with the requesting filename, if any. * For 404 requests, this leaves us with the requested permalink. *\/ $req_uri = str_replace( $pathinfo, &#8221;, $req_uri ); $req_uri = trim( $req_uri, &#8216;\/&#8217; ); $pathinfo = trim( $pathinfo, &#8216;\/&#8217; ); $self = trim( $self, &#8216;\/&#8217; ); if ( ! empty( $home_path_regex ) ) { $req_uri = preg_replace( $home_path_regex, &#8221;, $req_uri ); $req_uri = trim( $req_uri, &#8216;\/&#8217; ); $pathinfo = preg_replace( $home_path_regex, &#8221;, $pathinfo ); $pathinfo = trim( $pathinfo, &#8216;\/&#8217; ); $self = preg_replace( $home_path_regex, &#8221;, $self ); $self = trim( $self, &#8216;\/&#8217; ); } \/\/ The requested permalink is in $pathinfo for path info requests and $req_uri for other requests. if ( ! empty( $pathinfo ) &amp;&amp; ! preg_match( &#8216;|^.*&#8217; . $wp_rewrite-&gt;index . &#8216;$|&#8217;, $pathinfo ) ) { $requested_path = $pathinfo; } else { \/\/ If the request uri is the index, blank it out so that we don&#8217;t try to match it against a rule. if ( $req_uri === $wp_rewrite-&gt;index ) { $req_uri = &#8221;; } $requested_path = $req_uri; } $requested_file = $req_uri; $this-&gt;request = $requested_path; \/\/ Look for matches. $request_match = $requested_path; if ( empty( $request_match ) ) { \/\/ An empty request could only match against ^$ regex. if ( isset( $rewrite[&#8216;$&#8217;] ) ) { $this-&gt;matched_rule = &#8216;$&#8217;; $query = $rewrite[&#8216;$&#8217;]; $matches = array( &#8221; ); } } else { foreach ( (array) $rewrite as $match =&gt; $query ) { \/\/ If the requested file is the anchor of the match, prepend it to the path info. if ( ! empty( $requested_file ) &amp;&amp; str_starts_with( $match, $requested_file ) &amp;&amp; $requested_file !== $requested_path ) { $request_match = $requested_file . &#8216;\/&#8217; . $requested_path; } if ( preg_match( &#8220;#^$match#&#8221;, $request_match, $matches ) || preg_match( &#8220;#^$match#&#8221;, urldecode( $request_match ), $matches ) ) { if ( $wp_rewrite-&gt;use_verbose_page_rules &amp;&amp; preg_match( &#8216;\/pagename=\\$matches\\[([0-9]+)\\]\/&#8217;, $query, $varmatch ) ) { \/\/ This is a verbose page match, let&#8217;s check to be sure about it. $page = get_page_by_path( $matches[ $varmatch[1] ] ); if ( ! $page ) { continue; } $post_status_obj = get_post_status_object( $page-&gt;post_status ); if ( ! $post_status_obj-&gt;public &amp;&amp; ! $post_status_obj-&gt;protected &amp;&amp; ! $post_status_obj-&gt;private &amp;&amp; $post_status_obj-&gt;exclude_from_search ) { continue; } } \/\/ Got a match. $this-&gt;matched_rule = $match; break; } } } if ( ! empty( $this-&gt;matched_rule ) ) { \/\/ Trim the query of everything up to the &#8216;?&#8217;. $query = preg_replace( &#8216;!^.+\\?!&#8217;, &#8221;, $query ); \/\/ Substitute the substring matches into the query. $query = addslashes( WP_MatchesMapRegex::apply( $query, $matches ) ); $this-&gt;matched_query = $query; \/\/ Parse the query. parse_str( $query, $perma_query_vars ); \/\/ If we&#8217;re processing a 404 request, clear the error var since we found something. if ( &#8216;404&#8217; === $error ) { unset( $error, $_GET[&#8216;error&#8217;] ); } } \/\/ If req_uri is empty or if it is a request for ourself, unset error. if ( empty( $requested_path ) || $requested_file === $self || str_contains( $_SERVER[&#8216;PHP_SELF&#8217;], &#8216;wp-admin\/&#8217; ) ) { unset( $error, $_GET[&#8216;error&#8217;] ); if ( isset( $perma_query_vars ) &amp;&amp; str_contains( $_SERVER[&#8216;PHP_SELF&#8217;], &#8216;wp-admin\/&#8217; ) ) { unset( $perma_query_vars ); } $this-&gt;did_permalink = false; } } \/** * Filters the query variables allowed before processing. * * Allows (publicly allowed) query vars to be added, removed, or changed prior * to executing the query. Needed to allow custom rewrite rules using your own arguments * to work, or any other custom query variables you want to be publicly available. * * @since 1.5.0 * * @param string[] $public_query_vars The array of allowed query variable names. *\/ $this-&gt;public_query_vars = apply_filters( &#8216;query_vars&#8217;, $this-&gt;public_query_vars ); foreach ( get_post_types( array(), &#8216;objects&#8217; ) as $post_type =&gt; $t ) { if ( is_post_type_viewable( $t ) &amp;&amp; $t-&gt;query_var ) { $post_type_query_vars[ $t-&gt;query_var ] = $post_type; } } foreach ( $this-&gt;public_query_vars as $wpvar ) { if ( isset( $this-&gt;extra_query_vars[ $wpvar ] ) ) { $this-&gt;query_vars[ $wpvar ] = $this-&gt;extra_query_vars[ $wpvar ]; } elseif ( isset( $_GET[ $wpvar ] ) &amp;&amp; isset( $_POST[ $wpvar ] ) &amp;&amp; $_GET[ $wpvar ] !== $_POST[ $wpvar ] ) { wp_die( __( &#8216;A variable mismatch has been detected.&#8217; ), __( &#8216;Sorry, you are not allowed to view this item.&#8217; ), 400 ); } elseif ( isset( $_POST[ $wpvar ] ) ) { $this-&gt;query_vars[ $wpvar ] = $_POST[ $wpvar ]; } elseif ( isset( $_GET[ $wpvar ] ) ) { $this-&gt;query_vars[ $wpvar ] = $_GET[ $wpvar ]; } elseif ( isset( $perma_query_vars[ $wpvar ] ) ) { $this-&gt;query_vars[ $wpvar ] = $perma_query_vars[ $wpvar ]; } if ( ! empty( $this-&gt;query_vars[ $wpvar ] ) ) { if ( ! is_array( $this-&gt;query_vars[ $wpvar ] ) ) { $this-&gt;query_vars[ $wpvar ] = (string) $this-&gt;query_vars[ $wpvar ]; } else { foreach ( $this-&gt;query_vars[ $wpvar ] as $vkey =&gt; $v ) { if ( is_scalar( $v ) ) { $this-&gt;query_vars[ $wpvar ][ $vkey ] = (string) $v; } } } if ( isset( $post_type_query_vars[ $wpvar ] ) ) { $this-&gt;query_vars[&#8216;post_type&#8217;] = $post_type_query_vars[ $wpvar ]; $this-&gt;query_vars[&#8216;name&#8217;] = $this-&gt;query_vars[ $wpvar ]; } } } \/\/ Convert urldecoded spaces back into &#8216;+&#8217;. foreach ( get_taxonomies( array(), &#8216;objects&#8217; ) as $taxonomy =&gt; $t ) { if ( $t-&gt;query_var &amp;&amp; isset( $this-&gt;query_vars[ $t-&gt;query_var ] ) ) { $this-&gt;query_vars[ $t-&gt;query_var ] = str_replace( &#8216; &#8216;, &#8216;+&#8217;, $this-&gt;query_vars[ $t-&gt;query_var ] ); } } \/\/ Don&#8217;t allow non-publicly queryable taxonomies to be queried from the front end. if ( ! is_admin() ) { foreach ( get_taxonomies( array( &#8216;publicly_queryable&#8217; =&gt; false ), &#8216;objects&#8217; ) as $taxonomy =&gt; $t ) { \/* * Disallow when set to the &#8216;taxonomy&#8217; query var. * Non-publicly queryable taxonomies cannot register custom query vars. See register_taxonomy(). *\/ if ( isset( $this-&gt;query_vars[&#8216;taxonomy&#8217;] ) &amp;&amp; $taxonomy === $this-&gt;query_vars[&#8216;taxonomy&#8217;] ) { unset( $this-&gt;query_vars[&#8216;taxonomy&#8217;], $this-&gt;query_vars[&#8216;term&#8217;] ); } } } \/\/ Limit publicly queried post_types to those that are &#8216;publicly_queryable&#8217;. if ( isset( $this-&gt;query_vars[&#8216;post_type&#8217;] ) ) { $queryable_post_types = get_post_types( array( &#8216;publicly_queryable&#8217; =&gt; true ) ); if ( ! is_array( $this-&gt;query_vars[&#8216;post_type&#8217;] ) ) { if ( ! in_array( $this-&gt;query_vars[&#8216;post_type&#8217;], $queryable_post_types, true ) ) { unset( $this-&gt;query_vars[&#8216;post_type&#8217;] ); } } else { $this-&gt;query_vars[&#8216;post_type&#8217;] = array_intersect( $this-&gt;query_vars[&#8216;post_type&#8217;], $queryable_post_types ); } } \/\/ Resolve conflicts between posts with numeric slugs and date archive queries. $this-&gt;query_vars = wp_resolve_numeric_slug_conflicts( $this-&gt;query_vars ); foreach ( (array) $this-&gt;private_query_vars as $var ) { if ( isset( $this-&gt;extra_query_vars[ $var ] ) ) { $this-&gt;query_vars[ $var ] = $this-&gt;extra_query_vars[ $var ]; } } if ( isset( $error ) ) { $this-&gt;query_vars[&#8216;error&#8217;] = $error; } \/** * Filters the array of parsed query variables. * * @since 2.1.0 * * @param array $query_vars The array of requested query variables. *\/ $this-&gt;query_vars = apply_filters( &#8216;request&#8217;, $this-&gt;query_vars ); \/** * Fires once all query variables for the current request have been parsed. * * @since 2.1.0 * * @param WP $wp Current WordPress environment instance (passed by reference). *\/ do_action_ref_array( &#8216;parse_request&#8217;, array( &amp;$this ) ); return true; } \/** * Sends additional HTTP headers for caching, content type, etc. * * Sets the Content-Type header. Sets the &#8216;error&#8217; status (if passed) and optionally exits. * If showing a feed, it will also send Last-Modified, ETag, and 304 status if needed. * * @since 2.0.0 * @since 4.4.0 <code>X-Pingback<\/code> header is added conditionally for single posts that allow pings. * @since 6.1.0 Runs after posts have been queried. * * @global WP_Query $wp_query WordPress Query object. *\/ public function send_headers() { global $wp_query; $headers = array(); $status = null; $exit_required = false; $date_format = &#8216;D, d M Y H:i:s&#8217;; if ( is_user_logged_in() ) { $headers = array_merge( $headers, wp_get_nocache_headers() ); } elseif ( ! empty( $_GET[&#8216;unapproved&#8217;] ) &amp;&amp; ! empty( $_GET[&#8216;moderation-hash&#8217;] ) ) { \/\/ Unmoderated comments are only visible for 10 minutes via the moderation hash. $expires = 10 * MINUTE_IN_SECONDS; $headers[&#8216;Expires&#8217;] = gmdate( $date_format, time() + $expires ); $headers[&#8216;Cache-Control&#8217;] = sprintf( &#8216;max-age=%d, must-revalidate&#8217;, $expires ); } if ( ! empty( $this-&gt;query_vars[&#8216;error&#8217;] ) ) { $status = (int) $this-&gt;query_vars[&#8216;error&#8217;]; if ( 404 === $status ) { if ( ! is_user_logged_in() ) { $headers = array_merge( $headers, wp_get_nocache_headers() ); } $headers[&#8216;Content-Type&#8217;] = get_option( &#8216;html_type&#8217; ) . &#8216;; charset=&#8217; . get_option( &#8216;blog_charset&#8217; ); } elseif ( in_array( $status, array( 403, 500, 502, 503 ), true ) ) { $exit_required = true; } } elseif ( empty( $this-&gt;query_vars[&#8216;feed&#8217;] ) ) { $headers[&#8216;Content-Type&#8217;] = get_option( &#8216;html_type&#8217; ) . &#8216;; charset=&#8217; . get_option( &#8216;blog_charset&#8217; ); } else { \/\/ Set the correct content type for feeds. $type = $this-&gt;query_vars[&#8216;feed&#8217;]; if ( &#8216;feed&#8217; === $this-&gt;query_vars[&#8216;feed&#8217;] ) { $type = get_default_feed(); } $headers[&#8216;Content-Type&#8217;] = feed_content_type( $type ) . &#8216;; charset=&#8217; . get_option( &#8216;blog_charset&#8217; ); \/\/ We&#8217;re showing a feed, so WP is indeed the only thing that last changed. if ( ! empty( $this-&gt;query_vars[&#8216;withcomments&#8217;] ) || str_contains( $this-&gt;query_vars[&#8216;feed&#8217;], &#8216;comments-&#8216; ) || ( empty( $this-&gt;query_vars[&#8216;withoutcomments&#8217;] ) &amp;&amp; ( ! empty( $this-&gt;query_vars[&#8216;p&#8217;] ) || ! empty( $this-&gt;query_vars[&#8216;name&#8217;] ) || ! empty( $this-&gt;query_vars[&#8216;page_id&#8217;] ) || ! empty( $this-&gt;query_vars[&#8216;pagename&#8217;] ) || ! empty( $this-&gt;query_vars[&#8216;attachment&#8217;] ) || ! empty( $this-&gt;query_vars[&#8216;attachment_id&#8217;] ) ) ) ) { $wp_last_modified_post = mysql2date( $date_format, get_lastpostmodified( &#8216;GMT&#8217; ), false ); $wp_last_modified_comment = mysql2date( $date_format, get_lastcommentmodified( &#8216;GMT&#8217; ), false ); if ( strtotime( $wp_last_modified_post ) &gt; strtotime( $wp_last_modified_comment ) ) { $wp_last_modified = $wp_last_modified_post; } else { $wp_last_modified = $wp_last_modified_comment; } } else { $wp_last_modified = mysql2date( $date_format, get_lastpostmodified( &#8216;GMT&#8217; ), false ); } if ( ! $wp_last_modified ) { $wp_last_modified = gmdate( $date_format ); } $wp_last_modified .= &#8216; GMT&#8217;; $wp_etag = &#8216;&#8221;&#8216; . md5( $wp_last_modified ) . &#8216;&#8221;&#8216;; $headers[&#8216;Last-Modified&#8217;] = $wp_last_modified; $headers[&#8216;ETag&#8217;] = $wp_etag; \/\/ Support for conditional GET. if ( isset( $_SERVER[&#8216;HTTP_IF_NONE_MATCH&#8217;] ) ) { $client_etag = wp_unslash( $_SERVER[&#8216;HTTP_IF_NONE_MATCH&#8217;] ); } else { $client_etag = &#8221;; } if ( isset( $_SERVER[&#8216;HTTP_IF_MODIFIED_SINCE&#8217;] ) ) { $client_last_modified = trim( $_SERVER[&#8216;HTTP_IF_MODIFIED_SINCE&#8217;] ); } else { $client_last_modified = &#8221;; } \/\/ If string is empty, return 0. If not, attempt to parse into a timestamp. $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0; \/\/ Make a timestamp for our most recent modification. $wp_modified_timestamp = strtotime( $wp_last_modified ); if ( ( $client_last_modified &amp;&amp; $client_etag ) ? ( ( $client_modified_timestamp &gt;= $wp_modified_timestamp ) &amp;&amp; ( $client_etag === $wp_etag ) ) : ( ( $client_modified_timestamp &gt;= $wp_modified_timestamp ) || ( $client_etag === $wp_etag ) ) ) { $status = 304; $exit_required = true; } } if ( is_singular() ) { $post = isset( $wp_query-&gt;post ) ? $wp_query-&gt;post : null; \/\/ Only set X-Pingback for single posts that allow pings. if ( $post &amp;&amp; pings_open( $post ) ) { $headers[&#8216;X-Pingback&#8217;] = get_bloginfo( &#8216;pingback_url&#8217;, &#8216;display&#8217; ); } } \/** * Filters the HTTP headers before they&#8217;re sent to the browser. * * @since 2.8.0 * * @param string[] $headers Associative array of headers to be sent. * @param WP $wp Current WordPress environment instance. *\/ $headers = apply_filters( &#8216;wp_headers&#8217;, $headers, $this ); if ( ! empty( $status ) ) { status_header( $status ); } \/\/ If Last-Modified is set to false, it should not be sent (no-cache situation). if ( isset( $headers[&#8216;Last-Modified&#8217;] ) &amp;&amp; false === $headers[&#8216;Last-Modified&#8217;] ) { unset( $headers[&#8216;Last-Modified&#8217;] ); if ( ! headers_sent() ) { header_remove( &#8216;Last-Modified&#8217; ); } } if ( ! headers_sent() ) { foreach ( (array) $headers as $name =&gt; $field_value ) { header( &#8220;{$name}: {$field_value}&#8221; ); } } if ( $exit_required ) { exit; } \/** * Fires once the requested HTTP headers for caching, content type, etc. have been sent. * * @since 2.1.0 * * @param WP $wp Current WordPress environment instance (passed by reference). *\/ do_action_ref_array( &#8216;send_headers&#8217;, array( &amp;$this ) ); } \/** * Sets the query string property based off of the query variable property. * * The {@see &#8216;query_string&#8217;} filter is deprecated, but still works. Plugins should * use the {@see &#8216;request&#8217;} filter instead. * * @since 2.0.0 *\/ public function build_query_string() { $this-&gt;query_string = &#8221;; foreach ( (array) array_keys( $this-&gt;query_vars ) as $wpvar ) { if ( &#8221; !== $this-&gt;query_vars[ $wpvar ] ) { $this-&gt;query_string .= ( strlen( $this-&gt;query_string ) &lt; 1 ) ? &#8221; : &#8216;&amp;&#8217;; if ( ! is_scalar( $this-&gt;query_vars[ $wpvar ] ) ) { \/\/ Discard non-scalars. continue; } $this-&gt;query_string .= $wpvar . &#8216;=&#8217; . rawurlencode( $this-&gt;query_vars[ $wpvar ] ); } } if ( has_filter( &#8216;query_string&#8217; ) ) { \/\/ Don&#8217;t bother filtering and parsing if no plugins are hooked in. \/** * Filters the query string before parsing. * * @since 1.5.0 * @deprecated 2.1.0 Use {@see &#8216;query_vars&#8217;} or {@see &#8216;request&#8217;} filters instead. * * @param string $query_string The query string to modify. *\/ $this-&gt;query_string = apply_filters_deprecated( &#8216;query_string&#8217;, array( $this-&gt;query_string ), &#8216;2.1.0&#8217;, &#8216;query_vars, request&#8217; ); parse_str( $this-&gt;query_string, $this-&gt;query_vars ); } } \/** * Set up the WordPress Globals. * * The query_vars property will be extracted to the GLOBALS. So care should * be taken when naming global variables that might interfere with the * WordPress environment. * * @since 2.0.0 * * @global WP_Query $wp_query WordPress Query object. * @global string $query_string Query string for the loop. * @global array $posts The found posts. * @global WP_Post|null $post The current post, if available. * @global string $request The SQL statement for the request. * @global int $more Only set, if single page or post. * @global int $single If single page or post. Only set, if single page or post. * @global WP_User $authordata Only set, if author archive. *\/ public function register_globals() { global $wp_query; \/\/ Extract updated query vars back into global namespace. foreach ( (array) $wp_query-&gt;query_vars as $key =&gt; $value ) { $GLOBALS[ $key ] = $value; } $GLOBALS[&#8216;query_string&#8217;] = $this-&gt;query_string; $GLOBALS[&#8216;posts&#8217;] = &amp; $wp_query-&gt;posts; $GLOBALS[&#8216;post&#8217;] = isset( $wp_query-&gt;post ) ? $wp_query-&gt;post : null; $GLOBALS[&#8216;request&#8217;] = $wp_query-&gt;request; if ( $wp_query-&gt;is_single() || $wp_query-&gt;is_page() ) { $GLOBALS[&#8216;more&#8217;] = 1; $GLOBALS[&#8216;single&#8217;] = 1; } if ( $wp_query-&gt;is_author() ) { $GLOBALS[&#8216;authordata&#8217;] = get_userdata( get_queried_object_id() ); } } \/** * Set up the current user. * * @since 2.0.0 *\/ public function init() { wp_get_current_user(); } \/** * Set up the Loop based on the query variables. * * @since 2.0.0 * * @global WP_Query $wp_the_query WordPress Query object. *\/ public function query_posts() { global $wp_the_query; $this-&gt;build_query_string(); $wp_the_query-&gt;query( $this-&gt;query_vars ); } \/** * Set the Headers for 404, if nothing is found for requested URL. * * Issue a 404 if a request doesn&#8217;t match any posts and doesn&#8217;t match any object * (e.g. an existing-but-empty category, tag, author) and a 404 was not already issued, * and if the request was not a search or the homepage. * * Otherwise, issue a 200. * * This sets headers after posts have been queried. handle_404() really means &#8220;handle status&#8221;. * By inspecting the result of querying posts, seemingly successful requests can be switched to * a 404 so that canonical redirection logic can kick in. * * @since 2.0.0 * * @global WP_Query $wp_query WordPress Query object. *\/ public function handle_404() { global $wp_query; \/** * Filters whether to short-circuit default header status handling. * * Returning a non-false value from the filter will short-circuit the handling * and return early. * * @since 4.5.0 * * @param bool $preempt Whether to short-circuit default header status handling. Default false. * @param WP_Query $wp_query WordPress Query object. *\/ if ( false !== apply_filters( &#8216;pre_handle_404&#8217;, false, $wp_query ) ) { return; } \/\/ If we&#8217;ve already issued a 404, bail. if ( is_404() ) { return; } $set_404 = true; \/\/ Never 404 for the admin, robots, or favicon. if ( is_admin() || is_robots() || is_favicon() ) { $set_404 = false; \/\/ If posts were found, check for paged content. } elseif ( $wp_query-&gt;posts ) { $content_found = true; if ( is_singular() ) { $post = isset( $wp_query-&gt;post ) ? $wp_query-&gt;post : null; $next = &#8221;; \/\/ Check for paged content that exceeds the max number of pages. if ( $post &amp;&amp; ! empty( $this-&gt;query_vars[&#8216;page&#8217;] ) ) { \/\/ Check if content is actually intended to be paged. if ( str_contains( $post-&gt;post_content, $next ) ) { $page = trim( $this-&gt;query_vars[&#8216;page&#8217;], &#8216;\/&#8217; ); $content_found = (int) $page &lt;= ( substr_count( $post-&gt;post_content, $next ) + 1 ); } else { $content_found = false; } } } \/\/ The posts page does not support the\u00a0pagination. if ( $wp_query-&gt;is_posts_page &amp;&amp; ! empty( $this-&gt;query_vars[&#8216;page&#8217;] ) ) { $content_found = false; } if ( $content_found ) { $set_404 = false; } \/\/ We will 404 for paged queries, as no posts were found. } elseif ( ! is_paged() ) { $author = get_query_var( &#8216;author&#8217; ); \/\/ Don&#8217;t 404 for authors without posts as long as they matched an author on this site. if ( is_author() &amp;&amp; is_numeric( $author ) &amp;&amp; $author &gt; 0 &amp;&amp; is_user_member_of_blog( $author ) \/\/ Don&#8217;t 404 for these queries if they matched an object. || ( is_tag() || is_category() || is_tax() || is_post_type_archive() ) &amp;&amp; get_queried_object() \/\/ Don&#8217;t 404 for these queries either. || is_home() || is_search() || is_feed() ) { $set_404 = false; } } if ( $set_404 ) { \/\/ Guess it&#8217;s time to 404. $wp_query-&gt;set_404(); status_header( 404 ); nocache_headers(); } else { status_header( 200 ); } } \/** * Sets up all of the variables required by the WordPress environment. * * The action {@see &#8216;wp&#8217;} has one parameter that references the WP object. It * allows for accessing the properties and methods to further manipulate the * object. * * @since 2.0.0 * * @param string|array $query_args Passed to parse_request(). *\/ public function main( $query_args = &#8221; ) { $this-&gt;init(); $parsed = $this-&gt;parse_request( $query_args ); if ( $parsed ) { $this-&gt;query_posts(); $this-&gt;handle_404(); $this-&gt;register_globals(); } $this-&gt;send_headers(); \/** * Fires once the WordPress environment has been set up. * * @since 2.1.0 * * @param WP $wp Current WordPress environment instance (passed by reference). *\/ do_action_ref_array( &#8216;wp&#8217;, array( &amp;$this ) ); } }<\/p>\n","protected":false},"template":"","class_list":["post-12178587","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12178587","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12178587\/revisions"}],"wp:attachment":[{"href":"https:\/\/it.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=12178587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}