Edit File by line
/home/zeestwma/richards.../wp-inclu...
File: class-wp.php
}
[500] Fix | Delete
[501] Fix | Delete
if ( ! $wp_last_modified ) {
[502] Fix | Delete
$wp_last_modified = gmdate( $date_format );
[503] Fix | Delete
}
[504] Fix | Delete
[505] Fix | Delete
$wp_last_modified .= ' GMT';
[506] Fix | Delete
$wp_etag = '"' . md5( $wp_last_modified ) . '"';
[507] Fix | Delete
[508] Fix | Delete
$headers['Last-Modified'] = $wp_last_modified;
[509] Fix | Delete
$headers['ETag'] = $wp_etag;
[510] Fix | Delete
[511] Fix | Delete
// Support for conditional GET.
[512] Fix | Delete
if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) {
[513] Fix | Delete
$client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] );
[514] Fix | Delete
} else {
[515] Fix | Delete
$client_etag = '';
[516] Fix | Delete
}
[517] Fix | Delete
[518] Fix | Delete
if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
[519] Fix | Delete
$client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
[520] Fix | Delete
} else {
[521] Fix | Delete
$client_last_modified = '';
[522] Fix | Delete
}
[523] Fix | Delete
[524] Fix | Delete
// If string is empty, return 0. If not, attempt to parse into a timestamp.
[525] Fix | Delete
$client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
[526] Fix | Delete
[527] Fix | Delete
// Make a timestamp for our most recent modification.
[528] Fix | Delete
$wp_modified_timestamp = strtotime( $wp_last_modified );
[529] Fix | Delete
[530] Fix | Delete
if ( ( $client_last_modified && $client_etag )
[531] Fix | Delete
? ( ( $client_modified_timestamp >= $wp_modified_timestamp ) && ( $client_etag === $wp_etag ) )
[532] Fix | Delete
: ( ( $client_modified_timestamp >= $wp_modified_timestamp ) || ( $client_etag === $wp_etag ) )
[533] Fix | Delete
) {
[534] Fix | Delete
$status = 304;
[535] Fix | Delete
$exit_required = true;
[536] Fix | Delete
}
[537] Fix | Delete
}
[538] Fix | Delete
[539] Fix | Delete
if ( is_singular() ) {
[540] Fix | Delete
$post = isset( $wp_query->post ) ? $wp_query->post : null;
[541] Fix | Delete
[542] Fix | Delete
// Only set X-Pingback for single posts that allow pings.
[543] Fix | Delete
if ( $post && pings_open( $post ) ) {
[544] Fix | Delete
$headers['X-Pingback'] = get_bloginfo( 'pingback_url', 'display' );
[545] Fix | Delete
}
[546] Fix | Delete
[547] Fix | Delete
// Send nocache headers for password protected posts to avoid unwanted caching.
[548] Fix | Delete
if ( ! empty( $post->post_password ) ) {
[549] Fix | Delete
$headers = array_merge( $headers, wp_get_nocache_headers() );
[550] Fix | Delete
}
[551] Fix | Delete
}
[552] Fix | Delete
[553] Fix | Delete
/**
[554] Fix | Delete
* Filters the HTTP headers before they're sent to the browser.
[555] Fix | Delete
*
[556] Fix | Delete
* @since 2.8.0
[557] Fix | Delete
*
[558] Fix | Delete
* @param string[] $headers Associative array of headers to be sent.
[559] Fix | Delete
* @param WP $wp Current WordPress environment instance.
[560] Fix | Delete
*/
[561] Fix | Delete
$headers = apply_filters( 'wp_headers', $headers, $this );
[562] Fix | Delete
[563] Fix | Delete
if ( ! empty( $status ) ) {
[564] Fix | Delete
status_header( $status );
[565] Fix | Delete
}
[566] Fix | Delete
[567] Fix | Delete
// If Last-Modified is set to false, it should not be sent (no-cache situation).
[568] Fix | Delete
if ( isset( $headers['Last-Modified'] ) && false === $headers['Last-Modified'] ) {
[569] Fix | Delete
unset( $headers['Last-Modified'] );
[570] Fix | Delete
[571] Fix | Delete
if ( ! headers_sent() ) {
[572] Fix | Delete
header_remove( 'Last-Modified' );
[573] Fix | Delete
}
[574] Fix | Delete
}
[575] Fix | Delete
[576] Fix | Delete
if ( ! headers_sent() ) {
[577] Fix | Delete
foreach ( (array) $headers as $name => $field_value ) {
[578] Fix | Delete
header( "{$name}: {$field_value}" );
[579] Fix | Delete
}
[580] Fix | Delete
}
[581] Fix | Delete
[582] Fix | Delete
if ( $exit_required ) {
[583] Fix | Delete
exit;
[584] Fix | Delete
}
[585] Fix | Delete
[586] Fix | Delete
/**
[587] Fix | Delete
* Fires once the requested HTTP headers for caching, content type, etc. have been sent.
[588] Fix | Delete
*
[589] Fix | Delete
* @since 2.1.0
[590] Fix | Delete
*
[591] Fix | Delete
* @param WP $wp Current WordPress environment instance (passed by reference).
[592] Fix | Delete
*/
[593] Fix | Delete
do_action_ref_array( 'send_headers', array( &$this ) );
[594] Fix | Delete
}
[595] Fix | Delete
[596] Fix | Delete
/**
[597] Fix | Delete
* Sets the query string property based off of the query variable property.
[598] Fix | Delete
*
[599] Fix | Delete
* The {@see 'query_string'} filter is deprecated, but still works. Plugins should
[600] Fix | Delete
* use the {@see 'request'} filter instead.
[601] Fix | Delete
*
[602] Fix | Delete
* @since 2.0.0
[603] Fix | Delete
*/
[604] Fix | Delete
public function build_query_string() {
[605] Fix | Delete
$this->query_string = '';
[606] Fix | Delete
[607] Fix | Delete
foreach ( (array) array_keys( $this->query_vars ) as $wpvar ) {
[608] Fix | Delete
if ( '' !== $this->query_vars[ $wpvar ] ) {
[609] Fix | Delete
$this->query_string .= ( strlen( $this->query_string ) < 1 ) ? '' : '&';
[610] Fix | Delete
[611] Fix | Delete
if ( ! is_scalar( $this->query_vars[ $wpvar ] ) ) { // Discard non-scalars.
[612] Fix | Delete
continue;
[613] Fix | Delete
}
[614] Fix | Delete
[615] Fix | Delete
$this->query_string .= $wpvar . '=' . rawurlencode( $this->query_vars[ $wpvar ] );
[616] Fix | Delete
}
[617] Fix | Delete
}
[618] Fix | Delete
[619] Fix | Delete
if ( has_filter( 'query_string' ) ) { // Don't bother filtering and parsing if no plugins are hooked in.
[620] Fix | Delete
/**
[621] Fix | Delete
* Filters the query string before parsing.
[622] Fix | Delete
*
[623] Fix | Delete
* @since 1.5.0
[624] Fix | Delete
* @deprecated 2.1.0 Use {@see 'query_vars'} or {@see 'request'} filters instead.
[625] Fix | Delete
*
[626] Fix | Delete
* @param string $query_string The query string to modify.
[627] Fix | Delete
*/
[628] Fix | Delete
$this->query_string = apply_filters_deprecated(
[629] Fix | Delete
'query_string',
[630] Fix | Delete
array( $this->query_string ),
[631] Fix | Delete
'2.1.0',
[632] Fix | Delete
'query_vars, request'
[633] Fix | Delete
);
[634] Fix | Delete
[635] Fix | Delete
parse_str( $this->query_string, $this->query_vars );
[636] Fix | Delete
}
[637] Fix | Delete
}
[638] Fix | Delete
[639] Fix | Delete
/**
[640] Fix | Delete
* Set up the WordPress Globals.
[641] Fix | Delete
*
[642] Fix | Delete
* The query_vars property will be extracted to the GLOBALS. So care should
[643] Fix | Delete
* be taken when naming global variables that might interfere with the
[644] Fix | Delete
* WordPress environment.
[645] Fix | Delete
*
[646] Fix | Delete
* @since 2.0.0
[647] Fix | Delete
*
[648] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[649] Fix | Delete
* @global string $query_string Query string for the loop.
[650] Fix | Delete
* @global array $posts The found posts.
[651] Fix | Delete
* @global WP_Post|null $post The current post, if available.
[652] Fix | Delete
* @global string $request The SQL statement for the request.
[653] Fix | Delete
* @global int $more Only set, if single page or post.
[654] Fix | Delete
* @global int $single If single page or post. Only set, if single page or post.
[655] Fix | Delete
* @global WP_User $authordata Only set, if author archive.
[656] Fix | Delete
*/
[657] Fix | Delete
public function register_globals() {
[658] Fix | Delete
global $wp_query;
[659] Fix | Delete
[660] Fix | Delete
// Extract updated query vars back into global namespace.
[661] Fix | Delete
foreach ( (array) $wp_query->query_vars as $key => $value ) {
[662] Fix | Delete
$GLOBALS[ $key ] = $value;
[663] Fix | Delete
}
[664] Fix | Delete
[665] Fix | Delete
$GLOBALS['query_string'] = $this->query_string;
[666] Fix | Delete
$GLOBALS['posts'] = & $wp_query->posts;
[667] Fix | Delete
$GLOBALS['post'] = isset( $wp_query->post ) ? $wp_query->post : null;
[668] Fix | Delete
$GLOBALS['request'] = $wp_query->request;
[669] Fix | Delete
[670] Fix | Delete
if ( $wp_query->is_single() || $wp_query->is_page() ) {
[671] Fix | Delete
$GLOBALS['more'] = 1;
[672] Fix | Delete
$GLOBALS['single'] = 1;
[673] Fix | Delete
}
[674] Fix | Delete
[675] Fix | Delete
if ( $wp_query->is_author() ) {
[676] Fix | Delete
$GLOBALS['authordata'] = get_userdata( get_queried_object_id() );
[677] Fix | Delete
}
[678] Fix | Delete
}
[679] Fix | Delete
[680] Fix | Delete
/**
[681] Fix | Delete
* Set up the current user.
[682] Fix | Delete
*
[683] Fix | Delete
* @since 2.0.0
[684] Fix | Delete
*/
[685] Fix | Delete
public function init() {
[686] Fix | Delete
wp_get_current_user();
[687] Fix | Delete
}
[688] Fix | Delete
[689] Fix | Delete
/**
[690] Fix | Delete
* Set up the Loop based on the query variables.
[691] Fix | Delete
*
[692] Fix | Delete
* @since 2.0.0
[693] Fix | Delete
*
[694] Fix | Delete
* @global WP_Query $wp_the_query WordPress Query object.
[695] Fix | Delete
*/
[696] Fix | Delete
public function query_posts() {
[697] Fix | Delete
global $wp_the_query;
[698] Fix | Delete
$this->build_query_string();
[699] Fix | Delete
$wp_the_query->query( $this->query_vars );
[700] Fix | Delete
}
[701] Fix | Delete
[702] Fix | Delete
/**
[703] Fix | Delete
* Set the Headers for 404, if nothing is found for requested URL.
[704] Fix | Delete
*
[705] Fix | Delete
* Issue a 404 if a request doesn't match any posts and doesn't match any object
[706] Fix | Delete
* (e.g. an existing-but-empty category, tag, author) and a 404 was not already issued,
[707] Fix | Delete
* and if the request was not a search or the homepage.
[708] Fix | Delete
*
[709] Fix | Delete
* Otherwise, issue a 200.
[710] Fix | Delete
*
[711] Fix | Delete
* This sets headers after posts have been queried. handle_404() really means "handle status".
[712] Fix | Delete
* By inspecting the result of querying posts, seemingly successful requests can be switched to
[713] Fix | Delete
* a 404 so that canonical redirection logic can kick in.
[714] Fix | Delete
*
[715] Fix | Delete
* @since 2.0.0
[716] Fix | Delete
*
[717] Fix | Delete
* @global WP_Query $wp_query WordPress Query object.
[718] Fix | Delete
*/
[719] Fix | Delete
public function handle_404() {
[720] Fix | Delete
global $wp_query;
[721] Fix | Delete
[722] Fix | Delete
/**
[723] Fix | Delete
* Filters whether to short-circuit default header status handling.
[724] Fix | Delete
*
[725] Fix | Delete
* Returning a non-false value from the filter will short-circuit the handling
[726] Fix | Delete
* and return early.
[727] Fix | Delete
*
[728] Fix | Delete
* @since 4.5.0
[729] Fix | Delete
*
[730] Fix | Delete
* @param bool $preempt Whether to short-circuit default header status handling. Default false.
[731] Fix | Delete
* @param WP_Query $wp_query WordPress Query object.
[732] Fix | Delete
*/
[733] Fix | Delete
if ( false !== apply_filters( 'pre_handle_404', false, $wp_query ) ) {
[734] Fix | Delete
return;
[735] Fix | Delete
}
[736] Fix | Delete
[737] Fix | Delete
// If we've already issued a 404, bail.
[738] Fix | Delete
if ( is_404() ) {
[739] Fix | Delete
return;
[740] Fix | Delete
}
[741] Fix | Delete
[742] Fix | Delete
$set_404 = true;
[743] Fix | Delete
[744] Fix | Delete
// Never 404 for the admin, robots, or favicon.
[745] Fix | Delete
if ( is_admin() || is_robots() || is_favicon() ) {
[746] Fix | Delete
$set_404 = false;
[747] Fix | Delete
[748] Fix | Delete
// If posts were found, check for paged content.
[749] Fix | Delete
} elseif ( $wp_query->posts ) {
[750] Fix | Delete
$content_found = true;
[751] Fix | Delete
[752] Fix | Delete
if ( is_singular() ) {
[753] Fix | Delete
$post = isset( $wp_query->post ) ? $wp_query->post : null;
[754] Fix | Delete
$next = '<!--nextpage-->';
[755] Fix | Delete
[756] Fix | Delete
// Check for paged content that exceeds the max number of pages.
[757] Fix | Delete
if ( $post && ! empty( $this->query_vars['page'] ) ) {
[758] Fix | Delete
// Check if content is actually intended to be paged.
[759] Fix | Delete
if ( str_contains( $post->post_content, $next ) ) {
[760] Fix | Delete
$page = trim( $this->query_vars['page'], '/' );
[761] Fix | Delete
$content_found = (int) $page <= ( substr_count( $post->post_content, $next ) + 1 );
[762] Fix | Delete
} else {
[763] Fix | Delete
$content_found = false;
[764] Fix | Delete
}
[765] Fix | Delete
}
[766] Fix | Delete
}
[767] Fix | Delete
[768] Fix | Delete
// The posts page does not support the <!--nextpage--> pagination.
[769] Fix | Delete
if ( $wp_query->is_posts_page && ! empty( $this->query_vars['page'] ) ) {
[770] Fix | Delete
$content_found = false;
[771] Fix | Delete
}
[772] Fix | Delete
[773] Fix | Delete
if ( $content_found ) {
[774] Fix | Delete
$set_404 = false;
[775] Fix | Delete
}
[776] Fix | Delete
[777] Fix | Delete
// We will 404 for paged queries, as no posts were found.
[778] Fix | Delete
} elseif ( ! is_paged() ) {
[779] Fix | Delete
$author = get_query_var( 'author' );
[780] Fix | Delete
[781] Fix | Delete
// Don't 404 for authors without posts as long as they matched an author on this site.
[782] Fix | Delete
if ( is_author() && is_numeric( $author ) && $author > 0 && is_user_member_of_blog( $author )
[783] Fix | Delete
// Don't 404 for these queries if they matched an object.
[784] Fix | Delete
|| ( is_tag() || is_category() || is_tax() || is_post_type_archive() ) && get_queried_object()
[785] Fix | Delete
// Don't 404 for these queries either.
[786] Fix | Delete
|| is_home() || is_search() || is_feed()
[787] Fix | Delete
) {
[788] Fix | Delete
$set_404 = false;
[789] Fix | Delete
}
[790] Fix | Delete
}
[791] Fix | Delete
[792] Fix | Delete
if ( $set_404 ) {
[793] Fix | Delete
// Guess it's time to 404.
[794] Fix | Delete
$wp_query->set_404();
[795] Fix | Delete
status_header( 404 );
[796] Fix | Delete
nocache_headers();
[797] Fix | Delete
} else {
[798] Fix | Delete
status_header( 200 );
[799] Fix | Delete
}
[800] Fix | Delete
}
[801] Fix | Delete
[802] Fix | Delete
/**
[803] Fix | Delete
* Sets up all of the variables required by the WordPress environment.
[804] Fix | Delete
*
[805] Fix | Delete
* The action {@see 'wp'} has one parameter that references the WP object. It
[806] Fix | Delete
* allows for accessing the properties and methods to further manipulate the
[807] Fix | Delete
* object.
[808] Fix | Delete
*
[809] Fix | Delete
* @since 2.0.0
[810] Fix | Delete
*
[811] Fix | Delete
* @param string|array $query_args Passed to parse_request().
[812] Fix | Delete
*/
[813] Fix | Delete
public function main( $query_args = '' ) {
[814] Fix | Delete
$this->init();
[815] Fix | Delete
[816] Fix | Delete
$parsed = $this->parse_request( $query_args );
[817] Fix | Delete
[818] Fix | Delete
if ( $parsed ) {
[819] Fix | Delete
$this->query_posts();
[820] Fix | Delete
$this->handle_404();
[821] Fix | Delete
$this->register_globals();
[822] Fix | Delete
}
[823] Fix | Delete
[824] Fix | Delete
$this->send_headers();
[825] Fix | Delete
[826] Fix | Delete
/**
[827] Fix | Delete
* Fires once the WordPress environment has been set up.
[828] Fix | Delete
*
[829] Fix | Delete
* @since 2.1.0
[830] Fix | Delete
*
[831] Fix | Delete
* @param WP $wp Current WordPress environment instance (passed by reference).
[832] Fix | Delete
*/
[833] Fix | Delete
do_action_ref_array( 'wp', array( &$this ) );
[834] Fix | Delete
}
[835] Fix | Delete
}
[836] Fix | Delete
[837] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function