Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save n7studios/81806c091894553c7b99479f97da4f38 to your computer and use it in GitHub Desktop.
Save n7studios/81806c091894553c7b99479f97da4f38 to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: WP to Buffer Pro: Remove URLs from Content and Excerpt Tags
* Plugin URI: http://www.wpzinc.com/
* Version: 0.0.1
* Author: WP Zinc
* Author URI: http://www.wpzinc.com
* Description: Remove URLs from Content and Excerpt Tags.
*/
add_filter( 'wp_to_buffer_pro_publish_get_excerpt', function( $excerpt, $post ) {
return preg_replace( '/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', '', $excerpt );
}, 10, 2 );
add_filter( 'wp_to_buffer_pro_publish_get_content', function( $content, $post, $is_gutenberg_post_content ) {
return preg_replace( '/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', '', $content );
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment