/** * Makes sure that plugin options do not disappear just * because we're lazy (using checkboxes instead of radio buttons) :D * * @since 1.6.5.4 */ function file_gallery_save_media_settings($options) { global $file_gallery; $defaults = $file_gallery->false_defaults; $defaults = file_gallery_parse_args($options, $defaults); // $defaults = shortcode_atts( $defaults, $options ); $defaults['folder'] = file_gallery_https(FILE_GALLERY_URL); $defaults['abspath'] = FILE_GALLERY_ABSPATH; return $defaults; }
/** * This function displays attachment data inside an HTML * form. It allows attachment data to be viewed as well as edited. */ function file_gallery_edit_attachment() { check_ajax_referer('file-gallery'); $type = 'image'; $media_tags = array(); $options = get_option('file_gallery'); $attachment_id = (int) $_POST['attachment_id']; $attachment = get_post($attachment_id); if (!$attachment) { printf(__('Attachment with ID <strong>%d</strong> does not exist!', 'file-gallery'), $attachment_id); exit; } if (file_gallery_file_is_displayable_image(get_attached_file($attachment->ID))) { $fullsize_src = wp_get_attachment_image_src($attachment->ID, 'large', false); $fullsize_src = $fullsize_src[0]; $size_src = wp_get_attachment_image_src($attachment->ID, 'medium', false); $size_src = $size_src[0]; } else { $fullsize_src = wp_get_attachment_url($attachment->ID); $size_src = file_gallery_https(wp_mime_type_icon($attachment->ID)); $type = 'document'; } $post_author = get_userdata($attachment->post_author); $post_author = $post_author->user_nicename; $tags = wp_get_object_terms($attachment->ID, FILE_GALLERY_MEDIA_TAG_NAME); foreach ($tags as $tag) { $media_tags[] = $tag->name; } $media_tags = implode(', ', $media_tags); $has_copies = maybe_unserialize(get_post_meta($attachment->ID, '_has_copies', true)); $is_copy = get_post_meta($attachment->ID, '_is_copy_of', true); do_action('file_gallery_edit_attachment', $attachment->ID); ?> <div id="file_gallery_attachment_edit_image"> <?php if ('image' == $type) { ?> <a href="<?php echo $fullsize_src; ?> " title="" class="attachment_edit_thumb"><img src="<?php echo $size_src; ?> " alt="image" /></a> <p> <a href="#" id="file_gallery_regenerate-<?php echo $attachment->ID; ?> " class="file_gallery_regenerate"><?php _e("Regenerate this image's thumbnails", "file-gallery"); ?> </a> </p> <?php } else { ?> <img src="<?php echo $size_src; ?> " alt="image" /> <?php } ?> <br /> <div id="attachment_data"> <?php $attachment_link = 'post.php?post=' . $attachment->ID . '&action=edit'; $original_link = 'post.php?post=' . $attachment->ID . '&action=edit'; if (floatval(get_bloginfo('version')) < 3.5) { $attachment_link = 'media.php?attachment_id=' . $attachment->ID . '&action=edit'; } ?> <p><strong><?php _e('ID:', 'file-gallery'); ?> </strong> <a href="<?php echo admin_url($attachment_link . '&TB_iframe=1'); ?> " class="thickbox" onclick="return false;"><?php echo $attachment->ID; ?> </a></p> <p><strong><?php _e('Date uploaded:', 'file-gallery'); ?> </strong><br /><?php echo date(get_option('date_format'), strtotime($attachment->post_date)); ?> </p> <p><strong><?php _e('Uploaded by:', 'file-gallery'); ?> </strong> <?php echo $post_author; ?> </p> <?php if (is_array($has_copies)) { ?> <p class="attachment_info_has_copies"><?php _e('IDs of copies of this attachment:', 'file-gallery'); ?> <strong><?php foreach ($has_copies as $c) { echo '<a href="' . admin_url('media.php?attachment_id=' . $c . '&action=edit') . '" target="_blank">' . $c . '</a>'; } ?> </strong></p> <?php } ?> <?php if ($is_copy) { $original_link = 'post.php?post=' . $is_copy . '&action=edit'; if (floatval(get_bloginfo('version')) < 3.5) { $original_link = 'media.php?attachment_id=' . $is_copy . '&action=edit'; } ?> <p class="attachment_info_is_a_copy"><?php _e('This attachment is a copy of attachment ID', 'file-gallery'); ?> <strong><?php echo '<a href="' . admin_url($original_link) . '" target="_blank">' . $is_copy . '</a>'; ?> </strong></p> <?php } ?> </div> </div> <?php do_action('file_gallery_pre_edit_attachment_post_form', $attachment->ID); ?> <div id="attachment_data_edit_form"> <input type="hidden" name="post_id" id="fgae_post_id" value="<?php echo $_POST['post_id']; ?> " /> <input type="hidden" name="attachment_id" id="fgae_attachment_id" value="<?php echo $_POST['attachment_id']; ?> " /> <input type="hidden" name="attachment_order" id="fgae_attachment_order" value="<?php echo $_POST['attachment_order']; ?> " /> <input type="hidden" name="checked_attachments" id="fgae_checked_attachments" value="<?php echo $_POST['checked_attachments']; ?> " /> <input type="hidden" name="action" id="fgae_action" value="update" /> <?php if (file_gallery_file_is_displayable_image(get_attached_file($attachment->ID))) { ?> <label for="post_alt"><?php _e('Alternate text for this image', 'file-gallery'); ?> : </label> <input type="text" name="post_alt" id="fgae_post_alt" value="<?php echo get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); ?> " class="roundborder"<?php if (!current_user_can('edit_post', $attachment->ID)) { echo ' readonly="readonly"'; } ?> /><br /> <?php } ?> <label for="post_title"><?php _e('Title', 'file-gallery'); ?> : </label> <input type="text" name="post_title" id="fgae_post_title" value="<?php echo $attachment->post_title; ?> " class="roundborder"<?php if (!current_user_can('edit_post', $attachment->ID)) { echo ' readonly="readonly"'; } ?> /><br /> <label for="post_excerpt"><?php _e('Caption', 'file-gallery'); ?> : </label> <textarea name="post_excerpt" id="fgae_post_excerpt" class="roundborder"<?php if (!current_user_can('edit_post', $attachment->ID)) { echo ' readonly="readonly"'; } ?> ><?php echo $attachment->post_excerpt; ?> </textarea><br /> <label for="post_content"><?php _e('Description', 'file-gallery'); ?> : </label> <textarea name="post_content" id="fgae_post_content" rows="4" cols="20" class="roundborder"<?php if (!current_user_can('edit_post', $attachment->ID)) { echo ' readonly="readonly"'; } ?> ><?php echo $attachment->post_content; ?> </textarea><br /> <label for="tax_input"><?php _e('Media tags (separate each tag with a comma)', 'file-gallery'); ?> : </label> <input type="text" name="tax_input" id="fgae_tax_input" value="<?php echo $media_tags; ?> " class="roundborder"<?php if (!current_user_can('edit_post', $attachment->ID)) { echo ' readonly="readonly"'; } ?> /><br /> <label for="menu_order"><?php _e('Menu order', 'file-gallery'); ?> : </label> <input type="text" name="menu_order" id="fgae_menu_order" value="<?php echo $attachment->menu_order; ?> " class="roundborder"<?php if (!current_user_can('edit_post', $attachment->ID)) { echo ' readonly="readonly"'; } ?> /><br /> <label for="attachment_uri"><?php _e('Attachment file URL:', 'file-gallery'); ?> </label> <input type="text" name="attachment_uri" id="fgae_attachment_uri" readonly="readonly" value="<?php echo $fullsize_src; ?> " class="roundborder" /> <br /> <br /> <?php if (isset($options['display_acf']) && true == $options['display_acf']) { file_gallery_attachment_custom_fields_table($attachment->ID); } ?> <input type="button" id="file_gallery_edit_attachment_save" value="<?php _e('save and return', 'file-gallery'); ?> " class="button-primary" /> <input type="button" id="file_gallery_edit_attachment_cancel"value="<?php _e('cancel and return', 'file-gallery'); ?> " class="button-secondary" /> </div> <?php do_action('file_gallery_edit_attachment_post_form', $attachment->ID); exit; }
/** * returns a list of media tags found in db */ function file_gallery_list_tags($args = array()) { global $wpdb; $list = array(); extract(wp_parse_args($args, array("type" => "html", "echo" => true, "link" => true, "slug" => false, "separator" => ", "))); $options = get_option("file_gallery"); $media_tag_tax = get_taxonomy(FILE_GALLERY_MEDIA_TAG_NAME); $media_tag_slug = $media_tag_tax->rewrite["slug"]; if (isset($options["cache"]) && true == $options["cache"]) { $transient = "filegallery_mediatags_" . $type; $cache = get_transient($transient); if ($cache) { if (!$echo) { return $cache; } echo $cache; return; } } $media_tags = $wpdb->get_results("SELECT * FROM {$wpdb->terms} \r\n\t\t LEFT JOIN {$wpdb->term_taxonomy} ON ( {$wpdb->terms}.term_id = {$wpdb->term_taxonomy}.term_id ) \r\n\t\t LEFT JOIN {$wpdb->term_relationships} ON ( {$wpdb->term_taxonomy}.term_taxonomy_id = {$wpdb->term_relationships}.term_taxonomy_id ) \r\n\t\t WHERE {$wpdb->term_taxonomy}.taxonomy = '" . FILE_GALLERY_MEDIA_TAG_NAME . "'\r\n\t\t GROUP BY {$wpdb->terms}.term_id\r\n\t\t ORDER BY `name` ASC"); if (!empty($media_tags)) { if ("array" == $type || "json" == $type) { foreach ($media_tags as $tag) { $list[] = array("term_id" => $tag->term_id, "name" => $tag->name, "slug" => $tag->slug, "term_group" => $tag->term_group, "term_taxonomy_id" => $tag->term_taxonomy_id, "taxonomy" => $tag->taxonomy, "description" => $tag->description, "parent" => $tag->parent, "count" => $tag->count, "object_id" => $tag->object_id, "term_order" => $tag->term_order); } if ("json" == $type) { $list = "{" . json_encode($list) . "}"; } } elseif ("object" == $type) { $list = $media_tags; } else { if ($link) { global $wp_rewrite; $taglink = $wp_rewrite->get_tag_permastruct(); $fs = "/"; $ss = "/"; $ts = "/"; if ("" == $taglink) { $fs = "?"; $ss = "="; $ts = ""; } foreach ($media_tags as $tag) { $list[] = '<a href="' . file_gallery_https(get_bloginfo('url')) . $fs . $media_tag_slug . $ss . $tag->slug . $ts . '" class="fg_insert_tag" name="' . $tag->slug . '">' . $tag->name . '</a>'; } } else { if ($slug) { $whattag = "slug"; } else { $whattag = "name"; } foreach ($media_tags as $tag) { $list[] = $tag->{$whattag}; } } } } if ($echo && "html" == $type) { $list = implode($separator, $list); } if (isset($options["cache"]) && true == $options["cache"]) { set_transient($transient, $list, $options["cache_time"]); } if ($echo) { echo $list; } else { return $list; } }
/** * Adds css to admin area */ function file_gallery_css_admin() { global $pagenow, $current_screen, $file_gallery; if ('post.php' == $pagenow || 'post-new.php' == $pagenow || 'page.php' == $pagenow || 'page-new.php' == $pagenow || 'media.php' == $pagenow || 'options-media.php' == $pagenow || 'media-upload.php' == $pagenow || 'upload.php' == $pagenow || 'edit.php' == $pagenow || 'options-permalink.php' == $pagenow || isset($current_screen->post_type) && 'post' == $current_screen->base) { wp_enqueue_style('file_gallery_admin', apply_filters('file_gallery_admin_css_location', file_gallery_https(FILE_GALLERY_URL) . '/css/file-gallery.css'), false, FILE_GALLERY_VERSION); if (get_bloginfo('text_direction') == 'rtl') { wp_enqueue_style('file_gallery_admin_rtl', apply_filters('file_gallery_admin_rtl_css_location', file_gallery_https(FILE_GALLERY_URL) . '/css/file-gallery-rtl.css'), false, FILE_GALLERY_VERSION); } if (floatval(get_bloginfo('version')) < 3.5) { wp_enqueue_style('file_gallery_admin_buttons', apply_filters('file_gallery_admin_css_location', file_gallery_https(FILE_GALLERY_URL) . '/css/file-gallery-pre35.css'), false, FILE_GALLERY_VERSION); if (get_bloginfo('text_direction') == 'rtl') { wp_enqueue_style('file_gallery_admin_rtl_buttons', apply_filters('file_gallery_admin_rtl_css_location', file_gallery_https(FILE_GALLERY_URL) . '/css/file-gallery-pre35-rtl.css'), false, FILE_GALLERY_VERSION); } } } }
/** * Main shortcode function * * @since 0.1 */ function file_gallery_shortcode($content = false, $attr = false) { global $file_gallery, $wpdb, $post; // if the function is called directly, not via shortcode if (false !== $content && false === $attr) { $attr = $content; } if (!isset($file_gallery->gallery_id)) { $file_gallery->gallery_id = 1; } else { $file_gallery->gallery_id++; } $options = get_option('file_gallery'); if (isset($options['cache']) && true == $options['cache']) { if ('html' == $attr['output_type'] || isset($options['cache_non_html_output']) && true == $options['cache_non_html_output']) { $transient = 'filegallery_' . md5($post->ID . "_" . serialize($attr)); $cache = get_transient($transient); if ($cache) { return $cache; } } } // if option to show galleries in excerpts is set to false... // ...replace [gallery] with user selected text if (!is_singular() && (!isset($options['in_excerpt']) || true != $options['in_excerpt'])) { return $options['in_excerpt_replace_content']; } $default_templates = unserialize(FILE_GALLERY_DEFAULT_TEMPLATES); // We're trusting author input, so let's at least make sure it looks like a valid orderby statement if (isset($attr['orderby'])) { $attr['orderby'] = sanitize_sql_orderby($attr['orderby']); if (!$attr['orderby']) { unset($attr['orderby']); } } // extract the defaults... extract(shortcode_atts(array('order' => 'ASC', 'orderby' => '', 'id' => $post->ID, 'columns' => 3, 'size' => 'thumbnail', 'link' => 'attachment', 'include' => '', 'exclude' => '', 'template' => 'default', 'linkclass' => '', 'imageclass' => '', 'galleryclass' => '', 'rel' => 1, 'tags' => '', 'tags_from' => 'current', 'output_type' => 'html', 'output_params' => 1, 'attachment_ids' => '', 'mimetype' => '', 'limit' => -1, 'offset' => -1, 'paginate' => 0, 'link_size' => 'full'), $attr)); if (!in_array($template, $default_templates)) { $template_file = FILE_GALLERY_THEME_TEMPLATES_ABSPATH . '/' . $template . '/gallery.php'; if (!is_readable($template_file)) { $template_file = FILE_GALLERY_CONTENT_TEMPLATES_ABSPATH . '/' . $template . '/gallery.php'; } } else { if ('default' == $template) { $template_file = FILE_GALLERY_DEFAULT_TEMPLATE_ABSPATH . '/gallery.php'; $template = FILE_GALLERY_DEFAULT_TEMPLATE_NAME; } else { $template_file = FILE_GALLERY_ABSPATH . '/templates/' . $template . '/gallery.php'; } } // check if template exists and replace with default if it does not if (!is_readable($template_file)) { $template_file = FILE_GALLERY_ABSPATH . '/templates/default/gallery.php'; $template = 'default'; } // get overriding variables from the template file $overriding = true; ob_start(); include $template_file; ob_end_clean(); $overriding = false; if (is_array($file_gallery->overrides) && !empty($file_gallery->overrides)) { extract($file_gallery->overrides); $file_gallery->overrides = NULL; } $limit = (int) $limit; $offset = (int) $offset; $page = (int) get_query_var('page'); if ('false' === $rel || is_numeric($rel) && 0 === (int) $rel) { $_rel = false; } elseif (1 === $rel) { $_rel = true; } else { $_rel = $rel; } if ('false' === $output_params || is_numeric($output_params) && 0 === (int) $output_params) { $output_params = false; } else { $output_params = true; } if ('false' === $paginate || is_numeric($paginate) && 0 === (int) $paginate || 0 > $limit) { $paginate = false; $found_rows = ''; } else { $paginate = true; $found_rows = 'SQL_CALC_FOUND_ROWS'; if (0 === $page) { $page = 1; } if (is_singular() && 1 < $page) { $offset = $limit * ($page - 1); } } $file_gallery->debug_add('pagination', compact('paginate', 'page')); if ('' != $include && '' == $attachment_ids) { $attachment_ids = $include; } if (!isset($linkto)) { $linkto = $link; } $sql_mimetype = ''; if ('' != $mimetype) { $mimetype = file_gallery_get_mime_type($mimetype); $sql_mimetype = wp_post_mime_type_where($mimetype); } $approved_attachment_post_statuses = apply_filters('file_gallery_approved_attachment_post_statuses', array('inherit', 'draft')); $ignored_attachment_post_statuses = apply_filters('file_gallery_ignored_attachment_post_statuses', array('trash', 'private', 'pending', 'future')); if (!empty($approved_attachment_post_statuses)) { $post_statuses = " AND ({$wpdb->posts}.post_status IN ('" . implode("', '", $approved_attachment_post_statuses) . "') ) "; } elseif (!empty($ignored_attachment_post_statuses)) { $post_statuses = " AND ({$wpdb->posts}.post_status NOT IN ('" . implode("', '", $ignored_attachment_post_statuses) . "') ) "; } else { $post_statuses = ""; } $file_gallery_query = new stdClass(); // start with tags because they negate everything else if ('' != $tags) { if ('' == $orderby || 'file_gallery' == $orderby) { $orderby = "menu_order ID"; } $query = array('post_status' => implode(',', $approved_attachment_post_statuses), 'post_type' => 'attachment', 'order' => $order, 'orderby' => $orderby, 'posts_per_page' => $limit, 'post_mime_type' => $mimetype, FILE_GALLERY_MEDIA_TAG_NAME => $tags); if ('current' == $tags_from) { $query['post_parent'] = $id; } if (!empty($exclude)) { $query['post__not_in'] = explode(',', preg_replace('/[^0-9,]+/', '', $exclude)); } if (0 < $offset) { $query['offset'] = $offset; } $file_gallery_query = new WP_Query($query); $attachments = $file_gallery_query->posts; unset($query); } elseif ('' != $attachment_ids) { $attachment_ids = trim($attachment_ids, ','); $attachment_ids = explode(',', $attachment_ids); $sql_limit = count($attachment_ids); if ('rand' == $orderby) { shuffle($attachment_ids); } $attachment_ids = implode(',', $attachment_ids); if ('' == $orderby || 'rand' == $orderby) { $orderby = sprintf("FIELD(ID,'%s')", str_replace(",", "','", $attachment_ids)); $order = ''; } elseif ('title' == $orderby) { $orderby = "{$wpdb->posts}.post_title"; } $query = sprintf("SELECT " . $found_rows . " * FROM {$wpdb->posts} \n\t\t\t WHERE {$wpdb->posts}.ID IN (%s) \n\t\t\t AND {$wpdb->posts}.post_type = 'attachment' \n\t\t\t" . $post_statuses . " ", $attachment_ids); $query .= $sql_mimetype; $query .= sprintf(" ORDER BY %s %s ", $orderby, $order); if (true !== $paginate) { $limit = $sql_limit; } } else { if ('' == $orderby) { $orderby = "menu_order ID"; } $query = array('post_parent' => $id, 'post_status' => implode(',', $approved_attachment_post_statuses), 'post_type' => 'attachment', 'order' => $order, 'orderby' => $orderby, 'posts_per_page' => $limit, 'post_mime_type' => $mimetype); if (!empty($exclude)) { $query['post__not_in'] = explode(',', preg_replace('/[^0-9,]+/', '', $exclude)); } if (0 < $offset) { $query['offset'] = $offset; } $file_gallery_query = new WP_Query($query); $attachments = $file_gallery_query->posts; unset($query); } if (isset($query)) { if (0 < $limit) { $query .= " LIMIT " . $limit; } if (0 < $offset) { $query .= " OFFSET " . $offset; } $attachments = $wpdb->get_results($query); if ('' != $found_rows) { $file_gallery_query->found_posts = $wpdb->get_var("SELECT FOUND_ROWS()"); $file_gallery_query->max_num_pages = ceil($file_gallery_query->found_posts / $limit); } } if (empty($attachments)) { return '<!-- "File Gallery" plugin says: - No attachments found for the following shortcode arguments: "' . json_encode($attr) . '" -->'; } // feed if (is_feed()) { $output = "\n"; foreach ($attachments as $attachment) { $output .= wp_get_attachment_link($attachment->ID, $size, true) . "\n"; } return $output; } $i = 0; $unique_ids = array(); $gallery_items = ''; if ('object' == $output_type || 'array' == $output_type) { $gallery_items = array(); } $autoqueueclasses = array(); if (defined('FILE_GALLERY_LIGHTBOX_CLASSES')) { $autoqueueclasses = maybe_unserialize(FILE_GALLERY_LIGHTBOX_CLASSES); } else { $autoqueueclasses = explode(',', $options['auto_enqueued_scripts']); } $file_gallery_this_template_counter = 1; // create output foreach ($attachments as $attachment) { $param = array('image_class' => $imageclass, 'link_class' => $linkclass, 'rel' => $_rel, 'title' => '', 'caption' => '', 'description' => '', 'thumb_alt' => ''); $attachment_file = get_attached_file($attachment->ID); $attachment_is_image = file_gallery_file_is_displayable_image($attachment_file); $endcol = ''; $x = ''; if ($output_params) { $plcai = array_intersect($autoqueueclasses, explode(' ', trim($linkclass))); if (!empty($plcai)) { if ($attachment_is_image) { if (true === $param['rel']) { $param['rel'] = $plcai[0] . '[' . $file_gallery->gallery_id . ']'; } elseif (!is_bool($param['rel'])) { if (false !== strpos($_rel, '$GID$')) { $param['rel'] = str_replace('$GID$', $file_gallery->gallery_id, $_rel); } else { $param['rel'] = $_rel . '[' . $file_gallery->gallery_id . ']'; } } $filter_args = array('gallery_id' => $file_gallery->gallery_id, 'linkrel' => $param['rel'], 'linkclass' => $param['link_class'], 'imageclass' => $param['image_class']); if ($param['rel']) { $param['rel'] = apply_filters('file_gallery_lightbox_linkrel', $param['rel'], 'linkrel', $filter_args); } $param['link_class'] = apply_filters('file_gallery_lightbox_linkclass', $param['link_class'], 'linkclass', $filter_args); $param['image_class'] = apply_filters('file_gallery_lightbox_imageclass', $param['image_class'], 'imageclass', $filter_args); } else { $param['link_class'] = str_replace(trim(implode(' ', $plcai)), '', trim($linkclass)); } } // if rel is still true or false if (is_bool($param['rel'])) { $param['rel'] = ''; } switch ($linkto) { case 'parent_post': $param['link'] = get_permalink($wpdb->get_var("SELECT post_parent FROM {$wpdb->posts} WHERE ID = '" . $attachment->ID . "'")); break; case 'file': $param['link'] = wp_get_attachment_url($attachment->ID); break; case 'attachment': $param['link'] = get_attachment_link($attachment->ID); break; case 'none': $param['link'] = ''; break; default: // external url $param['link'] = urldecode($linkto); break; } $param['title'] = $attachment->post_title; $param['caption'] = $attachment->post_excerpt; $param['description'] = $attachment->post_content; if ($attachment_is_image) { $thumb_src = wp_get_attachment_image_src($attachment->ID, $size); $param['thumb_link'] = $thumb_src[0]; $param['thumb_width'] = 0 == $thumb_src[1] ? file_gallery_get_image_size($param['thumb_link']) : $thumb_src[1]; $param['thumb_height'] = 0 == $thumb_src[2] ? file_gallery_get_image_size($param['thumb_link'], true) : $thumb_src[2]; if ('' != $param['link'] && 'full' != $link_size && in_array($link_size, file_gallery_get_intermediate_image_sizes())) { $full_src = wp_get_attachment_image_src($attachment->ID, $link_size); $param['link'] = $full_src[0]; } } else { $param['thumb_link'] = file_gallery_https(FILE_GALLERY_CRYSTAL_URL) . '/' . file_gallery_get_file_type($attachment->post_mime_type) . '.png'; $param['thumb_link'] = apply_filters('file_gallery_non_image_thumb_link', $param['thumb_link'], $attachment->post_mime_type, $attachment->ID); $param['thumb_width'] = '46'; $param['thumb_height'] = '60'; } if ($thumb_alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true)) { $param['thumb_alt'] = $thumb_alt; } $param['attachment_id'] = $attachment->ID; } $param = array_map('trim', $param); if ('object' == $output_type) { if ($output_params) { $attachment->params = (object) $param; } $gallery_items[] = $attachment; } elseif ('array' == $output_type || 'json' == $output_type) { if ($output_params) { $attachment->params = $param; } $gallery_items[] = get_object_vars($attachment); } else { // add the column break class and append a line break... if ($columns > 0 && ++$i % $columns == 0) { $endcol = ' gallery-endcol'; } // parse template ob_start(); extract($param); include $template_file; $x = ob_get_contents(); ob_end_clean(); $file_gallery_this_template_counter++; if ($columns > 0 && $i % $columns == 0) { $x .= $cleartag; } $gallery_items .= $x; } } // handle data types if ('object' == $output_type || 'array' == $output_type) { $output = $gallery_items; } elseif ('json' == $output_type) { $output = json_encode($gallery_items); } else { $stc = ''; $cols = ''; $pagination_html = ''; if (0 < (int) $columns) { $cols = ' columns_' . $columns; } if (isset($starttag_class) && '' != $starttag_class) { $stc = ' ' . $starttag_class; } $trans_append = "\n<!-- file gallery output cached on " . date('Y.m.d @ H:i:s', time()) . "-->\n"; if (is_singular() && isset($file_gallery_query->max_num_pages) && 1 < $file_gallery_query->max_num_pages) { $pagination_html = file_gallery_do_pagination($file_gallery_query->max_num_pages, $page); } $gallery_class = apply_filters('file_gallery_galleryclass', 'gallery ' . str_replace(' ', '-', $template) . $cols . $stc . ' ' . $galleryclass); $output = '<' . $starttag . ' id="gallery-' . $file_gallery->gallery_id . '" class="' . $gallery_class . '">' . "\n" . $gallery_items . "\n" . $pagination_html . "\n</" . $starttag . '>'; } if (isset($options['cache']) && true == $options['cache']) { if ('html' == $output_type) { set_transient($transient, $output . $trans_append, $options['cache_time']); } elseif (isset($options['cache_non_html_output']) && true == $options['cache_non_html_output']) { set_transient($transient, $output, $options['cache_time']); } } return apply_filters('file_gallery_output', $output, $post->ID, $file_gallery->gallery_id); }