Version Description
- Bugfix: duplicate save_post action.
- Bugfix: file type.
Download this release
Release Info
Developer | Hiroaki Miyashita |
Plugin | Custom Field Template |
Version | 1.4.7 |
Comparing to | |
See all releases |
Code changes from version 1.4.6 to 1.4.7
- custom-field-template.php +47 -38
- readme.txt +5 -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.4.
|
8 |
Author URI: http://wpgogo.com/
|
9 |
*/
|
10 |
|
@@ -23,7 +23,7 @@ class custom_field_template {
|
|
23 |
add_action( 'admin_head', array(&$this, 'custom_field_template_admin_head'), 100 );
|
24 |
|
25 |
//add_action( 'edit_post', array(&$this, 'edit_meta_value'), 100 );
|
26 |
-
add_action( 'save_post', array(&$this, 'edit_meta_value'), 100 );
|
27 |
//add_action( 'publish_post', array(&$this, 'edit_meta_value'), 100 );
|
28 |
|
29 |
add_action( 'delete_post', array(&$this, 'custom_field_template_delete_post'), 100 );
|
@@ -1127,7 +1127,7 @@ hideKey = true<br />
|
|
1127 |
<th>multipleButton</th><td>multipleButton = true</td><td></td><td>multipleButton = true</td><td>multipleButton = true</td><td></td><td>multipleButton = true</td>
|
1128 |
</tr>
|
1129 |
<tr>
|
1130 |
-
<th>blank</th><td>blank = true</td><td>blank = true</td><td>blank = true</td><td>blank = true</td><td>blank = true</td><td
|
1131 |
</tr>
|
1132 |
<tr>
|
1133 |
<th>sort</th><td>sort = asc</td><td>sort = desc</td><td>sort = asc</td><td>sort = desc</td><td>sort = asc</td><td></td>
|
@@ -1688,11 +1688,7 @@ jQuery(this).addClass("closed");
|
|
1688 |
$value = $default;
|
1689 |
}
|
1690 |
if ( empty($ct_value) ) $ct_value = 1;
|
1691 |
-
|
1692 |
-
if ( !get_post($value) && $value ) :
|
1693 |
-
delete_post_meta($_REQUEST[ 'post' ], $name, $value);
|
1694 |
-
endif;
|
1695 |
-
|
1696 |
if ( $hideKey == true ) $hide = ' class="hideKey"';
|
1697 |
if ( !empty($class) ) $class = ' class="' . $class . '"';
|
1698 |
if ( !empty($style) ) $style = ' style="' . $style . '"';
|
@@ -1723,7 +1719,7 @@ jQuery(this).addClass("closed");
|
|
1723 |
$title = esc_attr($post->post_title);
|
1724 |
|
1725 |
$out .= '<p><label for=""><input type="checkbox" name="'.$name . '_delete[' . $sid . '][' . $cftnum . ']" id="'.$name . '_delete' . $sid . '" value="1" />' . __('Delete', 'custom-field-template') . '</label> <img src="'.$thumb_url.'" width="32" height="32" style="vertical-align:middle;" /> ' . $title . ' </p>';
|
1726 |
-
$out .= '<input type="hidden" name="'.$name . '[' . $sid . '][]" value="' . $value . '" />';
|
1727 |
endif;
|
1728 |
|
1729 |
$out .= '</dd></dl>'."\n";
|
@@ -2215,7 +2211,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
2215 |
return $out;
|
2216 |
}
|
2217 |
|
2218 |
-
function edit_meta_value( $id ) {
|
2219 |
global $wpdb, $wp_version;
|
2220 |
$options = $this->get_custom_field_template_data();
|
2221 |
|
@@ -2234,6 +2230,9 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
2234 |
return $id;
|
2235 |
endif;
|
2236 |
|
|
|
|
|
|
|
2237 |
$fields = $this->get_custom_fields($_REQUEST['custom-field-template-id']);
|
2238 |
|
2239 |
if ( $fields == null )
|
@@ -2250,7 +2249,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
2250 |
}
|
2251 |
|
2252 |
$save_value = array();
|
2253 |
-
|
2254 |
if ( $_FILES ) :
|
2255 |
foreach($_FILES as $key => $val ) :
|
2256 |
foreach( $val as $key2 => $val2 ) :
|
@@ -2290,38 +2289,38 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
2290 |
if ( is_numeric($data['editCode']) ) :
|
2291 |
eval(stripcslashes($options['php'][$data['editCode']]));
|
2292 |
endif;
|
2293 |
-
if
|
2294 |
-
if ( $
|
2295 |
-
|
2296 |
-
$
|
2297 |
-
|
|
|
2298 |
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
else :
|
2307 |
-
$tmp_value = $this->get_post_meta( $id, $title, false );
|
2308 |
-
if ( $data['type'] == 'checkbox' ) :
|
2309 |
-
delete_post_meta($id, $title, $data['value']);
|
2310 |
else :
|
2311 |
-
|
|
|
|
|
|
|
|
|
|
|
2312 |
endif;
|
2313 |
endif;
|
2314 |
-
|
2315 |
if ( $data['type'] == 'file' ) :
|
2316 |
if ( $_REQUEST[$name.'_delete'][$field_key][$data['cftnum']] ) :
|
2317 |
wp_delete_attachment($value);
|
2318 |
-
delete_post_meta($id, $title, $value);
|
2319 |
endif;
|
2320 |
-
if( isset($tmpfiles[$
|
2321 |
$_FILES[$title] = $tmpfiles[$name][$field_key][$data['cftnum']];
|
2322 |
if ( $value ) :
|
2323 |
wp_delete_attachment($value);
|
2324 |
-
delete_post_meta($id, $title, $value);
|
2325 |
endif;
|
2326 |
|
2327 |
if ( $data['relation'] == true ) :
|
@@ -2329,23 +2328,33 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
|
|
2329 |
else :
|
2330 |
$upload_id = media_handle_upload($title, '');
|
2331 |
endif;
|
2332 |
-
|
2333 |
unset($_FILES);
|
2334 |
-
|
2335 |
-
|
2336 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2337 |
endif;
|
2338 |
endif;
|
2339 |
endswitch;
|
2340 |
endforeach;
|
2341 |
endforeach;
|
2342 |
-
|
2343 |
/*print_r($tmpfiles);
|
2344 |
print_r($fields);
|
2345 |
print_r($_REQUEST);
|
2346 |
print_r($save_value);
|
|
|
2347 |
exit;*/
|
2348 |
-
|
2349 |
foreach( $save_value as $title => $values ) :
|
2350 |
unset($delete);
|
2351 |
if ( count($values) == 1 ) :
|
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.4.7
|
8 |
Author URI: http://wpgogo.com/
|
9 |
*/
|
10 |
|
23 |
add_action( 'admin_head', array(&$this, 'custom_field_template_admin_head'), 100 );
|
24 |
|
25 |
//add_action( 'edit_post', array(&$this, 'edit_meta_value'), 100 );
|
26 |
+
add_action( 'save_post', array(&$this, 'edit_meta_value'), 100, 2 );
|
27 |
//add_action( 'publish_post', array(&$this, 'edit_meta_value'), 100 );
|
28 |
|
29 |
add_action( 'delete_post', array(&$this, 'custom_field_template_delete_post'), 100 );
|
1127 |
<th>multipleButton</th><td>multipleButton = true</td><td></td><td>multipleButton = true</td><td>multipleButton = true</td><td></td><td>multipleButton = true</td>
|
1128 |
</tr>
|
1129 |
<tr>
|
1130 |
+
<th>blank</th><td>blank = true</td><td>blank = true</td><td>blank = true</td><td>blank = true</td><td>blank = true</td><td>blank = true</td>
|
1131 |
</tr>
|
1132 |
<tr>
|
1133 |
<th>sort</th><td>sort = asc</td><td>sort = desc</td><td>sort = asc</td><td>sort = desc</td><td>sort = asc</td><td></td>
|
1688 |
$value = $default;
|
1689 |
}
|
1690 |
if ( empty($ct_value) ) $ct_value = 1;
|
1691 |
+
|
|
|
|
|
|
|
|
|
1692 |
if ( $hideKey == true ) $hide = ' class="hideKey"';
|
1693 |
if ( !empty($class) ) $class = ' class="' . $class . '"';
|
1694 |
if ( !empty($style) ) $style = ' style="' . $style . '"';
|
1719 |
$title = esc_attr($post->post_title);
|
1720 |
|
1721 |
$out .= '<p><label for=""><input type="checkbox" name="'.$name . '_delete[' . $sid . '][' . $cftnum . ']" id="'.$name . '_delete' . $sid . '" value="1" />' . __('Delete', 'custom-field-template') . '</label> <img src="'.$thumb_url.'" width="32" height="32" style="vertical-align:middle;" /> ' . $title . ' </p>';
|
1722 |
+
$out .= '<input type="hidden" name="'.$name . '[' . $sid . '][' . $cftnum . ']" value="' . $value . '" />';
|
1723 |
endif;
|
1724 |
|
1725 |
$out .= '</dd></dl>'."\n";
|
2211 |
return $out;
|
2212 |
}
|
2213 |
|
2214 |
+
function edit_meta_value( $id, $post ) {
|
2215 |
global $wpdb, $wp_version;
|
2216 |
$options = $this->get_custom_field_template_data();
|
2217 |
|
2230 |
return $id;
|
2231 |
endif;
|
2232 |
|
2233 |
+
if ($post->post_type == 'revision')
|
2234 |
+
return;
|
2235 |
+
|
2236 |
$fields = $this->get_custom_fields($_REQUEST['custom-field-template-id']);
|
2237 |
|
2238 |
if ( $fields == null )
|
2249 |
}
|
2250 |
|
2251 |
$save_value = array();
|
2252 |
+
|
2253 |
if ( $_FILES ) :
|
2254 |
foreach($_FILES as $key => $val ) :
|
2255 |
foreach( $val as $key2 => $val2 ) :
|
2289 |
if ( is_numeric($data['editCode']) ) :
|
2290 |
eval(stripcslashes($options['php'][$data['editCode']]));
|
2291 |
endif;
|
2292 |
+
if ( $data['type'] != 'file' ) :
|
2293 |
+
if( isset( $value ) && strlen( $value ) ) :
|
2294 |
+
if ( $data['insertTag'] == true ) $tags_input[] = $value;
|
2295 |
+
if ( $data['valueCount'] == true ) :
|
2296 |
+
$options['value_count'][$title][$value] = $this->set_value_count($title, $value);
|
2297 |
+
endif;
|
2298 |
|
2299 |
+
if ( $_REQUEST['TinyMCE_' . $name . trim($_REQUEST[ $name."_rand" ][$i]) . '_size'] ) {
|
2300 |
+
preg_match('/cw=[0-9]+&ch=([0-9]+)/', $_REQUEST['TinyMCE_' . $name . trim($_REQUEST[ $name."_rand" ][$i]) . '_size'], $matched);
|
2301 |
+
$options['tinyMCE'][$id][$name][$i] = (int)($matched[1]/20);
|
2302 |
+
}
|
2303 |
+
$save_value[$title][] = $value;
|
2304 |
+
elseif ( $data['blank'] == true ) :
|
2305 |
+
$save_value[$title][] = '';
|
|
|
|
|
|
|
|
|
2306 |
else :
|
2307 |
+
$tmp_value = $this->get_post_meta( $id, $title, false );
|
2308 |
+
if ( $data['type'] == 'checkbox' ) :
|
2309 |
+
delete_post_meta($id, $title, $data['value']);
|
2310 |
+
else :
|
2311 |
+
delete_post_meta($id, $title, $tmp_value[$data['cftnum']]);
|
2312 |
+
endif;
|
2313 |
endif;
|
2314 |
endif;
|
2315 |
+
|
2316 |
if ( $data['type'] == 'file' ) :
|
2317 |
if ( $_REQUEST[$name.'_delete'][$field_key][$data['cftnum']] ) :
|
2318 |
wp_delete_attachment($value);
|
|
|
2319 |
endif;
|
2320 |
+
if( isset($tmpfiles[$title][$field_key][$data['cftnum']]) ) :
|
2321 |
$_FILES[$title] = $tmpfiles[$name][$field_key][$data['cftnum']];
|
2322 |
if ( $value ) :
|
2323 |
wp_delete_attachment($value);
|
|
|
2324 |
endif;
|
2325 |
|
2326 |
if ( $data['relation'] == true ) :
|
2328 |
else :
|
2329 |
$upload_id = media_handle_upload($title, '');
|
2330 |
endif;
|
2331 |
+
$save_value[$title][] = $upload_id;
|
2332 |
unset($_FILES);
|
2333 |
+
else :
|
2334 |
+
if ( !get_post($value) && $value ) :
|
2335 |
+
if ( $data['blank'] == true ) :
|
2336 |
+
$save_value[$title][] = '';
|
2337 |
+
endif;
|
2338 |
+
elseif ( $value ) :
|
2339 |
+
$save_value[$title][] = $value;
|
2340 |
+
else :
|
2341 |
+
if ( $data['blank'] == true ) :
|
2342 |
+
$save_value[$title][] = '';
|
2343 |
+
endif;
|
2344 |
+
endif;
|
2345 |
endif;
|
2346 |
endif;
|
2347 |
endswitch;
|
2348 |
endforeach;
|
2349 |
endforeach;
|
2350 |
+
|
2351 |
/*print_r($tmpfiles);
|
2352 |
print_r($fields);
|
2353 |
print_r($_REQUEST);
|
2354 |
print_r($save_value);
|
2355 |
+
print_r(get_post_custom($id));
|
2356 |
exit;*/
|
2357 |
+
|
2358 |
foreach( $save_value as $title => $values ) :
|
2359 |
unset($delete);
|
2360 |
if ( count($values) == 1 ) :
|
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: 2.8.5
|
7 |
-
Stable tag: 1.4.
|
8 |
|
9 |
This plugin adds the default custom fields on the Write Post/Page.
|
10 |
|
@@ -98,6 +98,10 @@ See the default template and modify it.
|
|
98 |
|
99 |
== Changelog ==
|
100 |
|
|
|
|
|
|
|
|
|
101 |
= 1.4.6 =
|
102 |
* Bugfix: checkbox id and save.
|
103 |
|
4 |
Tags: custom, fields, field, template, meta, custom field, custom fields, custom field template
|
5 |
Requires at least: 2.1
|
6 |
Tested up to: 2.8.5
|
7 |
+
Stable tag: 1.4.7
|
8 |
|
9 |
This plugin adds the default custom fields on the Write Post/Page.
|
10 |
|
98 |
|
99 |
== Changelog ==
|
100 |
|
101 |
+
= 1.4.7 =
|
102 |
+
* Bugfix: duplicate save_post action.
|
103 |
+
* Bugfix: file type.
|
104 |
+
|
105 |
= 1.4.6 =
|
106 |
* Bugfix: checkbox id and save.
|
107 |
|