Plugin: register custom post types, child ready and performance best practices

A few thoughts on your code The conditional function_exists() actually will never work because plugins are loaded first, then child theme functions then parent theme functions. You can just drop these conditional checks. The function_exists() function is basically meant for parent themes and allows for a function to be overridden by plugins or child themes … Read more

What is the proper way to include Bootstrap when executing a shortcode

I also find the typical practice of queuing globally or from inside shortcodes problematic. I had a similar challenge with implementing code highlight on my site — I only wanted scripts and style to load as necessary. I ended up checking content for <pre> tag as condition to output: {% if ‘<pre>’ in get_the_content() %} … Read more

How To Change Post Author Default?

You just create must-use plugin for your multisite instalation (https://codex.wordpress.org/Must_Use_Plugins), hook to post save action there (https://codex.wordpress.org/Plugin_API/Action_Reference/save_post), and inside action callback check if current user is admin/super admin (https://codex.wordpress.org/Function_Reference/is_super_admin), if so, you find current blog user with ‘author’ role (https://codex.wordpress.org/Function_Reference/get_users) and update post (https://codex.wordpress.org/Function_Reference/wp_update_post) with his ID as author ID. At least it is first, … Read more

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

Trying to understand order and frequency of action hooks firing

I’m not sure if you mean some custom login dialog, but let’s do some logging when we are on the wp-login.php page, where we fill the login form and press enter: #—————– # Page Load #1 #—————– 2015-11-24: 14:45:41 — $_SERVER: Array ( [REQUEST_URI] => /wp-login.php [SCRIPT_NAME] => /wp-login.php [DOCUMENT_URI] => /wp-login.php [REDIRECT_STATUS] => 200 … Read more