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 …

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 …

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.