Post with Code Formatting

Code

This is a demo page for the evolution code highlighting. This is not a theme feature because WordPress does not allow it. We use our plugin AH Code Highlighter for that.

AH Code Highlighter is a really simple to use and extrem lightweigt Code Syntax Highlighting with 7 different code highlighting themes. You can highlight your code with or without line numbers. It is based on Lea Verou’s Prism.js.

Prism is used on several big websites like the Smashing Magazine, A list Apart, CSS Tricks, SitePoint and Drupal, because it is fast, simple and lightweight.

AH Code Highlighter supports PHP, HTML, CSS, JavaScript, Apache, Http, Sess, Lass, Markdown, Nginx, MySql, Xml, Mathml and Clike.

This is some code

<?php

/**
 * Security - Login admin area only with e-mail address and password
 * 
 * @author Andreas Hecht
 * @since 1.0.0
 */ 
//WordPress Authentifikation löschen
remove_filter('authenticate', 'wp_authenticate_username_password', 20);

// Neue Authentifikation setzen - Anmelden nur mit E-Mail und Passwort
add_filter('authenticate', function($user, $email, $password){

    //Check for empty fields
    if(empty($email) || empty ($password)){        
        //create new error object and add errors to it.
        $error = new WP_Error();

        if(empty($email)){ //No email
            $error->add('empty_username', __('<strong>ERROR</strong>: Email field is empty.'));
        }
        else if(!filter_var($email, FILTER_VALIDATE_EMAIL)){ //Invalid Email
            $error->add('invalid_username', __('<strong>ERROR</strong>: Email is invalid.'));
        }

        if(empty($password)){ //No password
            $error->add('empty_password', __('<strong>ERROR</strong>: Password field is empty.'));
        }

        return $error;
    }

    //Check if user exists in WordPress database
    $user = get_user_by('email', $email);

    //bad email
    if(!$user){
        $error = new WP_Error();
        $error->add('invalid', __('<strong>ERROR</strong>: Either the email or password you entered is invalid.'));
        return $error;
    }
    else{ //check password
        if(!wp_check_password($password, $user->user_pass, $user->ID)){ //bad password
            $error = new WP_Error();
            $error->add('invalid', __('<strong>ERROR</strong>: Either the email or password you entered is invalid.'));
            return $error;
        }else{
            return $user; //passed
        }
    }
}, 20, 3);
Download Plugin from WordPress »

Sreenshots: The 7 Highlighting Themes from AH Code Highlighter

Choose between one of these nice looking themes

Default Theme

Okaidia Theme

Dark Theme

Funky Theme

Coy Theme

Solarized Light Theme

Twilight Theme

Download Plugin from WordPress »

Andreas Hecht

is a wordpress developer, designer and specialist for WordPress Performance and WordPress Security. He roams the web since its inception. He ist also a journalist.

Leave a Reply

Your email address will not be published. Required fields are marked *

* Die Checkbox für die Zustimmung zur Speicherung ist nach DSGVO zwingend.

Ich stimme zu.

This is a demo store for testing purposes — no orders shall be fulfilled. Dismiss