/** * Displays a slideshow that has been registered in the theme using register_slideshow * @param string $slideshow_id The id of the registered slideshow to display */ function display_slideshow($slideshow_id) { global $wordpress_slideshows; // Check that the slideshow is registered if (!empty($wordpress_slideshows) && !empty($wordpress_slideshows[$slideshow_id])) { // Get the slideshow that is associated with this ID $slideshows = get_option(WORDPRESS_SLIDESHOW_OPTION); // Check that a slideshow is actually associated with that id if (!empty($slideshows) && !empty($slideshows[$slideshow_id])) { $slideshow = WordpressSlideshow::find($slideshows[$slideshow_id]); if (!empty($slideshow)) { include WORDPRESS_SLIDESHOW_DIR . 'slideshow.php'; } } } }
public static function find($id) { if (empty($id)) { return; } global $wpdb; $query = $wpdb->prepare('SELECT * FROM ' . WORDPRESS_SLIDESHOW_SLIDE_TABLE . ' WHERE id=%s;', $id); $results = $wpdb->get_results($query); if (!is_array($results)) { throw new Exception(__('An error occured looking up for the slides', 'wordpress-slideshow')); } if (empty($results)) { return null; } $slide = WordpressSlideshow_Slide::fromQueryResult($results[0]); $slide->slideshow = WordpressSlideshow::find($slide->slideshow_id); return $slide; }