Posts Tagged ‘php’

Disable WP’s Automatic Paragraphs

Monday, June 20th, 2011

A quick hack to disable the wpautop() function’s tendency to mangle your WordPress-based HTML posts with extra markup:

Add the following to your functions.php:

function custom_autop($p, $br = 1) {
  if (stristr($p, '<!--noautop-->')) {
    return str_ireplace('<!--noautop-->', '', $p);
  } else {
    return wpautop($p, $br);
  }
}
remove_filter('the_content','wpautop');
add_filter('the_content','custom_autop');

That’s it. Now when you add <!–noautop–> to a post, it’ll disable the wpautop() function.

Incidentally, wpautop has a parameter called “$pee” and a loop that reads “foreach( $pees as $tinkle )” …

phpScenario, a split testing library

Wednesday, October 6th, 2010

I’m closing in on the first release of what you might call a by-product of Listy.us; phpScenario is a free split-testing library created out of the need to have a way of testing various ideas on Listy.us without relying on paid products or offsite solutions. I’m going to release it for free, though I haven’t chosen a license yet. (update: New BSD license!)

(more…)

PHP hashing performance experiment

Sunday, April 25th, 2010

Today, in the never-ending quest to tweak server performance by a few milliseconds, I decided to do a bit of testing of various php hashing methods. I therefore wrote a quick script under php (5.2.11 currently, I need to update), which ran each test case 10,000 times to achieve a decent min/avg/max for each case, on strings of 10KB, 100KB, and 1,000KB in size.

(more…)

Zend Framework: Email templating with layouts & views

Wednesday, December 2nd, 2009

This is a solution that I came up with for sending out welcome emails, comment notifications, etc, with nice standardized HTML & text layouts, using a few components of the Zend Framework.

Basically you create a view (here called $renderer) and a layout ($layout), then render your views and layouts for both HTML and text versions. My file tree looks like this:

application/
	emails/
		welcome.html.phtml
		welcome.text.phtml
		layouts/
			layout.html.phtml
			layout.text.phtml

So, ‘welcome’ would be your template name, with html and text versions. The layout is what you want wrapped around either version of every email you send out (header graphics, font settings, contact info, etc).

(more…)