Outrigger, my WordPress theme framework, is now at version 1.2. I’m designating it version 1.2 because of several changes to the layout and CSS. It is available for free on github. You can read more about it, as well as view the documentation, here.
Sync Comment Number in IntenseDebate with WordPress
I have been handling a lot of WordPress development at work recently. At my job, all of the blogs are using IntenseDebate to handle blog comments. This presented a problem to me recently with launch of a new theme I was working on.
The problem is that on a post, IntenseDebate would show one number of comments while the post detail info would show a different number. I tried several different methods of fixing this to no avail. IntenseDebate does not have much in the way of documentation, and the system itself leaves a lot to be desired.
It turns out that, IntenseDebate doesn’t automatically sync comments with WordPress, and instead uses a JavaScript method to sync the comment numbers on page load. Go figure! The reason why it wasn’t working for me is that I was using a custom function to get the number of comments on a post.
To get your comment numbers to sync, you need to use the WordPress provided template tags, comments_number() or comments_popup_link(). This fixed the problem for me.
I hope that this helps someone else, as there is not much info on this out there that I could find. And avoid IntenseDebate if you can.
Apache, PHP and MySQL on Snow Leopard
I have enjoyed using MacPorts for a number of reasons, and I have written about it several times. Recently, I have had to rely on it more, and I have grown frustrated with it to the point that I had to abandon it altogether.
I upgraded to Snow Leopard (10.6) last week. It broke my install of MacPorts, but they actually tell you to reinstall after an OS upgrade like this. So I did that, but I could not get Apache 2 and PHP running again to save my life, not to mention MySQL.
So I instead relied on the factory installs of Apache and PHP. It turns out they have gotten a lot better with Snow Leopard. All I had to do was reinstall MySQL which meant I lost my databases but I was prepared for that to happen by then anyway.
Here are the instructions to get Apache, PHP and MySQL running in Snow Leopard.
Install Apache/PHP/MySQL on Snow Leopard
It worked perfectly for me except for one thing. PHP short tags are off by default. So make sure to turn them on or check your code to make sure you are not using PHP short tags, or your PHP code will not work.
I may continue to use MacPorts for other things, but for now I am no longer using it for my dev environment. Maybe one day I will give it another shot if I need it.
Outrigger
I’ve developed a WordPress theme framework called Outrigger, that I’ve been using for my themes on WordPress. Today I released it publicly on github. You can read more about it, as well as view the documentation, here.
Install Apache, PHP and MySQL on Leopard with MacPorts
Running selfupdate on MacPorts is a good way to keep your MacPorts software up to date. The problem is when I did this, all my settings were overwritten. I should also mention that running selfupdate on my MacPorts install caused all my virtual hosts to get overwritten as well. I wrote a post last year on how to install Apache and PHP on Mac OS 10.5 with MacPorts, but following that post didn’t help me get up and running again. So I figured I would write a new one that would actually have the right information.
Here are the install instructions you need for installing Apache, PHP and MySQL with MacPorts. I had already installed Apache and PHP, but MySQL wasn’t working. I have MySQL server already installed and running, but PHP wasn’t finding it. I already had multiple databases set up, so I did not want to reinstall MySQL. All I had to do was follow the instructions in step 4. It fixed the problem, but there were a couple of settings that needed to be changed first.
After you install PHP, it gives you a 2 part message. Part 1,
Your php.ini contains a line that will prevent php5-mysql
and other PHP extensions from working. To fix this,
edit /opt/local/etc/php5/php.ini and delete this line:
extension_dir = "./"
is correct. Deleting that line is how you find the right extensions. Part 2,
To use mysqlnd with a local MySQL server, edit /opt/local/etc/php5/php.ini and set
mysql.default_socket, mysqli.default_socket and pdo_mysql.default_socket
to /opt/local/var/run/mysql5/mysqld.sock
did not work for me. For my MySQL server, that socket does not work. Instead, I found this article that tells you the correct socket on Leopard to set:
mysql.default_socket = /private/tmp/mysql.sock
That fixed everything for me, except for my virtual hosts. Again, your mileage may very. These instructions worked for me on my machine with the software I have.
MacPorts Commands
I use MacPorts to handle my installs of apache, php, etc. on my Mac. If you are using MacPorts on your Mac like I am, you may want to remember these handy codes to manage your MacPorts packages.
sudo port selfupdate
Update MacPorts to the latest version
port installed
List installed packages
sudo port upgrade outdated
Automatically upgrade outdated packages
With MacPorts, it really is that simple to install and then make sure you have the most current version. I love it, and I highly recommend it to everyone else.
Delete Blank Lines in TextMate
I use TextMate for coding on the Mac. At work, I use Dreamweaver. I’ve noticed if I switch between the 2, Dreamweaver throws an extra line break in for every line. Some text editors have a command to handle reformatting like deleting blank lines. TextMate by default does not.
You can customize TextMate though and add this command. Here is how you do it.
To add a new command to TextMate simply open the Bundle editor (bundles menu, Bundle Editor, Show Bundle Editor) and press the add button (+) and select “New Command”. This command will appear under the user’s bundle, you can move this later.
The command edtor window has several options these are:
1. Save: This allows you to configure whether to save the file or the current project before running the command
2. Command(s): This is where you enter your commands
3. Input: The text that becomes the standard input to the command. This can either be a selection or the entire document (and selection)
4. Output: This option is how the ouput from the command is handled. This can either be discarded, replace the selection, replace the document, insert as text, insert as snippet, Show as HTML, show as tooltip create a new document.
5. Activation: How the command is triggerred, in each case I’ll leave this up to you.
6. Scope: the scope of documents this should effect, e.g all js files etc.
For this example, we are going to use the sed command to remove all of the blank lines from a document.
Here’s the command configuration:
Save: Nothing
Command: sed /^$/d
Input: Entire document
Output: Replace Document
Activation: I’d recommend using a keystroke of your choice
Scope: Leave this blank
Sed processes a file line by line and carries out substitution based on regular expressions. In this example “/” is the delimiter. The regex part “^$” matches the beginning of a line and the end of a line (i.e a blank line) and lastly the “d” deletes the match.
One note, you may want to make a back up of any files in case something goes wrong.
via Muffin Research Labs.
Elgg Not Showing Latest Activity in 1.6
Update: It turns out this problem was caused by plugins. The Wire plugin is causing it on both sites, and the bookmarks plugin is causing it on one site. If you have this problem, I recommend turning off your plugins and enabling them one by one to see which one is causing the problem.
I complain about Elgg a lot, as you can see here. I want to like it, but it does have a lot of problems. I know it is Open Source, but it is also being actively worked on every day. So in my opinion, if there is a known bug in a prominent feature of the site, it should be fixed.
There is currently a major bug in the Latest Activity feature of the Elgg software. I have 2 sites running Elgg, and neither of them display the latest activity on the latest activity page or on the home page. Latest activity is blank on both sites. They were both upgraded and not fresh installs, which seems to be a common factor. Also, I was running the custom index plugin on both sites, so I didn’t notice the problem until I disabled the plugin.
This is a known bug that has not been fixed yet. As far as I can tell, it was reported at least a year ago here. There is a thread on Google Groups here. Here is the bug ticket for this in Elgg’s bug tracking system that was reported 3 months ago.
How does Elgg handle bug fixes? There is a major bug in Elgg’s latest activity display, which is a major feature of the site. They know about it, and it has not been fixed yet despite 2 discussion threads and a support ticket. Hopefully, they will fix it in the next release whenever that is.
How to Create a Google Analytics Plugin for WordPress
After creating my bbPress Google Analytics plugin, I wanted to do the same thing for WordPress. It is just as easy to do this as it is for bbPress. Your WordPress footer template should have a hook for adding code to the footer. If it doesn’t have this hook, you just have to add this piece of code, wp_footer();, to your footer template. Then you just have to create the code that will add your tracking script to the footer of every page. That is it.
Here is an example of the code you can use. Download wp-analytics here. Just upload the script to your plugins directory, and activate the plugin in the plugin admin. If you are using Google Analytics, all you need to do is replace “UA-XXXXXX-X” with your site code. But it will work with any tracking script, just replace the Google script with your own. Also you can use this same code to add any code you wanted to the footer.
How to Create a Google Analytics Plugin for bbPress
bbPress is a free, open source forum software from the makers of WordPress. I am even using it on this site. It just came out of beta with the relase of 1.0. If you are looking for forum software I recommend it.
However, the theming system is not as simple as WordPress. I had added a Google Analytics script to my themes. But when I upgraded to 1.0, I lost all my tracking scripts.
The best way around this, I thought, is to create an analytics plugin. It turns out, it is very easy, especially if you have experience creating plugins with WordPress. The bbPress footer template has a hook for adding code to the footer. You just have to create the code that will add your tracking script to the footer of every page. That is it.
Here is an example of the code you can use. Download bbpress-analytics here. Just upload the script to your bb-plugins directory, and activate the plugin in the plugin admin. If you are using Google Analytics, all you need to do is replace “UA-XXXXXX-X” with your site code. But it will work with any tracking script, just replace the Google script with your own. Also you can use this same code to add any code you wanted to the footer.