VC WordPress Theming

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.

My Recent Work

My Recent Work

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 [...] Read More

March In Photos 2010

March In Photos 2010

Here are more totally random pics from March 2010. Hope you enjoy, I think I’m back on track here!

[...] Read More

February In Photos 2010

February In Photos 2010

Here are some totally random pics from February 2010. I hope you enjoy. I know this is a little behind along with the January ones but oh well :)

[...] Read More

January In Photos 2010

January In Photos 2010

Here are some of my totally random photos from January 2010. I know I’m running quite a bit late on this, but hey better late than never! :)

[...] Read More

“R” is for Randy & “S” is for Sarah

Sarah and I have been chipping away at the wedding planning!!! We even tried to have a Wedding Shower, but sure enough the day we set for the shower Nashville decided to let the clouds snow on it more than it has in over decade :) (stupid clouds)

We are still on the hunt for a good Jazz Band, and we are still on the hunt for some warm weather too… If anyone here in Music [...] Read More

Top 10 of My 30th Year

So I’m 31 now and I was thinking it would be cool to try and come up with my top 5 things of my 30th year and my 5 pics of my 30th year.

Top 5 Things:

Meeting the most amazing girl at a coffee shop in Franklin!!!
Asking Sarah (the most amazing girl) to marry me! :)
Went to the Space Needle in Seattle.
Made about 2 Dozen new friends!
Went to California with Sarah to see my Family

Top 5 [...] Read More

Nashville Snow

It finally snowed in Nashville while I was in town!!! It seems as though every time it would snow I would randomly be out of town, as if I leave town on a regular basis. Not to mention it doesn’t snow that much here. All the same here are a few shots! There will be more to come.

[...] Read More

I am an “Official Nashvillian”

This last week I officialy moved into my new place in Nashville and that makes me an “Official Nashvillian”!!! Sarah and I got a place on the East side of Nashville in a nice two bedroom house, and we’ve been filling it up with all our little things.

So far so good, and the neighbor hood isn’t to bad either,,, although last night there was a strange guy on the sidewalk with a podium and some [...] Read More

A little Auburn For You

Just a few pics from the home town :) [...] Read More