public_html/wp-content/plugins/wp-statistics/includes/functions/functions.php
// This function creates the date range selector 'widget' used in the various statistics pages.
This function creates the date range selector 'widget' used in the various statistics pages.
This function creates the date range selector ' widget ' used in the various statistics pages .
function wp_statistics_date_range_selector( $page, $current, $range = array(), $desc = array(), $extrafields = '', $pre_extra = '', $post_extra = '' ) {
		GLOBAL $WP_Statistics;
		wp_enqueue_script( 'jquery-ui-datepicker' );
		wp_register_style( 'jquery-ui-smoothness-css', $WP_Statistics->plugin_url . 'assets/css/jquery-ui-smoothness' . WP_STATISTICS_MIN_EXT . '.css' );
		wp_enqueue_style( 'jquery-ui-smoothness-css' );
		if( count( $range ) == 0 ) { 
			$range = array( 10, 20, 30, 60, 90, 180, 270, 365 ); 
			$desc  = array( __( '10 Days', 'wp_statistics' ), __( '20 Days', 'wp_statistics' ), __( '30 Days', 'wp_statistics' ), __( '2 Months', 'wp_statistics' ), __( '3 Months', 'wp_statistics' ), __( '6 Months', 'wp_statistics' ), __( '9 Months', 'wp_statistics' ), __( '1 Year', 'wp_statistics' ) );
		}
		if( count( $desc ) == 0 ) {
			$desc = $range;
		}
		$rcount = count( $range );
		$bold = true;
		if( array_key_exists( 'rangestart', $_GET ) ) { $rangestart = $_GET['rangestart']; } else { $rangestart = $WP_Statistics->Current_Date( 'm/d/Y', '-' . $current ); } 
		if( array_key_exists( 'rangeend', $_GET ) ) { $rangeend = $_GET['rangeend']; } else { $rangeend = $WP_Statistics->Current_Date( 'm/d/Y' ); }
		$rangestart_utime = $WP_Statistics->strtotimetz( $rangestart );
		$rangeend_utime = $WP_Statistics->strtotimetz( $rangeend );
		$daysToDisplay = (int)( ( $rangeend_utime - $rangestart_utime ) / 24 / 60 / 60 );
		$today = $WP_Statistics->Current_Date( 'm/d/Y' );
		if( $rangeend != $today || ( $rangeend == $today && ! in_array( $current, $range ) ) ) {
			$current = -1;
		} else {
			$rangestart = $WP_Statistics->Current_Date( 'm/d/Y', '-' . $current );
			$rangeend = $WP_Statistics->Current_Date( 'm/d/Y' );
		}
		echo '<form method="get"><ul class="subsubsub">' . "\r\n";
		echo $pre_extra;
		for( $i = 0; $i < $rcount; $i ++ ) {
			echo '		<li class="all"><a ';
			if( $current == $range[$i] ) { echo 'class="current" '; $bold = false;}
			echo 'href="?page=' . $page . '&hitdays=' . $range[$i] . $extrafields . '">' . $desc[$i] . '</a></li>';
			if( $i < $rcount - 1 ) {
				echo ' | ';
			}
			echo "\r\n";
		}
		echo ' | ';
		echo '<input type="hidden" name="hitdays" value="-1"><input type="hidden" name="page" value="' . $page . '">';
		parse_str( $extrafields, $parse );
		foreach( $parse as $key => $value ) {
			echo '<input type="hidden" name="' . $key . '" value="' . $value . '">';
		}
		if( $bold ) { 
			echo ' <b>' . __( 'Range', 'wp_statistics' ) . ':</b> ';
		}
		else {
			echo ' ' . __( 'Range', 'wp_statistics' ) . ': ';
		}
		echo '<input type="text" size="10" name="rangestart" id="datestartpicker" value="' . $rangestart . '" placeholder="' . __( 'MM/DD/YYYY', 'wp_statistics' ) . '"> ' . __( 'to', 'wp_statistics' ) . ' <input type="text" size="10" name="rangeend" id="dateendpicker" value="' . $rangeend . '" placeholder="' . __( 'MM/DD/YYYY', 'wp_statistics' ) . '"> <input type="submit" value="'.__( 'Go', 'wp_statistics' ).'" class="button-primary">' . "\r\n";
		echo $post_extra;
		echo '</form>' . "\r\n";
		echo '<script>jQuery(function() { jQuery( "#datestartpicker" ).datepicker(); jQuery( "#dateendpicker" ).datepicker(); });</script>' . "\r\n";
	}
