Custom Field Template - Version 2.1.3

Version Description

  • Code cleaning.
Download this release

Release Info

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

Code changes from version 2.1.2 to 2.1.3

Files changed (2) hide show
  1. custom-field-template.php +27 -21
  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: 2.1.2
8
  Author URI: http://wpgogo.com/
9
  */
10
 
@@ -288,10 +288,16 @@ class custom_field_template {
288
  }
289
 
290
  if ( $key ) :
291
- if ( $single ) :
292
  return maybe_unserialize( $meta_cache[$key][0] );
293
  else :
294
- return array_map('maybe_unserialize', $meta_cache[$key]);
 
 
 
 
 
 
295
  endif;
296
  else :
297
  return array_map('maybe_unserialize', $meta_cache);
@@ -3452,36 +3458,36 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3452
  foreach ( $fields as $field_key => $field_val ) :
3453
  foreach ( $field_val as $key => $val ) :
3454
  $replace_val = '';
3455
- if ( count($data[$key]) > 1 ) :
3456
- if ( $val['sort'] == 'asc' ) :
3457
  sort($data[$key]);
3458
- elseif ( $val['sort'] == 'desc' ) :
3459
  rsort($data[$key]);
3460
  endif;
3461
  if ( $before_list ) : $replace_val = $before_list . "\n"; endif;
3462
  foreach ( $data[$key] as $val2 ) :
3463
  $value = $val2;
3464
- if ( is_numeric($val['outputCode']) ) :
3465
  eval(stripcslashes($options['php'][$val['outputCode']]));
3466
  endif;
3467
- if ( $val['shortCode'] == true ) $value = do_shortcode($value);
3468
  $replace_val .= $before_value . $value . $after_value . "\n";
3469
  endforeach;
3470
  if ( $after_list ) : $replace_val .= $after_list . "\n"; endif;
3471
- elseif ( count($data[$key]) == 1 ) :
3472
  $value = $data[$key][0];
3473
- if ( is_numeric($val['outputCode']) ) :
3474
  eval(stripcslashes($options['php'][$val['outputCode']]));
3475
  endif;
3476
- if ( $val['shortCode'] == true ) $value = do_shortcode($value);
3477
  $replace_val = $value;
3478
- if ( $val['singleList'] == true ) :
3479
  if ( $before_list ) : $replace_val = $before_list . "\n"; endif;
3480
  $replace_val .= $before_value . $value . $after_value . "\n";
3481
  if ( $after_list ) : $replace_val .= $after_list . "\n"; endif;
3482
  endif;
3483
  else :
3484
- if ( $val['outputNone'] ) $replace_val = $val['outputNone'];
3485
  else $replace_val = '';
3486
  endif;
3487
  if ( isset($options['shortcode_format_use_php'][$format]) )
@@ -3504,26 +3510,26 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3504
  $output = '<dl class="cft cft'.$template.'">' . "\n";
3505
  foreach ( $fields as $field_key => $field_val ) :
3506
  foreach ( $field_val as $key => $val ) :
3507
- if ( $keylist[$key] == true ) break;
3508
  $values = $this->get_post_meta( $post_id, $key );
3509
  if ( $values ):
3510
- if ( $val['sort'] == 'asc' ) :
3511
  sort($values);
3512
- elseif ( $val['sort'] == 'desc' ) :
3513
  rsort($values);
3514
  endif;
3515
- if ( $val['output'] == true ) :
3516
  foreach ( $values as $num => $value ) :
3517
  $value = str_replace('\\', '\\\\', $value);
3518
- if ( is_numeric($val['outputCode']) ) :
3519
  eval(stripcslashes($options['php'][$val['outputCode']]));
3520
  endif;
3521
  if ( empty($value) && $val['outputNone'] ) $value = $val['outputNone'];
3522
- if ( $val['shortCode'] == true ) $value = do_shortcode($value);
3523
  if ( !empty($val['label']) && !empty($options['custom_field_template_replace_keys_by_labels']) )
3524
  $key_val = stripcslashes($val['label']);
3525
  else $key_val = $key;
3526
- if ( $val['hideKey'] != true && $num == 0 )
3527
  $output .= '<dt>' . $key_val . '</dt>' . "\n";
3528
  $output .= '<dd>' . $value . '</dd>' . "\n";
3529
  endforeach;
@@ -3997,7 +4003,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3997
  function get_preview_id( $post_id ) {
3998
  global $post;
3999
  $preview_id = 0;
4000
- if ( $post->ID == $post_id && is_preview() && $preview = wp_get_post_autosave( $post->ID ) ) :
4001
  $preview_id = $preview->ID;
4002
  endif;
4003
  return $preview_id;
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.1.3
8
  Author URI: http://wpgogo.com/
9
  */
10
 
288
  }
289
 
290
  if ( $key ) :
291
+ if ( $single && isset($meta_cache[$key][0]) ) :
292
  return maybe_unserialize( $meta_cache[$key][0] );
293
  else :
294
+ if ( isset($meta_cache[$key]) ) :
295
+ if ( is_array($meta_cache[$key]) ) :
296
+ return array_map('maybe_unserialize', $meta_cache[$key]);
297
+ else :
298
+ return $meta_cache[$key];
299
+ endif;
300
+ endif;
301
  endif;
