function_exists call in function.php

That twentyeleven_setup function, and others like it, are pluggable – meaning that they can be overridden by a child theme. The child theme’s version of a function with that same name will be parsed first, so the parent theme’s version will not be run at all. In TwentyTwelve some functions are not pluggable, but instead … Read more

Check php version before theme activation

As you want to implement the check within your theme files you can use the action after_switch_theme; as you can guess this will activate your theme to perform the check but will switch back to the previous theme if necessary. If the requirements are not fulfilled we’re going to notify the user via an admin … Read more

get product attributes for current product and store it in a variable

get_terms() Retrieves the terms in a given taxonomy or list of taxonomies. What you need is get_the_terms() Retrieves the terms of the taxonomy that are attached to the post. So you can simply replace $brand_terms = get_terms( ‘pa_liquor-brands’ ); with $brand_terms = get_the_terms( $post, ‘pa_liquor-brands’ ); And that should to the trick. You can read … Read more

Do I require the use of nonce?

I think required would mean that “it doesn’t work without it”. It will work, but the question is of security and best practices. Even if it doesn’t seem necessary, it’s better to play in the safe side and do it always. You have to enqueue your JavaScript like bellow, passing PHP values (like the admin … Read more

How to order WP_User_Query results to match the order of an array of user IDs?

Updated: The WP_User_Query class, in WordPress 4.1+, supports it with : ‘orderby’ => ‘include’ Since WordPress 4.7 there’s also support for: ‘orderby’ => ‘login__in’ and ‘orderby’ => ‘nicename__in’ So we no longer need to implement it through a filter, like we did here below. Previous Answer: I wonder if this works for you: add_action( ‘pre_user_query’, … Read more

Hide old attachments from wp media library

You can adjust the attachment query in the media library popup, through the ajax_query_attachments_args filter. Here are two PHP 5.4+ examples: Example #1: Show only attachments that where uploaded during the last 24 hours: /** * Media Library popup * – Only display attachments uploaded during the last 24 hours: */ add_filter( ‘ajax_query_attachments_args’, function( $args … Read more