Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- To make the table display properly
- From:
- function parse_analytics($source){
- //echo ($source);
- $resp = _fetch_remote_file($source);
- $resp_result = $resp->results;
- if ( !function_exists('xml_parser_create') )
- trigger_error( "Failed to load PHP's XML Extension. http://www.php.net/manual/en/ref.xml.php" );
- $parser = xml_parser_create();
- if ( !is_resource($parser) ) {
- trigger_error( "Failed to create an instance of PHP's XML parser. http://www.php.net/manual/en/ref.xml.php");
- }
- ?>
- <table class="widefat post fixed" cellspacing="0" cellpadding="0" border=1>
- <thead>
- <tr>
- <th style="width: 50%;">URL</th>
- <th style="width: 10%;">Share Counts</th>
- <th style="width: 10%;">Like Counts</th>
- <th style="width: 10%;">Comment Counts</th>
- <th style="width: 10%;">Total Counts</th>
- <th style="width: 10%;">Click Counts</th>
- </tr>
- </thead>
- <?php
- xml_set_element_handler($parser, "startElementHandler", "endElementHandler");
- xml_set_character_data_handler($parser, "characterDataHandler");
- $status = xml_parse( $parser, $resp_result );
- xml_parser_free( $parser );
- }
- To:
- function parse_analytics($source){
- //echo ($source);
- $resp = _fetch_remote_file($source);
- $resp_result = $resp->results;
- if ( !function_exists('xml_parser_create') )
- trigger_error( "Failed to load PHP's XML Extension. http://www.php.net/manual/en/ref.xml.php" );
- $parser = xml_parser_create();
- if ( !is_resource($parser) ) {
- trigger_error( "Failed to create an instance of PHP's XML parser. http://www.php.net/manual/en/ref.xml.php");
- }
- ?>
- <?php
- xml_set_element_handler($parser, "startElementHandler", "endElementHandler");
- xml_set_character_data_handler($parser, "characterDataHandler");
- $status = xml_parse( $parser, $resp_result );
- xml_parser_free( $parser );
- }
- To load data for every 20 links:
- From:
- function fb_stats_page() {
- ?>
- <div class="wrap" style="font-size:13px;">
- <div class="icon32" id="icon-options-general"><br/></div><h2>Settings for Facebook Share Integration</h2>
- <div id="fb_canvas" style="width:800px;float:left">
- </div>
- <?php
- //The Query
- query_posts( 'post_type=post&posts_per_page=-1&orderby=title&order=ASC');
- //The Loop
- $urls = '';
- if ( have_posts() ) : while ( have_posts() ) : the_post();
- if (get_post_status($post->ID) == 'publish') {
- $urls .= get_permalink().",";
- }
- ?>
- <?php
- endwhile; endif;
- //Reset Query
- wp_reset_query();
- query_posts( 'post_type=page&posts_per_page=-1&orderby=title&order=ASC');
- //The Loop (Fix from RPG84 - http://wordpress.org/support/topic/plugin-facebook-share-new-some-fixes-for-the-statistics-page?replies=1)
- if ( have_posts() ) : while ( have_posts() ) : the_post();
- if (get_post_status($post->ID) == 'publish') {
- $urls .= get_permalink().",";
- }
- endwhile; endif;
- $get_analytics = fb_read_analytics($urls);
- echo "</table>";
- }
- To:
- function fb_stats_page() {
- ?>
- <div class="wrap" style="font-size:13px;">
- <div class="icon32" id="icon-options-general"><br/></div><h2>Settings for Facebook Share Integration</h2>
- <div id="fb_canvas" style="width:800px;float:left">
- </div>
- <table class="widefat post fixed" cellspacing="0" cellpadding="0" border=1>
- <thead>
- <tr>
- <th style="width: 50%;">URL</th>
- <th style="width: 10%;">Share Counts</th>
- <th style="width: 10%;">Like Counts</th>
- <th style="width: 10%;">Comment Counts</th>
- <th style="width: 10%;">Total Counts</th>
- <th style="width: 10%;">Click Counts</th>
- </tr>
- </thead>
- <?php
- //The Query
- query_posts( 'post_type=post&posts_per_page=-1&orderby=title&order=ASC');
- //The Loop
- $urls = '';
- $counturl = '';
- if ( have_posts() ) : while ( have_posts() ) : the_post();
- if (get_post_status($post->ID) == 'publish') {
- if($counturl<='20' ){
- $urls .= get_permalink().",";
- $counturl++;
- } else {
- $get_analytics = fb_read_analytics($urls);
- $urls = get_permalink().",";
- $counturl='';
- }
- }
- ?>
- <?php
- endwhile; endif;
- //Reset Query
- wp_reset_query();
- query_posts( 'post_type=page&posts_per_page=-1&orderby=title&order=ASC');
- //The Loop (Fix from RPG84 - http://wordpress.org/support/topic/plugin-facebook-share-new-some-fixes-for-the-statistics-page?replies=1)
- if ( have_posts() ) : while ( have_posts() ) : the_post();
- if (get_post_status($post->ID) == 'publish') {
- if($counturl<='20' ){
- $urls .= get_permalink().",";
- $counturl++;
- } else {
- $get_analytics = fb_read_analytics($urls);
- $urls = get_permalink().",";
- $counturl='';
- }
- }
- endwhile; endif;
- $get_analytics = fb_read_analytics($urls);
- echo "</table>";
- }
- This will give the counts different colors:
- From:
- function characterDataHandler ($parser, $cdata) {
- global $write;
- if ($write==1){
- echo('<td>'.$cdata.'</td>');
- }
- }
- To:
- function characterDataHandler ($parser, $cdata) {
- global $write;
- if ($write==1){
- if($cdata>"0" && $cdata<"10"){
- echo('<td><font color="#FBB117"><b>'.$cdata.'</b></font></td>');
- }elseif(is_numeric($cdata) && $cdata>="10"){
- echo('<td><font color="#4CC417"><b>'.$cdata.'</b></font></td>');
- }elseif($cdata=="0"){
- echo('<td><font color="#E42217"><b>'.$cdata.'</b></font></td>');
- }else{
- echo('<td>'.$cdata.'</td>');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement