get_total_indexed_url_count() public static method

Gets the current number of URLs indexed by msm-sitemap accross all sitemaps.
public static get_total_indexed_url_count ( ) : integer
return integer The number of total number URLs indexed
Exemplo n.º 1
0
    /**
     * Render admin options page
     */
    public static function render_sitemap_options_page()
    {
        if (!current_user_can('manage_options')) {
            wp_die(__('You do not have sufficient permissions to access this page.', 'metro-sitemaps'));
        }
        // Array of possible user actions
        $actions = apply_filters('msm_sitemap_actions', array());
        // Start outputting html
        echo '<div class="wrap">';
        screen_icon();
        echo '<h2>' . __('Sitemap', 'metro-sitemaps') . '</h2>';
        if (!self::is_blog_public()) {
            self::show_action_message(__('Oops! Sitemaps are not supported on private blogs. Please make your blog public and try again.', 'metro-sitemaps'), 'error');
            echo '</div>';
            return;
        }
        if (isset($_POST['action'])) {
            check_admin_referer('msm-sitemap-action');
            foreach ($actions as $slug => $action) {
                if ($action['text'] !== $_POST['action']) {
                    continue;
                }
                do_action('msm_sitemap_action-' . $slug);
                break;
            }
        }
        // All the settings we need to read to display the page
        $sitemap_create_in_progress = get_option('msm_sitemap_create_in_progress') === true;
        $sitemap_update_last_run = get_option('msm_sitemap_update_last_run');
        // Determine sitemap status text
        $sitemap_create_status = apply_filters('msm_sitemap_create_status', $sitemap_create_in_progress ? __('Running', 'metro-sitemaps') : __('Not Running', 'metro-sitemaps'));
        ?>
		<div class="stats-container">
			<div class="stats-box"><strong id="sitemap-count"><?php 
        echo number_format(Metro_Sitemap::count_sitemaps());
        ?>
</strong><?php 
        _e('Sitemaps', 'metro-sitemaps');
        ?>
</div>
			<div class="stats-box"><strong id="sitemap-indexed-url-count"><?php 
        echo number_format(Metro_Sitemap::get_total_indexed_url_count());
        ?>
</strong><?php 
        _e('Indexed URLs', 'metro-sitemaps');
        ?>
</div>
			<div class="stats-footer"><span><span class="noticon noticon-time"></span><?php 
        _e('Updated', 'metro-sitemaps');
        ?>
 <strong><?php 
        echo human_time_diff($sitemap_update_last_run);
        ?>
 <?php 
        _e('ago', 'metro-sitemaps');
        ?>
</strong></span></div>
		</div>

		<h3><?php 
        _e('Latest Sitemaps', 'metro-sitemaps');
        ?>
</h3>
		<div class="stats-container stats-placeholder"></div>
		<div id="stats-graph-summary"><?php 
        printf(__('Max: %s on %s. Showing the last %s days.', 'metro-sitemaps'), '<span id="stats-graph-max"></span>', '<span id="stats-graph-max-date"></span>', '<span id="stats-graph-num-days"></span>');
        ?>
</div>

		<h3><?php 
        _e('Generate', 'metro-sitemaps');
        ?>
</h3>
		<p><strong><?php 
        _e('Sitemap Create Status:', 'metro-sitemaps');
        ?>
</strong> <?php 
        echo esc_html($sitemap_create_status);
        ?>
</p>
		<form action="<?php 
        echo menu_page_url('metro-sitemap', false);
        ?>
" method="post" style="float: left;">
			<?php 
        wp_nonce_field('msm-sitemap-action');
        ?>
			<?php 
        foreach ($actions as $action) {
            if (!$action['enabled']) {
                continue;
            }
            ?>
				<input type="submit" name="action" class="button-secondary" value="<?php 
            echo esc_attr($action['text']);
            ?>
">
			<?php 
        }
        ?>
		</form>
		</div>
		<div id="tooltip"><strong class="content"></strong> <?php 
        _e('indexed urls', 'metro-sitemaps');
        ?>
</div>
		<?php 
    }
 function test_site_stats_for_deleted_post()
 {
     $today_str = date('Y') . '-' . date('m') . '-' . date('d');
     // Insert a new post for today
     $this->test_base->create_dummy_posts(array($today_str . ' 00:00:00'));
     // Build sitemaps
     $this->test_base->build_sitemaps();
     // Delete all posts (going backwards in time)
     $post_count = count($this->test_base->posts);
     $deleted_dates = array();
     while ($post_count) {
         $last_post = array_pop($this->test_base->posts);
         wp_delete_post($last_post['ID'], true);
         $post_count -= 1;
         $deleted_dates[trim(substr($last_post['post_date'], 0, 10))] = 0;
         // Build sitemaps
         $this->test_base->build_sitemaps();
         // Check stats
         $this->assertEquals($post_count, Metro_Sitemap::get_total_indexed_url_count());
         // Check specific stats
         $this->assertTrue($this->test_base->check_stats_for_created_posts());
     }
     // Make sure that there is nothing left over
     $this->assertEquals(0, Metro_Sitemap::count_sitemaps());
     $this->assertEquals(0, Metro_Sitemap::get_total_indexed_url_count());
 }