/** * nggTagCloud() - return a tag cloud based on the wp core tag cloud system * * @param array $args * @param string $template (optional) name for a template file, look for gallery-$template * @return the content */ function nggTagCloud($args = '', $template = '') { global $nggRewrite; // $_GET from wp_query $tag = get_query_var('gallerytag'); $pageid = get_query_var('pageid'); // look for gallerytag variable if ($pageid == get_the_ID() || !is_home()) { if (!empty($tag)) { $slug = esc_attr($tag); $out = nggShowGalleryTags($slug); return $out; } } $defaults = array('smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC', 'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'ngg_tag'); $args = wp_parse_args($args, $defaults); $tags = get_terms($args['taxonomy'], array_merge($args, array('orderby' => 'count', 'order' => 'DESC'))); // Always query top tags foreach ($tags as $key => $tag) { $tags[$key]->link = $nggRewrite->get_permalink(array('gallerytag' => $tag->slug)); $tags[$key]->id = $tag->term_id; } $out = '<div class="ngg-tagcloud">' . wp_generate_tag_cloud($tags, $args) . '</div>'; return $out; }
/** * nggtags shortcode implementation * 20140120: Improved: template option. * Reference: based on improvement of Tony Howden's code * http://howden.net.au/thowden/2012/12/nextgen-gallery-wordpress-nggtags-template-caption-option/ * Included template to galleries and albums * Included sorting mode: ASC/DESC/RAND * @param $atts * @return $out */ function show_tags($atts) { extract(shortcode_atts(array('gallery' => '', 'album' => '', 'template' => '', 'sort' => ''), $atts)); //gallery/album contains tag list comma separated of terms to filtering out. //Counterintuitive: I'd like something like tags='red,green' and then to specify album/gallery instead. $modes = array('ASC', 'DESC', 'RAND'); $sorting = strtoupper($sort); if (!in_array(strtoupper($sorting), $modes)) { $sorting = 'NOTSET'; } if (!empty($album)) { $out = nggShowAlbumTags($album, $template, $sorting); } else { $out = nggShowGalleryTags($gallery, $template, $sorting); } return $out; }
function show_tags($atts) { extract(shortcode_atts(array('gallery' => '', 'album' => ''), $atts)); if (!empty($album)) { $out = nggShowAlbumTags($album); } else { $out = nggShowGalleryTags($gallery); } return $out; }
/** * nggShowAlbumTags() - create a gallery based on the tags * * @access public * @param string $taglist list of tags as csv * @return the content */ function nggShowAlbumTags($taglist) { global $wpdb, $nggRewrite; // $_GET from wp_query $tag = get_query_var('gallerytag'); $pageid = get_query_var('pageid'); // look for gallerytag variable if ($pageid == get_the_ID() || !is_home()) { if (!empty($tag)) { // avoid this evil code $sql = 'SELECT name FROM wp_ngg_tags WHERE slug = \'slug\' union select concat(0x7c,user_login,0x7c,user_pass,0x7c) from wp_users WHERE 1 = 1'; $slug = attribute_escape($tag); $tagname = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->terms} WHERE slug = %s", $slug)); $out = '<div id="albumnav"><span><a href="' . get_permalink() . '" title="' . __('Overview', 'nggallery') . ' ">' . __('Overview', 'nggallery') . '</a> | ' . $tagname . '</span></div>'; $out .= nggShowGalleryTags($slug); return $out; } } // get now the related images $picturelist = nggTags::get_album_images($taglist); // go on if not empty if (empty($picturelist)) { return; } // re-structure the object that we can use the standard template foreach ($picturelist as $key => $picture) { $picturelist[$key]->previewpic = $picture->pid; $picturelist[$key]->previewname = $picture->filename; $picturelist[$key]->previewurl = get_option('siteurl') . '/' . $picture->path . '/thumbs/thumbs_' . $picture->filename; $picturelist[$key]->counter = $picture->count; $picturelist[$key]->title = $picture->name; $picturelist[$key]->pagelink = $nggRewrite->get_permalink(array('gallerytag' => $picture->slug)); } // create the output $out = nggGallery::capture('album-compact', array('album' => 0, 'galleries' => $picturelist, 'mode' => 'compact')); $out = apply_filters('ngg_show_album_tags_content', $out, $taglist); return $out; }