Posts by The Doctor:
Just __return_* It
in Functions, Tips
as WordPress, __return_empty_array, __return_false, __return_null, __return_true, __return_zero
WordPress has a lot of helper functions built into its core. Some of these functions are obvious and some are obscure … and almost every one of them can be easily put to use.
A chat group I was in the other day lead me to looking for a set of these helper functions in the code we were discussing … I didn’t find them. Well, I did find them in use but I did not find where they were defined. Next stop, the WordPress core … and there they were.
Now, as the title may suggest I am referring to the following WordPress core functions:
- __return_true() – returns the Boolean state of true
- __return_false() – returns the Boolean state of false
- __return_zero() – returns a value of zero (0)
- __return_empty_array() – returns an empty array, as in array()
- __return_null() – returns null (or void)
All of these functions have a very similar structure and were implemented at WordPress version 3.0.0, with the exception of `__return_null` which will be introduced at WordPress version 3.4 per their definitions in ‘../wp-includes/functions.php‘. For example, here is the code for `__return_true`:
function __return_true() {
return true;
}
Why are these great helper functions? Simple really … they provide easy to remember, and very useful, callback functions for filters. You should not need to write your own return functions now, just __return_* it instead.
Tri-Account Security
as accounts, how-to, security, WordPress
Tri-Account Security and protecting your self-hosted WordPress installation.
No-Title Sticky Post-Format Posts?!
in Tips
as add_theme_support, post-formats, post_class, sticky posts, WordPress
Making sure to test all of the combinations these three items can create.
Filtering WP Title
as add_filter, get_bloginfo, how-to, is_frontpage, is_home, WordPress, wp_title
A recent recommendation, starting with WordPress 3.3, from the WordPress Theme Review Team reads: Themes are REQUIRED to use wp_title filter to filter wp_title() (RECOMMENDED), or pass argument to wp_title() (OPTIONALLY), in order to modify document title content This has been discussed, worked through, and for the most part sorted out … but there doesn’t [...]
Enqueue Plugin Custom Stylesheet
in Tips
as add_action, how-to, is_readable, plugin_dir_path, plugin_dir_url, WordPress, wp_enqueue_scripts, wp_enqueue_styles
Now that is a bit of a handful to grab onto … but the code and concept is relatively straight forward and easy to implement. As I was recently updating some of my plugins in preparation for WordPress 3.3 I decided to better implement the style elements being used in these plugins. The current best-practice [...]
Start Using WordPress Beta
as beta, how-to, WordPress
The basics, as a general guideline, on how to start using the latest WordPress beta version.
Do Not Display Comments HTML Tags
A standard function found in many themes is the comment_form. This is a core function of WordPress that produces a standard comment form generally consisting of text fields for the name and email address and a textarea for the actual comment. You will also find there are some standard text outputs produced by this function [...]
Dynamic Copyright Revisited
in Tips
as apply_filters, bns_dynamic_copyright, dynamic_copyright, WordPress
An updated version of the dynamic copyright function found in BuyNowShop.com themes by Cais.



Remove Comment Form Website Section
in Functions, Tips
as add_filter, comment_form, how-to, WordPress
From time to time an interesting Five-Minute-FixTM comes along that sparks a great reason to add another WordPress Tips post. The idea for this tip started with this comment at BuyNowShop.com: … how to remove the website section when leaving a reply/comment … The solution may be obvious to some and can be readily derived [...]