WordPress.org

Ready to get started?Download WordPress

Forums

WP Statistics
[resolved] Errors Everywhere! (9 posts)

  1. Fischy
    Member
    Posted 7 months ago #

    After the last two or three updates i get errors in Admin Panel head.

    Warning: Invalid argument supplied for foreach() in /var/.../wp-content/plugins/wp-statistics/wp-statistics.php on line 102 Call Stack: 0.0004 746776
    1. {main}() /var/.../wp-admin/index.php:0 0.0007 872576
    2. require_once('/var/.../wp-admin/admin.php') /var/customers/webs/Fischy/wp-admin/index.php:10 0.4535 83185576
    3. require('/var/.../wp-admin/menu.php') /var/.../wp-admin/admin.php:120 0.458..........

    and much more :( please fix it!

    http://wordpress.org/plugins/wp-statistics/

  2. Greg Ross
    Member
    Plugin Author

    Posted 7 months ago #

    What version of WordPress are you running?

  3. Fischy
    Member
    Posted 7 months ago #

    i use version 3.8

  4. Greg Ross
    Member
    Plugin Author

    Posted 7 months ago #

    Are you using any plugins that change the roles/capabilities of WP?

    It looks like something has messed with WP's internal roles and created an invalid entry.

    Edit wp_statistics.php, go down to line 102, there should be a code block like:

    function wp_statistics_validate_capability( $capability ) {
    
    		global $wp_roles;
    
    		$role_list = $wp_roles->get_names();
    
    		foreach( $wp_roles->roles as $role ) {
    
    			$cap_list = $role['capabilities'];
    
    			foreach( $cap_list as $key => $cap ) {
    				if( substr($key,0,6) != 'level_' ) {
    					$all_caps[$key] = 1;
    				}
    			}
    		}
    
    		if( $all_caps[$capability] == 1 ) { return $capability; }
    
    		return 'manage_options';
    
    	}

    Replace it with:

    function wp_statistics_validate_capability( $capability ) {
    
    		global $wp_roles;
    
    		$role_list = $wp_roles->get_names();
    
    		foreach( $wp_roles->roles as $role ) {
    
    			$cap_list = $role['capabilities'];
    
    			if( is_array( $cap_list ) ) {
    
    				foreach( $cap_list as $key => $cap ) {
    					if( substr($key,0,6) != 'level_' ) {
    						$all_caps[$key] = 1;
    					}
    				}
    			}
    		}
  5. Fischy
    Member
    Posted 7 months ago #

    okay i'll try it.

    give you a feedback later :)

    btw. i dont use a plugin for change the roles ... hmmmpf

  6. Fischy
    Member
    Posted 7 months ago #

    now i created a fatal error o.o and the plugin is automatically deactivated T_T

    could it be .... i tested a plugin for role change a long time ago ... are there some pieces of code hidden?

  7. Greg Ross
    Member
    Plugin Author

    Posted 7 months ago #

    Sorry, copy and paste error on the second code snipit:

    function wp_statistics_validate_capability( $capability ) {
    
    		global $wp_roles;
    
    		$role_list = $wp_roles->get_names();
    
    		foreach( $wp_roles->roles as $role ) {
    
    			$cap_list = $role['capabilities'];
    
    			if( is_array( $cap_list ) ) {
    
    				foreach( $cap_list as $key => $cap ) {
    					if( substr($key,0,6) != 'level_' ) {
    						$all_caps[$key] = 1;
    					}
    				}
    			}
    		}
    
    		if( $all_caps[$capability] == 1 ) { return $capability; }
    
    		return 'manage_options';
    
    	}
  8. Fischy
    Member
    Posted 7 months ago #

    Dude ... you are awesome :) thank you 1000 times

    Karma +1000000

    You safed my day!

  9. shahrachna13
    Member
    Posted 6 months ago #

    thank you Greg

    It is really good stuff.

    Thank you very much :)

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.