Snoozy the Sloth Is a Creepy Comforting Stuffed Animal That Really Breathes [Robots]

View original post found on Gizmodo authored by Dan Nosowitz

Parsons student Justin Blinder created the Arduino-based Snoozy the Sloth stuffed animal as “an intimate, yet passive, toy interaction that relaxes and comforts a user.” Cuddly, or creepy?

Snoozy the Sloth from Justin Blinder on Vimeo.

The sloth doll uses an Arduino microcontroller, two diaphragm pumps, and a latex glove to act as the “lung;” Blinder makes it clear that he wanted not the illusion of breathing (by having, for example, a mechanically contracting and expanding chest) but the actual intake and expulsion of air. In other words, this thing can gently breathe on your neck, which sounds about the same mixture of creepy and cute as The Police’s “I’ll Be Watching You.” On the other hand, we could totally see kids loving this: They go crazy for dolls with semi-animate features, like giggling Elmo or those dolls that pee (weird!). And kids have less experience than we with machines behaving badly, anyway, so their innocent little minds can enjoy the doll without fear of, you know, horrible robot murder. [Official Site, Thanks Justin!]

The Dam Just Broke: Facebook Opens Up to OpenID

View original post found on ReadWriteWeb authored by Marshall Kirkpatrick

In a few minutes Facebook will become the biggest example of a social network that allows users to log-in with OpenID credentials granted to them by other companies’ websites. Major networks have said for months that their ID could be used as OpenID, but becoming “relying parties” that accepted OpenID from elsewhere was the step everyone was waiting for. The dam has broken.

It’s ironic that it’s Facebook that did it. Facebook is probably the most closed of all the major social networks (other than LinkedIn) and is so far ahead of everyone else in market share that traditional logic would argue that they have no interest in this kind of interoperability. This is the kind of step that was expected from networks more open and, frankly, far behind Facebook. Nevertheless, it has happened and it’s big news.

Sponsor

New Facebook users will now be able to create Facebook accounts using their Gmail credentials and existing users will be able to associate and thus log in with Gmail or any other OpenID account that supports “automatic login.”

FBOpenID.jpg

That means fewer passwords to remember. Just log in with your favorite OpenID supporting account and don’t worry about one just for Facebook. Single sign on is just the simplest benefit though.

Presumably, the friends you bring with you in your OpenID account will be searched for automatically on Facebook. “In tests we’ve run,” the company said today, “we’ve noticed that first-time users who register on the site with OpenID are more likely to become active Facebook users. They get up and running after registering even faster than before, find their friends easily, and quickly engage on the site.”

Contact lists are the second simplest benefit of this kind of data portability, but other payloads are possible and that’s when it gets even more exciting. We’ll see what Facebook does to move the ball even further up the court.

Nothing is live yet and we haven’t been able to test out usability (we just got a press release about the forthcoming announcement at 1:30 PM PST, which is latehere.), but Facebook is very good about things like that and has been working with the OpenID community on usability (its biggest challenge) for months.

Expect MySpace, Digg, Twitter and maybe some Yahoo sites to start accepting OpenID from other companies by the end of this summer at the latest. It’s only a matter of time now that Facebook has.

Note: Jason Kincaid at TechCrunch argues otherwise:

“Facebook has really been a relying party since its inception - there’s never been a “Facebook ID” because you’ve always used your university Email (or more recently, your personal Email) to log in. So the site isn’t really sacrificing anything by enabling OpenID support. The likes of Google and Microsoft have built many services tied to their own proprietary accounts, and they’re going to be far more hesitant to give those up.”

We can see some strong logic here, but we also suspect there will be additional factors that emerge, like an increasing number of websites deciding to become OpenID providers so their user data can be used in Facebook, that will keep the current flowing in this direction.

Discuss

Free Software Beats Nikon at its Own Game

View original post found on Wired: Gadget Lab authored by Charlie Sorrel

sofortbild

