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