[WPMU Tutorials] Change the default theme for sites without a plugin

There’s a new and very little documented feature in 3.0 for changing the default theme. And? This will work on single WordPress installs as well as being handy for a network of sites.

The magic line is this in your config file:

define('WP_DEFAULT_THEME', 'classic');

In this example, the classic theme is used as the default when a site is created, or when a theme in use is removed. If you are starting fresh with 3.0, the default is the new TwentyTen, so this override is handy.

Added tip: if you have a lot of blogs using the Kubrick theme and wanted to remove it and set the other blogs, do this define first with your new default theme, then remove or rename the Kubrick theme folder (in my it was simply “default”). On a refresh, all blogs using the Kubrick theme will be switched to your new default.

If you just wanted the Kubrick theme to go away and have twentyten show up, you won’t need to do the define above. Just rename the /default/ theme folder. It’ll kick in.

(thanks to Ron for reminding me & MichaelH for the codex note I missed)

Random Posts

     

    © andrea for WPMU Tutorials, 2010. | Permalink | 5 comments | Add to del.icio.us
    Post tags:

    Need real genuine helpful support? MU Support.

    Feed enhanced by Better Feed from Ozh

    [WP First Aid] Upgrade wp_list_pages() to wp_nav_menu()

    Following in the series dealing with upgrading to the wp_nav_menu() function in WordPress 3.0 from menus derived from the template tags: wp_page_menu(); wp_list_pages(); and, wp_list_categories(). This post will be covering the options involved in updating to wp_nav_menu() from wp_list_pages().

    Like the last post in the series we will look at the default arguments used by each function, starting with wp_nav_menu() 1:

    wp_nav_menu( array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '', 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'depth' => 0, 'walker' => '', 'theme_location' => '' ) );
    

    The following is a default “menu” version of wp_list_pages() 2, 3, often wrapped within a <ul class=”menu”> tag:

    <ul class="menu">
    <?php wp_list_pages( array( 'sort_column' => 'menu_order, post_title', 'include' => '', 'exclude' => '', 'exclude_tree' => '', 'child_of' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'title_li' => __(''), /* 'title_li' set to '' for menus from the default 'Pages' */ 'authors' => '', 'echo' => 1, 'link_before' => '', 'link_after' => '', 'depth' => 0, 'walker' => '' ) ); ?>
    </ul>
    

    Here is the break-down of the wp_list_pages() default options from above:

    • 'sort_column' – not used
    • 'include' – not used
    • 'exclude' – not used
    • 'exclude_tree' – not used
    • 'child_of' – not used
    • 'show_date' – not used
    • 'date_format' – not used
    • 'title_li' – not used, see below for additional notes
    • 'authors' – not used
    • 'echo' – similar to wp_nav_menu(); true versus 1 as value
    • 'link_before' – same as wp_nav_menu()
    • 'link_after' – same as wp_nav_menu()
    • 'depth' – same as wp_nav_menu()
    • 'walker' – same as wp_nav_menu()

    Similar to wp_page_menu(), the ‘sort_column’, ‘include’, ‘exclude’, ‘exclude_tree’, and ‘child_of’ are replaced via the end-user’s specific choices. The ‘show_date’ and its related ‘date_format’ option, as well as the ‘author’ argument, are not available within the default wp_nav_menu() structure. Once again, the balance of the default options in wp_list_pages() matches the defaults found in wp_nav_menu().

    Also consider setting the wp_nav_menu() fallback_cb option to 'fallback_cb' => 'wp_list_pages'. This backward compatibility may also be addressed with a custom function as posted by Nicolas Kuttler.

    Note: If the 'title_li' => __('') option was being used it may also require the removal of the wrapping <ul> tag in the existing menu structure created with wp_list_pages().

    [Desperately Seeking WordPress] The Argument between WordPress and Thesis for the Lay Person

    There’s a big kafuffle going on right now in the tweet/ wordpress/ social world.

    Have you heard?

    Dave of ThinkDave.com summed it up the best:

    1. Bill Erikson sent out a Tweet explaining that WordPress had dropped him as a developer because he suppports Thesis (they feel Thesis violates the GPL).
    2. A bored 12-year old in Elbonia injected some malicious code into the Thesis 1.7 and 1.8 Beta releases, so that anyone installing the theme from these downloads got infected. It’s fixed now
    3. Matt smacked Chris across the face with a wet fish, suggesting he doesn’t know how to code (how many times has a WordPress site been hacked, Matt?)
    4. Chris shouted at Matt for an hour on Mixergy.
    5. Matt sounded bored, like he was reading from a script his lawyers prepared.
    6. Chris challenged Matt to a duel in the highest court in the land.
    7. Matt said he might just do that.
    8. Andrew Warner gave up trying to convince (a) Chris to go GPL with Thesis, and (b) Matt to leave Chris alone.
    9. #thesiswp trended on Twitter and everybody from me to a dodgy affiliate in Delhi chimed in with an opinion that at the end of the day, doesn’t matter one little bit. Even so: [Read the rest of Dave's Post here]

    For those panicking about their Thesis Installation

    Nothing to fear – this could all fizzle away or land in courts for years on end. WordPress isn’t about to stop Thesis from working, nor could they according to their own license. And Thesis isn’t about to just leave WordPress – they can’t. So things are pretty well stuck for the time being. Your Thesis-ified sites are safe.

    What is the GPL and why the fuss?

    It is my understanding that the GNU GPL (General Public License) basically says that the source code of whatever you create must be available, and it is your choice whether you sell or give away your creation. The only restriction is that the GPL is passed on with any copies or derivative works.

    WordPress’s position is that any theme or plugin created for WordPress is a derivative work and therefore MUST be licensed by the GPL as well.

    Chris Pearson, and Thesis’ position is that his creation is not derivative and he can license it any way he pleases. And he pleases to make money. (As do we all!)

    This is a problem, because Matt Mullenweg sees this contradiction as unethical and stunting the growth of the open source community by ‘taking away’ the thesis code from the GPL.

    Whats with all the testosterone?

    It has become a bit of a pi$$ing match, because Chris Pearson is a bit of a hot head. And I mean that in the nicest way, but seriously? I dont follow him on twitter any longer because he was making remarks years ago ‘in good fun’ that were just infuriating me. But I digress…

    How do our themes measure up?

    Unless otherwise requested, we use StudioPress themes as our preferred framework. They are licensed by the GPL in accordance with WordPress’s official position on their licensing. Studio Press offers their framework and themes for a fee. Under the GPL, I am free to just take that code, and give it away from my site here. The only restriction is that it contain a copy of the GPL as well.

    Our themes? The majority of each theme is released under the GPL, because we use StudioPress, and as such, we are required to license our derivative works the same way. So theoretically, you could take what you purchase from DSWP, post it on your site, and let people take it – as long as they maintain the GPL on it.

    The Exception to the Rule

    The only thing that I can license separately are the images that we create and the css files that are separate css files from the StudioPress themes. So it gets a bit technical. But anyhow, it doesn’t really make a difference if I slap on a different license, most people want me to do that work for them, and each website to be customized to their specifications.

    Strictly, Cathy Speaking

    I suppose I’m old school, or I simply don’t understand the ‘freedom’ the GPL offers, but I’m a fan of traditional business models – you do GREAT work, and then people will pay for it. You do exceptional work, and people will pay more. You have great customer service, people will tell their friends. Seems kind of straight forward to me.

    So you want a StudioPress theme for free?

    You wont get it here. Sorry.

    I will only distribute their GPL themes with my own modifications for a fee, and (regrettably) under the GPL license. Once it is yours, you are free to do with it as you please, except for the images and css files. But all my fabulous clients, value the theme that they have paid top dollar for, and will keep it locked away to be safely on display on their site alone.

    The Trends for the Future

    If Matt and the GNU GPL folks get their way, software will become more and more open-source. It will be available for the good of everybody, where anybody can contribute to create the best possible experience for the end user. The thing that you can’t package and license is the technical support. More and more, developers are offering technical support as a service, either packaged with a software product or alone. And for me, that is the most exciting part.

    The exciting thing about WordPress is that for the life of your website, it can now be upgraded with the click of a button, extended with plugins, and content created by yourself. It brings website development into the hands of the everyday internet user. And where those users need an extra hand or dont want to be bothered with their own website, we are always here to assist in any way we can.


    [WPMU Tutorials] Last updated sites widget

    This is a handy little widget that will pull a list of all the sites in your network and order them by last updated. The code for this was originally in the home theme of the WPMU download, so thanks to Donncha for that bit. ;)

    Last Updated Sites widget (39)

    I tested it in the mu-plugins folder, but you should also be able to use it as a regular plugin as it only needs to run on one blog. It’s also the older widget code, so you can only use it once, not multiple times, and it has no options. Short, sweet & simple.

    Random Posts

       

      © andrea for WPMU Tutorials, 2010. | Permalink | No comment | Add to del.icio.us
      Post tags:

      Need real genuine helpful support? MU Support.

      Feed enhanced by Better Feed from Ozh

      [WPMU Tutorials] Get a list of the latest sites or blogs in the network

      From the archives (which are full of good things, btw) I revamped a post with an updated version of the List All plugin, and confirmed the Most Recent Blogs widget still worked. It does!

      So, if you’re looking to have a widget that will show the last ten blogs, go get it here.

      Random Posts

         

        © andrea for WPMU Tutorials, 2010. | Permalink | No comment | Add to del.icio.us
        Post tags:

        Need real genuine helpful support? MU Support.

        Feed enhanced by Better Feed from Ozh

        [BlueFur.com Web Hosting] WordPress Wednesday: SEO Slugs

        Search engine optimization is a very important whether you are running a small blog or you are trying to promote your business website. If you have WordPress as your chosen content management system, you also have access to a wide range of plugins and customizations that can aid you in this effort.

        An oldie but a goodie in this realm is SEO Slugs. This WordPress plug-in accomplishes one very simple task, but it does it very well. In short, it shortens the “post slug” portion of your URI, removing superfluous words. This generates a shorter URI and one that is more easily indexed by search engines like Google.

        The example used in the plug-in main page has a blog post called “What You Can Do Immediately For Higher Rankings.” If left at default, the post slug in WordPress would be “/what-you-can-do-immediately-for-higher-rankings”. By using the plugin, the slug is automatically shortened to “/immediately-higher-rankings.” That’s shorter and more efficient.

        For more information and to download SEO Slugs, head over to vretoolbar.com.

        [WP First Aid] Upgrade wp_page_menu() to wp_nav_menu()

        WordPress version 3.0 has been live for a while and a lot of people want to make use of the wp_nav_menu() functionality but they are using one of the older template tags: wp_page_menu(); wp_list_pages(); or, wp_list_categories().

        This post will be dealing with function arguments in common between wp_nav_menu() and wp_page_menu(). Follow-up posts will be covering wp_list_pages() and wp_list_categories(). I will not be covering the specific use for each function’s arguments; the idea is to help show how these options correlate to one another.

        Let’s start with the full default of wp_nav_menu() 1 explicitly displayed:

        wp_nav_menu( array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '', 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'depth' => 0, 'walker' => '', 'theme_location' => '' ) );
        

        Followed by the same explicit defaults of wp_page_menu() 2, 3:

        wp_page_menu( array( 'sort_column' => 'menu_order, post_title', 'include' => '', 'exclude' => '', 'show_home' => false, 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '' ) );
        

        Now onto updating wp_page_menu() to wp_nav_menu(), which turns out to be rather simple.

        Here is the break-down of the wp_page_menu() default options from above:

        • 'sort_column' – not used
        • 'include' – not used
        • 'exclude' – not used
        • 'show_home' – not used (see bonus section below)
        • 'menu_class' – same as wp_nav_menu()
        • 'echo' – same as wp_nav_menu()
        • 'link_before' – same as wp_nav_menu()
        • 'link_after' – same as wp_nav_menu()

        First off ‘sort_column’, ‘include’, and ‘exclude’ are replaced by the end-user’s choices using the UI of wp_nav_menu() found under Appearance | Menu in the dashboard. The balance of the default options are the same in wp_nav_menu(), with the exception of 'show_home' => false which is the “bonus” content.

        Upgrading from wp_page_menu() to wp_nav_menu() may be as easy as a simple find and replace operation.

        Bonus – Although the default in wp_page_menu() does not show a home page link you can add a custom menu item in wp_nav_menu() if you want one to appear. You may need to edit your theme to remove the orginal “home” link if one was being generated before upgrading.
        NB: You may also need to add this line of code to your ‘functions.php’ template file to add custom menu support to your theme: add_theme_support( 'menus' );

        [WPMU Tutorials] WP125 Ads Plugin

        We had a client who is using the WP125 Ads plugin. When they upgraded to WordPress 3.0, it was having an error. I fixed the error and forwarded it to our client. Other folks reported the same issue in this thread in the WP support forums. The author of the plugin posted and indicated he was going to be tied up for a bit. I have forward the update to the plugin author. At some point he will be releasing an updated version.

        In the mean time, you can download my updated version: WP125 Ads Plugin (74). If you have issues with it, please post those issues in the support thread linked above. I won’t be attempting to do other bug fixes or CSS changes.

         

        © Ron for WPMU Tutorials, 2010. | Permalink | 6 comments | Add to del.icio.us
        Post tags: Plugins, WordPress 3.0

        Need real genuine helpful support? MU Support.

        Feed enhanced by Better Feed from Ozh

        [Peter's Useful Crap] How to back up your site cheaply with Amazon S3 and s3sync

        The two main parts of WordPress and other popular CMS-powered websites are the database and the files. Your web host might keep regular backups of all elements of your site, but the unfortunate thing is that sometimes when your server is down, that is the most difficult time to access your host’s backups (as I discovered with a shared host). So it’s good to consider your own backup solutions.

        If you have a MySQL database, a simple mysqldump command can save the database as a file and you can potentially e-mail it to yourself if it’s small enough. With or without the dumped database file, you then have to back up the rest of the files. Dropbox is a creative solution, but an easier and more direct solution is to use Amazon’s Simple Storage Service, otherwise known as Amazon S3. S3 is a service that’s part of the much hyped cloud computing, a land of seemingly infinite data and virtualized resources. Amazon S3 is cheap, well-documented, robust, easy-to-use, and there are many good scripts to interface with S3. It is more than just a good backup option, but for this post I’ll only talk about it within the context of backups.

        Amazon S3’s costs are pay-per-use / pay-as-you-go and are split into a few categories:

        • Storage: starting at $0.15 per gigabyte
        • Data transfer in: Free until November 1, 2010; usually starting at $0.10 per GB
        • Data transfer out: starting at $0.15 per GB
        • Put and similar requests: 0.01 per 1,000 requests (if you have lots of files this will be the initial input)

        Account management in Amazon breaks this down really well into minute details. My blog is relatively small, as I’ve only accumulated about 100mb of files in 4 years and the database is less than 2mb compressed. My monthly cost for daily and weekly backups is less than 20 cents.

        Here are a few ways to get the most out of using Amazon S3 for backups:

        • Back up only what you need to. Most CMSs let you place all your modifications in one or only a few places. In the case of WordPress, if your entire site is contained in plugins, themes, and uploads, you might only need to back up the wp-content/ folder, since you could restore the rest of the site from a downloaded instance of WordPress.
        • Look into some of S3’s extra features, such as versioning and access control by IP as discussed in its FAQ
        • Although Amazon S3 claims to be designed to provide “99.999999999% durability and 99.99% availability of objects over a given year”, it could still fail at the same time that your server fails. To mitigate this already-small risk, you could back up to multiple S3 regions, or look at a supplementary backup service such as Rackspace Cloud Files
        • To actually access the backed up files, you can use the web-based AWS Management Console to view and download files, make them publicly accessible if needed, create “buckets” (top-level folders, which you can store in different physical locations). One of the more useful tools is a Firefox plugin called S3Fox Organizer, which lets you do much of the same stuff in a familiar explorer-like, two-panel interface (where you can drag-and-drop between your local file system on the left and the remote files on the right):

        Firefox plugin for browsing your Amazon S3 buckets

        If you need a step-by-step process to using Amazon S3 starting with the sign-up process, check out this post. Below are my notes on how to use the free s3sync and s3fs tools for the actual backup process. Both assume that you’ve already created a bucket via the AWS Management Console or S3Fox Organizer, although you can also use both tools to create buckets.

        s3sync

        s3sync is a script written in Ruby. Ruby is usually installed on Linux servers and is easy to install if needed.

        There are 3 main steps to start using s3sync.

        Download and extract the script

        You can currently download the latest version of s3sync at:
        http://s3.amazonaws.com/ServEdge_pub/s3sync/s3sync.tar.gz

        Then, you can extract the file through your control panel or with a simple tar command:

        tar -zxf s3ysnc.tar.gz

        Create a configuration file

        You’ll need to make a copy of the included s3config.yml.example file. It is very simple and has only two required lines:

        aws_access_key_id: your_access_key_id
        aws_secret_access_key: your_secret_access_key

        You can get both the access key ID and the secret access key on your account when you sign in to Amazon Web Services. Go to Account > Security Credentials.

        As for where to place the configuration file, take a look at s3config.rb. Line 15 shows:

        confpath = ["#{ENV['S3CONF']}", "#{ENV['HOME']}/.s3conf", "/etc/s3conf"]

        So you can either place the s3config.yml file in a self-defined environmental variable (if you have command line access); or in your user’s home directory (usually /home/yourusername/.s3conf/s3config.yml) or in etc/s3conf/s3config.yml. If all else fails, you can just edit s3config.rb and hardcode a path!

        Run the script

        Before you set up your full backup, you can test that your credentials and connection are working properly by listing the buckets on your account. The command is simply:

        ./s3cmd.rb listbuckets

        Note that s3cmd.rb needs to have executable permissions. If you don’t have command line / shell access to your server, you likely have access to a control panel where you can set up a cron job to execute s3cmd.rb. Just make sure that the cron job either refers to the full path where s3cmd.rb sits, or that it first changes directory (cd) into the folder to which you’ve extracted s3sync.

        If all is well, you can then run the full backup script and then set up a cron job to back up your files daily and weekly (or at whatever frequency you’d like).

        /path/to/s3sync/s3sync.rb -r /path/to/your/site theblog:daily

        The command would back up your site to an existing bucket “theblog” under a sub-folder “daily”.

        s3sync can also do many other Amazon S3 management tasks. Check the well-detailed README file for more information.

        s3fs

        s3fs is a simple solution for VPS and dedicated servers that enables you to mount an Amazon S3 bucket via a local FUSE file system. You can thus access your backup and sync it more or less locally.

        (A quick note to VPS users — first, make sure that FUSE has been installed on the hardware node of the VPS setup! Your hosting company will have to do this for you. Otherwise, you might struggle with errors that seem to be file permission related (“fuse: failed to open /dev/fuse: Permission denied”) but that are in fact not simply chmod, chown, or user group fixable!)

        If needed, install the fuse, fuse-devel, and curl-devel packages on your server. If you’re on Red Hat, Fedora, or CentOS, you can make use of yum:

        yum install fuse
        yum install fuse-devel
        yum install curl-devel

        Then, download and extract the latest s3fs source files from the s3fs website. You’ll have to compile the source, but that’s usually a simple “make -f Makefile” command. Then, move the s3fs binary into /usr/bin and you’re ready to mount the Amazon S3 bucket!

        /usr/bin/s3fs name_of_bucket -o accessKeyId=aaaa -o secretAccessKey=aaaa /mount_path

        As noted in the above s3sync notes, you can get both the access key ID and the secret access key on your account when you sign in to Amazon Web Services. Go to Account > Security Credentials.

        You can use the friendly rsync command to produce daily, weekly, or other frequency of backups:

        rsync -av --delete /path/to/your/site/ /mount_path/daily

        [A Fool's Wisdom] WordPress Activate Theme Action

        There isn’t yet a WordPress activate theme hook. In the last week, it’s come up twice where WordPress.com Hosting VIP partners wanted some code to run once on theme activation.

        It’s not an unusual scenario for our customers to create a new version of a theme, install it separately, and then activate it. Often this also allows reverting to the old version of the theme if something unexpected happens at launch.

        In this scenario, it’s often easy to check for the existence of a new option, migrated, or other seed data, but sometimes you want to do something like:

        global $pagenow;
        if ( is_admin() && 'themes.php' == $pagenow && isset( $_GET['activated'] ) ) { // When theme is activated this code runs. // Still be defensive if you need to be, and check if // your baby is already born
        }
        

        Hat tip Frank Bültge.

        Planet WordPress Canada theme by WPDesigner, syndication by Pipes, FeedWordPress, and Feedburner, powered by ?