Custom Field Template - Version 0.4

Version Description

Download this release

Release Info

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

Code changes from version 0.3.2 to 0.4

Files changed (2) hide show
  1. custom-field-template.php +132 -87
  2. readme.txt +3 -1
custom-field-template.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Custom Field Template
4
  Plugin URI: http://wordpressgogo.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: 0.3.2
8
  Author URI: http://wordpressgogo.com/
9
  */
10
 
@@ -79,9 +79,25 @@ class custom_field_template {
79
  type = textfield
80
  size = 35
81
 
82
- [Favorite Post]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  type = checkbox
84
- default = checked
 
85
 
86
  [Miles Walked]
87
  type = radio
@@ -98,12 +114,7 @@ type = textarea
98
  rows = 4
99
  cols = 40
100
  tinyMCE = true
101
-
102
- [Hidden Thought]
103
- type = textarea
104
- rows = 4
105
- cols = 40
106
- tinyMCE = true';
107
  update_option('custom_field_template_data', $options);
108
  }
109
 
@@ -217,65 +228,74 @@ tinyMCE = true';
217
  return $custom_fields;
218
  }
219
 
220
- function make_textfield( $name, $size = 25 ) {
221
  $title = $name;
222
  $name = $this->sanitize_name( $name );
223
 
224
  if( isset( $_REQUEST[ 'post' ] ) ) {
225
  $value = get_post_meta( $_REQUEST[ 'post' ], $title );
226
- $value = $value[ 0 ];
 
 
227
  }
228
 
229
- $out =
 
 
230
  '<tr>' .
231
- '<th scope="row">' . $title . ' </th>' .
232
- '<td> <input id="' . $name . '" name="' . $name . '" value="' . attribute_escape($value) . '" type="textfield" size="' . $size . '" /></td>' .
233
  '</tr>';
234
  return $out;
235
  }
236
 
237
- function make_checkbox( $name, $default ) {
238
  $title = $name;
239
  $name = $this->sanitize_name( $name );
240
 
 
 
241
  if( isset( $_REQUEST[ 'post' ] ) ) {
242
- $checked = get_post_meta( $_REQUEST[ 'post' ], $title );
243
- $checked = $checked ? 'checked="checked"' : '';
 
 
244
  }
245
  else {
246
- if ( isset( $default ) && trim( $default ) == 'checked' ) {
247
- $checked = 'checked="checked"';
248
- }
249
  }
250
-
251
- $out =
 
 
252
  '<tr>' .
253
- '<th scope="row" valign="top">' . $title. ' </th>' .
254
  '<td>';
255
 
256
- $out .=
257
- '<input class="checkbox" name="' . $name . '" value="true" id="' . $name . '" ' . $checked . ' type="checkbox" />';
258
-
259
  $out .= '</td>';
260
 
261
  return $out;
262
  }
263
 
264
- function make_radio( $name, $values, $default ) {
265
  $title = $name;
266
  $name = $this->sanitize_name( $name );
267
 
268
  if( isset( $_REQUEST[ 'post' ] ) ) {
269
  $selected = get_post_meta( $_REQUEST[ 'post' ], $title );
270
- $selected = $selected[ 0 ];
271
  }
272
  else {
273
  $selected = $default;
274
  }
275
 
276
- $out =
 
 
277
  '<tr>' .
278
- '<th scope="row" valign="top">' . $title . ' </th>' .
279
  '<td>';
280
 
281
  foreach( $values as $val ) {
@@ -284,30 +304,34 @@ tinyMCE = true';
284
  $checked = ( trim( $val ) == trim( $selected ) ) ? 'checked="checked"' : '';
285
 
286
  $out .=
287
- '<label for="' . $id . '" class="selectit"><input id="' . $id . '" name="' . $name . '" value="' . $val . '" ' . $checked . ' type="radio"> ' . $val . '</label><br>';
288
  }
289
  $out .= '</td>';
290
 
291
  return $out;
292
  }
293
 
294
- function make_select( $name, $values, $default ) {
295
  $title = $name;
296
  $name = $this->sanitize_name( $name );
297
 
298
  if( isset( $_REQUEST[ 'post' ] ) ) {
299
  $selected = get_post_meta( $_REQUEST[ 'post' ], $title );
300
- $selected = $selected[ 0 ];
 
 
301
  }
302
  else {
303
  $selected = $default;
304
  }
305
 
306
- $out =
 
 
307
  '<tr>' .
308
- '<th scope="row">' . $title . ' </th>' .
309
  '<td>' .
310
- '<select name="' . $name . '">' .
311
  '<option value="" >Select</option>';
312
 
313
  foreach( $values as $val ) {
@@ -321,7 +345,7 @@ tinyMCE = true';
321
  return $out;
322
  }
323
 
324
- function make_textarea( $name, $rows, $cols, $tinyMCE ) {
325
  global $wp_version;
326
 
327
  $title = $name;
@@ -329,7 +353,7 @@ tinyMCE = true';
329
 
330
  if( isset( $_REQUEST[ 'post' ] ) ) {
331
  $value = get_post_meta( $_REQUEST[ 'post' ], $title );
332
- $value = $value[ 0 ];
333
  }
334
 
335
  $rand = rand();
@@ -345,20 +369,22 @@ tinyMCE = true';
345
 
346
  if ( substr($wp_version, 0, 3) >= '2.5' ) {
347
 
348
- $media_upload_iframe_src = "media-upload.php";
349
- $media_title = __('Add Media');
350
- $image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src?type=image");
351
- $image_title = __('Add an Image');
352
- $video_upload_iframe_src = apply_filters('video_upload_iframe_src', "$media_upload_iframe_src?type=video");
353
- $video_title = __('Add Video');
354
- $audio_upload_iframe_src = apply_filters('audio_upload_iframe_src', "$media_upload_iframe_src?type=audio");
355
- $audio_title = __('Add Audio');
356
- $media = <<<EOF
 
357
  <a href="{$image_upload_iframe_src}&TB_iframe=true" id="add_image{$rand}" title='$image_title' onclick="focusTextArea('{$name}{$rand}'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);"><img src='images/media-button-image.gif' alt='$image_title' /></a>
358
  <a href="{$video_upload_iframe_src}&amp;TB_iframe=true" id="add_video{$rand}" title='$video_title' onclick="focusTextArea('{$name}{$rand}'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);"><img src='images/media-button-video.gif' alt='$video_title' /></a>
359
  <a href="{$audio_upload_iframe_src}&amp;TB_iframe=true" id="add_audio{$rand}" title='$audio_title' onclick="focusTextArea('{$name}{$rand}'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);"><img src='images/media-button-music.gif' alt='$audio_title' /></a>
360
  <a href="{$media_upload_iframe_src}?TB_iframe=true" id="add_media{$rand}" title='$media_title' onclick="focusTextArea('{$name}{$rand}'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);"><img src='images/media-button-other.gif' alt='$media_title' /></a>
361
  EOF;
 
362
 
363
  $switch = '<div>';
364
  if( $tinyMCE == true && user_can_richedit() ) {
@@ -368,10 +394,12 @@ EOF;
368
 
369
  }
370
 
 
 
371
  $out .=
372
  '<tr>' .
373
- '<th scope="row" valign="top">' . $title . '<br />' . $media . $switch . '</th>' .
374
- '<td><textarea id="' . $name . $rand . '" name="' . $name . '" type="textfield" rows="' .$rows. '" cols="' . $cols . '" style="color:#000000">' . attribute_escape($value) . '</textarea></td>' .
375
  '</tr>';
376
  return $out;
377
  }
@@ -386,26 +414,28 @@ EOF;
386
  $out .= '<input type="hidden" name="custom-field-template-id" id="custom-field-template-id" value="' . $id . '" />';
387
  $out .= '<table class="editform" style="width:100%;">';
388
  foreach( $fields as $title => $data ) {
389
- if( $data[ 'type' ] == 'textfield' ) {
390
- $out .= $this->make_textfield( $title, $data[ 'size' ] );
391
- }
392
- else if( $data[ 'type' ] == 'checkbox' ) {
393
- $out .=
394
- $this->make_checkbox( $title, $data[ 'default' ] );
395
- }
396
- else if( $data[ 'type' ] == 'radio' ) {
397
- $out .=
398
- $this->make_radio(
399
- $title, explode( '#', $data[ 'value' ] ), $data[ 'default' ] );
400
- }
401
- else if( $data[ 'type' ] == 'select' ) {
402
- $out .=
403
- $this->make_select(
404
- $title, explode( '#', $data[ 'value' ] ), $data[ 'default' ] );
405
- }
406
- else if( $data[ 'type' ] == 'textarea' ) {
407
- $out .=
408
- $this->make_textarea( $title, $data[ 'rows' ], $data[ 'cols' ], $data[ 'tinyMCE' ] );
 
 
409
  }
410
  }
411
 
@@ -509,11 +539,13 @@ EOF;
509
 
510
  $fields = $this->get_custom_fields( $init_id );
511
  foreach( $fields as $title => $data ) {
512
- if( $data[ 'type' ] == 'textarea' && $data[ 'tinyMCE' ] ) {
 
513
  $out .= 'jQuery(document).ready(function() {' . "\n" .
514
  ' if(wpTinyMCEConfig) if(wpTinyMCEConfig.defaultEditor == "html") { jQuery("#edButtonPreview").trigger("click"); }' . "\n" .
515
  '});' . "\n";
516
- break;
 
517
  }
518
  }
519
 
@@ -565,26 +597,30 @@ EOF;
565
 
566
  if ( $fields == null )
567
  return;
568
-
569
  foreach( $fields as $title => $data) {
570
  $name = $this->sanitize_name( $title );
571
  $title = $wpdb->escape(stripslashes(trim($title)));
 
 
 
 
 
 
 
572
 
573
- $meta_value = stripslashes(trim($_REQUEST[ "$name" ]));
574
- if( isset( $meta_value ) && !empty( $meta_value ) ) {
575
- delete_post_meta( $id, $title );
576
 
577
- if( $data[ 'type' ] == 'textfield' ||
578
- $data[ 'type' ] == 'radio' ||
579
- $data[ 'type' ] == 'select' ||
580
- $data[ 'type' ] == 'textarea' ) {
581
- add_post_meta( $id, $title, $meta_value );
 
 
 
582
  }
583
- else if( $data[ 'type' ] == 'checkbox' )
584
- add_post_meta( $id, $title, 'true' );
585
- }
586
- else {
587
- delete_post_meta( $id, $title );
588
  }
589
  }
590
 
@@ -595,6 +631,8 @@ EOF;
595
  function parse_ini_str($Str,$ProcessSections = TRUE) {
596
  $Section = NULL;
597
  $Data = array();
 
 
598
  if ($Temp = strtok($Str,"\r\n")) {
599
  do {
600
  switch ($Temp{0}) {
@@ -607,7 +645,14 @@ EOF;
607
  }
608
  $Pos = strpos($Temp,'[');
609
  $Section = substr($Temp,$Pos+1,strpos($Temp,']',$Pos)-1);
610
- $Data[$Section] = array();
 
 
 
 
 
 
 
611
  break;
612
  default:
613
  $Pos = strpos($Temp,'=');
@@ -619,7 +664,7 @@ EOF;
619
  $Value["VALUE"] = trim(substr($Temp,$Pos+1),' "');
620
 
621
  if ($ProcessSections) {
622
- $Data[$Section][$Value["NAME"]] = $Value["VALUE"];
623
  }
624
  else {
625
  $Data[$Value["NAME"]] = $Value["VALUE"];
4
  Plugin URI: http://wordpressgogo.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: 0.4
8
  Author URI: http://wordpressgogo.com/
9
  */
10
 
79
  type = textfield
80
  size = 35
81
 
82
+ [Plan]
83
+ type = textfield
84
+ size = 35
85
+ hideKey = true
86
+
87
+ [Favorite Animal]
88
+ type = checkbox
89
+ value = dog
90
+ checked = true
91
+
92
+ [Favorite Animal]
93
+ type = checkbox
94
+ value = cat
95
+ hideKey = true
96
+
97
+ [Favorite Animal]
98
  type = checkbox
99
+ value = monkey
100
+ hideKey = true
101
 
102
  [Miles Walked]
103
  type = radio
114
  rows = 4
115
  cols = 40
116
  tinyMCE = true
117
+ mediaButton = true';
 
 
 
 
 
118
  update_option('custom_field_template_data', $options);
119
  }
120
 
228
  return $custom_fields;
229
  }
230
 
231
+ function make_textfield( $name, $sid, $size = 25, $hideKey ) {
232
  $title = $name;
233
  $name = $this->sanitize_name( $name );
234
 
235
  if( isset( $_REQUEST[ 'post' ] ) ) {
236
  $value = get_post_meta( $_REQUEST[ 'post' ], $title );
237
+ if ( $value ) {
238
+ $value = $value[ $sid ];
239
+ }
240
  }
241
 
242
+ if( $hideKey == true ) $hide = ' style="visibility: hidden;"';
243
+
244
+ $out .=
245
  '<tr>' .
246
+ '<th scope="row"' . $hide . '>' . $title . ' </th>' .
247
+ '<td> <input id="' . $name . '" name="' . $name . '[]" value="' . attribute_escape($value) . '" type="textfield" size="' . $size . '" /></td>' .
248
  '</tr>';
249
  return $out;
250
  }
251
 
252
+ function make_checkbox( $name, $sid, $value, $checked, $hideKey ) {
253
  $title = $name;
254
  $name = $this->sanitize_name( $name );
255
 
256
+ if ( !$value ) $value = "true";
257
+
258
  if( isset( $_REQUEST[ 'post' ] ) ) {
259
+ $selected = get_post_meta( $_REQUEST[ 'post' ], $title );
260
+ if ( $selected ) {
261
+ if ( in_array($value, $selected) ) $checked = 'checked="checked"';
262
+ }
263
  }
264
  else {
265
+ if( $checked == true ) $checked = 'checked="checked"';
 
 
266
  }
267
+
268
+ if( $hideKey == true ) $hide = ' style="visibility: hidden;"';
269
+
270
+ $out .=
271
  '<tr>' .
272
+ '<th scope="row" valign="top"' . $hide . '>' . $title . ' </th>' .
273
  '<td>';
274
 
275
+ $out .= '<label for="' . $id . '" class="selectit"><input name="' . $name . '[' . $sid . ']" value="' . $value . '" ' . $checked . ' type="checkbox" /> ' . $value . '</label><br>';
276
+
 
277
  $out .= '</td>';
278
 
279
  return $out;
280
  }
281
 
282
+ function make_radio( $name, $sid, $values, $default, $hideKey ) {
283
  $title = $name;
284
  $name = $this->sanitize_name( $name );
285
 
286
  if( isset( $_REQUEST[ 'post' ] ) ) {
287
  $selected = get_post_meta( $_REQUEST[ 'post' ], $title );
288
+ $selected = $selected[ $sid ];
289
  }
290
  else {
291
  $selected = $default;
292
  }
293
 
294
+ if( $hideKey == true ) $hide = ' style="visibility: hidden;"';
295
+
296
+ $out .=
297
  '<tr>' .
298
+ '<th scope="row" valign="top"' . $hide . '>' . $title . ' </th>' .
299
  '<td>';
300
 
301
  foreach( $values as $val ) {
304
  $checked = ( trim( $val ) == trim( $selected ) ) ? 'checked="checked"' : '';
305
 
306
  $out .=
307
+ '<label for="' . $id . '" class="selectit"><input id="' . $id . '" name="' . $name . '[' . $sid . ']" value="' . $val . '" ' . $checked . ' type="radio" /> ' . $val . '</label><br>';
308
  }
309
  $out .= '</td>';
310
 
311
  return $out;
312
  }
313
 
314
+ function make_select( $name, $sid, $values, $default, $hideKey ) {
315
  $title = $name;
316
  $name = $this->sanitize_name( $name );
317
 
318
  if( isset( $_REQUEST[ 'post' ] ) ) {
319
  $selected = get_post_meta( $_REQUEST[ 'post' ], $title );
320
+ if ( $selected ) {
321
+ $selected = $selected[ $sid ];
322
+ }
323
  }
324
  else {
325
  $selected = $default;
326
  }
327
 
328
+ if( $hideKey == true ) $hide = ' style="visibility: hidden;"';
329
+
330
+ $out .=
331
  '<tr>' .
332
+ '<th scope="row" valign="top"' . $hide . '>' . $title . ' </th>' .
333
  '<td>' .
334
+ '<select name="' . $name . '[]">' .
335
  '<option value="" >Select</option>';
336
 
337
  foreach( $values as $val ) {
345
  return $out;
346
  }
347
 
348
+ function make_textarea( $name, $sid, $rows, $cols, $tinyMCE, $mediaButton, $hideKey ) {
349
  global $wp_version;
350
 
351
  $title = $name;
353
 
354
  if( isset( $_REQUEST[ 'post' ] ) ) {
355
  $value = get_post_meta( $_REQUEST[ 'post' ], $title );
356
+ $value = $value[ $sid ];
357
  }
358
 
359
  $rand = rand();
369
 
370
  if ( substr($wp_version, 0, 3) >= '2.5' ) {
371
 
372
+ if ( $mediaButton == true ) {
373
+ $media_upload_iframe_src = "media-upload.php";
374
+ $media_title = __('Add Media');
375
+ $image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src?type=image");
376
+ $image_title = __('Add an Image');
377
+ $video_upload_iframe_src = apply_filters('video_upload_iframe_src', "$media_upload_iframe_src?type=video");
378
+ $video_title = __('Add Video');
379
+ $audio_upload_iframe_src = apply_filters('audio_upload_iframe_src', "$media_upload_iframe_src?type=audio");
380
+ $audio_title = __('Add Audio');
381
+ $media = <<<EOF
382
  <a href="{$image_upload_iframe_src}&TB_iframe=true" id="add_image{$rand}" title='$image_title' onclick="focusTextArea('{$name}{$rand}'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);"><img src='images/media-button-image.gif' alt='$image_title' /></a>
383
  <a href="{$video_upload_iframe_src}&amp;TB_iframe=true" id="add_video{$rand}" title='$video_title' onclick="focusTextArea('{$name}{$rand}'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);"><img src='images/media-button-video.gif' alt='$video_title' /></a>
384
  <a href="{$audio_upload_iframe_src}&amp;TB_iframe=true" id="add_audio{$rand}" title='$audio_title' onclick="focusTextArea('{$name}{$rand}'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);"><img src='images/media-button-music.gif' alt='$audio_title' /></a>
385
  <a href="{$media_upload_iframe_src}?TB_iframe=true" id="add_media{$rand}" title='$media_title' onclick="focusTextArea('{$name}{$rand}'); jQuery(this).attr('href',jQuery(this).attr('href').replace('\?','?post_id='+jQuery('#post_ID').val())); return thickbox(this);"><img src='images/media-button-other.gif' alt='$media_title' /></a>
386
  EOF;
387
+ }
388
 
389
  $switch = '<div>';
390
  if( $tinyMCE == true && user_can_richedit() ) {
394
 
395
  }
396
 
397
+ if( $hideKey == true ) $hide = ' style="visibility: hidden;"';
398
+
399
  $out .=
400
  '<tr>' .
401
+ '<th scope="row" valign="top"><span' . $hide . '>' . $title . '</span><br />' . $media . $switch . '</th>' .
402
+ '<td><textarea id="' . $name . $rand . '" name="' . $name . '[' . $sid . ']" type="textfield" rows="' .$rows. '" cols="' . $cols . '" style="color:#000000">' . attribute_escape($value) . '</textarea></td>' .
403
  '</tr>';
404
  return $out;
405
  }
414
  $out .= '<input type="hidden" name="custom-field-template-id" id="custom-field-template-id" value="' . $id . '" />';
415
  $out .= '<table class="editform" style="width:100%;">';
416
  foreach( $fields as $title => $data ) {
417
+ for($i = 0; $i<count($data); $i++) {
418
+ if( $data[$i][ 'type' ] == 'textfield' ) {
419
+ $out .= $this->make_textfield( $title, $i, $data[$i][ 'size' ], $data[$i][ 'hideKey' ] );
420
+ }
421
+ else if( $data[$i][ 'type' ] == 'checkbox' ) {
422
+ $out .=
423
+ $this->make_checkbox( $title, $i, $data[$i][ 'value' ], $data[$i][ 'checked' ], $data[$i][ 'hideKey' ] );
424
+ }
425
+ else if( $data[$i][ 'type' ] == 'radio' ) {
426
+ $out .=
427
+ $this->make_radio(
428
+ $title, $i, explode( '#', $data[$i][ 'value' ] ), $data[$i][ 'default' ], $data[$i][ 'hideKey' ] );
429
+ }
430
+ else if( $data[$i][ 'type' ] == 'select' ) {
431
+ $out .=
432
+ $this->make_select(
433
+ $title, $i, explode( '#', $data[$i][ 'value' ] ), $data[$i][ 'default' ], $data[$i][ 'hideKey' ] );
434
+ }
435
+ else if( $data[$i][ 'type' ] == 'textarea' ) {
436
+ $out .=
437
+ $this->make_textarea( $title, $i, $data[$i][ 'rows' ], $data[$i][ 'cols' ], $data[$i][ 'tinyMCE' ], $data[$i][ 'mediaButton' ], $data[$i][ 'hideKey' ] );
438
+ }
439
  }
440
  }
441
 
539
 
540
  $fields = $this->get_custom_fields( $init_id );
541
  foreach( $fields as $title => $data ) {
542
+ for($i = 0; $i<count($data); $i++) {
543
+ if( $data[$i][ 'type' ] == 'textarea' && $data[$i][ 'tinyMCE' ] ) {
544
  $out .= 'jQuery(document).ready(function() {' . "\n" .
545
  ' if(wpTinyMCEConfig) if(wpTinyMCEConfig.defaultEditor == "html") { jQuery("#edButtonPreview").trigger("click"); }' . "\n" .
546
  '});' . "\n";
547
+ break;
548
+ }
549
  }
550
  }
551
 
597
 
598
  if ( $fields == null )
599
  return;
600
+
601
  foreach( $fields as $title => $data) {
602
  $name = $this->sanitize_name( $title );
603
  $title = $wpdb->escape(stripslashes(trim($title)));
604
+ delete_post_meta($id, $title);
605
+ }
606
+
607
+ foreach( $fields as $title => $data) {
608
+ for($i = 0; $i<count($data); $i++) {
609
+ $name = $this->sanitize_name( $title );
610
+ $title = $wpdb->escape(stripslashes(trim($title)));
611
 
612
+ $meta_value = stripslashes(trim($_REQUEST[ "$name" ][$i]));
613
+ if( isset( $meta_value ) && !empty( $meta_value ) ) {
 
614
 
615
+ /*if( $data[$i][ 'type' ] == 'textfield' ||
616
+ $data[$i][ 'type' ] == 'radio' ||
617
+ $data[$i][ 'type' ] == 'select' ||
618
+ $data[$i][ 'type' ] == 'textarea' ) {*/
619
+ add_post_meta( $id, $title, $meta_value );
620
+ /*}
621
+ else if( $data[$i][ 'type' ] == 'checkbox' )
622
+ add_post_meta( $id, $title, 'true' );*/
623
  }
 
 
 
 
 
624
  }
625
  }
626
 
631
  function parse_ini_str($Str,$ProcessSections = TRUE) {
632
  $Section = NULL;
633
  $Data = array();
634
+ $Sections = array();
635
+ $id = 0;
636
  if ($Temp = strtok($Str,"\r\n")) {
637
  do {
638
  switch ($Temp{0}) {
645
  }
646
  $Pos = strpos($Temp,'[');
647
  $Section = substr($Temp,$Pos+1,strpos($Temp,']',$Pos)-1);
648
+ if ( in_array($Section, $Sections) ) {
649
+ $id++;
650
+ } else {
651
+ $id = 0;
652
+ $Data[$Section] = array();
653
+ }
654
+ $Sections[] = $Section;
655
+ if($Data[$Section])
656
  break;
657
  default:
658
  $Pos = strpos($Temp,'=');
664
  $Value["VALUE"] = trim(substr($Temp,$Pos+1),' "');
665
 
666
  if ($ProcessSections) {
667
+ $Data[$Section][$id][$Value["NAME"]] = $Value["VALUE"];
668
  }
669
  else {
670
  $Data[$Value["NAME"]] = $Value["VALUE"];
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://wordpressgogo.com/development/custom-field-template.html
4
  Tags: custom, fields, field, template
5
  Requires at least: 2.1
6
  Tested up to: 2.6.2
7
- Stable tag: 0.3.2
8
 
9
  This plugin adds the default custom fields on the Write Post/Page.
10
 
@@ -16,6 +16,8 @@ The Custom Field Template plugin adds the default custom fields on the Write Pos
16
  * This plugin does not use the ini file for the template but set it in the option page of the plugin.
17
  * Support for TinyMCE in the textarea.
18
  * Support for media buttons in the textarea. - requires at least 2.5.
 
 
19
 
20
  == Installation ==
21
 
4
  Tags: custom, fields, field, template
5
  Requires at least: 2.1
6
  Tested up to: 2.6.2
7
+ Stable tag: 0.4
8
 
9
  This plugin adds the default custom fields on the Write Post/Page.
10
 
16
  * This plugin does not use the ini file for the template but set it in the option page of the plugin.
17
  * Support for TinyMCE in the textarea.
18
  * Support for media buttons in the textarea. - requires at least 2.5.
19
+ * Support for multiple fields with the same key.
20
+ * Support for hideKey options.
21
 
22
  == Installation ==
23