Home » Archive

Articles Archive for April 2008

  Posted: Apr 23 | Filed under: Wordpress

If you should come in the situation that you always need the same post over and over again, e.g. if you use wordpress as a CMS then I have a useful trick for you.

We have to edit the function “the_editor“, which is defined at general-template.php!

Open the file and find the function; now inside the function find

textarea class='mceEditor' $rows cols='40' name='$id' tabindex='2' id='$id'>%s

Straight after the %s add the text that is supposed to be your default post. If it’s a complex string you can safe the text in a variable e.g. $defaulttext = “here goes my php code”; and simply add $defaulttext after %s, but before the closing textarea tag!

  Posted: Apr 23 | Filed under: Wordpress

If you should ever come in the situation that you want a default custom field on your “write page” you should first of all create a draft with your default custom fields.
After that go to your phpMyAdmin interface and lookup the postid.
Once you got the postid simply goto “wp_postmeta” and find the postid of that draft. Change the id to zero.
VoilĂ  now you will have the custom field you defined in the draft at your write page. This is especially handy if you always need the same custom field because you can simply copy it.

  Posted: Apr 19 | Filed under: Wordpress

To realize a multilingual wordpress you have to follow the following steps:

1. Check if your theme is ready for localization.

To do that open for example comments.php in your theme folder and search for text that is currently displayed on your blog e.g.”Leave a comment”.

If it’s looking similar to

 " _e("Leave a comment", "mytheme");  "

then your theme should already be ready for localization.

2. Optional

If not then you will have to wrap the “_e” around every text passage in your theme. Replace mytheme with your theme’s name. Also don’t forget that this has to be inside a php statement!

You can do it like that:

<?php  _e("Text", "mytheme"); ?>

Inside a function:

'__('Text', "mytheme")'

e.g.

 comments_rss_link(__('Subscribe to the comments via RSS Feed', "mytheme"));

3. Add load_theme_textdomain to your functions.php

This is a very important step because it will load the text via gettext before sending out the headers. Add the following at the very first line of your functions.php inside your theme folder: (if you don’t have one create a functions.php!)

 <?php load_theme_textdomain('mytheme'); ?>
  Posted: Apr 13 | Filed under: General

The bash_history is a file that saves your command line entries. If you execute any commands via SSH it will save them in the file .bash_history, so that you are able to quickly execute older commands again.

However you can imagine that this is a security risk you can easily avoid by cleaning the history after you logout.

First of all you should locate your bash_history.
Nothing easier than that, simply execute:
“locate bash_history” via SSH and it will show you where it is.
The File “.bash_profile” should be in the same directory.

Now either use a SSH editor like nano to open the file “.bash_profile” or simply open it via WINSCP. This is really a personal taste but I prefer using nano instead of vim because it’s easier to handle. Execute “nano .bash_profile”. If it’s in a subdirectory then you will have to “cd” there.

Now add the following lines at the very end:

export HISTSIZE=100
export HISTFILESIZE=100
unset HISTFILE

You can change “100″ to the number of commands you want to keep while being logged on. If you logout it will “unset” everything and delete your commands.
VoilĂ ! Now it will automatically delete your bash_history if you logout.

  Posted: Apr 10 | Filed under: Cpanel/WHM

The following commands are very useful to make sure that imap is running properly:

 

/scripts/restartsrv_courier
Simple restart of courier.

 

/scripts/convert2maildir
This will convert your mail boxes into a proper format.

 

/scripts/courierup –force
This will make sure that the latest imap is running.

  Posted: Apr 10 | Filed under: Cpanel/WHM

If you are on a WHM/Cpanel server and you might want to update your cpanel including all components like FTP, Courier, etc., then you can run the following command via SSH:

 

/scripts/upcp --force

 

This will not only make sure you have got the latest Cpanel software, but will also “auto-heal” your system, which means that it will fix some server settings.