Categories
Uncategorized WordPress

WordPress 3.0 sneak peak presentation from the Portland WordPress User Group

Last night I presented at Portland WordPress user group on some of the features and changes coming in WordPress 3.0. In case you weren’t in attendance, my slides are below, and what I went over can be summed up in a couple of points:

  • The changes taking place are going to make things easier for you, but nothing is groundbreaking
  • It’s still Alpha at this point. Things can and will change before it’s released.
  • Multisite in a true sense is not going to work on a lot of shared hosting plans. You can still use Sub Directories though

After my presentation I gave a quick case study of what would happen if the A-team decided to use WordPress Multisite. I figured BA would be put in charge and would create the initial site theateam.tld. The next step for him would be to create a site for himself, ba.theateam.tld . And of course when the time came, he would create a site for a film they were using as cover, Boots and Bikinis. He would use the domain mapping plugin and thus would have just created three sites in a matter of minutes.

Continuing with my case study, I built a quick plugin to demonstrate just how easy it is to add a new post type. Figuring that the team would want to show off their missions, that’s what it does.

[php]
/*
Plugin Name: A-Team Missions
Description: I love it when a plan comes together
Author: Aaron Jorbin
Version: 1.0
Author URI: http://aaron.jorb.in/
*/

function post_type_missions() {
register_post_type( ‘missions’,
array( ‘label’ => __(‘missions’), ‘public’ => true, ‘show_ui’ => true ) );
register_taxonomy_for_object_type(‘post_tag’, ‘movies’);
}
add_action(‘init’, ‘post_type_missions’);

function loop_missions(){
$missions = get_posts(‘post_type=missions’);
ob_start();
echo "<ul>";
foreach ($missions as $mission){
echo "<li>".$mission->post_title."</li>";
}
echo "</ul>";
}

add_shortcode(‘missions’, ‘loop_missions’);

[/php]

It’s just that easy. Two functions. The first adds our post type, and the second adds a shortcode to display the title of each mission so it’s embeddable anywhere.

If you want to know more about my presentation, Kathleen Mcdade was live tweeting it.

I’m going to have some more posts in the coming weeks about WordPress 3.0. If you have any questions, please ask below.

View more presentations from aaronjorbin.
Categories
mostly pointless. Uncategorized

Tweets from the week before 2010-03-15

Categories
Code Uncategorized WordPress

More Twitter Shortcodes for WordPress

Building on my WordPress Shortcode How To, here are two more Twitter shortcodes. I’ve also added a new project on google code to track all of my shortcodes.

The first new shortcode is for twitter search. It’s logically enough

 [twitter-search phrase='#haikufriday']

