Testing Translation Function Speeds in WordPress

Speed of memoryAfter reading Pippin Williamson’s post about gettext speed issues, I wanted to learn more. My IDX+ plugin has 815 translatable strings, and I was worried that it was having a performance impact on the plugin.

I created a test that looped through different methods of outputting and printing strings to try and determine their relative speed. WordPress uses different functions for translating strings, as documented in the Codex, and I included __() and _e(), the functions I use the most often.

Here are the results of a 100,000-iteration loop:

  • echo 'Test': 0.1786 seconds
  • $out .= 'Test': 0.2454 seconds (37.4% slower)
  • __('Test'): 0.5301 seconds (196.8% slower)
  • _e('Test'): 0.5639 seconds (215.7% slower)
  • echo __('Test'): 0.5722 seconds (220.4% slower)
  • __('Test', 'test'): 0.5743 seconds (221.6% slower)
  • _e('Test', 'test'): 0.6076 seconds (240.2% slower)
  • echo __('Test', 'test'): 0.614 seconds (243.8% slower)
  • $out .= __('Test', 'test'): 0.6885 seconds (285.5% slower)

“Findings” (non-scientific)

  • Contrary to what I had read, echoing inline was by far the fastest method.
  • Adding a domain (the second parameter) to translation functions slows the functions down a bit.
  • Storing strings in a variable after using __() is slow.
  • All times are well below 1/10th of a second when translating 10,000 strings instead of 100,000.

Conclusion

Although translating 100,000 strings adds half a second processing time, if your site is processing well less than that, you shouldn’t have a problem.

It seems the site Pippin was working on had enough strings to affect the responsiveness of the site, but I would bet that’s not a normal site. I also would bet that the issues the site was having are not because of the translation functions themselves, but the translation plugin the site was running.

I’m going to be using more _e() and less echo __(), but other than that

Bradycardia & Cardiac Arrest for WordPress 3.6

Bradycardia is the resting heart rate of under 60 beats per minute….
Wikipedia

WordPress HeartbeatA new feature in WordPress 3.6 is an upgrade to the autosave functionality that’s been around for years. It’s called “Heartbeat” and it makes sure you have valid authentication credentials, aren’t working on the same post as other people, and more. The problem is that (as it is) it slows web pages down to a grinding halt.

Read the active discussion on WordPress.org about this feature – a lot of people are upset about the CPU load it adds.

Note: I don’t recommend doing these changes on every Admin page. Use sparingly.

Slow Down WordPress 3.6’s Racing Heartbeat

Here’s how to slow down the heartbeat from once every 15 seconds (the default) to once every minute (the max allowed by WordPress): Continue reading “Bradycardia & Cardiac Arrest for WordPress 3.6”

Add "Preview" Link to Manage Themes

Get That Preview Link Back!

Ever since WordPress added a Live Preview option to the Manage Themes screen, it’s been frustrating to test a plugin using multiple themes.

Why Live Preview sucks for developers

When using Live Preview, you can’t modify the URL of the page you’re visiting or open the preview in a new window or tab. Live Preview prevents you from viewing multiple themes at once in different tabs.

If you wanted to get the old Preview link back, you had to disable Javascript, then refresh the page, then open the links.  Continue reading “Add "Preview" Link to Manage Themes”

Passing parameters from PHP to Javascripts in plugins » Otto on WordPress

Much cleaner. One static and unchanging JS file to cache. Parameters get put into your HTML itself as a one-liner. You can deal with the parameters using a normal PHP array before passing them over. No need to screw around with generating Javascript from PHP or looking for wp-load or even messing with tricky actions.

via Passing parameters from PHP to Javascripts in plugins » Otto on WordPress.

Storing Data in WordPress Plugins – A Quick Rundown

Coding better WordPress plugins

As I’ve worked with WordPress plugins, I’ve learned new ways of working with WordPress. WordPress has tons of built-in functionality that is very useful and easy to use once discovered.

I am by no means a great PHP coder. I am still learning OOP principles and how to write code better. In creating new WordPress plugins (see a list of my plugins), I have improved how I code: writing more efficient code using WordPress functionality rather than hacks.

