Changeset 538292
- Timestamp:
- 04/30/2012 07:11:23 PM (14 years ago)
- Location:
- media-categories-2
- Files:
-
- 1 deleted
- 3 edited
- 4 copied
-
tags/1.2 (copied) (copied from media-categories-2/trunk)
-
tags/1.2/category-template-hierarchy.php (deleted)
-
tags/1.2/media-categories-script.js (copied) (copied from media-categories-2/trunk/media-categories-script.js) (3 diffs)
-
tags/1.2/media-categories.php (copied) (copied from media-categories-2/trunk/media-categories.php) (7 diffs)
-
tags/1.2/readme.txt (copied) (copied from media-categories-2/trunk/readme.txt) (2 diffs)
-
trunk/media-categories-script.js (modified) (3 diffs)
-
trunk/media-categories.php (modified) (7 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
media-categories-2/tags/1.2/media-categories-script.js
r495667 r538292 1 2 3 1 4 jQuery(document).ready(function($){ 2 5 … … 16 19 }); 17 20 18 19 21 form_fields.find("tr.category > td.field > input.text").val(slug_list); 20 22 }) 21 23 22 23 24 $.extend($.expr[":"], { 25 "icontains": function(elem, i, match, array) { 26 return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; 27 } 28 }); 24 29 /** 25 30 * The following javascript is borrowed from Jason Corradino's 'Searchable Categories' plugin. … … 30 35 */ 31 36 32 jQuery('#catsearch').keyup(function() {33 var val = jQuery('#catsearch').val(), lis = jQuery("#categorychecklist li");37 $('#catsearch').keyup(function() { 38 var val = $('#catsearch').val(), lis = $("#categorychecklist li"); 34 39 35 40 lis.hide(); 36 // find li labels's containing term, then back to parent li 37 var containingLabels = jQuery("#categorychecklist label:contains('" + val + "')"); 41 42 // find li labels's containing term, then back to parent li 43 var containingLabels = $("#categorychecklist label:icontains('" + val + "')"); 38 44 containingLabels.closest('li').find('li').andSelf().show(); 39 45 containingLabels.parents('#categorychecklist li').show(); -
media-categories-2/tags/1.2/media-categories.php
r519154 r538292 3 3 Plugin Name: Media Categories 4 4 Plugin URI: http://wordpress.org/extend/plugins/media-categories-2 5 Description: Allows users to assign categories to items in their Media Library with a clean and simplified, filterable version of the standard category metabox6 Version: 1. 15 Description: Allows users to assign categories to media with a clean and simplified, filterable category meta box and use shortcodes to display category galleries 6 Version: 1.2 7 7 Author: Eddie Moya 8 8 Author URL: http://eddiemoya.com … … 12 12 13 13 /** 14 * Start your engines. 15 * 14 16 * @author Eddie Moya 15 *16 * Start your engines.17 17 */ 18 18 function init() { 19 add_action('admin_init', array(__CLASS__, 'register_media_categories')); 19 add_action('init', array(__CLASS__, 'register_media_categories')); 20 add_action('init', array(__CLASS__, 'custom_gallery_shortcode')); 20 21 add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueue_media_categories_scripts')); 21 add_action('admin_ print_styles-media.php', array(__CLASS__, 'enqueue_media_categories_styles') );22 add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueue_media_categories_styles') ); 22 23 add_filter('attachment_fields_to_edit', array(__CLASS__, 'add_media_categories_metabox'), null, 2); 23 } 24 25 } 26 24 27 25 28 function enqueue_media_categories_scripts() { … … 28 31 wp_register_script('media_categories_metabox_script', WP_PLUGIN_URL . '/media-categories-2/media-categories-script.js'); 29 32 wp_enqueue_script('media_categories_metabox_script'); 30 31 33 } 32 34 } … … 38 40 wp_enqueue_style( 'media_categories_metabox_style'); 39 41 } 40 41 42 } 42 43 … … 84 85 function media_categories_meta_box($post, $box) { 85 86 86 require_once( WP_PLUGIN_DIR . '/media-categories-2/attachment-walker-category-checklist-class.php');87 require_once(plugin_dir_path(__FILE__) . 'attachment-walker-category-checklist-class.php'); 87 88 88 89 $defaults = array('taxonomy' => 'category'); … … 95 96 ?> 96 97 <div> 97 <label class='category-filter' for="category-filter"> FilterCategories:</label>98 <label class='category-filter' for="category-filter">Search Categories:</label> 98 99 <input id='catsearch' name="category-filter" type='text' /></div> 99 100 <div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv"> … … 149 150 } 150 151 152 function custom_gallery_shortcode(){ 153 remove_shortcode('gallery'); 154 add_shortcode('gallery', array(__CLASS__,'gallery_shortcode')); 155 } 156 157 /** 158 * The Gallery shortcode with category parameter. 159 * 160 * This implements the functionality of the Gallery Shortcode for displaying 161 * WordPress images on a post. 162 * 163 * Almost Identical to the gallery_shortcode() function in /wp-includes/media.php 164 * but adds a category parameter to the shortcode. 165 * 166 * @since 1.2 167 * @since WordPress 2.6.0 168 * 169 * @param array $attr Attributes of the shortcode. 170 * @return string HTML content to display gallery. 171 */ 172 function gallery_shortcode($attr) { 173 global $post; 174 175 static $instance = 0; 176 $instance++; 177 178 // Allow plugins/themes to override the default gallery template. 179 $output = apply_filters('post_gallery', '', $attr); 180 if ( $output != '' ) 181 return $output; 182 183 // We're trusting author input, so let's at least make sure it looks like a valid orderby statement 184 if ( isset( $attr['orderby'] ) ) { 185 $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); 186 if ( !$attr['orderby'] ) 187 unset( $attr['orderby'] ); 188 } 189 190 extract(shortcode_atts(array( 191 'order' => 'ASC', 192 'orderby' => 'menu_order ID', 193 'id' => $post->ID, 194 'itemtag' => 'dl', 195 'icontag' => 'dt', 196 'captiontag' => 'dd', 197 'columns' => 3, 198 'size' => 'thumbnail', 199 'include' => '', 200 'exclude' => '', 201 'category' => '' 202 ), $attr)); 203 204 $id = intval($id); 205 if ( 'RAND' == $order ) 206 $orderby = 'none'; 207 208 if( !empty($category) ){ 209 if(!is_numeric($category)) 210 $category = get_category_by_slug($category)->term_id; 211 212 if(!isset($attr['id'])) 213 $id = ''; 214 } 215 216 if ( !empty($include) ) { 217 $include = preg_replace( '/[^0-9,]+/', '', $include ); 218 $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'category' => $category) ); 219 220 $attachments = array(); 221 foreach ( $_attachments as $key => $val ) { 222 $attachments[$val->ID] = $_attachments[$key]; 223 } 224 } elseif ( !empty($exclude) ) { 225 $exclude = preg_replace( '/[^0-9,]+/', '', $exclude ); 226 $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'category' => $category) ); 227 } else { 228 $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'category' => $category) ); 229 } 230 231 if ( empty($attachments) ) 232 return ''; 233 234 if ( is_feed() ) { 235 $output = "\n"; 236 foreach ( $attachments as $att_id => $attachment ) 237 $output .= wp_get_attachment_link($att_id, $size, true) . "\n"; 238 return $output; 239 } 240 241 $itemtag = tag_escape($itemtag); 242 $captiontag = tag_escape($captiontag); 243 $columns = intval($columns); 244 $itemwidth = $columns > 0 ? floor(100/$columns) : 100; 245 $float = is_rtl() ? 'right' : 'left'; 246 247 $selector = "gallery-{$instance}"; 248 249 $gallery_style = $gallery_div = ''; 250 if ( apply_filters( 'use_default_gallery_style', true ) ) 251 $gallery_style = " 252 <style type='text/css'> 253 #{$selector} { 254 margin: auto; 255 } 256 #{$selector} .gallery-item { 257 float: {$float}; 258 margin-top: 10px; 259 text-align: center; 260 width: {$itemwidth}%; 261 } 262 #{$selector} img { 263 border: 2px solid #cfcfcf; 264 } 265 #{$selector} .gallery-caption { 266 margin-left: 0; 267 } 268 </style> 269 <!-- see gallery_shortcode() in wp-includes/media.php -->"; 270 $size_class = sanitize_html_class( $size ); 271 $gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>"; 272 $output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div ); 273 274 $i = 0; 275 foreach ( $attachments as $id => $attachment ) { 276 $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false); 277 278 $output .= "<{$itemtag} class='gallery-item'>"; 279 $output .= " 280 <{$icontag} class='gallery-icon'> 281 $link 282 </{$icontag}>"; 283 if ( $captiontag && trim($attachment->post_excerpt) ) { 284 $output .= " 285 <{$captiontag} class='wp-caption-text gallery-caption'> 286 " . wptexturize($attachment->post_excerpt) . " 287 </{$captiontag}>"; 288 } 289 $output .= "</{$itemtag}>"; 290 if ( $columns > 0 && ++$i % $columns == 0 ) 291 $output .= '<br style="clear: both" />'; 292 } 293 294 $output .= " 295 <br style='clear: both;' /> 296 </div>\n"; 297 298 return $output; 299 } 151 300 } 152 301 -
media-categories-2/tags/1.2/readme.txt
r495667 r538292 2 2 Contributors: eddiemoya 3 3 Donate link: http://eddiemoya.com 4 Tags: media categories, media, category, categories, attachment categories, taxonomy, category metabox, metabox, admin, media library, media editor, attachment editor, attachment 4 Tags: media categories, media, category, categories, attachment categories, taxonomy, category metabox, metabox, admin, media library, media editor, attachment editor, attachment, images, gallery shortcode, gallery, shortcode, gallery category 5 5 Requires at least: 3.0 6 6 Tested up to: 3.3.1 7 Stable tag: trunk7 Stable tag: 1.2 8 8 9 Allows users to assign categories to items in their Media Library with a clean and simplified, filterable version of the standard category meta box 9 Easily assign categories to media with a clean, simple, and searchable category meta box. Then use the gallery shortcode to display category galleries 10 10 11 11 == Description == 12 12 13 Allows users to assign categories to items in their Media Library with a clean and simplified, filterable version of the standard category meta box.14 The filter allows you to narrow your search for category as you type - this filteris not native to WordPress but is instead borrowed from Jason Corradino's15 [Searchable Categories](http://wordpress.org/extend/plugins/searchable-categories/) plugin. If you would like to enable this feature for your posts and pages13 Allows users to assign categories to items in their Media Library with a clean and simplified, searchable version of the standard category meta box. 14 The "Search Categories" field allows you to narrow your search for a category as you type - this functionality is not native to WordPress but is instead borrowed from Jason Corradino's 15 [Searchable Categories](http://wordpress.org/extend/plugins/searchable-categories/) plugin. If you would like to enable this feature for your posts 16 16 [download his plugin here](http://wordpress.org/extend/plugins/searchable-categories/) 17 18 NEW! Since version 1.2 this plugin extends the native [gallery] shortcode of WordPress so that it has a 'category' parameter. See the "Shortcode Usage" under "Other Notes" for more details. 19 20 21 == Shortcode Usage == 22 23 This plugin takes advantage of the existing `[gallery]` shortcode for showing images by adding the `'category'` parameter. 24 The value passed to the `'category'` parameter can be either the `category` `slug`, or the `term_id`. 25 26 `[gallery category="my-category-slug"] 27 OR 28 [gallery category="12"]` 29 30 Its important to note that when passing the `'category'` parameter, the `[gallery]` shortcode will by default **ignore the current post 31 and simply try to include all images from the category**. The syntax above will retrieve any images that are assigned 32 to `'my-category-slug'` a.k.a term id `#12`, regardless of whether or not those images are attached to the current post. 33 34 To query within a post (even the current post), you'll need to explicitly add the post id as such... 35 36 `[gallery category="my-category-slug" id="43"]` 37 38 This shortcode will retreive any images attached to post `#43` that are categorized as `'my-slug-category'`. 39 40 Aside from this behavior, the [gallery] shortcode should behave exactly as it does by default with the built-in shortcode. 41 The `id` parameter will behave as normal when the `category` parameter is not invoked. 42 For more information on using the built-in [gallery shortcode checkout the codex page](http://codex.wordpress.org/Gallery_Shortcode). 17 43 18 44 == Related Plugins == 19 45 20 As stated in the description, the filtering ability in this plugin is taken from Jason Corradino's46 As stated in the description, the search functionality in this plugin is taken from Jason Corradino's 21 47 [Searchable Categories](http://wordpress.org/extend/plugins/searchable-categories/) plugin. While I do 22 not employ the plugin direct ory, the javascript used for filtering is in fact derived with consent from48 not employ the plugin directly, the javascript used for filtering is in fact derived with consent from 23 49 that plugin. To enable this feature on all you category metabox, the 24 50 [Searchable Categories](http://wordpress.org/extend/plugins/searchable-categories/) plugin 25 51 26 I'd like to point out that I drew some inspiration from the ['WOS Media Categories'](http://suburbia.org.uk/page/projects.html#wos_media_categories) plugin which27 is not generally easy to find since its not in the plugin directory. However [WOS Media Categories](http://suburbia.org.uk/page/projects.html#wos_media_categories)28 was missing the clean simple to use hierarchical category interface that we are used to in29 WordPress. A couple of my projects were dependant that plugin, but as the scale of the project30 increased and the number of categories grew exponentially, the disorganized grid of checkboxes31 were no longer a viable option.32 33 52 = TL;DR = 34 Checkout these related plugins from which I borrowed code and drew inspiration. 53 Checkout this great plugin for Searchable Categories by Jason Corradino, whose javascript I use in this plugin. 54 I believe this very simple functionality should be a part of the standard categories metabox in core. 35 55 36 56 * [Searchable Categories](http://wordpress.org/extend/plugins/searchable-categories/) by Jason Corradino 37 * [WOS Media Categories](http://suburbia.org.uk/page/projects.html#wos_media_categories) by Rick Curran38 39 WOS is not as relevant since this plugin supplants that one, but the Searchable Categories plugin is a40 great simple plugin which adds very useful functionality that I think should be included in WordPress Core.41 57 42 58 == Screenshots == 43 59 44 1. This plugin will include clean, simple to use, filterable categories to your Media Editor page.60 1. This plugin will include clean, simple to use, searchable categories to your Media Editor page. 45 61 2. Use categories in much the same way you use them on your posts and pages. 46 62 3. Filter categories as you type, very useful if you have a lot of categories to look through (thanks to Jason Corradino's "Searchable Categories" plugin) … … 54 70 == Changelog == 55 71 72 = 1.2 = 73 * Added 'category' parameter to [gallery] shortcode. 74 * Modified the Searchable Categories script to make the search field case insensitive. 75 * Fixed styling problem on Media Library modal windows - the filter and styling were not working. 76 77 = 1.1 = 78 * Changed jQuery to use .live() rather than .on() for compatability with WordPress earlier than 3.3 - jQuery 1.7 was only added in v3.3 79 * Removed superfluous file which was accidentally included from a different plugin of mine. Would cause fatal errors if both plugins were turned on at the same time. 80 56 81 = 1.0 = 57 82 * Initial commit. 58 83 59 = 1.1 =60 * Changed jQuery to use .live() rather than .on() for compatability with WordPress which only added jQuery 1.7 in v3.361 * Removed superfilous file which was accidentally included from a different plugin of mine. Would fatal errors if both plugins were turned on at the same time.62 63 84 == Upgrade Notice == 64 * For compatibility with WordPress versions earlier than 3.3, upgrade to version 1.1 of this plugin .85 * For compatibility with WordPress versions earlier than 3.3, upgrade to version 1.1 of this plugin or later. -
media-categories-2/trunk/media-categories-script.js
r495667 r538292 1 2 3 1 4 jQuery(document).ready(function($){ 2 5 … … 16 19 }); 17 20 18 19 21 form_fields.find("tr.category > td.field > input.text").val(slug_list); 20 22 }) 21 23 22 23 24 $.extend($.expr[":"], { 25 "icontains": function(elem, i, match, array) { 26 return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; 27 } 28 }); 24 29 /** 25 30 * The following javascript is borrowed from Jason Corradino's 'Searchable Categories' plugin. … … 30 35 */ 31 36 32 jQuery('#catsearch').keyup(function() {33 var val = jQuery('#catsearch').val(), lis = jQuery("#categorychecklist li");37 $('#catsearch').keyup(function() { 38 var val = $('#catsearch').val(), lis = $("#categorychecklist li"); 34 39 35 40 lis.hide(); 36 // find li labels's containing term, then back to parent li 37 var containingLabels = jQuery("#categorychecklist label:contains('" + val + "')"); 41 42 // find li labels's containing term, then back to parent li 43 var containingLabels = $("#categorychecklist label:icontains('" + val + "')"); 38 44 containingLabels.closest('li').find('li').andSelf().show(); 39 45 containingLabels.parents('#categorychecklist li').show(); -
media-categories-2/trunk/media-categories.php
r519154 r538292 3 3 Plugin Name: Media Categories 4 4 Plugin URI: http://wordpress.org/extend/plugins/media-categories-2 5 Description: Allows users to assign categories to items in their Media Library with a clean and simplified, filterable version of the standard category metabox6 Version: 1. 15 Description: Allows users to assign categories to media with a clean and simplified, filterable category meta box and use shortcodes to display category galleries 6 Version: 1.2 7 7 Author: Eddie Moya 8 8 Author URL: http://eddiemoya.com … … 12 12 13 13 /** 14 * Start your engines. 15 * 14 16 * @author Eddie Moya 15 *16 * Start your engines.17 17 */ 18 18 function init() { 19 add_action('admin_init', array(__CLASS__, 'register_media_categories')); 19 add_action('init', array(__CLASS__, 'register_media_categories')); 20 add_action('init', array(__CLASS__, 'custom_gallery_shortcode')); 20 21 add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueue_media_categories_scripts')); 21 add_action('admin_ print_styles-media.php', array(__CLASS__, 'enqueue_media_categories_styles') );22 add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueue_media_categories_styles') ); 22 23 add_filter('attachment_fields_to_edit', array(__CLASS__, 'add_media_categories_metabox'), null, 2); 23 } 24 25 } 26 24 27 25 28 function enqueue_media_categories_scripts() { … … 28 31 wp_register_script('media_categories_metabox_script', WP_PLUGIN_URL . '/media-categories-2/media-categories-script.js'); 29 32 wp_enqueue_script('media_categories_metabox_script'); 30 31 33 } 32 34 } … … 38 40 wp_enqueue_style( 'media_categories_metabox_style'); 39 41 } 40 41 42 } 42 43 … … 84 85 function media_categories_meta_box($post, $box) { 85 86 86 require_once( WP_PLUGIN_DIR . '/media-categories-2/attachment-walker-category-checklist-class.php');87 require_once(plugin_dir_path(__FILE__) . 'attachment-walker-category-checklist-class.php'); 87 88 88 89 $defaults = array('taxonomy' => 'category'); … … 95 96 ?> 96 97 <div> 97 <label class='category-filter' for="category-filter"> FilterCategories:</label>98 <label class='category-filter' for="category-filter">Search Categories:</label> 98 99 <input id='catsearch' name="category-filter" type='text' /></div> 99 100 <div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv"> … … 149 150 } 150 151 152 function custom_gallery_shortcode(){ 153 remove_shortcode('gallery'); 154 add_shortcode('gallery', array(__CLASS__,'gallery_shortcode')); 155 } 156 157 /** 158 * The Gallery shortcode with category parameter. 159 * 160 * This implements the functionality of the Gallery Shortcode for displaying 161 * WordPress images on a post. 162 * 163 * Almost Identical to the gallery_shortcode() function in /wp-includes/media.php 164 * but adds a category parameter to the shortcode. 165 * 166 * @since 1.2 167 * @since WordPress 2.6.0 168 * 169 * @param array $attr Attributes of the shortcode. 170 * @return string HTML content to display gallery. 171 */ 172 function gallery_shortcode($attr) { 173 global $post; 174 175 static $instance = 0; 176 $instance++; 177 178 // Allow plugins/themes to override the default gallery template. 179 $output = apply_filters('post_gallery', '', $attr); 180 if ( $output != '' ) 181 return $output; 182 183 // We're trusting author input, so let's at least make sure it looks like a valid orderby statement 184 if ( isset( $attr['orderby'] ) ) { 185 $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); 186 if ( !$attr['orderby'] ) 187 unset( $attr['orderby'] ); 188 } 189 190 extract(shortcode_atts(array( 191 'order' => 'ASC', 192 'orderby' => 'menu_order ID', 193 'id' => $post->ID, 194 'itemtag' => 'dl', 195 'icontag' => 'dt', 196 'captiontag' => 'dd', 197 'columns' => 3, 198 'size' => 'thumbnail', 199 'include' => '', 200 'exclude' => '', 201 'category' => '' 202 ), $attr)); 203 204 $id = intval($id); 205 if ( 'RAND' == $order ) 206 $orderby = 'none'; 207 208 if( !empty($category) ){ 209 if(!is_numeric($category)) 210 $category = get_category_by_slug($category)->term_id; 211 212 if(!isset($attr['id'])) 213 $id = ''; 214 } 215 216 if ( !empty($include) ) { 217 $include = preg_replace( '/[^0-9,]+/', '', $include ); 218 $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'category' => $category) ); 219 220 $attachments = array(); 221 foreach ( $_attachments as $key => $val ) { 222 $attachments[$val->ID] = $_attachments[$key]; 223 } 224 } elseif ( !empty($exclude) ) { 225 $exclude = preg_replace( '/[^0-9,]+/', '', $exclude ); 226 $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'category' => $category) ); 227 } else { 228 $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'category' => $category) ); 229 } 230 231 if ( empty($attachments) ) 232 return ''; 233 234 if ( is_feed() ) { 235 $output = "\n"; 236 foreach ( $attachments as $att_id => $attachment ) 237 $output .= wp_get_attachment_link($att_id, $size, true) . "\n"; 238 return $output; 239 } 240 241 $itemtag = tag_escape($itemtag); 242 $captiontag = tag_escape($captiontag); 243 $columns = intval($columns); 244 $itemwidth = $columns > 0 ? floor(100/$columns) : 100; 245 $float = is_rtl() ? 'right' : 'left'; 246 247 $selector = "gallery-{$instance}"; 248 249 $gallery_style = $gallery_div = ''; 250 if ( apply_filters( 'use_default_gallery_style', true ) ) 251 $gallery_style = " 252 <style type='text/css'> 253 #{$selector} { 254 margin: auto; 255 } 256 #{$selector} .gallery-item { 257 float: {$float}; 258 margin-top: 10px; 259 text-align: center; 260 width: {$itemwidth}%; 261 } 262 #{$selector} img { 263 border: 2px solid #cfcfcf; 264 } 265 #{$selector} .gallery-caption { 266 margin-left: 0; 267 } 268 </style> 269 <!-- see gallery_shortcode() in wp-includes/media.php -->"; 270 $size_class = sanitize_html_class( $size ); 271 $gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>"; 272 $output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div ); 273 274 $i = 0; 275 foreach ( $attachments as $id => $attachment ) { 276 $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false); 277 278 $output .= "<{$itemtag} class='gallery-item'>"; 279 $output .= " 280 <{$icontag} class='gallery-icon'> 281 $link 282 </{$icontag}>"; 283 if ( $captiontag && trim($attachment->post_excerpt) ) { 284 $output .= " 285 <{$captiontag} class='wp-caption-text gallery-caption'> 286 " . wptexturize($attachment->post_excerpt) . " 287 </{$captiontag}>"; 288 } 289 $output .= "</{$itemtag}>"; 290 if ( $columns > 0 && ++$i % $columns == 0 ) 291 $output .= '<br style="clear: both" />'; 292 } 293 294 $output .= " 295 <br style='clear: both;' /> 296 </div>\n"; 297 298 return $output; 299 } 151 300 } 152 301 -
media-categories-2/trunk/readme.txt
r495667 r538292 2 2 Contributors: eddiemoya 3 3 Donate link: http://eddiemoya.com 4 Tags: media categories, media, category, categories, attachment categories, taxonomy, category metabox, metabox, admin, media library, media editor, attachment editor, attachment 4 Tags: media categories, media, category, categories, attachment categories, taxonomy, category metabox, metabox, admin, media library, media editor, attachment editor, attachment, images, gallery shortcode, gallery, shortcode, gallery category 5 5 Requires at least: 3.0 6 6 Tested up to: 3.3.1 7 Stable tag: trunk7 Stable tag: 1.2 8 8 9 Allows users to assign categories to items in their Media Library with a clean and simplified, filterable version of the standard category meta box 9 Easily assign categories to media with a clean, simple, and searchable category meta box. Then use the gallery shortcode to display category galleries 10 10 11 11 == Description == 12 12 13 Allows users to assign categories to items in their Media Library with a clean and simplified, filterable version of the standard category meta box.14 The filter allows you to narrow your search for category as you type - this filteris not native to WordPress but is instead borrowed from Jason Corradino's15 [Searchable Categories](http://wordpress.org/extend/plugins/searchable-categories/) plugin. If you would like to enable this feature for your posts and pages13 Allows users to assign categories to items in their Media Library with a clean and simplified, searchable version of the standard category meta box. 14 The "Search Categories" field allows you to narrow your search for a category as you type - this functionality is not native to WordPress but is instead borrowed from Jason Corradino's 15 [Searchable Categories](http://wordpress.org/extend/plugins/searchable-categories/) plugin. If you would like to enable this feature for your posts 16 16 [download his plugin here](http://wordpress.org/extend/plugins/searchable-categories/) 17 18 NEW! Since version 1.2 this plugin extends the native [gallery] shortcode of WordPress so that it has a 'category' parameter. See the "Shortcode Usage" under "Other Notes" for more details. 19 20 21 == Shortcode Usage == 22 23 This plugin takes advantage of the existing `[gallery]` shortcode for showing images by adding the `'category'` parameter. 24 The value passed to the `'category'` parameter can be either the `category` `slug`, or the `term_id`. 25 26 `[gallery category="my-category-slug"] 27 OR 28 [gallery category="12"]` 29 30 Its important to note that when passing the `'category'` parameter, the `[gallery]` shortcode will by default **ignore the current post 31 and simply try to include all images from the category**. The syntax above will retrieve any images that are assigned 32 to `'my-category-slug'` a.k.a term id `#12`, regardless of whether or not those images are attached to the current post. 33 34 To query within a post (even the current post), you'll need to explicitly add the post id as such... 35 36 `[gallery category="my-category-slug" id="43"]` 37 38 This shortcode will retrieve any images attached to post `#43` that are categorized as `'my-slug-category'`. 39 40 Aside from this behavior, the [gallery] shortcode should behave exactly as it does by default with the built-in shortcode. 41 The `id` parameter will behave as normal when the `category` parameter is not invoked. 42 For more information on using the built-in [gallery shortcode checkout the codex page](http://codex.wordpress.org/Gallery_Shortcode). 17 43 18 44 == Related Plugins == 19 45 20 As stated in the description, the filtering ability in this plugin is taken from Jason Corradino's46 As stated in the description, the search functionality in this plugin is taken from Jason Corradino's 21 47 [Searchable Categories](http://wordpress.org/extend/plugins/searchable-categories/) plugin. While I do 22 not employ the plugin direct ory, the javascript used for filtering is in fact derived with consent from48 not employ the plugin directly, the javascript used for filtering is in fact derived with consent from 23 49 that plugin. To enable this feature on all you category metabox, the 24 50 [Searchable Categories](http://wordpress.org/extend/plugins/searchable-categories/) plugin 25 51 26 I'd like to point out that I drew some inspiration from the ['WOS Media Categories'](http://suburbia.org.uk/page/projects.html#wos_media_categories) plugin which27 is not generally easy to find since its not in the plugin directory. However [WOS Media Categories](http://suburbia.org.uk/page/projects.html#wos_media_categories)28 was missing the clean simple to use hierarchical category interface that we are used to in29 WordPress. A couple of my projects were dependant that plugin, but as the scale of the project30 increased and the number of categories grew exponentially, the disorganized grid of checkboxes31 were no longer a viable option.32 33 52 = TL;DR = 34 Checkout these related plugins from which I borrowed code and drew inspiration. 53 Checkout this great plugin for Searchable Categories by Jason Corradino, whose javascript I use in this plugin. 54 I believe this very simple functionality should be a part of the standard categories metabox in core. 35 55 36 56 * [Searchable Categories](http://wordpress.org/extend/plugins/searchable-categories/) by Jason Corradino 37 * [WOS Media Categories](http://suburbia.org.uk/page/projects.html#wos_media_categories) by Rick Curran38 39 WOS is not as relevant since this plugin supplants that one, but the Searchable Categories plugin is a40 great simple plugin which adds very useful functionality that I think should be included in WordPress Core.41 57 42 58 == Screenshots == 43 59 44 1. This plugin will include clean, simple to use, filterable categories to your Media Editor page.60 1. This plugin will include clean, simple to use, searchable categories to your Media Editor page. 45 61 2. Use categories in much the same way you use them on your posts and pages. 46 62 3. Filter categories as you type, very useful if you have a lot of categories to look through (thanks to Jason Corradino's "Searchable Categories" plugin) … … 54 70 == Changelog == 55 71 72 = 1.2 = 73 * Added 'category' parameter to [gallery] shortcode. 74 * Modified the Searchable Categories script to make the search field case insensitive. 75 * Fixed styling problem on Media Library modal windows - the filter and styling were not working. 76 77 = 1.1 = 78 * Changed jQuery to use .live() rather than .on() for compatability with WordPress earlier than 3.3 - jQuery 1.7 was only added in v3.3 79 * Removed superfluous file which was accidentally included from a different plugin of mine. Would cause fatal errors if both plugins were turned on at the same time. 80 56 81 = 1.0 = 57 82 * Initial commit. 58 83 59 = 1.1 =60 * Changed jQuery to use .live() rather than .on() for compatability with WordPress which only added jQuery 1.7 in v3.361 * Removed superfilous file which was accidentally included from a different plugin of mine. Would fatal errors if both plugins were turned on at the same time.62 63 84 == Upgrade Notice == 64 * For compatibility with WordPress versions earlier than 3.3, upgrade to version 1.1 of this plugin .85 * For compatibility with WordPress versions earlier than 3.3, upgrade to version 1.1 of this plugin or later.
Note: See TracChangeset
for help on using the changeset viewer.