Vyčištění a zrychlení WordPressu

**BlankPress WordPress Cleaner**
„https://wordpress.org/plugins/bpwp-cleaner/“:https://wordpress.org/plugins/bpwp-cleaner/

This plugin allows users to selectively clean up the WordPress header, removes unwanted dashboard widgets and tweaks annoying WordPress features. Faster page load, Better security and Better WP experience.

Head Cleanup, Dashboard widgets Cleanup, Misc Cleanup.

– Page load speed increases drastically
– Better site performance
– Google will love your site. Also users will love your site
– Better security

Užitečné hooks & filters

**Modify post title when some string exists in the post content**
Add lock icon if there is a member shortcode present in the post content.
Without *$post->ID == $id* not only post title is changed but also menu items and next/previous links.

/—code php
function modify_title($title, $id) {
global $post;
$content = $post->post_content;
if(strpos($content, ‚[member]‘) AND $post->ID == $id) {
$theme_dir = get_bloginfo(‚stylesheet_directory‘);
$lock = ‚ ‚;
$new_title = $title.$lock;
return $new_title;
} else {
return $title;
}
}
add_filter(‚the_title‘, ‚modify_title‘, 10, 2);
\—

**Add extra contact methods to user profiles**

By default, WordPress allow users to enter an AIM name on their profile, but no Facebook and no Twitter names!
In order to add more contact methods to user profile, simply paste this hook in your functions.php file. In this example it will add Facebook and Twitter, but it can be used for any website or service you need.

/—code php
function my_user_contactmethods($user_contactmethods){
$user_contactmethods[‚twitter‘] = ‚Twitter Username‘;
$user_contactmethods[‚facebook‘] = ‚Facebook Username‘;

return $user_contactmethods;
}

add_filter(‚user_contactmethods‘, ‚my_user_contactmethods‘);
\—

**Automatically enable threaded comments**

By default, WordPress do not enable threaded comments. If you want/need to change this, here is a handy code snippet to paste in your functions.php file:

/—code php
function enable_threaded_comments(){
if (!is_admin()) {
if (is_singular() AND comments_open() AND (get_option(‚thread_comments‘) == 1))
wp_enqueue_script(‚comment-reply‘);
}
}

add_action(‚get_header‘, ‚enable_threaded_comments‘);
\—

**Automatically replace words in your posts**

/—code php
function replace_text_wps($text){
$replace = array(
// ‚WORD TO REPLACE‘ => ‚REPLACE WORD WITH THIS‘
‚wordpress‘ => ‚wordpress‚,
‚excerpt‘ => ‚excerpt‚,
‚function‘ => ‚function
);
$text = str_replace(array_keys($replace), $replace, $text);
return $text;
}

add_filter(‚the_content‘, ‚replace_text_wps‘);
add_filter(‚the_excerpt‘, ‚replace_text_wps‘);
\—

**Quick maintenance mode**

/—code php
function cwc_maintenance_mode() {
if ( !current_user_can( ‚edit_themes‘ ) || !is_user_logged_in() ) {
wp_die(‚Maintenance, please come back soon.‘);
}
}
add_action(‚get_header‘, ‚cwc_maintenance_mode‘);
\—

„Zdroj »“:http://www.catswhocode.com/blog/super-useful-wordpress-action-hooks-and-filters

**Přidání boxu pro excerpt (stručný výpis) i do stránek**

/—code php
function enable_page_excerpt() {
add_post_type_support( ‚page‘, ‚excerpt‘ );
}
add_action(‚init‘, ‚enable_page_excerpt‘);
\—

**Deaktivace HTML v komentářích**

/—code php
add_filter(‚pre_comment_content‘, ‚wp_specialchars‘);
\—

„10 Useful WordPress Hook Hacks »“:“http://www.smashingmagazine.com/2009/08/10-useful-wordpress-hook-hacks/

Hromadné mazání příspěvků

**Bulk delete**
„http://wordpress.org/extend/plugins/bulk-delete/“:http://wordpress.org/extend/plugins/bulk-delete/
„http://sudarmuthu.com/wordpress/bulk-delete“:http://sudarmuthu.com/wordpress/bulk-delete

Bulk Delete is a WordPress Plugin which can be used to delete posts in bulk from selected categories, tags or custom taxonomies. This Plugin can also delete all drafts, post revisions or pages.

Přejmenování obrázků a souborů v knihovně médií

**Media File Renamer**
„http://wordpress.org/extend/plugins/media-file-renamer/“:http://wordpress.org/extend/plugins/media-file-renamer/

This plugins allows you to rename physically the media files by updating their titles. It also updates theirs links in the posts automatically.

With this plugin, by updating the name of the image / media, you will also:

– rename physically the filename
– modify the guid of the media
– update all the references to that media in the associated post if there is any (img, src, url…)

Údržba systému a databáze

**WP-Sweep**
„https://wordpress.org/plugins/wp-sweep/“:https://wordpress.org/plugins/wp-sweep/

WP-Sweep allows you to clean up unused, orphaned and duplicated data in your WordPress. It also optimizes your database tables.
Autorem tohoto pluginu je Lester Chan, což je určitou zárukou kvality.

*Alternativy*

**WP CleanFix**
„http://wordpress.org/extend/plugins/wp-cleanfix/“:http://wordpress.org/extend/plugins/wp-cleanfix/