Sofortbild is the second cheap alternative to a Nikon product we have seen this week. It is a piece of software with which to tether your Nikon DSLR, and it’s free. Why shoot tethered? There are lots of reasons, including the ability to remote control the camera and to almost instantly display your pictures on the big screen as you take them.

Sofortbild (which translates roughly as Instant Picture) doesn’t offer all the features of Nikon’s Camera Control software, but it adds a few things you won’t find in Nikon’s version, such as shooting a bracketed range of pictures and generating an HDR (high dynamic range) image from them. There is also GPS support and a rather nice HUD-style panel to show the metadata. In fact, the entire application wins in terms of interface — Nikon’s software products seem to be designed with a real hatred for the user.

You don’t get to use live view, which is a shame — it’s nice to see a live, full screen feed from the camera, and you can’t control as much as you can with the Nikon software, but it’s free, and Nikon Capture Control cost $180. That alone makes it worth a download.

Product page [Sofortbild]

Google OpenID Updates UI, Extends More Data to Relying Party Sites

View original post found on ReadWriteWeb authored by Jolie O'Dell

This morning, Google announced two enhancements to their OpenID API. For end users, they have rolled out a popup-style interface for simpler logins with fewer redirects and less confusion. They also extended their Attribute Exchange to include more user data, such as first and last names, preferred language, country, and other, more personal information available via the Google Data API.

At the OpenID blog, David Recordon wrote this morning, “This means that Google users signing into sites… now have a much better user experience, one on par with Facebook Connect.” The screenshots below show the new login in action.

Sponsor

According to this morning’s entry from Yariv Adan on the Google Code Blog, the new UI “is designed to streamline the federated login experience for users. Specifically, it’s designed to ensure that the context of the Relying Party website is always available and visible, even in the extreme case where a confused user closes the Google approval window.”

The post continues with a specific use case. OpenID products company JanRain is using the new API in their RPX offering. The first step on the login page “is identical to that of the ‘full page’ version, and does not require any changes in the Relying Party UI,” read the blog.”

In addition to signing into sites using their Google accounts, users are also sharing specific data with the Relying Party website. The data shared can range from the user’s email, first and last name, preferred language, and country, to other information available through the Google Data API, including the user’s Contacts List, Web Albums, or Calendar.

Adan writes, “Google strongly believes that the data our users trust us with belongs to them and should always be available for them to use. By providing users with more secure means to share their data, they can benefit from a much more streamlined, personalized and socially relevant experience when they log in to trusted websites.”

The new process also allows a streamlined conversion process for Relying Party websites.

Discuss

Facebook First Big Site To Really Embrace OpenID

View original post found on TechCrunch authored by Michael Arrington

Apparently it’s embrace the developer community day at Facebook. In addition to the news that they are making activity stream data available to third party developers, they’ll also be making an announcement around OpenID, we’ve heard. And importantly, the announcement is that they’ll become what’s called a relying party, meaning anyone with an OpenID (Yahoo, Google, AOL, MySpace are all issuers, and Microsoft is in beta) can create and log into a Facebook account using those credentials.

Let me take a step back. OpenID is a distributed single sign on solution that allows people to sign into different services with the same login credentials. There are two ways companies/websites can participate in the OpenID framework - as “issuing parties” or as “relying parties.” Issuing parties make their user accounts OpenID compatible. Relying parties are websites that allow users to sign into their sites with credentials from Issuing parties. Of course, sites can also be both. In fact, if they aren’t both it can be confusing and isn’t a good user experience.

All the big guys are now Issuing Parties, which allow their users logging in all over the Internet with those credentials. But none of them accept IDs from anywhere else, so anyone that uses their services has to create new credentials with them. It’s all gain, no pain. There are two exceptions - AOL Mapquest and Google’s Blogger - but for the most part the big guys are issuers, not relying parties. And that has led us in the past to accuse them of exploiting OpenID for their own benefit without giving back to the community. See our post Is OpenID Being Exploited By The Big Internet Companies?

