Version Description
- bug fix in displaying placeholder image in wp-admin.
Download this release
Release Info
Developer | elzahlan |
Plugin | Categories Images |
Version | 2.2.2 |
Comparing to | |
See all releases |
Version 2.2.2
- categories-images.php +197 -0
- images/placeholder.png +0 -0
- languages/zci-ar.mo +0 -0
- languages/zci-ar.po +32 -0
- languages/zci-zh_CN.mo +0 -0
- languages/zci-zh_CN.po +32 -0
- readme.txt +86 -0
- screenshot-1.jpg +0 -0
- screenshot-2.jpg +0 -0
- screenshot-3.jpg +0 -0
categories-images.php
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.2.2
|
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 |
+
function z_add_style() {
|
34 |
+
echo '<style type="text/css" media="screen">
|
35 |
+
th.column-thumb {width:60px;}
|
36 |
+
.form-field img.taxonomy-image {border:1px solid #eee;max-width:300px;max-height:300px;}
|
37 |
+
.inline-edit-row fieldset .thumb label span.title {width:48px;height:48px;border:1px solid #eee;display:inline-block;}
|
38 |
+
.column-thumb span {width:48px;height:48px;border:1px solid #eee;display:inline-block;}
|
39 |
+
.inline-edit-row fieldset .thumb img,.column-thumb img {width:48px;height:48px;}
|
40 |
+
</style>';
|
41 |
+
}
|
42 |
+
|
43 |
+
// add image field in add form
|
44 |
+
function z_add_texonomy_field() {
|
45 |
+
wp_enqueue_style('thickbox');
|
46 |
+
wp_enqueue_script('thickbox');
|
47 |
+
echo '<div class="form-field">
|
48 |
+
<label for="taxonomy_image">' . __('Image', 'zci') . '</label>
|
49 |
+
<input type="text" name="taxonomy_image" id="taxonomy_image" value="" />
|
50 |
+
<br/>
|
51 |
+
<button class="upload_image_button button">' . __('Upload/Add image', 'zci') . '</button>
|
52 |
+
</div>'.z_script();
|
53 |
+
}
|
54 |
+
|
55 |
+
// add image field in edit form
|
56 |
+
function z_edit_texonomy_field($taxonomy) {
|
57 |
+
wp_enqueue_style('thickbox');
|
58 |
+
wp_enqueue_script('thickbox');
|
59 |
+
if (z_taxonomy_image_url( $taxonomy->term_id, TRUE ) == Z_IMAGE_PLACEHOLDER)
|
60 |
+
$image_text = "";
|
61 |
+
else
|
62 |
+
$image_text = z_taxonomy_image_url( $taxonomy->term_id, TRUE );
|
63 |
+
echo '<tr class="form-field">
|
64 |
+
<th scope="row" valign="top"><label for="taxonomy_image">' . __('Image', 'zci') . '</label></th>
|
65 |
+
<td><img class="taxonomy-image" src="' . z_taxonomy_image_url( $taxonomy->term_id, TRUE ) . '"/><br/><input type="text" name="taxonomy_image" id="taxonomy_image" value="'.$image_text.'" /><br />
|
66 |
+
<button class="upload_image_button button">' . __('Upload/Add image', 'zci') . '</button>
|
67 |
+
<button class="remove_image_button button">' . __('Remove image', 'zci') . '</button>
|
68 |
+
</td>
|
69 |
+
</tr>'.z_script();
|
70 |
+
}
|
71 |
+
// upload using wordpress upload
|
72 |
+
function z_script() {
|
73 |
+
return '<script type="text/javascript">
|
74 |
+
jQuery(document).ready(function() {
|
75 |
+
jQuery(".upload_image_button").click(function() {
|
76 |
+
upload_button = jQuery(this);
|
77 |
+
tb_show("", "media-upload.php?type=image&TB_iframe=true");
|
78 |
+
return false;
|
79 |
+
});
|
80 |
+
jQuery(".remove_image_button").click(function() {
|
81 |
+
jQuery("#taxonomy_image").val("");
|
82 |
+
jQuery(this).parent().siblings(".title").children("img").attr("src","' . Z_IMAGE_PLACEHOLDER . '");
|
83 |
+
jQuery(".inline-edit-col :input[name=\'taxonomy_image\']").val("");
|
84 |
+
return false;
|
85 |
+
});
|
86 |
+
window.send_to_editor = function(html) {
|
87 |
+
imgurl = jQuery("img",html).attr("src");
|
88 |
+
if (upload_button.parent().prev().children().hasClass("tax_list")) {
|
89 |
+
upload_button.parent().prev().children().val(imgurl);
|
90 |
+
upload_button.parent().prev().prev().children().attr("src", imgurl);
|
91 |
+
}
|
92 |
+
else
|
93 |
+
jQuery("#taxonomy_image").val(imgurl);
|
94 |
+
tb_remove();
|
95 |
+
}
|
96 |
+
jQuery(".editinline").live("click", function(){
|
97 |
+
var tax_id = jQuery(this).parents("tr").attr("id").substr(4);
|
98 |
+
var thumb = jQuery("#tag-"+tax_id+" .thumb img").attr("src");
|
99 |
+
if (thumb != "' . Z_IMAGE_PLACEHOLDER . '") {
|
100 |
+
jQuery(".inline-edit-col :input[name=\'taxonomy_image\']").val(thumb);
|
101 |
+
} else {
|
102 |
+
jQuery(".inline-edit-col :input[name=\'taxonomy_image\']").val("");
|
103 |
+
}
|
104 |
+
jQuery(".inline-edit-col .title img").attr("src",thumb);
|
105 |
+
return false;
|
106 |
+
});
|
107 |
+
});
|
108 |
+
</script>';
|
109 |
+
}
|
110 |
+
|
111 |
+
// save our taxonomy image while edit or save term
|
112 |
+
add_action('edit_term','z_save_taxonomy_image');
|
113 |
+
add_action('create_term','z_save_taxonomy_image');
|
114 |
+
function z_save_taxonomy_image($term_id) {
|
115 |
+
if(isset($_POST['taxonomy_image']))
|
116 |
+
update_option('z_taxonomy_image'.$term_id, $_POST['taxonomy_image']);
|
117 |
+
}
|
118 |
+
|
119 |
+
// output taxonomy image url for the given term_id (NULL by default)
|
120 |
+
function z_taxonomy_image_url($term_id = NULL, $return_placeholder = FALSE) {
|
121 |
+
if (!$term_id) {
|
122 |
+
if (is_category())
|
123 |
+
$term_id = get_query_var('cat');
|
124 |
+
elseif (is_tax()) {
|
125 |
+
$current_term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
|
126 |
+
$term_id = $current_term->term_id;
|
127 |
+
}
|
128 |
+
}
|
129 |
+
$taxonomy_image_url = get_option('z_taxonomy_image'.$term_id);
|
130 |
+
if ($return_placeholder)
|
131 |
+
return ($taxonomy_image_url != "") ? $taxonomy_image_url : Z_IMAGE_PLACEHOLDER;
|
132 |
+
else
|
133 |
+
$taxonomy_image_url;
|
134 |
+
}
|
135 |
+
|
136 |
+
function z_quick_edit_custom_box($column_name, $screen, $name) {
|
137 |
+
if ($column_name == 'thumb')
|
138 |
+
echo '<fieldset>
|
139 |
+
<div class="thumb inline-edit-col">
|
140 |
+
<label>
|
141 |
+
<span class="title"><img src="" alt="Thumbnail"/></span>
|
142 |
+
<span class="input-text-wrap"><input type="text" name="taxonomy_image" value="" class="tax_list" /></span>
|
143 |
+
<span class="input-text-wrap">
|
144 |
+
<button class="upload_image_button button">' . __('Upload/Add image', 'zci') . '</button>
|
145 |
+
<button class="remove_image_button button">' . __('Remove image', 'zci') . '</button>
|
146 |
+
</span>
|
147 |
+
</label>
|
148 |
+
</div>
|
149 |
+
</fieldset>';
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Thumbnail column added to category admin.
|
154 |
+
*
|
155 |
+
* @access public
|
156 |
+
* @param mixed $columns
|
157 |
+
* @return void
|
158 |
+
*/
|
159 |
+
function z_taxonomy_columns( $columns ) {
|
160 |
+
$new_columns = array();
|
161 |
+
$new_columns['cb'] = $columns['cb'];
|
162 |
+
$new_columns['thumb'] = __('Image', 'zci');
|
163 |
+
|
164 |
+
unset( $columns['cb'] );
|
165 |
+
|
166 |
+
return array_merge( $new_columns, $columns );
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Thumbnail column value added to category admin.
|
171 |
+
*
|
172 |
+
* @access public
|
173 |
+
* @param mixed $columns
|
174 |
+
* @param mixed $column
|
175 |
+
* @param mixed $id
|
176 |
+
* @return void
|
177 |
+
*/
|
178 |
+
function z_taxonomy_column( $columns, $column, $id ) {
|
179 |
+
if ( $column == 'thumb' )
|
180 |
+
$columns = '<span><img src="' . z_taxonomy_image_url($id, TRUE) . '" alt="' . __('Thumbnail', 'zci') . '" class="wp-post-image" /></span>';
|
181 |
+
|
182 |
+
return $columns;
|
183 |
+
}
|
184 |
+
|
185 |
+
// change 'insert into post' to 'use this image'
|
186 |
+
function z_change_insert_button_text($safe_text, $text) {
|
187 |
+
return str_replace("Insert into Post", "Use this image", $text);
|
188 |
+
}
|
189 |
+
|
190 |
+
// style the image in category list
|
191 |
+
if ( strpos( $_SERVER['SCRIPT_NAME'], 'edit-tags.php' ) > 0 ) {
|
192 |
+
add_action( 'admin_head', 'z_add_style' );
|
193 |
+
add_action('quick_edit_custom_box', 'z_quick_edit_custom_box', 10, 3);
|
194 |
+
add_filter("attribute_escape", "z_change_insert_button_text", 10, 2);
|
195 |
+
}
|
196 |
+
|
197 |
+
?>
|
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,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.2.2
|
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.2.2 =
|
56 |
+
* bug fix in displaying placeholder image in wp-admin.
|
57 |
+
|
58 |
+
= 2.2.1 =
|
59 |
+
* edit z_taxonomy_image_url() to only return data in case the user inserted image for the selected category or taxonomy
|
60 |
+
|
61 |
+
= 2.2 =
|
62 |
+
* fix a bug, prevent a function from running execpt when editing a category or taxonomy to avoid affecting other wordpress edit pages in the wp-admin
|
63 |
+
|
64 |
+
= 2.1 =
|
65 |
+
* fix a bug in languages
|
66 |
+
* fix a bug in quick edit category or taxonomy
|
67 |
+
|
68 |
+
= 2.0 =
|
69 |
+
* New screenshots.
|
70 |
+
* Added l10n support.
|
71 |
+
* Added Arabic and Chinese languages.
|
72 |
+
* Added new button for upload or select an image using wordpress media uploader.
|
73 |
+
* Added default image placeholder.
|
74 |
+
* Added thumbnail in categories or taxonomies list.
|
75 |
+
* Added image thumbnail, image text box, upload button and remove button in quick edit.
|
76 |
+
|
77 |
+
Thank so much to Joe Tse http://tkjune.com :)
|
78 |
+
|
79 |
+
= 1.2 =
|
80 |
+
Adding some screenshots
|
81 |
+
|
82 |
+
= 1.1 =
|
83 |
+
Fix javascript bug with wordpress 3.4
|
84 |
+
|
85 |
+
= 1.0 =
|
86 |
+
The First Release
|
screenshot-1.jpg
ADDED
Binary file
|
screenshot-2.jpg
ADDED
Binary file
|
screenshot-3.jpg
ADDED
Binary file
|