Version Description
- Support of taxonomies in the category ID field.
Download this release
Release Info
Developer | Hiroaki Miyashita |
Plugin | Custom Field Template |
Version | 1.9.4 |
Comparing to | |
See all releases |
Code changes from version 1.9.3 to 1.9.4
- custom-field-template.php +44 -10
- readme.txt +4 -1
custom-field-template.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Custom Field Template
|
|
4 |
Plugin URI: http://wpgogo.com/development/custom-field-template.html
|
5 |
Description: This plugin adds the default custom fields on the Write Post/Page.
|
6 |
Author: Hiroaki Miyashita
|
7 |
-
Version: 1.9.
|
8 |
Author URI: http://wpgogo.com/
|
9 |
*/
|
10 |
|
@@ -2117,14 +2117,32 @@ jQuery(this).addClass("closed");
|
|
2117 |
endif;
|
2118 |
endif;
|
2119 |
|
2120 |
-
if ( (!isset($_REQUEST['post']) || $_REQUEST['post']<0) && !empty($options['custom_fields'][$id]['category']) && $
|
2121 |
return;
|
2122 |
-
|
2123 |
-
if ( isset($_REQUEST['post']) && !empty($options['custom_fields'][$id]['category']) &&
|
2124 |
-
return;
|
2125 |
-
|
2126 |
-
if ( !isset($_REQUEST['id']) && !empty($options['custom_fields'][$id]['category']) && $options['custom_fields'][$id]['category'] && $_REQUEST['cft_mode'] == 'ajaxload' )
|
2127 |
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2128 |
|
2129 |
if ( !empty($options['custom_fields'][$id]['post']) ) :
|
2130 |
$post_ids = explode(',', $options['custom_fields'][$id]['post']);
|
@@ -2236,7 +2254,7 @@ tmp.find('."'input[type=text],input[type=hidden],input[type=file]'".').val('."''
|
|
2236 |
}
|
2237 |
|
2238 |
function insert_custom_field() {
|
2239 |
-
global $wp_version, $post;
|
2240 |
$options = $this->get_custom_field_template_data();
|
2241 |
$out = '';
|
2242 |
|
@@ -2388,9 +2406,18 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
2388 |
$categories = explode(',', $val['category']);
|
2389 |
$categories = array_filter($categories);
|
2390 |
array_walk( $categories, create_function('&$v', '$v = trim($v);') );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2391 |
foreach($categories as $cat_id) :
|
2392 |
if ( is_numeric($cat_id) ) :
|
2393 |
-
|
|
|
2394 |
if ( !empty($options['custom_field_template_use_autosave']) ) :
|
2395 |
$out .= ' var fields = jQuery(\'#cft :input\').fieldSerialize();';
|
2396 |
$out .= 'jQuery.ajax({type: \'POST\', url: \'?page=custom-field-template/custom-field-template.php&cft_mode=ajaxsave&post=\'+jQuery(\'#post_ID\').val()+\'&custom-field-template-verify-key=\'+jQuery(\'#custom-field-template-verify-key\').val()+\'&\'+fields, success: function(){jQuery(\'#custom_field_template_select\').val(\'' . $key . '\');jQuery.ajax({type: \'GET\', url: \'?page=custom-field-template/custom-field-template.php&cft_mode=ajaxload&id=' . $key . '&post=\'+jQuery(\'#post_ID\').val(), success: function(html) {';
|
@@ -2510,7 +2537,14 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
2510 |
$categories = get_the_category($post_id);
|
2511 |
$cats = array();
|
2512 |
if ( is_array($categories) ) foreach($categories as $category) $cats[] = $category->cat_ID;
|
2513 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2514 |
|
2515 |
for ( $i=0; $i < count($options['custom_fields']); $i++ ) :
|
2516 |
unset($cat_ids, $template_files, $post_ids);
|
4 |
Plugin URI: http://wpgogo.com/development/custom-field-template.html
|
5 |
Description: This plugin adds the default custom fields on the Write Post/Page.
|
6 |
Author: Hiroaki Miyashita
|
7 |
+
Version: 1.9.4
|
8 |
Author URI: http://wpgogo.com/
|
9 |
*/
|
10 |
|
2117 |
endif;
|
2118 |
endif;
|
2119 |
|
2120 |
+
if ( (!isset($_REQUEST['post']) || $_REQUEST['post']<0) && !empty($options['custom_fields'][$id]['category']) && $_REQUEST['cft_mode'] != 'ajaxload' )
|
2121 |
return;
|
2122 |
+
|
2123 |
+
if ( isset($_REQUEST['post']) && !empty($options['custom_fields'][$id]['category']) && !isset($options['posts'][$_REQUEST['post']]) && $options['posts'][$_REQUEST['post']] !== $id && $_REQUEST['cft_mode'] != 'ajaxload' )
|
|
|
|
|
|
|
2124 |
return;
|
2125 |
+
|
2126 |
+
if ( !isset($_REQUEST['id']) && !empty($options['custom_fields'][$id]['category']) && $_REQUEST['cft_mode'] == 'ajaxload' ) :
|
2127 |
+
$category = explode(',', $options['custom_fields'][$id]['category']);
|
2128 |
+
$category = array_filter( $category );
|
2129 |
+
$category = array_unique(array_filter(array_map('trim', $category)));
|
2130 |
+
|
2131 |
+
if ( !empty($_REQUEST['tax_input']) && is_array($_REQUEST['tax_input']) ) :
|
2132 |
+
foreach($_REQUEST['tax_input'] as $key => $val) :
|
2133 |
+
foreach($val as $key2 => $val2 ) :
|
2134 |
+
if ( in_array($val2, $category) ) : $notreturn = 1; break; endif;;
|
2135 |
+
endforeach;
|
2136 |
+
endforeach;
|
2137 |
+
else :
|
2138 |
+
if ( !empty($_REQUEST['post_category']) && is_array($_REQUEST['post_category']) ) :
|
2139 |
+
foreach($_REQUEST['post_category'] as $val) :
|
2140 |
+
if ( in_array($val, $category) ) : $notreturn = 1; break; endif;;
|
2141 |
+
endforeach;
|
2142 |
+
endif;
|
2143 |
+
endif;
|
2144 |
+
if ( empty($notreturn) ) return;
|
2145 |
+
endif;
|
2146 |
|
2147 |
if ( !empty($options['custom_fields'][$id]['post']) ) :
|
2148 |
$post_ids = explode(',', $options['custom_fields'][$id]['post']);
|
2254 |
}
|
2255 |
|
2256 |
function insert_custom_field() {
|
2257 |
+
global $wp_version, $post, $wpdb;
|
2258 |
$options = $this->get_custom_field_template_data();
|
2259 |
$out = '';
|
2260 |
|
2406 |
$categories = explode(',', $val['category']);
|
2407 |
$categories = array_filter($categories);
|
2408 |
array_walk( $categories, create_function('&$v', '$v = trim($v);') );
|
2409 |
+
$query = $wpdb->prepare("SELECT * FROM `".$wpdb->prefix."term_taxonomy` WHERE term_id IN (".$val['category'].")");
|
2410 |
+
$result = $wpdb->get_results($query, ARRAY_A);
|
2411 |
+
$category_taxonomy = array();
|
2412 |
+
if ( !empty($result) && is_array($result) ) :
|
2413 |
+
for($i=0;$i<count($result);$i++) :
|
2414 |
+
$category_taxonomy[$result[$i]['term_id']] = $result[$i]['taxonomy'];
|
2415 |
+
endfor;
|
2416 |
+
endif;
|
2417 |
foreach($categories as $cat_id) :
|
2418 |
if ( is_numeric($cat_id) ) :
|
2419 |
+
if ( $taxonomy == 'category' ) $taxonomy = $category_taxonomy[$cat_id];
|
2420 |
+
$out .= 'jQuery(\'#in-'.$category_taxonomy[$cat_id].'-' . $cat_id . '\').click(function(){if(jQuery(\'#in-'.$category_taxonomy[$cat_id].'-' . $cat_id . '\').attr(\'checked\') == true) { if(tinyMCEID.length) { for(i=0;i<tinyMCEID.length;i++) {tinyMCE.execCommand(\'mceRemoveControl\', false, tinyMCEID[i]);} tinyMCEID.length=0;}; jQuery.get(\'?page=custom-field-template/custom-field-template.php&cft_mode=selectbox&post=\'+jQuery(\'#post_ID\').val()+\'&\'+jQuery(\'#'.$taxonomy.'-all :input\').fieldSerialize(), function(html) { jQuery(\'#cft_selectbox\').html(html);';
|
2421 |
if ( !empty($options['custom_field_template_use_autosave']) ) :
|
2422 |
$out .= ' var fields = jQuery(\'#cft :input\').fieldSerialize();';
|
2423 |
$out .= 'jQuery.ajax({type: \'POST\', url: \'?page=custom-field-template/custom-field-template.php&cft_mode=ajaxsave&post=\'+jQuery(\'#post_ID\').val()+\'&custom-field-template-verify-key=\'+jQuery(\'#custom-field-template-verify-key\').val()+\'&\'+fields, success: function(){jQuery(\'#custom_field_template_select\').val(\'' . $key . '\');jQuery.ajax({type: \'GET\', url: \'?page=custom-field-template/custom-field-template.php&cft_mode=ajaxload&id=' . $key . '&post=\'+jQuery(\'#post_ID\').val(), success: function(html) {';
|
2537 |
$categories = get_the_category($post_id);
|
2538 |
$cats = array();
|
2539 |
if ( is_array($categories) ) foreach($categories as $category) $cats[] = $category->cat_ID;
|
2540 |
+
|
2541 |
+
if ( !empty($_REQUEST['tax_input']) && is_array($_REQUEST['tax_input']) ) :
|
2542 |
+
foreach($_REQUEST['tax_input'] as $key => $val) :
|
2543 |
+
$cats = array_merge($cats, $val);
|
2544 |
+
endforeach;
|
2545 |
+
elseif ( !empty($_REQUEST['post_category']) ) :
|
2546 |
+
$cats = array_merge($cats, $_REQUEST['post_category']);
|
2547 |
+
endif;
|
2548 |
|
2549 |
for ( $i=0; $i < count($options['custom_fields']); $i++ ) :
|
2550 |
unset($cat_ids, $template_files, $post_ids);
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://wpgogo.com/development/custom-field-template.html
|
|
4 |
Tags: custom, fields, field, template, meta, custom field, custom fields, custom field template
|
5 |
Requires at least: 2.1
|
6 |
Tested up to: 3.2.1
|
7 |
-
Stable tag: 1.9.
|
8 |
|
9 |
This plugin adds the default custom fields on the Write Post/Page.
|
10 |
|
@@ -105,6 +105,9 @@ See the default template and modify it.
|
|
105 |
|
106 |
== Changelog ==
|
107 |
|
|
|
|
|
|
|
108 |
= 1.9.3 =
|
109 |
* Bugfix: `level` attribute.
|
110 |
* Bugfix: image insert in IE.
|
4 |
Tags: custom, fields, field, template, meta, custom field, custom fields, custom field template
|
5 |
Requires at least: 2.1
|
6 |
Tested up to: 3.2.1
|
7 |
+
Stable tag: 1.9.4
|
8 |
|
9 |
This plugin adds the default custom fields on the Write Post/Page.
|
10 |
|
105 |
|
106 |
== Changelog ==
|
107 |
|
108 |
+
= 1.9.4 =
|
109 |
+
* Support of taxonomies in the category ID field.
|
110 |
+
|
111 |
= 1.9.3 =
|
112 |
* Bugfix: `level` attribute.
|
113 |
* Bugfix: image insert in IE.
|