• Resolved hjyun77

    (@hjyun77)


    My blog suffered a fatal HTTP 500 error once updating this plugin’s into new version.
    After rolling back my 1-day-before DB, I accessed my dashboard, deleted the previous version, and installed the new version.

    As a result, I faced a warning sign on top of Plugin page, which says :
    “Parse error: syntax error, unexpected ‘[‘ in /home/hosting_users/hjyun77/www/wp-content/plugins/wordpress-popular-posts/admin/class-wordpress-popular-posts-admin.php on line 858 ”

    I’m using other plugins as follows:
    Advanced Comments Widget
    Advanced Database Cleaner
    Akismet Anti-Spam
    Clean Up Booster (deactivated when regenetateThumbnail installed)
    Contact Form 7
    FancyBox for WordPress
    Google Analytics for WordPress by MonsterInsights
    Jetpack by WordPress.com
    WP Smush
    WP-Mail-SMTP
    YARPP Experiments
    Yet Another Related Posts Plugin

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi there!

    Thanks for the detailed report!

    Please try this:

    1. Go to Plugins > Editor and select WordPress Popular Posts from the dropwdown at your right.
    2. Click on wordpress-popular-posts/admin/class-wordpress-popular-posts-admin.php to edit this file.
    3. Find: $theme->colors = ['#333', '#999', '#881111', '#a80000']; and change it to: $theme->colors = array('#333', '#999', '#881111', '#a80000');
    4. Hit the Update file button to save changes.

    Please report back the results.

    • This reply was modified 7 years, 2 months ago by Hector Cabrera. Reason: Wrapped code in backticks

    Ok how do I do that without being able to gain access to the WordPress backend?

    Plugin Author Hector Cabrera

    (@hcabrera)

    Just noticed you guys might not have access to your dashboard either. So please follow these instructions to disable WPP, then reinstall it (but don’t enable it yet!) and follow the instructions from my previous comment. If you guys can confirm that the above fix works, I’ll push an update immediately.

    • This reply was modified 7 years, 2 months ago by Hector Cabrera.
    • This reply was modified 7 years, 2 months ago by Hector Cabrera. Reason: Fixed typo

    I made the edit suggested above and got a new error when activating the plugin:

    Plugin could not be activated because it triggered a fatal error.
    Parse error: syntax error, unexpected T_RETURN, expecting ‘)’ in website/wp-content/plugins/wordpress-popular-posts/admin/class-wordpress-popular-posts-admin.php on line 860

    Plugin Author Hector Cabrera

    (@hcabrera)

    Thanks @mountain-hiker-1!

    Could you please:

    • Share your PHP version.
    • Share a screenshot of the edited part of the file.

    I have an old GoDaddy account with shared hosting using PHP Version 5.3. I cannot upgrade to newer PHP unless I move to a new hosting plan. I plan to do that when I renew in October.

    I don’t have screenshot but saved edit looks like this:
    Edit Plugins
    Editing wordpress-popular-posts/admin/class-wordpress-popular-posts-admin.php (inactive)

    // Fallback, just in case

    $theme = new stdClass;
    $theme->colors = array(‘#333’, ‘#999’, ‘#881111’, ‘#a80000’);

    return $theme;

    Plugin Author Hector Cabrera

    (@hcabrera)

    I’m pretty sure it’s the PHP version. I’m running 5.6.30 on my laptop and during all this time (been working on version 4.0 for over a year now) never had this problem.

    Anyways, please try this:

    1. Let’s replace this entire block of code:
      // Fallback, just in case
      $theme = new stdClass;
      $theme->colors = ['#333', '#999', '#881111', '#a80000'];
      
      return $theme;

      with:

      // Fallback, just in case
      return array( '#333', '#999', '#881111', '#a80000' );
    2. Next, right above, change:
      if ( isset($_wp_admin_css_colors[ $color_scheme]) ) {
          return $_wp_admin_css_colors[ $color_scheme];
      }

      with:

      if ( isset($_wp_admin_css_colors[ $color_scheme]) && isset($_wp_admin_css_colors[ $color_scheme])->colors ) {
          return $_wp_admin_css_colors[ $color_scheme]->colors;
      }
    3. Finally, a few lines above find:
      var wpp_chart_views_color = '<?php echo $color_scheme->colors[2]; ?>';
      var wpp_chart_comments_color = '<?php echo $color_scheme->colors[3]; ?>';

      and change it to:

      var wpp_chart_views_color = '<?php echo $color_scheme[2]; ?>';
      var wpp_chart_comments_color = '<?php echo $color_scheme[3]; ?>';
    4. Hit the Update file button to save changes.

    Please report back the result.

    I made the edit suggested above and got a new error when activating the plugin:

    Plugin could not be activated because it triggered a fatal error.
    Parse error: syntax error, unexpected T_OBJECT_OPERATOR in website/wp-content/plugins/wordpress-popular-posts/admin/class-wordpress-popular-posts-admin.php on line 849

    Plugin Author Hector Cabrera

    (@hcabrera)

    Damn, I made a small mistake while typing that line here (that’s what I get for replying from my phone).

    Please change:

    if ( isset($_wp_admin_css_colors[ $color_scheme]) && isset($_wp_admin_css_colors[ $color_scheme])->colors ) {
        return $_wp_admin_css_colors[ $color_scheme]->colors;
    }

    to:

    if ( isset($_wp_admin_css_colors[ $color_scheme]) && isset($_wp_admin_css_colors[ $color_scheme]->colors) ) {
        return $_wp_admin_css_colors[ $color_scheme]->colors;
    }

    Success! I made the correction above. The plugin activated with no errors and my blog is again displaying popular posts.
    Thank you!

    Plugin Author Hector Cabrera

    (@hcabrera)

    Finally! Hahahah Thank you for your kind help and patience. I’m sure other users will appreciate it as much as I do.

    Alright, in the following minutes I’ll push a new update with this fix and other minor changes. Please update as soon as you can.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Fatal error occurred’ is closed to new replies.