[wp-trac] [WordPress Trac] #37425: Passing variables withing the previewURL get lost on server side
WordPress Trac
noreply at wordpress.org
Wed Jul 20 18:52:45 UTC 2016
#37425: Passing variables withing the previewURL get lost on server side
--------------------------+-----------------------------
Reporter: virgodesign | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Customize | Version: 4.5.3
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
I'm experiencing the following problem and I don't know exactly if it's a
bug or a normal behavior.
I'm trying to pass a custom variable within the previewUrl using the
wp.customize javascript object as following:
{{{
wp.customize.previewer.previewUrl( 'http://www.example.com/?custom_var=1'
);
}}}
and then call the refresh method to launch the ajax request
{{{
wp.customize.previewer.refresh();
}}}
To customize the preview that will return back to the customizer we need
to perform a check as following:
{{{
function load_custom_template( $template ) {
if( is_customize_preview() && isset($_GET['custom_var']) ) {
$new_template = locate_template( array(
'custom_template.php' ) );
if ( '' != $new_template ) {
return $new_template ;
}
}
}
return $template;
}
add_filter( 'template_include', 'load_custom_template', 99 );
}}}
But when we try to retrieve the $_GET variable, this is missing.
The REQUEST_URI seems to have no get variables.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37425>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list