/** * Setup the singleton. * * @access public */ public function setup() { // Register the ad server settings page add_action('init', array($this, 'add_settings_page')); // Add the required header and footer setup. May differ for each server. add_action('wp_head', array($this, 'header_setup')); add_action('wp_footer', array($this, 'footer_setup')); // Handle rendering units add_action('ad_layers_render_ad_unit', array($this, 'get_ad_unit')); // Load the Javascript API early add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5); // Load current settings self::$settings = apply_filters('ad_layers_ad_server_settings', get_option($this->option_name, array())); // Allow additional ad servers to be loaded via filter within a theme $this->ad_servers = apply_filters('ad_layers_ad_servers', array('Ad_Layers_DFP' => AD_LAYERS_BASE_DIR . '/php/ad-servers/class-ad-layers-dfp.php')); // Load ad server classes if (!empty($this->ad_servers) && is_array($this->ad_servers)) { foreach ($this->ad_servers as $ad_server) { if (file_exists($ad_server)) { require_once $ad_server; } } } // Set the current ad server class, if defined. if (!empty(self::$settings['ad_server']) && class_exists(self::$settings['ad_server'])) { $ad_server = new self::$settings['ad_server'](); $this->ad_server = $ad_server::instance(); } }
/** * Setup the singleton. * * @access public */ public function setup() { /** * Filter the capability required to manage the ad server settings. * * @param string $capability. Defaults to `manage_options`. */ $this->settings_capability = apply_filters('ad_layers_settings_capability', 'manage_options'); // Register the settings page if (function_exists('fm_register_submenu_page') && current_user_can($this->settings_capability)) { fm_register_submenu_page($this->option_name, Ad_Layers::instance()->get_edit_link(), __('Ad Server Settings', 'ad-layers'), null, $this->settings_capability); } // Hook the ad layer settings page onto Fieldmanager's action. add_action('fm_submenu_' . $this->option_name, array($this, 'add_settings_page')); // Add the required header and footer setup. May differ for each server. add_action('wp_head', array($this, 'header_setup')); add_action('wp_footer', array($this, 'footer_setup')); // Handle rendering units add_action('ad_layers_render_ad_unit', array($this, 'get_ad_unit')); // Load the Javascript API early add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5); // Load current settings self::$settings = apply_filters('ad_layers_ad_server_settings', get_option($this->option_name, array())); // Allow additional ad servers to be loaded via filter within a theme $this->ad_servers = apply_filters('ad_layers_ad_servers', array('Ad_Layers_DFP' => AD_LAYERS_BASE_DIR . '/php/ad-servers/class-ad-layers-dfp.php')); // Load ad server classes if (!empty($this->ad_servers) && is_array($this->ad_servers)) { foreach ($this->ad_servers as $ad_server) { if (file_exists($ad_server)) { require_once $ad_server; } } } // Set the current ad server class, if defined. if (!empty(self::$settings['ad_server']) && class_exists(self::$settings['ad_server'])) { $ad_server = new self::$settings['ad_server'](); $this->ad_server = $ad_server::instance(); } }