WordPress check box unchecked on null value ternary operator [plugin development]

checked() only checks if the passed first and second parameters match. It doesn’t do any array key checking, so you need to do it yourself before using the function to avoid errors. <?php global $options; $enabled = ( isset( $options[‘enable’] ) ) ? $options[‘enable’]: ”; ?> <input name=”settings[‘enable’]” type=”checkbox” id=”” value=”1″ <?php checked( $enabled, 1 … Read more

How to get the id dynamically to store cookies

If you want the ID of the current post outside of the loop, you can use get_queried_object_id(). Just make sure to check is_singular() first, or you could end up storing IDs of things other than posts. This could cause problems if there’s overlap with post IDs. I’d share the amended code with those changes, but … Read more

Support Gallery link to pages

What about using Page Links To? Install this plugin, go to the edit screen of the post “Project Management” and then link that post to any page you want. That way you can redirect the post to any page you want. Not a perfect solution but may work for your setup.

How to make Multisite global login that redirects to correct subsite after login

I just tested this on my local with a fresh subdmoain setup. Here’s my setup: Created subdomain.test Added site: demo1.subdomain.test with the admin user demo1 Added site: demo2.subdomain.test with the admin user demo2 Now, if I go to http://subdomain.test/wp-login.php and login, I get the following results: User demo1 logs in to http://subdomain.test/wp-login.php and is redirected … Read more

For each loop will not append to the_content hook

Filter should modify the given value and return it. It should not print anything. But your foreach loop does exactly opposite – it prints its output and doesn’t append anything to result. So when you use it to append its result to the content, it prints its result and doesn’t return anything – so nothing … Read more

Eliminate Render blocking CSS?

Generally you can’t impact when and how your plugins are loading their own stylesheets. Messing around with that will usually mean you can never update because it’ll reset all your work. That’s the trade off of using plugins – you lose control over some things that impact your performance, accessiblity, and validation. Without astronomical budgets … Read more