Category: WordPress
No Comments

I’ve been developing with WordPress for about 2.5 yrs and this morning I really wanted to write something about all the work that I do, but am realizing that I just don’t know what to say with out writing a freaking book on the DevTime of WordPress. Not to mention there are so many people out there who have already laid down the law on what WordPress is.

So to curb my need to publish I though I would share a WP function that I have found to be a huge time saver, and something WP uses a lot. As you’ll see below it’s not much to speak of and it’s fairly basic in the scheme of things, but it will save a lot of time when comparing incoming variables with default variables.

wp_parse_args()

You can find this in wp-includes/functions.php -> line 2887 wp3.0 beta1


/**
* Merge user defined arguments into defaults array.
*
* This function is used throughout WordPress to allow for both string or array
* to be merged into another array.
*
* @since 2.2.0
*
* @param string|array $args Value to merge with $defaults
* @param array $defaults Array that serves as the defaults.
* @return array Merged user defined values with defaults.
*/
function wp_parse_args( $args, $defaults = '' ) {
if ( is_object( $args ) )
$r = get_object_vars( $args );
elseif ( is_array( $args ) )
$r =& $args;
else
wp_parse_str( $args, $r );

if ( is_array( $defaults ) )
return array_merge( $defaults, $r );
return $r;
}

Here is an example being used in the form function of a widget class, which is a great place to set defaults variables.


function form( $instance ) {

$widget_options = get_option('_my_widget_options');

//Defaults
$defaults = array(
'title_display' => 'Text',
'text_title' => '',
'image_title' => '',
'link' => '',
'post_cat' => $widget_options['post_cat'],
'post_count' => $widget_options['post_count'],
'word_count' => $widget_options['word_count'],
'read_more' => $widget_options['read_more'],
'strip_tags' => $widget_options['strip_tags'],
'show_thumbnail' => '',
'show_video' => '',
'css_class' => ''
);

$r = wp_parse_args( $instance, $defaults );
extract( $r, EXTR_SKIP );

echo 'do cool stuff here...';
}

So yeah, really exciting stuff right? Maybe not, but hey if you’re into php & WordPress you should check this out for sure. It’s been around for while so there is really no excuse.

Category: Themes, WordPress
No Comments

I’ve been on the keyboard for the last 3.5 months and it’s been quite a crazy time. So far 2010 has been more busy then I ever expected. My recent work has been expanding my theme by leaps and bounds. It’s odd that every site I build kills all the previous ones. (it’s almost time to update my site, I just wish I had some time :)

There is a lot to go over so I’ll just list off the latest projects. (Most of these are Skörinc, but one or two came from BuzzPlant)

Category: WordPress
1 Comment

I think one of the most frequently asked questions I hear on a regular basis is; “Can WordPress Do That?” The answer is always the same…. Yes!!!

The best response to any question like that is, “Who’s building it?” Honestly the question isn’t about weather or not “WordPress” can do something or not. Sure “out of the Box WP” can only do you so much. You add a dozen good plugins, a standard theme and you’ll have yourself a serious platform.

I find that the best approach to explaining a Platform like WordPress is comparing it to a Pile of Legos. “In My Mind” every Version of WP is like an updated version of my favorite “Web Legos”. The WordPress Community and Automattic have been so kind as to create all these different pieces for us to use.

For me the idea of building something for a Web Site isn’t about just building something for one person. Every time I build a page I think about how I might use it in the future and I build it with development in mind…
“Could This be a Plugin”,
“Should This be a Plugin”,
“Should I work this into the Admin”,
“Should this be a Template”….
(and the list goes on and on and on…)

wp_lego_man.png

What it comes down to is that “WordPress is an Engine that lets the Average Person Interact with a Database”

Step 1. Build Your Own Legos – HTML / CSS FrameWork.
Step 2. Add WordPress Legos – PHP Functions & Plugins.
Step 3. Populate the Database Via WP Admin. the smart legos..
Step 4. Write Posts about Sailor Lego Men in Nasty Tank-tops….

This has been a message of Blogs for Blogs Network…