/** * Initialise menu items, notices, etc. */ static function init() { global $wp_version; add_object_page(__('Ads', 'advman'), __('Ads', 'advman'), 8, 'advman-list', array('Advman_List', 'process'), ADVMAN_URL . '/images/advman-menu-icon.svg'); $list_hook = add_submenu_page('advman-list', __('All Ads', 'advman'), __('All Ads', 'advman'), 8, 'advman-list', array('Advman_List', 'process')); $analytics_hook = add_submenu_page('advman-list', __('Analytics', 'advman'), __('Analytics', 'advman'), 8, 'advman-analytics', array('Advman_Analytics', 'process')); add_submenu_page('advman-list', __('Create New Ad', 'advman'), __('Create New', 'advman'), 8, 'advman-ad-new', array('Advman_Admin', 'create')); add_submenu_page(null, __('Edit Ad', 'advman'), __('Edit', 'advman'), 8, 'advman-ad', array('Advman_Admin', 'edit_ad')); add_submenu_page(null, __('Preview Ad', 'advman'), __('Preview', 'advman'), 8, 'advman-ad-preview', array('Advman_Admin', 'preview_ad')); add_submenu_page(null, __('Edit Network', 'advman'), __('Edit', 'advman'), 8, 'advman-network', array('Advman_Admin', 'edit_network')); add_options_page(__('Ads', 'advman'), __('Ads', 'advman'), 8, 'advman-settings', array('Advman_Admin', 'settings')); // List items if ($list_hook) { add_action("load-{$list_hook}", array('Advman_List', 'add_options')); add_action("admin_head-{$list_hook}", array('Advman_List', 'add_contextual_help')); add_action("admin_head-{$list_hook}", array('Advman_List', 'add_css')); } // Analytics items if ($analytics_hook) { add_action("load-{$analytics_hook}", array('Advman_Analytics', 'add_options')); add_action("admin_head-{$analytics_hook}", array('Advman_Analytics', 'add_contextual_help')); add_action("admin_head-{$analytics_hook}", array('Advman_Analytics', 'add_css')); } add_action('admin_enqueue_scripts', array('Advman_Admin', 'admin_enqueue_scripts')); // Display any notices that exist add_action('admin_notices', array('Advman_Admin', 'display_notices'), 1); // Add editor plugin to automatically insert an ad into a blog post add_action('admin_enqueue_scripts', array('Advman_Admin', 'add_editor_css')); add_action('before_wp_tiny_mce', array('Advman_Admin', 'tinymce_menu_script')); add_filter('mce_buttons', array('Advman_Admin', 'editor_button')); add_filter('mce_external_plugins', array('Advman_Admin', 'register_tinymce_javascript')); // Add 'settings' to the plugin activate page add_filter('plugin_action_links_advertising-manager/advertising-manager.php', array('Advman_Admin', 'plugin_action_links')); // Change footer text on Advertising Manager pages add_filter("admin_footer_text", array('Advman_Admin', 'admin_footer_text')); // Process any actions $action = OX_Tools::sanitize_post_var('advman-action'); $page = OX_Tools::sanitize_request_var('page'); // Check to see if the activate action is being fired Advman_Admin::notice_action($action); switch ($page) { case 'advman-ad-new': Advman_Admin::import_action($action); break; case 'advman-ad': Advman_Admin::ad_action($action); break; case 'advman-analytics': Advman_Analytics::init(); break; case 'advman-list': Advman_List::init(); break; case 'advman-network': Advman_Admin::network_action($action); break; } }
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); } }