← Back
Editing: convert-a-link-admin.php
<?php if (!defined('ABSPATH')) exit; if (!empty($_POST) && check_admin_referer('insert_publisher')) { if (!empty($_POST['publisherId']) && intval(sanitize_text_field($_POST['publisherId'])) > 0) { $publisherId = sanitize_text_field($_POST['publisherId']); $publisherId = intval($publisherId); delete_option('cal_publisherId'); add_option('cal_publisherId', $publisherId); // Admin request, so blocking is fine; a fresh install shows Active straight away. CAL_AIV_Bot_List::fetch_and_cache(); } else { echo "<div class='notice notice-error'>FAILED! Insert publisher ID</div>"; } } $cal_aiv_publisher_id = cal_aiv_publisher_id(); $cal_aiv_status = get_option(CAL_AIV_OPT_STATUS, array()); $cal_aiv_status = is_array($cal_aiv_status) ? $cal_aiv_status : array(); $cal_aiv_enabled = cal_aiv_is_enabled(); $cal_aiv_active = cal_aiv_is_active(); $cal_aiv_reason = ''; if (!$cal_aiv_enabled) { $cal_aiv_reason = 'Turned off.'; } elseif (!$cal_aiv_publisher_id) { $cal_aiv_reason = 'Publisher ID is missing.'; } elseif (!$cal_aiv_active) { $cal_aiv_reason = 'No bot list loaded yet.'; } ?> <div class="wrap"> <h2>Configure your MasterTag Settings </h2> <table> <tr> <td colspan="2"> <b>Step 1: Turn on a plugin inside of your Publisher MasterTag Settings</b> <br /> <i>Under "Toolbox" > "Links & Tools"</i> <p> <a target="_blank" href="https://wiki.awin.com/index.php/Publisher-MasterTag"> <img src="<?php echo esc_url(plugins_url('one.png', dirname(__FILE__))) ?>" alt=""></a> </p> </td> </tr> <tr> <td><b>Step 2: Enter your Publisher ID and save.</b></td> <td> <form enctype="multipart/form-data" name="convert-a-link" method="post" action=""> <?php echo wp_nonce_field('insert_publisher'); ?> <input type="number" value="<?php echo esc_attr(get_option('cal_publisherId')) ?>" name="publisherId" /> <input type="submit" name="submit" id="submit" class="button button-primary" value="Save"> </form> </td> </tr> </table> <h2>AI Visibility</h2> <p>AI visibility reports visits from AI bots to Awin. It runs automatically once your Publisher ID is saved.</p> <?php $cal_aiv_notice = isset($_GET['aiv']) ? sanitize_key(wp_unslash($_GET['aiv'])) : ''; ?> <?php if ($cal_aiv_notice === 'on') : ?> <div class="awin-aiv-notice notice notice-info inline"><p>AI visibility turned on.</p></div> <?php elseif ($cal_aiv_notice === 'off') : ?> <div class="awin-aiv-notice notice notice-info inline"><p>AI visibility turned off. No AI bot data is sent to Awin.</p></div> <?php endif; ?> <?php $cal_aiv_refresh = isset($_GET['refresh']) ? sanitize_key(wp_unslash($_GET['refresh'])) : ''; ?> <?php if ($cal_aiv_refresh === 'ok') : ?> <div class="awin-aiv-notice notice notice-success inline"><p>Bot list refreshed.</p></div> <?php elseif ($cal_aiv_refresh === 'failed') : ?> <div class="awin-aiv-notice notice notice-error inline"><p>Bot list refresh failed. AI visibility keeps using the last list it loaded.</p></div> <?php endif; ?> <table class="awin-aiv-settings"> <tr> <td><label for="cal_aiv_enabled"><b>Report AI bot visits to Awin</b></label></td> <td> <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>"> <?php wp_nonce_field('cal_aiv_toggle_nonce'); ?> <input type="hidden" name="action" value="cal_aiv_toggle"> <input type="checkbox" name="cal_aiv_enabled" id="cal_aiv_enabled" value="1" <?php checked($cal_aiv_enabled); ?>> <?php submit_button('Save', 'primary', 'cal_aiv_toggle_submit', false); ?> </form> </td> </tr> <tr> <td><b>Status</b></td> <td> <?php echo $cal_aiv_active ? 'Active' : 'Inactive'; ?> <?php if ($cal_aiv_reason) : ?> <i>(<?php echo esc_html($cal_aiv_reason); ?>)</i> <?php endif; ?> </td> </tr> <tr> <td><b>Last successful fetch</b></td> <td><?php echo esc_html(cal_aiv_format_datetime($cal_aiv_status['last_fetch'] ?? '')); ?></td> </tr> <tr> <td><b>Signatures loaded</b></td> <td><?php echo esc_html(number_format_i18n(absint($cal_aiv_status['bot_count'] ?? 0))); ?></td> </tr> <?php if (!empty($cal_aiv_status['last_error'])) : ?> <tr> <td><b>Last fetch failed</b></td> <td><?php echo esc_html(cal_aiv_format_datetime($cal_aiv_status['last_attempt'] ?? '')); ?> (<?php echo esc_html($cal_aiv_status['last_error']); ?>)</td> </tr> <?php endif; ?> <?php if ($cal_aiv_publisher_id && $cal_aiv_enabled) : ?> <tr> <td><b>Bot list</b></td> <td> <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>"> <?php wp_nonce_field('cal_aiv_refresh_nonce'); ?> <input type="hidden" name="action" value="cal_aiv_refresh"> <?php submit_button('Refresh bot list now', 'secondary', 'cal_aiv_refresh_submit', false); ?> </form> </td> </tr> <?php endif; ?> </table> <?php CAL_AIV_CDN_Checker::render_warnings(); ?> </div>
Save File
Cancel