当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_statistics_uri_to_id函数代码示例

本文整理汇总了PHP中wp_statistics_uri_to_id函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_statistics_uri_to_id函数的具体用法?PHP wp_statistics_uri_to_id怎么用?PHP wp_statistics_uri_to_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_statistics_uri_to_id函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wp_statistics_get_top_pages

function wp_statistics_get_top_pages()
{
    global $wpdb;
    // Get every unique URI from the pages database.
    $result = $wpdb->get_results("SELECT DISTINCT uri FROM {$wpdb->prefix}statistics_pages", ARRAY_N);
    $total = 0;
    $uris = array();
    // Now get the total page visit count for each unique URI.
    foreach ($result as $out) {
        // Increment the total number of results.
        $total++;
        // Retreive the post ID for the URI.
        $id = wp_statistics_uri_to_id($out[0]);
        // Lookup the post title.
        $post = get_post($id);
        if (is_object($post)) {
            $title = $post->post_title;
        } else {
            if ($out[0] == '/') {
                $title = get_bloginfo();
            } else {
                $title = '';
            }
        }
        // Add the current post to the array.
        $uris[] = array($out[0], wp_statistics_pages('total', $out[0]), $id, $title);
    }
    // If we have more than one result, let's sort them using usort.
    if (count($uris) > 1) {
        // Sort the URI's based on their hit count.
        usort($uris, 'wp_stats_compare_uri_hits');
    }
    return array($total, $uris);
}
开发者ID:proj-2014,项目名称:vlan247-test-wp,代码行数:34,代码来源:functions.php

示例2: wp_statistics_purge_data

	function wp_statistics_purge_data( $purge_days ) {
		GLOBAL $wpdb, $WP_Statistics;
		
		// If it's less than 30 days, don't do anything.
		if($purge_days > 30) {
			// Purge the visit data.
			$table_name = $wpdb->prefix . 'statistics_visit';
			$date_string = $WP_Statistics->current_date( 'Y-m-d', '-' . $purge_days); 
	 
			$result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string ) );
			
			if($result) {
				// Update the historical count with what we purged.
				$historical_result = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}statistics_historical SET value = value + %d WHERE `category` = 'visits'", $result ) );

				if( $historical_result == 0 ) {
					$wpdb->insert( $wpdb->prefix . "statistics_historical", array( 'value' => $result, 'category' => 'visits', 'page_id' => -2, 'uri' => '-2' ) );
				}
			
				$result_string = sprintf(__('%s data older than %s days purged successfully.', 'wp_statistics'), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>');
			} else {
				$result_string = sprintf(__('No records found to purge from %s!', 'wp_statistics'), '<code>' . $table_name . '</code>' ); 
			}

			// Purge the visitors data.
			$table_name = $wpdb->prefix . 'statistics_visitor';

			$result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string ) );
			
			if($result) {
				// Update the historical count with what we purged.
				$historical_result = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}statistics_historical SET value = value + %d WHERE `category` = 'visitors'", $result ) );
				
				if( $historical_result == 0 ) {
					$wpdb->insert( $wpdb->prefix . "statistics_historical", array( 'value' => $result, 'category' => 'visitors', 'page_id' => -1, 'uri' => '-1' ) );
				}
			
				$result_string .= '<br>' . sprintf(__('%s data older than %s days purged successfully.', 'wp_statistics'), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>');
			} else {
				$result_string .= '<br>' . sprintf(__('No records found to purge from %s!', 'wp_statistics'), '<code>' . $table_name . '</code>' ); 
			}

			// Purge the exclusions data.
			$table_name = $wpdb->prefix . 'statistics_exclusions';

			$result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `date` < %s", $date_string ) );
			
			if($result) {
				$result_string .= '<br>' . sprintf(__('%s data older than %s days purged successfully.', 'wp_statistics'), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>');
			} else {
				$result_string .= '<br>' . sprintf(__('No records found to purge from %s!', 'wp_statistics'), '<code>' . $table_name . '</code>' ); 
			}

			// Purge the search data.
			$table_name = $wpdb->prefix . 'statistics_search';

			$result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `last_counter` < %s", $date_string ) );
			
			if($result) {
				$result_string .= '<br>' . sprintf(__('%s data older than %s days purged successfully.', 'wp_statistics'), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>');
			} else {
				$result_string .= '<br>' . sprintf(__('No records found to purge from %s!', 'wp_statistics'), '<code>' . $table_name . '</code>' ); 
			}

			// Purge the pages data, this is more complex as we want to save the historical data per page.
			$table_name = $wpdb->prefix . 'statistics_pages';
			$historical = 0;
			
			// The first thing we need to do is update the historical data by finding all the unique pages.
			$result = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT uri FROM {$table_name} WHERE `date` < %s", $date_string ) );

			// If we have a result, let's store the historical data.		
			if( $result ) {
				// Loop through all the unique rows that were returned.
				foreach( $result as $row ) {
					// Use the unique rows to get a total count from the database of all the data from the given URIs/Pageids that we're going to delete later.
					$historical = $wpdb->get_var( $wpdb->prepare( "SELECT sum(count) FROM {$table_name} WHERE `uri` = %s AND `date` < %s", $row->uri, $date_string));
		
					// Do an update of the historical data.
					$uresult = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}statistics_historical SET `value` = value + %d WHERE `uri` = %s AND `category` = 'uri'", $historical, $row->uri, $date_string ) );

					// If we failed it's because this is the first time we've seen this URI/pageid so let's create a historical row for it.
					if( $uresult == 0 ) {
						$wpdb->insert( $wpdb->prefix . "statistics_historical", array( 'value' => $historical, 'category' => 'uri', 'uri' => $row->uri, 'page_id' => wp_statistics_uri_to_id($row->uri) ) );
					}
				}
			}
			
			// Now that we've done all of the required historical data storage, we can actually delete the data from the database.
			$result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE `date` < %s", $date_string ) );
			
			if($result) {
				$result_string .= '<br>' . sprintf(__('%s data older than %s days purged successfully.', 'wp_statistics'), '<code>' . $table_name . '</code>', '<code>' . $purge_days . '</code>');
			} else {
				$result_string .= '<br>' . sprintf(__('No records found to purge from %s!', 'wp_statistics'), '<code>' . $table_name . '</code>' ); 
			}
			
			if( $WP_Statistics->get_option('prune_report') == true ) {
				$blogname = get_bloginfo('name');
				$blogemail = get_bloginfo('admin_email');
//.........这里部分代码省略.........
开发者ID:simulacrum-amsterdam,项目名称:simulacrum-press,代码行数:101,代码来源:purge.php

示例3: wp_statistics_uri_to_id

		postboxes.add_postbox_toggles(pagenow);
	});