Facebook has been a wild card with OpenID. They’ve talked about adopting it eventually, but their Facebook Connect product has actually muddled the situation - Facebook actually competes directly with OpenID when allowing users to sign in to third party sites via Facebook Connect.

Now that’s going to change, and we’ll soon see users have the ability to sign in to Facebook using, say, their MySpace credentials if they choose to. I like the thought of that.

But it still may be a while before we see the other major players take similar steps. Facebook has never really had notion of a user ID - you’ve always logged in with your Email address, which could have come from any number of other services, so Facebook isn’t really sacrificing much here. Instead of a user name, Facebook members are assigned a meaningless user ID number (though they’re experimenting with vanity pages).

Contrast that with Yahoo and Google, both of which have built up their own login systems, which can be used across multiple services using a single persistent account name. Users benefit because they can seamlessly jump between services, and Yahoo and Google get their users to stay within their own suite of products. There’s a good chance they’re not going to give that up so readily.

Crunch Network: CrunchBoard because it’s time for you to find a new Job2.0

Facebook Open Stream API: The Next Huge Platform?

View original post found on Mashable! authored by Stan Schroeder

facebook logoAs expected since yesterday, Facebook has launched the Open Stream API, which lets third-party developers use Facebook’s activity stream inside their own applications and services.

Developers will be able to filter and remix the stream - consisting of status updates, photos, videos, notes, as well as likes and comments on all the above - as they see fit. They will also be able to create content directly in the streams; for example, an application will be able to change the user’s status update.

Such an open approach did wonders for Twitter, and it means that we can soon expect hundreds of new applications developed for Facebook. We’ll see advanced applications like Tweetdeck applied to Facebook. For many advanced, tech-savvy users, Facebook’s homepage will become obsolete as they move on to applications that offer even more options. It also means that Facebook will get even more free PR as all these new applications start hitting the mailboxes of technology oriented blogs.

All of this will, however, work only for users who give the individual application access to their stream. From the official documentation (emphasis mine):

“Instead of prompting your users for the status_update, photo_upload, video_upload, create_note, and share_item extended permissions, you can simply prompt them for the publish_stream extended permission, and that single permission lets your users update their statuses, upload photos and videos, write notes, and share links all from your application or site.”

Twitter does not have this restriction, and although it probably won’t stop developers from creating applications on the Open Stream API, ultimately it will always mean that all these applications aren’t perfect; i.e., they don’t necessarily deliver all the data you see on Facebook itself.

Beta partners include Adobe, which has created a stream Notifier, and Seesmic Desktop, an advanced Twitter and Seesmic AIR desktop client (and the successor of Twhirl), which now also includes Facebook support, but this latest version is not yet publicly available (some details can be found here however).


More Facebook Resources from Mashable:


- 5 Elements of a Successful Facebook Fan Page

- 5 Tips for Optimizing Your Brand’s Facebook Presence

- New Facebook Pages: A Guide for Social Media Marketers

- HOW TO: Survive the New, New Facebook

- 30+ Apps for Doing Business on Facebook


Reviews: Facebook, Seesmic Desktop, TweetDeck, Twhirl, Twitter

Tags: facebook, Open Stream API, twitter

Mobile Roadie Builds Bands Custom iPhone Apps On The Cheap

View original post found on TechCrunch authored by Jason Kincaid

The record industry has approached Apple’s App store with a somewhat amusing amount of hesitation. When the App Store first launched last summer, a few major artists tested the waters with some obnoxiously basic apps, sometimes consisting of little more than a splash screen and a handful of their songs. But things are beginning to change. Leading the charge has been Nine Inch Nails, which partnered with Tapulous last fall to release a special NIN version of Tap Tap Revenge and more recently launched a robust ‘NIN Access’ app that offers fans a library of rich media, news, and social features. The app’s reception has been overwhelmingly positive, with over 75% of reviewers giving it five stars.

