'grid', 'showdotnav' => true, 'order' => 'ASC', 'orderby' => 'menu_order ID' ); /** * @var Attributes for the gallery */ private $settings; /** * @var The current post */ private $post; /** * @var The images */ private $attachments; /** * Renders a gallery based on the attributes. * Prepares content before passing rendering to specific function. * * @param $attributes * * @return mixed */ public function render($attributes) { $this->post = get_post(); $this->settings = array_merge($this->defaults, $attributes); $arguments = array( 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $this->settings['order'], 'orderby' => $this->settings['orderby'] ); if (!empty($this->settings['ids'])) { $arguments['include'] = $this->settings['ids']; } else { $arguments['include'] = $this->post ? $this->post->ID : 0; } $this->attachments = get_posts($arguments); // If no images were found... if (empty($this->attachments)) { return; } // Render the gallery if ($this->settings['type'] == 'slideshow') { return $this->renderSlideshow(); } else if ($this->settings['type'] == 'grid') { return $this->renderGrid(); } } /** * Renders the gallery like a slideshow */ private function renderSlideshow() { $description = trim($attachment->post_content) ? esc_attr($attachment->post_content) : esc_attr(trim($attachment->post_excerpt)); $output = array(); $output[] = '
'; return implode(" ", $output); } /** * Renders the gallery like a grid with lightbox */ private function renderGrid() { $output = array(); $output[] = '