Version Description
Adding some screenshots
Download this release
Release Info
Developer | elzahlan |
Plugin | Categories Images |
Version | 1.2 |
Comparing to | |
See all releases |
Version 1.2
- categories-images.php +80 -0
- readme.txt +61 -0
- screenshot-1.jpg +0 -0
- screenshot-2.jpg +0 -0
categories-images.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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: 1.2
|
8 |
+
Author URI: http://zahlan.net/
|
9 |
+
*/
|
10 |
+
?>
|
11 |
+
<?php
|
12 |
+
// inti the plugin
|
13 |
+
add_action('admin_head', 'z_inti');
|
14 |
+
function z_inti() {
|
15 |
+
$z_taxonomies = get_taxonomies();
|
16 |
+
if (is_array($z_taxonomies)) {
|
17 |
+
foreach ($z_taxonomies as $z_taxonomy ) {
|
18 |
+
add_action($z_taxonomy.'_add_form_fields', 'z_add_texonomy_field');
|
19 |
+
add_action($z_taxonomy.'_edit_form_fields', 'z_edit_texonomy_field');
|
20 |
+
}
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
// add image field in add form
|
25 |
+
function z_add_texonomy_field() {
|
26 |
+
wp_enqueue_style('thickbox');
|
27 |
+
wp_enqueue_script('thickbox');
|
28 |
+
echo '<div class="form-field">
|
29 |
+
<label for="taxonomy_image">Image</label>
|
30 |
+
<input type="text" name="taxonomy_image" id="taxonomy_image" value="" />
|
31 |
+
</div>'.z_script();
|
32 |
+
}
|
33 |
+
|
34 |
+
// add image field in edit form
|
35 |
+
function z_edit_texonomy_field($taxonomy) {
|
36 |
+
wp_enqueue_style('thickbox');
|
37 |
+
wp_enqueue_script('thickbox');
|
38 |
+
echo '<tr class="form-field">
|
39 |
+
<th scope="row" valign="top"><label for="taxonomy_image">Image</label></th>
|
40 |
+
<td><input type="text" name="taxonomy_image" id="taxonomy_image" value="'.get_option('z_taxonomy_image'.$taxonomy->term_id).'" /><br /></td>
|
41 |
+
</tr>'.z_script();
|
42 |
+
}
|
43 |
+
// upload using wordpress upload
|
44 |
+
function z_script() {
|
45 |
+
return '<script type="text/javascript">
|
46 |
+
jQuery(document).ready(function() {
|
47 |
+
jQuery("#taxonomy_image").click(function() {
|
48 |
+
tb_show("", "media-upload.php?type=image&TB_iframe=true");
|
49 |
+
return false;
|
50 |
+
});
|
51 |
+
window.send_to_editor = function(html) {
|
52 |
+
imgurl = jQuery("img",html).attr("src");
|
53 |
+
jQuery("#taxonomy_image").val(imgurl);
|
54 |
+
tb_remove();
|
55 |
+
}
|
56 |
+
});
|
57 |
+
</script>';
|
58 |
+
}
|
59 |
+
|
60 |
+
// save our taxonomy image while edit or save term
|
61 |
+
add_action('edit_term','z_save_taxonomy_image');
|
62 |
+
add_action('create_term','z_save_taxonomy_image');
|
63 |
+
function z_save_taxonomy_image($term_id) {
|
64 |
+
if(isset($_POST['taxonomy_image']))
|
65 |
+
update_option('z_taxonomy_image'.$term_id, $_POST['taxonomy_image']);
|
66 |
+
}
|
67 |
+
|
68 |
+
// output taxonomy image url for the given term_id (NULL by default)
|
69 |
+
function z_taxonomy_image_url($term_id = NULL) {
|
70 |
+
if (!$term_id) {
|
71 |
+
if (is_category())
|
72 |
+
$term_id = get_query_var('cat');
|
73 |
+
elseif (is_tax()) {
|
74 |
+
$current_term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
|
75 |
+
$term_id = $current_term->term_id;
|
76 |
+
}
|
77 |
+
}
|
78 |
+
return get_option('z_taxonomy_image'.$term_id);
|
79 |
+
}
|
80 |
+
?>
|
readme.txt
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.4
|
6 |
+
Stable tag: 1.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. new image field in add/edit category or taxonomy.
|
50 |
+
2. click the image field and wordpress upload box will popup.
|
51 |
+
|
52 |
+
== Changelog ==
|
53 |
+
|
54 |
+
= 1.2 =
|
55 |
+
Adding some screenshots
|
56 |
+
|
57 |
+
= 1.1 =
|
58 |
+
Fix javascript bug with wordpress 3.4
|
59 |
+
|
60 |
+
= 1.0 =
|
61 |
+
The First Release
|
screenshot-1.jpg
ADDED
Binary file
|
screenshot-2.jpg
ADDED
Binary file
|