Created
November 28, 2013 23:41
-
-
Save willybahuaud/7699576 to your computer and use it in GitHub Desktop.
Gist pour illustrer la redirection du template, si la requête est faite en ajax, sur l'article de BoiteAWeb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'template_include', 'baw_template_include' ); | |
function baw_template_include( $template ) { | |
if( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && $_SERVER['HTTP_X_REQUESTED_WITH']== 'BAWXMLHttpRequest' ): | |
$pre = dirname( $template ); | |
$suf = basename( $template ); | |
$_template = $pre . '/ajax-' . $suf; | |
if( !file_exists( $_template ) ) | |
$_template = $template; | |
$template = $_template; | |
endif; | |
return $template; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment