• Resolved Salpetriere

    (@salpetriere)


    Jock on air now is causing the following Javascript error on all admin pages of WordPress.

    SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
    
    ...tion(b){if(a.JSON&&a.JSON.parse)return a.JSON.parse(b+"");var c,d=null,e=m.trim(...

    I’ve deactivated all other plugins and switched themes and can confirm that this plugin is causing the js error.

    I’m using the latest version of WordPress.

    The js error is causing a few other admin functions not to work correctly.

    Is there a fix for this?

    https://wordpress.org/plugins/joan/

Viewing 15 replies - 1 through 15 (of 27 total)
  • Plugin Author ganddser

    (@ganddser)

    Since you’re the first to report this, I’ll have to run some simulations to try an replicate this issue to make sure. No promises on a quick solution as it’s New Years Eve and my office is closed.
    In the meantime this seems like an issue caused by the jQuery version that’s running. One question is your hosting environment?

    Thread Starter Salpetriere

    (@salpetriere)

    Thanks for the response ganddser. No probs with the delay.

    The hosting environment is a shared Apache server running PHP 5.6.

    I’ve read that having mod_sec enabled on the server can cause issues with AJAX. Could that be an issue here?

    Plugin Author ganddser

    (@ganddser)

    We were unable to reproduce the error you reported. Can you provide anymore details about your WP install? Also if possible ask your host to disable mod_sec as it can indeed “cause the server to respond with an HTML page instead of the Ajax response.”

    Thread Starter Salpetriere

    (@salpetriere)

    I’ve been in touch with the hosting provider & they have informed me that it is indeed a development error with the plugin.

    I therefore tested the plugin across multiple hosting environments and can confirm that the error is consistently occurring across each of them.

    Do you know how to identify javascript errors? You’ve got to check the console in your browser dev tools (try using the console tab in Firebug).

    Here’s a screengrab of the error as presented in firebug (site url obscured for privacy) – http://postimg.org/image/tqzc0zegt/

    The error is only present when you are on pages of the WP dashboard. If you look for it on the front end of the site you wont see anything, even when logged in.

    The error is causing other functions not to work in my admin/dashboard. This has been confirmed by deactivating the plugin, at which point the functions begin working again.

    Plugin Author ganddser

    (@ganddser)

    OK, we are still not able to reproduce this error. We have this plugin installed on several of our customers websites and on our own sites as well none of them show this error, all different themes mostly the same Apache hosting environment.

    Let me ask you this:

    Did you modify the plugin in anyway?
    Was this the first time you installed this plugin, and or did you have it’s predecessor (Showtime) installed at anytime before installing Joan?

    Have you tried uninstalling the plugin and remove all Joan entries from your WP database and reinstall it from the plugin directory.
    (Compatibility up to WordPress 4.4.1)

    Thread Starter Salpetriere

    (@salpetriere)

    Thanks for your response.

    Just as a side note, I can rule out mod_sec being an issue here. I have tested disabling it across a number of servers and it makes no difference, the error still occurs.

    My answers to your queries are below.

    Did you modify the plugin in anyway? On the initial site that I experienced the issue I had, yes. When I tested it with other hosting providers though I installed the straight plugin straight from the repository and still experienced the issue.

    Was this the first time you installed this plugin, and or did you have it’s predecessor (Showtime) installed at anytime before installing Joan? On the initial site that I experienced the issue I had Showtime installed previously. When testing with other hosting providers though the Joan plugin was installed without Showtime, same results.

    Have you tried uninstalling the plugin and remove all Joan entries from your WP database and reinstall it from the plugin directory. On the testing sites the plugin was installed directly from the repository on a new WP install, with the same error occurring. How would that help in this instance?

    Thread Starter Salpetriere

    (@salpetriere)

    After posting my previous message I enabled WP_DEBUG and WP_DEBUG_LOG.

    In doing so I’ve been able to identify that the plugin is throwing the following php errors (via wp-content/debug.log).

    The called constructor method for WP_Widget is deprecated since version 4.3.0! Use __construct() instead.

    has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead.

    Further info on these errors can be found here & here.

    It appears the plugin is using outdated WordPress functions and needs to be updated for the latest version. Are you doing your testing for the javascript error on the latest version of WordPress?

    Additionally I’m getting the following error when deactivating then reactivating the plugin.

    The plugin generated 308 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

    Using this tool (with WP_DEBUG enabled), I’ve been able to identify the source of the ‘unexpected output’ error in the plugin code, as below.

    Notice:  Undefined variable: wpdb in /wp-content/plugins/joan/joan.php on line 20
    
    Notice:  Trying to get property of non-object in /wp-content/plugins/joan/joan.php on line 20

    Information on declaring wpdb as a global variable can be found here.

    If required, more information on the ‘unexpected output’ error can be found here.

    I would encourage you to enable WP_DEBUG and WP_DEBUG_LOG in your wp-config file and have a look over the deprecated functions currently being used in the code. There’s quite a few errors with the plugin that need to be resolved.

    Plugin Author ganddser

    (@ganddser)

    Ok Fixed these: The called constructor method… The plugin generated 308, a result of this (Undefined variable: wpdb).

    Only 1 issue when I fix this (has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead.)

    All WP errors a fixed but the Current Schedule disappears, when using the # in place of Use roles and capabilities instead.

    The current schedule shows up again.
    I’m sure it’s something simple I’m missing, can’t seem to see it now.

    Thread Starter Salpetriere

    (@salpetriere)

    Here’s a thread where other users have exemplified how to updated the has_cap function, and another here.

    I see you’ve resolved the ‘unexpected output’ error with the latest update. Thanks for that.

    The javascript error in the admin still persists though. It will be interesting to see whether the resolution of the deprecated function has_cap resolves that issue.

    Also, with the updated version of the plugin you’ve accidentally wrapped each list of shows in the front end program guide with <li class=”joan-schedule”> tags rather than <ul class=”joan-schedule”> tags. Could you fix that up?

    One last thing, any chance we can include my provided code for displaying the programs on air today in the plugin? I’m having to manually include this with each update.

    Plugin Author ganddser

    (@ganddser)

    All deprecated functions no errors, added your “schedule-today function.” If you’re still experiencing the admin error consider trying our hosting service.

    Thread Starter Salpetriere

    (@salpetriere)

    Thanks for the updates ganddser.

    Unfortunately the fix mentioned above for the incorrect list markup wasn’t applied.

    The code that needs to be amended is in joan.php on lines 165 & 179.

    Line 165 needs to be changed to the following,

    $output .= '<ul class="joan-schedule">';

    Line 179 needs to be changed to the following,

    $output .= '</ul>';

    Could you apply these updates? Thanks.

    Plugin Author ganddser

    (@ganddser)

    Done. Thanks for the feedback.

    Thread Starter Salpetriere

    (@salpetriere)

    Thanks ganddser, but the list markup is still incorrect.

    You made the correct changes I mentioned above, but you also changed some li tags (to uls) that needed to stay as is.

    You’ll need to amend the plugin again.

    In joan.php line 176 needs to be changed to the below.

    $output .= '<li><strong>'.$startClock.'</strong> - <strong>'.$endClock.'</strong>: '.$showName.'</li>';

    Also on line 223 I missed a closing ul tag which we’ll need to add, as below.

    $output .= '</ul>';

    Plugin Author ganddser

    (@ganddser)

    Thanks

    Thread Starter Salpetriere

    (@salpetriere)

    Thanks for everything gandsser.

    As you’ve advised, I’d like to look into your hosting. Do you have a test/dev WordPress site set up on it that I could log into and have a look around? I’d like make sure that everything works the way I need it to before moving forward.

Viewing 15 replies - 1 through 15 (of 27 total)

The topic ‘Plugin Causing Javascript Error in WordPress Admin’ is closed to new replies.