When we are using the wordpress sites then we need to clean the database always. If your site is having more than 500 articles then you need to worry about server performance.

Mysql load will impact your server.  Many people are suggesting to use the WP-DBManager wordpress plugin. But forgot about plugin feature. That plugin specially made for database backup and managing the tables.

If you want to optimize your wordpress database then you need to use wp-optimize wordpress plugin. I found that is only plugin is helpful for really keep optimize your wordpress database.

I used that plugin. Before using that plugin my mysql database size was 135mb. After using that wp-optimize plugin features database size was 4mb. That means my database really really optimized.

My sites performance was also improved.

What is features of wp-optimize?

  • Remove the existing wordpress post revisions
  • Remove all the comments in the spam queue
  • Remove all the un-approved comments
  • Rename one username to another username, it’s designed to rename default “Admin” user to something else
  • Apply MySql optimize commands on your database tables without phpMyAdmin.
  • Display Database table statistics.

I really liked this wordpress plugin. Thanks to Ruhani Rabin who wrote this plugin.

You can download this plugin from here

http://wordpress.org/extend/plugins/wp-optimize/

Keeping your wordpress database is very important for wordpress database. This will improve your site speed aslo.
Many times you install the wordpress plugins and some time you dont want that plugins and you delete that plugins. There is very nice wordpress plugin is avilable for database backup.

WP-DB-Backup

WP-DB-Backup allows you easily to backup your core WordPress database tables. You may also backup other tables in the same database.
But that plugins create some tables in your wordpress database. You need to remove that tables from your wordpress database.
Imp note: when ever you are cleaning the database or deleting the unwanted tables from wordpress database. Please consult with your web administrator.
Dont forget to take a full backup of your database.

This tutorial should be forward-compatible with WordPress 3.0

1. Install WP-DB-Backup by Austin Matzko

2. Mouse over Tools so that the down arrow appears

3. Click the down arrow

4. Click Backup

5. You’ll see something like this:

On the left are the default database tables included with WordPress. All of these are included every time you backup. The only thing you have to decide here is whether to exclude spam comments from being backed up (I recommend this) and whether to exclude post revisions (I recommend excluding these too, unless you have a specific reason for keeping revisions).

On the right is a list of additional database tables, most of which were probably created by plugins. There’s also a table called that will end with the name “commentmeta” – this can be used by plugins.

If your plugins have created a lot of data that you would like to save, or you’ve spent a lot of time configuring particular plugins, you’ll want to backup these tables. Otherwise, you can keep your database backups smaller by not checking them.

7. Next we see the Backup Option. There are three choices here:

A. Save to the server

This will save a backup of your database as a file on your web server. I don’t recommend this.

B. Download to your computer.

This will create a database backup file that you can save to your local computer.

C. Email backup to:

This allows you to send a copy of the backup to any e-mail address you’d like.

8. Let’s go ahead and download a copy to our hard drives now.

Check options you want in the Tables section then click “Backup now!”

You should see a progress bar, and when that’s done your browser will prompt you to save the file. You can save this file wherever you’d like.

9. There’s another section called “Scheduled Backup.” This is where this program gets really great.

Here we can schedule a backup to be e-mailed to a particular e-mail address however often we’d like. I recommend checking selecting “Once Daily.”

10. On the right, you’ll see that list of optional tables again. Check the ones you want to backup every time the backup runs.

11. Enter the e-mail address you want the backups delivered to in the “Email backup to:” field.

12. Click “Schedule backup.”

13. You should now get a backup file as an e-mail attachment every day. You should save these attachments to your local computer. If you’re using Gmail or another web mail host that has a lot of storage space, you might want to leave your databases on their server as an additional off-site backup. Be aware that that’s an additional security risk – if your e-mail account is ever compromised, the would have access to all of your database backups.

Many times you website content is not suitable for all the age group. There is very nice wordpress free plugin available.

Restricted to Adults