Now the major record labels (and countless indie bands) are looking to get in on the action. Enter Mobile Roadie, a new application platform that allows bands to quickly deploy their own custom applications to the App Store. For a relatively small fee, bands can use Mobile Roadie’s mostly-automated system to build their apps and have them posted to Apple’s App Store in as little as a week (and the majority of the wait is from Apple’s still-mysterious approval process).

The application supports a wide range of content, including photo galleries, streaming music (which can be linked to songs for purchase on iTunes), YouTube videos, a list of upcoming shows, and interactive features, like a ‘fan wall’ where users can post comments and photos in real time for all to see. On the backend, bands will have access to an intuitive CMS, where they’ll be able to update photos and video, manage comments, and post news stories. They can also choose what price they’d like their app to sell for on the App Store.

CEO Michael Schneider acknowledges that there are other media platforms available, like Kyte, but says that these can run thousands of dollars apiece. Mobile Roadie is substantially cheaper, running $399 for intitial setup and then $29 a month after that. For larger bands that receive over 1000 installs, there’s an additional 1 cent per month, per install charge. The company is currently in talks with every major record label (some of which are already testing the app), and has forged an exclusive partnership with The Orchard, a leading indie distributor.

I’ve tried out a few of Mobile Roadie’s apps, and for the most part they seem to work quite well (though if a band doesn’t upload many media assets the app feels a bit barren). The company has positioned itself well in a space that is about to really take off, especially once the iPhone 3.0 software hits and users will be able to see updates in realtime from their favorite bands without having to open the application manually.

If you’d like to check out a band’s app built on the Mobile Roadie platform, you can see a directory of their apps here.

Crunch Network: CrunchGear drool over the sexiest new gadgets and hardware.

Death-Defying Stunt Video is Like Parkour for Bikes

View original post found on Wired: Gadget Lab authored by Charlie Sorrel

Did you know that this kind of thing was even possible? The video shows Danny MacAskill. who rides for UK trials bike company Inspired Bicycles, shredding it in Edinburgh. As our own Danny Dumas says on Twitter*, “From what I gather this is parkour…done with bicycles.”

Keep watching. If you think it’s all over after the first couple of minutes, it isn’t. The video just gets bigger and better as it goes on.

Inspired Bicycles - Danny MacAskill April 2009 [YouTube via Danny Doom]

Product page [Inspired Bikes]

*Normally, of course, Danny’s answer to the Twitter question “What are you doing?” is “Styling my hair. My beautiful hair. In the mirror.”

Greatest Living Samurai Reduced To Slicing Vegetables, BBs in Slow-Mo [Impressive]

View original post found on Gizmodo authored by Sean Fallon

The noble Samurai has found his role in Japanese society reduced over the decades from a fearsome fighting warrior to a skilled cutter of vegetables and BBs that’s paraded on TV shows for our amusement.

Granted, this video illustrates Samurai Isao Machii’s impressive skill and hand-eye coordination, but until he can slice actual flying bullets instead of BBs, he will be nearly useless in battle (although he is still great for ratings). [Tokyomango via Neatorama]

10 Exceptional WordPress Hacks

View original post found on Smashing Magazine authored by Jean-Baptiste Jung

One of the reasons people love WordPress so much is its great flexibility. You can change the software’s appearance with themes. You can enhance its functionality with plug-ins. And, last but not least, you can totally unleash WordPress’ power with hacks. Some time ago, we wrote a post showing 10 Killer WordPress Hacks.

Today, let’s do it again with 10 new and totally killer WordPress hacks to make your blog stand out from the crowd. As usual, we won’t just list the hacks alone. In each entry, you’ll find an explanation of the code as well as the kinds of problems that the hack solves.

You may be interested in the following related posts:

1. Create TinyURLs On The Fly

Screenshot

