Last active
August 17, 2016 02:40
-
-
Save lenivene/1a4eaf2b182694ef60e0cd74fd6fd2dc to your computer and use it in GitHub Desktop.
Insert variable script ajax url
This file contains hidden or 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
<?php | |
add_action( 'wp_head', 'wp_set_ajaxurl' ); | |
function wp_set_ajaxurl() { | |
$html = '<script>'; | |
$html .= 'var ajaxurl = "' . esc_url( self_admin_url( 'admin-ajax.php' ) ) . '";'; | |
$html .= '</script>' . PHP_EOL; | |
echo $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment