• Stay in touch. Sign up for the 9seeds newsletter.
  • Inserting yourself as admin into WordPress

    On quite a few occasions I’ve had clients send me a complete backup of their site during the discovery period. Usually this is because they don’t have a Release Candidate / Quality Assurance / Staging / Development version(s) of their site where changes can be made, and approved, without affecting the live site.

    Without standing on my soapbox too long – if your website lacks a staging site, version control for custom code, or backups – you should address them immediately.

    In this case, I was glad the client had at least one backup (the one that was provided to me) which I could turn into a local WordPress installation to begin development. Since the client didn’t provide a WordPress Admin user and password, I just decided to insert myself into WordPress.
    [Read more...]

    Moving forums from SimplePress to BBPress

    I was recently asked by a member of our local WordPress meetup group which forum software I would suggest using. I mentioned that I had been using SimplePress for a while, but wasn’t in love with it. I had used BBPress quite a while ago, before it got the major revamp and if I had to choose which to use for a new site, I would go with BBPress. Then, with a stroke of great timing, the BBPress 2.3 beta was released the following day. Since it was fresh in my mind, I installed the beta to test it out. In short, BBPress has come a LONG way in the past year. So much so that we decided it was time to move our support forums off of SimplePress. That process would prove to be tricky.

    To follow are the steps I took to convert our forums from SimplePress version 4.4.0 to BBPress version 2.3

    Step 0

    Backup All The Things

    Seriously. Just do it.

    I went one step further than just backing everything up. Instead, I exported the database and set up a separate WordPress install just to run the conversion. This way, if everything broke I could simple delete it and start again. And now the actual conversion process.

    Step 1: Upgrade SimplePress

    When figuring out what it would take to do the conversion, I found that BBPress could convert SimplePress version 5 forums right from the tools menu. So in order to do the conversion, I first needed to upgrade SimplePress. Unfortunately, their upgrade only works with version 4.5.x. After reading this page, I took these steps:

    - Deactivate the SimplePress plugin (Do Not uninstall it, just deactivate it)
    - Remove the /plugins/simple-forum/ folder from your server
    - Download the latest version of SimplePress
    - Upload simple-press folder to /plugins/simple-press/ on your server
    - Activate the plugin

    Once the plugin is activated, you’ll have the “Forums” item added back to your menu which will link you to an upgrade process. Start the upgrade process and let it run. For our small forum this process took 3-4 minutes. I’m assuming for a larger forum, this process could take a bit longer. Be patient.

    After I ran the update, poking around the forums admin area, everything looked fine. I then checked the actual forums and found this message:

    SP error

    I was concerned that I had lost all my data, but the forum stats displaying below gave me some comfort.

    Forum Stats

     

    Step 2: Install BBPress

    Not wanting BBPress and SimplePress to colide, I started by deactivating SimplePress. I then uploaded the BBPress 2.3 beta to /plugins/bbpress/ and activated it from the plugins menu.

    Yeah, that part was pretty simple.

    Step 3: Import SimplePress forums

    Just a quick note. At the time of this writing BBPress 2.3 beta 2 has a bug related to importing of data. I posted a ticket about it in Trac and I’m sure it will be fixed soon. To get around the bug, I ran a search and replace on the database to remove any instance of   as it causes the post to be truncated upon import.

    Start by going to Tools -> Forums in the WordPress admin area, then click the Import Forums tab at the top. From the dropdown select SimplePress 5 and then fill in the database information. Just under that you’ll see a few options. The most important of which is the Convert Users option.

    The first time I ran the import, I was installing BBPress on the same WordPress installation that SimplePress had previously been installed on. This meant that all my user accounts already existed and their posts were all connected to them. I clicked the convert users tab prior to running the import, and all the posts, once converted, were once again attached to their rightful owners as part of BBPress.

    I then decided that I wanted to move my forum to a different WordPress install on a different domain. When doing so, I accidentally forgot to click the Convert Users checkbox. The results were less than optimal. All of the posts DID come over to the new installation, but they were all attached to a single user account. Oops.

    I can’t think of a reason (although, I’m sure there is one or this wouldn’t be an option) why you would ever want to NOT click the Convert Users checkbox. So before you click Start, make sure it’s checked.

    Step 4: Repair Forums

    After running the conversion in step 3, I was reviewing the forums and noticed that all the data appeared to be in place and the posts were all attached to the proper people, but, all of the counts were off. Anywhere where it said how many posts or replies were on a post or topic was all displaying zero. Back to the admin area we go. This time to Tools -> Forums and click the Repair Forums tab where you will find the following options:

    Repair Forums

    Taking the advice along the top, I clicked the first item in the list and then clicked Repair Items. It took a matter of seconds to complete. I then went through each item on the list, one at a time, and checked the box and ran the repair. When I was done I went back to the forums to find that all the counts had been updated and my forums were working perfectly.

    Once you know all the pieces, the process isn’t actually all that difficult. But hopefully I just saved you some trial and error time.

    Done Done. (as Chris Lema would say)

     

    WP Affiliate Manager version 1.5

    We’re glad to announce the release of WP Affiliate Manager version 1.5.0.  This version initially centered around a bugfix having to do with a namespace conflict in the latest (3.8.9.x) versions of WP e-Commerce.  However in the process, we were able to add several minor enhancements that will enhance WP Affiliate Manager for the future.

    gettext translation wrappers

    While not all screens have had the gettext translation wrappers applied (notably the settings and paypal pages in wp-admin), everything else has been added.  Expect a 1.5.x release early in 2013 that will be fully translatable.

    As such, we’re putting out a call for translators.  We are willing to offer free lifetime use & upgrades of the WP Affiliate Manager to anyone who contributes a full translation in their own language. We have a couple of people already talking to us about certain languages, so if you’re interested, please fill out the form on our translation page and let us know what language you’d like to help us add to WP Affiliate Manager!

    money_format() for Windows

    money_format() is a native PHP function, but it does not exist on Windows platforms.  We added a simple one for those hosting in Windows environments which should get the job done.

    PayPal enhancements

    First, the sandbox PayPal URL has been fixed.  This is mostly used for development/testing purposes, but none-the-less is important.

    Also, we removed the requirement for needing the PHP cURL module requirement.  Instead, WP Affiliate Manager uses WordPress’ native HTTP request methods.

    jQuery UI Tabs + cookies + mod_security bugfix

    An interesting sidenote… we discovered a bug where if you went to the 2nd tab on WP Affiliate Manager’s “My Affiliates” screen on our test server, your next navigation point in WordPress would either result in a 404 error, or an endless loop of 302 redirects.

    Turns out the bug was caused by a perfect storm of Apache’s mod_security (which is enabled on our test server) and the use of jQuery UI Tabs with a cookie save option.  What was occurring was the cookie name was being saved as “ui-tabs-1″ and if your last visited tab was the 2nd tab (index 1) the cookie was saved as “ui-tabs-1=1″.  This would be passed with each HTTP request as a cookie header.  Since mod_security doesn’t like anything where “1=1″, it was changing the request, causing WordPress to become all sorts of confused.  You can see a bug report about it here: http://bugs.jqueryui.com/ticket/8027

    The solution was to name the cookie, so the automatically generated name wasn’t used:

    jQuery("#tabs").tabs({
        cookie: {
            name: 'wpam_detail_tab'
        }
    });

    Enjoy all of the fixes!

    Including templates inside a plugin

    This past week I was working on a project for a client who needed a custom post type to manage events on his site. Normally for a project like this I would build the CPTs and push a couple templates in to the active theme folder. But in this instance, the client was working on a new theme that would be going live in a few weeks. Rather than making the client jump through hoops and move template files around, I wanted to provide the easiest solution possible. That meant, including all the templates as part of the plugin. Thanks to a very handy filter in WordPress, this wasn’t a problem. Here’s how it ended up.

    Here’s the makeup of the plugin:

    Plugin Layout

    The plugin itself is very standard. One thing I like to do is define the custom post types as separate files to keep the function file clean. I then include the CPTs and the custom metabox library like so:

    /** Add custom CPTs and Metaboxes */
    require_once( 'cpt-events.php' );
    require_once( 'cpt-locations.php' );
    require_once( 'metabox/init.php' );

    I store the stylesheet in a separate folder for cleanliness as well and encode it like this:

    /** Enqueue CSS */
    add_action( 'wp_enqueue_scripts', 'prefix_add_my_stylesheet' );
     
    function prefix_add_my_stylesheet() {
    	wp_register_style( 'cpt-style', plugins_url( 'css/style.css', __FILE__) );
    	wp_enqueue_style( 'cpt-style' );
    }

    And now the real meat of it. You can see the single-events.php and archive-events.php that make up the two template files I want to use on the front end. What I’m going to do is create a function that tells WordPress to use my templates for the archive and single pages for the event CPT. That code looks like this:

    // force use of templates from plugin folder
    function cpte_force_template( $template )
    {	
        if( is_archive( 'events' ) ) {
            $template = WP_PLUGIN_DIR .'/'. plugin_basename( dirname(__FILE__) ) .'/archive-events.php';
    	}
     
    	if( is_singular( 'events' ) ) {
            $template = WP_PLUGIN_DIR .'/'. plugin_basename( dirname(__FILE__) ) .'/single-events.php';
    	}
     
        return $template;
    }
    add_filter( 'template_include', 'cpte_force_template' );

    As you can see, I’ve set up a filter for template_include. I pass in the $template variable and check to see if the page is either an archive or singular event. If so, I override the default template location with the full path and file name of the file inside my plugin folder.

    The end result is a fully encapsulated plugin that takes care of the functionality, templates and stylesheet formatting the client requested all in one easy to manage package. Simply install the plugin and activate it and you’re ready to go!

    New plugin: Authorize.net SIM Gateway for WP e-Commerce

    A while back we released the WP Affiliate Manager plugin which integrates directly in to the WP e-Commerce plugin to allow you to easily track and pay affiliates for driving traffic to your site. We have since been keeping an eye on the WP e-Commerce community and when we saw the opportunity to help with another plugin, we jumped at the chance.

    Today we released a new payment gateway for WP e-Commerce: Authorize.net Server Integration Method, or SIM for short. From the Authorize.net website:

    SIM provides a customizable, secure hosted payment form to make integration easy for Web merchants that do not have an SSL certificate.

    WP e-Commerce has a wide range of payment gateway options available, and we’re happy to help expand their reach by giving users one more option to choose from.

    If you are interested in reading more about how Authorize.net’s SIM works, you can check out the developer center at Authorize.net.

    The plugin is available exclusively through the GetShopped marketplace and is compatible with the new 3.8.9.x software. And to celebrate the launch, use code WPECDEC at checkout to receive 30% off. (discount expires 12/17/12)