Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WPML Support + Change in Purge ALL with Redis. #116

Merged
merged 3 commits into from
Jun 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions purger.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ function purgePost( $_ID ) {
$this->log( "Function purgePost BEGIN ===" );

if ( $rt_wp_nginx_helper->options[ 'purge_homepage_on_edit' ] == 1 ) {
$homepage_url = trailingslashit( home_url() );

$this->log( "Purging homepage '$homepage_url'" );
$this->purgeUrl( $homepage_url );
$this->_purge_homepage();
}


Expand Down Expand Up @@ -435,10 +432,18 @@ function purge_on_post_moved_to_trash( $new_status, $old_status, $post ) {
}

private function _purge_homepage() {
// WPML installetd?
if ( function_exists('icl_get_home_url') )
{
$homepage_url = trailingslashit( icl_get_home_url() );
$this->log( sprintf( __( "Purging homepage (WPML) '%s'", "nginx-helper" ), $homepage_url ) );
}
else
{
$homepage_url = trailingslashit( home_url() );
$this->log( sprintf( __( "Purging homepage '%s'", "nginx-helper" ), $homepage_url ) );
}

$homepage_url = trailingslashit( home_url() );

$this->log( sprintf( __( "Purging homepage '%s'", "nginx-helper" ), $homepage_url ) );
$this->purgeUrl( $homepage_url );

return true;
Expand Down
21 changes: 14 additions & 7 deletions redis-purger.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,8 @@ function purgePost( $_ID )
$this->log( "Function purgePost BEGIN ===" );

if ( $rt_wp_nginx_helper->options['purge_homepage_on_edit'] == 1 ) {
$homepage_url = trailingslashit( home_url() );

$this->log( "Purging homepage '$homepage_url'" );
$this->purgeUrl( $homepage_url );
$this->_purge_homepage();
}


Expand Down Expand Up @@ -329,10 +327,18 @@ function purge_on_post_moved_to_trash( $new_status, $old_status, $post )

private function _purge_homepage()
{
// WPML installetd?
if ( function_exists('icl_get_home_url') )
{
$homepage_url = trailingslashit( icl_get_home_url() );
$this->log( sprintf( __( "Purging homepage (WPML) '%s'", "nginx-helper" ), $homepage_url ) );
}
else
{
$homepage_url = trailingslashit( home_url() );
$this->log( sprintf( __( "Purging homepage '%s'", "nginx-helper" ), $homepage_url ) );
}

$homepage_url = trailingslashit( home_url() );

$this->log( sprintf( __( "Purging homepage '%s'", "nginx-helper" ), $homepage_url ) );
$this->purgeUrl( $homepage_url );

return true;
Expand Down Expand Up @@ -661,11 +667,12 @@ function purge_on_check_ajax_referer( $action, $result )
function true_purge_all()
{
global $rt_wp_nginx_helper;
$prefix = substr($rt_wp_nginx_helper->options['redis_prefix'],0, -1);
$this->log( "* * * * *" );
$this->log( "* Purged Everything!" );
$this->log( "* * * * *" );
//delete_multi_keys("*");
delete_keys_by_wildcard("*");
delete_keys_by_wildcard($prefix."*");
}

function purge_urls()
Expand Down