WordPress-Christmas-2010-23

Separate Logic From Output

Once HTML is defined within a function for output, the HTML will be separated from the logic! In this case the function is defined twice. A function contains only logic and values ​​are returned only as return. The second function will contain HTML, test logic, loops or hooks and outputs values ​​as echo. Ok, the smart asses will say MVC, yeah you right, but WordPress does not pursue a Consistent MVC pattern!

Continue reading …

WordPress-Christmas-2010-22

Adding Custom Fields to WordPress User Profile

The user profile of WordPress can be fairly easily adapted to add your own values​​. So you can add the necessary fields according to your requirements. Here is how you do it, we add a field for the address and the content will be stored in the database. Various hooks in WordPress make sure that you only have to worry about the fields.
Continue reading …

WordPress-Christmas-2010-21

Register Settings on WordPress Multisite

The use of WordPress for several blogs in the network can be useful to simplify several steps and is becoming increasingly popular. Whether you want the classical scenarios of blog hosting service or like to create multilingual websites or other ideas. Therefore, it is also important for plugin developers to use the functions and to expand or develop their own Plugins for it specifically.

Much is the same, but not all, and in this small article I would like to briefly explain how you set settings in the database when you activate a Plugin. Continue reading …

WordPress-Christmas-2010-20

WordPress constants overview

In the backend of WordPress you don't have an input field for each possible modification. Some are only available via an action or a filter and for some changes you need to define or change a PHP constant.
In this article I have listed all constants which WordPress has by nature (except the deprecated ones).
Continue reading …

WordPress-Christmas-2010-18

Implement a 404 image in your Theme

Every good Theme comes with a 404.php for requests that don’t match any post or page. But what to do with missing images? They are requested per an <img> element usually, your visitors may never see the HTML template. Let’s use a 404 image.

I put the following code on top of my 404.php before get_header():

// @version 2011.12.23
// matches 'img.png' and 'img.gif?hello=world'
if ( preg_match( '~\.(jpe?g|png|gif|svg|bmp)(\?.*)?$~i', $_SERVER['REQUEST_URI'] ) )
{
    header( 'Content-Type: image/png' );
    locate_template( 'img/404.png', TRUE, TRUE );
    exit;
}

My 404 image is bright, eye-hurting red to let me see it easily during the tests.

404

License: WTFPL. Grab it while it’s red.