How to make my plugin code die gracefully

Fatal errors point to bad syntax, or bad naming conventions. WordPress does a good job of not activating plugins that throw fatal errors. However, once a plugin is activated, all bets are off. If you’ve created a function or a class, it’s best to follow good naming conventions and namespace properly. For example, a function … Read more

Error handling a plugin with exceptions

You can also extend expections and then catch only those that you throw. For example: function do_add_my_pws_exceptions() { class PWS_Exception extends Exception {} class PWS_Init_Exception extends PWS_Exception {} } add_action(‘plugins_loaded’, ‘do_add_my_pws_exceptions’); Of course, you should be certain the user is running at least version 5 of PHP by having your theme of plugin activation do … Read more

Unable to Upload Images on Local Windows Install

After trying many things with permissions, I found my problem. I uses a plugin called Duplicator to move WordPress installs around from server to server, it handles changing URLS’s and Paths. So in settings => Media => Store uploads in this folder it was setting the Full Filepath to my Uploads folder. I changed it … Read more

Accessing GET variable named ‘error’

Your problem is that you’re using Reserved Terms. error is a reserved term, you can’t use it. To get around this, you could intercept the request early, and do a redirect, changing the query parameters in the process. For example, handling a link get parameter: add_action( ‘wp’ , ‘reserved_term_intercept’ ); function reserved_term_intercept(){ global $wp_query; if( … Read more

Can a plugin still effect a site even after deletion?

Yes, a plugin that does not properly clean up after itself can continue to affect your site even after deletion. It can leave stuff behind in the database, or make alterations to your .htaccess file, which is probably the case in your scenario. You might need to restore your .htaccess file – look here for … Read more

Debugging with functions.php

You can use var_dump() instead of print_r() – you get the type and the value of the variable and it will also work when your variable holds FALSE or NULL. print_r( false ); # doesn’t output anything var_dump( false ); # output: bool(false) print_r( NULL ); # doesn’t output anything var_dump( NULL ); # output: … Read more

PHP notice coming from the WordPress core?

1) Looks like you are using the Visual Composer Plugin which is a legacy version which has a deprecated function. If you are using old version upgrade your Visual Composer plugin to the latest version which is 5.0.1. 2) Another case might be your are using a theme which might be using Visual Composer as … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)