Interesting post on how to set up a client portal with the SupportPress WordPress theme.
Category Archives: wordpress
[link] Introducing the _s Theme
Link
Ian Stewart of WP’s ThemeShaper Introduces The _s Theme. He calls it a 1000-hour head start. I’m excited to dig into it a bit.
Bootstrap, a CSS Framework from Twitter
I ran across the Bootstrap, from Twitter today. What beautiful-looking code! This could be a great place to start with for a new WP theme or for any other site I’m working on.
Aside
WordPress 3.3 was just released. Make sure you get your update!
WordPress network on Dreamhost
WordPress, as of version 3.0, allows you to set up more than one site within the same installation. Each site uses the same core software and users can use the same credentials in all the sites they have access to across the network. Essentially, it allows you to set up a mini WordPress.com. Since I have a growing number of WordPress sites hosted at Dreamhost, I decided to set up a network of my own to reduce time upgrading and maintaining them and to simplify user management.
Also, I needed to move to secure (SSL encrypted) logins and admin areas. This is relatively easy to setup on a site-by-site basis, however, that would have meant a dedicated IP and SSL certificate for each site. With a WordPress network and domain mapping I can host websites at their own domain, but use one-centralized WP install, set of usernames and only one dedicated IP address and SSL certificate, securing all of the sites at the cost of one. Win-Win right?
I was a little wary of running the gauntlet and getting it all set up. Don’t be. It’s very easy, really. And you’ve got lots to gain by doing it. Here’s my instructions for getting a WP network set up on Dreamhost. The instructions would probably work on any other shared hosting with a couple changes. Let’s begin!
Things you’ll need
- A static, dedicated IP Address. (March 2011, costs $43.17 / year)
This is required so that the mapped domains can default to your primary domain if the domain is not recognized. As a freebie it allows you to do secure logins and administration (highly recommended). - Optionally, a yearly certificate. (March 2011, costs $15 / year)
If you want to do secure login and administration and people other than you are accessing the system, having a legit certificate means that they don’t have to accept an ‘insecure’ certificate. The certificate from Dreamhost is cheap ($15) and means less fuss when people are using the admin area.
Step 1. Install WordPress
I’m assuming you’re familiar installing WordPress. If not, you can download the latest version and read installation instructions at WordPress.org.
Step 2. Setup the network
Follow the instructions on how to Create a Network. If, like me, you do not have a Dreamhost PS (Private Server), be sure to choose sub-directory type of network. This means that your primary site will be at example.com and the next sites would be at example.com/site2, example.com/site3 and so on. Without a Dreamhost PS you won’t be able to set up the sub-domain type network since it requires that Dreamhost manually add a wildcard apache directive, which they’re not wont to do for anyone, especially those without a PS account. A sub-directory network will actually work fine, you’ll just want to be installing a new site as your primary site, not converting a site that’s been round for more than a month as there could be collisions with the permalinks (there is a note about the reason for this in the link above). Since we’re planning on doing domain mapping anyway, sub-domains are not really necessary.
Step 3. Install the Domain Mapping Plugin
Installing WordPress MU Domain Mapping is relatively straightforward and there are lots of details about A and CNAME records on their site. You can go either way with A or CNAME records. I’m using A name records to get the mapping setup.
Step 4. Add the Static IP and (optionally) SSL Certificate
You need a dedicated IP address in order to get the network set up correctly. Without it, you can’t be guaranteed that your IP won’t change and you would also have issues with other domains on the same shared IP. The general idea is that WordPress will return the appropriate site if it recognizes the incoming domain name, if it doesn’t recognize it, then WP returns your primary site.
To add the static IP, login to the Dreamhost panel and go to your list of domains and click “Add IP” underneath the domain name. They’ll ask for some information and ask you to agree to the yearly or monthly charge. By default you’ll get a self-signed certificate which will make your site secure, but visitors will get an alert saying that the site is not trusted. To get a signed SSL certificate, you can purchase one from wherever you want, or from Dreamhost. Dreamhost’s is pretty cheap and no work at all to set up. As of March 2011, the signed certificate costs $15 / year.
After setting up the IP, you’ll want to make sure your primary domain’s DNS A record points to this new IP address. If you have the DNS for your primary domain hosted at Dreamhost you don’t have to worry about that.
Step 5. Mapping domain names
After you created a new (non-primary) site in your network, you’ll want to map that domain to the new WordPress site. In each site’s admin area under Tools you’ll find an option called Domain Mapping. That’s where you can enter the domain name so that WordPress knows about it.
You also have to edit the DNS for domain that you want to map and add an A record that points to your new static IP. Once the DNS propagates, WordPress should start responding for your new domain.
Update Otto has a good walkthrough setting up the Domain Mapping Plugin.
Step 6. Secure Login and Aministration
There are instructions on WordPress.org for setting up Administration over SSL. The conclusion is that you need to add the following lines to your wp-config.php file. Note that if the DNS change on your primary domain from a shared IP to a static IP hasn’t propagated, then this will lock up the admin area, so proceed accordingly.
[code]
define('FORCE_SSL_LOGIN', true);
define('FORCE_SSL_ADMIN', true);
[/code]
Presentation: WordPress Off Road
Here are the slides from my presentation at WordCamp Minneapolis / St. Paul, 2010.
I talked about a PHP class I wrote called wp_posts, how to update options across multiple WordPress sites in a WordPress multisite installation, and how to get LDAP authentication for multisite WordPress up and rolling.
Speaking at WordCamp MSP, 2010
I’m going to be speaking at WordCamp Minneapolis 2010 on November 13.
My presentation is titled WordPress Off Road. I’m going to talk about integrating WordPress with a multi-faceted (non-WordPress) website. I will be introducing a PHP class called wp_posts for exporting WordPress posts, scripts I’ve developed for maintaining multi-site WordPresses and experiences setting up LDAP authentication.
Register now – I look forward to seeing you there!
WP Plugin: Widget Context
Last night I ran across a WordPress plugin called Widget Context by Kaspars Dambis. The plugin gives you the ability to control on what context any widget will show up in, allowing you to narrow down widget content to certain types of posts / pages, to certain categories and URL’s. It’s really useful and allowed me to do some things within WordPress rather than making an ugly hack to a template — making things easier to maintain for non-developers in the future.
Currently, I’m using the plugin to show a custom menu on a certain set of sub-pages over on Mt Zion Church‘s website. Any WP developers out there, let me know if there’s a better way, but thanks Kaspars for the plugin — it’s certainly useful.
LDAP authentication for multi-site WordPress 3.0
I manage two WordPress installations with multi-site (previously WP MU). Logins via LDAP would be ideal. I hadn’t had any luck making the existing LDAP plugins to work with Novell eDirectory. However, we just moved to use Active Directory (AD) and so I retried some of the plugins. I now have Simple LDAP Login (plugin) working. Since I’ve installed it on a multi-site installation I made some further modifications to the plugin. Here’s how I did it.
I wanted the plugin to run on any blog so I put it in the mu-plugins folder. Anything in wp-content/mu-plugins will be run on every blog in the system and doesn’t show up in the ‘Plugins’ menu to activate / de-activate. After copying the plugin into the mu-plugin you also have to create a file in mu-plugins that includes a specific plugin file since WP won’t include folders in mu-plugins like it does with the plugins folder — it only executes the files in the mu-plugins folder itself. To cater for this, you must change the following line in Simple-LDAP-Login.php:
|
1 |
require_once( WP_PLUGIN_DIR."/simple-ldap-login/adLDAP.php"); |
to:
|
1 |
require_once( WPMU_PLUGIN_DIR."/simple-ldap-login/adLDAP.php"); |
I wanted the configuration for the LDAP plugin to be only accessible to Super Admin users to that individual users of any of the blogs in the system, even administrators wouldn’t be able to mess around with the settings for the pluing. To do this, you need to find the call to add_options_page() in Simple-LDAP-Login.php and change it to:
|
1 |
add_options_page("Simple LDAP Login", "Simple LDAP Login", 'update_core', "simple-ldap-login", "simpleldap_menu"); |
The key here is the third argument. This requires that in order for a user to see this options page the user must have ‘update_core’ capability. This capability is possessed by Super Admins. See more about WordPress Roles and Capabilities.
Finally, I created a quick PHP script that will update the blog options sitewide. Point it at a WordPress database, and edit it to adjust settings that you want and this will update the options on all blogs (with exceptions if you like) on a WordPress installation. The script is rough and ready and there no protection for SQL injection, so be careful if you’re thinking about hooking this up to some user input.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
<?php
// a quick script to update blog options in a WordPress 3.0 multi-site environment.
$conn = mysql_connection(...); // insert your db connection info here.
// options to set. this just alters options in the wp_*_options table
// with these 'option_name' => array('value' => 'option_value', 'autoload' => 'autoload')
$options = array(
// format: '<option-name>' => array('value' => '<option_value>', 'autoload' => '<yes|no>'),
// examples
"simpleldap_account_suffix" => array('value'=>'@domain', 'autoload'=>'yes'),
"show_avatars" => array('value'=>0, 'autoload'=>'yes'), // hide avatars.
);
// blog id's to exclude.
$wp_id_exceptions = array();
foreach( get_option_tables( $wp_id_exceptions ) as $table ) {
echo "processing TABLE ". $table."n";
update_options($options,$table);
}
function get_option_tables($wp_id_exceptions) {
global $db;
$query = " show tables like 'wp_%_options'";
$result = mysql_query($query);
if ($result) {
$tables = array();
while($row = mysql_fetch_row($result)) {
$add = 1;
foreach($wp_id_exceptions as $id) {
if ($row[0] == "wp_{$id}_options") {
$add = 0;
}
}
if ($add) {
$tables[] = $row[0];
}
}
}
return $tables;
}
function update_options($options,$table) {
global $db;
foreach($options as $opt_name => $info) {
$insert = "insert into $table (option_name, option_value, autoload) values ('$opt_name','{$info['value']}','{$info['autoload']}')";
$insert_result = mysql_query($insert);
if ($insert_result) {
echo "t inserted OPTION $opt_name = {$info['value']}n";
}
else if (mysql_errno() == 1062) {
// attempt to update what's already there.
$update_query = "update $table set option_value = '".$info['value']."', autoload = '{$info['autoload']}' where option_name = '$opt_name' n";
$update_result = mysql_query($update_query);
if ($update_result) {
if (mysql_affected_rows()) {
echo "t updated OPTION $opt_name = {$info['value']}n";
}
else {
echo "t no change OPTION $opt_name = {$info['value']}n";
}
}
else {
echo mysql_errno() . " " . mysql_error()."n";
}
}
else {
echo mysql_errno() . " " . mysql_error(). "n";
}
}
}
?> |
I wrote this script to keep the LDAP plugin up-to-date across blogs, but it has already proven really useful for other purposes.
Update 2010/11/11
If you want to run this update script everytime that a new blog is created, then you can add the following code to a file inside wp-content/wp-plugins. By doing this, you can ensure that as soon as a new blog is created, they should have LDAP authentication right away.
|
1 2 3 4 5 |
function update_blog_options($new_blog_id) {
file_get_contents('http://www.domain.com/path/to/update_script.php');
}
add_action ( 'wpmu_new_blog', 'update_blog_options', 50 ); |
Let me know if you have any comments or questions and your experiences installing LDAP authentication for WordPress.
WordPress install and updates with subversion
I’ve installed or upgraded WordPress a number of times recently – most of the time upgrading some older versions to the latest WP 3.0. I read on a couple of the WP folks’ blogs that they use subversion to keep their blogs up to date. So when I set this blog up, I decided to use subversion to keep things up to date. You’ll need to be reasonably comfortable with the command line and have shell access to your web server. You will also need subversion (svn) installed on your web server.
Step 1. Go to the directory that serves up your website
For me this is ‘room329.com’.
|
1 |
<code>cd ~/room329.com</code> |
Step 2. Checkout the latest version of WordPress
The following command pulls the 3.0 tag or version of WordPress into the current directory.
|
1 |
<code>svn co http://core.svn.wordpress.org/tags/3.0/ . </code> |
To see what tags are available, visit http://core.svn.wordpress.org/tags/.
Step 3. Done!
That’s it. Continue to set up your WordPress installation as you would normally.
Updates
For minor updates, the following command will pull the latest build of the current version of WordPress (3.0 if you used the command above).
|
1 |
<code>svn up</code> |
To upgrade to a new version of WordPress use the following command, replacing 3.0 with the tag of the version that you want to switch to.
|
1 2 |
<code>cd ~/room329.com svn sw http://core.svn.wordpress.org/tags/3.0/ . </code> |
More details can be found all of this on WordPress’s Updating WordPress with Subversion.

