Editing google analycator wordpress plug in

hari ini di sekre siem ngedit visitor counter google analytic butuh waktu 2 jam
permalsahanya adalah visitor cuma menampilkan total pengunjung hari ini dan keinginan saya adalah menampilkan seluruh pengunjung di website ini

kita mulai saja
plugin wordpress http://wordpress.org/extend/plugins/google-analyticator/

kita edit google-analytics-stats-widget.php
langsung copas saja
soalnya saya lupa baris keberapa yang saya edit
'widget_google_stats', 'description' => __("Displays Stat Info From Google Analytics", 'google-analyticator') );
$control_ops = array('width' => 400, 'height' => 400);
$this->WP_Widget('googlestats', __('Google Analytics Stats', 'google-analyticator'), $widget_ops, $control_ops);
}

function widget($args, $instance) {
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
$acnt = $instance['account'];
$timeFrame = empty($instance['timeFrame']) ? '1' : $instance['timeFrame'];
$pageBg = empty($instance['pageBg']) ? 'fff' : $instance['pageBg'];
$widgetBg = empty($instance['widgetBg']) ? '999' : $instance['widgetBg'];
$innerBg = empty($instance['innerBg']) ? 'fff' : $instance['innerBg'];
$font = empty($instance['font']) ? '333' : $instance['font'];
$line1 = empty($instance['line1']) ? 'Unique' : $instance['line1'];
$line2 = empty($instance['line2']) ? 'Visitors' : $instance['line2'];

# Before the widget
echo $before_widget;

# The title
if ( $title )
echo $before_title . $title . $after_title;

# Make the stats chicklet
echo '';
$this->initiateBackground($pageBg, $font);
$this->beginWidget($font, $widgetBg);
$this->widgetInfo($this->getUniqueVisitors($acnt, $timeFrame), $line1, $line2, $innerBg, $font);
$this->endWidget();

# After the widget
echo $after_widget;
}

function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = strip_tags(stripslashes($new_instance['title']));
$instance['account'] = strip_tags(stripslashes($new_instance['account']));
$instance['timeFrame'] = strip_tags(stripslashes($new_instance['timeFrame']));
$instance['pageBg'] = strip_tags(stripslashes($new_instance['pageBg']));
$instance['widgetBg'] = strip_tags(stripslashes($new_instance['widgetBg']));
$instance['innerBg'] = strip_tags(stripslashes($new_instance['innerBg']));
$instance['font'] = strip_tags(stripslashes($new_instance['font']));
$instance['line1'] = strip_tags(stripslashes($new_instance['line1']));
$instance['line2'] = strip_tags(stripslashes($new_instance['line2']));

return $instance;
}

function form($instance) {
//Defaults
$instance = wp_parse_args( (array) $instance, array('title'=>'', 'account'=>'', 'timeFrame'=>'1', 'pageBg'=>'fff', 'widgetBg'=>'999', 'innerBg'=>'fff', 'font'=>'333', 'line1'=>'Unique', 'line2'=>'Visitors') );

$title = htmlspecialchars($instance['title']);
$acnt = htmlspecialchars($instance['account']);
$timeFrame = htmlspecialchars($instance['timeFrame']);
$pageBg = htmlspecialchars($instance['pageBg']);
$widgetBg = htmlspecialchars($instance['widgetBg']);
$innerBg = htmlspecialchars($instance['innerBg']);
$font = htmlspecialchars($instance['font']);
$line1 = htmlspecialchars($instance['line1']);
$line2 = htmlspecialchars($instance['line2']);

$accounts = array();

# Get the current memory limit
$current_mem_limit = substr(ini_get('memory_limit'), 0, -1);

# Check if this limit is less than 96M, if so, increase it
if ( $current_mem_limit checkLogin();

# Get a list of accounts
$accounts = $stats->getAnalyticsAccounts();

# Output the options
echo '

';
# The list of accounts
echo '

';
# Time frame
echo '

';
# Page background
echo '

';
# Widget background
echo '

';
# Inner background
echo '

';
# Font color
echo '

';
# Text line 1
echo '

';
# Text line 2
echo '

';
}

/**
* This function is used to display the background color behind the widget. This is necessary
* for the Google Analytics text to have the same background color as the page.
*
* @param $font_color - Hexadecimal value for the font color used within the Widget (does not effect "Powered By Google Analytics Text"). This effects border color as well.
* @param $page_background_color - Hexadecimal value for the page background color
* @return void
**/
function initiateBackground($page_background_color = 'FFF', $font_color = '000')
{
echo '
';
echo '

';
}

/**
* This function starts the widget. The font color and widget background color are customizable.
*
* @param $font_color - Hexadecimal value for the font color used within the Widget (does not effect "Powered By Google Analytics Text"). This effects border color as well.
* @param $widget_background_color - Hexadecimal value for the widget background color.
* @return void
**/
function beginWidget($font_color = '000', $widget_background_color = 'FFF')
{
echo '

';
}

/**
* This function encases the text that appears on the right hand side of the widget.
* Both lines of text are customizable by each individual user.
*
* It also displays the visitor count that was pulled from the user's Google Analytics account.
*
* @param $visitor_count - Number of unique visits to the site pulled from the user's Google Analytics account.
* @param $line_one - First line of text displayed on the right hand side of the widget.
* @param $line_two - Second line of text displayed on the right hand side of the widget.
* @param $inner_background_color - Hexadecimal value for the background color that surrounds the Visitor Count.
* @param $font_color - Hexadecimal value for the font color used within the Widget (does not effect "Powered By Google Analytics Text"). This effects border color as well
* @return void
**/
function widgetInfo($visitor_count, $line_one = 'Unique', $line_two = 'Visitors', $inner_background_color = 'FFF', $font_color = '000')
{

echo '

';

echo '

';

}

/**
* The function is used strictly for visual appearance. It also displays the Google Analytics text.
*
* @return void
**/
function endWidget()
{
// This closes off the widget.
echo '

'. $visitor_count . '
' . $line_one . '
' . $line_two . '

';

// The following is used to displayed the "Powered By Google Anayltics" text.
echo '

Powered By Google Analytics

';
}

/**
* Grabs the cached value of the unique visits for the previous day
*
* @param account - the account to get the unique visitors from
* @param time - the amount of days to get
* @return void
**/
function getUniqueVisitors($account, $time = 1)
{
# Get the value from the database
$visits = maybe_unserialize(get_option('google_stats_visits_' . $account));

# Check to make sure the timeframe is an int and greater than one
$time = (int) $time;
if ( $time ( time() - 7200 ) )
return $visits['unique'];

}

# If here, the call has not been made or it is expired

# Get the current memory limit
$current_mem_limit = substr(ini_get('memory_limit'), 0, -1);

# Check if this limit is less than 96M, if so, increase it
if ( $current_mem_limit setAccount($account);

# Get the latest stats
$before = date('Y-m-d', strtotime('-' . $time . ' days'));
$yesterday = date('Y-m-d', strtotime('-1 day'));
$uniques = number_format($stats->getMetric('ga:entrances', $before, $yesterday));

# Store the array
update_option('google_stats_visits_' . $account, array('unique'=>$uniques, 'lastcalled'=>time()));

# Return the visits
return $uniques;
}

}// END class

/**
* Register Google Analytics Stat Widget.
*/
function GoogleStatsWidget_init() {
register_widget('GoogleStatsWidget');
}

add_action('widgets_init', 'GoogleStatsWidget_init');
?>

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: