Skip to content

Instantly share code, notes, and snippets.

@Zodiac1978
Created November 5, 2020 14:35
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 Zodiac1978/2b9fe8e1ec9c1cabb5d04e9c639c911c to your computer and use it in GitHub Desktop.
Save Zodiac1978/2b9fe8e1ec9c1cabb5d04e9c639c911c to your computer and use it in GitHub Desktop.
Add Divi markup to fix restrict content.
<?php
/**
* Add Divi markup to fix restrict content.
*/
function divi_compatibility( $content ) {
global $post, $current_user;
$hasaccess = pmpro_has_membership_access( null, null, true );
if ( is_array( $hasaccess ) ) {
// returned an array to give us the membership level values.
$post_membership_levels_ids = $hasaccess[1];
$post_membership_levels_names = $hasaccess[2];
$hasaccess = $hasaccess[0];
}
if ( $hasaccess ) {
// all good, return content.
return $content;
} else {
$output = '';
$output .= '<div class="et_pb_section et_pb_section_0 et_section_regular">';
$output .= '<div class="et_pb_row et_pb_row_0">';
$output .= '<div class="et_pb_column et_pb_column_4_4 et_pb_column_0 et_pb_css_mix_blend_mode_passthrough et-last-child">';
$output .= '<div class="et_pb_module et_pb_text et_pb_text_0 et_pb_text_align_left et_pb_bg_layout_light">';
$output .= '<div class="et_pb_text_inner">';
$output .= $content;
$output .= '</div> <!-- /text -->';
$output .= '</div> <!-- /module -->';
$output .= '</div> <!-- /column -->';
$output .= '</div> <!-- /row -->';
$output .= '</div> <!-- /section -->';
return $output;
}
}
add_filter( 'the_content', 'divi_compatibility' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment