Custom Field Template - Version 1.4.3

Version Description

  • Bugfix: group add new button, multiple values, and quotation marks.
Download this release

Release Info

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

Code changes from version 1.4.2 to 1.4.3

Files changed (2) hide show
  1. custom-field-template.php +14 -11
  2. 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.4.2
8
  Author URI: http://wpgogo.com/
9
  */
10
 
@@ -1295,7 +1295,7 @@ jQuery(this).addClass("closed");
1295
  $value = $value[ $cftnum ];
1296
  }
1297
  } else {
1298
- $value = $default;
1299
  }
1300
  if ( empty($ct_value) ) $ct_value = 1;
1301
 
@@ -1424,7 +1424,7 @@ jQuery(this).addClass("closed");
1424
  $ct_value = count($selected);
1425
  $selected = $selected[ $cftnum ];
1426
  } else {
1427
- $selected = $default;
1428
  }
1429
  if ( empty($ct_value) ) $ct_value = 1;
1430
 
@@ -1469,7 +1469,7 @@ jQuery(this).addClass("closed");
1469
  foreach( $values as $val ) {
1470
  $id = $name . $sid . '_' . $this->sanitize_name( $val );
1471
 
1472
- $checked = ( trim( $val ) == trim( $selected ) ) ? 'checked="checked"' : '';
1473
 
1474
  $out .=
1475
  '<label for="' . $id . '" class="selectit"><input name="' . $name . '[' . $sid . '][' . $cftnum . ']" value="' . attribute_escape(trim($val)) . '" ' . $checked . ' type="radio"' . $class . $style . $event_output . ' /> ';
@@ -1504,7 +1504,7 @@ jQuery(this).addClass("closed");
1504
  $selected = $selected[ $cftnum ];
1505
  }
1506
  } else {
1507
- $selected = $default;
1508
  }
1509
  if ( empty($ct_value) ) $ct_value = 1;
1510
 
@@ -1545,7 +1545,7 @@ jQuery(this).addClass("closed");
1545
  $i = 0;
1546
  if ( is_array($values) ) :
1547
  foreach( $values as $val ) {
1548
- $checked = ( trim( $val ) == trim( $selected ) ) ? 'selected="selected"' : '';
1549
 
1550
  $out .= '<option value="' . attribute_escape(trim($val)) . '" ' . $checked . '>';
1551
  if ( $valueLabel[$i] )
@@ -1578,7 +1578,7 @@ jQuery(this).addClass("closed");
1578
  $value = $this->get_post_meta( $_REQUEST[ 'post' ], $title );
1579
  $value = $value[ $cftnum ];
1580
  } else {
1581
- $value = $default;
1582
  }
1583
 
1584
  $rand = rand();
@@ -1822,7 +1822,7 @@ jQuery(this).addClass("closed");
1822
  $addfield .= ' <span>';
1823
  $addbutton = $this->get_post_meta( $_REQUEST['post'], $title, true )-1;
1824
  if ( $addbutton<=0 ) $addbutton = 0;
1825
- if ( $data['cftnum']/2 == $addbutton ) :
1826
  $addfield .= ' <a href="#clear" onclick="var tmp = jQuery(this).parent().parent().parent().clone().insertAfter(jQuery(this).parent().parent().parent());tmp.find('."'input[type=text],input[type=hidden],input[type=file]'".').val('."''".');tmp.find('."'select'".').val('."''".');tmp.find('."'textarea'".').val('."''".');tmp.find('."'input'".').attr('."'checked',false".');if(tmp.find('."'input[type=radio]'".').attr('."'name'".').match(/\[([0-9]+)\]$/)) { matchval = RegExp.$1; matchval++;tmp.find('."'input[type=radio]'".').attr('."'name',".'tmp.find('."'input[type=radio]'".').attr('."'name'".').replace(/\[([0-9]+)\]$/, \'[\'+matchval+\']\'));}jQuery(this).parent().css('."'visibility','hidden'".');return false;">' . __('Add New', 'custom-field-template') . '</a>';
1827
  else :
1828
  $addfield .= ' <a href="#clear" onclick="jQuery(this).parent().parent().parent().remove();return false;">' . __('Delete', 'custom-field-template') . '</a>';
@@ -1830,7 +1830,7 @@ jQuery(this).addClass("closed");
1830
  $addfield .= '</span>';
1831
  endif;
1832
 
1833
- if ( !empty($data['legend']) ) $out .= '<legend>' . stripcslashes(trim($data['legend'])) . $addfield . '</legend>';
1834
  }
1835
  else if( $data['type'] == 'fieldset_close' ) {
1836
  $out .= '</fieldset>';
@@ -2424,7 +2424,8 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
2424
  $gap = 0;
2425
  foreach( $Data as $Data_key => $Data_val ) :
2426
  foreach( $Data_val as $title => $data) :
2427
- $tmp_parentSN = count($returndata);
 
2428
  switch ( $data["type"]) :
2429
  case 'checkbox' :
2430
  if ( is_numeric($data["code"]) ) :
@@ -2506,7 +2507,8 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
2506
  $gap += ($org_counter - $counter);
2507
  endif;
2508
  else :
2509
- $Data[$Data_key][$title]['parentSN'] = $tmp_parentSN+$gap;
 
2510
  $returndata[] = $Data[$Data_key];
2511
  if ( is_array($fieldset) ) :
2512
  $Data[$Data_key][$title]['parentSN'] = $tmp_parentSN2[$title];
@@ -2525,6 +2527,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
2525
  endif;
2526
  unset($counter);
2527
  endswitch;
 
2528
  endforeach;
2529
  endforeach;
2530
 
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.3
8
  Author URI: http://wpgogo.com/
9
  */
10
 
1295
  $value = $value[ $cftnum ];
1296
  }
