Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #36637, comment 10


Ignore:
Timestamp:
04/27/2016 04:54:21 AM (9 years ago)
Author:
askapache
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #36637, comment 10

    initial v1  
    1111
    1212All in all, I like the idea, and it works fine for me, and the js code for this is very well-written!  It's just a major headache to have to respond to all these backend editors that there is nothing I can do to help them with this.
     13
     14
     15The only thing I have been able to do is add a filter to replace links to _wp_link_placeholder with links to the siteurl, and I added an error_log statement so that I am manually finding posts with this error, and then contacting editors individually notifying them they need to fix and learn this new way of doing it :(
     16
     17Here's a simple fix for at least preventing these links from showing up publically.. haven't found a fix for the editors yet.
     18
     19
     20
     21{{{#!php
     22<?php
     23function askapache_filter_link_placeholder( $content ) {
     24        if ( isset( $content[10] ) && strpos( $content, '_wp_link_placeholder' ) !== false ) {
     25                // remove links to /_wp_link_placeholder by replacing them with WP_SITEURL
     26                return preg_replace( '#_wp_link_placeholder#', WP_SITEURL, $content );
     27        }
     28        return $content;
     29}
     30add_filter( 'the_content', 'askapache_filter_link_placeholder' );
     31add_filter( 'the_content_feed', 'askapache_filter_link_placeholder' );
     32add_filter( 'get_the_content', 'askapache_filter_link_placeholder' );
     33add_filter( 'the_excerpt', 'askapache_filter_link_placeholder' );
     34add_filter( 'content_save_pre', 'askapache_filter_link_placeholder' );
     35add_filter( 'excerpt_save_pre', 'askapache_filter_link_placeholder' );
     36}}}
     37
     38
     39And then in `robots.txt`
     40
     41{{{
     42Disallow: /_wp_link_placeholder
     43}}}