selectAd($name); if (!empty($ad)) { echo $ad->display(); } die(0); } // An ad is being requested by its id if (!empty($_REQUEST['advman-ad-id'])) { $id = OX_Tools::sanitize($_REQUEST['advman-ad-id'], 'number'); $ad = $advman_engine->getAd($id); if (!empty($ad)) { echo $ad->display(); } die(0); } // Add a filter for displaying an ad in the content add_filter('the_content', 'advman_filter_content'); // Widgets are initialised add_action('widgets_init', array('Advman_Widget', 'init'), 1); // Add an action when the wordpress footer displays add_action('wp_footer', 'advman_footer'); // If admin, initialise the Admin functionality if (is_admin()) { add_action('admin_menu', array('Advman_Admin','init')); } } /* This filter parses post content and replaces markup with the correct ad, for named ad or for default */ function advman_filter_content($content) { $patterns = array( '//', '//', '//', '//', '/\[ad\]/', '/\[ad#(.*?)\]/', ); return preg_replace_callback($patterns, 'advman_filter_content_callback', $content); } function advman_filter_content_callback($matches) { global $advman_engine; $ad = $advman_engine->selectAd($matches[1]); if (!empty($ad)) { return $ad->display(); } return ''; } // Backwards compatibility with adsense-manager if (!function_exists('adsensem_ad')) { function adsensem_ad($name = false) { return advman_ad($name); } } function advman_ad($name = false) { global $advman_engine; $ad = $advman_engine->selectAd($name); if (!empty($ad)) { echo $ad->display(); } } /** * Called when the Wordpress footer displays, and adds a comment in the HTML for debugging purposes */ function advman_footer() { ?>