302
  else :
303
  return array_map('maybe_unserialize', $meta_cache);
3458
  foreach ( $fields as $field_key => $field_val ) :
3459
  foreach ( $field_val as $key => $val ) :
3460
  $replace_val = '';
3461
+ if ( isset($data[$key]) && count($data[$key]) > 1 ) :
3462
+ if ( isset($val['sort']) && $val['sort'] == 'asc' ) :
3463
  sort($data[$key]);
3464
+ elseif ( isset($val['sort']) && $val['sort'] == 'desc' ) :
3465
  rsort($data[$key]);
3466
  endif;
3467
  if ( $before_list ) : $replace_val = $before_list . "\n"; endif;
3468
  foreach ( $data[$key] as $val2 ) :
3469
  $value = $val2;
3470
+ if ( isset($val['outputCode']) && is_numeric($val['outputCode']) ) :
3471
  eval(stripcslashes($options['php'][$val['outputCode']]));
3472
  endif;
3473
+ if ( isset($val['shortCode']) && $val['shortCode'] == true ) $value = do_shortcode($value);
3474
  $replace_val .= $before_value . $value . $after_value . "\n";
3475
  endforeach;
3476
  if ( $after_list ) : $replace_val .= $after_list . "\n"; endif;
3477
+ elseif ( isset($data[$key]) && count($data[$key]) == 1 ) :
3478
  $value = $data[$key][0];
3479
+ if ( isset($val['outputCode']) && is_numeric($val['outputCode']) ) :
3480
  eval(stripcslashes($options['php'][$val['outputCode']]));
3481
  endif;
3482
+ if ( isset($val['shortCode']) && $val['shortCode'] == true ) $value = do_shortcode($value);
3483
  $replace_val = $value;
3484
+ if ( isset($val['singleList']) && $val['singleList'] == true ) :
3485
  if ( $before_list ) : $replace_val = $before_list . "\n"; endif;
3486
  $replace_val .= $before_value . $value . $after_value . "\n";
3487
  if ( $after_list ) : $replace_val .= $after_list . "\n"; endif;
3488
  endif;
3489
  else :
3490
+ if ( isset($val['outputNone']) ) $replace_val = $val['outputNone'];
3491
  else $replace_val = '';
3492
  endif;
3493
  if ( isset($options['shortcode_format_use_php'][$format]) )
3510
  $output = '<dl class="cft cft'.$template.'">' . "\n";
3511
  foreach ( $fields as $field_key => $field_val ) :
3512
  foreach ( $field_val as $key => $val ) :
3513
+ if ( isset($keylist[$key]) && $keylist[$key] == true ) break;
3514
  $values = $this->get_post_meta( $post_id, $key );
3515
  if ( $values ):
3516
+ if ( isset($val['sort']) && $val['sort'] == 'asc' ) :
3517
  sort($values);
3518
+ elseif ( isset($val['sort']) && $val['sort'] == 'desc' ) :
3519
  rsort($values);
3520
  endif;
3521
+ if ( isset($val['output']) && $val['output'] == true ) :
3522
  foreach ( $values as $num => $value ) :
3523
  $value = str_replace('\\', '\\\\', $value);
3524
+ if ( isset($val['outputCode']) && is_numeric($val['outputCode']) ) :
3525
  eval(stripcslashes($options['php'][$val['outputCode']]));
3526
  endif;
3527
  if ( empty($value) && $val['outputNone'] ) $value = $val['outputNone'];
3528
+ if ( isset($val['shortCode']) && $val['shortCode'] == true ) $value = do_shortcode($value);
3529
  if ( !empty($val['label']) && !empty($options['custom_field_template_replace_keys_by_labels']) )
3530
  $key_val = stripcslashes($val['label']);
3531
  else $key_val = $key;
3532
+ if ( isset($val['hideKey']) && $val['hideKey'] != true && $num == 0 )
3533
  $output .= '<dt>' . $key_val . '</dt>' . "\n";
3534
  $output .= '<dd>' . $value . '</dd>' . "\n";
3535
  endforeach;
4003
  function get_preview_id( $post_id ) {
4004
  global $post;
4005
  $preview_id = 0;
4006
+ if ( isset($post) && $post->ID == $post_id && is_preview() && $preview = wp_get_post_autosave( $post->ID ) ) :
4007
  $preview_id = $preview->ID;
4008
  endif;
4009
  return $preview_id;
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.6
7
- Stable tag: 2.1.2
8
  License: GPLv2 or later
9
 
10
  The Custom Field Template plugin extends the functionality of custom fields.
@@ -112,6 +112,9 @@ See the default template and modify it.
112
 
113
  == Changelog ==
114
 
 
 
 
115
  = 2.1.2 =
116
  * Post preview support.
117
  * Sort output by the input order.
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.6
7
+ Stable tag: 2.1.3
8
  License: GPLv2 or later
9
 
10
  The Custom Field Template plugin extends the functionality of custom fields.
112
 
113
  == Changelog ==
114
 
115
+ = 2.1.3 =
116
+ * Code cleaning.
117
+
118
  = 2.1.2 =
119
  * Post preview support.
120
  * Sort output by the input order.