Skip to content

Instantly share code, notes, and snippets.

@MaryOJob
Forked from ipokkel/no-oembed-pmpromd-pages.php
Created November 9, 2022 11:42
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 MaryOJob/7b0fd40bfc1f097efe5c9ec7be93fa21 to your computer and use it in GitHub Desktop.
Save MaryOJob/7b0fd40bfc1f097efe5c9ec7be93fa21 to your computer and use it in GitHub Desktop.
Prevent oembeds from running on the PMPro Member Directory Add On pages.
<?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