Like my last twitter shortcode, it caches the results for two minutes. It also includes some other options. You can specify the number of tweets using the number attribute. There is a default of 20. You can also specify a max and min tweet id using max_id and since_id . Finally, you can specify the language with the lang attribute. This defaults to English.
[sourcecode language=”php”]
function jorbin_firestream_search($atts){
extract(shortcode_atts(array(
‘phrase’ => false,
‘lang’ =&gt; ‘en’,
‘max_id’ =&gt; false,
‘since_id’ =&gt; false,
‘number’ =&gt; ’20’
), $atts));
if (‘phrase’ == false){
return false;
}
//*/ Build our search url and transient name
$transient = ‘tweet-‘. esc_sql($phrase) . ‘&l=’ . esc_sql($lang);
$url = ‘http://search.twitter.com/search.json?q=’. urlencode($phrase) . ‘&show_user=true〈=’. urlencode($lang) .’&rpp=’ . $number;

if ($max_id != false){
$url .= ‘&max_id=’ . (int) $max_id;
$transient .= ‘&m=’ . (int) $max_id;
}
if ($since_id != false){
$url .= ‘&since_id=’ . (int) $since_id;
$transient .= ‘&s=’ . (int) $since_id;
}

if ( $tweet_display = get_transient($transient) ){
// It’s allready been brought
}
else {

if ($search = wp_remote_get( $url ) ){

$results = json_decode($search[‘body’]);

ob_start();
$tweets = $results-&gt;results;
//*/
foreach ( (array) $tweets as $tweet){
$tweetcontent = $tweet-&gt;text;
$newcontent = preg_replace(‘%@([^\s]*)%’, "<a href="http://twitter.com/\\1">@\\1</a>", $tweetcontent);
echo "<div class="twitter_shortcode"><p>
<img class="twitter_shortcode_image" src="&quot;.esc_url($tweet-&gt;profile_image_url).&quot;"><span class="twitter_shotcode_username"><a href="http://twitter.com/&quot;.$tweet-&gt;from_user.&quot;">".$tweet-&gt;from_user."</a>&nbsp;—&nbsp;</span>". $newcontent ."</p>
</div>";

}
$tweet_display = ob_get_clean();
set_transient($transient, $tweet_display, 300);
}
else
{
$tweet_display = "I’m sorry, no tweets are availailable at this time";
}
}
return apply_filters(‘jorbin_tweet_content’, $tweet_display) ;
}
add_filter(‘jorbin_tweet_content’, ‘make_clickable’ );
add_shortcode(‘twitter-search’, ‘jorbin_firestream_search’);

[/sourcecode]
Like before, there are some classes for you to work with that should make it easy for you to theme these shortcodes. If you want for me to add more, comment below.

The second shortcode allows you to get and display a list of the most recent trends on twitter using the shortcode:

[twitter-trends]

This one doesn’t have any attribute. The output is in an unordered list with the class of twitter-trends.
[sourcecode language=”php”]
function jorbin_twitter_trends(){

$transient=’twitter-trends’;
$url = ‘http://search.twitter.com/trends.json’;

if ( $tweet_display = get_transient($transient) ){

}
else{
$search = wp_remote_get( $url );

$results = json_decode($search[‘body’]);
$trends = $results-&gt;trends;
ob_start();
echo "<ul class="twitter-trends">";
foreach ($trends as $trend){
echo ‘<li><a href="’ . esc_url($trend-&gt;url) . ‘"> ‘. esc_html($trend-&gt;name) . ‘</a></li>’;
}
echo "</ul>";
$tweet_display = ob_get_clean();
set_transient($transient, $tweet_display, 120);
}
return $tweet_display;
}

add_shortcode(‘twitter-trends’, ‘jorbin_twitter_trends’);

[/sourcecode]
If you use any of these, let me know. If there are any improvements or more you want to see, comment below.

Categories
Uncategorized WordPress

Portland WordPress User Group Presentation Upcoming

I’m going to be speaking at the March Portland WordPress User Group Meeting on March 18th at 6:00pm at Webtrends and demonstrating some of the features that are coming up in 3.0. I’m aiming for this to be beneficial for both users and developers.

Right now, I plan on covering:

  • What the Multisite features mean to both users and developers
  • How to enable Multisite once you’ve upgraded
  • How to add and customize custom menus on your site
  • How to add a custom post type

If there is anything else that you would like for me to cover, please comment on the post there. I hope to see you there!

Categories
mostly pointless. Uncategorized

Tweets from the week before 2010-03-08

Categories
Food One Hundred Meats Uncategorized

Torihamu Parmesan

Cooking and constructing a web presence with open source software is very similar. For one by combining the efforts of many, we can bring together a far superior product. While I usually combine WordPress with jQuery, this time I combined a Japanese preparation with an Italian food item for a delicious combination. For another you can start with a basic item, and grow it and expand it as your needs change. I started with a basic chicken recipe and expanded it into a meal much like you can use WordPress to start with a blog and expand it to manage your entire website.

I saw the recipe for Torihamu on Just Bento and had to give it a try. Here’s how I did it and how I then used some of it for a super quick Chicken Parmesan. I don’t measure a lot of the ingredients so you’ll have to eye-ball it.

ingredients

  • Boneless Skinless Chicken Breasts
  • 1 tablespoon of honey per breast
  • 1 & ½ teaspoon kosher salt per breast
  • Fresh cracked black pepper
  • Fresh Thyme
  • Garlic
  • Carrots
  • Onion
  • olive oil
  • Shredded Fresh mozzarella
  • Shredded Parmesan
  • tomato Sauce

Step 1:

Marinate the chicken breasts, honey, salt, fresh pepper, and fresh thyme in a Ziploc back for two days in the refrigerator.

Step 2:

Rinse the chicken and soak it for an hour in cold water for an hour

Step 3:

While the chicken is desalinating and soaking, crush up the garlic and put the onions and carrots in a food processor and process until finely chopped. Place these in a large heavy bottom pot with the olive oil and saute over medium heat for 5-10 min.

Step 4:

Fill the pot with enough cold water to comfortably cover all the chicken. Turn the heat to high and cover.

Step 5:

Once the water is boiling and the chicken has soaked for an hour, turn the heat low enough that you are at the lowest possible boil. Add the chicken, cover and turn off the heat. Now wait about 6-8 hours.

At this point, you have two things. You have chicken stock which I used for Potato Risotto and the Torihamu. You can store some of the chicken and use it on salads, in sandwiches or anything else. If you want Torihamu Parmesan, just continue.

Step 6:

Heat a nonstick skillet with some more olive oil over medium head.

Step 7:

Slice the chicken breasts in half (you want two not very thick chicken breasts). Place cut side down in the skillet, cover with some tomato sauce and both cheeses. Cover the skillet and cook for 5-10 min until the cheese is melted and the sauce is warmed.

Step 8: (optional)

I then put the chicken under the broiler for 1-2 more min so the cheese was a bit browned. I imagine you wouldn’t need to do this step if you didn’t want to

That’s it. It is that simple. I made plenty of Torihamu that my girlfriend enjoyed in many different ways for lunch and we had the Torihamu Parmesan as a the main course for dinner. Let me know if you try this and what your thoughts are.

Categories
Random Opinions Uncategorized

Three great places in the Washington DC area

I recently spent some time in the Washington, DC area. While I saw way more national chain stores then I’m used to seeing in Portland, there where three great local places that I wanted to highlight to anyone traveling or living there. One is a coffee shop and the two others restaurants.

Java Shack

Located at 2507 N Franklin Rd (near the intersection of Wilson and Barton in the Courthouse/Clarendon neighborhood) is a great coffee shop serving organic coffee from Lexington Coffee. The staff was friendly, the coffee hot and the wi-fi fast. One thing that I really liked was that they had a rotating single origin coffee along with a high quality house blend and a french roast that wasn’t as robust as I would have hoped. Next time I am in the area, I will definitely be returning.

Ray’s Hell Burger

Talk about one hell of a burger. Located just down the road from the java shack at 1713 Wilson Blvd, this has already jumped up into being on of my favorite burgers. They start with a patty of high quality meat that’s perfectly cooked unless you are actually looking for shoe leather. My girlfriend had mostly good things to say about the shoe leather version. Next up is a wide selection of cheeses such as Vermont White Cheddar, Dutch Mustard Seed Gouda, and Rogue Creamery Smokey Blue. You are then able to add a few extra charge toppings like Bacon, Foie Gras, and Ham. They also have an extremely large choice of free toppings including three types of Pickles, some of the best sautaedded mushrooms I’ve ever had and sautéed peppers. It was so good, I went twice.

The first time I had mine with Vermont white cheddar, sautéed mushrooms, grilled onions, sautéed peppers, and dill pickle chips. It was perfectly cooked with a warm red center and a great bun that held together even with how juicy the burger and toppings were. And boy were they juicy. I can’t say enough great things about the mushrooms. I almost want to see if I can just order a bun loaded with those mushrooms and some cheese.

On my second visit I switched the cheese to Pepper Jack and added bacon and roasted garlic to my burger. While it was amazing, I think next time I’m there I’ll cut down on the toppings to not overpower the burger. I tried both the regular fries and the sweet potato fries. My recommendation, skip the regular fries, and go straight for the sweet.

I couldn’t find a website for them, but you can take a look at a scan of the menu at Beans, Rice, & Life.  Also, bring cash, they don’t take cards.

Ben’s Chilli Bowl

The Chilli Half Smoke is by far the best Chili dog I’ve had in my life. There is no doubt about it. I can’t say that enough times. Best. Chilli. Dog. Ever. The chilli has a good kick, but yet isn’t so strong that it overpowers. The dogs come with chips and the fries are mostly lifeless.

It’s located right across the street from the U street metro station at 1213 U ST, NW. They also have vegan options, so even if you’re a herbivore, you can eat here.  Bring cash, they don’t take cards and the only people who eat for free are Bill Cosby, Malia Obama, Sasha Obama, and Michelle Obama.

Let me know if you try or have been to any of these places. I’d love to hear some others thoughts.

Categories
Programming Uncategorized WordPress

Commit: The Story of Writing a WordPress Patch

Hanging out in the #WordPress irc channel or on the wp-hackers mailing list, a question that comes up from time to time is “How do I get a bug patched”. I recently had a patch committed, so I thought I would detail the process from start to finish to help others get an idea of the process. I can’t guarantee that others will have the same experience, or that even I will have the same experience next time, but this was how I had my first substantial patch committed to WordPress.

The process for me started by seeing a post by Jane Wells talking about a few UX enhancements she wanted to see handled during the recent patch sprint. One that I noticed hadn’t received any attention was Showing the status of an admin attempts an e-mail change under the new multisite configuration. I took a quick look at the relevent code and figured this was something I could patch.

Lesson 1: Make it easy for coders and non-coders to see the change

After I wrote my first iteration of a patch, I hopped into #wordpress-dev and Andrew Nacin recommended that I add a screenshot to make it easier for Jane to see the change.  I couldn’t agree more that this was a great idea. After all, why should you need to apply my patch & test it, or understand the code behind it just to comment on it.

Lesson 2: Just because you write the patch, doesn’t mean others don’t have good ideas for it

I then waited till I was in #wordpress-dev at the same time as Jane and brought up the ticket. This led to a conversation between Jeremy Clarke, jane and myself about the best way to let users know. During this time I went thought a few other iterations and shared those on the ticket. We didn’t come to a firm conclusion, and the next morning Nacin commented with a suggestion on the ticket.

Lesson 3: Sometimes one small change leads to another

The next day I once again headed to #wordpress-dev where Jane, Nacin, and I took another stab at it and decided that an inline warning box would give the proper notification without being distracting. While writing the final version of the patch I noticed that all warning boxes automatically moved to the top of the screen. Nacin took ownership of fixing this, made a few minor changes to my patch and committed changeset #13446.  Now not only will users be able to see pending admin e-mail changes, but developers can use the existing UI warnings inline.

Overall, the process to fix this UX bug took four people and multiple iterations.  I want to thank all three others for assisting me. While there are times that errors make it into the released version of WordPress, I hope this story gives you the idea of the effort that the core development team takes to make sure only the highest quality code and user experience for users.

Categories
mostly pointless. Uncategorized

Tweets from the week before 2010-03-01

Categories
Code Programming WordPress

WordPress External Cron Plugin

There are plenty of scripts out there that require you to request a page on a daily basis to perform certain tasks. Normally you can accomplish this by setting up a simple cron. And on a good host, that’s easy. But what if your host doesn’t have cron? Well if you run WordPress, you now can use my Hit an External Cron plugin. You can download it from Google Code. It’s a simple plugin that adds an options page under settings to enter the url you need to visit on a daily basis.

Not only am I releasing this plugin under the GPL, but if you continue reading I’ll explain to you everything under the hood.