1297
  } else {
1298
+ $value = stripslashes($default);
1299
  }
1300
  if ( empty($ct_value) ) $ct_value = 1;
1301
 
1424
  $ct_value = count($selected);
1425
  $selected = $selected[ $cftnum ];
1426
  } else {
1427
+ $selected = stripslashes($default);
1428
  }
1429
  if ( empty($ct_value) ) $ct_value = 1;
1430
 
1469
  foreach( $values as $val ) {
1470
  $id = $name . $sid . '_' . $this->sanitize_name( $val );
1471
 
1472
+ $checked = ( stripcslashes(trim( $val )) == trim( $selected ) ) ? 'checked="checked"' : '';
1473
 
1474
  $out .=
1475
  '<label for="' . $id . '" class="selectit"><input name="' . $name . '[' . $sid . '][' . $cftnum . ']" value="' . attribute_escape(trim($val)) . '" ' . $checked . ' type="radio"' . $class . $style . $event_output . ' /> ';
1504
  $selected = $selected[ $cftnum ];
1505
  }
1506
  } else {
1507
+ $selected = stripslashes($default);
1508
  }
1509
  if ( empty($ct_value) ) $ct_value = 1;
1510
 
1545
  $i = 0;
1546
  if ( is_array($values) ) :
1547
  foreach( $values as $val ) {
1548
+ $checked = ( stripcslashes(trim( $val )) == trim( $selected ) ) ? 'selected="selected"' : '';
1549
 
1550
  $out .= '<option value="' . attribute_escape(trim($val)) . '" ' . $checked . '>';
1551
  if ( $valueLabel[$i] )
1578
  $value = $this->get_post_meta( $_REQUEST[ 'post' ], $title );
1579
  $value = $value[ $cftnum ];
1580
  } else {
1581
+ $value = stripslashes($default);
1582
  }
1583
 
1584
  $rand = rand();
1822
  $addfield .= ' <span>';
1823
  $addbutton = $this->get_post_meta( $_REQUEST['post'], $title, true )-1;
1824
  if ( $addbutton<=0 ) $addbutton = 0;
1825
+ if ( $data['cftnum'] == $addbutton ) :
1826
  $addfield .= ' <a href="#clear" onclick="var tmp = jQuery(this).parent().parent().parent().clone().insertAfter(jQuery(this).parent().parent().parent());tmp.find('."'input[type=text],input[type=hidden],input[type=file]'".').val('."''".');tmp.find('."'select'".').val('."''".');tmp.find('."'textarea'".').val('."''".');tmp.find('."'input'".').attr('."'checked',false".');if(tmp.find('."'input[type=radio]'".').attr('."'name'".').match(/\[([0-9]+)\]$/)) { matchval = RegExp.$1; matchval++;tmp.find('."'input[type=radio]'".').attr('."'name',".'tmp.find('."'input[type=radio]'".').attr('."'name'".').replace(/\[([0-9]+)\]$/, \'[\'+matchval+\']\'));}jQuery(this).parent().css('."'visibility','hidden'".');return false;">' . __('Add New', 'custom-field-template') . '</a>';
1827
  else :
1828
  $addfield .= ' <a href="#clear" onclick="jQuery(this).parent().parent().parent().remove();return false;">' . __('Delete', 'custom-field-template') . '</a>';
1830
  $addfield .= '</span>';
1831
  endif;
1832
 
1833
+ $out .= '<legend>' . stripcslashes(trim($data['legend'])) . $addfield . '</legend>';
1834
  }
1835
  else if( $data['type'] == 'fieldset_close' ) {
1836
  $out .= '</fieldset>';
2424
  $gap = 0;
2425
  foreach( $Data as $Data_key => $Data_val ) :
2426
  foreach( $Data_val as $title => $data) :
2427
+ if ( isset($cftisexist[$title]) ) $tmp_parentSN = $cftisexist[$title];
2428
+ else $tmp_parentSN = count($returndata);
2429
  switch ( $data["type"]) :
2430
  case 'checkbox' :
2431
  if ( is_numeric($data["code"]) ) :
2507
  $gap += ($org_counter - $counter);
2508
  endif;
2509
  else :
2510
+ if ( !isset($cftisexist[$title]) ) $Data[$Data_key][$title]['parentSN'] = $tmp_parentSN+$gap;
2511
+ else $Data[$Data_key][$title]['parentSN'] = $tmp_parentSN;
2512
  $returndata[] = $Data[$Data_key];
2513
  if ( is_array($fieldset) ) :
2514
  $Data[$Data_key][$title]['parentSN'] = $tmp_parentSN2[$title];
2527
  endif;
2528
  unset($counter);
2529
  endswitch;
2530
+ if ( !isset($cftisexist[$title]) ) $cftisexist[$title] = $Data[$Data_key][$title]['parentSN'];
2531
  endforeach;
2532
  endforeach;
2533
 
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.4
7
- Stable tag: 1.4.2
8
 
9
  This plugin adds the default custom fields on the Write Post/Page.
10
 
@@ -98,6 +98,9 @@ See the default template and modify it.
98
 
99
  == Changelog ==
100
 
 
 
 
101
  = 1.4.2 =
102
  * Bugfix: search functionality.
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.4
7
+ Stable tag: 1.4.3
8
 
9
  This plugin adds the default custom fields on the Write Post/Page.
10
 
98
 
99
  == Changelog ==
100
 
101
+ = 1.4.3 =
102
+ * Bugfix: group add new button, multiple values, and quotation marks.
103
+
104
  = 1.4.2 =
105
  * Bugfix: search functionality.
106