Categories Images - Version 2.1

Version Description

  • fix a bug in languages
  • fix a bug in quick edit category or taxonomy
Download this release

Release Info

Developer elzahlan
Plugin Icon 128x128 Categories Images
Version 2.1
Comparing to
See all releases

Version 2.1

categories-images.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Categories Images
4
+ Plugin URI: http://zahlan.net/blog/2012/06/categories-images/
5
+ Description: Categories Images Plugin allow you to add an image to category or any custom term.
6
+ Author: Muhammad Said El Zahlan
7
+ Version: 2.1
8
+ Author URI: http://zahlan.net/
9
+ */
10
+ ?>
11
+ <?php
12
+ if ( ! defined( 'Z_PLUGIN_URL' ) )
13
+ define( 'Z_PLUGIN_URL', untrailingslashit( plugins_url( '', __FILE__ ) ) );
14
+
15
+ define( 'Z_IMAGE_PLACEHOLDER', Z_PLUGIN_URL . "/images/placeholder.png");
16
+
17
+ // l10n
18
+ load_plugin_textdomain( 'zci', false, 'categories-images/languages' );
19
+
20
+ add_action('admin_init', 'z_init');
21
+ function z_init() {
22
+ $z_taxonomies = get_taxonomies();
23
+ if (is_array($z_taxonomies)) {
24
+ foreach ($z_taxonomies as $z_taxonomy ) {
25
+ add_action($z_taxonomy.'_add_form_fields', 'z_add_texonomy_field');
26
+ add_action($z_taxonomy.'_edit_form_fields', 'z_edit_texonomy_field');
27
+ add_filter( 'manage_edit-' . $z_taxonomy . '_columns', 'z_taxonomy_columns' );
28
+ add_filter( 'manage_' . $z_taxonomy . '_custom_column', 'z_taxonomy_column', 10, 3 );
29
+ }
30
+ }
31
+ }
32
+
33
+ // style the image in category list
34
+ if ( strpos( $_SERVER['SCRIPT_NAME'], 'edit-tags.php' ) > 0 ) {
35
+ add_action( 'admin_head', 'z_add_style' );
36
+ add_action('quick_edit_custom_box', 'z_quick_edit_custom_box', 10, 3);
37
+ }
38
+
39
+ function z_add_style() {
40
+ echo '<style type="text/css" media="screen">
41
+ th.column-thumb {width:60px;}
42
+ .form-field img.taxonomy-image {border:1px solid #eee;max-width:300px;max-height:300px;}
43
+ .inline-edit-row fieldset .thumb label span.title {width:48px;height:48px;border:1px solid #eee;display:inline-block;}
44
+ .column-thumb span {width:48px;height:48px;border:1px solid #eee;display:inline-block;}
45
+ .inline-edit-row fieldset .thumb img,.column-thumb img {width:48px;height:48px;}
46
+ </style>';
47
+ }
48
+
49
+ // add image field in add form
50
+ function z_add_texonomy_field() {
51
+ wp_enqueue_style('thickbox');
52
+ wp_enqueue_script('thickbox');
53
+ echo '<div class="form-field">
54
+ <label for="taxonomy_image">' . __('Image', 'zci') . '</label>
55
+ <input type="text" name="taxonomy_image" id="taxonomy_image" value="" />
56
+ <br/>
57
+ <button class="upload_image_button button">' . __('Upload/Add image', 'zci') . '</button>
58
+ </div>'.z_script();
59
+ }
60
+
61
+ // add image field in edit form
62
+ function z_edit_texonomy_field($taxonomy) {
63
+ wp_enqueue_style('thickbox');
64
+ wp_enqueue_script('thickbox');
65
+ if (z_taxonomy_image_url( $taxonomy->term_id ) == Z_IMAGE_PLACEHOLDER)
66
+ $image_text = "";
67
+ else
68
+ $image_text = z_taxonomy_image_url( $taxonomy->term_id );
69
+ echo '<tr class="form-field">
70
+ <th scope="row" valign="top"><label for="taxonomy_image">' . __('Image', 'zci') . '</label></th>
71
+ <td><img class="taxonomy-image" src="' . z_taxonomy_image_url( $taxonomy->term_id ) . '"/><br/><input type="text" name="taxonomy_image" id="taxonomy_image" value="'.$image_text.'" /><br />
72
+ <button class="upload_image_button button">' . __('Upload/Add image', 'zci') . '</button>
73
+ <button class="remove_image_button button">' . __('Remove image', 'zci') . '</button>
74
+ </td>
75
+ </tr>'.z_script();
76
+ }
77
+ // upload using wordpress upload
78
+ function z_script() {
79
+ return '<script type="text/javascript">
80
+ jQuery(document).ready(function() {
81
+ jQuery(".upload_image_button").click(function() {
82
+ upload_button = jQuery(this);
83
+ tb_show("", "media-upload.php?type=image&amp;TB_iframe=true");
84
+ return false;
85
+ });
86
+ jQuery(".remove_image_button").click(function() {
87
+ jQuery("#taxonomy_image").val("");
88
+ jQuery(this).parent().siblings(".title").children("img").attr("src","' . Z_IMAGE_PLACEHOLDER . '");
89
+ jQuery(".inline-edit-col :input[name=\'taxonomy_image\']").val("");
90
+ return false;
91
+ });
92
+ window.send_to_editor = function(html) {
93
+ imgurl = jQuery("img",html).attr("src");
94
+ if (upload_button.parent().prev().children().hasClass("tax_list")) {
95
+ upload_button.parent().prev().children().val(imgurl);
96
+ upload_button.parent().prev().prev().children().attr("src", imgurl);
97
+ }
98
+ else
99
+ jQuery("#taxonomy_image").val(imgurl);
100
+ tb_remove();
101
+ }
102
+ jQuery(".editinline").live("click", function(){
103
+ var tax_id = jQuery(this).parents("tr").attr("id").substr(4);
104
+ var thumb = jQuery("#tag-"+tax_id+" .thumb img").attr("src");
105
+ if (thumb != "' . Z_IMAGE_PLACEHOLDER . '") {
106
+ jQuery(".inline-edit-col :input[name=\'taxonomy_image\']").val(thumb);
107
+ } else {
108
+ jQuery(".inline-edit-col :input[name=\'taxonomy_image\']").val("");
109
+ }
110
+ jQuery(".inline-edit-col .title img").attr("src",thumb);
111
+ return false;
112
+ });
113
+ });
114
+ </script>';
115
+ }
116
+
117
+ // save our taxonomy image while edit or save term
118
+ add_action('edit_term','z_save_taxonomy_image');
119
+ add_action('create_term','z_save_taxonomy_image');
120
+ function z_save_taxonomy_image($term_id) {
121
+ if(isset($_POST['taxonomy_image']))
122
+ update_option('z_taxonomy_image'.$term_id, $_POST['taxonomy_image']);
123
+ }
124
+
125
+ // output taxonomy image url for the given term_id (NULL by default)
126
+ function z_taxonomy_image_url($term_id = NULL) {
127
+ if (!$term_id) {
128
+ if (is_category())
129
+ $term_id = get_query_var('cat');
130
+ elseif (is_tax()) {
131
+ $current_term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
132
+ $term_id = $current_term->term_id;
133
+ }
134
+ }
135
+ $taxonomy_image_url = get_option('z_taxonomy_image'.$term_id);
136
+ return ($taxonomy_image_url != "") ? $taxonomy_image_url : Z_IMAGE_PLACEHOLDER ;
137
+ }
138
+
139
+ function z_quick_edit_custom_box($column_name, $screen, $name) {
140
+ if ($column_name == 'thumb')
141
+ echo '<fieldset>
142
+ <div class="thumb inline-edit-col">
143
+ <label>
144
+ <span class="title"><img src="" alt="Thumbnail"/></span>
145
+ <span class="input-text-wrap"><input type="text" name="taxonomy_image" value="" class="tax_list" /></span>
146
+ <span class="input-text-wrap">
147
+ <button class="upload_image_button button">' . __('Upload/Add image', 'zci') . '</button>
148
+ <button class="remove_image_button button">' . __('Remove image', 'zci') . '</button>
149
+ </span>
150
+ </label>
151
+ </div>
152
+ </fieldset>';
153
+ }
154
+
155
+ /**
156
+ * Thumbnail column added to category admin.
157
+ *
158
+ * @access public
159
+ * @param mixed $columns
160
+ * @return void
161
+ */
162
+ function z_taxonomy_columns( $columns ) {
163
+ $new_columns = array();
164
+ $new_columns['cb'] = $columns['cb'];
165
+ $new_columns['thumb'] = __('Image', 'zci');
166
+
167
+ unset( $columns['cb'] );
168
+
169
+ return array_merge( $new_columns, $columns );
170
+ }
171
+
172
+ /**
173
+ * Thumbnail column value added to category admin.
174
+ *
175
+ * @access public
176
+ * @param mixed $columns
177
+ * @param mixed $column
178
+ * @param mixed $id
179
+ * @return void
180
+ */
181
+ function z_taxonomy_column( $columns, $column, $id ) {
182
+ if ( $column == 'thumb' )
183
+ $columns = '<span><img src="' . z_taxonomy_image_url($id) . '" alt="' . __('Thumbnail', 'zci') . '" class="wp-post-image" /></span>';
184
+
185
+ return $columns;
186
+ }
187
+
188
+ // change 'insert into post' to 'use this image'
189
+ add_filter("attribute_escape", "z_change_insert_button_text", 10, 2);
190
+ function z_change_insert_button_text($safe_text, $text) {
191
+ return str_replace("Insert into Post", "Use this image", $text);
192
+ }
193
+
194
+ ?>
images/placeholder.png ADDED
Binary file
languages/zci-ar.mo ADDED
Binary file
languages/zci-ar.po ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Categories Images\n"
4
+ "POT-Creation-Date: 2013-01-10 16:45+0800\n"
5
+ "PO-Revision-Date: 2013-01-25 09:23+0200\n"
6
+ "Last-Translator: Muhammad Zahlan <elzahlan@gmail.com>\n"
7
+ "Language-Team: Muhammad Zahlan <elzahlan@gmail.com>\n"
8
+ "Language: ar\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.5.4\n"
13
+ "X-Poedit-KeywordsList: _;__;_e\n"
14
+ "X-Poedit-Basepath: ../\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-SearchPath-0: .\n"
17
+
18
+ #: categories-images.php:52 categories-images.php:68 categories-images.php:164
19
+ msgid "Image"
20
+ msgstr "صورة"
21
+
22
+ #: categories-images.php:55 categories-images.php:70 categories-images.php:146
23
+ msgid "Upload/Add image"
24
+ msgstr "رفع/اضافة صورة"
25
+
26
+ #: categories-images.php:71 categories-images.php:147
27
+ msgid "Remove image"
28
+ msgstr "حذف الصورة"
29
+
30
+ #: categories-images.php:182
31
+ msgid "Thumbnail"
32
+ msgstr "صورة مصغرة"
languages/zci-zh_CN.mo ADDED
Binary file
languages/zci-zh_CN.po ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Categories Images\n"
4
+ "POT-Creation-Date: 2013-01-10 16:45+0800\n"
5
+ "PO-Revision-Date: 2013-01-10 16:45+0800\n"
6
+ "Last-Translator: Joe <tkjune@gmail.com>\n"
7
+ "Language-Team: Joe Tse <tkjune@gmail.com>\n"
8
+ "Language: zh_CN\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.5.4\n"
13
+ "X-Poedit-KeywordsList: _;__;_e\n"
14
+ "X-Poedit-Basepath: ../\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-SearchPath-0: .\n"
17
+
18
+ #: categories-images.php:52 categories-images.php:68 categories-images.php:164
19
+ msgid "Image"
20
+ msgstr "图片"
21
+
22
+ #: categories-images.php:55 categories-images.php:70 categories-images.php:146
23
+ msgid "Upload/Add image"
24
+ msgstr "上传/添加图片"
25
+
26
+ #: categories-images.php:71 categories-images.php:147
27
+ msgid "Remove image"
28
+ msgstr "删除图片"
29
+
30
+ #: categories-images.php:182
31
+ msgid "Thumbnail"
32
+ msgstr "缩略图"
readme.txt ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Categories Images ===
2
+ Contributors: elzahlan
3
+ Tags: Category Image, Category Images, Categories Images, taxonomy image, taxonomy images, taxonomies images, category icon, categories icons, category logo, categories logos, admin, wp-admin, category image plugin, categories images plugin
4
+ Requires at least: 2.8
5
+ Tested up to: 3.5
6
+ Stable tag: 2.1
7
+
8
+ The Categories Images Plugin allow you to add image with category or taxonomy.
9
+
10
+ == Description ==
11
+
12
+ The Categories Images Plugin allow you to add image with category or taxonomy.
13
+
14
+ Use `<?php if (function_exists('z_taxonomy_image_url')) echo z_taxonomy_image_url(); ?>` to get the url and put it in any img tag in (category or taxonomy) template.
15
+
16
+ = More documentation =
17
+
18
+ Go to [http://zahlan.net/blog/2012/06/categories-images/](http://zahlan.net/blog/2012/06/categories-images/)
19
+
20
+ == Installation ==
21
+
22
+ You can install Categories Images directly from the WordPress admin panel:
23
+
24
+ 1. Visit the Plugins > Add New and search for 'Categories Images'.
25
+ 2. Click to install.
26
+ 3. Once installed, activate and it is functional.
27
+
28
+ OR
29
+
30
+ Manual Installation:
31
+
32
+ 1. Download the plugin, then extract it.
33
+ 2. Upload `categories-images` extracted folder to the `/wp-content/plugins/` directory
34
+ 3. Activate the plugin through the 'Plugins' menu in WordPress
35
+
36
+ You're done! The Plugin ready to use, for more please check the plugin description.
37
+
38
+ = More documentation =
39
+
40
+ Go to [http://zahlan.net/blog/2012/06/categories-images/](http://zahlan.net/blog/2012/06/categories-images/)
41
+
42
+ == Frequently Asked Questions ==
43
+
44
+ Please check the documentation page:
45
+ [http://zahlan.net/blog/2012/06/categories-images/](http://zahlan.net/blog/2012/06/categories-images/)
46
+
47
+ == Screenshots ==
48
+
49
+ 1. image preview and new image field in add/edit category or taxonomy with upload button which allow you to select current or upload a new image.
50
+ 2. new image field with (upload/remove) buttons to allow you to edit category or taxonomy image in quick edit.
51
+ 2. when you click the upload button the wordpress upload box will popup, upload or select image then press use this image.
52
+
53
+ == Changelog ==
54
+
55
+ = 2.1 =
56
+ * fix a bug in languages
57
+ * fix a bug in quick edit category or taxonomy
58
+
59
+ = 2.0 =
60
+ * New screenshots.
61
+ * Added l10n support.
62
+ * Added Arabic and Chinese languages.
63
+ * Added new button for upload or select an image using wordpress media uploader.
64
+ * Added default image placeholder.
65
+ * Added thumbnail in categories or taxonomies list.
66
+ * Added image thumbnail, image text box, upload button and remove button in quick edit.
67
+
68
+ Thank so much to Joe Tse http://tkjune.com :)
69
+
70
+ = 1.2 =
71
+ Adding some screenshots
72
+
73
+ = 1.1 =
74
+ Fix javascript bug with wordpress 3.4
75
+
76
+ = 1.0 =
77
+ The First Release
screenshot-1.jpg ADDED
Binary file
screenshot-2.jpg ADDED
Binary file
screenshot-3.jpg ADDED
Binary file