示例#1
0
function stats_notice_footer()
{
    if (!stats_get_api_key() || stats_get_option('footer')) {
        return;
    }
    if (function_exists('is_plugin_active_for_network') && is_plugin_active_for_network(plugin_basename(__FILE__))) {
        return;
    }
    if (strpos(wp_remote_get(get_bloginfo('siteurl')), 'stats_footer_test')) {
        stats_set_option('footer', true);
        return;
    }
    echo "<div class='updated' style='background-color:#f66;'><p>" . __('WordPress.com Stats is unable to work properly because your theme seems to lack the necessary footer code. Usually this can be fixed by adding the following code just before &lt;/body&gt; in footer.php:', 'stats') . "</p><p><code>&lt;?php wp_footer(); ?&gt;</code></p></div>";
}
示例#2
0
function stats_admin_load()
{
    global $plugin_page;
    if (!empty($_POST['action']) && $_POST['_wpnonce'] == wp_create_nonce('stats')) {
        switch ($_POST['action']) {
            case 'reset':
                stats_set_options(array());
                wp_redirect("plugins.php?page={$plugin_page}");
                exit;
            case 'enter_key':
                stats_check_key($_POST['api_key']);
                wp_redirect("plugins.php?page={$plugin_page}");
                exit;
            case 'add_or_replace':
                $key_check = stats_get_option('key_check');
                stats_set_api_key($key_check[0]);
                if (isset($_POST['add'])) {
                    stats_get_blog_id($key_check[0]);
                } else {
                    extract(parse_url(get_option('home')));
                    $path = rtrim($path, '/');
                    if (empty($path)) {
                        $path = '/';
                    }
                    $options = stats_get_options();
                    $options['blog_id'] = intval($_POST['blog_id']);
                    $options['api_key'] = $key_check[0];
                    $options['host'] = $host;
                    $options['path'] = $path;
                    stats_set_options($options);
                    stats_update_bloginfo();
                }
                if (stats_get_option('blog_id')) {
                    stats_set_option('key_check', false);
                }
                wp_redirect("plugins.php?page={$plugin_page}");
                exit;
        }
    }
    $options = stats_get_options();
    if (empty($options['blog_id']) && empty($options['key_check']) && stats_get_api_key()) {
        stats_check_key(stats_get_api_key());
    }
}