Posts filed under code

how to filter post titles

Posted on 01 January 2010 at 4:46 PM | Filed under code

If you know that you will want to apply a filter to all of your post titles in WordPress, such as forcing uppercase, lowercase, or title capitalization, you can use a filter to do so. The filter below will force a title to lowercase as the post is saved:

  1. if ( !function_exists( 'ucc_post_title_filter' ) ) :
  2. function
  3. ucc_post_title_filter( $data ) {
  4.   $title = $data['post_title'];
  5.  
  6.   $title = strtolower( $title );
  7.   $data['post_title'] = $title;
  8.  
  9.   return( $data );
  10. }
  11. add_filter( 'wp_insert_post_data' , 'ucc_post_title_filter' );
  12. endif;

On line 6, strtolower() can be exchanged for any text-transforming function.

mt + php = legible archive listings

Posted on 06 August 2004 at 10:09 PM | Filed under code

Site archives often follow the format of a weblog's front page postings, listing entry excerpts with links to the entry's individual archive page. In some circumstances, this may take up considerable space without adding to the user's ability to quickly scan the archives for a specific entry.

On this site, I have used PHP with Movable Type to create phonebook-style listings of entry titles and their entry dates. I found that this is both aesthetically pleasing and fairly simple to implement. Other ways of implementing the alternating colors include using JavaScript on the client side or using MT plug-ins when the site is rebuilt rather than running the PHP to generate @class@ attributes every time the page is called by a browser.

These other implementations may be published at a later date.

Continue reading "mt + php = legible archive listings" ►

the third commandment

Posted on 17 July 2004 at 5:47 PM | Filed under code

MySQL went onto OS X without much of a hitch using DarwinPorts, as did updated versions of PHP, Perl, and various modules therein. PostgreSQL seems to be working, but something about Movable Type causes it to not be accessible via ObjectDriver—a stub program I wrote in Perl can access the data in a test database via DBD::Pg just fine, but MT chokes on the same username/password/database combination in mt.cfg.

Math::Pari can kiss my grits. Crypt::DSA made me cry. I despair of ever making sense of that mess of hacks, patches, and recompiles.

ImageMagick can take a hike. I gritted my teeth and installed NetPBM instead. Maybe I'll use the DarwinPorts version of ImageMagick and see if it plays nicely with PHP; other than that, though, I'm sick of it.

I'd hoped to get MT3.01D working in a PostgreSQL environment, but ended up using MySQL for it instead. It's installed, however, and working nicely.

Having root is overrated.

Copyright © 2003-2010 J.M. Dodd. | XHTML 1.0 Strict | CSS | RSS | 508