' . do_shortcode($content) . ''; } // Content displayed to all ad blocked users add_shortcode( 'adtoniq_message_adblocked', 'adtoniq_message_adblocked_shortcode' ); function adtoniq_message_adblocked_shortcode( $atts, $content = null ) { return ''; } // Content displayed to ad blocked users with acceptable ads disabled add_shortcode( 'adtoniq_message_adblocked_noacceptable', 'adtoniq_message_adblocked_noacceptable_shortcode' ); function adtoniq_message_adblocked_noacceptable_shortcode( $atts, $content = null ) { return ''; } // Content displayed to blocked users with acceptable ads enabled add_shortcode( 'adtoniq_message_adblocked_acceptable', 'adtoniq_message_adblocked_acceptable_shortcode' ); function adtoniq_message_adblocked_acceptable_shortcode( $atts, $content = null ) { return ''; } // Content displayed to all non-blocked users add_shortcode( 'adtoniq_message_nonblocked', 'adtoniq_message_nonblocked_shortcode' ); function adtoniq_message_nonblocked_shortcode( $atts, $content = null ) { return ''; } // Content displayed to users blocking analytics add_shortcode( 'adtoniq_message_blocked_analytics', 'adtoniq_message_blocked_analytics_shortcode' ); function adtoniq_message_blocked_analytics_shortcode( $atts, $content = null ) { return ''; } // Content displayed to users not blocking analytics add_shortcode( 'adtoniq_message_nonblocked_analytics', 'adtoniq_message_nonblocked_analytics_shortcode' ); function adtoniq_message_nonblocked_analytics_shortcode( $atts, $content = null ) { return ''; } add_shortcode('adtoniq_clear_choice', 'adtoniq_clear_choice_shortcode'); function adtoniq_clear_choice_shortcode($atts = [], $content = null, $tag = '') { // normalize attribute keys, lowercase $atts = array_change_key_case((array)$atts, CASE_LOWER); // override default attributes with user attributes $adtoniq_attrs = shortcode_atts([ 'style' => 'button', ], $atts, $tag); // Get style attribute $style = $adtoniq_attrs['style']; // start output $o = ''; $o .= ' '; switch ($style) { case 'button': default: $o .= ''; break; case 'anchor': $o .= ''; break; } // return output return $o; } function adtoniq_adtoniq_delete_option_variables() { adtoniq_delete_option('adtoniq-api-key'); adtoniq_delete_option('adtoniq-head-injection'); adtoniq_delete_option('adtoniq-is-private'); adtoniq_add_event('Deleted Adtoniq option variables.'); } function adtoniq_activation() { global $adtoniq_version; $adtoniq_version = ADTONIQ_VERSION; $lastVersion = get_option('adtoniq-lastVersion'); if (! isset($lastVersion) || strlen($lastVersion) === 0) { adtoniq_update_option('adtoniq-lastVersion', ADTONIQ_VERSION, true); adtoniq_add_event('Upgraded Adtoniq to version ' . ADTONIQ_VERSION); } elseif ($lastVersion != ADTONIQ_VERSION) { adtoniq_add_event('Updated Adtoniq plugin from version ' . $lastVersion . ' to version ' . ADTONIQ_VERSION); adtoniq_update_option('adtoniq-lastVersion', ADTONIQ_VERSION, true); } else { adtoniq_add_event('Adtoniq plugin version ' . ADTONIQ_VERSION . ' reactivated.'); } adtoniq_do_cache_update(''); } register_activation_hook(__FILE__, 'adtoniq_activation'); function adtoniq_deactivation() { adtoniq_add_event('Adtoniq deactivated.'); adtoniq_post_deactivate(); } register_deactivation_hook(__FILE__, 'adtoniq_deactivation'); add_action('admin_menu', 'adtoniq_menu'); global $adtoniq_menus; function adtoniq_add_menu($menuFunc) { global $adtoniq_menus; if (! isset($adtoniq_menus)) $adtoniq_menus = array(); $adtoniq_menus[] = $menuFunc; } function adtoniq_menu() { global $adtoniq_menus; add_menu_page('Adtoniq', 'Adtoniq', 'administrator', 'adtoniq', 'adtoniq_registered_page', 'dashicons-admin-generic'); if (isset($adtoniq_menus)) foreach ($adtoniq_menus as $menuFunc) { call_user_func($menuFunc); } } function adtoniq_get_server() { $adtoniq_server = get_option('adtoniq-debug-server', 'https://integration.adtoniq.com/'); if (strlen($adtoniq_server) == 0) $adtoniq_server = 'https://integration.adtoniq.com/'; return $adtoniq_server; } function adtoniq_post_operation($operation) { $response = null; try { $apiKey = get_option('adtoniq-api-key'); $fqdn = get_option('adtoniq-fqdn'); $url = adtoniq_get_server() . 'api/v1'; $version = ADTONIQ_VERSION; $params = array( 'operation' => $operation, 'apiKey' => $apiKey, 'fqdn' => $fqdn, 'version' => $version ); $response = adtoniq_post($url, $params); } catch(Exception $e) { adtoniq_add_event('Error / ' . $e); } return $response; } function adtoniq_post_deactivate() { adtoniq_post_operation('deactivate'); } add_action( 'wp_ajax_adtoniq_update', 'adtoniq_update' ); function adtoniq_update() { global $wpdb; // this is how you get access to the database $adtoniqAction = $_POST['adtoniqAction']; if ($adtoniqAction === 'requestJSUpdate') { adtoniq_do_cache_update(''); echo "Updated your Adtoniq defintions."; } else { echo "No action performed."; } wp_die(); // this is required to terminate immediately and return a proper response } function adtoniq_get_features() { $userInfo = adtoniq_post_operation('getUser'); if (isset($userInfo->features)) $userInfo = $userInfo->features; return $userInfo; } function adtoniq_has_adsense() { $features = adtoniq_get_features(); return $features != null && strpos(strtolower($features), 'adsense') !== false; } function adtoniq_admin_notice() { $api_key = get_option('adtoniq-api-key'); if (strlen($api_key) == 0) { ?>
Register for a free ' . 'Adtoniq Cloud account, and then paste your Cloud key below.'); ?>
get_row("SELECT post_name FROM wp_posts WHERE post_name = '" . $post_name . "'", 'ARRAY_A')) { return true; } else { return false; } } function createWaisaPage() { $slug = 'why-am-i-seeing-ads'; $page = get_page_by_path($slug); if(isset($page->ID)) adtoniq_update_option('adtoniq-waisa-pageid', $page->ID); else { $title = 'Why am I seeing ads?'; $error_message = ''; $page_content = array( 'post_type' => 'page', 'post_title' => $title, 'post_content' => 'We respect our visitors who use ad blockers, and give you a choice about whether or not to see ads on our site. We rely on ads to cover our costs for bringing you free content. Opting in to see ads will help us continue to pay our bills.', 'post_status' => 'publish', 'post_slug' => $slug ); $waisa_page_id = wp_insert_post($page_content); if (!is_wp_error($waisa_page_id)) { $error_message = 'The post is valid.'; adtoniq_update_option('adtoniq-waisa-pageid', $waisa_page_id); } else { $error_message = $waisa_page_id->get_error_message(); } } } function updateWaisaPage($newContent) { $waisa_page_id = get_option('adtoniq-waisa-pageid'); $my_post = array( 'ID' => $waisa_page_id, 'post_content' => $newContent, ); wp_update_post( $my_post ); } function adtoniq_registered_page() { createWaisaPage(); adtoniq_get_features(); $action = isset($_POST['adtoniqAction']) ? sanitize_text_field($_POST['adtoniqAction']) : ''; $injectStr = get_option('adtoniq-head-injection', ''); $lastUpdate = get_option('adtoniq-lastUpdate', ''); switch ($action) { case 'requestJSUpdate': $api_key = get_option('adtoniq-api-key'); $passedAPIKey = isset($_POST['adtoniqAPIKey']) ? sanitize_text_field($_POST['adtoniqAPIKey']) : ''; if ($passedAPIKey === $api_key) adtoniq_do_cache_update(''); else adtoniq_add_event('Passed API did not match, got: ' . $passedAPIKey); break; default: adtoniq_do_cache_update(''); break; } $lastUpdate = get_option('adtoniq-lastUpdate', ''); $apiKey = get_option('adtoniq-api-key'); $actualServer = $_SERVER['SERVER_NAME']; $actualPort = $_SERVER['SERVER_PORT']; if (strlen($injectStr) === 0) $injectStr = adtoniq_do_cache_update(''); if (! ($actualPort === '80' || $actualPort === '443')) $actualServer .= ":" . $actualPort; $adtoniq_server = adtoniq_get_server(); global $adtoniq_version; // register includes global $adtoniq_adsense; global $adtoniq_api; global $adtoniq_ga; global $adtoniq_msg; global $adtoniq_protection; ?>
Version

Adtoniq Express

adtoniq_api_init($apiKey); ?>
"; $debug = ""; if (function_exists('adtoniq_debug_head_injection')) $debug = adtoniq_debug_head_injection(); global $adtoniq_msg, $adtoniq_adsense; return $adblockCheckerStr . $injectStr . adtoniq_gen_ga_script() . $adtoniq_adsense->javascript() . $debug; } function adtoniq_gen_ga_script() { $gaPropertyId = get_option('adtoniq-ga-property-id', ''); $gaTrafficSplit = get_option('adtoniq-ga-traffic-split', ''); $gaSaved = get_option('adtoniq-ga-saved', ''); $ga_bypass = true; $script = ""; if (strlen($gaPropertyId) > 0 && strlen($gaTrafficSplit) > 0) { $script = ""; } return $script; } function adtoniq_do_cache_update($nonce) { $api_key = get_option('adtoniq-api-key'); $injectStr = ''; $gaid = isset($_POST['adtoniqGaid']) ? sanitize_text_field($_POST['adtoniqGaid']) : ''; if (strlen($gaid) > 0) { adtoniq_update_option('adtoniq-ga-property-id', $gaid, true); } $adtoniq_server = adtoniq_get_server(); $debugJS = get_option('adtoniq-debug-js', ''); $url = $adtoniq_server . 'api/v1'; $version = ADTONIQ_VERSION; $data = array('operation' => 'update', 'apiKey' => $api_key, 'nonce' => $nonce, 'debug' => $debugJS, 'version' => $version); $response = adtoniq_post($url, $data); if (strlen($response) > 0) { $injectStr = $response; adtoniq_update_option('adtoniq-head-injection', $injectStr, true); adtoniq_update_option('adtoniq-lastUpdate', date('F d, Y h:i a T', time()), true); adtoniq_add_event('Updated Adtoniq JavaScript'); } else adtoniq_add_event('Adtoniq received 0 length JavaScript for injection'); $response = adtoniq_post_operation("getWebsiteSettings"); adtoniq_add_event("Response to getWebsiteSettings is " . $response); // Get all settings from Adtoniq Cloud if (strlen($response) > 0) { $settings = json_decode($response); adtoniq_add_event($settings); adtoniq_update_option('adtoniq-msg-message', $settings->msgMessage); adtoniq_update_option('adtoniq-msg-is-enabled', $settings->msgIsEnabled); adtoniq_update_option('adtoniq-msg-users', $settings->msgUsers); adtoniq_update_option('adtoniq-msg-confirm', $settings->msgConfirm); adtoniq_update_option('adtoniq-msg-reject', $settings->msgReject); adtoniq_update_option('adtoniq-msg-confirm-btn', $settings->msgConfirmBtn); adtoniq_update_option('adtoniq-msg-reject-btn', $settings->msgRejecteBtn); adtoniq_update_option('adtoniq-msg-custom-btn-class', $settings->msgCustomBtnClass); adtoniq_update_option('adtoniq-protection-status', $settings->protectionStatus); adtoniq_update_option('adtoniq-protection-url', $settings->protectionUrl); adtoniq_update_option('adtoniq-protection-css', $settings->protectionCss); adtoniq_update_option('adtoniq-ga-property-id', $settings->gaPropertyId); adtoniq_update_option('adtoniq-ga-traffic-split', $settings->gaTrafficSplit); adtoniq_update_option('adtoniq-as-enabled', $settings->asEnabled); adtoniq_update_option('adtoniq-as-max-ads', $settings->asMaxAds); adtoniq_update_option('adtoniq-as-publisher-id', $settings->asPublisherId); adtoniq_update_option('adtoniq-as-css-selector', $settings->asCssSelector); adtoniq_update_option('adtoniq-as-code-snippet', $settings->asCodeSnippet); adtoniq_update_option('adtoniq-as-data-ad-layout', $settings->asDataAdLayout); adtoniq_update_option('adtoniq-as-data-ad-format', $settings->asDataAdFormat); adtoniq_update_option('adtoniq-as-data-ad-client', $settings->asDataAdClient); adtoniq_update_option('adtoniq-as-data-ad-slot', $settings->asDataAdSlot); adtoniq_update_option('adtoniq-master-control', $settings->masterControl); updateWaisaPage($settings->waisaContent); /* */ } else adtoniq_add_event('Adtoniq received 0 length response for getSettings'); return $injectStr; } function adtoniq_update_cache() { $api_key = get_option('adtoniq-api-key'); $passedAPIKey = isset($_POST['adtoniqAPIKey']) ? sanitize_text_field($_POST['adtoniqAPIKey']) : ''; // Note: This is not a WordPress nonce. This nonce comes from the Adtoniq server and must be sent back for validation // The Adtoniq server validates this nonce, since it generated it. That is why we only check for length > 0. $nonce = isset($_POST['adtoniqNonce']) ? sanitize_text_field($_POST['adtoniqNonce']) : ''; $validNonce = $api_key == $passedAPIKey && strlen($nonce) > 0; if ($validNonce) { adtoniq_do_cache_update($nonce); } } function adtoniq_post($url, $data) { $evt = 'POST url: ' . $url . ''; $evt .= '
' . adtoniq_add_event_var($data) . '
'; $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded", 'method' => 'POST', 'content' => http_build_query($data) ) ); $context = stream_context_create($options); $response = trim(file_get_contents($url, false, $context)); $evt .= '
' . 'response: ' . htmlspecialchars(substr($response, 0, 300)) . '
'; adtoniq_add_event($evt); return $response; } function adtoniq_get($url, $data) { $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded", 'method' => 'GET', 'content' => http_build_query($data) ) ); $context = stream_context_create($options); $response = trim(file_get_contents($url, false, $context)); return $response; } add_action('wp_dashboard_setup', 'adtoniq_dashboard_widgets'); function adtoniq_dashboard_widgets() { global $wp_meta_boxes; wp_add_dashboard_widget('adtoniq_help_widget', 'Adtoniq News', 'adtoniq_dashboard_help'); } function adtoniq_dashboard_help() { $data = array( ); $news = adtoniq_get('http://static-42andpark-com.s3-website-us-west-2.amazonaws.com/html/news.html', $data); $wpnews = adtoniq_get("http://static-42andpark-com.s3-website-us-west-2.amazonaws.com/html/wordpress-news.html", $data); ?>

adtoniq_api_settings(); $adtoniq_msg->adtoniq_msg_settings(); $adtoniq_ga->adtoniq_ga_settings(); $adtoniq_adsense->adtoniq_adsense_settings(); $adtoniq_protection->adtoniq_protection_settings(); }