Skip to content

Posts from the ‘Web Design’ Category

21
Jun

Hello Thelonius

WordPress 3.0 “Thelonius” has dropped and all is right and good in the world. Thanks to Matt Mullenweg and all of the hard working WP devs. My upgrade experience on this site and on a WPMU/BuddyPress site I have in development went as smooth as silk. Looking forward to fully exploiting all of the 3.0 goodness in the near future.

1
Aug

WordPress Shortcode for File Inclusion

I have a project that requires a lot of complex, yet static Pages in WordPress … think lots of tabular data with heavy CSS styling. This sort of content is best written in an external editor like Zend IDE or Dreamweaver and then dropped into WordPress.

However, if you’ve ever done this, testing the page as you develop it is a huge pain in the backside. It involves cutting and pasting from the editor to WP … saving and refreshing … make changes in the external editor … rinse and repeat.

Not fun. Not efficient.

The solution is fairly straightforward — keep these files static HTML and simply include them somehow in the page. I researched the available plugins and they all seemed like overkill which added overhead. Then, in WP IRC, Fris suggested writing a custom shortcode to do the heavy lifting. 90 minutes later, I have precisely what I need and a renewed respect for WordPress and the community supporting it.

For those interested, here is the code:

< ?php

// SHORTCODE FOR STATIC FILE INCLUDE
function sc_static_html ($atts) {

	// Extract Shortcode Parameters/Attributes
    extract( shortcode_atts( array(
    'subdir' => NULL,
    'file' => NULL
    ), $atts ) );

    // Set file path
    $path_base = ABSPATH."wp-content/inc_static/";
    $path_file = ($subdir == NULL) ? $path_base.$file : $path_base.$subdir."/".$file;

    // Load file or, if absent. throw error
    if (file_exists($path_file)) {
        $file_content = file_get_contents($path_file);
        return $file_content;
    }
    else {
        trigger_error("'$path_file' file not found", E_USER_WARNING);
        return "FILE NOT FOUND: ".$path_file."SUBDIR = ".$subdir."FILE = ".$file."

";
    }
}

add_shortcode('static_html', 'sc_static_html');

?>

USE CASE

[static_html subdir="testdir" file="dirtest.html"]
31
Jan

Tell Me Your WordPress 2.7 Must Haves, Win a $50 Amazon Gift Card!

Dear WordPress Nation,

I need your help. I pour through the WP Themes and WP Plugins listings looking for the best of breed, but there is something missing … opinion based on informed experience. In other words, you.

So, based solely on your own experience, add a comment to this thread which includes the following:

  1. Name of your #1 must-have plugin.
  2. Link to said plugin.
  3. In a nod to Twitter (sort of) tell me why you cannot live without the aforementioned plugin in 140 WORDS (not characters, hence the “sort of”) or less.

This contest will run through February 15th at midnight. By February 22nd, I will select one winner who will receive a $50 Amazon Gift Card. Easy-peezy, no?

A few parameters for you …

  1. I know and use many of the most common and popular plugins for SEO, Twitter and the like. So, I am really looking for something out-of-the-ordinary. If it makes me go “Hmmm, I never thought I’d want that on my blog, but now I MUST have it!” … you have a good chance of winning.
  2. You cannot be the author of the plugin. No SPAM or shills please.
  3. Themes will be considered as well, but they better be pretty special to win.
  4. All Plugins or Themes must currently work with WordPress 2.7.
  5. You can only list one plugin/theme in one comment. Multiple entries in any form will be disqualified.
  6. Be sure to provide your email in the comment so I can contact you if you win. I promise not to SPAM you.

So there you have it. Knock my socks off, if not my pants (though no one really wants to see the latter but my wife). ;^D

Peace,

Doug