Media Library Categories - Version 1.4.7

Version Description

  • New images are now added to the default category (if a default category exists). I most cases the default category is "Uncategorized".
Download this release

Release Info

Developer jeffrey-wp
Plugin Icon 128x128 Media Library Categories
Version 1.4.7
Comparing to
See all releases

Code changes from version 1.4.6 to 1.4.7

Files changed (2) hide show
  1. index.php +25 -2
  2. readme.txt +4 -1
index.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Media Library Categories
4
  * Plugin URI: http://wordpress.org/plugins/wp-media-library-categories/
5
  * Description: Adds the ability to use categories in the media library.
6
- * Version: 1.4.6
7
  * Author: Jeffrey-WP
8
  * Author URI: http://codecanyon.net/user/jeffrey-wp/?ref=jeffrey-wp
9
  */
@@ -30,6 +30,28 @@ add_action( 'init', 'wpmediacategory_init' );
30
  // load code that is only needed in the admin section
31
  if( is_admin() ) {
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  /** Custom walker for wp_dropdown_categories, based on https://gist.github.com/stephenh1988/2902509 */
34
  class wpmediacategory_walker_category_filter extends Walker_CategoryDropdown{
35
 
@@ -228,7 +250,8 @@ if( is_admin() ) {
228
  $taxonomy = apply_filters( 'wpmediacategory_taxonomy', $taxonomy );
229
  return array_merge(
230
  array(
231
- 'settings' => '<a href="' . get_bloginfo( 'wpurl' ) . '/wp-admin/edit-tags.php?taxonomy=' . $taxonomy . '&amp;post_type=attachment">' . __('Categories') . '</a>'
 
232
  ),
233
  $links
234
  );
3
  * Plugin Name: Media Library Categories
4
  * Plugin URI: http://wordpress.org/plugins/wp-media-library-categories/
5
  * Description: Adds the ability to use categories in the media library.
6
+ * Version: 1.4.7
7
  * Author: Jeffrey-WP
8
  * Author URI: http://codecanyon.net/user/jeffrey-wp/?ref=jeffrey-wp
9
  */
30
  // load code that is only needed in the admin section
31
  if( is_admin() ) {
32
 
33
+ /** Handle default category of attachments without category */
34
+ function wpmediacategory_set_attachment_category( $post_ID ) {
35
+
36
+ // default taxonomy
37
+ $taxonomy = 'category';
38
+ // add filter to change the default taxonomy
39
+ $taxonomy = apply_filters( 'wpmediacategory_taxonomy', $taxonomy );
40
+
41
+ // if attachment already have categories, stop here
42
+ if( wp_get_object_terms( $post_ID, $taxonomy ) )
43
+ return;
44
+
45
+ // no, then get the default one
46
+ $post_category = array( get_option('default_category') );
47
+
48
+ // then set category if default category is set on writting page
49
+ if( $post_category )
50
+ wp_set_post_categories( $post_ID, $post_category );
51
+ }
52
+ add_action( 'add_attachment', 'wpmediacategory_set_attachment_category' );
53
+ add_action( 'edit_attachment', 'wpmediacategory_set_attachment_category' );
54
+
55
  /** Custom walker for wp_dropdown_categories, based on https://gist.github.com/stephenh1988/2902509 */
56
  class wpmediacategory_walker_category_filter extends Walker_CategoryDropdown{
57
 
250
  $taxonomy = apply_filters( 'wpmediacategory_taxonomy', $taxonomy );
251
  return array_merge(
252
  array(
253
+ 'settings' => '<a href="' . get_bloginfo( 'wpurl' ) . '/wp-admin/edit-tags.php?taxonomy=' . $taxonomy . '&amp;post_type=attachment">' . __('Categories') . '</a>',
254
+ 'premium' => '<a href="http://codecanyon.net/item/media-library-categories-premium/6691290?ref=jeffrey-wp">' . __('Get Premium Version') . '</a>'
255
  ),
256
  $links
257
  );
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: category, categories, media, library, medialibrary
5
  Requires at least: 3.1
6
  Tested up to: 3.8.1
7
- Stable tag: 1.4.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -68,6 +68,9 @@ add_filter( 'wpmediacategory_taxonomy', function(){ return 'category_media'; },
68
 
69
  == Changelog ==
70
 
 
 
 
71
  = 1.4.6 =
72
  * fixed bug where in some rare cases the filter by category didn't work
73
 
4
  Tags: category, categories, media, library, medialibrary
5
  Requires at least: 3.1
6
  Tested up to: 3.8.1
7
+ Stable tag: 1.4.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
68
 
69
  == Changelog ==
70
 
71
+ = 1.4.7 =
72
+ * [New images are now added to the default category (if a default category exists). I most cases the default category is "Uncategorized".](http://wordpress.org/support/topic/new-images-arent-automatically-in-uncategorized)
73
+
74
  = 1.4.6 =
75
  * fixed bug where in some rare cases the filter by category didn't work
76