The problem. Because Twitter has become a social media revolution, many bloggers and Twitter users enjoy sharing blog posts they have found and liked on Twitter. However, manually creating a TinyURL before tweeting can get a little tedious. As you probably know, Twitter can bring a lot of traffic to your blog, so it is in your interest to consistently provide short URLs to your readers.

The solution. To use this recipe, follow the simple steps below:

  1. Open your functions.php file.
  2. Paste the following code in the file:
    function getTinyUrl($url) {
        $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
        return $tinyurl;
    }
  3. Open your single.php file and paste the following in the loop:
    <?php
    $turl = getTinyUrl(get_permalink($post->ID));
    echo 'Tiny Url for this post: <a href="'.$turl.'">'.$turl.'</a>'
    ?>
  4. That’s all you need. Each of your posts now has its own TinyURL, ready for tweeting!

Code explanation. The popular URL shortening service TinyURL provides a quick API that creates TinyURLs on the fly. When you pass a URL to http://tinyurl.com/api-create.php, the API immediately prints the related TinyURL on the screen.

Using the PHP function file_get_contents(), we can get it and assign it to the $tinyurl variable. The last part of the code retrieves the post’s permalink and passes it as a parameter to the getTinyUrl() function previously created.

Source:

2. List Upcoming Posts

Screenshot

The problem. If you often schedule posts to be published, how about displaying them in a list? This will make your readers look forward to what you’re going to publish in a few days and can help you reach new RSS subscribers. Implementing this functionality on your WordPress blog isn’t hard at all.

The solution. Nothing hard here. Just copy this code and paste it anywhere in your theme files.

<div id="zukunft">
	<div id="zukunft_header"><p>Future events</p></div>

	<?php query_posts('showposts=10&post_status=future'); ?>
	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
		<div >
			<p class><b><?php the_title(); ?></b><?php edit_post_link('e',' (',')'); ?><br />

			<span class="datetime"><?php the_time('j. F Y'); ?></span></p>
		</div>
	<?php endwhile; else: ?><p>No future events scheduled.</p><?php endif; ?>

</div>

Once you’ve saved the file, your upcoming posts will be displayed on your blog.

Code explanation. This code use the super-powerful query_posts() WordPress function, which allows you to take control of the WordPress loop.

The parameter used is post_status, which allows you to get posts according to their status (published, draft, pending or future). The showposts parameter is also used to define how many items you’d like to get. You can change the value of this parameter on line 4 to retrieve more or less than ten posts.

Source:

3. Create A “Send To Facebook” Button

Screenshot

The problem. In the first hack, we noted that Twitter can bring a lot traffic to your blog. Another website that can boost your traffic stats easily is Facebook. In this hack, let’s see how we can create a “Send to Facebook” button for your WordPress blog.

The solution.

  1. Open the single.php file in your theme.
  2. Paste the following code in the loop:
    <a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>" target="blank">Share on Facebook</a>
  3. Alternatively, you could use the getTinyUrl() function to send a short URL to Facebook:
    <?php $turl = getTinyUrl(get_permalink($post->ID)); ?>
    <a href="http://www.facebook.com/sharer.php?u=<?php echo $turl;?>&t=<?php the_title(); ?>" target="blank">Share on Facebook</a>
  4. That’s all. Your readers will now be able to share your blog post on Facebook with their friends!

Code explanation. This useful hack is very easy to understand: the only thing we do here is retrieve the post’s permalink and title and send them as parameters to http://www.facebook.com/sharer.php.

In the alternative method, we used the getTinyUrl() function (created in the previous hack) to send a short URL instead of the post’s permalink.

Source:

4. Create A Maintenance Page For Your WordPress Blog

Screenshot

The problem. One thing I really like about Drupal is the option to temporarily redirect visitors to a maintenance page. Sadly, WordPress doesn’t have this feature. When you upgrade your blog, switch themes or make design changes, you may not want your visitors to see your blog as it is being tweaked, especially if it has design or code problems or, even worse, security gaps.