</script>
<?php 
if (array_key_exists('page-uri', $_GET)) {
    $pageuri = $_GET['page-uri'];
} else {
    $pageuri = null;
}
if (array_key_exists('page-id', $_GET)) {
    $pageid = (int) $_GET['page-id'];
} else {
    $pageid = null;
}
if ($pageuri && !$pageid) {
    $pageid = wp_statistics_uri_to_id($pageuri);
}
$post = get_post($pageid);
if (is_object($post)) {
    $title = $post->post_title;
} else {
    $title = "";
}
$urlfields = "&page-id={$pageid}";
if ($pageuri) {
    $urlfields .= "&page-uri={$pageuri}";
}
$daysToDisplay = 20;
if (array_key_exists('hitdays', $_GET)) {
    $daysToDisplay = intval($_GET['hitdays']);
}
开发者ID:wenhao87,项目名称:WPPlugins,代码行数:31,代码来源:page-statistics.php

示例4: wp_statistics_generate_page_postbox_content

function wp_statistics_generate_page_postbox_content($pageuri, $pageid, $days = 20, $chart_title = null, $rangestart = '', $rangeend = '')
{
    global $WP_Statistics;
    if (!$WP_Statistics->get_option('pages')) {
        return;
    }
    if ($chart_title == null) {
        $chart_title = __('Page Trending Stats', 'wp_statistics');
    }
    if ($pageuri && !$pageid) {
        $pageid = wp_statistics_uri_to_id($pageuri);
    }
    $post = get_post($pageid);
    if (is_object($post)) {
        $title = $post->post_title;
    } else {
        $title = "";
    }
    $urlfields = "&page-id={$pageid}";
    if ($pageuri) {
        $urlfields .= "&page-uri={$pageuri}";
    }
    list($daysToDisplay, $rangestart_utime, $rangeend_utime) = wp_statistics_date_range_calculator($days, $rangestart, $rangeend);
    ?>
						<script type="text/javascript">
						var pages_chart;
						jQuery(document).ready(function() {
<?php 
    echo "var page_data_line = [";
    for ($i = $daysToDisplay; $i >= 0; $i--) {
        $stat = wp_statistics_pages('-' . $i, $pageuri, $pageid);
        echo "['" . $WP_Statistics->Real_Current_Date('Y-m-d', '-' . $i, $rangeend_utime) . "'," . $stat . "], ";
    }
    echo "];\n";
    $tickInterval = $daysToDisplay / 20;
    if ($tickInterval < 1) {
        $tickInterval = 1;
    }
    ?>
							pages_jqchart = jQuery.jqplot('page-stats', [page_data_line], {
								title: {
									text: '<b>' + <?php 
    echo json_encode(__($chart_title, 'wp_statistics'));
    ?>
 + '</b>',
									fontSize: '12px',
									fontFamily: 'Tahoma',
									textColor: '#000000',
									},
								axes: {
									xaxis: {
											min: '<?php 
    echo $WP_Statistics->Real_Current_Date('Y-m-d', '-' . $daysToDisplay, $rangeend_utime);
    ?>
',
											max: '<?php 
    echo $WP_Statistics->Real_Current_Date('Y-m-d', '-0', $rangeend_utime);
    ?>
',
											tickInterval:  '<?php 
    echo $tickInterval;
    ?>
 day',
											renderer:jQuery.jqplot.DateAxisRenderer,
											tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
											tickOptions: { 
												angle: -45,
												formatString:'%b %#d',
												showGridline: false, 
												},
										},										
									yaxis: {
											min: 0,
											padMin: 1.0,
											label: <?php 
    echo json_encode(__('Number of Hits', 'wp_statistics'));
    ?>
,
											labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
											labelOptions: {
												angle: -90,
												fontSize: '12px',
												fontFamily: 'Tahoma',
												fontWeight: 'bold',
											},
										}
									},
								legend: {
									show: true,
									location: 's',
									placement: 'outsideGrid',
									labels: [ '<?php 
    echo $pageid . ' - ' . $title;
    ?>
' ],
									renderer: jQuery.jqplot.EnhancedLegendRenderer,
									rendererOptions:
										{
											numberColumns: 5, 
											disableIEFading: false,
//.........这里部分代码省略.........
开发者ID:lykeven,项目名称:graspzhihu,代码行数:101,代码来源:page.php


注:本文中的wp_statistics_uri_to_id函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。