Edit File by line
/home/barbar84/www/wp-conte.../plugins/nginx-he.../admin
File: class-purger.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* The admin-specific functionality of the plugin.
[2] Fix | Delete
*
[3] Fix | Delete
* @package nginx-helper
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Description of purger
[8] Fix | Delete
*
[9] Fix | Delete
* @package nginx-helper
[10] Fix | Delete
*
[11] Fix | Delete
* @subpackage nginx-helper/admin
[12] Fix | Delete
*
[13] Fix | Delete
* @author rtCamp
[14] Fix | Delete
*/
[15] Fix | Delete
abstract class Purger {
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Purge cache for url.
[19] Fix | Delete
*
[20] Fix | Delete
* @param string $url URL.
[21] Fix | Delete
* @param bool $feed Is feed or not.
[22] Fix | Delete
*
[23] Fix | Delete
* @return mixed
[24] Fix | Delete
*/
[25] Fix | Delete
abstract public function purge_url( $url, $feed = true );
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* Purge cache for custom url.
[29] Fix | Delete
*
[30] Fix | Delete
* @return mixed
[31] Fix | Delete
*/
[32] Fix | Delete
abstract public function custom_purge_urls();
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Purge all cache
[36] Fix | Delete
*
[37] Fix | Delete
* @return mixed
[38] Fix | Delete
*/
[39] Fix | Delete
abstract public function purge_all();
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Purge cache on comment.
[43] Fix | Delete
*
[44] Fix | Delete
* @param int $comment_id Comment id.
[45] Fix | Delete
* @param object $comment Comment data.
[46] Fix | Delete
*/
[47] Fix | Delete
public function purge_post_on_comment( $comment_id, $comment ) {
[48] Fix | Delete
[49] Fix | Delete
$oldstatus = '';
[50] Fix | Delete
$approved = $comment->comment_approved;
[51] Fix | Delete
[52] Fix | Delete
if ( null === $approved ) {
[53] Fix | Delete
$newstatus = false;
[54] Fix | Delete
} elseif ( '1' === $approved ) {
[55] Fix | Delete
$newstatus = 'approved';
[56] Fix | Delete
} elseif ( '0' === $approved ) {
[57] Fix | Delete
$newstatus = 'unapproved';
[58] Fix | Delete
} elseif ( 'spam' === $approved ) {
[59] Fix | Delete
$newstatus = 'spam';
[60] Fix | Delete
} elseif ( 'trash' === $approved ) {
[61] Fix | Delete
$newstatus = 'trash';
[62] Fix | Delete
} else {
[63] Fix | Delete
$newstatus = false;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
$this->purge_post_on_comment_change( $newstatus, $oldstatus, $comment );
[67] Fix | Delete
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
/**
[71] Fix | Delete
* Purge post cache on comment change.
[72] Fix | Delete
*
[73] Fix | Delete
* @param string $newstatus New status.
[74] Fix | Delete
* @param string $oldstatus Old status.
[75] Fix | Delete
* @param object $comment Comment data.
[76] Fix | Delete
*/
[77] Fix | Delete
public function purge_post_on_comment_change( $newstatus, $oldstatus, $comment ) {
[78] Fix | Delete
[79] Fix | Delete
global $nginx_helper_admin, $blog_id;
[80] Fix | Delete
[81] Fix | Delete
if ( ! $nginx_helper_admin->options['enable_purge'] ) {
[82] Fix | Delete
return;
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
$_post_id = $comment->comment_post_ID;
[86] Fix | Delete
$_comment_id = $comment->comment_ID;
[87] Fix | Delete
[88] Fix | Delete
$this->log( '* * * * *' );
[89] Fix | Delete
$this->log( '* Blog :: ' . addslashes( get_bloginfo( 'name' ) ) . ' ( ' . $blog_id . ' ). ' );
[90] Fix | Delete
$this->log( '* Post :: ' . get_the_title( $_post_id ) . ' ( ' . $_post_id . ' ) ' );
[91] Fix | Delete
$this->log( "* Comment :: $_comment_id." );
[92] Fix | Delete
$this->log( "* Status Changed from $oldstatus to $newstatus" );
[93] Fix | Delete
[94] Fix | Delete
switch ( $newstatus ) {
[95] Fix | Delete
[96] Fix | Delete
case 'approved':
[97] Fix | Delete
if ( 1 === (int) $nginx_helper_admin->options['purge_page_on_new_comment'] ) {
[98] Fix | Delete
[99] Fix | Delete
$this->log( '* Comment ( ' . $_comment_id . ' ) approved. Post ( ' . $_post_id . ' ) purging...' );
[100] Fix | Delete
$this->log( '* * * * *' );
[101] Fix | Delete
$this->purge_post( $_post_id );
[102] Fix | Delete
[103] Fix | Delete
}
[104] Fix | Delete
break;
[105] Fix | Delete
[106] Fix | Delete
case 'spam':
[107] Fix | Delete
case 'unapproved':
[108] Fix | Delete
case 'trash':
[109] Fix | Delete
if ( 'approved' === $oldstatus && 1 === (int) $nginx_helper_admin->options['purge_page_on_deleted_comment'] ) {
[110] Fix | Delete
[111] Fix | Delete
$this->log( '* Comment ( ' . $_comment_id . ' ) removed as ( ' . $newstatus . ' ). Post ( ' . $_post_id . ' ) purging...' );
[112] Fix | Delete
$this->log( '* * * * *' );
[113] Fix | Delete
$this->purge_post( $_post_id );
[114] Fix | Delete
[115] Fix | Delete
}
[116] Fix | Delete
break;
[117] Fix | Delete
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
/**
[123] Fix | Delete
* Purge post cache.
[124] Fix | Delete
*
[125] Fix | Delete
* @param int $post_id Post id.
[126] Fix | Delete
*/
[127] Fix | Delete
public function purge_post( $post_id ) {
[128] Fix | Delete
[129] Fix | Delete
global $nginx_helper_admin, $blog_id;
[130] Fix | Delete
[131] Fix | Delete
if ( ! $nginx_helper_admin->options['enable_purge'] ) {
[132] Fix | Delete
return;
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
switch ( current_filter() ) {
[136] Fix | Delete
[137] Fix | Delete
case 'publish_post':
[138] Fix | Delete
$this->log( '* * * * *' );
[139] Fix | Delete
$this->log( '* Blog :: ' . addslashes( get_bloginfo( 'name' ) ) . ' ( ' . $blog_id . ' ).' );
[140] Fix | Delete
$this->log( '* Post :: ' . get_the_title( $post_id ) . ' ( ' . $post_id . ' ).' );
[141] Fix | Delete
$this->log( '* Post ( ' . $post_id . ' ) published or edited and its status is published' );
[142] Fix | Delete
$this->log( '* * * * *' );
[143] Fix | Delete
break;
[144] Fix | Delete
[145] Fix | Delete
case 'publish_page':
[146] Fix | Delete
$this->log( '* * * * *' );
[147] Fix | Delete
$this->log( '* Blog :: ' . addslashes( get_bloginfo( 'name' ) ) . ' ( ' . $blog_id . ' ).' );
[148] Fix | Delete
$this->log( '* Page :: ' . get_the_title( $post_id ) . ' ( ' . $post_id . ' ).' );
[149] Fix | Delete
$this->log( '* Page ( ' . $post_id . ' ) published or edited and its status is published' );
[150] Fix | Delete
$this->log( '* * * * *' );
[151] Fix | Delete
break;
[152] Fix | Delete
[153] Fix | Delete
case 'comment_post':
[154] Fix | Delete
case 'wp_set_comment_status':
[155] Fix | Delete
break;
[156] Fix | Delete
[157] Fix | Delete
default:
[158] Fix | Delete
$_post_type = get_post_type( $post_id );
[159] Fix | Delete
$this->log( '* * * * *' );
[160] Fix | Delete
$this->log( '* Blog :: ' . addslashes( get_bloginfo( 'name' ) ) . ' ( ' . $blog_id . ' ).' );
[161] Fix | Delete
$this->log( "* Custom post type '" . $_post_type . "' :: " . get_the_title( $post_id ) . ' ( ' . $post_id . ' ).' );
[162] Fix | Delete
$this->log( "* CPT '" . $_post_type . "' ( " . $post_id . ' ) published or edited and its status is published' );
[163] Fix | Delete
$this->log( '* * * * *' );
[164] Fix | Delete
break;
[165] Fix | Delete
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
$this->log( 'Function purge_post BEGIN ===' );
[169] Fix | Delete
[170] Fix | Delete
if ( 1 === (int) $nginx_helper_admin->options['purge_homepage_on_edit'] ) {
[171] Fix | Delete
$this->_purge_homepage();
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
if ( 'comment_post' === current_filter() || 'wp_set_comment_status' === current_filter() ) {
[175] Fix | Delete
[176] Fix | Delete
$this->_purge_by_options(
[177] Fix | Delete
$post_id,
[178] Fix | Delete
$blog_id,
[179] Fix | Delete
$nginx_helper_admin->options['purge_page_on_new_comment'],
[180] Fix | Delete
$nginx_helper_admin->options['purge_archive_on_new_comment'],
[181] Fix | Delete
$nginx_helper_admin->options['purge_archive_on_new_comment']
[182] Fix | Delete
);
[183] Fix | Delete
[184] Fix | Delete
} else {
[185] Fix | Delete
[186] Fix | Delete
$this->_purge_by_options(
[187] Fix | Delete
$post_id,
[188] Fix | Delete
$blog_id,
[189] Fix | Delete
$nginx_helper_admin->options['purge_page_on_mod'],
[190] Fix | Delete
$nginx_helper_admin->options['purge_archive_on_edit'],
[191] Fix | Delete
$nginx_helper_admin->options['purge_archive_on_edit']
[192] Fix | Delete
);
[193] Fix | Delete
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
$this->custom_purge_urls();
[197] Fix | Delete
[198] Fix | Delete
$this->log( 'Function purge_post END ^^^' );
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
/**
[202] Fix | Delete
* Purge cache by options.
[203] Fix | Delete
*
[204] Fix | Delete
* @param int $post_id Post id.
[205] Fix | Delete
* @param int $blog_id Blog id.
[206] Fix | Delete
* @param bool $_purge_page Purge page or not.
[207] Fix | Delete
* @param bool $_purge_archive Purge archive or not.
[208] Fix | Delete
* @param bool $_purge_custom_taxa Purge taxonomy or not.
[209] Fix | Delete
*/
[210] Fix | Delete
private function _purge_by_options( $post_id, $blog_id, $_purge_page, $_purge_archive, $_purge_custom_taxa ) {
[211] Fix | Delete
[212] Fix | Delete
$_post_type = get_post_type( $post_id );
[213] Fix | Delete
[214] Fix | Delete
if ( $_purge_page ) {
[215] Fix | Delete
[216] Fix | Delete
if ( 'post' === $_post_type || 'page' === $_post_type ) {
[217] Fix | Delete
$this->log( 'Purging ' . $_post_type . ' ( id ' . $post_id . ', blog id ' . $blog_id . ' ) ' );
[218] Fix | Delete
} else {
[219] Fix | Delete
$this->log( "Purging custom post type '" . $_post_type . "' ( id " . $post_id . ', blog id ' . $blog_id . ' )' );
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
$post_status = get_post_status( $post_id );
[223] Fix | Delete
[224] Fix | Delete
if ( 'publish' !== $post_status ) {
[225] Fix | Delete
[226] Fix | Delete
if ( ! function_exists( 'get_sample_permalink' ) ) {
[227] Fix | Delete
require_once ABSPATH . '/wp-admin/includes/post.php';
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
$url = get_sample_permalink( $post_id );
[231] Fix | Delete
[232] Fix | Delete
if ( ! empty( $url[0] ) && ! empty( $url[1] ) ) {
[233] Fix | Delete
$url = str_replace( '%postname%', $url[1], $url[0] );
[234] Fix | Delete
} else {
[235] Fix | Delete
$url = '';
[236] Fix | Delete
}
[237] Fix | Delete
} else {
[238] Fix | Delete
$url = get_permalink( $post_id );
[239] Fix | Delete
}
[240] Fix | Delete
[241] Fix | Delete
if ( empty( $url ) && ! is_array( $url ) ) {
[242] Fix | Delete
return;
[243] Fix | Delete
}
[244] Fix | Delete
[245] Fix | Delete
if ( 'trash' === get_post_status( $post_id ) ) {
[246] Fix | Delete
$url = str_replace( '__trashed', '', $url );
[247] Fix | Delete
}
[248] Fix | Delete
[249] Fix | Delete
$this->purge_url( $url );
[250] Fix | Delete
[251] Fix | Delete
}
[252] Fix | Delete
[253] Fix | Delete
if ( $_purge_archive ) {
[254] Fix | Delete
[255] Fix | Delete
$_post_type_archive_link = get_post_type_archive_link( $_post_type );
[256] Fix | Delete
[257] Fix | Delete
if ( function_exists( 'get_post_type_archive_link' ) && $_post_type_archive_link ) {
[258] Fix | Delete
[259] Fix | Delete
$this->log( 'Purging post type archive ( ' . $_post_type . ' )' );
[260] Fix | Delete
$this->purge_url( $_post_type_archive_link );
[261] Fix | Delete
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
if ( 'post' === $_post_type ) {
[265] Fix | Delete
[266] Fix | Delete
$this->log( 'Purging date' );
[267] Fix | Delete
[268] Fix | Delete
$day = get_the_time( 'd', $post_id );
[269] Fix | Delete
$month = get_the_time( 'm', $post_id );
[270] Fix | Delete
$year = get_the_time( 'Y', $post_id );
[271] Fix | Delete
[272] Fix | Delete
if ( $year ) {
[273] Fix | Delete
[274] Fix | Delete
$this->purge_url( get_year_link( $year ) );
[275] Fix | Delete
[276] Fix | Delete
if ( $month ) {
[277] Fix | Delete
[278] Fix | Delete
$this->purge_url( get_month_link( $year, $month ) );
[279] Fix | Delete
[280] Fix | Delete
if ( $day ) {
[281] Fix | Delete
$this->purge_url( get_day_link( $year, $month, $day ) );
[282] Fix | Delete
}
[283] Fix | Delete
}
[284] Fix | Delete
}
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
$categories = wp_get_post_categories( $post_id );
[288] Fix | Delete
[289] Fix | Delete
if ( ! is_wp_error( $categories ) ) {
[290] Fix | Delete
[291] Fix | Delete
$this->log( 'Purging category archives' );
[292] Fix | Delete
[293] Fix | Delete
foreach ( $categories as $category_id ) {
[294] Fix | Delete
[295] Fix | Delete
$this->log( 'Purging category ' . $category_id );
[296] Fix | Delete
$this->purge_url( get_category_link( $category_id ) );
[297] Fix | Delete
[298] Fix | Delete
}
[299] Fix | Delete
}
[300] Fix | Delete
[301] Fix | Delete
$tags = get_the_tags( $post_id );
[302] Fix | Delete
[303] Fix | Delete
if ( ! is_wp_error( $tags ) && ! empty( $tags ) ) {
[304] Fix | Delete
[305] Fix | Delete
$this->log( 'Purging tag archives' );
[306] Fix | Delete
[307] Fix | Delete
foreach ( $tags as $tag ) {
[308] Fix | Delete
[309] Fix | Delete
$this->log( 'Purging tag ' . $tag->term_id );
[310] Fix | Delete
$this->purge_url( get_tag_link( $tag->term_id ) );
[311] Fix | Delete
[312] Fix | Delete
}
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
$author_id = get_post( $post_id )->post_author;
[316] Fix | Delete
[317] Fix | Delete
if ( ! empty( $author_id ) ) {
[318] Fix | Delete
[319] Fix | Delete
$this->log( 'Purging author archive' );
[320] Fix | Delete
$this->purge_url( get_author_posts_url( $author_id ) );
[321] Fix | Delete
[322] Fix | Delete
}
[323] Fix | Delete
}
[324] Fix | Delete
[325] Fix | Delete
if ( $_purge_custom_taxa ) {
[326] Fix | Delete
[327] Fix | Delete
$custom_taxonomies = get_taxonomies(
[328] Fix | Delete
array(
[329] Fix | Delete
'public' => true,
[330] Fix | Delete
'_builtin' => false,
[331] Fix | Delete
)
[332] Fix | Delete
);
[333] Fix | Delete
[334] Fix | Delete
if ( ! empty( $custom_taxonomies ) ) {
[335] Fix | Delete
[336] Fix | Delete
$this->log( 'Purging custom taxonomies related' );
[337] Fix | Delete
[338] Fix | Delete
foreach ( $custom_taxonomies as $taxon ) {
[339] Fix | Delete
[340] Fix | Delete
if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ), true ) ) {
[341] Fix | Delete
[342] Fix | Delete
$terms = get_the_terms( $post_id, $taxon );
[343] Fix | Delete
[344] Fix | Delete
if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
[345] Fix | Delete
[346] Fix | Delete
foreach ( $terms as $term ) {
[347] Fix | Delete
$this->purge_url( get_term_link( $term, $taxon ) );
[348] Fix | Delete
}
[349] Fix | Delete
}
[350] Fix | Delete
} else {
[351] Fix | Delete
$this->log( "Your built-in taxonomy '" . $taxon . "' has param '_builtin' set to false.", 'WARNING' );
[352] Fix | Delete
}
[353] Fix | Delete
}
[354] Fix | Delete
}
[355] Fix | Delete
}
[356] Fix | Delete
}
[357] Fix | Delete
[358] Fix | Delete
/**
[359] Fix | Delete
* Deletes local cache files without a 3rd party nginx module.
[360] Fix | Delete
* Does not require any other modules. Requires that the cache be stored on the same server as WordPress. You must also be using the default nginx cache options (levels=1:2) and (fastcgi_cache_key "$scheme$request_method$host$request_uri").
[361] Fix | Delete
* Read more on how this works here:
[362] Fix | Delete
* https://www.digitalocean.com/community/tutorials/how-to-setup-fastcgi-caching-with-nginx-on-your-vps#purging-the-cache
[363] Fix | Delete
*
[364] Fix | Delete
* @param string $url URL to purge.
[365] Fix | Delete
*
[366] Fix | Delete
* @return bool
[367] Fix | Delete
*/
[368] Fix | Delete
protected function delete_cache_file_for( $url ) {
[369] Fix | Delete
[370] Fix | Delete
// Verify cache path is set.
[371] Fix | Delete
if ( ! defined( 'RT_WP_NGINX_HELPER_CACHE_PATH' ) ) {
[372] Fix | Delete
[373] Fix | Delete
$this->log( 'Error purging because RT_WP_NGINX_HELPER_CACHE_PATH was not defined. URL: ' . $url, 'ERROR' );
[374] Fix | Delete
return false;
[375] Fix | Delete
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
// Verify URL is valid.
[379] Fix | Delete
$url_data = wp_parse_url( $url );
[380] Fix | Delete
if ( ! $url_data ) {
[381] Fix | Delete
[382] Fix | Delete
$this->log( 'Error purging because specified URL did not appear to be valid. URL: ' . $url, 'ERROR' );
[383] Fix | Delete
return false;
[384] Fix | Delete
[385] Fix | Delete
}
[386] Fix | Delete
[387] Fix | Delete
// Build a hash of the URL.
[388] Fix | Delete
$hash = md5( $url_data['scheme'] . 'GET' . $url_data['host'] . $url_data['path'] );
[389] Fix | Delete
[390] Fix | Delete
// Ensure trailing slash.
[391] Fix | Delete
$cache_path = RT_WP_NGINX_HELPER_CACHE_PATH;
[392] Fix | Delete
$cache_path = ( '/' === substr( $cache_path, -1 ) ) ? $cache_path : $cache_path . '/';
[393] Fix | Delete
[394] Fix | Delete
// Set path to cached file.
[395] Fix | Delete
$cached_file = $cache_path . substr( $hash, -1 ) . '/' . substr( $hash, -3, 2 ) . '/' . $hash;
[396] Fix | Delete
[397] Fix | Delete
/**
[398] Fix | Delete
* Filters the cached file name.
[399] Fix | Delete
*
[400] Fix | Delete
* @since 2.1.0
[401] Fix | Delete
*
[402] Fix | Delete
* @param string $cached_file Cached file name.
[403] Fix | Delete
*/
[404] Fix | Delete
$cached_file = apply_filters( 'rt_nginx_helper_purge_cached_file', $cached_file );
[405] Fix | Delete
[406] Fix | Delete
// Verify cached file exists.
[407] Fix | Delete
if ( ! file_exists( $cached_file ) ) {
[408] Fix | Delete
[409] Fix | Delete
$this->log( '- - ' . $url . ' is currently not cached ( checked for file: ' . $cached_file . ' )' );
[410] Fix | Delete
return false;
[411] Fix | Delete
[412] Fix | Delete
}
[413] Fix | Delete
[414] Fix | Delete
// Delete the cached file.
[415] Fix | Delete
if ( unlink( $cached_file ) ) {
[416] Fix | Delete
$this->log( '- - ' . $url . ' *** PURGED ***' );
[417] Fix | Delete
[418] Fix | Delete
/**
[419] Fix | Delete
* Fire an action after deleting file from cache.
[420] Fix | Delete
*
[421] Fix | Delete
* @since 2.1.0
[422] Fix | Delete
*
[423] Fix | Delete
* @param string $url URL to be purged.
[424] Fix | Delete
* @param string $cached_file Cached file name.
[425] Fix | Delete
*/
[426] Fix | Delete
do_action( 'rt_nginx_helper_purged_file', $url, $cached_file );
[427] Fix | Delete
} else {
[428] Fix | Delete
$this->log( '- - An error occurred deleting the cache file. Check the server logs for a PHP warning.', 'ERROR' );
[429] Fix | Delete
}
[430] Fix | Delete
[431] Fix | Delete
}
[432] Fix | Delete
[433] Fix | Delete
/**
[434] Fix | Delete
* Remote get data from url.
[435] Fix | Delete
*
[436] Fix | Delete
* @param string $url URL to do remote request.
[437] Fix | Delete
*/
[438] Fix | Delete
protected function do_remote_get( $url ) {
[439] Fix | Delete
/**
[440] Fix | Delete
* Filters the URL to be purged.
[441] Fix | Delete
*
[442] Fix | Delete
* @since 2.1.0
[443] Fix | Delete
*
[444] Fix | Delete
* @param string $url URL to be purged.
[445] Fix | Delete
*/
[446] Fix | Delete
$url = apply_filters( 'rt_nginx_helper_remote_purge_url', $url );
[447] Fix | Delete
[448] Fix | Delete
/**
[449] Fix | Delete
* Fire an action before purging URL.
[450] Fix | Delete
*
[451] Fix | Delete
* @since 2.1.0
[452] Fix | Delete
*
[453] Fix | Delete
* @param string $url URL to be purged.
[454] Fix | Delete
*/
[455] Fix | Delete
do_action( 'rt_nginx_helper_before_remote_purge_url', $url );
[456] Fix | Delete
[457] Fix | Delete
$response = wp_remote_get( $url );
[458] Fix | Delete
[459] Fix | Delete
if ( is_wp_error( $response ) ) {
[460] Fix | Delete
[461] Fix | Delete
$_errors_str = implode( ' - ', $response->get_error_messages() );
[462] Fix | Delete
$this->log( 'Error while purging URL. ' . $_errors_str, 'ERROR' );
[463] Fix | Delete
[464] Fix | Delete
} else {
[465] Fix | Delete
[466] Fix | Delete
if ( $response['response']['code'] ) {
[467] Fix | Delete
[468] Fix | Delete
switch ( $response['response']['code'] ) {
[469] Fix | Delete
[470] Fix | Delete
case 200:
[471] Fix | Delete
$this->log( '- - ' . $url . ' *** PURGED ***' );
[472] Fix | Delete
break;
[473] Fix | Delete
case 404:
[474] Fix | Delete
$this->log( '- - ' . $url . ' is currently not cached' );
[475] Fix | Delete
break;
[476] Fix | Delete
default:
[477] Fix | Delete
$this->log( '- - ' . $url . ' not found ( ' . $response['response']['code'] . ' )', 'WARNING' );
[478] Fix | Delete
[479] Fix | Delete
}
[480] Fix | Delete
}
[481] Fix | Delete
[482] Fix | Delete
/**
[483] Fix | Delete
* Fire an action after remote purge request.
[484] Fix | Delete
*
[485] Fix | Delete
* @since 2.1.0
[486] Fix | Delete
*
[487] Fix | Delete
* @param string $url URL to be purged.
[488] Fix | Delete
* @param array $response Array of results including HTTP headers.
[489] Fix | Delete
*/
[490] Fix | Delete
do_action( 'rt_nginx_helper_after_remote_purge_url', $url, $response );
[491] Fix | Delete
}
[492] Fix | Delete
[493] Fix | Delete
}
[494] Fix | Delete
[495] Fix | Delete
/**
[496] Fix | Delete
* Check http connection.
[497] Fix | Delete
*
[498] Fix | Delete
* @return string
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function