Caching 404 pages in WordPress

This is to stop WordPress in handling 404, using headers to manage cache expiry. This code should be added to the theme’s functions.php file.

function template_slug_404_cache() {
	if( is_404() ){
		header( 'Cache-Control: max-age=30000, must-revalidate' );
		header( 'Expires: ' . date( 'D, d M Y H:i:s', strtotime( '+5000 minutes' ) ) . 'UTC' );
		header( 'Last-Modified: ' . date( 'D, d M Y H:i:s', strtotime( '-5000 minutes' ) ) . 'UTC' );        

 * Redirect a 404 to a cache page
 * @return void
function template_slug_404_redirect() {
	if ( is_404() ) {
		header( 'Location:' . site_url( '/404' ) );
add_action( 'template_redirect', 'template_slug_404_cache' );

Be sure that there is a 404.php file on the template directory.

Add a help tab to a WordPress Plugin

This is a help tab that can be found on the WordPress admin dashboard, a custom plugin can have also contextual help that can be found on the rightmost part of the admin screen.

Ever since WordPress Version 3.0, every built-in Administration Panel has contained a contextual help section providing additional information to the user on how to navigate the various settings displayed in that admin panel. This helps WordPress keep the main part of the admin panel clear and concise by eliminating unnecessary text that regular users don’t need to see on a regular basis.

We should use the Screen class to achieve adding the help tab.

This is a concrete class that is instantiated in the WordPress $screen global. It is primarily used to create and customize WordPress admin screens (as of WordPress 3.3).

An example function to add a help tab using the WP_Screen class.

function my_add_help_tab() {
	$screen = get_current_screen();
			'id' => 'hello_dolly',
			'title' => __( 'Hello Dolly' ),
			'content' => '<p>' . Well, hello, Dolly
It's so nice to have you back where you belong
You're lookin' swell, Dolly . '</p>',
	$screen->set_help_sidebar( __( 'Hello Dolly' ) );

There are two methods that are used add_help_tab and the set_help_sidebar. The add_help_tab would add the tab button on the screen and also the left-side title and the content.

The set_help_side_bar would add an additional third column.

Upon activation of an Options page or Menu page, use an action hook and use the callback function.

function my_options_page() {
	$my_menu_page = add_menu_page(
		'Hello Dolly',
		'wpl_options_page_html'  // callback function to display the page
	// Add help bar.
	add_action( 'load-' . $my_menu_page, 'my_add_help_tab' );

add_action( 'admin_menu', 'my_options_page' );

That’s all to it.

Starting with PHP

Just bump around recently with some students from a University nearby our home, though it is not yet part of their curriculum they are more than interested in the language. So I am going to write some simple tutorials regarding the language. The last time, I taught or mentor was very long ago, so this would be an exciting journey for me.

When PHP not yet existed?

If my memory serves me right, people do have the internet by 1995, most of the sites use CGI (Common Gateway Interface). If you need to fetch data from a database server, you would need to use the C language or Perl script. It’s a little bit hard to debug or develop since the need to spit out the information either to compile if it’s on C if it’s on Perl not many server log messages to pinpoint where the error is. You would see some servers have the cgi-bin folder that uses to house scripts that will interact with a Web browser. I think it has still today especially for most cPanel hosts.

Here comes PHP

PHP was written by Rasmus Lerdorf in C language. It was written in C because it was the language Rasmus was most comfortable with at that time. Unlike using CGI (Common Gateway Interface) the approach was to embed it with HTML, mostly just specifying with the file extension php. Basically, a scripting language that is executed on the server.

<!DOCTYPE html>
echo 'Hello world';

The basic syntax of PHP is very similar to that of Perl, and both share several syntactic features with C. Whitespace is ignored in code, statements are ended with semicolons, and curly braces group together several statements into a single block. The name of the function is accompanied by the actual arguments, which are enclosed in parentheses and separated by commas.

<?php // all code starts with this tag 

// single statement
$variable = "Value of variable"; 

// sample function
function sample($argument, $argument2) {


// all code end with this tag

The best way to learn a language is by using it. We would try to install PHP on a server or on a local development machine.