Electric Tree House (bottom of the right sidebar) to try it out yourself. See Plugin website for more details and customization options. Version: 3.0.0 Author: Eric Burger Author URI: http://electrictreehouse.com/ */ class Asteroids_Widget extends WP_Widget { function Asteroids_Widget() { $widget_ops = array('classname' => 'widget_asteroids', 'description' => __('Play Asteroids and Blow Stuff Up')); $control_ops = array('width' => 500, 'height' => 350); $this->WP_Widget('asteroids', __('Asteroids Widget'), $widget_ops, $control_ops); } function widget( $args, $options ) { extract($args); $asteroids_title = apply_filters( 'widget_title', empty($options['title']) ? '' : $options['title'], $options ); $asteroids_text = apply_filters( 'widget_asteroids', $options['text'], $options ); $asteroids_link = '

By Eric and Erik

'; /* Set Image Locations */ $plugin_dir = basename(dirname(__FILE__)); $bloginfo = home_url(); $asteroids_gears = ''. $bloginfo . '/wp-content/plugins/' . $plugin_dir . '/gears'; $asteroids_bk = ''. $asteroids_gears .'/asteroids-bk.jpg'; $asteroids_mainimage = ''. $asteroids_gears .'/asteroids-image.jpg'; $asteroids_rocketimage = ''. $asteroids_gears .'/asteroids-rocket.png'; $asteroids_nohoverimage = ''. $asteroids_gears .'/asteroids.jpg'; $asteroids_hoverimage = ''. $asteroids_gears .'/asteroids-hover.jpg'; $asteroids_arcadered = ''. $asteroids_gears .'/arcade-red.png'; $asteroids_arcadeyellow = ''. $asteroids_gears .'/arcade-yellow.png'; $asteroids_arcadeblack = ''. $asteroids_gears .'/arcade-black.gif'; /* Change bullet color to yellow */ if(isset($options['bullet-color']) && $options['bullet-color'] != "") { $address = ''.WP_PLUGIN_URL .'/'. basename(dirname(__FILE__)) . '/gears/play-asteroids-yellow.min.js'; $asteroids_start = "startAsteroids('yellow','$address');"; }else{ $address = ''.WP_PLUGIN_URL .'/'. basename(dirname(__FILE__)) . '/gears/play-asteroids.min.js'; $asteroids_start = "startAsteroids('','$address');"; } $asteroids_show = $options['show']; $asteroids_slug = $options['slug']; $asteroids_buttonopt = $options['button-opt']; $asteroids_imageopt = $options['image-opt']; if($options['background']){ $before_asteroids = '
'; $before_text = ''; $after_text = ''; $after_asteroids = '
'; } else{ $before_asteroids = '
'; $before_text = ''; $after_text = ''; $after_asteroids = '
'; } switch ($asteroids_show) { case "all": // Start echo $before_widget; // Add title if ( !empty( $asteroids_title ) ) { echo $before_title . $asteroids_title . $after_title; } echo $before_asteroids; include( 'gears/run-asteroids.php'); // Clean and foramt text // ob_ and eval used to handle html and php ob_start(); eval('?>'.$asteroids_text); $asteroids_text = ob_get_contents(); ob_end_clean(); $asteroids_text = '
'.($options['filter'] ? wpautop($asteroids_text) : $asteroids_text).'
'; echo $before_text; echo $asteroids_text; echo $after_text; echo $after_asteroids; // Add link to front page only if ( is_front_page() ) {echo $asteroids_link;} // Done echo $after_widget; break; case "front": if (is_front_page()) { // Start echo $before_widget; // Add title if ( !empty( $asteroids_title ) ) { echo $before_title . $asteroids_title . $after_title; } echo $before_asteroids; include( 'gears/run-asteroids.php'); // Clean and foramt text // ob_ and eval used to handle html and php ob_start(); eval('?>'.$asteroids_text); $asteroids_text = ob_get_contents(); ob_end_clean(); $asteroids_text = '
'.($options['filter'] ? wpautop($asteroids_text) : $asteroids_text).'
'; echo $before_text; echo $asteroids_text; echo $after_text; echo $after_asteroids; // Add link to front page only echo $asteroids_link; // Done echo $after_widget; } break; case "post": if (is_single($slug)) { // Start echo $before_widget; // Add title if ( !empty( $asteroids_title ) ) { echo $before_title . $asteroids_title . $after_title; } echo $before_asteroids; include( 'gears/run-asteroids.php'); // Clean and foramt text // ob_ and eval used to handle html and php ob_start(); eval('?>'.$asteroids_text); $asteroids_text = ob_get_contents(); ob_end_clean(); $asteroids_text = '
'.($options['filter'] ? wpautop($asteroids_text) : $asteroids_text).'
'; echo $before_text; echo $asteroids_text; echo $after_text; echo $after_asteroids; // Add link to front page only echo $asteroids_link; // Done echo $after_widget; } break; case "category": if (is_category($slug)) { // Start echo $before_widget; // Add title if ( !empty( $asteroids_title ) ) { echo $before_title . $asteroids_title . $after_title; } echo $before_asteroids; include( 'gears/run-asteroids.php'); // Clean and foramt text // ob_ and eval used to handle html and php ob_start(); eval('?>'.$asteroids_text); $asteroids_text = ob_get_contents(); ob_end_clean(); $asteroids_text = '
'.($options['filter'] ? wpautop($asteroids_text) : $asteroids_text).'
'; echo $before_text; echo $asteroids_text; echo $after_text; echo $after_asteroids; // Add link to front page only echo $asteroids_link; // Done echo $after_widget; } break; case "page": if (is_page($slug)) { // Start echo $before_widget; // Add title if ( !empty( $asteroids_title ) ) { echo $before_title . $asteroids_title . $after_title; } echo $before_asteroids; include( 'gears/run-asteroids.php'); // Clean and foramt text // ob_ and eval used to handle html and php ob_start(); eval('?>'.$asteroids_text); $asteroids_text = ob_get_contents(); ob_end_clean(); $asteroids_text = '
'.($options['filter'] ? wpautop($asteroids_text) : $asteroids_text).'
'; echo $before_text; echo $asteroids_text; echo $after_text; echo $after_asteroids; // Add link to front page only echo $asteroids_link; // Done echo $after_widget; } break; } } function update( $newoptions, $oldoptions ) { $options = $oldoptions; $options['title'] = strip_tags($newoptions['title']); if ( current_user_can('unfiltered_html') ) $options['text'] = $newoptions['text']; else $options['text'] = stripslashes( wp_filter_post_kses( $newoptions['text'] ) ); $options['filter'] = isset($newoptions['filter']); $options['bullet-color'] = isset($newoptions['bullet-color']); $options['background'] = isset($newoptions['background']); $options['button-opt'] = $newoptions['button-opt']; $options['image-opt'] = $newoptions['image-opt']; $options['show'] = $newoptions['show']; $options['slug'] = strip_tags(stripslashes($newoptions['slug'])); return $options; } function form( $options ) { $options = wp_parse_args( (array) $options, array( 'title' => '', 'text' => '' , 'button-opt' => 'push-1' ) ); $title = strip_tags($options['title']); $text = format_to_edit($options['text']); $allSelected = $frontSelected = $postSelected = $pageSelected = $categorySelected = false; switch ($options['show']) { case "all": $allSelected = true; break; case "": $allSelected = true; break; case "front": $frontSelected = true; break; case "post": $postSelected = true; break; case "page": $pageSelected = true; break; case "category": $categorySelected = true; break; } ?>

Add a description so people know what they are clicking on. Add directions like: fly with the arrow keys and shoot with spacebar. Or add html/php code to include a picture. See Read Me for more editing options or visit Electric Tree House.

tags for it to be recognized. */ ?>

Choose the pages on which the Asteroids Widget should appear:

Though Erik and I are upstanding young people, have put a lot of time and work into this widget, and would appreciate the link, you can use the "Page(s)" option to disable the link.

The Asteroids Button can be added to any post or page by simple writting [asteroids] within the text. 'something', 'bar' => 'something else', ), $atts ) ); $address = ''.WP_PLUGIN_URL .'/'. basename(dirname(__FILE__)) . '/gears/play-asteroids.min.js'; $asteroids_start = "startAsteroids('','$address');"; $asteroids_buttonopt = "push-1"; include( 'gears/run-asteroids.php'); //return "foo = {$foo}"; } add_shortcode( 'asteroids', 'asteroids_short_func' ); ?>