Viewing 13 replies - 1 through 13 (of 13 total)
  • not sure. Diffs are:

    7c7
    < Version: 1.4
    ---
    > Version: 1.5
    10c10
    < Requires WordPress 2.1 or later. Not for use with WPMU.
    ---
    > Requires WordPress 2.7 or later. Not for use with WPMU.
    15a16
    > 1.5   - Kill iframes. Use blog's role/cap system to allow local users to view reports. Thanks to Stefanos Kofopoulos for helping to debug encoding issues.
    132c133
    < 		$hook = add_submenu_page('index.php', __('Blog Stats'), __('Blog Stats'), 'manage_options', 'stats', 'stats_reports_page');
    ---
    > 		$hook = add_submenu_page('index.php', __('Blog Stats'), __('Blog Stats'), 'publish_posts', 'stats', 'stats_reports_page');
    155c156
    < 	if ( isset( $_GET['noheader'] ) )
    ---
    > 	if ( isset( $_GET['dashboard'] ) )
    158,159c159,244
    < 	$day = isset( $_GET['day'] ) && preg_match( '/^\d{4}-\d{2}-\d{2}$/', $_GET['day'] ) ? "&day=$_GET[day]" : '';
    < 	echo "<iframe id='statsreport' frameborder='0' src='https://dashboard.wordpress.com/wp-admin/index.php?page=estats&blog=$blog_id&noheader=true$day'></iframe>";
    ---
    > 	$key = stats_get_api_key();
    > 	$day = isset( $_GET['day'] ) && preg_match( '/^\d{4}-\d{2}-\d{2}$/', $_GET['day'] ) ? $_GET['day'] : false;
    > 	$q = array(
    > 		'noheader' => 'true',
    > 		'proxy' => '',
    > 		'page' => 'stats',
    > 		'key' => $key,
    > 		'day' => $day,
    > 		'blog' => $blog_id,
    > 		'charset' => get_option('blog_charset'),
    > 	);
    > 	$args = array(
    > 		'view' => array('referrers', 'postviews', 'searchterms', 'clicks', 'post', 'table'),
    > 		'numdays' => 'int',
    > 		'day' => 'date',
    > 		'unit' => array(1, 7, 31),
    > 		'summarize' => null,
    > 		'post' => 'int',
    > 		'width' => 'int',
    > 		'height' => 'int',
    > 		'data' => 'data',
    > 	);
    > 	foreach ( $args as $var => $vals ) {
    > 		if ( ! isset($_GET[$var]) )
    > 			continue;
    > 		if ( is_array($vals) ) {
    > 			if ( in_array($_GET[$var], $vals) )
    > 				$q[$var] = $_GET[$var];
    > 		} elseif ( $vals == 'int' ) {
    > 			$q[$var] = intval($_GET[$var]);
    > 		} elseif ( $vals == 'date' ) {
    > 			if ( preg_match('/^\d{4}-\d{2}-\d{2}$/', $_GET[$var]) )
    > 				$q[$var] = $_GET[$var];
    > 		} elseif ( $vals == null ) {
    > 			$q[$var] = '';
    > 		} elseif ( $vals == 'data' ) {
    > 			if ( substr($_GET[$var], 0, 9) == 'index.php' )
    > 				$q[$var] = $_GET[$var];
    > 		}
    > 	}
    > 	if ( isset( $_GET['swf'] ) ) {
    > 		$url = "https://s-ssl.wordpress.com/wp-includes/charts/ofc/open-flash-chart.swf";
    > 	} elseif ( isset( $_GET['chart'] ) ) {
    > 		if ( preg_match('/^[a-z0-9-]+$/', $_GET['chart']) )
    > 			$url = "https://dashboard.wordpress.com/wp-includes/charts/{$_GET['chart']}.php";
    > 	} else {
    > 		$url = "https://dashboard.wordpress.com/wp-admin/index.php";
    > 	}
    >
    > 	$url = add_query_arg($q, $url);
    >
    > 	$get = wp_remote_get($url, array('timeout'=>300));
    >
    > 	if ( is_wp_error($get) || empty($get['body']) ) {
    > 		$http = $_SERVER['https'] ? 'https' : 'http';
    > 		$day = $day ? "&day=$day" : '';
    > 		echo "<iframe id='statsreport' frameborder='0' src='$https://dashboard.wordpress.com/wp-admin/index.php?page=estats&blog=$blog_id&noheader=true$day'></iframe>";
    > 	} else {
    > 		echo convert_post_titles($get['body']);
    > 	}
    > 	if ( isset( $_GET['noheader'] ) )
    > 		die;
    > }
    >
    > function convert_post_titles($html) {
    > 	global $wpdb, $stats_posts;
    > 	$pattern = "<span class='post-(\d+)-link'>.*?</span>";
    > 	if ( ! preg_match_all("!$pattern!", $html, $matches) )
    > 		return $html;
    > 	$posts = get_posts(array(
    > 		'include' => implode(',', $matches[1]),
    > 		'post_type' => 'any',
    > 		'numberposts' => -1,
    > 	));
    > 	foreach ( $posts as $post )
    > 		$stats_posts[$post->ID] = $post;
    > 	$html = preg_replace_callback("!$pattern!", 'convert_post_title', $html);
    > 	return $html;
    > }
    >
    > function convert_post_title($matches) {
    > 	global $stats_posts;
    > 	$post_id = $matches[1];
    > 	if ( isset($stats_posts[$post_id]) )
    > 		return '<a href="'.get_permalink($post_id).'" target="_blank">'.get_the_title($post_id).'</a>';
    > 	return sprintf(__("Post #%d"), $post_id);
    616c701
    < 	dashStats.not( '.dashboard-widget-control' ).load('index.php?page=stats&noheader&' + args );
    ---
    > 	dashStats.not( '.dashboard-widget-control' ).load('index.php?page=stats&noheader&dashboard&' + args );
    797c882,892
    < 	$http = ( !empty( $_SERVER['HTTPS'] ) ) ? 'https' : 'http';
    ---
    > 	$q = array(
    > 		'noheader' => 'true',
    > 		'proxy' => '',
    > 		'page' => 'stats',
    > 		'blog' => $blog_id,
    > 		'key' => stats_get_api_key(),
    > 		'chart' => '',
    > 		'unit' => $options['chart'],
    > 		'width' => $_width,
    > 		'height' => $_height,
    > 	);
    799c894
    < 	$src = clean_url( "$https://dashboard.wordpress.com/wp-admin/index.php?page=estats&blog=$blog_id&noheader=true&chart&unit=$options[chart]&width=$_width&height=$_height" );
    ---
    > 	$url = 'https://dashboard.wordpress.com/wp-admin/index.php';
    801c896,907
    < 	echo "<iframe id='stats-graph' class='stats-section' frameborder='0' style='width: {$width}px; height: {$height}px; overflow: hidden' src='$src'></iframe>";
    ---
    > 	$url = add_query_arg($q, $url);
    >
    > 	$get = wp_remote_get($url, array('timeout'=>300));
    >
    >
    > 	if ( is_wp_error($get) || empty($get['body']) ) {
    > 		$http = $_SERVER['https'] ? 'https' : 'http';
    > 		$src = clean_url( "$https://dashboard.wordpress.com/wp-admin/index.php?page=estats&blog=$blog_id&noheader=true&chart&unit=$options[chart]&width=$_width&height=$_height" );
    > 		echo "<iframe id='stats-graph' class='stats-section' frameborder='0' style='width: {$width}px; height: {$height}px; overflow: hidden' src='$src'></iframe>";
    > 	} else {
    > 		echo $get['body'];
    > 	}

    From the stats.php file:

    Recent changes:
    1.5 – Kill iframes. Use blog’s role/cap system to allow local users to view reports. Thanks to Stefanos Kofopoulos for helping to debug encoding issues.

    I just auto-updated wp-stats to the new version 1.5. It still works, but when I click on ‘Blog stats’ in the wp-dashboard, i get the following error:

    Fatal error: Call to undefined function wp_remote_get() in /home/denhelder/domains/justanexample/public_html/wp-content/plugins/stats/stats.php on line 210

    (justanexample is ofcourse where the sitename is)
    Anyone know what’s wrong?

    ronaldb73: your question does not need to be asked twice.

    Thread Starter efikim

    (@efikim)

    Thanks Eric – since I don’t need either I shan’t bother upgrading.

    andy, it would be nice if a changelog was displayed in the plug-in info so that it wasn’t necessary to download the plug-in to see whether its worth installing!

    Michael Torbert

    (@hallsofmontezuma)

    WordPress Virtuoso

    @efikin You don’t have to download the plugin. You can visit svn.wp-plugins.org and see the files, or you can go to plugins.trac.www.ads-software.com and see the files, diff, anything you want.

    Thread Starter efikim

    (@efikim)

    Thanks but downloading the plugin looks like being easier than using those sites, and I’m not interested in which lines of code have changed (diff) just the functional changes.
    Other plugins I use show the changes in the info pane from the WordPress admin plugins page, either in a specific changelog tab, or in one of the other tabs.

    The problem I’m seeing with the iframe change is that, unlike before, now any local users set as ‘Editor’ can see the reports and they do not need to be logged into www.ads-software.com! I’d still like people who are capable of editing posts to be able to do so without seeing the stats, but with that change I cannot.

    So, in the meantime, I rolled back the change. Is it possible to add a new role/cap so I could change that capability on a per-user basis by using the Role Manager plugin?

    gudlyf: I briefly considered making a stats role for that purpose. Would you like to try patching the plugin so that it works with Role Manager?

    efikim: I like your idea of putting a changelog in the readme so it appears in the plugin’s web page. It’s on my todo list.

    andy:

    These changes seem to work:

    133c133
    < $hook = add_submenu_page(‘index.php’, __(‘Blog Stats’), __(‘Blog Stats’), ‘publish_posts’, ‘stats’, ‘stats_reports_page’);

    > $hook = add_submenu_page(‘index.php’, __(‘Blog Stats’), __(‘Blog Stats’), ‘stats’, ‘stats’, ‘stats_reports_page’);
    136c136
    < $hook = add_submenu_page(‘plugins.php’, __(‘WordPress.com Stats Plugin’), __(‘WordPress.com Stats’), ‘manage_options’, ‘wpstats’, ‘stats_admin_page’);

    > $hook = add_submenu_page(‘plugins.php’, __(‘WordPress.com Stats Plugin’), __(‘WordPress.com Stats’), ‘stats’, ‘wpstats’, ‘stats_admin_page’);
    588a589,593
    >
    > $role = get_role(‘administrator’);
    > if(!$role->has_cap(‘stats’)) {
    > $role->add_cap(‘stats’);
    > }
    599c604
    < if ( ( !$blog_id = stats_get_option(‘blog_id’) ) || !stats_get_api_key() || !current_user_can( ‘manage_options’ ) )

    > if ( ( !$blog_id = stats_get_option(‘blog_id’) ) || !stats_get_api_key() || !current_user_can( ‘stats’ ) )
    676c681
    < if ( !isset($wp_registered_widgets[‘dashboard_stats’]) || !current_user_can( ‘manage_options’ ) )

    > if ( !isset($wp_registered_widgets[‘dashboard_stats’]) || !current_user_can( ‘stats’ ) )

    gudlyf: Good start! Shouldn’t there be a different cap for managing the stats options? I think the manage_options cap is appropriate there. Also, I can’t take the cap away from editors/authors now that they have it. I would call the cap ‘stats_reports’ and give it to editors and authors.

    Good point re: options vs. reports. I made a change that does just that, however I did not make the change to allow editors and authors access to the reports by default the way I have it, since if someone didn’t want those groups to have access, the plugin would force the cap on those users anytime they upgraded the plugin.

    At least this way, when you install or upgrade the plugin, the Administrator definitely gets both caps. If the blog owner wants Editors and Authors to have access, they can make the change in the manager and it won’t reset when the plugin needs to be upgraded or reinstalled.

    133c133
    <               $hook = add_submenu_page('index.php', __('Blog Stats'), __('Blog Stats'), 'publish_posts', 'stats', 'stats_reports_page');
    ---
    >               $hook = add_submenu_page('index.php', __('Blog Stats'), __('Blog Stats'), 'stats_reports', 'stats', 'stats_reports_page');
    136c136
    <       $hook = add_submenu_page('plugins.php', __('WordPress.com Stats Plugin'), __('WordPress.com Stats'), 'manage_options', 'wpstats', 'stats_admin_page');
    ---
    >       $hook = add_submenu_page('plugins.php', __('WordPress.com Stats Plugin'), __('WordPress.com Stats'), 'stats_options', 'wpstats', 'stats_admin_page');
    588a589,596
    >
    >         $role = get_role('administrator');
    >       if(!$role->has_cap('stats_options')) {
    >               $role->add_cap('stats_options');
    >       }
    >       if(!$role->has_cap('stats_reports')) {
    >               $role->add_cap('stats_reports');
    >       }
    599c607
    <       if ( ( !$blog_id = stats_get_option('blog_id') ) || !stats_get_api_key() || !current_user_can( 'manage_options' ) )
    ---
    >       if ( ( !$blog_id = stats_get_option('blog_id') ) || !stats_get_api_key() || !current_user_can( 'stats_reports' ) )
    676c684
    <       if ( !isset($wp_registered_widgets['dashboard_stats']) || !current_user_can( 'manage_options' ) )
    ---
    >       if ( !isset($wp_registered_widgets['dashboard_stats']) || !current_user_can( 'stats_reports' ) )
    Thread Starter efikim

    (@efikim)

    efikim: I like your idea of putting a changelog in the readme so it appears in the plugin’s web page. It’s on my todo list.

    Thanks andy!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘[Plugin: WordPress.com Stats] what has changed in 1.5’ is closed to new replies.