The solution. To solve this problem, we use the power of the .htaccess file. Just follow the steps below to get started.

  1. Create your maintenance page. A simple WordPress page is generally sufficient.
  2. Find your .htaccess file (located at the root of your WordPress installation) and create a back-up.
  3. Open your .htaccess file for editing.
  4. Paste the following code:
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !/maintenance.html$
    RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123
    RewriteRule $ /maintenance.html [R=302,L]
  5. Replace 123\.123\.123\.123 on line 3 with your IP address (Don’t know it?). Make sure to use the same syntax.
  6. Now, all visitors except you will be redirected to your maintenance page.
  7. Once you’re done tweaking, upgrading, theme switching or whatever, re-open your .htaccess file and remove (or comment out) the redirection code.

Code explanation. The .htaccess file, which controls the Apache Web server, is very useful for these kinds of tasks.

In this example, we state that any visitor who has an IP different from 123.123.123.123 (which doesn’t request maintenance.html) should be redirected to maintenance.html.

By replacing 123.123.123.123 with your own IP address, you make sure you’re still allowed to browse your blog normally, while others are redirected to maintenance.html.

Source:

5. Display Related Posts Without A Plug-In

Screenshot

The problem. One well-known way of keeping visitors on your blog longer and helping them discover news posts is to display, usually at the end of the article, a list of related content.

Many plug-ins will do this job, but why not super-charge your theme by integrating this functionality by default?

The solution.

  1. Open the single.php file in your theme.
  2. Paste the following code in the loop:
    <?php
    $tags = wp_get_post_tags($post->ID);
    if ($tags) {
      echo 'Related Posts';
      $first_tag = $tags[0]->term_id;
      $args=array(
        'tag__in' => array($first_tag),
        'post__not_in' => array($post->ID),
        'showposts'=>5,
        'caller_get_posts'=>1
       );
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) { ?>
    <ul>
    
    </ul>
    
  3. Save the file, and then have a look at your blog: related posts are automatically displayed!

Code explanation. This hack uses tags to retrieve related posts. The first thing it does is get the post’s tags. If a post has tags, the first one is extracted and used in a query that retrieves posts with the same tag.

By default, this code displays up to five related posts. To change this number, simply edit line 9 of the code.

Source:

6. Automatically Retrieve The First Image From Posts On Your Home Page

Screenshot

The problem. Many WordPress users use custom fields to display a thumbnail on their blog home page. Of course, this is a nice solution, but how about automatically retrieving the first image from a post and using it as a thumbnail?

The solution. This hack is quite easy to implement:

  1. Open the functions.php file in your theme.
  2. Paste this code in. Don’t forget to specify a default image on line 10 (in case a post of yours does not have an image).
    function catch_that_image() {
      global $post, $posts;
      $first_img = '';
      ob_start();
      ob_end_clean();
      $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
      $first_img = $matches [1] [0];
    
      if(empty($first_img)){ //Defines a default image
        $first_img = "/images/default.jpg";
      }
      return $first_img;
    }
  3. Save the functions.php file.
  4. On your blog home page (index.php), call the function this way to get the URL of the first image from the post:
    <?php echo catch_that_image() ?>

Code explanation. The function uses the global variable $post to parse the post’s content with a regular expression. If an image is found, its URL is returned by the function. If not, the default image URL is returned.

Source:

7. Resize Images On The Fly

Screenshot

The problem. When you use thumbnails on your blog’s home page or even images in posts, having to manually resize them is boring and wastes a lot of time. So, why not use the power of PHP to do it?

The solution. To achieve this hack, just follow these simple steps:

  1. Get this script and save it on your computer (I’ll assume you’ve named it timthumb.php).
  2. Use an FTP program to connect to your server and create a new directory called scripts. Upload the timthumb.php file to it.
  3. Once done, you can display images like so:
    <img src="/scripts/timthumb.php?src=/images/whatever.jpg&h=150&w=150&zc=1" alt="Screenshot" />

    In other words, you just call the timthumb.php file and pass your image as a parameter. The same goes for your desired width and height.

Code explanation. The timthumb.php script use the PHP GD library, which allows you to manipulate images dynamically with PHP. GD is installed by default on all servers running PHP5. If you’re not running PHP5, you’ll have to check if GD is installed before using this script.

The timthumb.php file gets the parameters you’ve passed to it (image URL, width and height) and uses it to create a new image with your stated dimensions. Once that’s done, the image is returned to you.

Source:

8. Get Your Most Popular Posts Without A Plug-In

Screenshot

The problem. Displaying your most popular posts is a good way to make visitors stay longer on your blog, as is displaying related posts. Many great plug-ins can list your most popular posts, but again, why use a plug-in when you can simply hack your WordPress theme to do it automatically?

The solution. Just paste the following code anywhere in your theme files (for example, in sidebar.php). To change the number of displayed posts, simply change the “5″ on line 3 to your desired number.

<h2>Popular Posts</h2>
<ul>
<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5");
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>

<li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>">
<?php echo $title ?></a> {<?php echo $commentcount ?>}</li>
<?php } } ?>