One of the methods of coding that I have discovered (thanks to Jeremy Clarke) is using the WP Cache and Transient APIs to store plugin data. It’s made a big difference in the speed of all my plugins.

The following is a quick review of three different ways of storing data when you code plugins or work with WordPress. This is to the best of my knowledge, and I welcome feedback/improvements in the comments. Continue reading “Storing Data in WordPress Plugins – A Quick Rundown”

EasyVideoPlayer WordPress Plugin

Embed EasyVideoPlayer videos to WordPress

Finally add videos inside your WordPress content without the hassle!

Download the plugin from WordPress.org

It’s been hard — and very technical — to embed EVP videos inside WordPress content…until now. The EVP plugin for WordPress changes everything – it is now simple to add EVP videos to your content. Continue reading “EasyVideoPlayer WordPress Plugin”

Lottery Results – A New WordPress Plugin

Download the plugin at WordPress.org

For plugin support, please visit the support forum.

Show lottery results from all 43 states with lotteries

  • Choose which games you want to display
  • Choose from different lotto results layouts
  • Embed results in your content using the lottery] shortcode.

The widget automatically gets updated results every 6 hours, then they are stored in your website for very fast load times.

 

Continue reading “Lottery Results – A New WordPress Plugin”

Two Easy Ways to Add “nofollow” to WordPress Menu Items

By default, WordPress menus don’t have the ability to add “nofollow” to the link items…but WordPress 3.0+ has the functionality built in.

This tutorial will show you how to add nofollow to specific items using the new wp_nav_menu() function. Continue reading “Two Easy Ways to Add “nofollow” to WordPress Menu Items”

Snow Report – Ski Mountain Conditions Plugin for WordPress

Denver Snow

Get the latest ski/snowboarding conditions from your favorite area or mountain using the Snow Report WordPress plugin.

The plugin uses the OnTheSnow.com website’s data feeds that provide the most accurate, up to date information available. Continue reading “Snow Report – Ski Mountain Conditions Plugin for WordPress”

Weather Forecasts for WordPress – WP Wunderground Plugin

This is the official plugin support page for the Wunderground plugin. Download it now from WordPress.org.

Do you need plugin support or have comments?

For information on how to use the Wunderground plugin, please view the plugin page. Continue reading “Weather Forecasts for WordPress – WP Wunderground Plugin”

5 Easy Ways to Disable the Gravity Forms CSS Stylesheet

Pliers

We can do this the easy way or the hard way. What’ll it be?

The WordPress form plugin Gravity Forms (if you don’t use it, you should — it’s great) comes with a stylesheet found at [plugin-directory]/plugins/gravityforms/css/forms.css. SEODenver.com’s is found here.

If you want to turn off styles for Gravity Forms, there are a few different ways. Here are five examples of how to turn off CSS for the form plugin. Continue reading “5 Easy Ways to Disable the Gravity Forms CSS Stylesheet”

WordPress.org Changes Plugin Page Layout

WordPress.org plugin page layout change likely for usability

Wordpress.org plugin page from 2008
What the WordPress.org plugin page used to look like.

A couple of weeks ago, WordPress.org changed the layout of their plugins directory plugin pages. The update was likely to improve usability for users trying to determine whether a plugin is trustworthy and what it does. I believe the re-arranging of the page has achieved those goals.

The update removes author links

The layout redesign removes links to the official plugin page. I believe this makes it more difficult for users trying to get support on plugins.

Removing links also affects plugin authors. One of the ways that plugin authors are “rewarded” for creating plugins used to be a link from the WordPress.org website. This resulted in two things: increased traffic to the author’s website and some passed SEO value from the WordPress website to the author’s website.

I recommend all authors to go back through their readme.txt files and add a link to their support pages. Continue reading “WordPress.org Changes Plugin Page Layout”

Auto-Optimize WordPress Database without a Plugin

These horses are somehow not cool. Speeding up your blog is.

I am working on a WordPress project that has a pretty heavy database, and I want to be able to auto-optimize the WordPress database. Even though they are integrating this functionality into WordPress 3.0, I want it now, and without having to use a plugin (I have had some issues with WP-DBManager configuring properly on a few sites).

