Custom Field Template - Version 2.3.8

Version Description

  • Code cleaning.
Download this release

Release Info

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

Code changes from version 2.3.7 to 2.3.8

Files changed (2) hide show
  1. custom-field-template.php +30 -30
  2. readme.txt +7 -2
custom-field-template.php CHANGED
@@ -5,7 +5,7 @@ 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
  Author URI: http://wpgogo.com/
8
- Version: 2.3.7
9
  Text Domain: custom-field-template
10
  Domain Path: /
11
  */
@@ -15,7 +15,7 @@ This program is based on the rc:custom_field_gui plugin written by Joshua Sigar.
15
  I appreciate your efforts, Joshua.
16
  */
17
 
18
- /* Copyright 2008 -2016 Hiroaki Miyashita
19
 
20
  This program is free software; you can redistribute it and/or modify
21
  it under the terms of the GNU General Public License as published by
@@ -3471,8 +3471,8 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3471
  if ( $after_list ) : $output .= $after_list . "\n"; endif;
3472
  return do_shortcode($output);
3473
  endif;
3474
-
3475
- if ( is_numeric($format) && $output = $options['shortcode_format'][$format] ) :
3476
  $data = $this->get_post_meta($post_id);
3477
  $output = stripcslashes($output);
3478
 
@@ -3622,7 +3622,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3622
  case 'textfield':
3623
  case 'textarea':
3624
  if ( !empty($rval['class']) ) $class = ' class="' . $rval['class'] . '"';
3625
- $replace_val[$rkey] .= '<input type="text" name="cftsearch[' . rawurlencode($key) . '][' . $rkey . '][]" value="' . esc_attr($_REQUEST['cftsearch'][rawurlencode($key)][$rkey][0]) . '"' . $class . ' />';
3626
  break;
3627
  case 'checkbox':
3628
  if ( !empty($rval['class']) ) $class = ' class="' . $rval['class'] . '"';
@@ -3761,12 +3761,12 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3761
  $output = '<form method="get" action="'.get_option('home').'/" id="cftsearch'.(int)$format.'">' . "\n";
3762
  foreach( $fields as $field_key => $field_val) :
3763
  foreach( $field_val as $key => $val) :
3764
- if ( $val['search'] == true ) :
3765
  if ( !empty($val['label']) && !empty($options['custom_field_template_replace_keys_by_labels']) )
3766
  $label = stripcslashes($val['label']);
3767
  else $label = $key;
3768
  $output .= '<dl>' ."\n";
3769
- if ( $val['hideKey'] != true) :
3770
  $output .= '<dt><label>' . $label . '</label></dt>' ."\n";
3771
  endif;
3772
 
@@ -3775,33 +3775,33 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3775
  case 'text':
3776
  case 'textfield':
3777
  case 'textarea':
3778
- if ( $val['class'] ) $class = ' class="' . $val['class'] . '"';
3779
- $output .= '<dd><input type="text" name="cftsearch[' . rawurlencode($key) . '][' . $rkey . '][]" value="' . esc_attr($_REQUEST['cftsearch'][rawurlencode($key)][0][0]) . '"' . $class . ' /></dd>';
3780
  break;
3781
  case 'checkbox':
3782
- unset($checked);
3783
- if ( $val['class'] ) $class = ' class="' . $val['class'] . '"';
3784
- if ( is_array($_REQUEST['cftsearch'][rawurlencode($key)]) )
3785
  foreach ( $_REQUEST['cftsearch'][rawurlencode($key)] as $values )
3786
  if ( $val['value'] == $values[0] ) $checked = ' checked="checked"';
3787
- $output .= '<dd><label><input type="checkbox" name="cftsearch[' . rawurlencode($key) . '][' . $rkey . '][]" value="' . esc_attr($val['value']) . '"' . $class . $checked . ' /> ';
3788
- if ( $val['valueLabel'] )
3789
  $output .= stripcslashes($val['valueLabel']);
3790
  else
3791
  $output .= stripcslashes($val['value']);
3792
  $output .= '</label></dd>' . "\n";
3793
  break;
3794
  case 'radio':
3795
- if ( $val['class'] ) $class = ' class="' . $val['class'] . '"';
3796
  $values = explode( '#', $val['value'] );
3797
- $valueLabel = explode( '#', $val['valueLabel'] );
3798
  $i=0;
3799
  foreach ( $values as $metaval ) :
3800
- unset($checked);
3801
  $metaval = trim($metaval);
3802
- if ( $_REQUEST['cftsearch'][rawurlencode($key)][0][0] == $metaval ) $checked = 'checked="checked"';
3803
- $output .= '<dd><label>' . '<input type="radio" name="cftsearch[' . rawurlencode($key) . '][' . $rkey . '][]" value="' . esc_attr($metaval) . '"' . $class . $checked . ' /> ';
3804
- if ( $val['valueLabel'] )
3805
  $output .= stripcslashes(trim($valueLabel[$i]));
3806
  else
3807
  $output .= stripcslashes($metaval);
@@ -3810,19 +3810,19 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3810
  endforeach;
3811
  break;
3812
  case 'select':
3813
- if ( $val['class'] ) $class = ' class="' . $val['class'] . '"';
3814
  $values = explode( '#', $val['value'] );
3815
- $valueLabel = explode( '#', $val['valueLabel'] );
3816
- $output .= '<dd><select name="cftsearch[' . rawurlencode($key) . '][' . $rkey . '][]"' . $class . '>';
3817
  $output .= '<option value=""></option>';
3818
  $i=0;
3819
  foreach ( $values as $metaval ) :
3820
- unset($selected);
3821
  $metaval = trim($metaval);
3822
- if ( $_REQUEST['cftsearch'][rawurlencode($key)][0][0] == $metaval ) $selected = 'selected="selected"';
3823
  else $selected = "";
3824
  $output .= '<option value="' . esc_attr($metaval) . '"' . $selected . '>';
3825
- if ( $val['valueLabel'] )
3826
  $output .= stripcslashes(trim($valueLabel[$i]));
3827
  else
3828
  $output .= stripcslashes($metaval);
@@ -3928,7 +3928,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3928
  endforeach;
3929
  endif;
3930
 
3931
- if ( $_REQUEST['s'] ) :
3932
  $where .= ' AND (';
3933
  if ( function_exists('mb_split') ) :
3934
  $s = mb_split('\s', $_REQUEST['s']);
@@ -3947,7 +3947,7 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3947
  $where .= ') ';
3948
  endif;
3949
 
3950
- if ( is_array($_REQUEST['cftcategory_in']) ) :
3951
  $ids = get_objects_in_term($_REQUEST['cftcategory_in'], 'category');
3952
  if ( is_array($ids) && count($ids) > 0 ) :
3953
  $in_posts = "'" . implode("', '", $ids) . "'";
@@ -3977,8 +3977,8 @@ jQuery("#edButtonPreview").trigger("click"); }' . "\n";*/
3977
  }
