Tag: WordPress

  • Piwik GPL web analytics

    Piwik is an open source (GPLed) web analytics program. It looks very comprehensive. I will endeavour to install it and test it out soon. I’ll report back on it when I do.
    There is also a WordPress plugin for Piwik.
     

  • Apache Virtual Host configuration for a Networked WordPress Installation

    Direct any URL request that Apache receives to the WordPress installation. You need to do it if you are setting up a WordPress Network multi-site installation that has sites with their own unique domain names. e.g. site1.org, site2.com, someothersite.co.uk etc.

    /etc/apache2/sites-enabled$ ls -al
    total 8
    drwxr-xr-x 2 root root 4096 Jul 25 13:18 .
    drwxr-xr-x 7 root root 4096 Jul 24 12:28 ..
    lrwxrwxrwx 1 root root 40 Jul 24 12:06 000-wordpress-network-ssl -> ../sites-available/wordpress-network-ssl
    lrwxrwxrwx 1 root root 36 Jul 24 12:02 010-wordpress-network -> ../sites-available/wordpress-network
    

    Order of the files is very important. wordpress-network contents below:

    <VirtualHost *:80>
    UseCanonicalName Off
    ServerAlias *.examplehost.com examplehost.com
    ServerName examplehost.com
    DocumentRoot /var/www
    Options All
    ServerAdmin myname@examplehost.com
    # Store uploads of www.domain.com in /srv/www/wp-uploads/\
    <VirtualHost *:80>
    UseCanonicalName Off
    ServerAlias *.examplehost.com examplehost.com
    ServerName examplehost.com
    DocumentRoot /var/www
    Options All
    ServerAdmin myname@examplehost.com
    # Store uploads of www.domain.com in /srv/www/wp-uploads/$0
    RewriteEngine On
    RewriteRule ^/wp-uploads/(.*)$ /var/www/wp-uploads/%{HTTP_HOST}/$1
    # try and make server-status return server status
    #RewriteRule ^/server-status - [L]
    RewriteCond %{REQUEST_URI} !=/server-status
    <Location /server-status>
    SetHandler server-status
    Order Deny,Allow
    # Deny from all
    # Allow from localhost
    Allow from all
    </Location>
    <Directory />
    Options FollowSymLinks
    AllowOverride All
    </Directory>
    CustomLog /var/log/apache2/access.log vhost_combined
    ErrorLog /var/log/apache2/error.log
    # this is needed when activating multisite, WP needs to to a
    # fopen("http://randomname.domain.com") to verify
    # that apache is correctly configured
    php_admin_flag allow_url_fopen on
    </VirtualHost>
    
    RewriteEngine On RewriteRule ^/wp-uploads/(.*)$ /var/www/wp-uploads/%{HTTP_HOST}/\ # try and make server-status return server status #RewriteRule ^/server-status - [L] RewriteCond %{REQUEST_URI} !=/server-status <Location /server-status> SetHandler server-status Order Deny,Allow # Deny from all # Allow from localhost Allow from all </Location> <Directory /> Options FollowSymLinks AllowOverride All </Directory> CustomLog /var/log/apache2/access.log vhost_combined ErrorLog /var/log/apache2/error.log # this is needed when activating multisite, WP needs to to a # fopen("http://randomname.domain.com") to verify # that apache is correctly configured php_admin_flag allow_url_fopen on </VirtualHost>
  • Migrating single site WordPress installations to a multisite network

    I have seen this question about migrating to a networked multisite WordPress install come up more than once so I thought I’d write down my experience. I used to host about 10 individual WordPress installations. Managing them and keeping them all up to date was a pain, and that meant I always had sites that were out of date. So a few months ago I spent some time migrating them all to a new WordPress network installation. That allows you to host multiple sites all in the one WordPress installation. The only problem is that its quite cumbersome to migrate sites into the new site.
    I’ve tried to document the overall process. If anything isn’t clear please let me know and I’ll and elaborate.

    1. Backup all your old sites and databases
    2. Go to each site and export the site
    3. Select a suitable main domain name for your new networked WordPress site. When you create a new blog in the network, the admin of the blog will get an email from your multi site saying it was set up, so choose something that is suitable bearing that in mind.
    4. Set up the multi site with subdomain (not sub folder).
    5. Set up apache virtual hosts to direct ALL host traffic to the wp install.
    6. Set up subdomain sites for each site you wish to import.
    7. Install the WordPress MU Domain Mapping plugin
    8. For each subdomain:
      1. Import the old blog
      2. re-delegate the domain or set your hosts file up to point the domain name to your new WordPress network.
      3. On the Info tab in your network settings for the domain, change the Domain to the actual domain you want,
      4. On settings tab, change siteurl to the blogs correct domain,
      5. Change “home” to the correct domain
      6. Check through the list and fix up any other instances of incorrect domain. Save the changes.
      7. Note down the site id (from the url. something like: http://mynewmultisite/wp-admin/network/site-settings.php?id=4  means site ID is 4)
      8. Go to Settings/Domains and in the New Domain section, enter the site ID and correct domain for the new site
      9. Click save and that’s it – the new domain should be working. Test it out.
      10. Fix up all the old links to images. they will currently be links with the old subdomian in them. You can fix them up with the most excelent Search and Replace plugin.
    9. That’s it, you should be done.

    It’s a fairly long winded process but it can be done and is worth the effort. Running a networked site instead of many individual installs saves a lot of time in upgrades and  maintenance.
    Moving across the plugins and themes is also a bit of a pain. You just have to manually do it per site. There are plugins that are supposed to help move widget settings across but I had limited success with them. “Widget Data – Setting Import/Export Plugin” seemed to add the settings not replace them so you end up with duplicates of widgets and things. it may have improved since I tried it.
    I don’t like to site wide activate plugins but WordPress does not have an option like with themes, to only enable a plugin on a per site basis. There is however a plugin for that: Multisite Plugin Manager. With that you can turn on plugins for each site in the Network Admin/Edit Site area. Then you have to go to the site’s dashboard and activate the plugin in there afterwards.
    Another useful plugin for a networked site is called “Network Plugin Auditor” it adds a column to the Network/Admin/Plugins page that shows which sites are using each plugin. It also also shows the converse on the Sites page.
    There are tools to assist this process also. One such tool that comes highly recommended, that I have not personally used is Backup Buddy. If you have more than a few sites to migrate it may well be worth investing in something like that to help you.

  • CSS Arrows

    cssarrowplease makes lovely speech bubbles in pure CSS.

  • Twenty Twelve WordPress theme

    I switched to using the Twenty Twelve WordPress theme a few days ago. I really am liking it although I’m not sure about the header image being below Site Title and Tag Line. That looks a little strange to me.
    Having said that, I think Twenty Twelve looks fantastic on the demo site.
    Currently you have get Twenty Twelve from the WordPress trac repository as as far as I know it is not released yet. They will release it as a stand alone theme soon I believe, so you can try it out before WordPress 3.5 is released.
    I did a git clone of the WordPress code mirror on github, into my home directory. Then I symlinked the ~/wordpress-git/wp-content/themes/twentytwelve directory to my live WordPress install path. That way I can simply do a git pull to update the theme.

  • \(\LaTeX\) Equations in WordPress using MathJax

    I came accross this great tool for displaying mathematical equations the other day. MathJax not only supports \(\LaTeX\) syntax but also renders the equations as pure text, so no unsightly images and they scale beautifully. You can also right click on the equation and see it’s \(\LaTeX\) code.
    The code for MathJax is open source, but if you don’t want to go to the bother of installing it yourself, you can use it on their CDN.
    There are a couple of plugins to enable MathJax in WordPress. I’m using the Simple MathJax plugin. I’ve not tried the others.
    To use MathJax simply mark up your equation with \[…\]. If you want to have an equation inline, use \(…\). You can also inline equations in the post title.
    Here are a few examples taken from the MathJax site:

    The Lorenz Equations

    \begin{aligned}
    \dot{x} & = \sigma(y-x) \\
    \dot{y} & = \rho x – y – xz \\
    \dot{z} & = -\beta z + xy
    \end{aligned}

    The Cauchy-Schwarz Inequality

    \[\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)\]

    A Cross Product Formula

    \[\mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix}
    \mathbf{i} & \mathbf{j} & \mathbf{k} \\
    \frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\
    \frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0
    \end{vmatrix}\]

    The probability of getting \(k\) heads when flipping \(n\) coins is

    \[P(E) = {n \choose k} p^k (1-p)^{ n-k}\]

    An Identity of Ramanujan

    \[\frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} =
    1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}}
    {1+\frac{e^{-8\pi}} {1+\ldots} } } }\]

    A Rogers-Ramanujan Identity

    \[1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots =
    \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})},
    \quad\quad \text{for $|q|<1$}.\]

    Maxwell’s Equations

    \begin{aligned}
    \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
    \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
    \nabla \cdot \vec{\mathbf{B}} & = 0 \end{aligned}

  • \(\LaTeX\) Equations in WordPress using MathJax

    I came accross this great tool for displaying mathematical equations the other day. MathJax not only supports \(\LaTeX\) syntax but also renders the equations as pure text, so no unsightly images and they scale beautifully. You can also right click on the equation and see it’s \(\LaTeX\) code.
    The code for MathJax is open source, but if you don’t want to go to the bother of installing it yourself, you can use it on their CDN.
    There are a couple of plugins to enable MathJax in WordPress. I’m using the Simple MathJax plugin. I’ve not tried the others.
    To use MathJax simply mark up your equation with \[…\]. If you want to have an equation inline, use \(…\). You can also inline equations in the post title.
    Here are a few examples taken from the MathJax site:

    The Lorenz Equations

    \begin{aligned}
    \dot{x} & = \sigma(y-x) \\
    \dot{y} & = \rho x – y – xz \\
    \dot{z} & = -\beta z + xy
    \end{aligned}

    The Cauchy-Schwarz Inequality

    \[\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)\]

    A Cross Product Formula

    \[\mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix}
    \mathbf{i} & \mathbf{j} & \mathbf{k} \\
    \frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\
    \frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0
    \end{vmatrix}\]

    The probability of getting \(k\) heads when flipping \(n\) coins is

    \[P(E) = {n \choose k} p^k (1-p)^{ n-k}\]

    An Identity of Ramanujan

    \[\frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} =
    1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}}
    {1+\frac{e^{-8\pi}} {1+\ldots} } } }\]

    A Rogers-Ramanujan Identity

    \[1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots =
    \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})},
    \quad\quad \text{for $|q|<1$}.\]

    Maxwell’s Equations

    \begin{aligned}
    \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
    \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
    \nabla \cdot \vec{\mathbf{B}} & = 0 \end{aligned}

  • \(\LaTeX\) Equations in WordPress using MathJax

    I came accross this great tool for displaying mathematical equations the other day. MathJax not only supports \(\LaTeX\) syntax but also renders the equations as pure text, so no unsightly images and they scale beautifully. You can also right click on the equation and see it’s \(\LaTeX\) code.
    The code for MathJax is open source, but if you don’t want to go to the bother of installing it yourself, you can use it on their CDN.
    There are a couple of plugins to enable MathJax in WordPress. I’m using the Simple MathJax plugin. I’ve not tried the others.
    To use MathJax simply mark up your equation with \[…\]. If you want to have an equation inline, use \(…\). You can also inline equations in the post title.
    Here are a few examples taken from the MathJax site:

    The Lorenz Equations

    \begin{aligned}
    \dot{x} & = \sigma(y-x) \\
    \dot{y} & = \rho x – y – xz \\
    \dot{z} & = -\beta z + xy
    \end{aligned}

    The Cauchy-Schwarz Inequality

    \[\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)\]

    A Cross Product Formula

    \[\mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix}
    \mathbf{i} & \mathbf{j} & \mathbf{k} \\
    \frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\
    \frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0
    \end{vmatrix}\]

    The probability of getting \(k\) heads when flipping \(n\) coins is

    \[P(E) = {n \choose k} p^k (1-p)^{ n-k}\]

    An Identity of Ramanujan

    \[\frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} =
    1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}}
    {1+\frac{e^{-8\pi}} {1+\ldots} } } }\]

    A Rogers-Ramanujan Identity

    \[1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots =
    \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})},
    \quad\quad \text{for $|q|<1$}.\]

    Maxwell’s Equations

    \begin{aligned}
    \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
    \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
    \nabla \cdot \vec{\mathbf{B}} & = 0 \end{aligned}