. */ class AntiAdBlock { var $name = 'anti_adblock'; var $homepage = 'http://omninoggin.com/projects/wordpress-plugins/anti-adblock-wordpress-plugin/'; var $displayed = false; function get_default_options() { return array( 'can_close' => true, 'hide_content' => false, 'image' => $this->get_plugin_url() . '/images/disable_adblock.png', 'message' => __('
We noticed that you\'ve been here ###visit_count### times. We are glad that you find our content useful, but we are also sad that you are blocking advertisements on this site.
Without advertisement revenue we will not be able to continue to provide quality content. If you enjoy our content, please consider supporting us by any of the following ways:
%s
%s%s%s
', __('Click here to close', $this->name), __('You will no longer receive this message after ', $this->name), $aab_options['max_nag'], __(' visit(s) (cookies required).', $this->name) ); } else $close_html = ''; if ( $aab_options['use_message_bar'] ) { $use_message_bar_html = "true"; } else { $use_message_bar_html = "false"; } if ( $aab_options['show_link'] ) $link_html = sprintf('
', $this->homepage, __('Powered by Anti-AdBlock', $this->name), __('Powered by Anti-AdBlock', $this->name) ); else $link_html = ''; // generate JS printf(' ', $expire_days, $expire_days, ($aab_options['visits_till_nag']) ? $aab_options['visits_till_nag'] : 0, ($aab_options['visits_till_nag']) ? $aab_options['visits_till_nag'] : 0, ($aab_options['max_nag']) ? $aab_options['max_nag'] : 0, $aab_options['nonce_banner'], $aab_options['nonce_banner'], $aab_options['nonce_message'], $image_html, str_replace('"', '\"', $aab_options['message']), $close_html, $link_html, $use_message_bar_html, $aab_options['nonce_message_bar'], str_replace('"', '\\"', $aab_options['message_bar']), $aab_options['nonce_message'], $aab_options['nonce_message_bar'], $aab_options['nonce_message_bar'], $aab_options['nonce_message'], $aab_options['nonce_message'] ); } function load_styles() { $style= $this->get_plugin_url().'/css/style.css'; wp_register_style($this->name.'_style', $style); wp_enqueue_style($this->name.'_style'); } function update_options() { // new options $aab_new_options = stripslashes_deep($_POST['aab_options_update']); // current options $aab_current_options = get_option($this->name); // convert "on" to true and "off" to false for checkbox fields // and set defaults for fields that are left blank if ( isset($aab_new_options['can_close']) ) $aab_new_options['can_close'] = true; else $aab_new_options['can_close'] = false; if ( isset($aab_new_options['hide_content']) ) $aab_new_options['hide_content'] = true; else $aab_new_options['hide_content'] = false; if ( isset($aab_new_options['show_link']) && $aab_new_options['show_link'] == "on") $aab_new_options['show_link'] = true; else $aab_new_options['show_link'] = false; if ( isset($aab_new_options['use_message_bar']) && isset($aab_new_options['use_message_bar']) == "on") $aab_new_options['use_message_bar'] = true; else $aab_new_options['use_message_bar'] = false; // set defaults if some fields that are left blank or invalid if ( !is_numeric($aab_new_options['max_nag']) ) $aab_new_options['max_nag'] = $aab_current_options['max_nag']; elseif ( !$aab_new_options['max_nag'] || (int)$aab_new_options['max_nag'] < 0 ) $aab_new_options['max_nag'] = 0; else { $aab_new_options['max_nag'] = (int)$aab_new_options['max_nag']; } if ( !is_numeric($aab_new_options['visits_till_nag']) ) $aab_new_options['visits_till_nag'] = $aab_current_options['visits_till_nag']; elseif ( !$aab_new_options['visits_till_nag'] || (int)$aab_new_options['visits_till_nag'] < 0 ) $aab_new_options['visits_till_nag'] = 0; else { $aab_new_options['visits_till_nag'] = (int)$aab_new_options['visits_till_nag']; } // Update options foreach($aab_new_options as $key => $value) { $aab_current_options[$key] = $value; } update_option($this->name, $aab_current_options); } function upgrade_options() { $aab_options = get_option($this->name); if ( !$aab_options ) { add_option($this->name, $this->get_default_options()); } else { $default_options = $this->get_default_options(); foreach($default_options as $option_name => $option_value) { if(!isset($aab_options[$option_name])) { $aab_options[$option_name] = $option_value; } } update_option($this->name, $aab_options); } } function reset_options() { if ( !get_option($this->name) ) { add_option($this->name, $this->get_default_options()); } else { update_option($this->name, $this->get_default_options()); } } function get_name() { return $this->name; } function get_plugin_dir() { // Pre-2.6 compatibility if ( !defined('WP_CONTENT_DIR') ) define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); return WP_CONTENT_DIR.'/plugins/'.plugin_basename(dirname(__FILE__)); } function get_plugin_url() { // Pre-2.6 compatibility if ( !defined('WP_CONTENT_URL') ) define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); return WP_CONTENT_URL.'/plugins/'.plugin_basename(dirname(__FILE__)); } function get_current_page_url() { $isHTTPS = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on"); $port = (isset($_SERVER["SERVER_PORT"]) && ((!$isHTTPS && $_SERVER["SERVER_PORT"] != "80") || ($isHTTPS && $_SERVER["SERVER_PORT"] != "443"))); $port = ($port) ? ':'.$_SERVER["SERVER_PORT"] : ''; $url = ($isHTTPS ? 'https://' : 'http://').$_SERVER["SERVER_NAME"].$port.$_SERVER["REQUEST_URI"]; return $url; } function admin_menu() { add_options_page('Anti-AdBlock', 'Anti-AdBlock', 'manage_options', 'anti-adblock', array($this, 'admin_page')); } function admin_page() { // load text domain for translations load_plugin_textdomain($this->name); if ( isset($_POST['aab_options_update_submit']) ) { // if user wants to update options check_admin_referer($this->name); $this->update_options(); printf('%s
%s
%s