Skip to content

Instantly share code, notes, and snippets.

@Slaver
Last active November 13, 2019 15:48
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Slaver/0e0c7c952caf0d309b4e to your computer and use it in GitHub Desktop.
Save Slaver/0e0c7c952caf0d309b4e to your computer and use it in GitHub Desktop.
How to use WP Super Cache and AdRotate
<?php
/**
* Custom banner handler for cache
*/
add_action('init', 'adrotate_request_handler');
function adrotate_request_handler() {
if ( isset($_GET['adrotate_action']) && $_GET['adrotate_action'] == 'show' ) {
// You can use adrotate_group or adrotate_ad
// First param — ad group ID
echo adrotate_group(1, 0, 0, 0);
exit();
}
}
/**
* Custom theme functions file.
*
* Contains handlers for social sharing
*/
( function( $ ) {
$( document ).ready( function() {
$.ajax({
type: 'GET',
url: '/index.php',
data: { adrotate_action: 'show' },
success: function(response) {
$('#adrotate_div').html(response);
}
});
} );
} )( jQuery );
<?php
/**
* Add custom div to text widget
*/
?>
<div id="adrotate_div"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment