Last active
May 20, 2020 01:27
-
-
Save gaupoit/65c2bb3caf8471d1dde5e2dcb3720f6d to your computer and use it in GitHub Desktop.
Integrate PPWP with Pro Photo 7 theme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'plugin_loaded', 'add_prophoto_middleware' ); | |
function add_prophoto_middleware() { | |
add_action('pp_render_content', 'ppw_check_password_protection' ); | |
add_action('wp', 'ppw_prevent_caching' ); | |
} | |
function ppw_prevent_caching() { | |
global $post; | |
if ( ! $post ) { | |
return; | |
} | |
if ( ! class_exists( 'PPW_Password_Services' ) ) { | |
return; | |
} | |
$ppwp_password_services = new PPW_Password_Services(); | |
if ( ! $ppwp_password_services->is_protected_content( $post->ID ) ) { | |
return; | |
} | |
$is_using_noindex = call_user_func( 'ppw_core_get_setting_type_bool', 'ppwp_remove_search_engine' ); | |
if ( $is_using_noindex ) { | |
wp_no_robots(); | |
} | |
defined( 'DONOTCACHEPAGE' ) || define( 'DONOTCACHEPAGE', true ); | |
if ( ! headers_sent() ) { | |
header( 'Cache-Control: private' ); | |
} | |
} | |
function ppw_check_password_protection() { | |
if ( ! post_password_required() ) { | |
return; | |
} | |
$form = get_the_password_form(); | |
echo $form; | |
do_action( 'get_footer' ); | |
exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment