-
-
Save MaryOJob/7b0fd40bfc1f097efe5c9ec7be93fa21 to your computer and use it in GitHub Desktop.
Prevent oembeds from running on the PMPro Member Directory Add On pages.
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 | |
/** | |
* Prevent oembeds from running on the PMPro Member Directory Add On pages. | |
* | |
* This may be helpful if any external or social URLs are listed on the directory | |
* or profile page. | |
* | |
* Can clear oembed cache with steps here: https://siteorigin.com/clearing-oembed-cache/ | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function prevent_oembed_pmpro_directory_profile_page( $result, $url, $args ) { | |
global $pmpro_pages; | |
if ( is_page( $pmpro_pages['profile'] ) || is_page( $pmpro_pages['directory'] ) ) { | |
$clickable = make_clickable( $url ); | |
$result = str_ireplace( '<a href=', '<a target="_blank" href=', $clickable ); | |
} | |
return $result; | |
} | |
add_filter( 'pre_oembed_result', 'prevent_oembed_pmpro_directory_profile_page', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment