Tag Archives: Silenced tutorials

Ternary Conditionals

I know most of you allready use them, but there are still people that don`t know about them, so to make the following tutorials easyer, I`ll do a small example.

First of all you must know that all you will see here is a simpler way to write not so complex if statements.
Traditional way:

if (condition) {
    echo "true";
} else {
    echo "false";
}

The shorter way:

echo (condition) ? "true"  : "false";

Another example:

if (date("m")<12) {
    $var = 12-date("m") ." months till december";
}else{
    $var = "It`s December";
}
echo $var;

The shorter way:

$var = (date("m")<12) ? 12-date("m")." months till december" : "It`s December";
echo $var;

I hope you got it and this will make easyer for you to undersand the following tutorials.

Disable news in wp-admin

This is the fastest way to remove the news from the wordpress admin dashboard.

Open up your favorite ftp program and connect to your blog.

In the wp-admin folder find the file index.php, make a backup of this file just in case u mess it up and you have to restore it later.

Now open up index.php and around line 15 you should find the following:

add_action( 'admin_head', 'index_js' );

Just comment out that line with double slashes like this:

//add_action( 'admin_head', 'index_js' );

Save the file and you`re done!

I only did this to my blog because I wanted to clean it up a bit.

Keep in mind that if you disable the news you will not see the latest updates from “WordPress Development Blog”. This can be a bad thing.

However, if you want to keep the “WordPress Development Blog” news and only disable the “Other WordPress News” do the following:

In stead of commenting out the line like told above, look for this:

jQuery('#planetnews').load('index-extra.php?jax=planetnews');

It should be around line 10. Just remove it, save the file and you`re done.

I only did this on Version 2.3 so if your version is prior to this it might not work exactly like this but you got the idea. It might not be the best way to do it but it`s the simplest and fastest for me.

Enjoy!

Simple text based hit counter

First make a new file called stats.txt and one called stats.php

Give write permission on the .txt file (CHMOD 666 or 777 if you don`t see a growing count)

php code for .php file


<?php
//set data file name/path
$data='stats.txt';
//read content fom the .txt file
$show = file_get_contents($data);
//write new content to the .txt file
$new=file_put_contents($data,$show+1);
//show your hit counter
echo $show;
?>

This is faster thran fopen() and if the data file dose not exists the script creates it, if it can.