kieranbarnes Independent PHP, WordPress & CubeCart Programmer

Using Persistent Cache in WordPress (with APC)

Posted on January 9, 2012

Ever since WordPress 2.5, the WP Cache functions haven't been persistent, so the cached objects are only available for the page load (or script run). This means that data stored in the cache resides in memory only and only for the duration of the request.

Upto version 2.5 we could have simply added define('WP_CACHE', true) to the wp-config.php and we got persistent cache features. This is no longer the case and isn't really very well documented.

The later versions need a Persistent Cache Plugin. I'm not a fan of some of the larger caching plugins like W3 Total Cache or WP Super Cache as they tend to add complexity and can cause other problems. Besides, as developers, we're better off writing the code ourselves.

Before going any furuther its probably worth pointing out WordPress has two persistent caching methods.

The first method is the WP Transients API,

The second method is extending the existing WP Object Cache that is currently throughout your WordPress site already.

  • Extending this object is much more flexible
  • Can extend into APC, memcache or similar
  • Provides a fast cache for basic WordPress functions even before you write your own code

New Site: Lizzie Lane – Hand Selected Beautiful Jewellery and Gifts

Posted on December 8, 2011

Today I completed work on another customer's site: Lizzie Lane - Hand Selected Beautiful Jewellery and Gifts.

My tasks were to develop some custom templates for it's Thesis based theme, many Shopp modifications including fixing an XSS issue in Shopp, making Shopp work with SSL (something it does not do out of the box), some CSS work and various other Shopp modifications.

 

Tagged as: , , No Comments

WordPress Auto Install Script for cPanel

Posted on December 5, 2011

I have released version one of my WordPress Auto Install Script for cPanel.

This script can be run from /scripts/postwwwacct to automatically download, install WordPress and create the required database and database username.
No 3rd party licenses, scripts, FTP sessions. No outdated versions, always grabs the latest version from WordPress.org

This script is available upon request for £50. Get in touch for details.

 

WordPress/Shopp Shipping Calculator/Options Access-Control-Allow-Origin Error

Posted on November 4, 2011

I've recently been debugging a customer's WordPress/Shopp store. When the customer set the Cart & Checkout to be served over SSL  the shipping calculator failed.

Serving Cart / Checkout / My Account pages over SSL is not built into Shopp for some reason. I have a post on this -  SSL/HTTPS for Shopp pages or checkout process only. If you use a shipping calculator, or offer different shipping methods this will fail.

How To List A Custom Post Type’s Taxonomies And Terms

Posted on September 21, 2011

Jennifer M. Dodd has published a brilliant article on listing post taxonomies / terms / formats & categories. I love it!
Entitled  How To List A Custom Post Type's Taxonomies And Terms, she offers two functions that cover displaying all custom taxonomies, terms, post formats, categories and tags.

Just saved me hours writing my own. Thanks!

Filed under: PHP, WordPress No Comments

[Snippet] Programmatically add a WordPress User

Posted on September 15, 2011

Here's how I would programmatically add a WordPress User

  1. require('../wp-blog-header.php');
  2.  
  3. $user_name ='kieran';
  4. $user_email = 'kieran@bl0ke.org';
  5.  
  6. $user_id = username_exists( $user_name );
  7. if ( !$user_id ) {
  8. $random_password = wp_generate_password( 12, false );
  9. $user_id = wp_create_user( $user_name, $random_password, $user_email );
  10. } else {
  11. $random_password = __('User already exists. Password inherited.');
  12. }
Tagged as: No Comments

Highlighting current page in WordPress Menus

Posted on September 14, 2011

By default, wp_nav_menu doesn't create a .current_page_item or .current-menu-item class for certain elements in a wp_nav_menu, for example if you are viewing a custom post type archive or single page.

Here's some code to fix that. Bang it in functions.php

Don't forget to create your CSS classes if you already haven't done so.

Tagged as: , Continue reading

Redirecting a custom post type

Posted on September 13, 2011

Ever had to rename a custom post type? Pain in the ass. Lets just redirect it instead.

Edit your functions.php

  1. add_rewrite_tag('/<old name>/','<new name>','top');

Simple as that.

Filed under: WordPress No Comments

WP-Ecommerce documentation still sucks

Posted on September 12, 2011

WP-Ecommerce documentation still sucks.

I'm sorry too!

Filed under: WordPress No Comments

Splitting WordPress content with ‘more’ on single pages

Posted on September 12, 2011

WordPress uses the "More" button to create a small snippet of content, usually used on the blog page, to create article teasers and such. WordPress ignores the "More" function on single posts, pages and several other pages.

Here's some code of make use of the "More" function on single pages and single posts. Perhaps splitting the content into columns or hiding extra content in an accordion or pretty much anything. Look, I'm going to press the "More" button right now.

Page 1 of 712345...Last »