</ul>

Code explanation. This code executes an SQL query to the WordPress database, using the $wpdb object, to get a list of the five posts with the most comments. The results are then wrapped in an unordered HTML list and displayed on screen.

Source:

9. Highlight Searched Text In Search Results

Screenshot

The problem. The WordPress search engine system is often criticized for not being powerful enough. One of its weakest points in my opinion is that searched text is not easily distinguishable from the rest of the text. Let’s solve that!

The solution.

  1. Open your search.php file and find the the_title() function.
  2. Replace it with the following:
    echo $title;
  3. Now, just before the modified line, add this code:
    <?php
    	$title 	= get_the_title();
    	$keys= explode(" ",$s);
    	$title 	= preg_replace('/('.implode('|', $keys) .')/iu',
    		'<strong class="search-excerpt">\0</strong>',
    		$title);
    ?>
  4. Save the search.php file and open style.css. Add the following line to it:
    strong.search-excerpt { background: yellow; }

That’s all. Better, isn’t it?

Code explanation. Once again, regular expressions are a lifesaver. The regexp parses the $s content ($s is the variable containing the searched text) and automatically adds a <strong class=”search-excerpt”> element around any occurrences of $s.

Then, you simply modify your style.css file to give searched text a special style and make it more visible to your readers.

Sources:

10. Disable Widgetized Areas Without Editing Theme Files

Screenshot

The problem. Widgets are very useful, but sometimes you don’t need them on a particular page or post. Sure, you can create a page template for a particular page or even remove the widgetized zone from the code, but a much better and more elegant solution exists.

The solution. To do this, simply add the following code to your functions.php file:

<?php
add_filter( 'sidebars_widgets', 'disable_all_widgets' );

function disable_all_widgets( $sidebars_widgets ) {
	if ( is_home() )
		$sidebars_widgets = array( false );
	return $sidebars_widgets;
}
?>

Code explanation. This code first adds a filter to the sidebars_widgets WordPress function. Now every time WordPress tries to execute this function, it will execute the disable_all_widgets function we just created.

The disable_all_widgets function uses WordPress conditional tags (in this example, is_home(), but you can use any conditional tag) to disable all widgets if a visitor is on a particular page or post.

Source:

Related posts

You may be interested in the following related posts:

About the author

This post was written by Jean-Baptiste Jung, a 27-year-old blogger from Belgium, who blogs about WordPress at WpRecipes, about Photoshop at PsdRecipes and about everything related to blogging and programming at Cats Who Code. You can stay in touch with Jean by following him on Twitter.

(al)


© Jean-Baptiste Jung for Smashing Magazine, 2009. |
Permalink |
104 comments |
Add to del.icio.us | Digg this | Stumble on StumbleUpon! | Tweet it! | Submit to Reddit | Forum Smashing Magazine

Post tags: , , , , , , ,