Last active
November 13, 2019 15:48
-
-
Save Slaver/0e0c7c952caf0d309b4e to your computer and use it in GitHub Desktop.
How to use WP Super Cache and AdRotate
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
<?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(); | |
} | |
} |
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
/** | |
* 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 ); |
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
<?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