Created
November 5, 2020 14:35
-
-
Save Zodiac1978/2b9fe8e1ec9c1cabb5d04e9c639c911c to your computer and use it in GitHub Desktop.
Add Divi markup to fix restrict content.
This file contains 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 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