'admiral-adblock-analytics'); if ($success) { $args['embed_refreshed'] = '1'; } else { $args['embed_refresh_error'] = '1'; } $url = add_query_arg($args, class_exists('Jetpack') ? admin_url('admin.php') : admin_url('options-general.php')); wp_redirect($url); exit; }); add_action("admin_menu", function() { add_options_page("Admiral Options", "Admiral", "manage_options", "admiral-adblock-analytics", function() { if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } $embedOptionKey = wp\AdmiralAdBlockAnalytics::EMBED_OPTION_KEY; $propertyOptionIDKey = wp\AdmiralAdBlockAnalytics::PROPERTY_OPTION_ID_KEY; $protectOptionKey = wp\AdmiralAdBlockAnalytics::PROTECT_OPTION_KEY; $firstPartyModeOptionKey = wp\AdmiralAdBlockAnalytics::FIRST_PARTY_MODE_OPTION_KEY; $legacyFirstPartyModeOptionKey = wp\AdmiralAdBlockAnalytics::LEGACY_FIRST_PARTY_MODE_OPTION_KEY; if (array_key_exists($propertyOptionIDKey, $_POST)) { $pidValue = wp\AdmiralAdBlockAnalytics::getPropertyID(); if ($pidValue !== $_POST[$propertyOptionIDKey]) { wp\AdmiralAdBlockAnalytics::updatePropertyIDByPOST(); } } if (array_key_exists($protectOptionKey, $_POST) && $_POST[$protectOptionKey] !== 'unconfigured') { wp\AdmiralAdBlockAnalytics::setProtect($_POST[$protectOptionKey]); } $postedFirstPartyMode = null; // the form posts under the current key, but accept the pre-rename field // name too so anything posting this form programmatically keeps working if (array_key_exists($firstPartyModeOptionKey, $_POST)) { $postedFirstPartyMode = $_POST[$firstPartyModeOptionKey]; } else if (array_key_exists($legacyFirstPartyModeOptionKey, $_POST)) { $postedFirstPartyMode = $_POST[$legacyFirstPartyModeOptionKey]; } if ($postedFirstPartyMode !== null && $postedFirstPartyMode !== 'unconfigured') { wp\AdmiralAdBlockAnalytics::setFirstPartyMode($postedFirstPartyMode); } $pidValue = wp\AdmiralAdBlockAnalytics::getPropertyID(); $pidPromiseValue = wp\AdmiralAdBlockAnalytics::getPropertyPromiseID(); $pluginCode = wp\AdmiralAdBlockAnalytics::getPluginCode(); $pidOrphan = wp\AdmiralAdBlockAnalytics::isPropertyOrphanProperty($pidValue); $pidValueSpecial = htmlspecialchars($pidValue); $protect = wp\AdmiralAdBlockAnalytics::getProtect(); $firstPartyMode = wp\AdmiralAdBlockAnalytics::getFirstPartyMode(); $supportFirstPartyMode = wp\AdmiralAdBlockAnalytics::hasPermalinks(); if (isset($_GET['embed_refreshed']) && $_GET['embed_refreshed'] === '1') { echo <<

Embed script successfully refreshed.

END; } if (isset($_GET['embed_refresh_error']) && $_GET['embed_refresh_error'] === '1') { echo <<

Failed to refresh embed script. Please ensure your Property ID is configured correctly.

END; } $admiralPluginVersion = ADMIRAL_PLUGIN_VERSION; echo <<

Version $admiralPluginVersion

The Admiral WordPress Plugin allows you to easily measure how much revenue you are losing to adblock. After measuring, you can use the Admiral platform to recover and engage with adblock visitors.

Learn more about Admiral

END; if (wp\AdmiralAdBlockAnalytics::getEnvConfiguredPropertyID()) { echo << Property ID $pidValueSpecial (configured via ADMIRAL_PROPERTY_ID environment variable) END; } else { $promiseError = false; $signupLink = wp\AdmiralAdBlockAnalytics::getClaimPropertyLink(); if (empty($signupLink)) { $signupLink = wp\AdmiralAdBlockAnalytics::getBaseSignupLink(); if ($pidPromiseValue) { $promiseError = true; } } if (empty($pidValue) || $pidOrphan) { echo <<

Free Adblock Analytics with Admiral.

Admiral is the industry's leading adblock revenue recovery specialists, serving over 12,000 customers worldwide. We build products that empower publishers to grow visitor relationships, protect copyrighted content, and recover advertising revenue.

END; if (empty($pidValue)) { echo <<

Click Create Property to start collecting data and discover how much revenue you're losing to adblockers. Afterwards, create an account to view your analytics.

END; } else { echo <<

Click Create Account to view analytics about your traffic and visitors.

END; } echo << END; } else { echo << END; } settings_fields('admiral_property_settings'); do_settings_sections('admiral_property_settings'); if ($promiseError) { echo <<

Unable to generate claim token for your property. Please contact us at https://www.getadmiral.com/contact-us to resolve.

HTML; } $args = array('page' => 'admiral-adblock-analytics'); $url = add_query_arg($args, class_exists('Jetpack') ? admin_url('admin.php') : admin_url('options-general.php')); echo << END; echo << END; echo << END; if (!empty($pidValue) && !$pidOrphan) { $refreshUrl = admin_url('admin-post.php'); $refreshUrl = add_query_arg(array( 'action' => 'refresh_admiral_embed', '_wpnonce' => wp_create_nonce('refresh_admiral_embed') ), $refreshUrl); echo << END; } echo <<
Property ID END; if (empty($pidValue)) { echo <<The property ID is a unique identifier for your site. If you already have an account at getadmiral.com, then enter the property ID found on the property settings page here. If you don't, no worries!

Creating an account is quick and free via our dashboard.

END; } echo <<
END; if ($supportFirstPartyMode) { echo << END; if ($firstPartyMode === "unconfigured") { echo ''; } echo ''; echo ''; echo << END; } else { echo <<Admiral First-Party Mode is not supported on this site because it requires a permalink structure. Please contact us at https://www.getadmiral.com/contact-us to resolve.

END; } echo << First-Party Mode will send requests through this WordPress server before sending them to Admiral to further improve conversions.

Refresh Embed

Click to force refresh the embed script from Admiral's servers. This is useful if you've made changes to your property settings.

END; submit_button(); echo ''; } }); }); // This checks for `Activated_Admiral` and redirects to the plugin settings page. if (is_admin()) { add_action('init', function() { if (get_option('Activated_Admiral')) { delete_option('Activated_Admiral'); if (!headers_sent()) { wp_redirect(add_query_arg(array('page' => 'admiral-adblock-analytics'), class_exists('Jetpack') ? admin_url('admin.php') : admin_url('options-general.php'))); } } }); } add_action('admin_notices', function() { global $hook_suffix; $pidValue = wp\AdmiralAdBlockAnalytics::getPropertyID(); if (('plugins.php' === $hook_suffix || 'index.php' === $hook_suffix) && empty($pidValue)) { $title = esc_html__('Admiral is not configured.', 'admiral'); $desc = esc_html__('A Property ID must be configured for Admiral to measure visitors with adblock installed and provide analytics. Visit the plugin Settings to complete setup.', 'admiral'); echo <<

$title

$desc

END; } }); add_action('upgrader_process_complete', function($upgrader, $options) { $pluginBasename = plugin_basename(__FILE__); if ($options['action'] == 'update' && $options['type'] == 'plugin' && isset($options['plugins'])) { foreach ($options['plugins'] as $plugin) { // we want to make sure that "autoload" is set to true for some options after we update the plugin if ($plugin == $pluginBasename) { wp\AdmiralAdBlockAnalytics::touchOptions(); } } } }, 10, 2); /* EOF */