Display a pop-up notice to ask your visitors to disable their AdBlocker add-on. Also detects if scripting is active.

'; echo '
'; echo '

Important:
' .'This currently only detects some google ads. If you have ads on your site but the pop-up notice is not appearing; You will need to add the CSS class \' .adbuddy-protected \' to your ad container(s).

'; echo '
'; } function adbuddy_force() { $options = get_option('adbuddy_options'); echo '

Make this mandatory to view your website.
(Setting this to \'No\' allows visitors to close the pop-up notice without disabling AdBlocker. The pop-up will persist from page to page)

'; echo '    '; echo '
'; } function adbuddy_title() { $options = get_option('adbuddy_options'); echo ''; } function adbuddy_message() { $options = get_option('adbuddy_options'); echo ''; } function adbuddy_button() { $options = get_option('adbuddy_options'); echo ''; } function adbuddy_img_preview() { $options = get_option( 'adbuddy_options' ); ?>

id ) { wp_enqueue_script('jquery'); wp_enqueue_script('thickbox'); wp_enqueue_style('thickbox'); wp_enqueue_script('media-upload'); wp_enqueue_script('adbuddy-upload'); } } add_action('admin_enqueue_scripts', 'adbuddy_enqueue_scripts'); /* hack-in image select button title */ function adbuddy_options_setup() { global $pagenow; if ( 'media-upload.php' == $pagenow || 'async-upload.php' == $pagenow ) { // Now we'll replace the 'Insert into Post Button' inside Thickbox add_filter( 'gettext', 'replace_thickbox_text' , 1, 3 ); } } add_action( 'admin_init', 'adbuddy_options_setup' ); function replace_thickbox_text($translated_text, $text, $domain) { if ('Insert into Post' == $text) { $referer = strpos( wp_get_referer(), 'adbuddy' ); if ( $referer != '' ) { return __('Use this image', 'adbuddy' ); } } return $translated_text; } /* remove custom display image ( reverts to default ) */ function adbuddy_delete_image( $image_url ) { global $wpdb; // We need to get the image's meta ID. $query = "SELECT ID FROM wp_posts where guid = '" . esc_url($image_url) . "' AND post_type = 'attachment'"; $results = $wpdb->get_results($query); // And delete it foreach ( $results as $row ) { wp_delete_attachment( $row->ID ); } } /* addBuddy Options Validate */ function adbuddy_options_validate($input) { $options['title'] = (!empty($input['title']) ? trim($input['title']) : ADBUDDY_TITLE ); $options['message'] = (!empty($input['message']) ? trim($input['message']) : ADBUDDY_MSG ); $options['button'] = (!empty($input['button']) ? trim($input['button']) : ADBUDDY_BUTTON ); $options['display_img'] = (!empty($input['display_img']) ? trim($input['display_img']) : ADBUDDY_IMG); $options['force'] = (isset($input['force']) ? $input['force'] : 1); $delete_logo = ! empty($input['delete_logo']) ? true : false; if ( $delete_logo ) { adbuddy_delete_image( $input['display_img'] ); $options['display_img'] = ADBUDDY_IMG; } return $options; } /* addBuddy Options Page */ function adbuddy_options_page() { if ( !current_user_can( 'manage_options' ) ) { wp_die( __( ADBUDDY_SECURED ) ); } echo '
'; echo '

adBuddy+ (AdBlocker Detection)

'; echo '
'; settings_fields( 'adbuddy_options' ); do_settings_sections( 'adbuddy' ); echo '
'; submit_button(); echo '
'; echo '
'; /* Debug */ //$options = get_option( 'adbuddy_options' ); //echo '
';
	  //echo '
debug
'; //print_r ($options); //echo '
'; } /* adBuddy JS added to Wordpress page footer */ if (!function_exists( 'netfunk_adbuddy')){ function netfunk_adbuddy_script() { if ( !is_admin() ) { $options = get_option( 'adbuddy_options' ); $jQeury = "jQuery"; // the jquery variable ( incase you are using older Foundation or another framework. The default setting would be '$' ) $title = (isset($options['title']) ? $options['title'] : ADBUDDY_TITLE); $message = (isset($options['message']) ? $options['message'] : ADBUDDY_MSG); $button = (isset($options['button']) ? $options['button'] : ADBUDDY_BUTTON); echo "'; } } } add_action( 'wp_footer', 'netfunk_adbuddy_script'); /* adBuddy NoScript added to page footer */ if (!function_exists( 'netfunk_adbuddy')){ function netfunk_adbuddy() { if ( !is_admin() ) { echo ""; } } } add_action( 'wp_footer', 'netfunk_adbuddy'); // EOF