Menu

Snippets

Yet another programmer blogging about code

Posts Tagged ‘php’

Add custom JavaScript actions to WP e-Commerce cart updates, again

Saturday, September 14th, 2013

I previously wrote about adding your own custom JavaScript actions to the WP e-Commerce cart update event. Of course, things change, people change, hairstyles change, interest rates fluctuate, WP e-Commerce moves goalposts, so there is a new way to do this since version 3.8.11 came out.

WordPress WP_DEBUG_LOG without E_STRICT

Wednesday, September 11th, 2013

As Debugging in WordPress explains, it’s easy to get good debugging information into a debug.log file while developing WordPress plugins and themes. Unfortunately, it sets the PHP error reporting level to E_ALL, which includes E_STRICT and can throw so much noise into the log that you can’t find the useful information. What we need is a way to turn on the debug log but specify the error reporting level.

WooCommerce add to cart with quantity and AJAX

Sunday, August 18th, 2013

WooCommerce is a great e-commerce plugin for WordPress. It has some very nice basic features, but it’s also easy to customise and extend. On single product pages, you can add to cart with a quantity other than just one, and on the purchase page you can add to cart via AJAX without leaving the page. Wouldn’t it be nice to add to cart with both quantity and AJAX?

Events Manager Pro and required user fields

Friday, July 5th, 2013

Events Manager + Events Manager Pro is a great plugin team for taking bookings for events on WordPress websites. One hitch I’ve struck is that if you as webmaster need to edit a user, and the user hasn’t filled in all their details, Events Manager Pro won’t let you save without filling in all of its required fields (basically, address details). And of course, the chances are that you won’t know what those fields should contain.

WordPress menu login / logout link

Friday, June 7th, 2013

The WordPress drag-and-drop menus make it easy to build a custom menu for your website, but adding a login/logout link requires a little PHP code. It’s very simple though, and easy to add to any theme.

Add an external link to the WordPress admin menu

Monday, June 3rd, 2013

WordPress has a good API for adding admin menu items. Unfortunately, it doesn’t allow you to specify a direct link to something, only a “slug” that links your menu item to a callback function to run when your menu item is selected. But fortunately, there’s a hack.

Custom post names for WordPress custom post types

Thursday, February 28th, 2013

When you edit a new post, page, or an object of a custom post type, WordPress generates a slug or post name that will be used in its permalink. It derives the post name from the title you gave it. Sometimes, however, you want the post name to have a little more information in it.

WordPress is_ssl() doesn’t work behind some load balancers

Wednesday, February 6th, 2013

WordPress has a function is_ssl() that it uses to check whether a page is loaded with the HTTPS protocol, so that it can use the same protocol to load scripts, stylesheets, and other assets. It relies on the web server giving it a couple of clues, but when your website is hosted behind a load balancer, those clues aren’t always available. In particular, websites hosted by Network Solutions get no clues at all when pages are loaded over HTTPS.

Stop Events Manager from cropping thumbnails

Monday, January 21st, 2013

Events Manager gives you a special placeholder that you can put into its templates, for inserting the event’s “featured image” into lists and single event pages. If you want to insert a thumbnail, it uses the timthumb script to create one on the fly — but it crops that thumbnail. Here’s how to use the WordPress uncropped thumbnail (or any registered image size).

Events Manager locations map with directions

Wednesday, January 9th, 2013

Events Manager is my events and bookings plugin of choice for WordPress, because it is very flexible, easy to integrate into a theme, and has hooks galore for customising to suit almost any requirement. Its location map doesn’t offer a way to provide directions, however. So, here’s how to replace the Events Manager locations map with WP Flexible Map and get a directions link on location pages.