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

BlankPress WordPress Cleaner
https://wordpress.org/…pwp-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.

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 = ' <img src="'.$theme_dir.'/images/lock.gif" border="0"/>';
        $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.

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:

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

function replace_text_wps($text){
    $replace = array(
        // 'WORD TO REPLACE' => 'REPLACE WORD WITH THIS'
        'wordpress' => '<a href="#">wordpress</a>',
        'excerpt' => '<a href="#">excerpt</a>',
        'function' => '<a href="#">function</a>'
    );
    $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

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 »

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

function enable_page_excerpt() {
add_post_type_support( 'page', 'excerpt' );
}
add_action('init', 'enable_page_excerpt');

Deaktivace HTML v komentářích

add_filter('pre_comment_content', 'wp_specialchars');

10 Useful WordPress Hook Hacks »

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

Media File Renamer
http://wordpress.org/…ile-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/…ns/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/…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/I­talian Localization
  • Added Bubble repair count on item menu

10 Quick Ways to Clean Up and Optimize Your WordPress Site »

Údržbový mód

WP Maintenance Mode
http://wordpress.org/…enance-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

function wp_maintenance_mode(){
    if(!current_user_can('edit_themes') || !is_user_logged_in()){
        wp_die('<h1 style="color:red">Chystá se.</h1><br />Zkuste to později.');
    }
}
add_action('get_header', 'wp_maintenance_mode');

Údržba databáze

WP-Cleanup
http://wordpress.org/…/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/…ze-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/…e-collector/

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

Delete-Revision
http://wordpress.org/…te-revision/

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

Revision Control
http://wordpress.org/…sion-control

Optimize Database after Deleting Revisions
http://wordpress.org/…ze-database/

One Click WordPress Database Cleaner / Optimizer.

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

v souboru wp-config.php možno nastavit

// 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í :

<?php
mysql_connect("server.cz", "uživatel", "heslo") or die(mysql_error());
mysql_select_db("jméno databáze") or die(mysql_error());
mysql_query("DELETE FROM wp_posts WHERE post_type='revision'");
?>

Ev. v Myadminu jen SQL příkazem :

DELETE FROM wp_posts WHERE post_type='revision'