There’s a lot of content which isn’t appropriate for all ages. The [Association of Sites Advocating Child Protection (ASACP)](http://www.asacp.org/ “ASACP) has developed the Restricted to Adults (RTA) tag which most online protection software respects.

Installing the RTA tag on a WordPress install can be somewhat complicated, so the Restricted to Adults plugin makes it one click — activate the plugin and your site is restricted to adults.

What is persistent database connection?

Persistent connections are links that do not close when the execution of your script ends. When a persistent connection is requested, PHP checks if there’s already an identical persistent connection (that remained open from earlier) – and if it exists, it uses it. If it does not exist, it creates the link. An ‘identical’ connection is a connection that was opened to the same host, with the same username and the same password (where applicable).

If you want to use the persistent database connection then you should follow my steps:

First Open the wp-db.php file from wp-includes folder. In that file find following words:


// @mysql_connect( $dbhost, $dbuser, $dbpassword, true );

//Change that to

@mysql_pconnect( $dbhost, $dbuser, $dbpassword, true );

comment the mysql_connect line. This line you will find two times in that file. You need to change the line both the times. Then upload this file to your wordpress installation.

Persistent database connection will open only one connection and for every query that will check for connection is present or not. If connection is alreadypresent then your query will execute using that persistent database connection.

There are cupple of issues with persistent database connection, When you are using the persistent connection you should keep following things in mind.

Imp: There are a couple of additional caveats to keep in mind when using persistent connections. One is that when using table locking on a persistent connection, if the script for whatever reason cannot release the lock, then subsequent scripts using the same connection will block indefinitely and may require that you either restart the httpd server or the database server. Another is that when using transactions, a transaction block will also carry over to the next script which uses that connection if script execution ends before the transaction block does. In either case, you can use register_shutdown_function() to register a simple cleanup function to unlock your tables or roll back your transactions. Better yet, avoid the problem entirely by not using persistent connections in scripts which use table locks or transactions (you can still use them elsewhere).

Now WordPress 3.0 is released and the new post thumbnail function will not changed until.

You can provide 4 picture formats to the function (change the width and height values to your need):

// the thumbnail
the_post_thumbnail(array(100,100));

// medium resolution
the_post_thumbnail(array(300,200));

// large resolution
the_post_thumbnail(array(600, 400));

// original
the_post_thumbnail();

You can set how the images should align. It is also possible to assign an own class:

//  left align
the_post_thumbnail(array(100,100), array('class' => 'alignleft'));

//  right align
the_post_thumbnail(array(100,100), array('class' => 'alignright'));

//  center
the_post_thumbnail(array(100,100), array('class' => 'aligncenter'));

// align right and the class  'my_own_class'
the_post_thumbnail(array(100,100), array('class' => 'alignright my_own_class'));

The 3rd possibility is the control of the images size with an array of height and width:
For this purpose we suppose that the settings for thumbnail is 150×150, for medium 300×200 and for large 600×400.

// thumbnail scaled to 60x60 pixel
the_post_thumbnail(array(60,60), array('class' => 'alignleft'));

// original thumbnail
the_post_thumbnail(array(150,150), array('class' => 'alignleft'));

// medium resolution scaled to 200x133 pixel
the_post_thumbnail(array(200,200), array('class' => 'alignleft'));

// large resolution scaled to 400x266 Pixel
the_post_thumbnail(array(400,345), array('class' => 'alignleft'));

We see that the image proportions are always maintained, even if one specifies crooked values.

For the Theme Designers is this not necessarily easier, because no one knows what the user will put in his settings o his library. One way to approach this problem, to query the options for the various sizes:

// width of the thumbnails
get_option('thumbnail_size_w');

//  height of the thumbnails
get_option('thumbnail_size_h');

//  height of the medium resolution
get_option('medium_size_h');

//  width of the large resolution
get_option('large_size_w');

//  1 = Crop thumbnail to exact dimensions, 0 = Crop off
get_option('thumbnail_crop')

You can change these values in your theme.

$w = get_option('thumbnail_size_w') / 2;
$h = get_option('thumbnail_size_h') /2;

the_post_thumbnail(array($w, $h), array('class' => 'alignleft'));

Here another example: If the size of a thumbnail is bigger than 100×100 and crop is activated, then the thumbnail should be resized to 100×100, otherwise use the original thumbnail.

if(get_option('thumbnail_size_w') > 100 && get_option('thumbnail_crop') == 1) {
    the_post_thumbnail(array(100,100));
}else{
    the_post_thumbnail('thumbnail');
}

What Matt is saying?

I wouldn’t recommend anyone use the named arguments for the_post_thumbnail, like ‘thumbnail’, could you remove those from your tutorial.

Inspired by

Here is one small security to protect your wordpress site.

We all know that, when the blog admin left a comment on his blog, WordPress use the name in the comment css class. If admin left a comment on his blog any would-be hacker/cracker only has to figure out your password–making it much easier to get into your site. So..

Remove admin name in comments class

Here’s simple solution, put this code on your functions.php

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function remove_comment_author_class( $classes ) {

foreach( $classes as $key => $class ) {
if(strstr($class, "comment-author-")) {
unset( $classes[$key] );
}
}
return $classes;
}
add_filter( 'comment_class' , 'remove_comment_author_class' );

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The code above will clean comment_class for the author.

Thank You!

When you publish your post,the feed an published to the whole world.That’s very annoying thing.

Some times you need to change the content or change the url, that time you got the errors

The following example publishs the post 10 minutes later in your feed:


/**
 * puplish the content in the feed later
 * $where ist default-var in WordPress (wp-includes/query.php)
 * // Apply filters on where and join prior to paging so that any
 * This function an a SQL-syntax
 */
function publish_later_on_feed($where) {
 global $wpdb;

 if ( is_feed() ) {
 // timestamp in WP-format
 $now = gmdate('Y-m-d H:i:s');

 // value for wait; + device
 $wait = '10'; // integer

 // http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
 $device = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR

 // add SQL-sytax to default $where
 $where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
 }
 return $where;
}

add_filter('posts_where', 'publish_later_on_feed');

You need to open the your wordpress themes functions.php file and put above code in that file. Using this function your feed will publish after 10 minute of your wordpress post publishing.

The default upload file size is in php settings is 2 MB and for wordpress also default upload size is 2 MB.
When we try to upload big size image or media files in wordpress we got the following error

The uploaded file exceeds the upload_max_filesize directive in php.ini
For fixing the issue use following steps
Use the php.ini file from root folder.

1. Find this line in the php.ini file in your php installtion upload_max_filesize = 2MB and replace it with a higher value (e.g. upload_max_filesize = 64MB)
2. Search for this line in your php.ini file post_max_size and increase it.

If you don’t have a php.ini file in your directory,
you can usually generate one from the control panels of your host. or create the file and put following values in that
memory_limit = 32M
upload_max_filesize = 100M
upload_max_filesize = 100M
post_max_size = 100M

This file is copied into your wp-admin folder, the problem should be solved.

You cannot change a WordPress.com account username once it has been set. However, you can change what is seen on your posts and comments by changing the display name (nickname) in your profile, or you can create a new account and transfer your blog(s) to the new account.

Change Display Name (Nickname)

1. Access your User Profile

2. Change the value next to Display name publicly as under Basic Details

3. Click Update Profile.

↑ Table of Contents ↑

Change Username

1. Log into your current account (using your existing username)

2. Access your Personal Settings and change the e-mail address to another email address. This will free up your primary e-mail for use with the new username.

3. Once the new address has been verified via email confirmation, log out of the account.

4. Go to http://wordpress.com/signup/ and attempt to register a new account (the username you wish to change to) with your e-mail address.

5. If you’ve got a blog you should transfer its ownership to your new username.

Once you’ve done all of that you’ll be rocking WordPress.com with your new username.

via Change Your Username « Support.

Filters are the hooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browser screen. Your plugin can specify that one or more of its PHP functions is executed to modify specific types of text at these times, using the Filter API.

All filters are located in wp-includes/plugin.php file. Following function you can use for using the filters in wordpress plugin.

has filter

Check if any filter has been registered for a hook.

<?php has_filters( $tag, $function_to_check ); ?> 

$tag

(string) (required) The name of the filter hook.

Default: None

$function_to_check
(callback) (optional) If specified, return the priority of that function on this hook or false if not attached.

Default: False

add filter

<?php add_filter( $tag, $function_to_add, $priority, $accepted_args ); ?>

$tag
(string) (required) The name of the filter to hook the $function_to_add to.

Default: None

$function_to_add
(callback) (required) The name of the function to be called when the filter is applied.

Default: None

$priority
(integer) (optional) Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.

Default: 10

$accepted_args
(integer) (optional) The number of arguments the function(s) accept(s). In WordPress 1.5.1 and newer. hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run.

Default: 1

example

<?php add_filter('media_upload_newtab', array(&$this, 'media_upload_mycallback')); ?>

apply filters

<?php apply_filters( $tag, $value ); ?>

$tag
(string) (required) The name of the filter hook.

Default: None

$value
(mixed) (required) The value which the filters hooked to $tag may modify.

Default: None

example.

$myvar = apply_filters( $tag, $value );

current filter

Retrieve the name of the current filter or action.

<?php current_filter() ?>

merge filters

Merge the filter functions of a specific filter hook with generic filter functions.

<?php merge_filters($tag); ?>

$tag
(string) (required) The filter hook of which the functions should be merged.

Default: None

remove filter

This function removes a function attached to a specified filter hook. This method can be used to remove default functions attached to a specific filter hook and possibly replace them with a substitute. See also remove_action(), add_filter() and add_action().
Important: Because of long-time unfixed bugs resulting in flaws of the underlying implementation, it is unpredictable which filters this function will remove when called. Usage might/will result in loss of other then the intended filter(s). Plugin authors should prevent the usage of this function if possible.

Important: To remove a hook, the $function_to_remove and $priority arguments must match when the hook was added. This goes for both filters and actions. No warning will be given on removal failure.

$tag
(string) (required) The action hook to which the function to be removed is hooked.

Default: None

$function_to_remove
(string) (required) The name of the function which should be removed.

Default: None

$priority
(int) (optional) The priority of the function (as defined when the function was originally hooked).

Default: 10

$accepted_args
(int) (optional) The number of arguments the function accepts.

Default: 1

remove all filters

Remove all of the hooks from a filter.

<?php remove_all_filters( $tag, $priority ) ?>

$tag
(string) (required) The filter to remove hooks from.

Default: None

$priority
(integer) (optional) The priority number to remove.

Default: false

——————————————-x———————————–x—————————–

All List of all WordPress filter hooks you will find on following URL

http://adambrown.info/p/wp_hooks/hook/filters

Wordpressapi is developer code book.
wordpressapi on Facebook

Who am I?

Sony Kumari founded Wordpressapi in Feb 2010. She started writing since Aug 2006 in wordpress blog. Later on She moved her blog to wordpressapi.com.

Sony Kumari is dubble gradute and earned M.C.A. in Computers. Sony Kumari handled the so many projects in many different technology. She worked on Java, PHP, Ruby on Rails, Javascript, Web services, Social applications, Ad campaigns.

Mahesh is the Author of Wordpressapi, as well as a serial web entrepreneur, sci-fi author, and aspiring world changer. He has been writing for Wordpressapi since Dec 2009. His previous experience includes Photoshop Design, CSS design, Web design and wordpress themes development.

Mahesh is a graduate and earned a B.E. in Electronics. He is having three years of experience in Web design and Wordpress application development.

Rahul is the Author of Wordpressapi, as well as a web designer and photoshop artist. His previous experience includes Photoshop Design, CSS design, Web design and wordpress themes development.

Rahul is a graduate and earned a B.A. in History. He is having Five years of experience in Web design and Wordpress application development.

© 2010 Wordpressapi. All Rights Reserved. Reproduction without explicit permission is prohibited.