How to fix Uninitialized string offset: error on a checkbox in WP Settings API

Most likely your $options is a string and not an array. It is always better to validate that the $options are in the format you are expecting especially in development time when you are likely to switch formats and too lazy to clean the DB when doing that. something like if (!isset($options[‘hide_avatar’])) $options[‘hide_avatar’] = 0; … Read more

List $wp_admin_bar menu items (debug)

You can use error_log() and print_r(): add_action( ‘wp_footer’, ‘wpse_debug_toolbar’ ); function wpse_debug_toolbar() { global $wp_admin_bar; error_log( print_r( $wp_admin_bar, true ) ); } Note that when using print_r() we’ve set the second parameter $return to true so that the results are returned and not echo’d.

Same log message keeps on printing to debug.log file thousand of times

OK, as far as I understand, you’ve put this code: $debug_log = “DEBUG-debug log”; trigger_error($debug_log); //OR error_log($debug_log); directly in your functionsphp` file. It means, that this code will be executed (so new log item will be added to log file) every time the functions.php file is loaded – so during every request to your WP. … Read more

WordPress: Adding Security

Yes, basically debug.log, but without deny, with 404 Yes, that directive will serve a “404 Not Found” when attempting to request debug.log. |log? However, because of the ? in the above regex, it will also block debug.lo. Is that intentional? In fact, if that is intentional then you could simply remove the g? part – … Read more

Notice: Undefined index: suppress_filters

If $query->query_vars[‘suppress_filters’] is not set you will get that message. Use empty($query->query_vars[‘suppress_filters’]) instead of false == $query->query_vars[‘suppress_filters’] ) or use $query->get(‘suppress_filters’) like this false == $query->get(‘suppress_filters’). Untested (minimally tested) but I believe either of those should give you the same results minus the notice.

Using debug log in production, is that a security concern?

I would consider it a security concern if everyone is able to view the debug.log file from the browser. It could reveal e.g. paths, plugins and their problems. There are though ways to restrict access to it via Nginx or Apache. Another problem I’ve seen with logging to debug.log on production sites is that it’s … Read more

Undefined constant with debug set to true

You have a lot of issues here. Stay away from defining globals and constants if you can. The global scope is an evil place to be. WordPress has made a huge mess of the global scope already, don’t make it a bigger mess than it already is. You can make use a static variable inside … Read more

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