function wp_statistics_date_range_selector ( $ page , $ current , $ range = array ( ) , $ desc = array ( ) , $ extrafields = '' , $ pre_extra = '' , $ post_extra = '' ) { GLOBAL $ WP_Statistics ; wp_enqueue_script ( 'jquery-ui-datepicker' ) ; wp_register_style ( 'jquery-ui-smoothness-css' , $ WP_Statistics -> plugin_url . 'assets/css/jquery-ui-smoothness' . WP_STATISTICS_MIN_EXT . '.css' ) ; wp_enqueue_style ( 'jquery-ui-smoothness-css' ) ; if ( count ( $ range ) == 0 ) { $ range = array ( 10 , 20 , 30 , 60 , 90 , 180 , 270 , 365 ) ; $ desc = array ( __ ( '10 Days' , 'wp_statistics' ) , __ ( '20 Days' , 'wp_statistics' ) , __ ( '30 Days' , 'wp_statistics' ) , __ ( '2 Months' , 'wp_statistics' ) , __ ( '3 Months' , 'wp_statistics' ) , __ ( '6 Months' , 'wp_statistics' ) , __ ( '9 Months' , 'wp_statistics' ) , __ ( '1 Year' , 'wp_statistics' ) ) ; } if ( count ( $ desc ) == 0 ) { $ desc = $ range ; } $ rcount = count ( $ range ) ; $ bold = true ; if ( array_key_exists ( 'rangestart' , $ _GET ) ) { $ rangestart = $ _GET [ 'rangestart' ] ; } else { $ rangestart = $ WP_Statistics -> Current_Date ( 'm/d/Y' , '-' . $ current ) ; } if ( array_key_exists ( 'rangeend' , $ _GET ) ) { $ rangeend = $ _GET [ 'rangeend' ] ; } else { $ rangeend = $ WP_Statistics -> Current_Date ( 'm/d/Y' ) ; } $ rangestart_utime = $ WP_Statistics -> strtotimetz ( $ rangestart ) ; $ rangeend_utime = $ WP_Statistics -> strtotimetz ( $ rangeend ) ; $ daysToDisplay = ( int ) ( ( $ rangeend_utime - $ rangestart_utime ) / 24 / 60 / 60 ) ; $ today = $ WP_Statistics -> Current_Date ( 'm/d/Y' ) ; if ( $ rangeend != $ today || ( $ rangeend == $ today && ! in_array ( $ current , $ range ) ) ) { $ current = - 1 ; } else { $ rangestart = $ WP_Statistics -> Current_Date ( 'm/d/Y' , '-' . $ current ) ; $ rangeend = $ WP_Statistics -> Current_Date ( 'm/d/Y' ) ; } echo '<form method="get"><ul class="subsubsub">' . " \r \n " ; echo $ pre_extra ; for ( $ i = 0 ; $ i < $ rcount ; $ i ++ ) { echo '		<li class="all"><a ' ; if ( $ current == $ range [ $ i ] ) { echo 'class="current" ' ; $ bold = false ; } echo 'href="?page=' . $ page . '&hitdays=' . $ range [ $ i ] . $ extrafields . '">' . $ desc [ $ i ] . '</a></li>' ; if ( $ i < $ rcount - 1 ) { echo ' | ' ; } echo " \r \n " ; } echo ' | ' ; echo '<input type="hidden" name="hitdays" value="-1"><input type="hidden" name="page" value="' . $ page . '">' ; parse_str ( $ extrafields , $ parse ) ; foreach ( $ parse as $ key => $ value ) { echo '<input type="hidden" name="' . $ key . '" value="' . $ value . '">' ; } if ( $ bold ) { echo ' <b>' . __ ( 'Range' , 'wp_statistics' ) . ':</b> ' ; } else { echo ' ' . __ ( 'Range' , 'wp_statistics' ) . ': ' ; } echo '<input type="text" size="10" name="rangestart" id="datestartpicker" value="' . $ rangestart . '" placeholder="' . __ ( 'MM/DD/YYYY' , 'wp_statistics' ) . '"> ' . __ ( 'to' , 'wp_statistics' ) . ' <input type="text" size="10" name="rangeend" id="dateendpicker" value="' . $ rangeend . '" placeholder="' . __ ( 'MM/DD/YYYY' , 'wp_statistics' ) . '"> <input type="submit" value="' . __ ( 'Go' , 'wp_statistics' ) . '" class="button-primary">' . " \r \n " ; echo $ post_extra ; echo '</form>' . " \r \n " ; echo '<script>jQuery(function() { jQuery( "#datestartpicker" ).datepicker(); jQuery( "#dateendpicker" ).datepicker(); });</script>' . " \r \n " ; }
This function creates the date range selector 'widget' used in the various statistics pages.
This function creates the date range selector ' widget ' used in the various statistics pages .
// Check to see if there's a range in the URL, if so set it, otherwise use the default. // Now get the number of days in the range. // If the rangeend isn't today OR it is but not one of the standard range values, then it's a custom selected value and we need to flag it as such. // If on the other hand we are a standard range, let's reset the custom range selector to match it. // Output any extra HTML we've been passed after the form element but before the date selector. // Dont' bother adding he date range to the standard links as they're not needed any may confuse the custom range selector. // Output any extra HTML we've been passed after the date selector but before the submit button.