3978
 
3979
  function custom_field_template_posts_join($sql) {
3980
- if ( !in_array($_REQUEST['orderby'], array('post_author', 'post_date', 'post_title', 'post_modified', 'menu_order', 'post_parent', 'ID')) ):
3981
- if ( (strtoupper($_REQUEST['order']) == 'ASC' || strtoupper($_REQUEST['order']) == 'DESC') && !empty($_REQUEST['orderby']) ) :
3982
  global $wpdb;
3983
 
3984
  $sql = $wpdb->prepare(" LEFT JOIN `" . $wpdb->postmeta . "` AS meta ON (`" . $wpdb->posts . "`.ID = meta.post_id AND meta.meta_key = %s)", $_REQUEST['orderby']);
5
  Description: This plugin adds the default custom fields on the Write Post/Page.
6
  Author: Hiroaki Miyashita
7
  Author URI: http://wpgogo.com/
8
+ Version: 2.3.8
9
  Text Domain: custom-field-template
10
  Domain Path: /
11
  */
15
  I appreciate your efforts, Joshua.
16
  */
17
 
18
+ /* Copyright 2008 -2018 Hiroaki Miyashita
19
 
20
  This program is free software; you can redistribute it and/or modify
21
  it under the terms of the GNU General Public License as published by
3471
  if ( $after_list ) : $output .= $after_list . "\n"; endif;
3472
  return do_shortcode($output);
3473
  endif;
3474
+
3475
+ if ( is_numeric($format) && !empty($options['shortcode_format'][$format]) && $output = $options['shortcode_format'][$format] ) :
3476
  $data = $this->get_post_meta($post_id);
3477
  $output = stripcslashes($output);
3478
 
3622
  case 'textfield':
3623
  case 'textarea':
3624
  if ( !empty($rval['class']) ) $class = ' class="' . $rval['class'] . '"';
3625
+ $replace_val[$rkey] .= '<input type="text" name="cftsearch[' . rawurlencode($key) . '][' . $rkey . '][]" value="' . (isset($_REQUEST['cftsearch'][rawurlencode($key)][$rkey][0]) ? esc_attr($_REQUEST['cftsearch'][rawurlencode($key)][$rkey][0]) : '') . '"' . $class . ' />';
3626
  break;
3627
  case 'checkbox':
3628
  if ( !empty($rval['class']) ) $class = ' class="' . $rval['class'] . '"';
3761
  $output = '<form method="get" action="'.get_option('home').'/" id="cftsearch'.(int)$format.'">' . "\n";
3762
  foreach( $fields as $field_key => $field_val) :
3763
  foreach( $field_val as $key => $val) :
3764
+ if ( isset($val['search']) && $val['search'] == true ) :
3765
  if ( !empty($val['label']) && !empty($options['custom_field_template_replace_keys_by_labels']) )
3766
  $label = stripcslashes($val['label']);
3767
  else $label = $key;
3768
  $output .= '<dl>' ."\n";
3769
+ if ( !isset($val['hideKey']) || $val['hideKey'] != true) :
3770
  $output .= '<dt><label>' . $label . '</label></dt>' ."\n";
3771
  endif;
3772
 
3775
  case 'text':
3776
  case 'textfield':
3777
  case 'textarea':
3778
+ if ( !empty($val['class']) ) $class = ' class="' . $val['class'] . '"';
3779
+ $output .= '<dd><input type="text" name="cftsearch[' . rawurlencode($key) . '][' . $key . '][]" value="' . (isset($_REQUEST['cftsearch'][rawurlencode($key)][0][0]) ? esc_attr($_REQUEST['cftsearch'][rawurlencode($key)][0][0]) : '') . '"' . $class . ' /></dd>';
3780
  break;
3781
  case 'checkbox':
3782
+ $checked = '';
3783
+ if ( !empty($val['class']) ) $class = ' class="' . $val['class'] . '"';
3784
+ if ( isset($_REQUEST['cftsearch'][rawurlencode($key)]) && is_array($_REQUEST['cftsearch'][rawurlencode($key)]) )
3785
  foreach ( $_REQUEST['cftsearch'][rawurlencode($key)] as $values )
3786
  if ( $val['value'] == $values[0] ) $checked = ' checked="checked"';
3787
+ $output .= '<dd><label><input type="checkbox" name="cftsearch[' . rawurlencode($key) . '][' . $key . '][]" value="' . esc_attr($val['value']) . '"' . $class . $checked . ' /> ';
3788
+ if ( !empty($val['valueLabel']) )
3789
  $output .= stripcslashes($val['valueLabel']);
3790
  else
3791
  $output .= stripcslashes($val['value']);
3792
  $output .= '</label></dd>' . "\n";
3793
  break;
3794
  case 'radio':
3795
+ if ( !empty($val['class']) ) $class = ' class="' . $val['class'] . '"';
3796
  $values = explode( '#', $val['value'] );
3797
+ $valueLabel = isset($val['valueLabel']) ? explode( '#', $val['valueLabel'] ) : '';
3798
  $i=0;
3799
  foreach ( $values as $metaval ) :
3800
+ $checked = '';
3801
  $metaval = trim($metaval);
3802
+ if ( isset($_REQUEST['cftsearch'][rawurlencode($key)][0][0]) && $_REQUEST['cftsearch'][rawurlencode($key)][0][0] == $metaval ) $checked = 'checked="checked"';
3803
+ $output .= '<dd><label>' . '<input type="radio" name="cftsearch[' . rawurlencode($key) . '][' . $key . '][]" value="' . esc_attr($metaval) . '"' . $class . $checked . ' /> ';
3804
+ if ( !empty($val['valueLabel']) )
3805
  $output .= stripcslashes(trim($valueLabel[$i]));
3806
  else
3807
  $output .= stripcslashes($metaval);
3810
  endforeach;
3811
  break;
3812
  case 'select':
3813
+ if ( !empty($val['class']) ) $class = ' class="' . $val['class'] . '"';
3814
  $values = explode( '#', $val['value'] );
3815
+ $valueLabel = isset($val['valueLabel']) ? explode( '#', $val['valueLabel'] ) : '';
3816
+ $output .= '<dd><select name="cftsearch[' . rawurlencode($key) . '][' . $key . '][]"' . $class . '>';
3817
  $output .= '<option value=""></option>';
3818
  $i=0;
3819
  foreach ( $values as $metaval ) :
3820
+ $selected = '';
3821
  $metaval = trim($metaval);
3822
+ if ( isset($_REQUEST['cftsearch'][rawurlencode($key)][0][0]) && $_REQUEST['cftsearch'][rawurlencode($key)][0][0] == $metaval ) $selected = 'selected="selected"';
3823
  else $selected = "";
3824
  $output .= '<option value="' . esc_attr($metaval) . '"' . $selected . '>';
3825
+ if ( !empty($val['valueLabel']) )
3826
  $output .= stripcslashes(trim($valueLabel[$i]));
3827
  else
3828
  $output .= stripcslashes($metaval);
3928
  endforeach;
3929
  endif;
3930
 
3931
+ if ( isset($_REQUEST['s']) ) :
3932
  $where .= ' AND (';
3933
  if ( function_exists('mb_split') ) :
3934
  $s = mb_split('\s', $_REQUEST['s']);
3947
  $where .= ') ';
3948
  endif;
3949
 
3950
+ if ( isset($_REQUEST['cftcategory_in']) && is_array($_REQUEST['cftcategory_in']) ) :
3951
  $ids = get_objects_in_term($_REQUEST['cftcategory_in'], 'category');
3952
  if ( is_array($ids) && count($ids) > 0 ) :
3953
  $in_posts = "'" . implode("', '", $ids) . "'";
3977
  }
3978
 
3979
  function custom_field_template_posts_join($sql) {
3980
+ if ( !empty($_REQUEST['orderby']) && !in_array($_REQUEST['orderby'], array('post_author', 'post_date', 'post_title', 'post_modified', 'menu_order', 'post_parent', 'ID')) ):
3981
+ if ( (strtoupper($_REQUEST['order']) == 'ASC' || strtoupper($_REQUEST['order']) == 'DESC') ) :
3982
  global $wpdb;
3983
 
3984
  $sql = $wpdb->prepare(" LEFT JOIN `" . $wpdb->postmeta . "` AS meta ON (`" . $wpdb->posts . "`.ID = meta.post_id AND meta.meta_key = %s)", $_REQUEST['orderby']);
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Hiroaki Miyashita
3
  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: 4.5.2
7
- Stable tag: 2.3.7
8
  License: GPLv2 or later
9
 
10
  The Custom Field Template plugin extends the functionality of custom fields.
@@ -89,6 +89,8 @@ If you have translated into your language, please let me know.
89
 
90
  * [Japanese Custom Field Template Manual](http://ja.wpcft.com/)
91
 
 
 
92
  == Installation ==
93
 
94
  1. Copy the `custom-field-template` directory into your `wp-content/plugins` directory
@@ -112,6 +114,9 @@ See the default template and modify it.
112
 
113
  == Changelog ==
114
 
 
 
 
115
  = 2.3.7 =
116
  * Bugfix: image output in the cft shortcode with the format attribute.
117
 
3
  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: 4.9.4
7
+ Stable tag: 2.3.8
8
  License: GPLv2 or later
9
 
10
  The Custom Field Template plugin extends the functionality of custom fields.
89
 
90
  * [Japanese Custom Field Template Manual](http://ja.wpcft.com/)
91
 
92
+ Are you interested in other plugins? See the following site [CMS x WP](https://www.cmswp.jp/).
93
+
94
  == Installation ==
95
 
96
  1. Copy the `custom-field-template` directory into your `wp-content/plugins` directory
114
 
115
  == Changelog ==
116
 
117
+ = 2.3.8 =
118
+ * Code cleaning.
119
+
120
  = 2.3.7 =
121
  * Bugfix: image output in the cft shortcode with the format attribute.
122