WP CleanFix is a management tool for for check, repair, fix and optimize your WordPress blog. The Ajax interface allow to manage all status in one only page!

FEATURES

– Database Tables optimization
– Check/Remove for unused UserMeta
– Check/Remove for Post Revision and Trash
– Check/Remove for unused Post Meta
– Check/Remove for unused Tags
– Check/Remove/Relink for Posts without Authors
– Check/Remove/Relink for Pages without Authors
– Check/Remove for Attachments without Post/Page
– Check/Remove for unused Categories
– Check/Remove for unlink Categories (terms)
– Check/Remove for unlink Categories Taxonomy
– Check/Remove for unapproved and Trash comments
– Check/Remove for spam comments
– Find & Replace on Posts Content
– Find & Replace on Comments Content
– WordPress MU compatibility
– English/French/Italian Localization
– Added Bubble repair count on item menu

„10 Quick Ways to Clean Up and Optimize Your WordPress Site »“:http://premium.wpmudev.org/blog/clean-up-optimize-wordpress/

Čištění databáze po pluginech

**Plugins Garbage Collector**
„http://wordpress.org/extend/plugins/plugins-garbage-collector/“:http://wordpress.org/extend/plugins/plugins-garbage-collector/
„http://www.shinephp.com/plugins-garbage-collector-wordpress-plugin/“:http://www.shinephp.com/plugins-garbage-collector-wordpress-plugin/

Plugin maps tables and entries created by plugins in your database. It also shows you which ones are used by which plugin and whether this plugin is active, inactive or deleted, so you can decide if you want to keep or delete those tables.

Údržbový mód

**WP Maintenance Mode**
„http://wordpress.org/extend/plugins/wp-maintenance-mode/“:http://wordpress.org/extend/plugins/wp-maintenance-mode/

Adds a maintenance-page to your blog that lets visitors know your blog is down for maintenancetime. User with rights for theme-options get full access to the blog including the frontend. Activate the plugin and your blog is in maintenance-mode, works and see the frontend, only registered users with enough rights. You can use a date with a countdown for informations the visitors or set a value and unit for infomrations. Also you can add urls for exlude of maintenance mode.

You can add your own html and stylesheet and add the url of this style to the options of the plugin.

**Maintenance Mode Without Plugin**

/—code php
function wp_maintenance_mode(){
if(!current_user_can(‚edit_themes‘) || !is_user_logged_in()){
wp_die(‚

Chystá se.

Zkuste to později.‘);
}
}
add_action(‚get_header‘, ‚wp_maintenance_mode‘);
\—

Údržba databáze

**WP-Cleanup**
„http://wordpress.org/extend/plugins/wp-cleanup/“:http://wordpress.org/extend/plugins/wp-cleanup/

This WordPress plugin will cleanup your WordPress database, which means that it will perform the following actions:

– Remove all post revisions
– Remove all spam comments
– Remove all unapproved comments
– Remove all unused tags
– Remove all unused post meta
– Optimize MySQL tables by removing all unused table space

**Optimize Database after Deleting Revisions**
„http://wordpress.org/extend/plugins/rvg-optimize-database/“:http://wordpress.org/extend/plugins/rvg-optimize-database/

A ‚One Click‘ WordPress Database Cleaner / Optimizer.

– Deletes redundant revisions of posts and pages (you optionally can keep an ‚x‘-amount of the most recent revisions)
– Deletes trashed posts, pages and comments (optional)
– Deletes spammed comments (optional)
– Deletes ‚orphan postmeta items‘
– Optimizes the database tables (optionally you can exclude certain tables from optimization)
– Creates a log file of the optimizations (optional)
– Optimization can be scheduled to automatically run once hourly, twice daily, once daily or once weekly (optional)

**Plugins Garbage Collector**

Vymaže tabulky po deaktivovaných a nepoužívaných pluginech.
„http://wordpress.org/extend/plugins/plugins-garbage-collector/“:http://wordpress.org/extend/plugins/plugins-garbage-collector/

Nastavení počtu revizí a smazání revizí příspěvků

**Delete-Revision**
„http://wordpress.org/extend/plugins/delete-revision/“:http://wordpress.org/extend/plugins/delete-revision/

V *Nastavení > Delete-Revision > Check Redundant Revision* pak lze vymazat zbytečné revize.

**Revision Control**
„http://wordpress.org/extend/plugins/revision-control“:http://wordpress.org/extend/plugins/revision-control

**Optimize Database after Deleting Revisions**
„http://wordpress.org/plugins/rvg-optimize-database/“:http://wordpress.org/plugins/rvg-optimize-database/

One Click WordPress Database Cleaner / Optimizer.

**Řešení bez použití pluginů:**

v souboru wp-config.php možno nastavit
/—code php
// vypne revize
define(‚WP_POST_REVISIONS‘, false );

// ukládá jen definovaný počet revizí
define(‚WP_POST_REVISIONS‘, 2);

// nastaví interval ukládání ve vteřinách
define(‚AUTOSAVE_INTERVAL‘, 60 );
\—

**PHP skript pro hromadné smazání všech revizí :**

/—code php

\—

**Ev. v Myadminu jen SQL příkazem :**

/—code php
DELETE FROM wp_posts WHERE post_type=’revision‘
\—