Support » Plugin: Xhanch - My Twitter » Many errors: PHP Notices & Incorrectly Enqueued Scripts.Please debug.

  • As some people have reported in previous support threads, there are some errors in the plugin that need to be fixed.

    All WordPress plugin developers should use WP_DEBUG to prevent easily fixable errors before releasing them to the WordPress plugin directory. https://codex.wordpress.org/Debugging_in_WordPress

    We run WP_DEBUG with logging on all of our test sites, and in two minutes this plugin filled up our debug.log with many copies of the following errors as soon as we activated it:

    PHP Notice: Undefined variable: acc_lst in /XXXXXXXX/wp-content/plugins/xhanch-my-twitter/xhanch-my-twitter.php on line 149
    PHP Notice: wpdb::escape is <strong>deprecated</strong> since version 3.6! Use wpdb::prepare() or esc_sql() instead. in /XXXXXXXX/wp-includes/functions.php on line 3391
    PHP Notice: wp_enqueue_script was called <strong>incorrectly</strong>. Scripts and styles should not be registered or enqueued until the <code>wp_enqueue_scripts</code>, <code>admin_enqueue_scripts</code>, or <code>login_enqueue_scripts</code> hooks. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.3.) in /XXXXXXXX/wp-includes/functions.php on line 3560
    PHP Notice: get_bloginfo was called with an argument that is <strong>deprecated</strong> since version 2.2! The <code>siteurl</code> option is deprecated for the family of <code>bloginfo()</code> functions. Use the <code>url</code> option instead. in /XXXXXXXX/wp-includes/functions.php on line 3508
    PHP Notice: Undefined index: sql_crt in /XXXXXXXX/wp-content/plugins/xhanch-my-twitter/admin/setting.php on line 668

    Please see the WordPress standards for enqueueing scripts and styles.

    wp_enqueue_script() – https://codex.wordpress.org/Function_Reference/wp_enqueue_script
    wp_enqueue_style() – https://codex.wordpress.org/Function_Reference/wp_enqueue_style

    If you see from the examples the relevant commands are inside functions, and are enqueued by using add_action() to hook the function that enqueues your scripts/styles at the right time in the loading process. See this for a rundown of the order of action hooks in a WordPress page load: https://codex.wordpress.org/Plugin_API/Action_Reference

    This explains how to properly add the action for your enqueueing function(s) to the hook ‘wp_enqueue_scripts’: https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts

    Since your scripts are only used in the admin, you should use ‘admin_enqueue_scripts’: https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts

    Also, you’ll want to see the section “Example: Target a Specific Admin Page” and make sure it’s only added to your plugin’s settings page.

    I would also recommend Googling how to properly enqueue scripts and styles as there are some good tutorials out there.

    Additionally, these are some annoying features I could do with out:

    • Besides having a lot of errors, the plugin creates its own menu. That is completely unnecessary. Unless you have an extremely essential plugin with many submenus, having your own menu is just being a bit rude and clutters up the Admin UI.
    • The settings page has a banner ad right at the top. Is that really necessary? Seems like there could be a less spammy way to handle that.
    • Upon deactivation and deleting the plugin through the WordPress Dashboard, the plugin does not clean up after itself on uninstall. There is still an ‘xhc-xmt’ directory within the ‘wp-content’ directory, and three new tables in the database that were added but not deleted. Things like this should be cleaned up so as not to clutter the file structure or bloat the database. Little remnants like this add up over time and affect a site’s performance.

    I’ll be honest..after that, we didn’t even want to check if the plugin actually did what it claimed to do. (Which is unfortunate, because it looked promising.) When I see a plugin that starts firing off so many errors, I’m pretty much done at that point. In 2 minutes the plugin had generated 35kb of errors in the debug.log. Do the math…that is going to add up quickly and can amount to over 20MB of errors per day.

    Lately we’ve been finding more and more plugins from developers that don’t seem to be even making an attempt to properly debug their plugins or read up on WordPress coding standards. WP_DEBUG…WP_DEBUG. Please!!

    People have posted many support threads going back over a year, and the same errors are in still in the code, uncorrected even after your update this month.

    Please fix the errors in this plugin.

    https://wordpress.org/plugins/xhanch-my-twitter/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Many errors: PHP Notices & Incorrectly Enqueued Scripts.Please debug.’ is closed to new replies.