Solution to slow WordPress Multisite (wpmu) admin

After an update to WordPress running WordPress MU (multisite) the root blog (ID1) went dead slow. Each request took about 1 minute! Every other site on the system was still running at normal speed.

We run a pretty complex setup with plugins like, WordPress MU Domain Mapping and Networks for WordPress (that lets ju run multiple main-blogs with it’s own child blogs).

My initial though was to reinstall WordPress and deactivate plugins and test the installation out. But no luck!

After some Google magic, I found this post at the WordPress support forums (user MacManX (James Huff)).

First step solved our problem!

1. Manually run /wp-admin/upgrade.php (visit it in your browser).

So run (but replace with your own, stupid!) and run the upgrade wizard and you should be fine, if not; follow the other suggestion in the support post.

I suspect that db_version in wp_options did not match the new WordPress install. and WordPress, play nice.

Just discovered a great new service,

“Hosting websites has never been this easy
Keep your websites up and running. Zero server hassle.”

One great thing is the ability to clone (or duplicate) an installation of WordPress (like a staging sever), but that is _exactly_ what it is, a copy. That means that the clone has the root installation URL, so when you try to log in at your new clone it points back to your root installation, not cool. A feature request is made, but in the meantime this following method is a poor mans solution to the problem.

Open up wp-config.php and paste this:

Then visit (Not /wp-admin, didn’t work for me at least) (Replace with your own URL).

You should now be able to access the new (clone) admin.

You should now prob remove the line in wp-config.php

Read more @ WordPress Codex.

Sending mail with Mandrill & PHP (MailChimp)

Hi there

Short post about sending mail through the Mandrill-system.

“Mandrill is a scalable and affordable email infrastructure service, with all the marketing-friendly analytics tools you’ve come to expect from MailChimp.”

Download the latest release (working 2014-16-04). Grab the /src.

Create an API-key @

Put for example mail.php (code below) in the root folder (with /src).

Full API docs.

A dead crappy simple node.js chat with telnet

Stolen from Prerequisite: node.js installed (


create chat.js (with the code from down under)

  • type node chat.js in the terminal
  • open a new terminal-window
  • telnet 8000
  • chat away

Bonus: on a local company net? get your IP (ifconfig) and telnet into that, share it with your friends.

Move a WordPress Multisite installation to single installation

From the multisite installation

  1. Download export-file from Tools -> Export
  2. Download the theme
  3. Download any dependent plugins

The single installation

  1. Install a clean WordPress single installation.
  2. Activate theme and any dependent plugins
  3. Import the xml (choose to download attachments if so)
  4. Go

Website Facebook feed, take 2 a more robust way!?

In a previous post we walked through a way to get a Facebook feed onto your site.

This post is about a more robust(?) way to get the work done!

This solution always provides you with a valid access token. You don’t have to create one yourself.

First the code and the walkthrough below.

Line 1 – 4: Fill in your app id, app secret, the redirect url and the page id you want the feed from.

Line 6 – 9: Here we get an access token (app token) with grant type of client_credentials. Read more about Facebook access tokens.

On line 13 – 16 we query the Facebook graph API to get the data from our page. We use FQL to fetch the result. Read more about FQL and what data to get from the tables.

Line 17 then JSON-decodes the response in an array.

Output the data

We run through the data with foreach.

On line 4 we get any attachments and suppress any warnings/notices with the @-sign (@$data).

We then run a inline foreach to get all the attachments (only photos in this case) and echos out the src for the image. Note that the [1] on line 7 gets the second element in the array. Without any deeper investigation I believe you get the largest image. The first element is the small (_s), thumb. (See below for an alternative solution).

Alternative image solution

In the $image object there is ‘src’ ($image[‘src’]), where you get the small source (_s). You can then use the same replace-method in the previous post to get the normal (_n) one.

Source on git

Website Facebook feed

A twitter friend asked me about creating a custom feed for a Facebook wall. Pretty easy with the php sdk, but when I looked at the source it turns out I made it another way. Better or worse? You tell me.

The dirty secret

PHP’s file_get_contents. Here goes.

You need an access token for this, get one like this (small warning, it may expire). Create a Facebook app and add the client_id and client_secret like below.********7221&client_secret=b4a761c0a6************9692ffd58&grant_type=client_credentials

This will return the access token needed to get the content of the Facebook page.

Now your variable $content (from above) will contain a JSON-feed.

Decode it with

Then run a foreach to output the array (see below for code explanation).

Line 2: If there is Facebook wall posts (called messages in the JSON) then on line 4 output the message with the WordPress wpautop-function

If there is a image (line 6) then print the image but replace the small feed image with a bigger one (from _s (small) to _n (normal).

On line 9 output the updated time with a custom time ago-function. Tho you could use WordPress built in function for this: human_diff_time

Download source/example-file

The dive into Handlebars and Ember.js

It is time! Time to talk Handlebars and how to use them in Ember.js or how Ember uses Handlebars.

If you want to follow along, get a copy of the Ember Starter Kit.

Open up the app.js and add the following code right before the App.Router.

(we are creating (create();) an instance of a class, therefor we use a lower case – personController, while when extending (extend();) a class we use a capital letter)

Here we are creating a controller naming it personController, and setting its content to some static content.

In your index.html put the following right after the body.

The ‘each’ loops through the content in the personController and outputs each name. The ‘#’ means start of the handlebar view and ‘/’ is the end point.

Run the app and it should output:


The Bonus part

To enhance the app somewhat we add a model. Right before the personController add:

This adds a new model, class (whatever you want to call it). Setting a name and setting it to null is not necessary but it can help to remember what properties the model exists of(f)(?) <- (hey I'm swedish).

Add this to your personController:

this._super(); calls the parent class (super is a reserved to JavaScript hence the underscore _ ) and you need to do this inside the init so the init method will be called all the way up the prototype chain. (source Cerebris)

Then we create a instance (person) of the class Person and set its name property to ‘Linda’ and finally push (add) this to the content array.

Running the app should yield the following result:


Get the source files.

Unsolved issue

Doing a console.log() last in init reveals the following:

Screen Shot 2012-12-19 at 22.08.41

The first two are objects but the last one is ‘c’, the one we created from a class, stand s for class?

Diggin’ deeper into Ember.js

I guess with Ember 1.0.0-PRE.2 the smallest application is.

An Ember-app MUST have the ApplicationView and the ApplicationController. It must be named exactly like that and without it the root view could not render any content.

The Router

The router is keeping track of your app’s state. The router must have two routes. The first must be named root and the second (index) is where Ember looks at the init, must have ‘/’ as path.

Next we are going to check out a more hands on example. Building a small app with some Ember outlets and look at how the template system (Handlebars) is working.

A bonus video

This guy is a lot smarter than me, check out the video

The Ember MVC

Model, View, Controller. That spells M V C.

The model is where the data is kept. It’s the blueprint. For example: Model describes a Person. A Person has a name and an age. In Ember.js we create a model like this.

The view is the visual layer. It’s what you see and interact with. A form, a bullet list etc. To define a view type:

And last but not least the controller. The controller is the bridge between the model and the view. When someone, for example, clicks a button the controller gets input from the view and preforms actions on the model (CRUD).

In the controller the information about your (in this case) Person(s) will be stored.

And that wraps it up for this time.