'ol', 'container_class' => 'ga-ranking', 'before' => '
Authentication Failed
"; echo "" . $e->getMessage() . "
"; } } if ( !empty($ga) ) { $ga->requestReportData( $ga_profile_id, $dimensions, $metrics, $sort_metric, $filter, $start_date, $end_date, $start_index, $max_results ); $transient_key = 'aistear_ga_ranking_' . $ga_profile_id; $transients = get_transient( $transient_key ); if ( $transients === false ) { $rank = 1; $container_class = esc_attr( $container_class ); $transients = '<' . $container . ' class="' . $container_class . '">'; foreach( $ga->getResults() as $result ) { $sbefore = sprintf( $before, $rank ); $transients .= $sbefore . '' . $result->getPagetitle() . ''. $after; $rank++; } $transients .= '' . $container . '>'; set_transient( $transient_key, $transients, 24*60*60 ); } $output = $transients; if (!$echo) { return $output; } echo $output; } } function aistear_ga_ranking_deactivation() { $options = get_option( 'aistear_ga_ranking_options' ); $transient_key = 'aistear_ga_ranking_' . $options[profile_id]; delete_transient( $transient_key ); delete_option( 'aistear_ga_ranking_options' ); } register_deactivation_hook( __FILE__, 'aistear_ga_ranking_deactivation'); /* Widget */ class Aistear_GA_Ranking_WidgetItem extends WP_Widget { function __construct() { $widget_options = array( 'classname' => 'ga-ranking-widget', 'description' => 'Displays the ranking that is based on the data of Google Analytics' ); parent::__construct('aistear_ga_rankig', __('Google Analytics Ranking'), $widget_options); } function widget( $args, $instance ) { extract( $args ); $title = apply_filters( 'widget_title', $instance['title'] ); echo $before_widget; if ( $title ) { echo $before_title . $title . $after_title; } aistear_ga_ranking(); echo $after_widget; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); return $instance; } function form($instance) { $title = esc_attr($instance['title']); ?>