Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




preview_theme_ob_filter_callback [ WordPress Function ]

preview_theme_ob_filter_callback ( $matches )
Access:
  • private
Parameters:
  • (array) $matches
Returns:
  • (string)
Defined at:



Manipulates preview theme links in order to control and maintain location.

Callback function for preg_replace_callback() to accept and filter matches.

Source


<?php
function preview_theme_ob_filter_callback$matches ) {
    if ( 
strpos($matches[4], 'onclick') !== false )
        
$matches[4] = preg_replace('#onclick=([\'"]).*?(?<!\\\)\\1#i'''$matches[4]); //Strip out any onclicks from rest of <a>. (?<!\\\) means to ignore the '" if its escaped by \  to prevent breaking mid-attribute.
    
if (
        ( 
false !== strpos($matches[3], '/wp-admin/') )
    ||
        ( 
false !== strpos$matches[3], '://' ) && !== strpos$matches[3], home_url() ) )
    ||
        ( 
false !== strpos($matches[3], '/feed/') )
    ||
        ( 
false !== strpos($matches[3], '/trackback/') )
    )
        return 
$matches[1] . "#$matches[2] onclick=$matches[2]return false;" $matches[4];

    
$link add_query_arg( array( 'preview' => 1'template' => $_GET['template'], 'stylesheet' => @$_GET['stylesheet'], 'preview_iframe' => ), $matches[3] );
    if ( 
=== strpos($link'preview=1') )
        
$link "?$link";
    return 
$matches[1] . esc_attr$link ) . $matches[4];
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics