static function init() { global $advman_engine, $advman_list; $advman_list = new Advman_Template_Table_List(); //Detect when a bulk action is being triggered... $action = OX_Tools::sanitize_request_var('action'); // Perform actions if ($action) { $ads = Advman_Tools::get_current_ads(); if ($ads) { if (count($ads) == 1) { // If there is a single ad selected, then perform the action on that ad. Notice messages and workflow are different in this case foreach ($ads as $ad) { Advman_Admin::ad_action($action, $ad); } } else { // These are bulk actions switch ($action) { case 'copy': foreach ($ads as $ad) { if ($ad) { $advman_engine->copyAd($ad->id); } } Advman_Admin::add_notice('advman-notice-once', __("Ads copied"), false); break; case 'delete': foreach ($ads as $ad) { if ($ad) { $advman_engine->deleteAd($ad->id); } } Advman_Admin::add_notice('advman-notice-once', __("Ads deleted"), false); break; } } } else { $ad = Advman_Tools::get_current_ad(); if ($ad) { Advman_Admin::ad_action($action, $ad); } } $url = remove_query_arg(array('action', 'ad', 'network', '_wpnonce')); wp_redirect($url); } }
static function advman_3_5_1(&$data) { // Check to see if we need to migrate any old ad tags to new ad tags global $advman_engine; $patterns = array('/<!--adsense-->/', '/<!--adsense-->/', '/<!--adsense#(.*?)-->/', '/<!--adsense#(.*?)-->/', '/<!--am-->/', '/<!--am-->/', '/<!--am#(.*?)-->/', '/<!--am#(.*?)-->/', '/\\[ad#(.*?)\\]/'); $found_posts = 0; $found_ads = 0; $offset = 0; $numberposts = 10; $args = array('numberposts' => $numberposts, 'offset' => $offset, 'post_type' => array('post', 'page'), 'suppress_filters' => false); $posts = get_posts($args); while ($posts) { foreach ($posts as $post) { $ad_found_in_post = false; if (!empty($post->post_content)) { foreach ($patterns as $pattern) { if (preg_match_all($pattern, $post->post_content, $matches)) { if (!empty($matches[1])) { for ($i = 0; $i < sizeof($matches[1]); $i++) { $name = $matches[1][$i]; $ad = Advman_Upgrade::_selectAd($data, $name); if (!$ad) { $name = html_entity_decode($name); $ad = Advman_Upgrade::_selectAd($data, $name); } if (!$ad) { $name = str_replace(";", "\\;", $name); $ad = Advman_Upgrade::_selectAd($data, $name); } if ($ad) { $found_ads++; if (!$ad_found_in_post) { $ad_found_in_post = true; $found_posts++; } } } } else { $found_ads++; if (!$ad_found_in_post) { $ad_found_in_post = true; $found_posts++; } } } } } } $offset += $numberposts; $args = array('numberposts' => $numberposts, 'offset' => $offset, 'post_type' => array('post', 'page'), 'suppress_filters' => false); $posts = get_posts($args); } if ($found_ads) { $question = __('You have [num_ads] Advertising Manager ads in [num_posts] posts that need to be upgraded to a new ad shortcode format. <b>Do you want to automatically upgrade these shortcodes?</b>', 'advman'); $question = str_replace('[num_ads]', $found_ads, $question); $question = str_replace('[num_posts]', $found_posts, $question); Advman_Admin::add_notice('update_shortcodes', $question, 'yn'); } }
static function activate() { // Add quality notice $notice = __('Would you like to enable ad quality measurement in <strong>Advertising Manager</strong>?', 'advman'); Advman_Admin::add_notice('adjs-beta', $notice, 'learn'); }
function upgrade_adsensem(&$data) { $version = Advman_Upgrade::_get_version($data); Advman_Upgrade::adsensem_upgrade_ad_classes($data); Advman_Upgrade::adsensem_upgrade_ad_ids($data); Advman_Upgrade::adsensem_upgrade_network_classes($data); Advman_Upgrade::adsensem_upgrade_ad_settings($data); Advman_Upgrade::adsensem_upgrade_network_settings($data); Advman_Upgrade::adsensem_upgrade_settings($data); $notice = __('<strong>Advertising Manager</strong> has been upgraded from your <strong>Adsense Manager</strong> settings.', 'advman'); // $question = __('Enable <a>auto optimisation</a>? (RECOMMENDED)', 'advman'); // $question = str_replace('<a>', '<a href="http://code.openx.org/wiki/advertising-manager/Auto_Optimization" target="_new">', $question); Advman_Admin::add_notice('optimise', $notice, 'ok'); // Set the new version $data['settings']['version'] = '3.3.19'; return Advman_Upgrade::upgrade_advman($data); }