[wp-trac] [WordPress Trac] #11006: Theme Preview on Admin Page
WordPress Trac
wp-trac at lists.automattic.com
Thu Oct 22 19:52:33 UTC 2009
#11006: Theme Preview on Admin Page
----------------------------+-----------------------------------------------
Reporter: AntonShevchuk | Owner:
Type: enhancement | Status: new
Priority: low | Milestone: 2.9
Component: Administration | Version: 2.8.4
Severity: normal | Keywords:
----------------------------+-----------------------------------------------
I have trouble with my theme Constructor - I write following code for
register stylesheet generated by PHP:
{{{
wp_enqueue_style( 'constructor-custom-style', get_option('home').'/?theme-
constructor=css');
}}}
But this is code doesn't work with theme preview, because correct url for
preview is '/?theme-constructor=css&preview=1&template=constructor'
I found simple solution, but this is requried changes of Wordpress source
code in file wp-includes/theme.php:
{{{
function preview_theme_ob_filter( $content ) {
// apply new filter
$content = apply_filters('preview_theme_ob_filter', $content); // add
filter for preview content
return preg_replace_callback( "|(<a.*?href=([\"']))(.*?)([\"'].*?>)|",
'preview_theme_ob_filter_callback', $content );
}
}}}
I can use this is filter in my function.php:
{{{
function constructor_preview($content) {
$link = add_query_arg(array('preview' => 1, 'template' =>
get_template()), '?theme-constructor=css');
$content = str_replace('?theme-constructor=css', $link, $content);
return $content;
}
add_filter('preview_theme_ob_filter', 'constructor_preview');
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/11006>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list