If you add the following code to your functions.php file, it will automatically optimize your WordPress database every 6 hours, keeping it squeaky clean. Continue reading “Auto-Optimize WordPress Database without a Plugin”

WordPress Debt Calculator

Download the plugin from WordPress.org

Add a debt calculator to your WordPress blog

Debt Calculator ScreenshotDo you have a financial blog or a blog about debt, money management, or household spending? Add a free debt calculator to your blog with no coding required.

  • Updating the style: You can update the form’s style by editing the plugin’s debt.css file
  • You can add the calculator to your website’s sidebar by using the shortcode in a text widget
  • Use in combination with the Show Content Only plugin as a pop-up window

Continue reading “WordPress Debt Calculator”

Add Custom Titles for Tags and Categories in WordPress

The Best WordPress SEO Plugin? A combination of two.

All in One SEO Pack (AIOSEO) is the leader in WordPress SEO plugins. It offers great functionality and simple integration into the process of writing a post. AIOSEO is not a perfect plugin, however, because it lacks some very important functionality:

  • Custom category title tags
  • Custom tag title tags
  • Mass editing of page, post, tag and category title tags/slugs

The plugin that has all of the features above (but lacks AIOSEO features) is SEO Title Tag, an imperfect but elegant solution to the list above.  This article shows how to use both plugins and have them combine forces to create a powerful solution for getting custom titles on all your site’s pages. Continue reading “Add Custom Titles for Tags and Categories in WordPress”

Save Coding Time by Creating Special-Case Categories in WordPress

When you would use excluded categories:

When using WordPress as more of a content management system (CMS) than a blogging platform, there are many things that you need control over. One of them is special-case categories.

  • Frequently asked questions
  • Testimonials
  • Case studies
  • Press releases

When you have a category of posts that you don’t want to have comments, publishing dates, post author, etc., you can define a list of excluded categories. In most cases, you should use Category Templates to achieve this functionality, but that is not always practical or the best option. Continue reading “Save Coding Time by Creating Special-Case Categories in WordPress”

Strip Extra ImageScaler Attribute from Plugin-Generated Code

I am using the ImageScaler plugin for WordPress on a project, and I like what it does, but it adds a non-standards-compliant attribute to images, such as:

<img class="" src="http://www.example.com/imagescaler/generated-image.jpg" alt="Example" width="258" height="234" imagescaler="http://www.example.com/imagescaler/original-image.jpg" />

To strip imagescaler’s imagescaler attribute, add the following into your functions.php file:

add_filter('the_content', 'strip_imagescaler');
function strip_imagescaler($content) {
	$content = preg_replace('/imagescaler="(.*?)".?/s','', $content);
	return $content;
}

Simple Taxonomies Formatting — Improve the Plugin's Code Output

Making the Simple Taxonomies WordPress Plugin Semantic

I’ve been using Joost de Valk’s Simple Taxonomies plugin for a couple of projects, and I’ve been very disappointed by the formatting of the terms output code.

When configuring the plugin, you have the option of choosing “Add terms to the end of posts” or “Add terms to the end of excerpts.” If you do, you get a <div> and a couple of spans. Not very semantic. Also, the code uses an #id, instead of a .class, meaning that if you have more than one post on a page with taxonomies, it no longer validates.

Simple Taxonomies uses terms, so let’s make a list of them!

Here’s a way to reformat the code and prevent overwriting in future plugin updates. We’re going to strip the code and use a definition list instead (<dl>). Definition lists in HTML have a term and description; just as a custom taxonomies creates a taxonomy and its terms. Continue reading “Simple Taxonomies Formatting — Improve the Plugin's Code Output”

How to Display a Random Testimonial or Post in WordPress

Set up a testimonials category — no need for a plugin.

There are a couple of plugins designed specifically for testimonials, but I didn’t want to use them; they use their own databases, and don’t keep with WordPress’ simplicity. If possible, the best way to work with WordPress is to use it’s built-in functionality.

I also wanted to have the testimonials as a category in WP, rather than as a separate plugin. This code will work for any type of category, not just a testimonial.

Here’s how to create a random post item in your sidebar: Continue reading “How to Display a Random Testimonial or Post in WordPress”