WordPress: Useful Default Configuration Settings Via Plugin

Everybody who installs WordPress quite often knows the problem: You always have to do the same adjustments, for example deleting the Hello World post. That cost time and money. Our friend Thomas Scholz alias toscho had a simple but genius idea, he puts all needed option settings in a Plugin. Just activate the Plugin, deactivate it and delete it. Done!

You can adjust and expand the options as you like. A good overview is the wp-admin/options.php.

<?php
/*
Plugin Name: Toscho's basic settings
Plugin URI: http://toscho.de/2010/wordpress-grundeinstellungen-per-plugin-setzen/
Description: Some useful default configuration settings. See 'wp-admin/options.php' for more options.
Version: 0.2
Author: Thomas Scholz
Author URI: http://toscho.de
*/

function set_toscho_defaults()
{
    $o = array(
        'avatar_default'            => 'blank',
        'avatar_rating'             => 'G',
        'category_base'             => '/thema',
        'comment_max_links'         => 0,
        'comments_per_page'         => 0,
        'date_format'               => 'd.m.Y',
        'default_ping_status'       => 'closed',
        'default_post_edit_rows'    => 30,
        'links_updated_date_format' => 'j. F Y, H:i',
        'permalink_structure'       => '/%year%/%postname%/',
        'rss_language'              => 'de',
        'timezone_string'           => 'Etc/GMT-1',
        'use_smilies'               => 0,
    );

    foreach ( $o as $k => $v )
    {
        update_option($k, $v);
    }

    // Delete dummy post and comment.
    wp_delete_post(1, TRUE);
    wp_delete_comment(1);

    return;
}
register_activation_hook(__FILE__, 'set_toscho_defaults');
?>

Here you can download the Plugin by toscho.

Comments are closed.

21 comments

  1. visaap

    This is SUPER handy!!!
    Thanx a lot.

  2. Markus

    very helpful thank you

  3. Tony Dunsworth

    This could come in very handy with several site I administer.

  4. Tomáš Kapler

    This solution is not the best one - FAR better is to have own instal.php in /wp-content which is automaticaly run during instalation. And this instal.php can contain definition of own posts, own users, own configuration, plugins etc. So you will even not need to download and run some plugin, you just have your own wordpress instalation.

  5. JhezeR

    Trik dan plugin yang sangat cerdas 🙂

  6. Chris

    With the number of install I do this is going to be a real time-saver.

  7. Peter Westwood

    The wp-content/install.php solution is a much better way to do this IMHO.

    That way you have full control over the defaults installed!

    http://wpbits.wordpress.com/2007/08/10/automating-wordpress-customizations-the-installphp-way/

  8. Michael

    @Westi: a lead dev must be right :p
    but i like this little solution without modifying the core files.

  9. Deryck

    Very usefull! It´s simple and efficient for clients!

  10. Pulsuz Sayt

    Hi,
    I use WPMU and want to create default widget settings for newly created sub blogs. I want to create deafult widget settings for "text" widget as want to write something into to newly created blog`s sidebar. I use this code to auto add widget:
    'My Categories' ));
    update_blog_option($blog_id, "sidebars_widgets",
    array("sidebar-1" => array("text"),));
    }
    add_action('wpmu_new_blog', 'default_widgets');
    ?>

    But this widget adds to sidebar empty. Can you help me to add some text to this text widget as default:
    $title and $text

  11. Florian Weber

    I'm installing blogs weekly, awesome plugin. It doesn't take much time to change default settings but it sums up...great little helper!

  12. Paul Cunningham

    Got to admit, hadn't thought of either this or the install.php method before.

    Insanely useful for regular installers.

  13. Jessi Hance

    Does anyone know how you would change the name of the dummy page and turn off comments and pings on it?

    And how to set the Reading settings to use that page for the front page?

    And even how to create another page called Blog and set that for the posts page?

    I don't ask for much, do I.

  14. David Page

    @Michael The solution @Westi indicates doesn't modify core files, the install file is located in wp-content/
    I find it's really useful to pre-setup new installations with a set of pages, couple of users, change the WP default options, activate a different theme, even pre-activate plugins and set their options. Everything that @Jessi above wants and more.

  15. Philip Downer

    Looks like there are several different ways to skin a cat in this case. Since the majority of my WordPress developments starts with a custom theme framework, I generally keep a sandbox environment that contains all my basic plugins, functions and theme files.

    Then, when I'm ready to start a new project, I'm able to simply duplicate the database, as well as the file/folder structure to get rolling.

    All settings, users, posts, etc. are kept intact.

  16. Omer Greenwald

    Very awesome! thanks

  17. Jürgen

    Don't forget register_uninstall_hook()
    to delete your values as well:
    delete_metadata()
    delete_option()

    Keep you system clean

  18. Benjamin Charity

    Can anyone help me transfer this into something that can be triggered by the theme? So that when they enable my theme, certain defaults are set that the theme needs? My PHP isn't too strong so any help is greatly appreciated!

    Thanks in advance!

  19. Jacob V

    But... THAT WAS EXACTLY WHAT I WAS LOOKING FOR!!!

    (sorry for the caps lock but it was intended)

    So nice!

2 pingbacks

  1. Standaard instellingen WordPress installatie | Hiranthi's weblog - Weblog van een ondernemende vrouw
  2. Plugin: Benutzerdefinierte Konfiguration… | Wordpress Lesezeichen