Smart Custom Fields - Version 1.6.5

Version Description

  • Fixed a bug that multi value in the loop is broken.
  • In setting screen, if the field is closed, display the field name.
Download this release

Release Info

Developer inc2734
Plugin Icon wp plugin Smart Custom Fields
Version 1.6.5
Comparing to
See all releases

Code changes from version 1.6.4 to 1.6.5

classes/class.scf.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
  /**
3
  * SCF
4
- * Version : 1.3.0
5
  * Author : inc2734
6
  * Created : September 23, 2014
7
- * Modified : November 12, 2015
8
  * License : GPLv2 or later
9
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
@@ -56,7 +56,7 @@ class SCF {
56
 
57
  /**
58
  * Getting all of the post meta data to feel good
59
- *
60
  * @param int $post_id
61
  * @return array
62
  */
@@ -77,7 +77,7 @@ class SCF {
77
 
78
  /**
79
  * Getting the post meta data to feel good
80
- *
81
  * @param string $name group name or field name
82
  * @param int $post_id
83
  * @return mixed
@@ -99,7 +99,7 @@ class SCF {
99
 
100
  /**
101
  * Getting the user meta data to feel good
102
- *
103
  * @param int $user_id
104
  * @param string $name group name or field name
105
  * @return mixed
@@ -121,7 +121,7 @@ class SCF {
121
 
122
  /**
123
  * Getting the term meta data to feel good
124
- *
125
  * @param int $term_id
126
  * @param string $taxonomy_name
127
  * @param string $name group name or field name
@@ -144,7 +144,7 @@ class SCF {
144
 
145
  /**
146
  * Getting any meta data to feel good
147
- *
148
  * @param WP_Post|WP_User|object $object
149
  * @param string $name group name or field name
150
  * @return mixed
@@ -183,7 +183,7 @@ class SCF {
183
 
184
  /**
185
  * Getting all of any meta data to feel good
186
- *
187
  * @param WP_Post|WP_User|WP_Term $object
188
  * @return mixed
189
  */
@@ -232,7 +232,7 @@ class SCF {
232
 
233
  /**
234
  * Saving to cache
235
- *
236
  * @param WP_Post|WP_User|WP_Term $object
237
  * @param string $name
238
  * @param mixed $data
@@ -249,7 +249,7 @@ class SCF {
249
 
250
  /**
251
  * Getting the cache
252
- *
253
  * @param WP_Post|WP_User|WP_Term $object
254
  * @param string $name
255
  * @return mixed
@@ -282,7 +282,7 @@ class SCF {
282
  /**
283
  * Getting the meta data of the group
284
  * When group, Note the point that returned data are repetition
285
- *
286
  * @param WP_Post|WP_User|WP_Term $object
287
  * @param Smart_Custom_Fields_Group $Group
288
  * @return mixed
@@ -314,7 +314,7 @@ class SCF {
314
 
315
  /**
316
  * Getting the meta data of the field
317
- *
318
  * @param WP_Post|WP_User|WP_Term $object
319
  * @param array $field
320
  * @param bool $is_repeatable Whether the group that this field belongs is repetition
@@ -448,7 +448,7 @@ class SCF {
448
 
449
  /**
450
  * Getting enabled custom field settings in the post type or the role or the term.
451
- *
452
  * @param WP_Post|WP_User|WP_Term $object
453
  * @return array $settings
454
  */
@@ -568,10 +568,6 @@ class SCF {
568
  $type = $Meta->get_type( false );
569
  $meta_type = $Meta->get_meta_type();
570
 
571
- // 投稿IDで出し分けされているカスタムフィールド設定を持つ投稿の場合、
572
- // プレビュー画面ではIDが変わって表示されなくなってしまうため、
573
- // プレビュー画面の場合は元の投稿(プレビューの親)から設定の再取得が必要
574
-
575
  // IF the post that has custom field settings according to post ID,
576
  // don't display because the post ID would change in preview.
577
  // So if in preview, re-getting post ID from original post (parent of the preview).
@@ -722,7 +718,7 @@ class SCF {
722
 
723
  /**
724
  * Getting delimited identification data of the repeated multi-value items
725
- *
726
  * @param WP_Post|WP_User|WP_Term $object
727
  * @return array
728
  */
@@ -744,7 +740,7 @@ class SCF {
744
 
745
  /**
746
  * Return true if null or empty value
747
- *
748
  * @param mixed $value
749
  * @return bool
750
  */
@@ -760,7 +756,7 @@ class SCF {
760
 
761
  /**
762
  * Adding the available form field object
763
- *
764
  * @param Smart_Custom_Fields_Field_Base $instance
765
  */
766
  public static function add_form_field_instance( Smart_Custom_Fields_Field_Base $instance ) {
@@ -772,7 +768,7 @@ class SCF {
772
 
773
  /**
774
  * Getting the available form field object
775
- *
776
  * @param string $type type of the form field
777
  * @param Smart_Custom_Fields_Field_Base
778
  */
@@ -798,7 +794,7 @@ class SCF {
798
  /**
799
  * Getting custom fields that saved custo field settings page
800
  * Note that not return only one even define multiple fields with the same name of the field name
801
- *
802
  * @param WP_Post|WP_User|WP_Term $object
803
  * @param string $field_name
804
  * @return Smart_Custom_Fields_Field_Base|null
@@ -806,19 +802,16 @@ class SCF {
806
  public static function get_field( $object, $field_name ) {
807
  $settings = self::get_settings( $object );
808
  foreach ( $settings as $Setting ) {
809
- $groups = $Setting->get_groups();
810
- foreach ( $groups as $Group ) {
811
- $Field = $Group->get_field( $field_name );
812
- if ( $Field ) {
813
- return $Field;
814
- }
815
  }
816
  }
817
  }
818
 
819
  /**
820
  * Convert to array from newline delimiter $choices
821
- *
822
  * @param string $choices
823
  * @return array
824
  */
1
  <?php
2
  /**
3
  * SCF
4
+ * Version : 1.3.1
5
  * Author : inc2734
6
  * Created : September 23, 2014
7
+ * Modified : December 13, 2015
8
  * License : GPLv2 or later
9
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
56
 
57
  /**
58
  * Getting all of the post meta data to feel good
59
+ *
60
  * @param int $post_id
61
  * @return array
62
  */
77
 
78
  /**
79
  * Getting the post meta data to feel good
80
+ *
81
  * @param string $name group name or field name
82
  * @param int $post_id
83
  * @return mixed
99
 
100
  /**
101
  * Getting the user meta data to feel good
102
+ *
103
  * @param int $user_id
104
  * @param string $name group name or field name
105
  * @return mixed
121
 
122
  /**
123
  * Getting the term meta data to feel good
124
+ *
125
  * @param int $term_id
126
  * @param string $taxonomy_name
127
  * @param string $name group name or field name
144
 
145
  /**
146
  * Getting any meta data to feel good
147
+ *
148
  * @param WP_Post|WP_User|object $object
149
  * @param string $name group name or field name
150
  * @return mixed
183
 
184
  /**
185
  * Getting all of any meta data to feel good
186
+ *
187
  * @param WP_Post|WP_User|WP_Term $object
188
  * @return mixed
189
  */
232
 
233
  /**
234
  * Saving to cache
235
+ *
236
  * @param WP_Post|WP_User|WP_Term $object
237
  * @param string $name
238
  * @param mixed $data
249
 
250
  /**
251
  * Getting the cache
252
+ *
253
  * @param WP_Post|WP_User|WP_Term $object
254
  * @param string $name
255
  * @return mixed
282
  /**
283
  * Getting the meta data of the group
284
  * When group, Note the point that returned data are repetition
285
+ *
286
  * @param WP_Post|WP_User|WP_Term $object
287
  * @param Smart_Custom_Fields_Group $Group
288
  * @return mixed
314
 
315
  /**
316
  * Getting the meta data of the field
317
+ *
318
  * @param WP_Post|WP_User|WP_Term $object
319
  * @param array $field
320
  * @param bool $is_repeatable Whether the group that this field belongs is repetition
448
 
449
  /**
450
  * Getting enabled custom field settings in the post type or the role or the term.
451
+ *
452
  * @param WP_Post|WP_User|WP_Term $object
453
  * @return array $settings
454
  */
568
  $type = $Meta->get_type( false );
569
  $meta_type = $Meta->get_meta_type();
570
 
 
 
 
 
571
  // IF the post that has custom field settings according to post ID,
572
  // don't display because the post ID would change in preview.
573
  // So if in preview, re-getting post ID from original post (parent of the preview).
718
 
719
  /**
720
  * Getting delimited identification data of the repeated multi-value items
721
+ *
722
  * @param WP_Post|WP_User|WP_Term $object
723
  * @return array
724
  */
740
 
741
  /**
742
  * Return true if null or empty value
743
+ *
744
  * @param mixed $value
745
  * @return bool
746
  */
756
 
757
  /**
758
  * Adding the available form field object
759
+ *
760
  * @param Smart_Custom_Fields_Field_Base $instance
761
  */
762
  public static function add_form_field_instance( Smart_Custom_Fields_Field_Base $instance ) {
768
 
769
  /**
770
  * Getting the available form field object
771
+ *
772
  * @param string $type type of the form field
773
  * @param Smart_Custom_Fields_Field_Base
774
  */
794
  /**
795
  * Getting custom fields that saved custo field settings page
796
  * Note that not return only one even define multiple fields with the same name of the field name
797
+ *
798
  * @param WP_Post|WP_User|WP_Term $object
799
  * @param string $field_name
800
  * @return Smart_Custom_Fields_Field_Base|null
802
  public static function get_field( $object, $field_name ) {
803
  $settings = self::get_settings( $object );
804
  foreach ( $settings as $Setting ) {
805
+ $fields = $Setting->get_fields();
806
+ if ( !empty( $fields[$field_name] ) ) {
807
+ return $fields[$field_name];
 
 
 
808
  }
809
  }
810
  }
811
 
812
  /**
813
  * Convert to array from newline delimiter $choices
814
+ *
815
  * @param string $choices
816
  * @return array
817
  */
classes/controller/class.controller-base.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
  /**
3
  * Smart_Custom_Fields_Controller_Base
4
- * Version : 1.2.0
5
  * Author : inc2734
6
  * Created : April 27, 2015
7
- * Modified : November 12, 2015
8
  * License : GPLv2 or later
9
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
@@ -25,7 +25,7 @@ class Smart_Custom_Fields_Controller_Base {
25
 
26
  /**
27
  * Loading resources for edit page.
28
- *
29
  * @param string $hook
30
  */
31
  public function admin_enqueue_scripts( $hook ) {
@@ -51,7 +51,7 @@ class Smart_Custom_Fields_Controller_Base {
51
 
52
  /**
53
  * Display custom fields in edit page.
54
- *
55
  * @param WP_Post|WP_User|WP_Term $object
56
  * @param array $callback_args custom field setting information
57
  */
@@ -107,7 +107,7 @@ class Smart_Custom_Fields_Controller_Base {
107
 
108
  /**
109
  * Generating array for displaying the custom fields
110
- *
111
  * @param WP_Post|WP_User|WP_Term $object
112
  * @param array $groups Settings from custom field settings page
113
  * @return array $tables Array for displaying a table for custom fields
@@ -162,7 +162,7 @@ class Smart_Custom_Fields_Controller_Base {
162
 
163
  /**
164
  * Getting the multi-value field meta data.
165
- *
166
  * @param WP_Post|WP_User|WP_Term $object
167
  * @param Smart_Custom_Fields_Field_Base $Field
168
  * @param int $index
@@ -197,6 +197,8 @@ class Smart_Custom_Fields_Controller_Base {
197
 
198
  if ( $now_num ) {
199
  $value = array_slice( $value, $start, $now_num );
 
 
200
  }
201
  }
202
  return $value;
@@ -204,7 +206,7 @@ class Smart_Custom_Fields_Controller_Base {
204
 
205
  /**
206
  * Getting the non multi-value field meta data.
207
- *
208
  * @param WP_Post|WP_User|WP_Term $object
209
  * @param Smart_Custom_Fields_Field_Base $Field
210
  * @param int $index
@@ -230,7 +232,7 @@ class Smart_Custom_Fields_Controller_Base {
230
 
231
  /**
232
  * Displaying tr element for table of custom fields
233
- *
234
  * @param WP_Post|WP_User|WP_Term $object
235
  * @param bool $is_repeat
236
  * @param array $fields
1
  <?php
2
  /**
3
  * Smart_Custom_Fields_Controller_Base
4
+ * Version : 1.2.1
5
  * Author : inc2734
6
  * Created : April 27, 2015
7
+ * Modified : January 5, 2016
8
  * License : GPLv2 or later
9
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
25
 
26
  /**
27
  * Loading resources for edit page.
28
+ *
29
  * @param string $hook
30
  */
31
  public function admin_enqueue_scripts( $hook ) {
51
 
52
  /**
53
  * Display custom fields in edit page.
54
+ *
55
  * @param WP_Post|WP_User|WP_Term $object
56
  * @param array $callback_args custom field setting information
57
  */
107
 
108
  /**
109
  * Generating array for displaying the custom fields
110
+ *
111
  * @param WP_Post|WP_User|WP_Term $object
112
  * @param array $groups Settings from custom field settings page
113
  * @return array $tables Array for displaying a table for custom fields
162
 
163
  /**
164
  * Getting the multi-value field meta data.
165
+ *
166
  * @param WP_Post|WP_User|WP_Term $object
167
  * @param Smart_Custom_Fields_Field_Base $Field
168
  * @param int $index
197
 
198
  if ( $now_num ) {
199
  $value = array_slice( $value, $start, $now_num );
200
+ } else {
201
+ $value = array();
202
  }
203
  }
204
  return $value;
206
 
207
  /**
208
  * Getting the non multi-value field meta data.
209
+ *
210
  * @param WP_Post|WP_User|WP_Term $object
211
  * @param Smart_Custom_Fields_Field_Base $Field
212
  * @param int $index
232
 
233
  /**
234
  * Displaying tr element for table of custom fields
235
+ *
236
  * @param WP_Post|WP_User|WP_Term $object
237
  * @param bool $is_repeat
238
  * @param array $fields
classes/controller/class.settings.php CHANGED
@@ -102,7 +102,7 @@ class Smart_Custom_Fields_Controller_Settings {
102
 
103
  /**
104
  * Displaying "hide" if $key isn't empty
105
- *
106
  * @param string $key
107
  */
108
  private function add_hide_class( $key ) {
@@ -134,9 +134,10 @@ class Smart_Custom_Fields_Controller_Settings {
134
  <?php foreach ( $fields as $field_key => $Field ) : ?>
135
  <div class="<?php echo esc_attr( SCF_Config::PREFIX . 'field' ); ?> <?php $this->add_hide_class( $field_key ); ?>">
136
  <?php
 
137
  $field_label = $Field->get( 'label' );
138
  if ( !$field_label ) {
139
- $field_label = $Field->get( 'name' );
140
  if ( !$field_label ) {
141
  $field_label = "&nbsp;";
142
  }
@@ -144,7 +145,7 @@ class Smart_Custom_Fields_Controller_Settings {
144
  ?>
145
  <div class="<?php echo esc_attr( SCF_Config::PREFIX . 'icon-handle' ); ?>"></div>
146
  <b class="btn-remove-field"><span class="dashicons dashicons-no-alt"></span></b>
147
- <div class="field-label"><?php echo esc_html( $field_label ); ?></div>
148
  <table class="<?php $this->add_hide_class( !$Field->get( 'name' ) ); ?>">
149
  <tr>
150
  <th><?php esc_html_e( 'Type', 'smart-custom-fields' ); ?><span class="<?php echo esc_attr( SCF_Config::PREFIX . 'require' ); ?>">*</span></th>
102
 
103
  /**
104
  * Displaying "hide" if $key isn't empty
105
+ *
106
  * @param string $key
107
  */
108
  private function add_hide_class( $key ) {
134
  <?php foreach ( $fields as $field_key => $Field ) : ?>
135
  <div class="<?php echo esc_attr( SCF_Config::PREFIX . 'field' ); ?> <?php $this->add_hide_class( $field_key ); ?>">
136
  <?php
137
+ $field_name = $Field->get( 'name' );
138
  $field_label = $Field->get( 'label' );
139
  if ( !$field_label ) {
140
+ $field_label = $field_name;
141
  if ( !$field_label ) {
142
  $field_label = "&nbsp;";
143
  }
145
  ?>
146
  <div class="<?php echo esc_attr( SCF_Config::PREFIX . 'icon-handle' ); ?>"></div>
147
  <b class="btn-remove-field"><span class="dashicons dashicons-no-alt"></span></b>
148
+ <div class="field-label"><?php echo esc_html( $field_label ); ?> <small>[ <?php echo esc_html( $field_name ); ?> ]</small></div>
149
  <table class="<?php $this->add_hide_class( !$Field->get( 'name' ) ); ?>">
150
  <tr>
151
  <th><?php esc_html_e( 'Type', 'smart-custom-fields' ); ?><span class="<?php echo esc_attr( SCF_Config::PREFIX . 'require' ); ?>">*</span></th>
classes/models/class.meta.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
  /**
3
  * Smart_Custom_Fields_Meta
4
- * Version : 1.2.1
5
  * Author : inc2734
6
  * Created : March 17, 2015
7
- * Modified : November 21, 2015
8
  * License : GPLv2 or later
9
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
@@ -162,12 +162,9 @@ class Smart_Custom_Fields_Meta {
162
  $settings = SCF::get_settings( $this->object );
163
  if ( $key ) {
164
  foreach ( $settings as $Setting ) {
165
- $groups = $Setting->get_groups();
166
- foreach ( $groups as $Group ) {
167
- $Field = $Group->get_field( $key );
168
- if ( $Field ) {
169
- return $meta;
170
- }
171
  }
172
  }
173
  } else {
1
  <?php
2
  /**
3
  * Smart_Custom_Fields_Meta
4
+ * Version : 1.2.2
5
  * Author : inc2734
6
  * Created : March 17, 2015
7
+ * Modified : December 13, 2015
8
  * License : GPLv2 or later
9
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
162
  $settings = SCF::get_settings( $this->object );
163
  if ( $key ) {
164
  foreach ( $settings as $Setting ) {
165
+ $fields = $Setting->get_fields();
166
+ if ( !empty( $fields[$key] ) ) {
167
+ return $meta;
 
 
 
168
  }
169
  }
170
  } else {
css/settings.css CHANGED
@@ -156,6 +156,10 @@
156
  overflow: hidden;
157
  *zoom: 1;
158
  }
 
 
 
 
159
 
160
  /**
161
  * .btn-remove-field
156
  overflow: hidden;
157
  *zoom: 1;
158
  }
159
+ .smart-cf-group .smart-cf-field .field-label small {
160
+ color: #999;
161
+ font-size: 90%;
162
+ }
163
 
164
  /**
165
  * .btn-remove-field
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: inc2734, toro_unit, mimosafa, hideokamoto
3
  Donate link: http://www.amazon.co.jp/registry/wishlist/39ANKRNSTNW40
4
  Tags: plugin, custom field, custom, field, meta, meta field, repeat, repeatable
5
  Requires at least: 3.9
6
- Tested up to: 4.4-beta3
7
- Stable tag: 1.6.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -37,26 +37,26 @@ https://www.youtube.com/watch?v=WxPZurn0yvI
37
 
38
  = How to get meta data ? =
39
 
40
- * SCF::get( 'field-name' )
41
  This method can get any meta data.
42
- * SCF::get( 'group-name' )
43
  This method can get meta data of any group.
44
 
45
- * SCF::gets()
46
  This method can get all meta data.
47
 
48
- * SCF::get_user_meta( $user_id, 'field-name' )
49
  This method can get any user meta data.
50
- * SCF::get_user_meta( $user_id, 'group-name' )
51
  This method can get user meta data of any group.
52
- * SCF::get_user_meta( $user_id )
53
  This method can get all user meta data.
54
 
55
- * SCF::get_term_meta( $term_id, $taxonomy 'field-name' )
56
  This method can get any term meta data.
57
- * SCF::get_term_meta( $term_id, $taxonomy, 'group-name' )
58
  This method can get term meta data of any group.
59
- * SCF::get_term_meta( $term_id, $taxonomy )
60
  This method can get all term meta data.
61
 
62
  = Register custom fields by the code. =
@@ -86,6 +86,10 @@ You can send your own language pack to me.
86
 
87
  == Changelog ==
88
 
 
 
 
 
89
  = 1.6.4 =
90
  * Fixed a bug that wysiwyg fields became tinymce default format when content editor mode is text.
91
  * Change the comment in English.
3
  Donate link: http://www.amazon.co.jp/registry/wishlist/39ANKRNSTNW40
4
  Tags: plugin, custom field, custom, field, meta, meta field, repeat, repeatable
5
  Requires at least: 3.9
6
+ Tested up to: 4.4
7
+ Stable tag: 1.6.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
37
 
38
  = How to get meta data ? =
39
 
40
+ * SCF::get( 'field-name' )
41
  This method can get any meta data.
42
+ * SCF::get( 'group-name' )
43
  This method can get meta data of any group.
44
 
45
+ * SCF::gets()
46
  This method can get all meta data.
47
 
48
+ * SCF::get_user_meta( $user_id, 'field-name' )
49
  This method can get any user meta data.
50
+ * SCF::get_user_meta( $user_id, 'group-name' )
51
  This method can get user meta data of any group.
52
+ * SCF::get_user_meta( $user_id )
53
  This method can get all user meta data.
54
 
55
+ * SCF::get_term_meta( $term_id, $taxonomy 'field-name' )
56
  This method can get any term meta data.
57
+ * SCF::get_term_meta( $term_id, $taxonomy, 'group-name' )
58
  This method can get term meta data of any group.
59
+ * SCF::get_term_meta( $term_id, $taxonomy )
60
  This method can get all term meta data.
61
 
62
  = Register custom fields by the code. =
86
 
87
  == Changelog ==
88
 
89
+ = 1.6.5 =
90
+ * Fixed a bug that multi value in the loop is broken.
91
+ * In setting screen, if the field is closed, display the field name.
92
+
93
  = 1.6.4 =
94
  * Fixed a bug that wysiwyg fields became tinymce default format when content editor mode is text.
95
  * Change the comment in English.
smart-custom-fields.php CHANGED
@@ -3,11 +3,11 @@
3
  * Plugin name: Smart Custom Fields
4
  * Plugin URI: https://github.com/inc2734/smart-custom-fields/
5
  * Description: Smart Custom Fields is a simple plugin that management custom fields.
6
- * Version: 1.6.4
7
  * Author: inc2734
8
  * Author URI: http://2inc.org
9
  * Created: October 9, 2014
10
- * Modified: Novermber 21, 2015
11
  * Text Domain: smart-custom-fields
12
  * Domain Path: /languages
13
  * License: GPLv2 or later
3
  * Plugin name: Smart Custom Fields
4
  * Plugin URI: https://github.com/inc2734/smart-custom-fields/
5
  * Description: Smart Custom Fields is a simple plugin that management custom fields.
6
+ * Version: 1.6.5
7
  * Author: inc2734
8
  * Author URI: http://2inc.org
9
  * Created: October 9, 2014
10
+ * Modified: January 5, 2016
11
  * Text Domain: smart-custom-fields
12
  * Domain Path: /languages
13
  * License: GPLv2 or later