Documentation

Preserve post content while using Replacements

Posted in: Getting Started (3) Plugin Options Explained (32) Actions / Filters (25) How To (11)      Code Example (10)  

This functionality is available for PRO version.

The Replacements feature is a powerful tool, it allows any of specific traces ( classes, IDs, JavaScript variables ) to be changed easily and make the code unrecognizable.

The Replacement functionality filter all HTML code, CSS and JavaScript assets, before they are sent back to the user’s browser. This strips out the required word and replaces it with a different one. The process is a complex operation as it required to be done unitary across all site assets. The WP Hide engine successfully does that while maintaining the perfect functionality and layout, just like default.

There are cases when a blog post contains a word ( or multiple words ) that is required to stay as is and not be replaced through the Replacement functionality. The replacement functionality is intended to operate across all site resources. This can be achieved using a custom code, which makes the Replacements module acknowledged where the actual post content starts and keep it as is.



    add_filter('the_content', '__the_content_start', -999 );
    add_filter('the_content', '__the_content_end', 999 );

    function __the_content_start( $content )
        {
            $content = '<!-- WPH Preserve - Start -->' . $content;      
            
            return $content;
        }
        
    function __the_content_end( $content )
        {
            $content .= '<!-- WPH Preserve - Stop -->';      
            
            return $content;
        }
        
        
    add_filter('the_title', '__the_title_start', -999 );
    add_filter('the_title', '__the_title_end', 999 );

    function __the_title_start( $content )
        {
            $content = '<!-- WPH Preserve - Start -->' . $content;      
            
            return $content;
        }
        
    function __the_title_end( $content )
        {
            $content .= '<!-- WPH Preserve - Stop -->';      
            
            return $content;
        }

The above code should be placed within a file inside your /wp-cotnent/mu-plugins/ folder

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Scroll to top