PHP code in page template vs functions

In spite of no ‘official’ answers, this question is still rather popular, so a year later I will post my solidified thoughts on this. What led to this question is the experience of code working in some places, and not in others. For instance, why was I having to wrap code within a function in … Read more

Enforcing password complexity

Well, ended up fixing this after hours of banging my head against ones keyboard. Fixed by making the first parameter of my hooked function a value instead of a reference – curious when nearly all hooks in wordpress pass the error object by reference! function validatePasswordReset( &$errors, $userData ) { return validateComplexPassword( $errors ); } … Read more

How to add a .php file to WordPress

What you can do is this: Put up.php in your active theme’s folder, and put this line at the top of your up.php file: <?php /* Template Name: Up */ ?> Create a page called Up in your WordPress Dashboard, then on the right side of the edit page screen, set the Template to ‘Up’. … Read more

WordPress Themes and PHP unit

When it comes to unit testing themes, it’s a small jungle. I read on Make WordPress Core that things are changing (http://make.wordpress.org/core/2013/08/06/a-new-frontier-for-core-development/). I searched for blogs linking to that specific post in hope to find some useful. Found this: http://ben.lobaugh.net/blog/84669/how-to-add-unit-testing-and-continuous-integration-to-your-wordpress-plugin that looks promising. Note that it focuses on plugin testing, but useful for theme unit … Read more

esc_attr() right way and use

No you don’t need esc_attr() function to print out fixed static text. You only need it to print out dynamic or generated text, so that if the attributes have any special characters that may break your HTML, esc_attr will escape that properly. In your particular case, you can just write: echo ‘<label><input type=”checkbox” id=”custom_header” name=”custom_header” … Read more

How do I add a WP_List_Table to WordPress page?

Your WP_List_Table will be different — this was adapted from WP_List_Table – a step by step guide and using the GIST: Sample plugin for usage of WP_List_Table class (complete version). You’ll want to adjust your methods to include CSS on the front-end as well (not included in this answer). WARNING : Since this class is … Read more

Why do you need to wrap a function inside array($this, function)

It’s a PHP callback. You need the syntax to keep a reference to the class instance. Put it this way – if you didn’t have $this, how does the caller know that getStuffDone is a method of your class, and not just a regular PHP function? It doesn’t. Using array( $this, ‘getStuffDone’ ) says to … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş