Custom Field Template - Version 2.0.9

Version Description

  • Bugfix: output with the cft format.
  • Bugfix: multibyte character key name.
Download this release

Release Info

Developer Hiroaki Miyashita
Plugin Icon 128x128 Custom Field Template
Version 2.0.9
Comparing to
See all releases

Code changes from version 2.0.8 to 2.0.9

Files changed (2) hide show
  1. custom-field-template.php +28 -21
  2. 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: 2.0.8
8
  Author URI: http://wpgogo.com/
9
  */
10
 
@@ -13,7 +13,7 @@ This program is based on the rc:custom_field_gui plugin written by Joshua Sigar.
13
  I appreciate your efforts, Joshua.
14
  */
15
 
16
- /* Copyright 2008 -2012 Hiroaki Miyashita
17
 
18
  This program is free software; you can redistribute it and/or modify
19
  it under the terms of the GNU General Public License as published by
@@ -1795,6 +1795,7 @@ jQuery(this).addClass("closed");
1795
 
1796
  $title = $name;
1797
  $name = $this->sanitize_name( $name );
 
1798
 
1799
  if ( isset($code) && is_numeric($code) ) :
1800
  eval(stripcslashes($options['php'][$code]));
@@ -1843,16 +1844,16 @@ jQuery(this).addClass("closed");
1843
  $addfield .= '</div>';
1844
  endif;
1845
 
1846
- $out_key = '<span' . $hide . '><label for="' . $name . $sid . '_' . $cftnum . '">' . $title . '</label></span>'.$addfield;
1847
 
1848
  $out =
1849
- '<dl id="dl_' . $name . $sid . '_' . $cftnum . '" class="dl_text">' .
1850
  '<dt>'.$out_key.'</dt>' .
1851
  '<dd>';
1852
 
1853
  if ( !empty($label) && empty($options['custom_field_template_replace_keys_by_labels']) )
1854
  $out_value .= '<p class="label">' . stripcslashes($label) . '</p>';
1855
- $out_value .= trim($before).'<input id="' . $name . $sid . '_' . $cftnum . '" name="' . $name . '['. $sid . '][]" value="' . esc_attr(trim($value)) . '" type="text" size="' . $size . '"' . $class . $style . $maxlength . $event_output . $readOnly . ' />'.trim($after);
1856
 
1857
  if ( $date == true ) :
1858
  $out_value .= '<script type="text/javascript">' . "\n" .
@@ -1881,6 +1882,7 @@ jQuery(this).addClass("closed");
1881
 
1882
  $title = $name;
1883
  $name = $this->sanitize_name( $name );
 
1884
 
1885
  if ( !$value ) $value = "true";
1886
 
@@ -1909,7 +1911,7 @@ jQuery(this).addClass("closed");
1909
  $event_output .= " " . $key . '="' . stripcslashes(trim($val)) . '"';
1910
  endforeach;
1911
 
1912
- $id = $name . '_' . $this->sanitize_name( $value ) . '_' . $sid . '_' . $cftnum;
1913
 
1914
  $out_key = '<span' . $hide . '>' . $title . '</span>';
1915
 
@@ -1940,6 +1942,7 @@ jQuery(this).addClass("closed");
1940
 
1941
  $title = $name;
1942
  $name = $this->sanitize_name( $name );
 
1943
 
1944
  if ( isset($code) && is_numeric($code) ) :
1945
  eval(stripcslashes($options['php'][$code]));
@@ -1960,7 +1963,7 @@ jQuery(this).addClass("closed");
1960
  endif;
1961
 
1962
  if ( $hideKey == true ) $hide = ' class="hideKey"';
1963
- $class .= ' '.$name . $sid;
1964
  if ( !empty($class) ) $class = ' class="' . trim($class) . '"';
1965
  if ( !empty($style) ) $style = ' style="' . $style . '"';
1966
 
@@ -1984,12 +1987,12 @@ jQuery(this).addClass("closed");
1984
 
1985
  if( $clearButton == true ) {
1986
  $out_key .= '<div>';
1987
- $out_key .= '<a href="#clear" onclick="jQuery(\'.'.$name . $sid.'\').attr(\'checked\', false); return false;">' . __('Clear', 'custom-field-template') . '</a>';
1988
  $out_key .= '</div>';
1989
  }
1990
 
1991
  $out .=
1992
- '<dl id="dl_' . $name . $sid . '_' . $cftnum . '" class="dl_radio">' .
1993
  '<dt>'.$out_key.'</dt>' .
1994
  '<dd>';
1995
 
@@ -2001,7 +2004,7 @@ jQuery(this).addClass("closed");
2001
 
2002
  if ( is_array($values) ) :
2003
  foreach( $values as $val ) {
2004
- $id = $name . '_' . $this->sanitize_name( $val ) . '_' . $sid . '_' . $cftnum;
2005
 
2006
  $checked = ( stripcslashes(trim( $val )) == trim( $selected ) ) ? 'checked="checked"' : '';
2007
 
@@ -2029,6 +2032,7 @@ jQuery(this).addClass("closed");
2029
 
2030
  $title = $name;
2031
  $name = $this->sanitize_name( $name );
 
2032
 
2033
  if ( isset($code) && is_numeric($code) ) :
2034
  eval(stripcslashes($options['php'][$code]));
@@ -2068,16 +2072,16 @@ jQuery(this).addClass("closed");
2068
  $addfield .= '</div>';
2069
  endif;
2070
 
2071
- $out_key = '<span' . $hide . '><label for="' . $name . $sid . '_' . $cftnum . '">' . $title . '</label></span>'.$addfield;
2072
 
2073
  $out .=
2074
- '<dl id="dl_' . $name . $sid . '_' . $cftnum . '" class="dl_select">' .
2075
  '<dt>'.$out_key.'</dt>' .
2076
  '<dd>';
2077
 
2078
  if ( !empty($label) && !$options['custom_field_template_replace_keys_by_labels'] )
2079
  $out_value .= '<p class="label">' . stripcslashes($label) . '</p>';
2080
- $out_value .= trim($before).'<select id="' . $name . $sid . '_' . $cftnum . '" name="' . $name . '[' . $sid . '][]"' . $class . $style . $event_output . '>';
2081
 
2082
  if ( $selectLabel )
2083
  $out_value .= '<option value="">' . stripcslashes(trim($selectLabel)) . '</option>';
@@ -2114,6 +2118,7 @@ jQuery(this).addClass("closed");
2114
 
2115
  $title = $name;
2116
  $name = $this->sanitize_name( $name );
 
2117
 
2118
  if ( is_numeric($code) ) :
2119
  eval(stripcslashes($options['php'][$code]));
@@ -2251,10 +2256,10 @@ jQuery(this).addClass("closed");
2251
  $addfield .= '</div>';
2252
  endif;
2253
 
2254
- $out_key = '<span' . $hide . '><label for="' . $name . $sid . '_' . $cftnum . '">' . $title . '</label></span><br />' . $addfield . $media . $switch;
2255
 
2256
  $out .=
2257
- '<dl id="dl_' . $name . $sid . '_' . $cftnum . '" class="dl_textarea">' .
2258
  '<dt>'.$out_key.'</dt>' .
2259
  '<dd>';
2260
 
@@ -2296,6 +2301,7 @@ jQuery(this).addClass("closed");
2296
 
2297
  $title = $name;
2298
  $name = $this->sanitize_name( $name );
 
2299
 
2300
  if ( !isset($_REQUEST['default']) || (isset($_REQUEST['default']) && $_REQUEST['default'] != true) ) $_REQUEST['default'] = false;
2301
 
@@ -2332,16 +2338,16 @@ jQuery(this).addClass("closed");
2332
  $picker .= '<a href="'.$image_upload_iframe_src.'&post_id='.$_REQUEST[ 'post' ].'&TB_iframe=1&tab='.$tab.'" class="thickbox" onclick="jQuery('."'#cft_current_template'".').val(jQuery(this).parent().parent().parent().parent().attr(\'id\').replace(\'cft_\',\'\'));jQuery('."'#cft_clicked_id'".').val(jQuery(this).parent().find(\'input\').attr(\'id\'));">'.__('Select by Media Picker', 'custom-field-template').'</a>';
2333
  endif;
2334
 
2335
- $out_key = '<span' . $hide . '><label for="' . $name . $sid . '_' . $cftnum . '">' . $title . '</label></span>'.$addfield;
2336
 
2337
  $out .=
2338
- '<dl id="dl_' . $name . $sid . '_' . $cftnum . '" class="dl_file">' .
2339
  '<dt>'.$out_key.'</dt>' .
2340
  '<dd>';
2341
 
2342
  if ( !empty($label) && !$options['custom_field_template_replace_keys_by_labels'] )
2343
  $out_value .= '<p class="label">' . stripcslashes($label) . '</p>';
2344
- $out_value .= trim($before).'<input id="' . $name . $sid . '_' . $cftnum . '" name="' . $name . '['.$sid.'][]" type="file" size="' . $size . '"' . $class . $style . ' onchange="if (jQuery(this).val()) { jQuery(\'#cft_save_button\'+jQuery(this).parent().parent().parent().parent().attr(\'id\').replace(\'cft_\',\'\')).attr(\'disabled\', true); jQuery(\'#post-preview\').hide(); } else { jQuery(\'#cft_save_button\').attr(\'disabled\', false); jQuery(\'#post-preview\').show(); }" />'.trim($after).$picker;
2345
 
2346
  if ( isset($value) && ( $value = intval($value) ) && $thumb_url = wp_get_attachment_image_src( $value, 'thumbnail', true ) ) :
2347
  $thumb_url = $thumb_url[0];
@@ -2354,10 +2360,10 @@ jQuery(this).addClass("closed");
2354
  $title = '<a href="'.$image_upload_iframe_src.'&post_id='.$_REQUEST[ 'post' ].'&TB_iframe=1&tab='.$tab.'" class="thickbox">'.$title.'</a>';
2355
  endif;
2356
 
2357
- $out_value .= '<p><label for="'.$name . $sid . '_' . $cftnum . '_delete"><input type="checkbox" name="'.$name . '_delete[' . $sid . '][' . $cftnum . ']" id="'.$name . $sid . '_' . $cftnum . '_delete" value="1" class="delete_file_checkbox" /> ' . __('Delete', 'custom-field-template') . '</label> <img src="'.$thumb_url.'" width="32" height="32" style="vertical-align:middle;" /> ' . $title . ' </p>';
2358
- $out_value .= '<input type="hidden" id="' . $name . $sid . '_' . $cftnum . '_hide" name="'.$name . '[' . $sid . '][' . $cftnum . ']" value="' . $value . '" />';
2359
  else :
2360
- $out_value .= '<input type="hidden" id="' . $name . $sid . '_' . $cftnum . '_hide" name="'.$name . '[' . $sid . '][' . $cftnum . ']" value="" />';
2361
  endif;
2362
 
2363
  $out .= $out_value.'</dd></dl>'."\n";
@@ -3402,6 +3408,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3402
  $fields = $this->get_custom_fields( $i );
3403
  foreach ( $fields as $field_key => $field_val ) :
3404
  foreach ( $field_val as $key => $val ) :
 
3405
  if ( count($data[$key]) > 1 ) :
3406
  if ( $val['sort'] == 'asc' ) :
3407
  sort($data[$key]);
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: 2.0.9
8
  Author URI: http://wpgogo.com/
9
  */
10
 
13
  I appreciate your efforts, Joshua.
14
  */
15
 
16
+ /* Copyright 2008 -2013 Hiroaki Miyashita
17
 
18
  This program is free software; you can redistribute it and/or modify
19
  it under the terms of the GNU General Public License as published by
1795
 
1796
  $title = $name;
1797
  $name = $this->sanitize_name( $name );
1798
+ $name_id = preg_replace( '/%/', '', $name );
1799
 
1800
  if ( isset($code) && is_numeric($code) ) :
1801
  eval(stripcslashes($options['php'][$code]));
1844
  $addfield .= '</div>';
1845
  endif;
1846
 
1847
+ $out_key = '<span' . $hide . '><label for="' . $name_id . $sid . '_' . $cftnum . '">' . $title . '</label></span>'.$addfield;
1848
 
1849
  $out =
1850
+ '<dl id="dl_' . $name_id . $sid . '_' . $cftnum . '" class="dl_text">' .
1851
  '<dt>'.$out_key.'</dt>' .
1852
  '<dd>';
1853
 
1854
  if ( !empty($label) && empty($options['custom_field_template_replace_keys_by_labels']) )
1855
  $out_value .= '<p class="label">' . stripcslashes($label) . '</p>';
1856
+ $out_value .= trim($before).'<input id="' . $name_id . $sid . '_' . $cftnum . '" name="' . $name . '['. $sid . '][]" value="' . esc_attr(trim($value)) . '" type="text" size="' . $size . '"' . $class . $style . $maxlength . $event_output . $readOnly . ' />'.trim($after);
1857
 
1858
  if ( $date == true ) :
1859
  $out_value .= '<script type="text/javascript">' . "\n" .
1882
 
1883
  $title = $name;
1884
  $name = $this->sanitize_name( $name );
1885
+ $name_id = preg_replace( '/%/', '', $name );
1886
 
1887
  if ( !$value ) $value = "true";
1888
 
1911
  $event_output .= " " . $key . '="' . stripcslashes(trim($val)) . '"';
1912
  endforeach;
1913
 
1914
+ $id = $name_id . '_' . $this->sanitize_name( $value ) . '_' . $sid . '_' . $cftnum;
1915
 
1916
  $out_key = '<span' . $hide . '>' . $title . '</span>';
1917
 
1942
 
1943
  $title = $name;
1944
  $name = $this->sanitize_name( $name );
1945
+ $name_id = preg_replace( '/%/', '', $name );
1946
 
1947
  if ( isset($code) && is_numeric($code) ) :
1948
  eval(stripcslashes($options['php'][$code]));
1963
  endif;
1964
 
1965
  if ( $hideKey == true ) $hide = ' class="hideKey"';
1966
+ $class .= ' '.$name_id . $sid;
1967
  if ( !empty($class) ) $class = ' class="' . trim($class) . '"';
1968
  if ( !empty($style) ) $style = ' style="' . $style . '"';
1969
 
1987
 
1988
  if( $clearButton == true ) {
1989
  $out_key .= '<div>';
1990
+ $out_key .= '<a href="#clear" onclick="jQuery(\'.'.$name_id . $sid.'\').attr(\'checked\', false); return false;">' . __('Clear', 'custom-field-template') . '</a>';
1991
  $out_key .= '</div>';
1992
  }
1993
 
1994
  $out .=
1995
+ '<dl id="dl_' . $name_id . $sid . '_' . $cftnum . '" class="dl_radio">' .
1996
  '<dt>'.$out_key.'</dt>' .
1997
  '<dd>';
1998
 
2004
 
2005
  if ( is_array($values) ) :
2006
  foreach( $values as $val ) {
2007
+ $id = $name_id . '_' . $this->sanitize_name( $val ) . '_' . $sid . '_' . $cftnum;
2008
 
2009
  $checked = ( stripcslashes(trim( $val )) == trim( $selected ) ) ? 'checked="checked"' : '';
2010
 
2032
 
2033
  $title = $name;
2034
  $name = $this->sanitize_name( $name );
2035
+ $name_id = preg_replace( '/%/', '', $name );
2036
 
2037
  if ( isset($code) && is_numeric($code) ) :
2038
  eval(stripcslashes($options['php'][$code]));
2072
  $addfield .= '</div>';
2073
  endif;
2074
 
2075
+ $out_key = '<span' . $hide . '><label for="' . $name_id . $sid . '_' . $cftnum . '">' . $title . '</label></span>'.$addfield;
2076
 
2077
  $out .=
2078
+ '<dl id="dl_' . $name_id . $sid . '_' . $cftnum . '" class="dl_select">' .
2079
  '<dt>'.$out_key.'</dt>' .
2080
  '<dd>';
2081
 
2082
  if ( !empty($label) && !$options['custom_field_template_replace_keys_by_labels'] )
2083
  $out_value .= '<p class="label">' . stripcslashes($label) . '</p>';
2084
+ $out_value .= trim($before).'<select id="' . $name_id . $sid . '_' . $cftnum . '" name="' . $name . '[' . $sid . '][]"' . $class . $style . $event_output . '>';
2085
 
2086
  if ( $selectLabel )
2087
  $out_value .= '<option value="">' . stripcslashes(trim($selectLabel)) . '</option>';
2118
 
2119
  $title = $name;
2120
  $name = $this->sanitize_name( $name );
2121
+ $name_id = preg_replace( '/%/', '', $name );
2122
 
2123
  if ( is_numeric($code) ) :
2124
  eval(stripcslashes($options['php'][$code]));
2256
  $addfield .= '</div>';
2257
  endif;
2258
 
2259
+ $out_key = '<span' . $hide . '><label for="' . $name_id . $sid . '_' . $cftnum . '">' . $title . '</label></span><br />' . $addfield . $media . $switch;
2260
 
2261
  $out .=
2262
+ '<dl id="dl_' . $name_id . $sid . '_' . $cftnum . '" class="dl_textarea">' .
2263
  '<dt>'.$out_key.'</dt>' .
2264
  '<dd>';
2265
 
2301
 
2302
  $title = $name;
2303
  $name = $this->sanitize_name( $name );
2304
+ $name_id = preg_replace( '/%/', '', $name );
2305
 
2306
  if ( !isset($_REQUEST['default']) || (isset($_REQUEST['default']) && $_REQUEST['default'] != true) ) $_REQUEST['default'] = false;
2307
 
2338
  $picker .= '<a href="'.$image_upload_iframe_src.'&post_id='.$_REQUEST[ 'post' ].'&TB_iframe=1&tab='.$tab.'" class="thickbox" onclick="jQuery('."'#cft_current_template'".').val(jQuery(this).parent().parent().parent().parent().attr(\'id\').replace(\'cft_\',\'\'));jQuery('."'#cft_clicked_id'".').val(jQuery(this).parent().find(\'input\').attr(\'id\'));">'.__('Select by Media Picker', 'custom-field-template').'</a>';
2339
  endif;
2340
 
2341
+ $out_key = '<span' . $hide . '><label for="' . $name_id . $sid . '_' . $cftnum . '">' . $title . '</label></span>'.$addfield;
2342
 
2343
  $out .=
2344
+ '<dl id="dl_' . $name_id . $sid . '_' . $cftnum . '" class="dl_file">' .
2345
  '<dt>'.$out_key.'</dt>' .
2346
  '<dd>';
2347
 
2348
  if ( !empty($label) && !$options['custom_field_template_replace_keys_by_labels'] )
2349
  $out_value .= '<p class="label">' . stripcslashes($label) . '</p>';
2350
+ $out_value .= trim($before).'<input id="' . $name_id . $sid . '_' . $cftnum . '" name="' . $name . '['.$sid.'][]" type="file" size="' . $size . '"' . $class . $style . ' onchange="if (jQuery(this).val()) { jQuery(\'#cft_save_button\'+jQuery(this).parent().parent().parent().parent().attr(\'id\').replace(\'cft_\',\'\')).attr(\'disabled\', true); jQuery(\'#post-preview\').hide(); } else { jQuery(\'#cft_save_button\').attr(\'disabled\', false); jQuery(\'#post-preview\').show(); }" />'.trim($after).$picker;
2351
 
2352
  if ( isset($value) && ( $value = intval($value) ) && $thumb_url = wp_get_attachment_image_src( $value, 'thumbnail', true ) ) :
2353
  $thumb_url = $thumb_url[0];
2360
  $title = '<a href="'.$image_upload_iframe_src.'&post_id='.$_REQUEST[ 'post' ].'&TB_iframe=1&tab='.$tab.'" class="thickbox">'.$title.'</a>';
2361
  endif;
2362
 
2363
+ $out_value .= '<p><label for="'.$name . $sid . '_' . $cftnum . '_delete"><input type="checkbox" name="'.$name . '_delete[' . $sid . '][' . $cftnum . ']" id="'.$name_id . $sid . '_' . $cftnum . '_delete" value="1" class="delete_file_checkbox" /> ' . __('Delete', 'custom-field-template') . '</label> <img src="'.$thumb_url.'" width="32" height="32" style="vertical-align:middle;" /> ' . $title . ' </p>';
2364
+ $out_value .= '<input type="hidden" id="' . $name_id . $sid . '_' . $cftnum . '_hide" name="'.$name . '[' . $sid . '][' . $cftnum . ']" value="' . $value . '" />';
2365
  else :
2366
+ $out_value .= '<input type="hidden" id="' . $name_id . $sid . '_' . $cftnum . '_hide" name="'.$name . '[' . $sid . '][' . $cftnum . ']" value="" />';
2367
  endif;
2368
 
2369
  $out .= $out_value.'</dd></dl>'."\n";
3408
  $fields = $this->get_custom_fields( $i );
3409
  foreach ( $fields as $field_key => $field_val ) :
3410
  foreach ( $field_val as $key => $val ) :
3411
+ $replace_val = '';
3412
  if ( count($data[$key]) > 1 ) :
3413
  if ( $val['sort'] == 'asc' ) :
3414
  sort($data[$key]);
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://wpgogo.com/development/custom-field-template.html
4
  Tags: custom field, custom fields, custom, fields, field, template, meta, custom field template, custom post type
5
  Requires at least: 2.1
6
  Tested up to: 3.5
7
- Stable tag: 2.0.8
8
  License: GPLv2 or later
9
 
10
  The Custom Field Template plugin extends the functionality of custom fields.
@@ -111,6 +111,10 @@ See the default template and modify it.
111
 
112
  == Changelog ==
113
 
 
 
 
 
114
  = 2.0.8 =
115
  * Code cleaning.
116
 
4
  Tags: custom field, custom fields, custom, fields, field, template, meta, custom field template, custom post type
5
  Requires at least: 2.1
6
  Tested up to: 3.5
7
+ Stable tag: 2.0.9
8
  License: GPLv2 or later
9
 
10
  The Custom Field Template plugin extends the functionality of custom fields.
111
 
112
  == Changelog ==
113
 
114
+ = 2.0.9 =
115
+ * Bugfix: output with the cft format.
116
+ * Bugfix: multibyte character key name.
117
+
118
  = 2.0.8 =
119
  * Code cleaning.
120