Skip to content

Instantly share code, notes, and snippets.

@gaupoit
Last active May 20, 2020 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaupoit/65c2bb3caf8471d1dde5e2dcb3720f6d to your computer and use it in GitHub Desktop.
Save gaupoit/65c2bb3caf8471d1dde5e2dcb3720f6d to your computer and use it in GitHub Desktop.
Integrate PPWP with Pro Photo 7 theme
<?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