Smart Custom Fields - Version 4.2.0

Version Description

Download this release

Release Info

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

Code changes from version 4.1.5 to 4.2.0

Files changed (49) hide show
  1. classes/class.config.php +7 -7
  2. classes/class.rest-api.php +25 -10
  3. classes/class.scf.php +231 -228
  4. classes/controller/class.controller-base.php +84 -89
  5. classes/controller/class.editor.php +16 -16
  6. classes/controller/class.option.php +23 -21
  7. classes/controller/class.profile.php +18 -16
  8. classes/controller/class.settings.php +47 -46
  9. classes/controller/class.taxonomy.php +26 -25
  10. classes/fields/class.field-boolean.php +18 -19
  11. classes/fields/class.field-check.php +17 -17
  12. classes/fields/class.field-colorpicker.php +18 -18
  13. classes/fields/class.field-datepicker.php +20 -20
  14. classes/fields/class.field-datetime-picker.php +13 -14
  15. classes/fields/class.field-file.php +20 -24
  16. classes/fields/class.field-image.php +16 -16
  17. classes/fields/class.field-message.php +16 -16
  18. classes/fields/class.field-radio.php +16 -16
  19. classes/fields/class.field-related-posts.php +26 -26
  20. classes/fields/class.field-related-terms.php +26 -26
  21. classes/fields/class.field-select.php +16 -16
  22. classes/fields/class.field-text.php +16 -16
  23. classes/fields/class.field-textarea.php +16 -16
  24. classes/fields/class.field-wysiwyg.php +35 -25
  25. classes/models/class.abstract-field-base.php +58 -40
  26. classes/models/class.ajax.php +14 -14
  27. classes/models/class.cache.php +72 -64
  28. classes/models/class.group.php +28 -28
  29. classes/models/class.meta.php +100 -91
  30. classes/models/class.options-page.php +38 -17
  31. classes/models/class.revisions.php +34 -31
  32. classes/models/class.setting.php +40 -39
  33. classes/models/class.yoast-seo-analysis.php +8 -10
  34. composer.json +32 -0
  35. composer.lock +361 -0
  36. readme.txt +7 -3
  37. smart-custom-fields.php +36 -21
  38. vendor/autoload.php +7 -0
  39. vendor/composer/ClassLoader.php +572 -0
  40. vendor/composer/InstalledVersions.php +337 -0
  41. vendor/composer/LICENSE +21 -0
  42. vendor/composer/autoload_classmap.php +10 -0
  43. vendor/composer/autoload_namespaces.php +9 -0
  44. vendor/composer/autoload_psr4.php +9 -0
  45. vendor/composer/autoload_real.php +57 -0
  46. vendor/composer/autoload_static.php +20 -0
  47. vendor/composer/installed.json +5 -0
  48. vendor/composer/installed.php +23 -0
  49. vendor/composer/platform_check.php +26 -0
classes/class.config.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * SCF_Config
4
- * Version : 1.0.1
5
- * Author : inc2734
6
- * Created : September 23, 2014
7
- * Modified : June 04, 2018
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class SCF_Config {
12
  /**
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * SCF_Config class.
10
  */
11
  class SCF_Config {
12
  /**
classes/class.rest-api.php CHANGED
@@ -1,15 +1,22 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Rest_API
4
- * Version : 1.0.1
5
- * Author : robssanches
6
- * Created : July 14, 2018
7
- * Modified : July 22, 2020
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Rest_API {
12
 
 
 
 
 
 
 
 
13
  /**
14
  * __construct
15
  */
@@ -25,8 +32,8 @@ class Smart_Custom_Fields_Rest_API {
25
  SCF_Config::PREFIX . 'api/v2',
26
  '/search/posts',
27
  array(
28
- 'methods' => 'GET',
29
- 'callback' => array( $this, 'get_all_posts' ),
30
  'permission_callback' => function() {
31
  return current_user_can( 'edit_posts' );
32
  },
@@ -40,7 +47,7 @@ class Smart_Custom_Fields_Rest_API {
40
  public function get_all_posts() {
41
  $all_posts = get_posts(
42
  array(
43
- 'post_type' => array( 'post', 'page' ),
44
  'post_status' => 'publish',
45
  'orderby' => 'date',
46
  'order' => 'ASC',
@@ -59,4 +66,12 @@ class Smart_Custom_Fields_Rest_API {
59
 
60
  return $source;
61
  }
 
 
 
 
 
 
 
 
62
  }
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Rest_API class.
10
  */
11
  class Smart_Custom_Fields_Rest_API {
12
 
13
+ /**
14
+ * Post Type
15
+ *
16
+ * @var array
17
+ */
18
+ protected $post_type = array( 'post', 'page' );
19
+
20
  /**
21
  * __construct
22
  */
32
  SCF_Config::PREFIX . 'api/v2',
33
  '/search/posts',
34
  array(
35
+ 'methods' => 'GET',
36
+ 'callback' => array( $this, 'get_all_posts' ),
37
  'permission_callback' => function() {
38
  return current_user_can( 'edit_posts' );
39
  },
47
  public function get_all_posts() {
48
  $all_posts = get_posts(
49
  array(
50
+ 'post_type' => $this->get_post_type(),
51
  'post_status' => 'publish',
52
  'orderby' => 'date',
53
  'order' => 'ASC',
66
 
67
  return $source;
68
  }
69
+
70
+ /**
71
+ * Get posts type.
72
+ */
73
+ public function get_post_type() {
74
+ $post_type = $this->post_type;
75
+ return apply_filters( SCF_Config::PREFIX . 'rest_api_post_type', $post_type );
76
+ }
77
  }
classes/class.scf.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * SCF
4
- * Version : 2.0.1
5
- * Author : inc2734
6
- * Created : September 23, 2014
7
- * Modified : JAnuary 16, 2017
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class SCF {
12
 
@@ -25,9 +25,9 @@ class SCF {
25
  protected static $options_pages = array();
26
 
27
  /**
28
- * Getting all of the post meta data to feel good
29
  *
30
- * @param int $post_id
31
  * @return array
32
  */
33
  public static function gets( $post_id = null ) {
@@ -46,10 +46,10 @@ class SCF {
46
  }
47
 
48
  /**
49
- * Getting the post meta data to feel good
50
  *
51
- * @param string $name group name or field name
52
- * @param int $post_id
53
  * @return mixed
54
  */
55
  public static function get( $name, $post_id = null ) {
@@ -62,16 +62,16 @@ class SCF {
62
  return;
63
  }
64
 
65
- // Don't output meta data that not save in the SCF settings page
66
  // Getting the settings data, judged to output meta data.
67
  return self::get_meta( get_post( $post_id ), $name );
68
  }
69
 
70
  /**
71
- * Getting the user meta data to feel good
72
  *
73
- * @param int $user_id
74
- * @param string $name group name or field name
75
  * @return mixed
76
  */
77
  public static function get_user_meta( $user_id, $name = null ) {
@@ -80,7 +80,7 @@ class SCF {
80
  }
81
 
82
  // If $name is null, return the all meta data.
83
- if ( $name === null ) {
84
  return self::get_all_meta( get_userdata( $user_id ) );
85
  }
86
 
@@ -90,11 +90,11 @@ class SCF {
90
  }
91
 
92
  /**
93
- * Getting the term meta data to feel good
94
  *
95
- * @param int $term_id
96
- * @param string $taxonomy_name
97
- * @param string $name group name or field name
98
  * @return mixed
99
  */
100
  public static function get_term_meta( $term_id, $taxonomy_name, $name = null ) {
@@ -103,7 +103,7 @@ class SCF {
103
  }
104
 
105
  // If $name is null, return the all meta data.
106
- if ( $name === null ) {
107
  return self::get_all_meta( get_term( $term_id, $taxonomy_name ) );
108
  }
109
 
@@ -113,10 +113,10 @@ class SCF {
113
  }
114
 
115
  /**
116
- * Getting the custom options page meta data to feel good
117
  *
118
- * @param string $menu_slug custom options page slug
119
- * @param string $name group name or field name
120
  * @return mixed
121
  */
122
  public static function get_option_meta( $menu_slug, $name = null ) {
@@ -128,52 +128,52 @@ class SCF {
128
  return;
129
  }
130
 
131
- $Option = self::generate_option_object( $menu_slug );
132
 
133
  // If $name is null, return the all meta data.
134
- if ( $name === null ) {
135
- return self::get_all_meta( $Option );
136
  }
137
 
138
  // Don't output meta data that not save in the SCF settings page
139
  // Getting the settings data, judged to output meta data.
140
- return self::get_meta( $Option, $name );
141
  }
142
 
143
  /**
144
- * Getting any meta data to feel good
145
  *
146
- * @param WP_Post|WP_User|WP_Term|stdClass $object
147
- * @param string $name group name or field name
148
  * @return mixed
149
  */
150
  protected static function get_meta( $object, $name ) {
151
- $Cache = Smart_Custom_Fields_Cache::getInstance();
152
- if ( $Cache->get_meta( $object, $name ) ) {
153
  self::debug_cache_message( "use get cache. [name: {$name}]" );
154
- return $Cache->get_meta( $object, $name );
155
  } else {
156
  self::debug_cache_message( "dont use get cache... [name: {$name}]" );
157
  }
158
 
159
  $settings = self::get_settings( $object );
160
- foreach ( $settings as $Setting ) {
161
  // If $name matches the group name, returns fields in the group as array.
162
- $Group = $Setting->get_group( $name );
163
- if ( $Group ) {
164
- $values_by_group = self::get_values_by_group( $object, $Group );
165
- $Cache->save_meta( $object, $name, $values_by_group );
166
  return $values_by_group;
167
  }
168
 
169
  // If $name doesn't matche the group name, returns the field that matches.
170
- $groups = $Setting->get_groups();
171
- foreach ( $groups as $Group ) {
172
- $Field = $Group->get_field( $name );
173
- if ( $Field ) {
174
- $is_repeatable = $Group->is_repeatable();
175
- $value_by_field = self::get_value_by_field( $object, $Field, $is_repeatable );
176
- $Cache->save_meta( $object, $name, $value_by_field );
177
  return $value_by_field;
178
  }
179
  }
@@ -181,30 +181,30 @@ class SCF {
181
  }
182
 
183
  /**
184
- * Getting all of any meta data to feel good
185
  *
186
- * @param WP_Post|WP_User|WP_Term|stdClass $object
187
  * @return mixed
188
  */
189
  protected static function get_all_meta( $object ) {
190
- $Cache = Smart_Custom_Fields_Cache::getInstance();
191
  $settings = self::get_settings( $object );
192
  $post_meta = array();
193
- foreach ( $settings as $Setting ) {
194
- $groups = $Setting->get_groups();
195
- foreach ( $groups as $Group ) {
196
- $is_repeatable = $Group->is_repeatable();
197
- $group_name = $Group->get_name();
198
  if ( $is_repeatable && $group_name ) {
199
- $values_by_group = self::get_values_by_group( $object, $Group );
200
- $Cache->save_meta( $object, $group_name, $values_by_group );
201
  $post_meta[ $group_name ] = $values_by_group;
202
  } else {
203
- $fields = $Group->get_fields();
204
- foreach ( $fields as $Field ) {
205
- $field_name = $Field->get( 'name' );
206
- $value_by_field = self::get_value_by_field( $object, $Field, $is_repeatable );
207
- $Cache->save_meta( $object, $field_name, $value_by_field );
208
  $post_meta[ $field_name ] = $value_by_field;
209
  }
210
  }
@@ -214,9 +214,9 @@ class SCF {
214
  }
215
 
216
  /**
217
- * If in preview, return the preview post ID
218
  *
219
- * @param int $post_id
220
  * @return int
221
  */
222
  protected static function get_real_post_id( $post_id ) {
@@ -230,30 +230,30 @@ class SCF {
230
  }
231
 
232
  /**
233
- * Getting the meta data of the group
234
- * When group, Note the point that returned data are repetition
235
  *
236
- * @param WP_Post|WP_User|WP_Term|stdClass $object
237
- * @param Smart_Custom_Fields_Group $Group
238
  * @return mixed
239
  */
240
- protected static function get_values_by_group( $object, $Group ) {
241
- $is_repeatable = $Group->is_repeatable();
242
- $meta = array();
243
- $fields = $Group->get_fields();
244
- $value_by_fields = array();
245
- foreach ( $fields as $Field ) {
246
- if ( $Field->get_attribute( 'allow-multiple-data' ) ) {
247
- $meta[0][ $Field->get( 'name' ) ] = array();
248
  } else {
249
- $meta[0][ $Field->get( 'name' ) ] = '';
250
  }
251
  }
252
  $default_meta = $meta[0];
253
- foreach ( $fields as $Field ) {
254
- $value_by_field = self::get_value_by_field( $object, $Field, $is_repeatable );
255
  foreach ( $value_by_field as $i => $value ) {
256
- $meta[ $i ][ $Field->get( 'name' ) ] = $value;
257
  }
258
  }
259
  foreach ( $meta as $i => $value ) {
@@ -263,77 +263,77 @@ class SCF {
263
  }
264
 
265
  /**
266
- * Getting the meta data of the field
267
  *
268
- * @param WP_Post|WP_User|WP_Term|stdClass $object
269
- * @param array $field
270
- * @param bool $is_repeatable Whether the group that this field belongs is repetition
271
  * @return mixed $post_meta
272
  */
273
- protected static function get_value_by_field( $object, $Field, $is_repeatable ) {
274
- $field_name = $Field->get( 'name' );
275
  if ( ! $field_name ) {
276
  return;
277
  }
278
 
279
- $Meta = new Smart_Custom_Fields_Meta( $object );
280
 
281
  // In the case of multi-value items in the loop
282
- $field_type = $Field->get_attribute( 'type' );
283
  $repeat_multiple_data = self::get_repeat_multiple_data( $object );
284
  if ( is_array( $repeat_multiple_data ) && isset( $repeat_multiple_data[ $field_name ] ) ) {
285
- if ( $Meta->is_saved_the_key( $field_name ) ) {
286
- $_meta = $Meta->get( $field_name );
287
  } else {
288
- $_meta = self::get_default_value( $Field );
289
  }
290
- $start = 0;
 
291
  foreach ( $repeat_multiple_data[ $field_name ] as $repeat_multiple_key => $repeat_multiple_value ) {
292
- if ( $repeat_multiple_value === 0 ) {
293
  $value = array();
294
  } else {
295
  $value = array_slice( $_meta, $start, $repeat_multiple_value );
296
  $start += $repeat_multiple_value;
297
  }
298
- $value = apply_filters( SCF_Config::PREFIX . 'validate-get-value', $value, $field_type );
299
- $meta[ $repeat_multiple_key ] = $value;
300
  }
301
- }
302
- // Other than that
303
- else {
304
  $single = true;
305
- if ( $Field->get_attribute( 'allow-multiple-data' ) || $is_repeatable ) {
306
  $single = false;
307
  }
308
- if ( $Meta->is_saved_the_key( $field_name ) ) {
309
- $meta = $Meta->get( $field_name, $single );
310
  } else {
311
- $meta = self::get_default_value( $Field, $single );
312
  }
313
- $meta = apply_filters( SCF_Config::PREFIX . 'validate-get-value', $meta, $field_type );
314
  }
315
- return $meta;
316
  }
317
 
318
  /**
319
- * Return the default value
320
  *
321
- * @param Smart_Custom_Fields_Field_Base $Field
322
- * @param bool $single
323
  * @return array|strings
324
  */
325
- public static function get_default_value( $Field, $single = false ) {
326
- if ( ! is_a( $Field, 'Smart_Custom_Fields_Field_Base' ) ) {
327
  if ( $single ) {
328
  return '';
329
  }
330
  return array();
331
  }
332
 
333
- $choices = $Field->get( 'choices' );
334
- $default = $Field->get( 'default' );
335
 
336
- if ( $Field->get_attribute( 'allow-multiple-data' ) ) {
337
  $choices = self::choices_eol_to_array( $choices );
338
  $default = self::choices_eol_to_array( $default );
339
  $default_sanitized = array();
@@ -344,7 +344,7 @@ class SCF {
344
  $_choices = $choices;
345
  }
346
  foreach ( $default as $key => $value ) {
347
- if ( in_array( $value, $_choices ) ) {
348
  if ( preg_match( '/^\d+$/', $value ) ) {
349
  $value = (int) $value;
350
  }
@@ -354,16 +354,15 @@ class SCF {
354
  return $default_sanitized;
355
  }
356
 
357
- // Return string
358
  if ( $single ) {
 
359
  return $default;
360
- }
361
- // Return array
362
- else {
363
  if ( is_array( $default ) ) {
364
  return $default;
365
  }
366
- if ( $default === '' || $default === false || $default === null ) {
367
  return array();
368
  }
369
  return (array) $default;
@@ -373,23 +372,23 @@ class SCF {
373
  /**
374
  * Getting enabled custom field settings in the post type or the role or the term.
375
  *
376
- * @param WP_Post|WP_User|WP_Term|stdClass $object
377
- * @return array $settings
378
  */
379
  public static function get_settings_posts( $object ) {
380
- $Cache = Smart_Custom_Fields_Cache::getInstance();
381
  $settings_posts = array();
382
- if ( $Cache->get_settings_posts( $object ) !== null ) {
383
  self::debug_cache_message( 'use settings posts cache.' );
384
- return $Cache->get_settings_posts( $object );
385
  } else {
386
  self::debug_cache_message( 'dont use settings posts cache...' );
387
  }
388
 
389
- $Meta = new Smart_Custom_Fields_Meta( $object );
390
- $types = $Meta->get_types( false );
391
 
392
- switch ( $Meta->get_meta_type() ) {
393
  case 'post':
394
  $key = SCF_Config::PREFIX . 'condition';
395
  break;
@@ -430,28 +429,28 @@ class SCF {
430
  $settings_posts = get_posts( $args );
431
  }
432
 
433
- $Cache = Smart_Custom_Fields_Cache::getInstance();
434
- $Cache->save_settings_posts( $object, $settings_posts );
435
  return $settings_posts;
436
  }
437
 
438
  /**
439
- * Getting array of the Setting object
440
  *
441
- * @param WP_Post|WP_User|WP_Term|Smart_Custom_Fields_Options_Mock $object
442
- * @return array $settings
443
  */
444
  public static function get_settings( $object ) {
445
- $Meta = new Smart_Custom_Fields_Meta( $object );
446
- $id = $Meta->get_id();
447
- $type = $Meta->get_type( false );
448
- $types = $Meta->get_types( false );
449
- $meta_type = $Meta->get_meta_type();
450
 
451
  // IF the post that has custom field settings according to post ID,
452
  // don't display because the post ID would change in preview.
453
  // So if in preview, re-getting post ID from original post (parent of the preview).
454
- if ( $meta_type === 'post' && $object->post_type === 'revision' ) {
455
  $object = get_post( $object->post_parent );
456
  }
457
 
@@ -459,13 +458,13 @@ class SCF {
459
 
460
  if ( ! empty( $types ) ) {
461
  $settings_posts = self::get_settings_posts( $object );
462
- if ( $meta_type === 'post' ) {
463
  $settings = self::get_settings_for_post( $object, $settings_posts );
464
- } elseif ( $meta_type === 'user' ) {
465
  $settings = self::get_settings_for_profile( $object, $settings_posts );
466
- } elseif ( $meta_type === 'term' ) {
467
  $settings = self::get_settings_for_term( $object, $settings_posts );
468
- } elseif ( $meta_type === 'option' ) {
469
  $settings = self::get_settings_for_option( $object, $settings_posts );
470
  }
471
  }
@@ -484,21 +483,21 @@ class SCF {
484
  }
485
 
486
  /**
487
- * Getting the Setting object for post
488
  *
489
- * @param WP_Post $object
490
- * @param array $settings_posts
491
  * @return array
492
  */
493
  protected static function get_settings_for_post( $object, $settings_posts ) {
494
- $Cache = Smart_Custom_Fields_Cache::getInstance();
495
  $settings = array();
496
  foreach ( $settings_posts as $settings_post ) {
497
- if ( $Cache->get_settings( $settings_post->ID ) !== null ) {
498
  self::debug_cache_message( "use settings cache. [id: {$settings_post->ID}]" );
499
- $Setting = $Cache->get_settings( $settings_post->ID, $object );
500
- if ( $Setting ) {
501
- $settings[ $settings_post->ID ] = $Setting;
502
  }
503
  continue;
504
  }
@@ -512,54 +511,54 @@ class SCF {
512
  $condition_post_ids_raw = explode( ',', $condition_post_ids_raw );
513
  foreach ( $condition_post_ids_raw as $condition_post_id ) {
514
  $condition_post_id = trim( $condition_post_id );
515
- $Setting = self::add_setting( $settings_post->ID, $settings_post->post_title );
516
- if ( $object->ID == $condition_post_id ) {
517
- $settings[ $settings_post->ID ] = $Setting;
518
  }
519
- $Post = get_post( $condition_post_id );
520
- if ( empty( $Post ) ) {
521
- $Post = self::generate_post_object( $condition_post_id );
522
  }
523
- $Cache->save_settings( $settings_post->ID, $Setting, $Post );
524
  }
525
  } else {
526
- $Setting = self::add_setting( $settings_post->ID, $settings_post->post_title );
527
- $settings[ $settings_post->ID ] = $Setting;
528
- $Cache->save_settings( $settings_post->ID, $Setting );
529
  }
530
  }
531
  return $settings;
532
  }
533
 
534
  /**
535
- * Getting the Setting object for user
536
  *
537
- * @param WP_User $object
538
- * @param array $settings_posts
539
  * @return array
540
  */
541
  protected static function get_settings_for_profile( $object, $settings_posts ) {
542
- $Cache = Smart_Custom_Fields_Cache::getInstance();
543
  $settings = array();
544
  foreach ( $settings_posts as $settings_post ) {
545
- if ( $Cache->get_settings( $settings_post->ID ) !== null ) {
546
  self::debug_cache_message( "use settings cache. [id: {$settings_post->ID}]" );
547
- $settings[] = $Cache->get_settings( $settings_post->ID );
548
  continue;
549
  }
550
  self::debug_cache_message( "dont use settings cache... [id: {$settings_post->ID}]" );
551
- $Setting = self::add_setting( $settings_post->ID, $settings_post->post_title );
552
- $settings[] = $Setting;
553
- $Cache->save_settings( $settings_post->ID, $Setting );
554
  }
555
  return $settings;
556
  }
557
 
558
  /**
559
- * Getting the Setting object for term
560
  *
561
- * @param WP_Term $object
562
- * @param array $settings_posts
563
  * @return array
564
  */
565
  protected static function get_settings_for_term( $object, $settings_posts ) {
@@ -567,10 +566,10 @@ class SCF {
567
  }
568
 
569
  /**
570
- * Getting the Setting object for option
571
  *
572
- * @param WP_Term $object
573
- * @param array $settings_posts
574
  * @return array
575
  */
576
  protected static function get_settings_for_option( $object, $settings_posts ) {
@@ -578,37 +577,37 @@ class SCF {
578
  }
579
 
580
  /**
581
- * Getting delimited identification data of the repeated multi-value items
582
  *
583
- * @param WP_Post|WP_User|WP_Term|stdClass $object
584
  * @return array
585
  */
586
  public static function get_repeat_multiple_data( $object ) {
587
- $Cache = Smart_Custom_Fields_Cache::getInstance();
588
  $repeat_multiple_data = array();
589
- if ( $Cache->get_repeat_multiple_data( $object ) ) {
590
- return $Cache->get_repeat_multiple_data( $object );
591
  }
592
 
593
- $Meta = new Smart_Custom_Fields_Meta( $object );
594
- $_repeat_multiple_data = $Meta->get( SCF_Config::PREFIX . 'repeat-multiple-data', true );
595
  if ( ! empty( $_repeat_multiple_data ) ) {
596
  $repeat_multiple_data = $_repeat_multiple_data;
597
  }
598
 
599
- $Cache->save_repeat_multiple_data( $object, $repeat_multiple_data );
600
  return $repeat_multiple_data;
601
  }
602
 
603
  /**
604
- * Return true if null or empty value
605
  *
606
- * @param mixed $value
607
  * @return bool
608
  */
609
  public static function is_empty( &$value ) {
610
  if ( isset( $value ) ) {
611
- if ( is_null( $value ) || $value === '' ) {
612
  return true;
613
  }
614
  return false;
@@ -617,11 +616,12 @@ class SCF {
617
  }
618
 
619
  /**
620
- * Whether the associative array or not
621
  *
622
  * @see http://qiita.com/ka215/items/a14e53547e717d2a564f
623
- * @param array $data This argument should be expected an array
624
- * @param boolean $multidimensional True if a multidimensional array is inclusion into associative array, the default value is false
 
625
  * @return boolean
626
  */
627
  public static function is_assoc( $data, $multidimensional = false ) {
@@ -642,9 +642,9 @@ class SCF {
642
  }
643
 
644
  /**
645
- * Adding the available form field object
646
  *
647
- * @param Smart_Custom_Fields_Field_Base $instance
648
  */
649
  public static function add_form_field_instance( Smart_Custom_Fields_Field_Base $instance ) {
650
  $type = $instance->get_attribute( 'type' );
@@ -654,10 +654,10 @@ class SCF {
654
  }
655
 
656
  /**
657
- * Getting the available form field object
658
  *
659
- * @param string $type type of the form field
660
- * @param Smart_Custom_Fields_Field_Base
661
  */
662
  public static function get_form_field_instance( $type ) {
663
  if ( ! empty( self::$fields[ $type ] ) ) {
@@ -666,7 +666,7 @@ class SCF {
666
  }
667
 
668
  /**
669
- * Getting all available form field object
670
  *
671
  * @return array
672
  */
@@ -679,17 +679,17 @@ class SCF {
679
  }
680
 
681
  /**
682
- * Getting custom fields that saved custo field settings page
683
- * Note that not return only one even define multiple fields with the same name of the field name
684
  *
685
- * @param WP_Post|WP_User|WP_Term|stdClass $object
686
- * @param string $field_name
687
  * @return Smart_Custom_Fields_Field_Base|null
688
  */
689
  public static function get_field( $object, $field_name ) {
690
  $settings = self::get_settings( $object );
691
- foreach ( $settings as $Setting ) {
692
- $fields = $Setting->get_fields();
693
  if ( ! empty( $fields[ $field_name ] ) ) {
694
  return $fields[ $field_name ];
695
  }
@@ -697,14 +697,14 @@ class SCF {
697
  }
698
 
699
  /**
700
- * Convert to array from newline delimiter $choices
701
  *
702
- * @param string $choices
703
  * @return array
704
  */
705
  public static function choices_eol_to_array( $choices ) {
706
  if ( ! is_array( $choices ) ) {
707
- if ( $choices === '' || $choices === false || $choices === null ) {
708
  return array();
709
  }
710
  $_choices = str_replace( array( "\r\n", "\r", "\n" ), "\n", $choices );
@@ -723,10 +723,10 @@ class SCF {
723
  }
724
 
725
  /**
726
- * Return generated Setting object
727
  *
728
- * @param string $id
729
- * @param string $title
730
  * @return Smart_Custom_Fields_Setting
731
  */
732
  public static function add_setting( $id, $title ) {
@@ -734,16 +734,17 @@ class SCF {
734
  }
735
 
736
  /**
737
- * Adding custom options page
738
  *
739
  * @see https://developer.wordpress.org/reference/functions/add_menu_page/
740
- * @param string $page_title
741
- * @param string $menu_title
742
- * @param string $capability
743
- * @param string $menu_slug
744
- * @param string $icon_url
745
- * @param int $position
746
- * @return $menu_slug
 
747
  */
748
  public static function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $icon_url = '', $position = null ) {
749
  self::$options_pages[ $menu_slug ] = $menu_title;
@@ -761,23 +762,23 @@ class SCF {
761
  }
762
 
763
  /**
764
- * Generate WP_Post object
765
  *
766
- * @param int $post_id
767
- * @param string $post_type
768
  * @return WP_Post
769
  */
770
  public static function generate_post_object( $post_id, $post_type = null ) {
771
- $Post = new stdClass();
772
- $Post->ID = $post_id;
773
- $Post->post_type = $post_type;
774
- return new WP_Post( $Post );
775
  }
776
 
777
  /**
778
- * Generate option object
779
  *
780
- * @param string $menu_slug
781
  * @return stdClass
782
  */
783
  public static function generate_option_object( $menu_slug ) {
@@ -785,14 +786,16 @@ class SCF {
785
  if ( ! isset( $options_pages[ $menu_slug ] ) ) {
786
  return;
787
  }
788
- $Option = new stdClass();
789
- $Option->menu_slug = $menu_slug;
790
- $Option->menu_title = $options_pages[ $menu_slug ];
791
- return $Option;
792
  }
793
 
794
  /**
795
- * Print cache usage
 
 
796
  */
797
  protected static function debug_cache_message( $message ) {
798
  if ( defined( 'SCF_DEBUG_CACHE' ) && SCF_DEBUG_CACHE === true ) {
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * SCF class.
10
  */
11
  class SCF {
12
 
25
  protected static $options_pages = array();
26
 
27
  /**
28
+ * Getting all of the post meta data to feel good.
29
  *
30
+ * @param int $post_id Post id.
31
  * @return array
32
  */
33
  public static function gets( $post_id = null ) {
46
  }
47
 
48
  /**
49
+ * Getting the post meta data to feel good.
50
  *
51
+ * @param string $name Group name or field name.
52
+ * @param int $post_id Post id.
53
  * @return mixed
54
  */
55
  public static function get( $name, $post_id = null ) {
62
  return;
63
  }
64
 
65
+ // Don't output meta data that not save in the SCF settings page.
66
  // Getting the settings data, judged to output meta data.
67
  return self::get_meta( get_post( $post_id ), $name );
68
  }
69
 
70
  /**
71
+ * Getting the user meta data to feel good.
72
  *
73
+ * @param int $user_id User id.
74
+ * @param string $name Group name or field name.
75
  * @return mixed
76
  */
77
  public static function get_user_meta( $user_id, $name = null ) {
80
  }
81
 
82
  // If $name is null, return the all meta data.
83
+ if ( null === $name ) {
84
  return self::get_all_meta( get_userdata( $user_id ) );
85
  }
86
 
90
  }
91
 
92
  /**
93
+ * Getting the term meta data to feel good.
94
  *
95
+ * @param int $term_id Term id.
96
+ * @param string $taxonomy_name Taxonomy name.
97
+ * @param string $name Group name or field name.
98
  * @return mixed
99
  */
100
  public static function get_term_meta( $term_id, $taxonomy_name, $name = null ) {
103
  }
104
 
105
  // If $name is null, return the all meta data.
106
+ if ( null === $name ) {
107
  return self::get_all_meta( get_term( $term_id, $taxonomy_name ) );
108
  }
109
 
113
  }
114
 
115
  /**
116
+ * Getting the custom options page meta data to feel good.
117
  *
118
+ * @param string $menu_slug custom options page slug.
119
+ * @param string $name group name or field name.
120
  * @return mixed
121
  */
122
  public static function get_option_meta( $menu_slug, $name = null ) {
128
  return;
129
  }
130
 
131
+ $option = self::generate_option_object( $menu_slug );
132
 
133
  // If $name is null, return the all meta data.
134
+ if ( null === $name ) {
135
+ return self::get_all_meta( $option );
136
  }
137
 
138
  // Don't output meta data that not save in the SCF settings page
139
  // Getting the settings data, judged to output meta data.
140
+ return self::get_meta( $option, $name );
141
  }
142
 
143
  /**
144
+ * Getting any meta data to feel good.
145
  *
146
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object meta object.
147
+ * @param string $name Group name or field name.
148
  * @return mixed
149
  */
150
  protected static function get_meta( $object, $name ) {
151
+ $cache = Smart_Custom_Fields_Cache::get_instance();
152
+ if ( $cache->get_meta( $object, $name ) ) {
153
  self::debug_cache_message( "use get cache. [name: {$name}]" );
154
+ return $cache->get_meta( $object, $name );
155
  } else {
156
  self::debug_cache_message( "dont use get cache... [name: {$name}]" );
157
  }
158
 
159
  $settings = self::get_settings( $object );
160
+ foreach ( $settings as $setting ) {
161
  // If $name matches the group name, returns fields in the group as array.
162
+ $group = $setting->get_group( $name );
163
+ if ( $group ) {
164
+ $values_by_group = self::get_values_by_group( $object, $group );
165
+ $cache->save_meta( $object, $name, $values_by_group );
166
  return $values_by_group;
167
  }
168
 
169
  // If $name doesn't matche the group name, returns the field that matches.
170
+ $groups = $setting->get_groups();
171
+ foreach ( $groups as $group ) {
172
+ $field = $group->get_field( $name );
173
+ if ( $field ) {
174
+ $is_repeatable = $group->is_repeatable();
175
+ $value_by_field = self::get_value_by_field( $object, $field, $is_repeatable );
176
+ $cache->save_meta( $object, $name, $value_by_field );
177
  return $value_by_field;
178
  }
179
  }
181
  }
182
 
183
  /**
184
+ * Getting all of any meta data to feel good.
185
  *
186
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object meta object.
187
  * @return mixed
188
  */
189
  protected static function get_all_meta( $object ) {
190
+ $cache = Smart_Custom_Fields_Cache::get_instance();
191
  $settings = self::get_settings( $object );
192
  $post_meta = array();
193
+ foreach ( $settings as $setting ) {
194
+ $groups = $setting->get_groups();
195
+ foreach ( $groups as $group ) {
196
+ $is_repeatable = $group->is_repeatable();
197
+ $group_name = $group->get_name();
198
  if ( $is_repeatable && $group_name ) {
199
+ $values_by_group = self::get_values_by_group( $object, $group );
200
+ $cache->save_meta( $object, $group_name, $values_by_group );
201
  $post_meta[ $group_name ] = $values_by_group;
202
  } else {
203
+ $fields = $group->get_fields();
204
+ foreach ( $fields as $field ) {
205
+ $field_name = $field->get( 'name' );
206
+ $value_by_field = self::get_value_by_field( $object, $field, $is_repeatable );
207
+ $cache->save_meta( $object, $field_name, $value_by_field );
208
  $post_meta[ $field_name ] = $value_by_field;
209
  }
210
  }
214
  }
215
 
216
  /**
217
+ * If in preview, return the preview post ID.
218
  *
219
+ * @param int $post_id Post id.
220
  * @return int
221
  */
222
  protected static function get_real_post_id( $post_id ) {
230
  }
231
 
232
  /**
233
+ * Getting the meta data of the group.
234
+ * When group, Note the point that returned data are repetition.
235
  *
236
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object meta object.
237
+ * @param Smart_Custom_Fields_Group $group Group object.
238
  * @return mixed
239
  */
240
+ protected static function get_values_by_group( $object, $group ) {
241
+ $is_repeatable = $group->is_repeatable();
242
+ $meta = array();
243
+ $fields = $group->get_fields();
244
+
245
+ foreach ( $fields as $field ) {
246
+ if ( $field->get_attribute( 'allow-multiple-data' ) ) {
247
+ $meta[0][ $field->get( 'name' ) ] = array();
248
  } else {
249
+ $meta[0][ $field->get( 'name' ) ] = '';
250
  }
251
  }
252
  $default_meta = $meta[0];
253
+ foreach ( $fields as $field ) {
254
+ $value_by_field = self::get_value_by_field( $object, $field, $is_repeatable );
255
  foreach ( $value_by_field as $i => $value ) {
256
+ $meta[ $i ][ $field->get( 'name' ) ] = $value;
257
  }
258
  }
259
  foreach ( $meta as $i => $value ) {
263
  }
264
 
265
  /**
266
+ * Getting the meta data of the field.
267
  *
268
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object meta object.
269
+ * @param Smart_Custom_Fields_Field_Base $field Field object.
270
+ * @param bool $is_repeatable Whether the group that this field belongs is repetition.
271
  * @return mixed $post_meta
272
  */
273
+ protected static function get_value_by_field( $object, $field, $is_repeatable ) {
274
+ $field_name = $field->get( 'name' );
275
  if ( ! $field_name ) {
276
  return;
277
  }
278
 
279
+ $meta = new Smart_Custom_Fields_Meta( $object );
280
 
281
  // In the case of multi-value items in the loop
282
+ $field_type = $field->get_attribute( 'type' );
283
  $repeat_multiple_data = self::get_repeat_multiple_data( $object );
284
  if ( is_array( $repeat_multiple_data ) && isset( $repeat_multiple_data[ $field_name ] ) ) {
285
+ if ( $meta->is_saved_the_key( $field_name ) ) {
286
+ $_meta = $meta->get( $field_name );
287
  } else {
288
+ $_meta = self::get_default_value( $field );
289
  }
290
+ $start = 0;
291
+ $meta_value = [];
292
  foreach ( $repeat_multiple_data[ $field_name ] as $repeat_multiple_key => $repeat_multiple_value ) {
293
+ if ( 0 === $repeat_multiple_value ) {
294
  $value = array();
295
  } else {
296
  $value = array_slice( $_meta, $start, $repeat_multiple_value );
297
  $start += $repeat_multiple_value;
298
  }
299
+ $value = apply_filters( SCF_Config::PREFIX . 'validate-get-value', $value, $field_type );
300
+ $meta_value[ $repeat_multiple_key ] = $value;
301
  }
302
+ } else {
303
+ // Other than that
 
304
  $single = true;
305
+ if ( $field->get_attribute( 'allow-multiple-data' ) || $is_repeatable ) {
306
  $single = false;
307
  }
308
+ if ( $meta->is_saved_the_key( $field_name ) ) {
309
+ $meta_value = $meta->get( $field_name, $single );
310
  } else {
311
+ $meta_value = self::get_default_value( $field, $single );
312
  }
313
+ $meta_value = apply_filters( SCF_Config::PREFIX . 'validate-get-value', $meta_value, $field_type );
314
  }
315
+ return $meta_value;
316
  }
317
 
318
  /**
319
+ * Return the default value.
320
  *
321
+ * @param Smart_Custom_Fields_Field_Base $field Field object.
322
+ * @param bool $single Whether to return a single value. This parameter has no effect if $key is not specified.
323
  * @return array|strings
324
  */
325
+ public static function get_default_value( $field, $single = false ) {
326
+ if ( ! is_a( $field, 'Smart_Custom_Fields_Field_Base' ) ) {
327
  if ( $single ) {
328
  return '';
329
  }
330
  return array();
331
  }
332
 
333
+ $choices = $field->get( 'choices' );
334
+ $default = $field->get( 'default' );
335
 
336
+ if ( $field->get_attribute( 'allow-multiple-data' ) ) {
337
  $choices = self::choices_eol_to_array( $choices );
338
  $default = self::choices_eol_to_array( $default );
339
  $default_sanitized = array();
344
  $_choices = $choices;
345
  }
346
  foreach ( $default as $key => $value ) {
347
+ if ( in_array( $value, $_choices, true ) ) {
348
  if ( preg_match( '/^\d+$/', $value ) ) {
349
  $value = (int) $value;
350
  }
354
  return $default_sanitized;
355
  }
356
 
 
357
  if ( $single ) {
358
+ // Return string
359
  return $default;
360
+ } else {
361
+ // Return array
 
362
  if ( is_array( $default ) ) {
363
  return $default;
364
  }
365
+ if ( '' === $default || false === $default || null === $default ) {
366
  return array();
367
  }
368
  return (array) $default;
372
  /**
373
  * Getting enabled custom field settings in the post type or the role or the term.
374
  *
375
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object meta object.
376
+ * @return array
377
  */
378
  public static function get_settings_posts( $object ) {
379
+ $cache = Smart_Custom_Fields_Cache::get_instance();
380
  $settings_posts = array();
381
+ if ( null !== $cache->get_settings_posts( $object ) ) {
382
  self::debug_cache_message( 'use settings posts cache.' );
383
+ return $cache->get_settings_posts( $object );
384
  } else {
385
  self::debug_cache_message( 'dont use settings posts cache...' );
386
  }
387
 
388
+ $meta = new Smart_Custom_Fields_Meta( $object );
389
+ $types = $meta->get_types( false );
390
 
391
+ switch ( $meta->get_meta_type() ) {
392
  case 'post':
393
  $key = SCF_Config::PREFIX . 'condition';
394
  break;
429
  $settings_posts = get_posts( $args );
430
  }
431
 
432
+ $cache = Smart_Custom_Fields_Cache::get_instance();
433
+ $cache->save_settings_posts( $object, $settings_posts );
434
  return $settings_posts;
435
  }
436
 
437
  /**
438
+ * Getting array of the Setting object.
439
  *
440
+ * @param WP_Post|WP_User|WP_Term|Smart_Custom_Fields_Options_Mock $object Object meta object.
441
+ * @return array
442
  */
443
  public static function get_settings( $object ) {
444
+ $meta = new Smart_Custom_Fields_Meta( $object );
445
+ $id = $meta->get_id();
446
+ $type = $meta->get_type( false );
447
+ $types = $meta->get_types( false );
448
+ $meta_type = $meta->get_meta_type();
449
 
450
  // IF the post that has custom field settings according to post ID,
451
  // don't display because the post ID would change in preview.
452
  // So if in preview, re-getting post ID from original post (parent of the preview).
453
+ if ( 'post' === $meta_type && 'revision' === $object->post_type ) {
454
  $object = get_post( $object->post_parent );
455
  }
456
 
458
 
459
  if ( ! empty( $types ) ) {
460
  $settings_posts = self::get_settings_posts( $object );
461
+ if ( 'post' === $meta_type ) {
462
  $settings = self::get_settings_for_post( $object, $settings_posts );
463
+ } elseif ( 'user' === $meta_type ) {
464
  $settings = self::get_settings_for_profile( $object, $settings_posts );
465
+ } elseif ( 'term' === $meta_type ) {
466
  $settings = self::get_settings_for_term( $object, $settings_posts );
467
+ } elseif ( 'option' === $meta_type ) {
468
  $settings = self::get_settings_for_option( $object, $settings_posts );
469
  }
470
  }
483
  }
484
 
485
  /**
486
+ * Getting the Setting object for post.
487
  *
488
+ * @param WP_Term $object WP_Term object.
489
+ * @param array $settings_posts Settings.
490
  * @return array
491
  */
492
  protected static function get_settings_for_post( $object, $settings_posts ) {
493
+ $cache = Smart_Custom_Fields_Cache::get_instance();
494
  $settings = array();
495
  foreach ( $settings_posts as $settings_post ) {
496
+ if ( $cache->get_settings( $settings_post->ID ) !== null ) {
497
  self::debug_cache_message( "use settings cache. [id: {$settings_post->ID}]" );
498
+ $setting = $cache->get_settings( $settings_post->ID, $object );
499
+ if ( $setting ) {
500
+ $settings[ $settings_post->ID ] = $setting;
501
  }
502
  continue;
503
  }
511
  $condition_post_ids_raw = explode( ',', $condition_post_ids_raw );
512
  foreach ( $condition_post_ids_raw as $condition_post_id ) {
513
  $condition_post_id = trim( $condition_post_id );
514
+ $setting = self::add_setting( $settings_post->ID, $settings_post->post_title );
515
+ if ( (int) $object->ID === (int) $condition_post_id ) {
516
+ $settings[ $settings_post->ID ] = $setting;
517
  }
518
+ $post = get_post( $condition_post_id );
519
+ if ( empty( $post ) ) {
520
+ $post = self::generate_post_object( $condition_post_id );
521
  }
522
+ $cache->save_settings( $settings_post->ID, $setting, $post );
523
  }
524
  } else {
525
+ $setting = self::add_setting( $settings_post->ID, $settings_post->post_title );
526
+ $settings[ $settings_post->ID ] = $setting;
527
+ $cache->save_settings( $settings_post->ID, $setting );
528
  }
529
  }
530
  return $settings;
531
  }
532
 
533
  /**
534
+ * Getting the Setting object for user.
535
  *
536
+ * @param WP_Term $object WP_Term object.
537
+ * @param array $settings_posts Settings.
538
  * @return array
539
  */
540
  protected static function get_settings_for_profile( $object, $settings_posts ) {
541
+ $cache = Smart_Custom_Fields_Cache::get_instance();
542
  $settings = array();
543
  foreach ( $settings_posts as $settings_post ) {
544
+ if ( $cache->get_settings( $settings_post->ID ) !== null ) {
545
  self::debug_cache_message( "use settings cache. [id: {$settings_post->ID}]" );
546
+ $settings[] = $cache->get_settings( $settings_post->ID );
547
  continue;
548
  }
549
  self::debug_cache_message( "dont use settings cache... [id: {$settings_post->ID}]" );
550
+ $setting = self::add_setting( $settings_post->ID, $settings_post->post_title );
551
+ $settings[] = $setting;
552
+ $cache->save_settings( $settings_post->ID, $setting );
553
  }
554
  return $settings;
555
  }
556
 
557
  /**
558
+ * Getting the Setting object for term.
559
  *
560
+ * @param WP_Term $object WP_Term object.
561
+ * @param array $settings_posts Settings.
562
  * @return array
563
  */
564
  protected static function get_settings_for_term( $object, $settings_posts ) {
566
  }
567
 
568
  /**
569
+ * Getting the Setting object for option.
570
  *
571
+ * @param WP_Term $object WP_Term object.
572
+ * @param array $settings_posts Settings.
573
  * @return array
574
  */
575
  protected static function get_settings_for_option( $object, $settings_posts ) {
577
  }
578
 
579
  /**
580
+ * Getting delimited identification data of the repeated multi-value items.
581
  *
582
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object meta object.
583
  * @return array
584
  */
585
  public static function get_repeat_multiple_data( $object ) {
586
+ $cache = Smart_Custom_Fields_Cache::get_instance();
587
  $repeat_multiple_data = array();
588
+ if ( $cache->get_repeat_multiple_data( $object ) ) {
589
+ return $cache->get_repeat_multiple_data( $object );
590
  }
591
 
592
+ $meta = new Smart_Custom_Fields_Meta( $object );
593
+ $_repeat_multiple_data = $meta->get( SCF_Config::PREFIX . 'repeat-multiple-data', true );
594
  if ( ! empty( $_repeat_multiple_data ) ) {
595
  $repeat_multiple_data = $_repeat_multiple_data;
596
  }
597
 
598
+ $cache->save_repeat_multiple_data( $object, $repeat_multiple_data );
599
  return $repeat_multiple_data;
600
  }
601
 
602
  /**
603
+ * Return true if null or empty value.
604
  *
605
+ * @param mixed $value Value.
606
  * @return bool
607
  */
608
  public static function is_empty( &$value ) {
609
  if ( isset( $value ) ) {
610
+ if ( is_null( $value ) || '' === $value ) {
611
  return true;
612
  }
613
  return false;
616
  }
617
 
618
  /**
619
+ * Whether the associative array or not.
620
  *
621
  * @see http://qiita.com/ka215/items/a14e53547e717d2a564f
622
+ *
623
+ * @param array $data This argument should be expected an array.
624
+ * @param boolean $multidimensional True if a multidimensional array is inclusion into associative array, the default value is false.
625
  * @return boolean
626
  */
627
  public static function is_assoc( $data, $multidimensional = false ) {
642
  }
643
 
644
  /**
645
+ * Adding the available form field object.
646
  *
647
+ * @param Smart_Custom_Fields_Field_Base $instance Field object.
648
  */
649
  public static function add_form_field_instance( Smart_Custom_Fields_Field_Base $instance ) {
650
  $type = $instance->get_attribute( 'type' );
654
  }
655
 
656
  /**
657
+ * Getting the available form field object.
658
  *
659
+ * @param string $type Type of the form field.
660
+ * @return Smart_Custom_Fields_Field_Base
661
  */
662
  public static function get_form_field_instance( $type ) {
663
  if ( ! empty( self::$fields[ $type ] ) ) {
666
  }
667
 
668
  /**
669
+ * Getting all available form field object.
670
  *
671
  * @return array
672
  */
679
  }
680
 
681
  /**
682
+ * Getting custom fields that saved custo field settings page.
683
+ * Note that not return only one even define multiple fields with the same name of the field name.
684
  *
685
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object meta object.
686
+ * @param string $field_name Field name.
687
  * @return Smart_Custom_Fields_Field_Base|null
688
  */
689
  public static function get_field( $object, $field_name ) {
690
  $settings = self::get_settings( $object );
691
+ foreach ( $settings as $setting ) {
692
+ $fields = $setting->get_fields();
693
  if ( ! empty( $fields[ $field_name ] ) ) {
694
  return $fields[ $field_name ];
695
  }
697
  }
698
 
699
  /**
700
+ * Convert to array from newline delimiter $choices.
701
  *
702
+ * @param string $choices Choices.
703
  * @return array
704
  */
705
  public static function choices_eol_to_array( $choices ) {
706
  if ( ! is_array( $choices ) ) {
707
+ if ( '' === $choices || false === $choices || null === $choices ) {
708
  return array();
709
  }
710
  $_choices = str_replace( array( "\r\n", "\r", "\n" ), "\n", $choices );
723
  }
724
 
725
  /**
726
+ * Return generated Setting object.
727
  *
728
+ * @param string $id Post ID of custom field settings page.
729
+ * @param string $title Title of custom field settings page.
730
  * @return Smart_Custom_Fields_Setting
731
  */
732
  public static function add_setting( $id, $title ) {
734
  }
735
 
736
  /**
737
+ * Adding custom options page.
738
  *
739
  * @see https://developer.wordpress.org/reference/functions/add_menu_page/
740
+ *
741
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected.
742
+ * @param string $menu_title The text to be used for the menu.
743
+ * @param string $capability The capability required for this menu to be displayed to the user.
744
+ * @param string $menu_slug The slug name to refer to this menu by. Should be unique for this menu page and only include lowercase alphanumeric, dashes, and underscores characters to be compatible with sanitize_key().
745
+ * @param string $icon_url The URL to the icon to be used for this menu.
746
+ * @param int $position The position in the menu order this item should appear.
747
+ * @return string
748
  */
749
  public static function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $icon_url = '', $position = null ) {
750
  self::$options_pages[ $menu_slug ] = $menu_title;
762
  }
763
 
764
  /**
765
+ * Generate WP_Post object.
766
  *
767
+ * @param int $post_id Post id.
768
+ * @param string $post_type Post type.
769
  * @return WP_Post
770
  */
771
  public static function generate_post_object( $post_id, $post_type = null ) {
772
+ $post = new stdClass();
773
+ $post->ID = $post_id;
774
+ $post->post_type = $post_type;
775
+ return new WP_Post( $post );
776
  }
777
 
778
  /**
779
+ * Generate option object.
780
  *
781
+ * @param string $menu_slug Menu slug.
782
  * @return stdClass
783
  */
784
  public static function generate_option_object( $menu_slug ) {
786
  if ( ! isset( $options_pages[ $menu_slug ] ) ) {
787
  return;
788
  }
789
+ $option = new stdClass();
790
+ $option->menu_slug = $menu_slug;
791
+ $option->menu_title = $options_pages[ $menu_slug ];
792
+ return $option;
793
  }
794
 
795
  /**
796
+ * Print cache usage.
797
+ *
798
+ * @param string $message Message.
799
  */
800
  protected static function debug_cache_message( $message ) {
801
  if ( defined( 'SCF_DEBUG_CACHE' ) && SCF_DEBUG_CACHE === true ) {
classes/controller/class.controller-base.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Controller_Base
4
- * Version : 1.4.0
5
- * Author : inc2734
6
- * Created : April 27, 2015
7
- * Modified : June 4, 2016
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Controller_Base {
12
 
@@ -26,10 +26,8 @@ class Smart_Custom_Fields_Controller_Base {
26
 
27
  /**
28
  * Loading resources for edit page.
29
- *
30
- * @param string $hook
31
  */
32
- public function admin_enqueue_scripts( $hook ) {
33
  do_action( SCF_Config::PREFIX . 'before-editor-enqueue-scripts' );
34
  wp_enqueue_style(
35
  SCF_Config::PREFIX . 'editor',
@@ -67,8 +65,8 @@ class Smart_Custom_Fields_Controller_Base {
67
  /**
68
  * Display custom fields in edit page.
69
  *
70
- * @param WP_Post|WP_User|WP_Term|stdClass $object
71
- * @param array $callback_args custom field setting information
72
  */
73
  public function display_meta_box( $object, $callback_args ) {
74
  $groups = $callback_args['args'];
@@ -76,27 +74,29 @@ class Smart_Custom_Fields_Controller_Base {
76
 
77
  printf( '<div class="%s">', esc_attr( SCF_Config::PREFIX . 'meta-box' ) );
78
  $index = 0;
79
- foreach ( $tables as $group_key => $Group ) {
80
- $is_repeatable = $Group->is_repeatable();
81
- if ( $is_repeatable && $index === 0 ) {
82
  printf(
83
  '<div class="%s">',
84
  esc_attr( SCF_Config::PREFIX . 'meta-box-repeat-tables' )
85
  );
86
- $this->display_tr( $object, $is_repeatable, $Group->get_fields() );
87
  }
88
- $this->display_tr( $object, $is_repeatable, $Group->get_fields(), $index );
89
 
90
  // If in the loop, count up the index.
91
  // If exit the loop, reset the count.
92
- if ( $is_repeatable &&
93
- isset( $tables[ $group_key + 1 ] ) &&
94
- $tables[ $group_key + 1 ]->get_name() === $Group->get_name() ) {
 
 
95
  $index ++;
96
  } else {
97
  $index = 0;
98
  }
99
- if ( $is_repeatable && $index === 0 ) {
100
  printf( '</div>' );
101
  }
102
  }
@@ -105,10 +105,10 @@ class Smart_Custom_Fields_Controller_Base {
105
  }
106
 
107
  /**
108
- * Saving posted data
109
  *
110
- * @param array $data
111
- * @param WP_Post|WP_User|WP_Term|stdClass $object
112
  */
113
  protected function save( $data, $object ) {
114
  check_admin_referer(
@@ -116,46 +116,45 @@ class Smart_Custom_Fields_Controller_Base {
116
  SCF_Config::PREFIX . 'fields-nonce'
117
  );
118
 
119
- $Meta = new Smart_Custom_Fields_Meta( $object );
120
- $Meta->save( $_POST );
121
  }
122
 
123
  /**
124
- * Generating array for displaying the custom fields
125
  *
126
- * @param WP_Post|WP_User|WP_Term|stdClass $object
127
- * @param array $groups Settings from custom field settings page
128
- * @return array $tables Array for displaying a table for custom fields
129
  */
130
  protected function get_tables( $object, $groups ) {
131
- $Meta = new Smart_Custom_Fields_Meta( $object );
132
 
133
  $repeat_multiple_data = SCF::get_repeat_multiple_data( $object );
134
  $tables = array();
135
- foreach ( $groups as $Group ) {
136
  // If in the loop, Added groupgs by the amount of the loop.
137
  // Added only one if setting is repetition but not loop (Ex, new registration)
138
- if ( $Group->is_repeatable() === true ) {
139
  $loop_count = 1;
140
- $fields = $Group->get_fields();
141
- foreach ( $fields as $Field ) {
142
- $field_name = $Field->get( 'name' );
143
- $meta = $Meta->get( $field_name );
144
- if ( is_array( $meta ) ) {
145
- $meta_count = count( $meta );
146
  // When the same name of the custom field is a multiple (checbox or loop)
147
  if ( $meta_count > 1 ) {
148
  // checkbox
149
- if ( $Field->get_attribute( 'allow-multiple-data' ) ) {
150
  if ( is_array( $repeat_multiple_data ) && isset( $repeat_multiple_data[ $field_name ] ) ) {
151
  $repeat_multiple_data_count = count( $repeat_multiple_data[ $field_name ] );
152
  if ( $loop_count < $repeat_multiple_data_count ) {
153
  $loop_count = $repeat_multiple_data_count;
154
  }
155
  }
156
- }
157
- // other than checkbox
158
- else {
159
  if ( $loop_count < $meta_count ) {
160
  $loop_count = $meta_count;
161
  }
@@ -165,12 +164,12 @@ class Smart_Custom_Fields_Controller_Base {
165
  }
166
  if ( $loop_count >= 1 ) {
167
  for ( $i = $loop_count; $i > 0; $i -- ) {
168
- $tables[] = $Group;
169
  }
170
  continue;
171
  }
172
  }
173
- $tables[] = $Group;
174
  }
175
  return $tables;
176
  }
@@ -178,24 +177,24 @@ class Smart_Custom_Fields_Controller_Base {
178
  /**
179
  * Getting the multi-value field meta data.
180
  *
181
- * @param WP_Post|WP_User|WP_Term|stdClass $object
182
- * @param Smart_Custom_Fields_Field_Base $Field
183
- * @param int $index
184
  * @return array
185
  */
186
- public function get_multiple_data_field_value( $object, $Field, $index ) {
187
- $Meta = new Smart_Custom_Fields_Meta( $object );
188
- $field_name = $Field->get( 'name' );
189
 
190
  if ( is_null( $index ) ) {
191
- return SCF::get_default_value( $Field );
192
  }
193
 
194
- if ( ! $Meta->is_saved_the_key( $field_name ) ) {
195
- return SCF::get_default_value( $Field );
196
  }
197
 
198
- $value = $Meta->get( $field_name );
199
 
200
  // in the loop
201
  $repeat_multiple_data = SCF::get_repeat_multiple_data( $object );
@@ -222,40 +221,38 @@ class Smart_Custom_Fields_Controller_Base {
222
  /**
223
  * Getting the non multi-value field meta data.
224
  *
225
- * @param WP_Post|WP_User|WP_Term|stdClass $object
226
- * @param Smart_Custom_Fields_Field_Base $Field
227
- * @param int $index
228
  * @return string
229
  */
230
- public function get_single_data_field_value( $object, $Field, $index ) {
231
- $Meta = new Smart_Custom_Fields_Meta( $object );
232
- $field_name = $Field->get( 'name' );
233
 
234
  if ( is_null( $index ) ) {
235
- return SCF::get_default_value( $Field, true );
236
  }
237
 
238
- if ( $Meta->is_saved_the_key( $field_name ) ) {
239
- $value = $Meta->get( $field_name );
240
  if ( isset( $value[ $index ] ) ) {
241
  return $value[ $index ];
242
  }
243
  return '';
244
  }
245
- return SCF::get_default_value( $Field, true );
246
  }
247
 
248
  /**
249
- * Displaying tr element for table of custom fields
250
  *
251
- * @param WP_Post|WP_User|WP_Term|stdClass $object
252
- * @param bool $is_repeat
253
- * @param array $fields
254
- * @param int, null $index
255
  */
256
  protected function display_tr( $object, $is_repeat, $fields, $index = null ) {
257
- $Meta = new Smart_Custom_Fields_Meta( $object );
258
-
259
  $btn_repeat = '';
260
  if ( $is_repeat ) {
261
  $btn_repeat = sprintf(
@@ -278,26 +275,24 @@ class Smart_Custom_Fields_Controller_Base {
278
  $btn_repeat
279
  );
280
 
281
- foreach ( $fields as $Field ) {
282
- $display_name = $Field->get_attribute( 'display-name' );
283
- $field_type = $Field->get_attribute( 'type' ); // gets the field type for use in aditional CSS classes
284
- $layout = $Field->get_attribute( 'layout' ); // get layout type
285
- $field_name = $Field->get( 'name' );
286
- $field_label = $Field->get( 'label' );
287
  if ( ! $field_label ) {
288
  $field_label = $field_name;
289
  }
290
 
291
- // When multi-value field
292
- if ( $Field->get_attribute( 'allow-multiple-data' ) ) {
293
- $value = $this->get_multiple_data_field_value( $object, $Field, $index );
294
- }
295
- // When non multi-value field
296
- else {
297
- $value = $this->get_single_data_field_value( $object, $Field, $index );
298
  }
299
 
300
- $instruction = $Field->get( 'instruction' );
301
  if ( ! empty( $instruction ) ) {
302
  if ( apply_filters( SCF_Config::PREFIX . 'instruction-apply-html', false ) === true ) {
303
  $instruction_html = $instruction;
@@ -310,7 +305,7 @@ class Smart_Custom_Fields_Controller_Base {
310
  );
311
  }
312
 
313
- $notes = $Field->get( 'notes' );
314
  if ( ! empty( $notes ) ) {
315
  $notes = sprintf(
316
  '<p class="description">%s</p>',
@@ -318,10 +313,10 @@ class Smart_Custom_Fields_Controller_Base {
318
  );
319
  }
320
 
321
- $form_field = $Field->get_field( $index, $value );
322
 
323
  // if the layout type is full-width, it hides the "Table Header" (th)
324
- $table_th = $layout != 'full-width' ? '<th>' . esc_html( $field_label ) . '</th>' : '';
325
  printf(
326
  '<table class="%1$sfield-type-%6$s %1$slayout-type-%7$s"><tr>
327
  %2$s
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Controller_Base class.
10
  */
11
  class Smart_Custom_Fields_Controller_Base {
12
 
26
 
27
  /**
28
  * Loading resources for edit page.
 
 
29
  */
30
+ public function admin_enqueue_scripts() {
31
  do_action( SCF_Config::PREFIX . 'before-editor-enqueue-scripts' );
32
  wp_enqueue_style(
33
  SCF_Config::PREFIX . 'editor',
65
  /**
66
  * Display custom fields in edit page.
67
  *
68
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object meta object.
69
+ * @param array $callback_args Custom field setting information.
70
  */
71
  public function display_meta_box( $object, $callback_args ) {
72
  $groups = $callback_args['args'];
74
 
75
  printf( '<div class="%s">', esc_attr( SCF_Config::PREFIX . 'meta-box' ) );
76
  $index = 0;
77
+ foreach ( $tables as $group_key => $group ) {
78
+ $is_repeatable = $group->is_repeatable();
79
+ if ( $is_repeatable && 0 === $index ) {
80
  printf(
81
  '<div class="%s">',
82
  esc_attr( SCF_Config::PREFIX . 'meta-box-repeat-tables' )
83
  );
84
+ $this->display_tr( $object, $is_repeatable, $group->get_fields() );
85
  }
86
+ $this->display_tr( $object, $is_repeatable, $group->get_fields(), $index );
87
 
88
  // If in the loop, count up the index.
89
  // If exit the loop, reset the count.
90
+ if (
91
+ $is_repeatable
92
+ && isset( $tables[ $group_key + 1 ] )
93
+ && $group->get_name() === $tables[ $group_key + 1 ]->get_name()
94
+ ) {
95
  $index ++;
96
  } else {
97
  $index = 0;
98
  }
99
+ if ( $is_repeatable && 0 === $index ) {
100
  printf( '</div>' );
101
  }
102
  }
105
  }
106
 
107
  /**
108
+ * Saving posted data.
109
  *
110
+ * @param array $data Data.
111
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object meta object.
112
  */
113
  protected function save( $data, $object ) {
114
  check_admin_referer(
116
  SCF_Config::PREFIX . 'fields-nonce'
117
  );
118
 
119
+ $meta = new Smart_Custom_Fields_Meta( $object );
120
+ $meta->save( $data );
121
  }
122
 
123
  /**
124
+ * Generating array for displaying the custom fields.
125
  *
126
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object meta object.
127
+ * @param array $groups Settings from custom field settings page.
128
+ * @return array Array for displaying a table for custom fields.
129
  */
130
  protected function get_tables( $object, $groups ) {
131
+ $meta = new Smart_Custom_Fields_Meta( $object );
132
 
133
  $repeat_multiple_data = SCF::get_repeat_multiple_data( $object );
134
  $tables = array();
135
+ foreach ( $groups as $group ) {
136
  // If in the loop, Added groupgs by the amount of the loop.
137
  // Added only one if setting is repetition but not loop (Ex, new registration)
138
+ if ( true === $group->is_repeatable() ) {
139
  $loop_count = 1;
140
+ $fields = $group->get_fields();
141
+ foreach ( $fields as $field ) {
142
+ $field_name = $field->get( 'name' );
143
+ $meta_value = $meta->get( $field_name );
144
+ if ( is_array( $meta_value ) ) {
145
+ $meta_count = count( $meta_value );
146
  // When the same name of the custom field is a multiple (checbox or loop)
147
  if ( $meta_count > 1 ) {
148
  // checkbox
149
+ if ( $field->get_attribute( 'allow-multiple-data' ) ) {
150
  if ( is_array( $repeat_multiple_data ) && isset( $repeat_multiple_data[ $field_name ] ) ) {
151
  $repeat_multiple_data_count = count( $repeat_multiple_data[ $field_name ] );
152
  if ( $loop_count < $repeat_multiple_data_count ) {
153
  $loop_count = $repeat_multiple_data_count;
154
  }
155
  }
156
+ } else {
157
+ // other than checkbox
 
158
  if ( $loop_count < $meta_count ) {
159
  $loop_count = $meta_count;
160
  }
164
  }
165
  if ( $loop_count >= 1 ) {
166
  for ( $i = $loop_count; $i > 0; $i -- ) {
167
+ $tables[] = $group;
168
  }
169
  continue;
170
  }
171
  }
172
+ $tables[] = $group;
173
  }
174
  return $tables;
175
  }
177
  /**
178
  * Getting the multi-value field meta data.
179
  *
180
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object meta object.
181
+ * @param Smart_Custom_Fields_Field_Base $field Field object.
182
+ * @param int $index Index of value.
183
  * @return array
184
  */
185
+ public function get_multiple_data_field_value( $object, $field, $index ) {
186
+ $meta = new Smart_Custom_Fields_Meta( $object );
187
+ $field_name = $field->get( 'name' );
188
 
189
  if ( is_null( $index ) ) {
190
+ return SCF::get_default_value( $field );
191
  }
192
 
193
+ if ( ! $meta->is_saved_the_key( $field_name ) ) {
194
+ return SCF::get_default_value( $field );
195
  }
196
 
197
+ $value = $meta->get( $field_name );
198
 
199
  // in the loop
200
  $repeat_multiple_data = SCF::get_repeat_multiple_data( $object );
221
  /**
222
  * Getting the non multi-value field meta data.
223
  *
224
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object meta object.
225
+ * @param Smart_Custom_Fields_Field_Base $field Field object.
226
+ * @param int $index Index of value.
227
  * @return string
228
  */
229
+ public function get_single_data_field_value( $object, $field, $index ) {
230
+ $meta = new Smart_Custom_Fields_Meta( $object );
231
+ $field_name = $field->get( 'name' );
232
 
233
  if ( is_null( $index ) ) {
234
+ return SCF::get_default_value( $field, true );
235
  }
236
 
237
+ if ( $meta->is_saved_the_key( $field_name ) ) {
238
+ $value = $meta->get( $field_name );
239
  if ( isset( $value[ $index ] ) ) {
240
  return $value[ $index ];
241
  }
242
  return '';
243
  }
244
+ return SCF::get_default_value( $field, true );
245
  }
246
 
247
  /**
248
+ * Displaying tr element for table of custom fields.
249
  *
250
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object meta object.
251
+ * @param bool $is_repeat If repeat, return true.
252
+ * @param array $fields Fields.
253
+ * @param int|null $index Field index.
254
  */
255
  protected function display_tr( $object, $is_repeat, $fields, $index = null ) {
 
 
256
  $btn_repeat = '';
257
  if ( $is_repeat ) {
258
  $btn_repeat = sprintf(
275
  $btn_repeat
276
  );
277
 
278
+ foreach ( $fields as $field ) {
279
+ $field_type = $field->get_attribute( 'type' ); // gets the field type for use in aditional CSS classes
280
+ $layout = $field->get_attribute( 'layout' ); // get layout type
281
+ $field_name = $field->get( 'name' );
282
+ $field_label = $field->get( 'label' );
 
283
  if ( ! $field_label ) {
284
  $field_label = $field_name;
285
  }
286
 
287
+ if ( $field->get_attribute( 'allow-multiple-data' ) ) {
288
+ // When multi-value field
289
+ $value = $this->get_multiple_data_field_value( $object, $field, $index );
290
+ } else {
291
+ // When non multi-value field
292
+ $value = $this->get_single_data_field_value( $object, $field, $index );
 
293
  }
294
 
295
+ $instruction = $field->get( 'instruction' );
296
  if ( ! empty( $instruction ) ) {
297
  if ( apply_filters( SCF_Config::PREFIX . 'instruction-apply-html', false ) === true ) {
298
  $instruction_html = $instruction;
305
  );
306
  }
307
 
308
+ $notes = $field->get( 'notes' );
309
  if ( ! empty( $notes ) ) {
310
  $notes = sprintf(
311
  '<p class="description">%s</p>',
313
  );
314
  }
315
 
316
+ $form_field = $field->get_field( $index, $value );
317
 
318
  // if the layout type is full-width, it hides the "Table Header" (th)
319
+ $table_th = 'full-width' !== $layout ? '<th>' . esc_html( $field_label ) . '</th>' : '';
320
  printf(
321
  '<table class="%1$sfield-type-%6$s %1$slayout-type-%7$s"><tr>
322
  %2$s
classes/controller/class.editor.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Controller_Editor
4
- * Version : 1.1.0
5
- * Author : inc2734
6
- * Created : September 23, 2014
7
- * Modified : April 28, 2015
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Controller_Editor extends Smart_Custom_Fields_Controller_Base {
12
 
@@ -20,30 +20,30 @@ class Smart_Custom_Fields_Controller_Editor extends Smart_Custom_Fields_Controll
20
  }
21
 
22
  /**
23
- * Displaying custom fields in post edit page
24
  *
25
- * @param string $post_type
26
- * @param WP_Post $post
27
  */
28
  public function add_meta_boxes( $post_type, $post ) {
29
  $settings = SCF::get_settings( $post );
30
- foreach ( $settings as $Setting ) {
31
  add_meta_box(
32
- SCF_Config::PREFIX . 'custom-field-' . $Setting->get_id(),
33
- $Setting->get_title(),
34
  array( $this, 'display_meta_box' ),
35
  $post_type,
36
  'normal',
37
  'default',
38
- $Setting->get_groups()
39
  );
40
  }
41
  }
42
 
43
  /**
44
- * Saving meta data from custom fields in post edit page
45
  *
46
- * @param int $post_id
47
  */
48
  public function save_post( $post_id ) {
49
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Controller_Editor class.
10
  */
11
  class Smart_Custom_Fields_Controller_Editor extends Smart_Custom_Fields_Controller_Base {
12
 
20
  }
21
 
22
  /**
23
+ * Displaying custom fields in post edit page.
24
  *
25
+ * @param string $post_type Post type.
26
+ * @param WP_Post $post WP_Post object.
27
  */
28
  public function add_meta_boxes( $post_type, $post ) {
29
  $settings = SCF::get_settings( $post );
30
+ foreach ( $settings as $setting ) {
31
  add_meta_box(
32
+ SCF_Config::PREFIX . 'custom-field-' . $setting->get_id(),
33
+ $setting->get_title(),
34
  array( $this, 'display_meta_box' ),
35
  $post_type,
36
  'normal',
37
  'default',
38
+ $setting->get_groups()
39
  );
40
  }
41
  }
42
 
43
  /**
44
+ * Saving meta data from custom fields in post edit page.
45
  *
46
+ * @param int $post_id Post id.
47
  */
48
  public function save_post( $post_id ) {
49
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
classes/controller/class.option.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Controller_Option
4
- * Version : 1.0.0
5
- * Author : inc2734
6
- * Created : May 29, 2014
7
- * Modified :
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Controller_Option extends Smart_Custom_Fields_Controller_Base {
12
 
@@ -20,9 +20,9 @@ class Smart_Custom_Fields_Controller_Option extends Smart_Custom_Fields_Controll
20
  }
21
 
22
  /**
23
- * Loading resources for term edit page
24
  *
25
- * @param string $hook
26
  */
27
  public function admin_enqueue_scripts( $hook ) {
28
  parent::admin_enqueue_scripts( $hook );
@@ -33,23 +33,25 @@ class Smart_Custom_Fields_Controller_Option extends Smart_Custom_Fields_Controll
33
  }
34
 
35
  /**
36
- * Displaying custom fields in custom options page
37
  *
38
- * @param stdClass $Option
39
  */
40
- public function custom_options_page( $Option ) {
41
- $settings = SCF::get_settings( $Option );
42
  if ( ! $settings ) {
43
  return;
44
  }
 
 
45
  ?>
46
  <form method="post" action="">
47
- <?php foreach ( $settings as $Setting ) : ?>
48
- <?php $callback_args['args'] = $Setting->get_groups(); ?>
49
  <table class="form-table">
50
  <tr>
51
- <th scope="row"><?php echo esc_html( $Setting->get_title() ); ?></th>
52
- <td><?php $this->display_meta_box( $Option, $callback_args ); ?></td>
53
  </tr>
54
  </table>
55
  <?php endforeach; ?>
@@ -61,15 +63,15 @@ class Smart_Custom_Fields_Controller_Option extends Smart_Custom_Fields_Controll
61
  }
62
 
63
  /**
64
- * Saving meta data from custom fields in custom options page
65
  *
66
- * @param stdClass $Option
67
  */
68
- public function save_option( $Option ) {
69
  if ( ! isset( $_POST[ SCF_Config::NAME ] ) ) {
70
  return;
71
  }
72
 
73
- $this->save( $_POST, $Option );
74
  }
75
  }
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Controller_Option class.
10
  */
11
  class Smart_Custom_Fields_Controller_Option extends Smart_Custom_Fields_Controller_Base {
12
 
20
  }
21
 
22
  /**
23
+ * Loading resources for term edit page.
24
  *
25
+ * @param string $hook The current admin page.
26
  */
27
  public function admin_enqueue_scripts( $hook ) {
28
  parent::admin_enqueue_scripts( $hook );
33
  }
34
 
35
  /**
36
+ * Displaying custom fields in custom options page.
37
  *
38
+ * @param stdClass $option Option object.
39
  */
40
+ public function custom_options_page( $option ) {
41
+ $settings = SCF::get_settings( $option );
42
  if ( ! $settings ) {
43
  return;
44
  }
45
+
46
+ $callback_args = [];
47
  ?>
48
  <form method="post" action="">
49
+ <?php foreach ( $settings as $setting ) : ?>
50
+ <?php $callback_args['args'] = $setting->get_groups(); ?>
51
  <table class="form-table">
52
  <tr>
53
+ <th scope="row"><?php echo esc_html( $setting->get_title() ); ?></th>
54
+ <td><?php $this->display_meta_box( $option, $callback_args ); ?></td>
55
  </tr>
56
  </table>
57
  <?php endforeach; ?>
63
  }
64
 
65
  /**
66
+ * Saving meta data from custom fields in custom options page.
67
  *
68
+ * @param stdClass $option Option object.
69
  */
70
+ public function save_option( $option ) {
71
  if ( ! isset( $_POST[ SCF_Config::NAME ] ) ) {
72
  return;
73
  }
74
 
75
+ $this->save( $_POST, $option );
76
  }
77
  }
classes/controller/class.profile.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Controller_Profile
4
- * Version : 1.0.1
5
- * Author : inc2734
6
- * Created : March 16, 2015
7
- * Modified : April 26, 2015
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Controller_Profile extends Smart_Custom_Fields_Controller_Base {
12
 
@@ -22,12 +22,13 @@ class Smart_Custom_Fields_Controller_Profile extends Smart_Custom_Fields_Control
22
  }
23
 
24
  /**
25
- * Loading resources for profile edit page
26
  *
27
- * @param string $hook
28
  */
29
  public function admin_enqueue_scripts( $hook ) {
30
  parent::admin_enqueue_scripts( $hook );
 
31
  wp_enqueue_style(
32
  SCF_Config::PREFIX . 'profile',
33
  plugins_url( SCF_Config::NAME ) . '/css/profile.css'
@@ -35,19 +36,20 @@ class Smart_Custom_Fields_Controller_Profile extends Smart_Custom_Fields_Control
35
  }
36
 
37
  /**
38
- * Displaying custom fields
39
  *
40
- * @param WP_User $user
41
  */
42
  public function user_profile( $user ) {
43
  printf( '<h3>%s</h3>', esc_html__( 'Custom Fields', 'smart-custom-fields' ) );
44
- $settings = SCF::get_settings( $user );
45
- foreach ( $settings as $Setting ) {
46
- $callback_args['args'] = $Setting->get_groups();
 
47
  ?>
48
  <table class="form-table">
49
  <tr>
50
- <th scope="row"><?php echo esc_html( $Setting->get_title() ); ?></th>
51
  <td><?php $this->display_meta_box( $user, $callback_args ); ?></td>
52
  </tr>
53
  </table>
@@ -58,7 +60,7 @@ class Smart_Custom_Fields_Controller_Profile extends Smart_Custom_Fields_Control
58
  /**
59
  * Saving meta data from custom fields in profile edit page.
60
  *
61
- * @param int $user_id
62
  */
63
  public function update( $user_id ) {
64
  if ( ! current_user_can( 'edit_user', $user_id ) ) {
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Controller_Profile class.
10
  */
11
  class Smart_Custom_Fields_Controller_Profile extends Smart_Custom_Fields_Controller_Base {
12
 
22
  }
23
 
24
  /**
25
+ * Loading resources for profile edit page.
26
  *
27
+ * @param string $hook The current admin page.
28
  */
29
  public function admin_enqueue_scripts( $hook ) {
30
  parent::admin_enqueue_scripts( $hook );
31
+
32
  wp_enqueue_style(
33
  SCF_Config::PREFIX . 'profile',
34
  plugins_url( SCF_Config::NAME ) . '/css/profile.css'
36
  }
37
 
38
  /**
39
+ * Displaying custom fields.
40
  *
41
+ * @param WP_User $user WP_User object.
42
  */
43
  public function user_profile( $user ) {
44
  printf( '<h3>%s</h3>', esc_html__( 'Custom Fields', 'smart-custom-fields' ) );
45
+ $settings = SCF::get_settings( $user );
46
+ $callback_args = [];
47
+ foreach ( $settings as $setting ) {
48
+ $callback_args['args'] = $setting->get_groups();
49
  ?>
50
  <table class="form-table">
51
  <tr>
52
+ <th scope="row"><?php echo esc_html( $setting->get_title() ); ?></th>
53
  <td><?php $this->display_meta_box( $user, $callback_args ); ?></td>
54
  </tr>
55
  </table>
60
  /**
61
  * Saving meta data from custom fields in profile edit page.
62
  *
63
+ * @param int $user_id User id.
64
  */
65
  public function update( $user_id ) {
66
  if ( ! current_user_can( 'edit_user', $user_id ) ) {
classes/controller/class.settings.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Controller_Settings
4
- * Version : 1.3.1
5
- * Author : inc2734
6
- * Created : September 23, 2014
7
- * Modified : August 12, 2020
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Controller_Settings {
12
 
13
  /**
14
- * Selectbox choices of the field selection
15
  *
16
  * @var array
17
  */
@@ -47,7 +47,7 @@ class Smart_Custom_Fields_Controller_Settings {
47
  }
48
 
49
  /**
50
- * Get Current Admin Color Scheme
51
  *
52
  * @return object
53
  */
@@ -61,11 +61,10 @@ class Smart_Custom_Fields_Controller_Settings {
61
  }
62
 
63
  /**
64
- * Add Custom Inline CSS on Admin Dashboard
65
  */
66
  public function admin_inline_css() {
67
- $colors = $this->admin_color_scheme()->colors;
68
- $icon_colors = $this->admin_color_scheme()->icon_colors;
69
  ?>
70
  <style>
71
  #smart-cf-meta-box-condition-post .selectivity-load-more.highlight,
@@ -85,7 +84,7 @@ class Smart_Custom_Fields_Controller_Settings {
85
  }
86
 
87
  /**
88
- * Loading resources
89
  */
90
  public function admin_enqueue_scripts() {
91
  do_action( SCF_Config::PREFIX . 'before-settings-enqueue-scripts' );
@@ -153,7 +152,7 @@ class Smart_Custom_Fields_Controller_Settings {
153
  }
154
 
155
  /**
156
- * Adding meta boxes
157
  */
158
  public function add_meta_boxes() {
159
  add_meta_box(
@@ -193,9 +192,9 @@ class Smart_Custom_Fields_Controller_Settings {
193
  }
194
 
195
  /**
196
- * Displaying "hide" if $key isn't empty
197
  *
198
- * @param string $key
199
  */
200
  private function add_hide_class( $key ) {
201
  if ( ! $key ) {
@@ -204,30 +203,30 @@ class Smart_Custom_Fields_Controller_Settings {
204
  }
205
 
206
  /**
207
- * Displaying custom fields
208
  */
209
  public function display_meta_box() {
210
- $Setting = SCF::add_setting( get_the_ID(), get_the_title() );
211
- $Setting->add_group_unshift();
212
- $groups = $Setting->get_groups();
213
  ?>
214
  <div class="<?php echo esc_attr( SCF_Config::PREFIX . 'fields-wrapper' ); ?>">
215
  <div class="<?php echo esc_attr( SCF_Config::PREFIX . 'groups' ); ?>">
216
- <?php foreach ( $groups as $group_key => $Group ) : ?>
217
  <?php
218
- $fields = $Group->get_fields();
219
  array_unshift( $fields, SCF::get_form_field_instance( 'text' ) );
220
  ?>
221
  <div class="<?php echo esc_attr( SCF_Config::PREFIX . 'group' ); ?> <?php $this->add_hide_class( $group_key ); ?>">
222
  <div class="btn-remove-group"><span class="dashicons dashicons-no-alt"></span></div>
223
- <?php $Group->display_options( $group_key ); ?>
224
 
225
  <div class="<?php echo esc_attr( SCF_Config::PREFIX . 'fields' ); ?>">
226
- <?php foreach ( $fields as $field_key => $Field ) : ?>
227
  <div class="<?php echo esc_attr( SCF_Config::PREFIX . 'field' ); ?> <?php $this->add_hide_class( $field_key ); ?>">
228
  <?php
229
- $field_name = $Field->get( 'name' );
230
- $field_label = $Field->get( 'label' );
231
  if ( ! $field_label ) {
232
  $field_label = $field_name;
233
  if ( ! $field_label ) {
@@ -243,12 +242,12 @@ class Smart_Custom_Fields_Controller_Settings {
243
  <small>[ <?php echo esc_html( $field_name ); ?> ]</small>
244
  <?php endif; ?>
245
  </div>
246
- <table class="<?php $this->add_hide_class( ! $Field->get( 'name' ) ); ?>">
247
  <tr>
248
  <th><?php esc_html_e( 'Type', 'smart-custom-fields' ); ?><span class="<?php echo esc_attr( SCF_Config::PREFIX . 'require' ); ?>">*</span></th>
249
  <td>
250
  <select
251
- name="<?php echo esc_attr( $Field->get_field_name_in_setting( $group_key, $field_key, 'type' ) ); ?>"
252
  class="<?php echo esc_attr( SCF_Config::PREFIX . 'field-select' ); ?>" />
253
  <?php
254
  foreach ( $this->optgroups as $optgroup_name => $optgroup_values ) {
@@ -261,7 +260,7 @@ class Smart_Custom_Fields_Controller_Settings {
261
  $optgroup_fields[] = sprintf(
262
  '<option value="%s" %s>%s</option>',
263
  esc_attr( $option_key ),
264
- selected( $Field->get_attribute( 'type' ), $option_key, false ),
265
  esc_html( $option )
266
  );
267
  }
@@ -275,12 +274,12 @@ class Smart_Custom_Fields_Controller_Settings {
275
  </select>
276
  </td>
277
  </tr>
278
- <?php $Field->display_options( $group_key, $field_key ); ?>
279
  </table>
280
  </div>
281
  <?php endforeach; ?>
282
  </div>
283
- <div class="button btn-add-field <?php $this->add_hide_class( $Group->is_repeatable() ); ?>"><?php esc_html_e( 'Add Sub field', 'smart-custom-fields' ); ?></div>
284
  </div>
285
  <?php endforeach; ?>
286
  </div>
@@ -291,7 +290,7 @@ class Smart_Custom_Fields_Controller_Settings {
291
  }
292
 
293
  /**
294
- * Displaying the meta box to set the display conditions for post edit page
295
  */
296
  public function display_meta_box_condition_post() {
297
  $post_types = get_post_types(
@@ -307,7 +306,7 @@ class Smart_Custom_Fields_Controller_Settings {
307
  $conditions = get_post_meta( get_the_ID(), SCF_Config::PREFIX . 'condition', true );
308
  $post_type_field = '';
309
  foreach ( $post_types as $post_type => $post_type_object ) {
310
- $current = ( is_array( $conditions ) && in_array( $post_type, $conditions ) ) ? $post_type : false;
311
  $post_type_field .= sprintf(
312
  '<label><input type="checkbox" name="%s" value="%s" %s /> %s</label>',
313
  esc_attr( SCF_Config::PREFIX . 'condition[]' ),
@@ -331,7 +330,7 @@ class Smart_Custom_Fields_Controller_Settings {
331
  $saved = array();
332
 
333
  foreach ( $saved_posts as $k => $post_id ) {
334
- if ( $post_id != '' ) {
335
  $saved[ $k ]['id'] = $post_id;
336
  $saved[ $k ]['text'] = $post_id; // $post_id . ' - ' . get_the_title($post_id);
337
  }
@@ -361,19 +360,20 @@ class Smart_Custom_Fields_Controller_Settings {
361
  }
362
 
363
  /**
364
- * Displaying the meta box to set the display conditions for profile edit page
365
  */
366
  public function display_meta_box_condition_profile() {
367
  $roles = get_editable_roles();
368
  $conditions = get_post_meta( get_the_ID(), SCF_Config::PREFIX . 'roles', true );
369
  $profile_field = '';
370
  foreach ( $roles as $name => $role ) {
371
- $current = ( is_array( $conditions ) && in_array( $name, $conditions ) ) ? $name : false;
372
  $profile_field .= sprintf(
373
  '<label><input type="checkbox" name="%s" value="%s" %s /> %s</label>',
374
  esc_attr( SCF_Config::PREFIX . 'roles[]' ),
375
  esc_attr( $name ),
376
  checked( $current, $name, false ),
 
377
  esc_html__( $role['name'], 'smart-custom-fields' )
378
  );
379
  }
@@ -385,7 +385,7 @@ class Smart_Custom_Fields_Controller_Settings {
385
  }
386
 
387
  /**
388
- * Displaying the meta box to set the display conditions for term edit page
389
  */
390
  public function display_meta_box_condition_taxonomy() {
391
  $taxonomies = get_taxonomies(
@@ -397,12 +397,13 @@ class Smart_Custom_Fields_Controller_Settings {
397
  $conditions = get_post_meta( get_the_ID(), SCF_Config::PREFIX . 'taxonomies', true );
398
  $taxonomy_field = '';
399
  foreach ( $taxonomies as $name => $taxonomy ) {
400
- $current = ( is_array( $conditions ) && in_array( $name, $conditions ) ) ? $name : false;
401
  $taxonomy_field .= sprintf(
402
  '<label><input type="checkbox" name="%s" value="%s" %s /> %s</label>',
403
  esc_attr( SCF_Config::PREFIX . 'taxonomies[]' ),
404
  esc_attr( $name ),
405
  checked( $current, $name, false ),
 
406
  esc_html__( $taxonomy->label, 'smart-custom-fields' )
407
  );
408
  }
@@ -414,14 +415,14 @@ class Smart_Custom_Fields_Controller_Settings {
414
  }
415
 
416
  /**
417
- * Displaying the meta box to set the display conditions for custom options page
418
  */
419
  public function display_meta_box_condition_options_page() {
420
  $optinos_pages = SCF::get_options_pages();
421
  $conditions = get_post_meta( get_the_ID(), SCF_Config::PREFIX . 'options-pages', true );
422
  $options_page_field = '';
423
  foreach ( $optinos_pages as $name => $optinos_page ) {
424
- $current = ( is_array( $conditions ) && in_array( $name, $conditions ) ) ? $name : false;
425
  $options_page_field .= sprintf(
426
  '<label><input type="checkbox" name="%s" value="%s" %s /> %s</label>',
427
  esc_attr( SCF_Config::PREFIX . 'options-pages[]' ),
@@ -438,9 +439,9 @@ class Smart_Custom_Fields_Controller_Settings {
438
  }
439
 
440
  /**
441
- * Saving settings
442
  *
443
- * @param int $post_id
444
  */
445
  public function save_post( $post_id ) {
446
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
@@ -457,14 +458,14 @@ class Smart_Custom_Fields_Controller_Settings {
457
  $data = array();
458
  foreach ( $_POST[ SCF_Config::NAME ] as $group_key => $group_value ) {
459
  // $group_key = 0 is hidden field so don't save
460
- if ( $group_key === 0 ) {
461
  continue;
462
  }
463
  if ( ! empty( $group_value['fields'] ) && count( $group_value['fields'] ) > 1 ) {
464
  $fields = array();
465
  foreach ( $group_value['fields'] as $field_key => $field_value ) {
466
  // $field_key = 0 is hidden field so don't save
467
- if ( $field_key === 0 ) {
468
  continue;
469
  }
470
  if ( ! empty( $field_value['name'] ) ) {
@@ -475,7 +476,7 @@ class Smart_Custom_Fields_Controller_Settings {
475
  continue;
476
  }
477
 
478
- if ( ! empty( $group_value['repeat'] ) && $group_value['repeat'] === 'true' ) {
479
  $group_value['repeat'] = true;
480
  } else {
481
  $group_value['repeat'] = false;
@@ -483,7 +484,7 @@ class Smart_Custom_Fields_Controller_Settings {
483
 
484
  // If "repeat" isn't true, empty name
485
  // If "repeat" is true and name is empty, assign index
486
- if ( ! ( isset( $group_value['repeat'] ) && $group_value['repeat'] === true && ! empty( $group_value['group-name'] ) ) ) {
487
  $group_value['group-name'] = $group_key;
488
  }
489
 
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Controller_Settings class.
10
  */
11
  class Smart_Custom_Fields_Controller_Settings {
12
 
13
  /**
14
+ * Selectbox choices of the field selection.
15
  *
16
  * @var array
17
  */
47
  }
48
 
49
  /**
50
+ * Get Current Admin Color Scheme.
51
  *
52
  * @return object
53
  */
61
  }
62
 
63
  /**
64
+ * Add Custom Inline CSS on Admin Dashboard.
65
  */
66
  public function admin_inline_css() {
67
+ $colors = $this->admin_color_scheme()->colors;
 
68
  ?>
69
  <style>
70
  #smart-cf-meta-box-condition-post .selectivity-load-more.highlight,
84
  }
85
 
86
  /**
87
+ * Loading resources.
88
  */
89
  public function admin_enqueue_scripts() {
90
  do_action( SCF_Config::PREFIX . 'before-settings-enqueue-scripts' );
152
  }
153
 
154
  /**
155
+ * Adding meta boxes.
156
  */
157
  public function add_meta_boxes() {
158
  add_meta_box(
192
  }
193
 
194
  /**
195
+ * Displaying "hide" if $key isn't empty.
196
  *
197
+ * @param string $key Key.
198
  */
199
  private function add_hide_class( $key ) {
200
  if ( ! $key ) {
203
  }
204
 
205
  /**
206
+ * Displaying custom fields.
207
  */
208
  public function display_meta_box() {
209
+ $setting = SCF::add_setting( get_the_ID(), get_the_title() );
210
+ $setting->add_group_unshift();
211
+ $groups = $setting->get_groups();
212
  ?>
213
  <div class="<?php echo esc_attr( SCF_Config::PREFIX . 'fields-wrapper' ); ?>">
214
  <div class="<?php echo esc_attr( SCF_Config::PREFIX . 'groups' ); ?>">
215
+ <?php foreach ( $groups as $group_key => $group ) : ?>
216
  <?php
217
+ $fields = $group->get_fields();
218
  array_unshift( $fields, SCF::get_form_field_instance( 'text' ) );
219
  ?>
220
  <div class="<?php echo esc_attr( SCF_Config::PREFIX . 'group' ); ?> <?php $this->add_hide_class( $group_key ); ?>">
221
  <div class="btn-remove-group"><span class="dashicons dashicons-no-alt"></span></div>
222
+ <?php $group->display_options( $group_key ); ?>
223
 
224
  <div class="<?php echo esc_attr( SCF_Config::PREFIX . 'fields' ); ?>">
225
+ <?php foreach ( $fields as $field_key => $field ) : ?>
226
  <div class="<?php echo esc_attr( SCF_Config::PREFIX . 'field' ); ?> <?php $this->add_hide_class( $field_key ); ?>">
227
  <?php
228
+ $field_name = $field->get( 'name' );
229
+ $field_label = $field->get( 'label' );
230
  if ( ! $field_label ) {
231
  $field_label = $field_name;
232
  if ( ! $field_label ) {
242
  <small>[ <?php echo esc_html( $field_name ); ?> ]</small>
243
  <?php endif; ?>
244
  </div>
245
+ <table class="<?php $this->add_hide_class( ! $field->get( 'name' ) ); ?>">
246
  <tr>
247
  <th><?php esc_html_e( 'Type', 'smart-custom-fields' ); ?><span class="<?php echo esc_attr( SCF_Config::PREFIX . 'require' ); ?>">*</span></th>
248
  <td>
249
  <select
250
+ name="<?php echo esc_attr( $field->get_field_name_in_setting( $group_key, $field_key, 'type' ) ); ?>"
251
  class="<?php echo esc_attr( SCF_Config::PREFIX . 'field-select' ); ?>" />
252
  <?php
253
  foreach ( $this->optgroups as $optgroup_name => $optgroup_values ) {
260
  $optgroup_fields[] = sprintf(
261
  '<option value="%s" %s>%s</option>',
262
  esc_attr( $option_key ),
263
+ selected( $field->get_attribute( 'type' ), $option_key, false ),
264
  esc_html( $option )
265
  );
266
  }
274
  </select>
275
  </td>
276
  </tr>
277
+ <?php $field->display_options( $group_key, $field_key ); ?>
278
  </table>
279
  </div>
280
  <?php endforeach; ?>
281
  </div>
282
+ <div class="button btn-add-field <?php $this->add_hide_class( $group->is_repeatable() ); ?>"><?php esc_html_e( 'Add Sub field', 'smart-custom-fields' ); ?></div>
283
  </div>
284
  <?php endforeach; ?>
285
  </div>
290
  }
291
 
292
  /**
293
+ * Displaying the meta box to set the display conditions for post edit page.
294
  */
295
  public function display_meta_box_condition_post() {
296
  $post_types = get_post_types(
306
  $conditions = get_post_meta( get_the_ID(), SCF_Config::PREFIX . 'condition', true );
307
  $post_type_field = '';
308
  foreach ( $post_types as $post_type => $post_type_object ) {
309
+ $current = is_array( $conditions ) && in_array( $post_type, $conditions, true ) ? $post_type : false;
310
  $post_type_field .= sprintf(
311
  '<label><input type="checkbox" name="%s" value="%s" %s /> %s</label>',
312
  esc_attr( SCF_Config::PREFIX . 'condition[]' ),
330
  $saved = array();
331
 
332
  foreach ( $saved_posts as $k => $post_id ) {
333
+ if ( '' !== $post_id ) {
334
  $saved[ $k ]['id'] = $post_id;
335
  $saved[ $k ]['text'] = $post_id; // $post_id . ' - ' . get_the_title($post_id);
336
  }
360
  }
361
 
362
  /**
363
+ * Displaying the meta box to set the display conditions for profile edit page.
364
  */
365
  public function display_meta_box_condition_profile() {
366
  $roles = get_editable_roles();
367
  $conditions = get_post_meta( get_the_ID(), SCF_Config::PREFIX . 'roles', true );
368
  $profile_field = '';
369
  foreach ( $roles as $name => $role ) {
370
+ $current = is_array( $conditions ) && in_array( $name, $conditions, true ) ? $name : false;
371
  $profile_field .= sprintf(
372
  '<label><input type="checkbox" name="%s" value="%s" %s /> %s</label>',
373
  esc_attr( SCF_Config::PREFIX . 'roles[]' ),
374
  esc_attr( $name ),
375
  checked( $current, $name, false ),
376
+ // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
377
  esc_html__( $role['name'], 'smart-custom-fields' )
378
  );
379
  }
385
  }
386
 
387
  /**
388
+ * Displaying the meta box to set the display conditions for term edit page.
389
  */
390
  public function display_meta_box_condition_taxonomy() {
391
  $taxonomies = get_taxonomies(
397
  $conditions = get_post_meta( get_the_ID(), SCF_Config::PREFIX . 'taxonomies', true );
398
  $taxonomy_field = '';
399
  foreach ( $taxonomies as $name => $taxonomy ) {
400
+ $current = is_array( $conditions ) && in_array( $name, $conditions, true ) ? $name : false;
401
  $taxonomy_field .= sprintf(
402
  '<label><input type="checkbox" name="%s" value="%s" %s /> %s</label>',
403
  esc_attr( SCF_Config::PREFIX . 'taxonomies[]' ),
404
  esc_attr( $name ),
405
  checked( $current, $name, false ),
406
+ // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
407
  esc_html__( $taxonomy->label, 'smart-custom-fields' )
408
  );
409
  }
415
  }
416
 
417
  /**
418
+ * Displaying the meta box to set the display conditions for custom options page.
419
  */
420
  public function display_meta_box_condition_options_page() {
421
  $optinos_pages = SCF::get_options_pages();
422
  $conditions = get_post_meta( get_the_ID(), SCF_Config::PREFIX . 'options-pages', true );
423
  $options_page_field = '';
424
  foreach ( $optinos_pages as $name => $optinos_page ) {
425
+ $current = is_array( $conditions ) && in_array( $name, $conditions, true ) ? $name : false;
426
  $options_page_field .= sprintf(
427
  '<label><input type="checkbox" name="%s" value="%s" %s /> %s</label>',
428
  esc_attr( SCF_Config::PREFIX . 'options-pages[]' ),
439
  }
440
 
441
  /**
442
+ * Saving settings.
443
  *
444
+ * @param int $post_id The post id.
445
  */
446
  public function save_post( $post_id ) {
447
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
458
  $data = array();
459
  foreach ( $_POST[ SCF_Config::NAME ] as $group_key => $group_value ) {
460
  // $group_key = 0 is hidden field so don't save
461
+ if ( 0 === $group_key ) {
462
  continue;
463
  }
464
  if ( ! empty( $group_value['fields'] ) && count( $group_value['fields'] ) > 1 ) {
465
  $fields = array();
466
  foreach ( $group_value['fields'] as $field_key => $field_value ) {
467
  // $field_key = 0 is hidden field so don't save
468
+ if ( 0 === $field_key ) {
469
  continue;
470
  }
471
  if ( ! empty( $field_value['name'] ) ) {
476
  continue;
477
  }
478
 
479
+ if ( ! empty( $group_value['repeat'] ) && 'true' === $group_value['repeat'] ) {
480
  $group_value['repeat'] = true;
481
  } else {
482
  $group_value['repeat'] = false;
484
 
485
  // If "repeat" isn't true, empty name
486
  // If "repeat" is true and name is empty, assign index
487
+ if ( ! isset( $group_value['repeat'] ) || true !== $group_value['repeat'] || empty( $group_value['group-name'] ) ) {
488
  $group_value['group-name'] = $group_key;
489
  }
490
 
classes/controller/class.taxonomy.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Controller_Taxonomy
4
- * Version : 1.0.1
5
- * Author : inc2734
6
- * Created : April 26, 2015
7
- * Modified : May 31, 2016
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Controller_Taxonomy extends Smart_Custom_Fields_Controller_Base {
12
 
@@ -22,9 +22,9 @@ class Smart_Custom_Fields_Controller_Taxonomy extends Smart_Custom_Fields_Contro
22
  }
23
 
24
  /**
25
- * Loading resources for term edit page
26
  *
27
- * @param string $hook
28
  */
29
  public function admin_enqueue_scripts( $hook ) {
30
  parent::admin_enqueue_scripts( $hook );
@@ -35,18 +35,19 @@ class Smart_Custom_Fields_Controller_Taxonomy extends Smart_Custom_Fields_Contro
35
  }
36
 
37
  /**
38
- * Displaying custom fields in term edit page
39
  *
40
- * @param object $term
41
  */
42
  public function edit_form_fields( $term ) {
43
- $settings = SCF::get_settings( $term );
44
- foreach ( $settings as $Setting ) {
45
- $callback_args['args'] = $Setting->get_groups();
 
46
  ?>
47
  <table class="form-table">
48
  <tr>
49
- <th scope="row"><?php echo esc_html( $Setting->get_title() ); ?></th>
50
  <td><?php $this->display_meta_box( $term, $callback_args ); ?></td>
51
  </tr>
52
  </table>
@@ -55,10 +56,10 @@ class Smart_Custom_Fields_Controller_Taxonomy extends Smart_Custom_Fields_Contro
55
  }
56
 
57
  /**
58
- * Saving meta data from custom fields in term edit page
59
  *
60
- * @param int $term_id
61
- * @param string $taxonomy
62
  */
63
  public function update( $term_id, $taxonomy ) {
64
  if ( ! current_user_can( 'manage_categories' ) ) {
@@ -73,15 +74,15 @@ class Smart_Custom_Fields_Controller_Taxonomy extends Smart_Custom_Fields_Contro
73
  }
74
 
75
  /**
76
- * Delete meta data
77
  *
78
- * @param int $term_id
79
- * @param int $term_taxonomy_id
80
- * @param string $taxonomy
81
- * @param object $deleted_term
82
  */
83
  public function delete( $term_id, $term_taxonomy_id, $taxonomy, $deleted_term ) {
84
- $Meta = new Smart_Custom_Fields_Meta( $deleted_term );
85
- $Meta->delete();
86
  }
87
  }
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Controller_Taxonomy class.
10
  */
11
  class Smart_Custom_Fields_Controller_Taxonomy extends Smart_Custom_Fields_Controller_Base {
12
 
22
  }
23
 
24
  /**
25
+ * Loading resources for term edit page.
26
  *
27
+ * @param string $hook The current admin page.
28
  */
29
  public function admin_enqueue_scripts( $hook ) {
30
  parent::admin_enqueue_scripts( $hook );
35
  }
36
 
37
  /**
38
+ * Displaying custom fields in term edit page.
39
  *
40
+ * @param object $term Term object.
41
  */
42
  public function edit_form_fields( $term ) {
43
+ $settings = SCF::get_settings( $term );
44
+ $callback_args = [];
45
+ foreach ( $settings as $setting ) {
46
+ $callback_args['args'] = $setting->get_groups();
47
  ?>
48
  <table class="form-table">
49
  <tr>
50
+ <th scope="row"><?php echo esc_html( $setting->get_title() ); ?></th>
51
  <td><?php $this->display_meta_box( $term, $callback_args ); ?></td>
52
  </tr>
53
  </table>
56
  }
57
 
58
  /**
59
+ * Saving meta data from custom fields in term edit page.
60
  *
61
+ * @param int $term_id Term ID.
62
+ * @param string $taxonomy Taxonomy slug.
63
  */
64
  public function update( $term_id, $taxonomy ) {
65
  if ( ! current_user_can( 'manage_categories' ) ) {
74
  }
75
 
76
  /**
77
+ * Delete meta data.
78
  *
79
+ * @param int $term_id Term ID.
80
+ * @param int $term_taxonomy_id Term taxonomy ID.
81
+ * @param string $taxonomy Taxonomy slug.
82
+ * @param object $deleted_term Copy of the already-deleted term.
83
  */
84
  public function delete( $term_id, $term_taxonomy_id, $taxonomy, $deleted_term ) {
85
+ $meta = new Smart_Custom_Fields_Meta( $deleted_term );
86
+ $meta->delete();
87
  }
88
  }
classes/fields/class.field-boolean.php CHANGED
@@ -1,18 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Field_Boolean
4
- * Version : 1.1.1
5
- * Author : Toro_Unit, inc2734
6
- * Created : April 6, 2015
7
- * Modified : July 28, 2016
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
 
 
 
 
12
  class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
13
 
14
  /**
15
- * Set the required items
16
  *
17
  * @return array
18
  */
@@ -26,7 +25,7 @@ class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
26
  }
27
 
28
  /**
29
- * Set the non required items
30
  *
31
  * @return array
32
  */
@@ -41,11 +40,11 @@ class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
41
  }
42
 
43
  /**
44
- * Getting the field
45
  *
46
- * @param int $index
47
- * @param int $value
48
- * @return string html
49
  */
50
  public function get_field( $index, $value ) {
51
  $name = $this->get_field_name_in_editor( $index );
@@ -72,10 +71,10 @@ class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
72
  }
73
 
74
  /**
75
- * Displaying the option fields in custom field settings page
76
  *
77
- * @param int $group_key
78
- * @param int $field_key
79
  */
80
  public function display_field_options( $group_key, $field_key ) {
81
  $this->display_label_option( $group_key, $field_key );
@@ -147,10 +146,10 @@ class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
147
  }
148
 
149
  /**
150
- * Validating when displaying meta data
151
  *
152
- * @param int|string $value
153
- * @param string $field_type
154
  * @return boolean
155
  */
156
  public function validate_get_value( $value, $field_type ) {
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
 
 
 
 
6
  */
7
 
8
+ /**
9
+ * Smart_Custom_Fields_Field_Boolean class.
10
+ */
11
  class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
+ * Set the required items.
15
  *
16
  * @return array
17
  */
25
  }
26
 
27
  /**
28
+ * Set the non required items.
29
  *
30
  * @return array
31
  */
40
  }
41
 
42
  /**
43
+ * Getting the field.
44
  *
45
+ * @param int $index Field index.
46
+ * @param int $value The value.
47
+ * @return string
48
  */
49
  public function get_field( $index, $value ) {
50
  $name = $this->get_field_name_in_editor( $index );
71
  }
72
 
73
  /**
74
+ * Displaying the option fields in custom field settings page.
75
  *
76
+ * @param int $group_key Group key.
77
+ * @param int $field_key Field key.
78
  */
79
  public function display_field_options( $group_key, $field_key ) {
80
  $this->display_label_option( $group_key, $field_key );
146
  }
147
 
148
  /**
149
+ * Validating when displaying meta data.
150
  *
151
+ * @param int|string $value The value.
152
+ * @param string $field_type Field type.
153
  * @return boolean
154
  */
155
  public function validate_get_value( $value, $field_type ) {
classes/fields/class.field-check.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Field_Check
4
- * Version : 1.3.0
5
- * Author : inc2734
6
- * Created : October 7, 2014
7
- * Modified : June 4, 2016
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Field_Check extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
- * Set the required items
15
  *
16
  * @return array
17
  */
@@ -25,7 +25,7 @@ class Smart_Custom_Fields_Field_Check extends Smart_Custom_Fields_Field_Base {
25
  }
26
 
27
  /**
28
- * Set the non required items
29
  *
30
  * @return array
31
  */
@@ -40,11 +40,11 @@ class Smart_Custom_Fields_Field_Check extends Smart_Custom_Fields_Field_Base {
40
  }
41
 
42
  /**
43
- * Getting the field
44
  *
45
- * @param int $index
46
- * @param array $value
47
- * @return string html
48
  */
49
  public function get_field( $index, $value ) {
50
  $name = $this->get_field_name_in_editor( $index );
@@ -67,7 +67,7 @@ class Smart_Custom_Fields_Field_Check extends Smart_Custom_Fields_Field_Base {
67
  esc_attr( SCF_Config::PREFIX . 'item-' . $direction ),
68
  esc_attr( $name . '[]' ),
69
  esc_attr( $key ),
70
- checked( true, ( is_array( $value ) && in_array( $key, $value ) ), false ),
71
  disabled( true, $disabled, false ),
72
  esc_html( $choice )
73
  );
@@ -76,10 +76,10 @@ class Smart_Custom_Fields_Field_Check extends Smart_Custom_Fields_Field_Base {
76
  }
77
 
78
  /**
79
- * Displaying the option fields in custom field settings page
80
  *
81
- * @param int $group_key
82
- * @param int $field_key
83
  */
84
  public function display_field_options( $group_key, $field_key ) {
85
  $this->display_label_option( $group_key, $field_key );
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Field_Check class.
10
  */
11
  class Smart_Custom_Fields_Field_Check extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
+ * Set the required items.
15
  *
16
  * @return array
17
  */
25
  }
26
 
27
  /**
28
+ * Set the non required items.
29
  *
30
  * @return array
31
  */
40
  }
41
 
42
  /**
43
+ * Getting the field.
44
  *
45
+ * @param int $index Field index.
46
+ * @param array $value The value.
47
+ * @return string
48
  */
49
  public function get_field( $index, $value ) {
50
  $name = $this->get_field_name_in_editor( $index );
67
  esc_attr( SCF_Config::PREFIX . 'item-' . $direction ),
68
  esc_attr( $name . '[]' ),
69
  esc_attr( $key ),
70
+ checked( true, is_array( $value ) && in_array( $key, $value, true ), false ),
71
  disabled( true, $disabled, false ),
72
  esc_html( $choice )
73
  );
76
  }
77
 
78
  /**
79
+ * Displaying the option fields in custom field settings page.
80
  *
81
+ * @param int $group_key Group key.
82
+ * @param int $field_key Field key.
83
  */
84
  public function display_field_options( $group_key, $field_key ) {
85
  $this->display_label_option( $group_key, $field_key );
classes/fields/class.field-colorpicker.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Field_Colorpicker
4
- * Version : 1.2.0
5
- * Author : inc2734
6
- * Created : October 21, 2014
7
- * Modified : June 04, 2018
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
- * Set the required items
15
  *
16
  * @return array
17
  */
@@ -32,7 +32,7 @@ class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Ba
32
  }
33
 
34
  /**
35
- * Set the non required items
36
  *
37
  * @return array
38
  */
@@ -45,7 +45,7 @@ class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Ba
45
  }
46
 
47
  /**
48
- * Loading resources for editor
49
  */
50
  public function editor_enqueue_scripts() {
51
  wp_enqueue_style( 'wp-color-picker' );
@@ -60,7 +60,7 @@ class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Ba
60
  }
61
 
62
  /**
63
- * Loading resources for editor for custom field settings page
64
  */
65
  public function settings_enqueue_scripts() {
66
  wp_enqueue_style( 'wp-color-picker' );
@@ -75,11 +75,11 @@ class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Ba
75
  }
76
 
77
  /**
78
- * Getting the field
79
  *
80
- * @param int $index
81
- * @param string $value
82
- * @return string html
83
  */
84
  public function get_field( $index, $value ) {
85
  $name = $this->get_field_name_in_editor( $index );
@@ -94,10 +94,10 @@ class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Ba
94
  }
95
 
96
  /**
97
- * Displaying the option fields in custom field settings page
98
  *
99
- * @param int $group_key
100
- * @param int $field_key
101
  */
102
  public function display_field_options( $group_key, $field_key ) {
103
  $this->display_label_option( $group_key, $field_key );
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Field_Colorpicker class.
10
  */
11
  class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
+ * Set the required items.
15
  *
16
  * @return array
17
  */
32
  }
33
 
34
  /**
35
+ * Set the non required items.
36
  *
37
  * @return array
38
  */
45
  }
46
 
47
  /**
48
+ * Loading resources for editor.
49
  */
50
  public function editor_enqueue_scripts() {
51
  wp_enqueue_style( 'wp-color-picker' );
60
  }
61
 
62
  /**
63
+ * Loading resources for editor for custom field settings page.
64
  */
65
  public function settings_enqueue_scripts() {
66
  wp_enqueue_style( 'wp-color-picker' );
75
  }
76
 
77
  /**
78
+ * Getting the field.
79
  *
80
+ * @param int $index Field index.
81
+ * @param string $value The value.
82
+ * @return string
83
  */
84
  public function get_field( $index, $value ) {
85
  $name = $this->get_field_name_in_editor( $index );
94
  }
95
 
96
  /**
97
+ * Displaying the option fields in custom field settings page.
98
  *
99
+ * @param int $group_key Group key.
100
+ * @param int $field_key Field key.
101
  */
102
  public function display_field_options( $group_key, $field_key ) {
103
  $this->display_label_option( $group_key, $field_key );
classes/fields/class.field-datepicker.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Field_Datepicker
4
- * Version : 1.2.0
5
- * Author : inc2734
6
- * Created : January 17, 2015
7
- * Modified : June 04, 2018
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
- * Set the required items
15
  *
16
  * @return array
17
  */
@@ -32,7 +32,7 @@ class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Bas
32
  }
33
 
34
  /**
35
- * Set the non required items
36
  *
37
  * @return array
38
  */
@@ -48,7 +48,7 @@ class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Bas
48
  }
49
 
50
  /**
51
- * Loading resources for editor
52
  */
53
  public function editor_enqueue_scripts() {
54
  global $wp_scripts;
@@ -70,7 +70,7 @@ class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Bas
70
  }
71
 
72
  /**
73
- * Loading resources for editor for custom field settings page
74
  */
75
  public function settings_enqueue_scripts() {
76
  global $wp_scripts;
@@ -95,11 +95,11 @@ class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Bas
95
  }
96
 
97
  /**
98
- * Getting the field
99
  *
100
- * @param int $index
101
- * @param string $value
102
- * @return string html
103
  */
104
  public function get_field( $index, $value ) {
105
  $name = $this->get_field_name_in_editor( $index );
@@ -117,10 +117,10 @@ class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Bas
117
  }
118
 
119
  /**
120
- * Displaying the option fields in custom field settings page
121
  *
122
- * @param int $group_key
123
- * @param int $field_key
124
  */
125
  public function display_field_options( $group_key, $field_key ) {
126
  $this->display_label_option( $group_key, $field_key );
@@ -217,9 +217,9 @@ class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Bas
217
  }
218
 
219
  /**
220
- * Return datepicker option with json_encode
221
  *
222
- * @return string option with json_encode
223
  */
224
  protected function get_data_js() {
225
  $js = array(
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Field_Datepicker class.
10
  */
11
  class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
+ * Set the required items.
15
  *
16
  * @return array
17
  */
32
  }
33
 
34
  /**
35
+ * Set the non required items.
36
  *
37
  * @return array
38
  */
48
  }
49
 
50
  /**
51
+ * Loading resources for editor.
52
  */
53
  public function editor_enqueue_scripts() {
54
  global $wp_scripts;
70
  }
71
 
72
  /**
73
+ * Loading resources for editor for custom field settings page.
74
  */
75
  public function settings_enqueue_scripts() {
76
  global $wp_scripts;
95
  }
96
 
97
  /**
98
+ * Getting the field.
99
  *
100
+ * @param int $index Field index.
101
+ * @param string $value The value.
102
+ * @return string
103
  */
104
  public function get_field( $index, $value ) {
105
  $name = $this->get_field_name_in_editor( $index );
117
  }
118
 
119
  /**
120
+ * Displaying the option fields in custom field settings page.
121
  *
122
+ * @param int $group_key Group key.
123
+ * @param int $field_key Field key.
124
  */
125
  public function display_field_options( $group_key, $field_key ) {
126
  $this->display_label_option( $group_key, $field_key );
217
  }
218
 
219
  /**
220
+ * Return datepicker option with json_encode.
221
  *
222
+ * @return string
223
  */
224
  protected function get_data_js() {
225
  $js = array(
classes/fields/class.field-datetime-picker.php CHANGED
@@ -1,20 +1,19 @@
1
  <?php
2
  /**
3
- * Class file for Smart_Custom_Fields_Field_Datetime_picker.
4
- *
5
  * @author Toshihiro Kanai <i@miruc.co>
6
- * @package Smart_Custom_Fields
7
  */
8
 
9
  /**
10
- * Class Smart_Custom_Fields_Field_Datetime_Picker.
11
  *
12
  * @since 4.x
13
  */
14
  class Smart_Custom_Fields_Field_Datetime_Picker extends Smart_Custom_Fields_Field_Base {
15
 
16
  /**
17
- * Set the required items
18
  *
19
  * @return array
20
  */
@@ -35,7 +34,7 @@ class Smart_Custom_Fields_Field_Datetime_Picker extends Smart_Custom_Fields_Fiel
35
  }
36
 
37
  /**
38
- * Set the non required items
39
  *
40
  * @return array
41
  */
@@ -52,7 +51,7 @@ class Smart_Custom_Fields_Field_Datetime_Picker extends Smart_Custom_Fields_Fiel
52
  }
53
 
54
  /**
55
- * Loading resources for editor
56
  */
57
  public function editor_enqueue_scripts() {
58
  wp_enqueue_style(
@@ -87,7 +86,7 @@ class Smart_Custom_Fields_Field_Datetime_Picker extends Smart_Custom_Fields_Fiel
87
  }
88
 
89
  /**
90
- * Loading resources for editor for custom field settings page
91
  */
92
  public function settings_enqueue_scripts() {
93
  wp_enqueue_style(
@@ -122,11 +121,11 @@ class Smart_Custom_Fields_Field_Datetime_Picker extends Smart_Custom_Fields_Fiel
122
  }
123
 
124
  /**
125
- * Get the field
126
  *
127
- * @param int $index Index number.
128
- * @param string $value Value.
129
- * @return string HTML content.
130
  */
131
  public function get_field( $index, $value ) {
132
  $name = $this->get_field_name_in_editor( $index );
@@ -143,7 +142,7 @@ class Smart_Custom_Fields_Field_Datetime_Picker extends Smart_Custom_Fields_Fiel
143
  }
144
 
145
  /**
146
- * Displaying the option fields in custom field settings page
147
  *
148
  * @param int $group_key Group key.
149
  * @param int $field_key Field key.
@@ -288,7 +287,7 @@ class Smart_Custom_Fields_Field_Datetime_Picker extends Smart_Custom_Fields_Fiel
288
  /**
289
  * Return locale name for flatpickr.
290
  *
291
- * @return false|string $locale
292
  */
293
  private function get_locale_name() {
294
 
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @license GPL-2.0+
5
  * @author Toshihiro Kanai <i@miruc.co>
 
6
  */
7
 
8
  /**
9
+ * Smart_Custom_Fields_Field_Datetime_Picker class.
10
  *
11
  * @since 4.x
12
  */
13
  class Smart_Custom_Fields_Field_Datetime_Picker extends Smart_Custom_Fields_Field_Base {
14
 
15
  /**
16
+ * Set the required items.
17
  *
18
  * @return array
19
  */
34
  }
35
 
36
  /**
37
+ * Set the non required items.
38
  *
39
  * @return array
40
  */
51
  }
52
 
53
  /**
54
+ * Loading resources for editor.
55
  */
56
  public function editor_enqueue_scripts() {
57
  wp_enqueue_style(
86
  }
87
 
88
  /**
89
+ * Loading resources for editor for custom field settings page.
90
  */
91
  public function settings_enqueue_scripts() {
92
  wp_enqueue_style(
121
  }
122
 
123
  /**
124
+ * Get the field.
125
  *
126
+ * @param int $index Field index.
127
+ * @param string $value The value.
128
+ * @return string
129
  */
130
  public function get_field( $index, $value ) {
131
  $name = $this->get_field_name_in_editor( $index );
142
  }
143
 
144
  /**
145
+ * Displaying the option fields in custom field settings page.
146
  *
147
  * @param int $group_key Group key.
148
  * @param int $field_key Field key.
287
  /**
288
  * Return locale name for flatpickr.
289
  *
290
+ * @return false|string $locale Locale.
291
  */
292
  private function get_locale_name() {
293
 
classes/fields/class.field-file.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Field_File
4
- * Version : 1.3.0
5
- * Author : inc2734
6
- * Created : October 7, 2014
7
- * Modified : September 6, 2016
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Field_File extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
- * Set the required items
15
  *
16
  * @return array
17
  */
@@ -24,7 +24,7 @@ class Smart_Custom_Fields_Field_File extends Smart_Custom_Fields_Field_Base {
24
  }
25
 
26
  /**
27
- * Set the non required items
28
  *
29
  * @return array
30
  */
@@ -36,11 +36,11 @@ class Smart_Custom_Fields_Field_File extends Smart_Custom_Fields_Field_Base {
36
  }
37
 
38
  /**
39
- * Getting the field
40
  *
41
- * @param int $index
42
- * @param string $value
43
- * @return string html
44
  */
45
  public function get_field( $index, $value ) {
46
  $name = $this->get_field_name_in_editor( $index );
@@ -64,7 +64,7 @@ class Smart_Custom_Fields_Field_File extends Smart_Custom_Fields_Field_Base {
64
  $image_src = $image_src[0];
65
  }
66
  } else {
67
- $imag_url = $value;
68
  $path = str_replace( home_url(), '', $value );
69
  $image_path = ABSPATH . untrailingslashit( $path );
70
  if ( file_exists( $image_path ) ) {
@@ -76,12 +76,8 @@ class Smart_Custom_Fields_Field_File extends Smart_Custom_Fields_Field_Base {
76
  }
77
 
78
  if ( $image_src && ! is_array( $image_src ) ) {
79
- $attachment = get_post( $value );
80
- $attachment_name = $attachment->post_name;
81
- $attachment_url = get_attached_file( $attachment->ID );
82
- $filetype = wp_check_filetype( $attachment_url );
83
- $filename = $attachment_name . '.' . $filetype['ext'];
84
- $image = sprintf(
85
  '<a href="%s" target="_blank"><img src="%s" alt="%s" />%s</a>%s',
86
  wp_get_attachment_url( $value ),
87
  esc_url( $image_src ),
@@ -89,7 +85,7 @@ class Smart_Custom_Fields_Field_File extends Smart_Custom_Fields_Field_Base {
89
  esc_attr( $filename ),
90
  $btn_remove
91
  );
92
- $hide_class = '';
93
  }
94
  }
95
 
@@ -108,10 +104,10 @@ class Smart_Custom_Fields_Field_File extends Smart_Custom_Fields_Field_Base {
108
  }
109
 
110
  /**
111
- * Displaying the option fields in custom field settings page
112
  *
113
- * @param int $group_key
114
- * @param int $field_key
115
  */
116
  public function display_field_options( $group_key, $field_key ) {
117
  $this->display_label_option( $group_key, $field_key );
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Field_File class.
10
  */
11
  class Smart_Custom_Fields_Field_File extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
+ * Set the required items.
15
  *
16
  * @return array
17
  */
24
  }
25
 
26
  /**
27
+ * Set the non required items.
28
  *
29
  * @return array
30
  */
36
  }
37
 
38
  /**
39
+ * Getting the field.
40
  *
41
+ * @param int $index Field index.
42
+ * @param string $value The value.
43
+ * @return string
44
  */
45
  public function get_field( $index, $value ) {
46
  $name = $this->get_field_name_in_editor( $index );
64
  $image_src = $image_src[0];
65
  }
66
  } else {
67
+ $image_url = $value;
68
  $path = str_replace( home_url(), '', $value );
69
  $image_path = ABSPATH . untrailingslashit( $path );
70
  if ( file_exists( $image_path ) ) {
76
  }
77
 
78
  if ( $image_src && ! is_array( $image_src ) ) {
79
+ $filename = wp_basename( get_attached_file( $value ) );
80
+ $image = sprintf(
 
 
 
 
81
  '<a href="%s" target="_blank"><img src="%s" alt="%s" />%s</a>%s',
82
  wp_get_attachment_url( $value ),
83
  esc_url( $image_src ),
85
  esc_attr( $filename ),
86
  $btn_remove
87
  );
88
+ $hide_class = '';
89
  }
90
  }
91
 
104
  }
105
 
106
  /**
107
+ * Displaying the option fields in custom field settings page.
108
  *
109
+ * @param int $group_key Group key.
110
+ * @param int $field_key Field key.
111
  */
112
  public function display_field_options( $group_key, $field_key ) {
113
  $this->display_label_option( $group_key, $field_key );
classes/fields/class.field-image.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Field_Image
4
- * Version : 1.3.0
5
- * Author : inc2734
6
- * Created : October 7, 2014
7
- * Modified : September 6, 2016
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Field_Image extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
- * Set the required items
15
  *
16
  * @return array
17
  */
@@ -24,7 +24,7 @@ class Smart_Custom_Fields_Field_Image extends Smart_Custom_Fields_Field_Base {
24
  }
25
 
26
  /**
27
- * Set the non required items
28
  *
29
  * @return array
30
  */
@@ -37,11 +37,11 @@ class Smart_Custom_Fields_Field_Image extends Smart_Custom_Fields_Field_Base {
37
  }
38
 
39
  /**
40
- * Getting the field
41
  *
42
- * @param int $index
43
- * @param string $value
44
- * @return string html
45
  */
46
  public function get_field( $index, $value ) {
47
  $name = $this->get_field_name_in_editor( $index );
@@ -103,10 +103,10 @@ class Smart_Custom_Fields_Field_Image extends Smart_Custom_Fields_Field_Base {
103
  }
104
 
105
  /**
106
- * Displaying the option fields in custom field settings page
107
  *
108
- * @param int $group_key
109
- * @param int $field_key
110
  */
111
  public function display_field_options( $group_key, $field_key ) {
112
  $this->display_label_option( $group_key, $field_key );
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Field_Image class.
10
  */
11
  class Smart_Custom_Fields_Field_Image extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
+ * Set the required items.
15
  *
16
  * @return array
17
  */
24
  }
25
 
26
  /**
27
+ * Set the non required items.
28
  *
29
  * @return array
30
  */
37
  }
38
 
39
  /**
40
+ * Getting the field.
41
  *
42
+ * @param int $index Field index.
43
+ * @param string $value The value.
44
+ * @return string
45
  */
46
  public function get_field( $index, $value ) {
47
  $name = $this->get_field_name_in_editor( $index );
103
  }
104
 
105
  /**
106
+ * Displaying the option fields in custom field settings page.
107
  *
108
+ * @param int $group_key Group key.
109
+ * @param int $field_key Field key.
110
  */
111
  public function display_field_options( $group_key, $field_key ) {
112
  $this->display_label_option( $group_key, $field_key );
classes/fields/class.field-message.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Field_Message
4
- * Version : 1.0.0
5
- * Author : robssanches, inc2734
6
- * Created : June 2, 2018
7
- * Modified : June 2, 2018
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Field_Message extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
- * Set the required items
15
  *
16
  * @return array
17
  */
@@ -26,7 +26,7 @@ class Smart_Custom_Fields_Field_Message extends Smart_Custom_Fields_Field_Base {
26
  }
27
 
28
  /**
29
- * Set the non required items
30
  *
31
  * @return array
32
  */
@@ -38,11 +38,11 @@ class Smart_Custom_Fields_Field_Message extends Smart_Custom_Fields_Field_Base {
38
  }
39
 
40
  /**
41
- * Getting the field
42
  *
43
- * @param int $index
44
- * @param string $value
45
- * @return string html
46
  */
47
  public function get_field( $index, $value ) {
48
  $name = $this->get_field_name_in_editor( $index );
@@ -56,10 +56,10 @@ class Smart_Custom_Fields_Field_Message extends Smart_Custom_Fields_Field_Base {
56
  }
57
 
58
  /**
59
- * Displaying the option fields in custom field settings page
60
  *
61
- * @param int $group_key
62
- * @param int $field_key
63
  */
64
  public function display_field_options( $group_key, $field_key ) {
65
  $this->display_name_option( $group_key, $field_key );
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Field_Message class.
10
  */
11
  class Smart_Custom_Fields_Field_Message extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
+ * Set the required items.
15
  *
16
  * @return array
17
  */
26
  }
27
 
28
  /**
29
+ * Set the non required items.
30
  *
31
  * @return array
32
  */
38
  }
39
 
40
  /**
41
+ * Getting the field.
42
  *
43
+ * @param int $index Field index.
44
+ * @param string $value The value.
45
+ * @return string
46
  */
47
  public function get_field( $index, $value ) {
48
  $name = $this->get_field_name_in_editor( $index );
56
  }
57
 
58
  /**
59
+ * Displaying the option fields in custom field settings page.
60
  *
61
+ * @param int $group_key Group key.
62
+ * @param int $field_key Field key.
63
  */
64
  public function display_field_options( $group_key, $field_key ) {
65
  $this->display_name_option( $group_key, $field_key );
classes/fields/class.field-radio.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Field_Radio
4
- * Version : 1.3.0
5
- * Author : inc2734
6
- * Created : October 7, 2014
7
- * Modified : June 4, 2016
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Field_Radio extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
- * Set the required items
15
  *
16
  * @return array
17
  */
@@ -24,7 +24,7 @@ class Smart_Custom_Fields_Field_Radio extends Smart_Custom_Fields_Field_Base {
24
  }
25
 
26
  /**
27
- * Set the non required items
28
  *
29
  * @return array
30
  */
@@ -39,11 +39,11 @@ class Smart_Custom_Fields_Field_Radio extends Smart_Custom_Fields_Field_Base {
39
  }
40
 
41
  /**
42
- * Getting the field
43
  *
44
- * @param int $index
45
- * @param string $value
46
- * @return string html
47
  */
48
  public function get_field( $index, $value ) {
49
  $name = $this->get_field_name_in_editor( $index );
@@ -75,10 +75,10 @@ class Smart_Custom_Fields_Field_Radio extends Smart_Custom_Fields_Field_Base {
75
  }
76
 
77
  /**
78
- * Displaying the option fields in custom field settings page
79
  *
80
- * @param int $group_key
81
- * @param int $field_key
82
  */
83
  public function display_field_options( $group_key, $field_key ) {
84
  $this->display_label_option( $group_key, $field_key );
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Field_Radio class.
10
  */
11
  class Smart_Custom_Fields_Field_Radio extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
+ * Set the required items.
15
  *
16
  * @return array
17
  */
24
  }
25
 
26
  /**
27
+ * Set the non required items.
28
  *
29
  * @return array
30
  */
39
  }
40
 
41
  /**
42
+ * Getting the field.
43
  *
44
+ * @param int $index Field index.
45
+ * @param string $value The value.
46
+ * @return string
47
  */
48
  public function get_field( $index, $value ) {
49
  $name = $this->get_field_name_in_editor( $index );
75
  }
76
 
77
  /**
78
+ * Displaying the option fields in custom field settings page.
79
  *
80
+ * @param int $group_key Group key.
81
+ * @param int $field_key Field key.
82
  */
83
  public function display_field_options( $group_key, $field_key ) {
84
  $this->display_label_option( $group_key, $field_key );
classes/fields/class.field-related-posts.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Field_Related_Posts
4
- * Version : 1.4.2
5
- * Author : inc2734
6
- * Created : October 7, 2014
7
- * Modified : August 12, 2020
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
- * Set the required items
15
  *
16
  * @return array
17
  */
@@ -28,7 +28,7 @@ class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_
28
  }
29
 
30
  /**
31
- * Set the non required items
32
  *
33
  * @return array
34
  */
@@ -42,11 +42,9 @@ class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_
42
  }
43
 
44
  /**
45
- * Loading resources
46
- *
47
- * @param string $hook
48
  */
49
- public function admin_enqueue_scripts( $hook ) {
50
  wp_enqueue_script(
51
  SCF_Config::PREFIX . 'editor-relation-common',
52
  plugins_url( SCF_Config::NAME ) . '/js/editor-relation-common.js',
@@ -75,7 +73,7 @@ class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_
75
  }
76
 
77
  /**
78
- * Process that loading post when clicking post load button
79
  */
80
  public function relational_posts_search() {
81
  check_ajax_referer( SCF_Config::NAME . '-relation-post-types', 'nonce' );
@@ -130,11 +128,11 @@ class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_
130
  }
131
 
132
  /**
133
- * Getting the field
134
  *
135
- * @param int $index
136
- * @param array $value
137
- * @return string html
138
  */
139
  public function get_field( $index, $value ) {
140
  $name = $this->get_field_name_in_editor( $index );
@@ -250,10 +248,10 @@ class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_
250
  }
251
 
252
  /**
253
- * Displaying the option fields in custom field settings page
254
  *
255
- * @param int $group_key
256
- * @param int $field_key
257
  */
258
  public function display_field_options( $group_key, $field_key ) {
259
  $this->display_label_option( $group_key, $field_key );
@@ -276,12 +274,14 @@ class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_
276
  <?php foreach ( $post_types as $post_type => $post_type_object ) : ?>
277
  <?php
278
  $save_post_types = $this->get( 'post-type' );
279
- $checked = ( is_array( $save_post_types ) && in_array( $post_type, $save_post_types ) ) ? 'checked="checked"' : '';
 
 
280
  ?>
281
  <input type="checkbox"
282
  name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'post-type' ) ); ?>[]"
283
  value="<?php echo esc_attr( $post_type ); ?>"
284
- <?php echo $checked; ?> /><?php echo esc_html( $post_type_object->labels->singular_name ); ?>
285
  <?php endforeach; ?>
286
  </td>
287
  </tr>
@@ -314,10 +314,10 @@ class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_
314
  }
315
 
316
  /**
317
- * Validating when displaying meta data
318
  *
319
- * @param array $value
320
- * @param string $field_type
321
  * @return array
322
  */
323
  public function validate_get_value( $value, $field_type ) {
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Field_Related_Posts class.
10
  */
11
  class Smart_Custom_Fields_Field_Related_Posts extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
+ * Set the required items.
15
  *
16
  * @return array
17
  */
28
  }
29
 
30
  /**
31
+ * Set the non required items.
32
  *
33
  * @return array
34
  */
42
  }
43
 
44
  /**
45
+ * Loading resources.
 
 
46
  */
47
+ public function admin_enqueue_scripts() {
48
  wp_enqueue_script(
49
  SCF_Config::PREFIX . 'editor-relation-common',
50
  plugins_url( SCF_Config::NAME ) . '/js/editor-relation-common.js',
73
  }
74
 
75
  /**
76
+ * Process that loading post when clicking post load button.
77
  */
78
  public function relational_posts_search() {
79
  check_ajax_referer( SCF_Config::NAME . '-relation-post-types', 'nonce' );
128
  }
129
 
130
  /**
131
+ * Getting the field.
132
  *
133
+ * @param int $index Field index.
134
+ * @param array $value The value.
135
+ * @return string
136
  */
137
  public function get_field( $index, $value ) {
138
  $name = $this->get_field_name_in_editor( $index );
248
  }
249
 
250
  /**
251
+ * Displaying the option fields in custom field settings page.
252
  *
253
+ * @param int $group_key Group key.
254
+ * @param int $field_key Field key.
255
  */
256
  public function display_field_options( $group_key, $field_key ) {
257
  $this->display_label_option( $group_key, $field_key );
274
  <?php foreach ( $post_types as $post_type => $post_type_object ) : ?>
275
  <?php
276
  $save_post_types = $this->get( 'post-type' );
277
+ $checked = is_array( $save_post_types ) && in_array( $post_type, $save_post_types, true )
278
+ ? 'checked="checked"'
279
+ : '';
280
  ?>
281
  <input type="checkbox"
282
  name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'post-type' ) ); ?>[]"
283
  value="<?php echo esc_attr( $post_type ); ?>"
284
+ <?php echo $checked; ?> /><?php echo esc_html( $post_type_object->labels->singular_name ); ?>
285
  <?php endforeach; ?>
286
  </td>
287
  </tr>
314
  }
315
 
316
  /**
317
+ * Validating when displaying meta data.
318
  *
319
+ * @param array $value The value.
320
+ * @param string $field_type Field type.
321
  * @return array
322
  */
323
  public function validate_get_value( $value, $field_type ) {
classes/fields/class.field-related-terms.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Field_Related_Terms
4
- * Version : 1.5.1
5
- * Author : inc2734
6
- * Created : October 7, 2014
7
- * Modified : June 04, 2018
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Field_Related_Terms extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
- * Set the required items
15
  *
16
  * @return array
17
  */
@@ -28,7 +28,7 @@ class Smart_Custom_Fields_Field_Related_Terms extends Smart_Custom_Fields_Field_
28
  }
29
 
30
  /**
31
- * Set the non required items
32
  *
33
  * @return array
34
  */
@@ -42,11 +42,9 @@ class Smart_Custom_Fields_Field_Related_Terms extends Smart_Custom_Fields_Field_
42
  }
43
 
44
  /**
45
- * Loading resources
46
- *
47
- * @param string $hook
48
  */
49
- public function admin_enqueue_scripts( $hook ) {
50
  wp_enqueue_script(
51
  SCF_Config::PREFIX . 'editor-relation-common',
52
  plugins_url( SCF_Config::NAME ) . '/js/editor-relation-common.js',
@@ -75,7 +73,7 @@ class Smart_Custom_Fields_Field_Related_Terms extends Smart_Custom_Fields_Field_
75
  }
76
 
77
  /**
78
- * Process that loading post when clicking post load button
79
  */
80
  public function relational_terms_search() {
81
  check_ajax_referer( SCF_Config::NAME . '-relation-taxonomies', 'nonce' );
@@ -119,11 +117,11 @@ class Smart_Custom_Fields_Field_Related_Terms extends Smart_Custom_Fields_Field_
119
  }
120
 
121
  /**
122
- * Getting the field
123
  *
124
- * @param int $index
125
- * @param array $value
126
- * @return string html
127
  */
128
  public function get_field( $index, $value ) {
129
  $name = $this->get_field_name_in_editor( $index );
@@ -227,10 +225,10 @@ class Smart_Custom_Fields_Field_Related_Terms extends Smart_Custom_Fields_Field_
227
  }
228
 
229
  /**
230
- * Displaying the option fields in custom field settings page
231
  *
232
- * @param int $group_key
233
- * @param int $field_key
234
  */
235
  public function display_field_options( $group_key, $field_key ) {
236
  $this->display_label_option( $group_key, $field_key );
@@ -250,12 +248,14 @@ class Smart_Custom_Fields_Field_Related_Terms extends Smart_Custom_Fields_Field_
250
  <?php foreach ( $tasonomies as $taxonomy => $taxonomy_object ) : ?>
251
  <?php
252
  $save_taxonomies = $this->get( 'taxonomy' );
253
- $checked = ( is_array( $save_taxonomies ) && in_array( $taxonomy, $save_taxonomies ) ) ? 'checked="checked"' : '';
 
 
254
  ?>
255
  <input type="checkbox"
256
  name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'taxonomy' ) ); ?>[]"
257
  value="<?php echo esc_attr( $taxonomy ); ?>"
258
- <?php echo $checked; ?> /><?php echo esc_html( $taxonomy_object->labels->singular_name ); ?>
259
  <?php endforeach; ?>
260
  </td>
261
  </tr>
@@ -288,10 +288,10 @@ class Smart_Custom_Fields_Field_Related_Terms extends Smart_Custom_Fields_Field_
288
  }
289
 
290
  /**
291
- * Validating when displaying meta data
292
  *
293
- * @param array $value
294
- * @param string $field_type
295
  * @return array
296
  */
297
  public function validate_get_value( $value, $field_type ) {
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Field_Related_Terms class.
10
  */
11
  class Smart_Custom_Fields_Field_Related_Terms extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
+ * Set the required items.
15
  *
16
  * @return array
17
  */
28
  }
29
 
30
  /**
31
+ * Set the non required items.
32
  *
33
  * @return array
34
  */
42
  }
43
 
44
  /**
45
+ * Loading resources.
 
 
46
  */
47
+ public function admin_enqueue_scripts() {
48
  wp_enqueue_script(
49
  SCF_Config::PREFIX . 'editor-relation-common',
50
  plugins_url( SCF_Config::NAME ) . '/js/editor-relation-common.js',
73
  }
74
 
75
  /**
76
+ * Process that loading post when clicking post load button.
77
  */
78
  public function relational_terms_search() {
79
  check_ajax_referer( SCF_Config::NAME . '-relation-taxonomies', 'nonce' );
117
  }
118
 
119
  /**
120
+ * Getting the field.
121
  *
122
+ * @param int $index Field index.
123
+ * @param string $value The value.
124
+ * @return string
125
  */
126
  public function get_field( $index, $value ) {
127
  $name = $this->get_field_name_in_editor( $index );
225
  }
226
 
227
  /**
228
+ * Displaying the option fields in custom field settings page.
229
  *
230
+ * @param int $group_key Group key.
231
+ * @param int $field_key Field key.
232
  */
233
  public function display_field_options( $group_key, $field_key ) {
234
  $this->display_label_option( $group_key, $field_key );
248
  <?php foreach ( $tasonomies as $taxonomy => $taxonomy_object ) : ?>
249
  <?php
250
  $save_taxonomies = $this->get( 'taxonomy' );
251
+ $checked = is_array( $save_taxonomies ) && in_array( $taxonomy, $save_taxonomies, true )
252
+ ? 'checked="checked"'
253
+ : '';
254
  ?>
255
  <input type="checkbox"
256
  name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'taxonomy' ) ); ?>[]"
257
  value="<?php echo esc_attr( $taxonomy ); ?>"
258
+ <?php echo $checked; ?> /><?php echo esc_html( $taxonomy_object->labels->singular_name ); ?>
259
  <?php endforeach; ?>
260
  </td>
261
  </tr>
288
  }
289
 
290
  /**
291
+ * Validating when displaying meta data.
292
  *
293
+ * @param array $value The value.
294
+ * @param string $field_type Field type.
295
  * @return array
296
  */
297
  public function validate_get_value( $value, $field_type ) {
classes/fields/class.field-select.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Field_Select
4
- * Version : 1.3.0
5
- * Author : inc2734
6
- * Created : October 7, 2014
7
- * Modified : June 4, 2016
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Field_Select extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
- * Set the required items
15
  *
16
  * @return array
17
  */
@@ -24,7 +24,7 @@ class Smart_Custom_Fields_Field_Select extends Smart_Custom_Fields_Field_Base {
24
  }
25
 
26
  /**
27
- * Set the non required items
28
  *
29
  * @return array
30
  */
@@ -38,11 +38,11 @@ class Smart_Custom_Fields_Field_Select extends Smart_Custom_Fields_Field_Base {
38
  }
39
 
40
  /**
41
- * Getting the field
42
  *
43
- * @param int $index
44
- * @param string $value
45
- * @return string html
46
  */
47
  public function get_field( $index, $value ) {
48
  $name = $this->get_field_name_in_editor( $index );
@@ -71,10 +71,10 @@ class Smart_Custom_Fields_Field_Select extends Smart_Custom_Fields_Field_Base {
71
  }
72
 
73
  /**
74
- * Displaying the option fields in custom field settings page
75
  *
76
- * @param int $group_key
77
- * @param int $field_key
78
  */
79
  public function display_field_options( $group_key, $field_key ) {
80
  $this->display_label_option( $group_key, $field_key );
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Field_Select class.
10
  */
11
  class Smart_Custom_Fields_Field_Select extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
+ * Set the required items.
15
  *
16
  * @return array
17
  */
24
  }
25
 
26
  /**
27
+ * Set the non required items.
28
  *
29
  * @return array
30
  */
38
  }
39
 
40
  /**
41
+ * Getting the field.
42
  *
43
+ * @param int $index Field index.
44
+ * @param string $value The value.
45
+ * @return string
46
  */
47
  public function get_field( $index, $value ) {
48
  $name = $this->get_field_name_in_editor( $index );
71
  }
72
 
73
  /**
74
+ * Displaying the option fields in custom field settings page.
75
  *
76
+ * @param int $group_key Group key.
77
+ * @param int $field_key Field key.
78
  */
79
  public function display_field_options( $group_key, $field_key ) {
80
  $this->display_label_option( $group_key, $field_key );
classes/fields/class.field-text.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Field_Text
4
- * Version : 1.2.0
5
- * Author : inc2734
6
- * Created : October 7, 2014
7
- * Modified : June 4, 2016
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Field_Text extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
- * Set the required items
15
  *
16
  * @return array
17
  */
@@ -24,7 +24,7 @@ class Smart_Custom_Fields_Field_Text extends Smart_Custom_Fields_Field_Base {
24
  }
25
 
26
  /**
27
- * Set the non required items
28
  *
29
  * @return array
30
  */
@@ -37,11 +37,11 @@ class Smart_Custom_Fields_Field_Text extends Smart_Custom_Fields_Field_Base {
37
  }
38
 
39
  /**
40
- * Getting the field
41
  *
42
- * @param int $index
43
- * @param string $value
44
- * @return string html
45
  */
46
  public function get_field( $index, $value ) {
47
  $name = $this->get_field_name_in_editor( $index );
@@ -55,10 +55,10 @@ class Smart_Custom_Fields_Field_Text extends Smart_Custom_Fields_Field_Base {
55
  }
56
 
57
  /**
58
- * Displaying the option fields in custom field settings page
59
  *
60
- * @param int $group_key
61
- * @param int $field_key
62
  */
63
  public function display_field_options( $group_key, $field_key ) {
64
  $this->display_label_option( $group_key, $field_key );
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Field_Text class.
10
  */
11
  class Smart_Custom_Fields_Field_Text extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
+ * Set the required items.
15
  *
16
  * @return array
17
  */
24
  }
25
 
26
  /**
27
+ * Set the non required items.
28
  *
29
  * @return array
30
  */
37
  }
38
 
39
  /**
40
+ * Getting the field.
41
  *
42
+ * @param int $index Field index.
43
+ * @param string $value The value.
44
+ * @return string
45
  */
46
  public function get_field( $index, $value ) {
47
  $name = $this->get_field_name_in_editor( $index );
55
  }
56
 
57
  /**
58
+ * Displaying the option fields in custom field settings page.
59
  *
60
+ * @param int $group_key Group key.
61
+ * @param int $field_key Field key.
62
  */
63
  public function display_field_options( $group_key, $field_key ) {
64
  $this->display_label_option( $group_key, $field_key );
classes/fields/class.field-textarea.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Field_Textarea
4
- * Version : 1.3.0
5
- * Author : inc2734
6
- * Created : October 7, 2014
7
- * Modified : June 4, 2016
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Field_Textarea extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
- * Set the required items
15
  *
16
  * @return array
17
  */
@@ -24,7 +24,7 @@ class Smart_Custom_Fields_Field_Textarea extends Smart_Custom_Fields_Field_Base
24
  }
25
 
26
  /**
27
- * Set the non required items
28
  *
29
  * @return array
30
  */
@@ -38,11 +38,11 @@ class Smart_Custom_Fields_Field_Textarea extends Smart_Custom_Fields_Field_Base
38
  }
39
 
40
  /**
41
- * Getting the field
42
  *
43
- * @param int $index
44
- * @param string $value
45
- * @return string html
46
  */
47
  public function get_field( $index, $value ) {
48
  $name = $this->get_field_name_in_editor( $index );
@@ -58,10 +58,10 @@ class Smart_Custom_Fields_Field_Textarea extends Smart_Custom_Fields_Field_Base
58
  }
59
 
60
  /**
61
- * Displaying the option fields in custom field settings page
62
  *
63
- * @param int $group_key
64
- * @param int $field_key
65
  */
66
  public function display_field_options( $group_key, $field_key ) {
67
  $this->display_label_option( $group_key, $field_key );
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Field_Textarea class.
10
  */
11
  class Smart_Custom_Fields_Field_Textarea extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
+ * Set the required items.
15
  *
16
  * @return array
17
  */
24
  }
25
 
26
  /**
27
+ * Set the non required items.
28
  *
29
  * @return array
30
  */
38
  }
39
 
40
  /**
41
+ * Getting the field.
42
  *
43
+ * @param int $index Field index.
44
+ * @param string $value The value.
45
+ * @return string
46
  */
47
  public function get_field( $index, $value ) {
48
  $name = $this->get_field_name_in_editor( $index );
58
  }
59
 
60
  /**
61
+ * Displaying the option fields in custom field settings page.
62
  *
63
+ * @param int $group_key Group key.
64
+ * @param int $field_key Field key.
65
  */
66
  public function display_field_options( $group_key, $field_key ) {
67
  $this->display_label_option( $group_key, $field_key );
classes/fields/class.field-wysiwyg.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Field_Wysiwyg
4
- * Version : 1.2.0
5
- * Author : inc2734
6
- * Created : October 7, 2014
7
- * Modified : June 4, 2016
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
- * Set the required items
15
  *
16
  * @return array
17
  */
@@ -29,7 +29,7 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
29
  }
30
 
31
  /**
32
- * Set the non required items
33
  *
34
  * @return array
35
  */
@@ -42,11 +42,15 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
42
  }
43
 
44
  /**
45
- * Loading js after loading TinyMCE in editor page
46
  */
47
  public function editor_enqueue_scripts() {
48
  add_action( 'after_wp_tiny_mce', array( $this, 'after_wp_tiny_mce' ) );
49
  }
 
 
 
 
50
  public function after_wp_tiny_mce() {
51
  printf(
52
  '<script type="text/javascript" src="%s"></script>',
@@ -55,12 +59,16 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
55
  }
56
 
57
  /**
58
- * Processing to be executed immediately after the field initialization
59
  * If not exec this, taxonomy and profile wysiwyg has js error.
60
  */
61
  protected function after_loaded() {
62
  add_action( 'admin_footer', array( $this, 'admin_footer' ) );
63
  }
 
 
 
 
64
  public function admin_footer() {
65
  ?>
66
  <div style="display:none;">
@@ -70,11 +78,11 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
70
  }
71
 
72
  /**
73
- * Getting the field
74
  *
75
- * @param int $index
76
- * @param string $value
77
- * @return string html
78
  */
79
  public function get_field( $index, $value ) {
80
  $name = $this->get_field_name_in_editor( $index );
@@ -110,10 +118,10 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
110
  }
111
 
112
  /**
113
- * Displaying the option fields in custom field settings page
114
  *
115
- * @param int $group_key
116
- * @param int $field_key
117
  */
118
  public function display_field_options( $group_key, $field_key ) {
119
  $this->display_label_option( $group_key, $field_key );
@@ -149,9 +157,9 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
149
  }
150
 
151
  /**
152
- * Return the media button
153
  *
154
- * @param string $editor_id
155
  * @return string
156
  */
157
  protected function media_buttons( $editor_id = 'content' ) {
@@ -159,16 +167,18 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
159
  return sprintf(
160
  '<a href="#" class="button insert-media add_media" data-editor="%s" title="%s">%s</a>',
161
  esc_attr( $editor_id ),
 
162
  esc_attr__( 'Add Media' ),
 
163
  $img . __( 'Add Media' )
164
  );
165
  }
166
 
167
  /**
168
- * Validating when displaying meta data
169
  *
170
- * @param mixed $value
171
- * @param string $field_type
172
  * @return string|array
173
  */
174
  public function validate_get_value( $value, $field_type ) {
@@ -187,9 +197,9 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
187
  }
188
 
189
  /**
190
- * Hooking functions that is hooked to the_content
191
  *
192
- * @param string $value
193
  * @return string
194
  */
195
  protected function add_the_content_filter( $value ) {
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Field_Wysiwyg class.
10
  */
11
  class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
12
 
13
  /**
14
+ * Set the required items.
15
  *
16
  * @return array
17
  */
29
  }
30
 
31
  /**
32
+ * Set the non required items.
33
  *
34
  * @return array
35
  */
42
  }
43
 
44
  /**
45
+ * Loading js after loading TinyMCE in editor page.
46
  */
47
  public function editor_enqueue_scripts() {
48
  add_action( 'after_wp_tiny_mce', array( $this, 'after_wp_tiny_mce' ) );
49
  }
50
+
51
+ /**
52
+ * Add script for wysiwyg.
53
+ */
54
  public function after_wp_tiny_mce() {
55
  printf(
56
  '<script type="text/javascript" src="%s"></script>',
59
  }
60
 
61
  /**
62
+ * Processing to be executed immediately after the field initialization.
63
  * If not exec this, taxonomy and profile wysiwyg has js error.
64
  */
65
  protected function after_loaded() {
66
  add_action( 'admin_footer', array( $this, 'admin_footer' ) );
67
  }
68
+
69
+ /**
70
+ * Add dummy editor.
71
+ */
72
  public function admin_footer() {
73
  ?>
74
  <div style="display:none;">
78
  }
79
 
80
  /**
81
+ * Getting the field.
82
  *
83
+ * @param int $index Field index.
84
+ * @param string $value The value.
85
+ * @return string
86
  */
87
  public function get_field( $index, $value ) {
88
  $name = $this->get_field_name_in_editor( $index );
118
  }
119
 
120
  /**
121
+ * Displaying the option fields in custom field settings page.
122
  *
123
+ * @param int $group_key Group key.
124
+ * @param int $field_key Field key.
125
  */
126
  public function display_field_options( $group_key, $field_key ) {
127
  $this->display_label_option( $group_key, $field_key );
157
  }
158
 
159
  /**
160
+ * Return the media button.
161
  *
162
+ * @param string $editor_id Editor id.
163
  * @return string
164
  */
165
  protected function media_buttons( $editor_id = 'content' ) {
167
  return sprintf(
168
  '<a href="#" class="button insert-media add_media" data-editor="%s" title="%s">%s</a>',
169
  esc_attr( $editor_id ),
170
+ // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
171
  esc_attr__( 'Add Media' ),
172
+ // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
173
  $img . __( 'Add Media' )
174
  );
175
  }
176
 
177
  /**
178
+ * Validating when displaying meta data.
179
  *
180
+ * @param mixed $value The value.
181
+ * @param string $field_type Field type.
182
  * @return string|array
183
  */
184
  public function validate_get_value( $value, $field_type ) {
197
  }
198
 
199
  /**
200
+ * Hooking functions that is hooked to the_content.
201
  *
202
+ * @param string $value The value.
203
  * @return string
204
  */
205
  protected function add_the_content_filter( $value ) {
classes/models/class.abstract-field-base.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Field_Base
4
- * Version : 1.1.1
5
- * Author : inc2734
6
- * Created : October 7, 2014
7
- * Modified : June 2, 2018
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  abstract class Smart_Custom_Fields_Field_Base {
12
 
@@ -77,18 +77,18 @@ abstract class Smart_Custom_Fields_Field_Base {
77
  }
78
 
79
  /**
80
- * Getting the field
81
  *
82
- * @param int $index
83
- * @param mixed $value
84
- * @return string html
85
  */
86
  abstract public function get_field( $index, $value );
87
 
88
  /**
89
- * Adding the type of this field to fields selection in custom field settings page
90
  *
91
- * @param array $attributes List of fields that belong to the optgroup
92
  * @return array
93
  */
94
  public function field_select( $attributes ) {
@@ -97,23 +97,29 @@ abstract class Smart_Custom_Fields_Field_Base {
97
  }
98
 
99
  /**
100
- * Displaying the option fields in custom field settings page ( Common )
101
  *
102
- * @param int $group_key
103
- * @param int $field_key
104
  */
105
  public function display_options( $group_key, $field_key ) {
106
  $fields = SCF::get_form_field_instances();
107
- foreach ( $fields as $Field ) {
108
- if ( $Field->get_attribute( 'type' ) === $this->get_attribute( 'type' ) ) {
109
  foreach ( $this->options as $key => $value ) {
110
- $Field->set( $key, $value );
111
  }
112
  }
113
- $Field->_display_field_options( $group_key, $field_key );
114
  }
115
  }
116
 
 
 
 
 
 
 
117
  protected function display_name_option( $group_key, $field_key ) {
118
  ?>
119
  <tr>
@@ -130,6 +136,12 @@ abstract class Smart_Custom_Fields_Field_Base {
130
  <?php
131
  }
132
 
 
 
 
 
 
 
133
  protected function display_label_option( $group_key, $field_key ) {
134
  ?>
135
  <tr>
@@ -147,12 +159,19 @@ abstract class Smart_Custom_Fields_Field_Base {
147
  }
148
 
149
  /**
150
- * Displaying the option fields in custom field settings page ( original )
151
  *
152
- * @param int $group_key
153
- * @param int $field_key
154
  */
155
  abstract protected function display_field_options( $group_key, $field_key );
 
 
 
 
 
 
 
156
  public function _display_field_options( $group_key, $field_key ) {
157
  ?>
158
  <tr class="<?php echo esc_attr( SCF_Config::PREFIX . 'field-options' ); ?> <?php echo esc_attr( SCF_Config::PREFIX . 'field-options-' . $this->get_attribute( 'type' ) ); ?> hide">
@@ -166,10 +185,9 @@ abstract class Smart_Custom_Fields_Field_Base {
166
  }
167
 
168
  /**
169
- * Getting the name attribute in editor page
170
  *
171
- * @param string $name
172
- * @param string $index
173
  * @return string
174
  */
175
  protected function get_field_name_in_editor( $index ) {
@@ -182,11 +200,11 @@ abstract class Smart_Custom_Fields_Field_Base {
182
  }
183
 
184
  /**
185
- * Whether to disabled
186
  * Return true only when the null because data that all users have saved when $index is not null
187
  *
188
- * @param string $index
189
- * @return bool $disabled
190
  */
191
  protected function get_disable_attribute( $index ) {
192
  $disabled = false;
@@ -197,11 +215,11 @@ abstract class Smart_Custom_Fields_Field_Base {
197
  }
198
 
199
  /**
200
- * Getting the name attribute in custom field settings page
201
  *
202
- * @param int $group_key
203
- * @param int $field_key
204
- * @param string $name
205
  * @return string
206
  */
207
  public function get_field_name_in_setting( $group_key, $field_key, $name ) {
@@ -215,9 +233,9 @@ abstract class Smart_Custom_Fields_Field_Base {
215
  }
216
 
217
  /**
218
- * Getting saved option value
219
  *
220
- * @param string $key key of the data
221
  * @return mixed
222
  */
223
  public function get( $key ) {
@@ -227,10 +245,10 @@ abstract class Smart_Custom_Fields_Field_Base {
227
  }
228
 
229
  /**
230
- * Set option value
231
  *
232
- * @param string $key
233
- * @param mixed $value
234
  */
235
  public function set( $key, $value ) {
236
  if ( array_key_exists( $key, $this->options ) ) {
@@ -239,9 +257,9 @@ abstract class Smart_Custom_Fields_Field_Base {
239
  }
240
 
241
  /**
242
- * Getting the attribute value
243
  *
244
- * @param string $key
245
  * @return mixed
246
  */
247
  public function get_attribute( $key ) {
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Field_Base class.
10
  */
11
  abstract class Smart_Custom_Fields_Field_Base {
12
 
77
  }
78
 
79
  /**
80
+ * Getting the field.
81
  *
82
+ * @param int $index Field index.
83
+ * @param mixed $value Field value.
84
+ * @return string
85
  */
86
  abstract public function get_field( $index, $value );
87
 
88
  /**
89
+ * Adding the type of this field to fields selection in custom field settings page.
90
  *
91
+ * @param array $attributes List of fields that belong to the optgroup.
92
  * @return array
93
  */
94
  public function field_select( $attributes ) {
97
  }
98
 
99
  /**
100
+ * Displaying the option fields in custom field settings page ( Common ).
101
  *
102
+ * @param int $group_key Group key.
103
+ * @param int $field_key Field key.
104
  */
105
  public function display_options( $group_key, $field_key ) {
106
  $fields = SCF::get_form_field_instances();
107
+ foreach ( $fields as $field ) {
108
+ if ( $field->get_attribute( 'type' ) === $this->get_attribute( 'type' ) ) {
109
  foreach ( $this->options as $key => $value ) {
110
+ $field->set( $key, $value );
111
  }
112
  }
113
+ $field->_display_field_options( $group_key, $field_key );
114
  }
115
  }
116
 
117
+ /**
118
+ * Displaying the name in custom field settings page.
119
+ *
120
+ * @param int $group_key Group key.
121
+ * @param int $field_key Field key.
122
+ */
123
  protected function display_name_option( $group_key, $field_key ) {
124
  ?>
125
  <tr>
136
  <?php
137
  }
138
 
139
+ /**
140
+ * Displaying the label in custom field settings page.
141
+ *
142
+ * @param int $group_key Group key.
143
+ * @param int $field_key Field key.
144
+ */
145
  protected function display_label_option( $group_key, $field_key ) {
146
  ?>
147
  <tr>
159
  }
160
 
161
  /**
162
+ * Displaying the option fields in custom field settings page ( original ).
163
  *
164
+ * @param int $group_key Group key.
165
+ * @param int $field_key Field key.
166
  */
167
  abstract protected function display_field_options( $group_key, $field_key );
168
+
169
+ /**
170
+ * Displaying the option fields in custom field settings page ( original ).
171
+ *
172
+ * @param int $group_key Group key.
173
+ * @param int $field_key Field key.
174
+ */
175
  public function _display_field_options( $group_key, $field_key ) {
176
  ?>
177
  <tr class="<?php echo esc_attr( SCF_Config::PREFIX . 'field-options' ); ?> <?php echo esc_attr( SCF_Config::PREFIX . 'field-options-' . $this->get_attribute( 'type' ) ); ?> hide">
185
  }
186
 
187
  /**
188
+ * Getting the name attribute in editor page.
189
  *
190
+ * @param string $index Field index.
 
191
  * @return string
192
  */
193
  protected function get_field_name_in_editor( $index ) {
200
  }
201
 
202
  /**
203
+ * Whether to disabled.
204
  * Return true only when the null because data that all users have saved when $index is not null
205
  *
206
+ * @param string $index Field index.
207
+ * @return bool
208
  */
209
  protected function get_disable_attribute( $index ) {
210
  $disabled = false;
215
  }
216
 
217
  /**
218
+ * Getting the name attribute in custom field settings page.
219
  *
220
+ * @param int $group_key Group key.
221
+ * @param int $field_key Field key.
222
+ * @param string $name Field name.
223
  * @return string
224
  */
225
  public function get_field_name_in_setting( $group_key, $field_key, $name ) {
233
  }
234
 
235
  /**
236
+ * Getting saved option value.
237
  *
238
+ * @param string $key Key of options of this field.
239
  * @return mixed
240
  */
241
  public function get( $key ) {
245
  }
246
 
247
  /**
248
+ * Set option value.
249
  *
250
+ * @param string $key Key of options of this field.
251
+ * @param mixed $value Value of options of this field.
252
  */
253
  public function set( $key, $value ) {
254
  if ( array_key_exists( $key, $this->options ) ) {
257
  }
258
 
259
  /**
260
+ * Getting the attribute value.
261
  *
262
+ * @param string $key Internal attribute key.
263
  * @return mixed
264
  */
265
  public function get_attribute( $key ) {
classes/models/class.ajax.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Ajax
4
- * Version : 1.2.0
5
- * Author : inc2734
6
- * Created : April 27, 2015
7
- * Modified : December 12, 2015
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Ajax {
12
 
@@ -20,15 +20,15 @@ class Smart_Custom_Fields_Ajax {
20
  }
21
 
22
  /**
23
- * Deleting term meta
24
  *
25
- * @param int $term_id
26
- * @param int $term_taxonomy_id
27
- * @param string $taxonomy
28
- * @param object $deleted_term
29
  */
30
  public function delete_term( $term_id, $term_taxonomy_id, $taxonomy, $deleted_term ) {
31
- $Meta = new Smart_Custom_Fields_Meta( $deleted_term );
32
- $Meta->delete_term_meta_for_wp43();
33
  }
34
  }
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Ajax class.
10
  */
11
  class Smart_Custom_Fields_Ajax {
12
 
20
  }
21
 
22
  /**
23
+ * Deleting term meta.
24
  *
25
+ * @param int $term_id Term ID.
26
+ * @param int $term_taxonomy_id Term taxonomy ID.
27
+ * @param string $taxonomy Taxonomy slug.
28
+ * @param object $deleted_term Copy of the already-deleted term.
29
  */
30
  public function delete_term( $term_id, $term_taxonomy_id, $taxonomy, $deleted_term ) {
31
+ $meta = new Smart_Custom_Fields_Meta( $deleted_term );
32
+ $meta->delete_term_meta_for_wp43();
33
  }
34
  }
classes/models/class.cache.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Cache
4
- * Version : 1.0.0
5
- * Author : inc2734
6
- * Created : Mau 31, 2016
7
- * Modified :
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Cache {
12
 
13
  /**
14
- * Singleton instance
15
  *
16
  * @var Smart_Custom_Fields_Cache
17
  */
@@ -49,9 +49,17 @@ class Smart_Custom_Fields_Cache {
49
  */
50
  protected $repeat_multiple_data = array();
51
 
 
 
 
52
  private function __construct() {}
53
 
54
- public static function getInstance() {
 
 
 
 
 
55
  if ( ! self::$instance ) {
56
  self::$instance = new Smart_Custom_Fields_Cache();
57
  }
@@ -69,34 +77,34 @@ class Smart_Custom_Fields_Cache {
69
  }
70
 
71
  /**
72
- * Saving to cache
73
  *
74
- * @param WP_Post|WP_User|WP_Term|stdClass $object
75
- * @param string $name
76
- * @param mixed $data
77
  */
78
  public function save_meta( $object, $name, $data ) {
79
- $Meta = new Smart_Custom_Fields_Meta( $object );
80
- $id = $Meta->get_id();
81
- $type = $Meta->get_type();
82
- $meta_type = $Meta->get_meta_type();
83
  if ( ! empty( $id ) && ! empty( $type ) && ! empty( $meta_type ) ) {
84
  $this->meta[ $meta_type . '_' . $type . '_' . $id ][ $name ] = $data;
85
  }
86
  }
87
 
88
  /**
89
- * Getting the cache
90
  *
91
- * @param WP_Post|WP_User|WP_Term|stdClass $object
92
- * @param string $name
93
  * @return mixed
94
  */
95
  public function get_meta( $object, $name = null ) {
96
- $Meta = new Smart_Custom_Fields_Meta( $object );
97
- $id = $Meta->get_id();
98
- $type = $Meta->get_type();
99
- $meta_type = $Meta->get_meta_type();
100
  if ( ! empty( $id ) && ! empty( $type ) && ! empty( $meta_type ) ) {
101
  if ( is_null( $name ) ) {
102
  if ( isset( $this->meta[ $meta_type . '_' . $type . '_' . $id ] ) ) {
@@ -111,7 +119,7 @@ class Smart_Custom_Fields_Cache {
111
  }
112
 
113
  /**
114
- * Clear caches
115
  */
116
  public function clear_meta() {
117
  $this->meta = array();
@@ -120,55 +128,55 @@ class Smart_Custom_Fields_Cache {
120
  /**
121
  * Saving to cache that enabled custom field settings in the post type or the role or the term.
122
  *
123
- * @param WP_Post|WP_User|WP_Term|stdClass $object
124
- * @param array $settings_posts
125
  */
126
  public function save_settings_posts( $object, $settings_posts ) {
127
- $Meta = new Smart_Custom_Fields_Meta( $object );
128
- $type = $Meta->get_type( false );
129
- $meta_type = $Meta->get_meta_type();
130
  $this->settings_posts[ $meta_type . '_' . $type ] = $settings_posts;
131
  }
132
 
133
  /**
134
  * Getting cache that enabled custom field settings in the post type or the role or the term.
135
  *
136
- * @param WP_Post|WP_User|WP_Term|stdClass $object
137
  * @return array|null
138
  */
139
  public function get_settings_posts( $object ) {
140
- $Meta = new Smart_Custom_Fields_Meta( $object );
141
- $type = $Meta->get_type( false );
142
- $meta_type = $Meta->get_meta_type();
143
  if ( isset( $this->settings_posts[ $meta_type . '_' . $type ] ) ) {
144
  return $this->settings_posts[ $meta_type . '_' . $type ];
145
  }
146
  }
147
 
148
  /**
149
- * Clear the $settings_posts
150
  */
151
  public function clear_settings_posts() {
152
  $this->settings_posts = array();
153
  }
154
 
155
  /**
156
- * Saving the Setting object to cache
157
  *
158
- * @param int $settings_post_id
159
- * @param Smart_Custom_Fields_Setting $Setting
160
- * @param WP_Post|WP_User|WP_Term|stdClass $object
161
  */
162
- public function save_settings( $settings_post_id, $Setting, $object = null ) {
163
  if ( ! is_null( $object ) ) {
164
- $Meta = new Smart_Custom_Fields_Meta( $object );
165
- $id = $Meta->get_id();
166
- $meta_type = $Meta->get_meta_type();
167
  }
168
  if ( ! empty( $meta_type ) && ! empty( $id ) ) {
169
- $this->settings[ $settings_post_id ][ $meta_type . '_' . $id ] = $Setting;
170
  } else {
171
- $this->settings[ $settings_post_id ][0] = $Setting;
172
  }
173
  }
174
 
@@ -181,15 +189,15 @@ class Smart_Custom_Fields_Cache {
181
  * There isn't a thing of the General ... false
182
  * If there the data for the specified $meta_type + $id ... Smart_Custom_Fields_Setting
183
  *
184
- * @param int $settings_post_id
185
- * @param WP_Post|WP_User|WP_Term|stdClass $object
186
  * @return Smart_Custom_Fields_Setting|false|null
187
  */
188
  public function get_settings( $settings_post_id, $object = null ) {
189
  if ( ! is_null( $object ) ) {
190
- $Meta = new Smart_Custom_Fields_Meta( $object );
191
- $id = $Meta->get_id();
192
- $meta_type = $Meta->get_meta_type();
193
  }
194
 
195
  if ( isset( $this->settings[ $settings_post_id ] ) ) {
@@ -212,32 +220,32 @@ class Smart_Custom_Fields_Cache {
212
  }
213
 
214
  /**
215
- * Saving the delimited identification data of the repeated multi-value items to cache
216
  *
217
- * @param WP_Post|WP_User|WP_Term|stdClass $object
218
- * @param mixed $repeat_multiple_data
219
  */
220
  public function save_repeat_multiple_data( $object, $repeat_multiple_data ) {
221
- $Meta = new Smart_Custom_Fields_Meta( $object );
222
- $id = $Meta->get_id();
223
- $type = $Meta->get_type();
224
- $meta_type = $Meta->get_meta_type();
225
  if ( ! empty( $id ) && ! empty( $type ) && ! empty( $meta_type ) ) {
226
  $this->repeat_multiple_data[ $meta_type . '_' . $type . '_' . $id ] = $repeat_multiple_data;
227
  }
228
  }
229
 
230
  /**
231
- * Getting delimited identification data of the repeated multi-value items from cache
232
  *
233
- * @param WP_Post|WP_User|WP_Term|stdClass $object
234
  * @return mixed
235
  */
236
  public function get_repeat_multiple_data( $object ) {
237
- $Meta = new Smart_Custom_Fields_Meta( $object );
238
- $id = $Meta->get_id();
239
- $type = $Meta->get_type();
240
- $meta_type = $Meta->get_meta_type();
241
  if ( ! empty( $id ) && ! empty( $type ) ) {
242
  if ( isset( $this->repeat_multiple_data[ $meta_type . '_' . $type . '_' . $id ] ) ) {
243
  return $this->repeat_multiple_data[ $meta_type . '_' . $type . '_' . $id ];
@@ -246,7 +254,7 @@ class Smart_Custom_Fields_Cache {
246
  }
247
 
248
  /**
249
- * Clear delimited identification data of the repeated multi-value items cache
250
  */
251
  public function clear_repeat_multiple_data() {
252
  $this->repeat_multiple_data = array();
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Cache class.
10
  */
11
  class Smart_Custom_Fields_Cache {
12
 
13
  /**
14
+ * Singleton instance.
15
  *
16
  * @var Smart_Custom_Fields_Cache
17
  */
49
  */
50
  protected $repeat_multiple_data = array();
51
 
52
+ /**
53
+ * __construct
54
+ */
55
  private function __construct() {}
56
 
57
+ /**
58
+ * Get instance.
59
+ *
60
+ * @return Smart_Custom_Fields_Cache
61
+ */
62
+ public static function get_instance() {
63
  if ( ! self::$instance ) {
64
  self::$instance = new Smart_Custom_Fields_Cache();
65
  }
77
  }
78
 
79
  /**
80
+ * Saving to cache.
81
  *
82
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object type object.
83
+ * @param string $name Cache name.
84
+ * @param mixed $data Cache data.
85
  */
86
  public function save_meta( $object, $name, $data ) {
87
+ $meta = new Smart_Custom_Fields_Meta( $object );
88
+ $id = $meta->get_id();
89
+ $type = $meta->get_type();
90
+ $meta_type = $meta->get_meta_type();
91
  if ( ! empty( $id ) && ! empty( $type ) && ! empty( $meta_type ) ) {
92
  $this->meta[ $meta_type . '_' . $type . '_' . $id ][ $name ] = $data;
93
  }
94
  }
95
 
96
  /**
97
+ * Getting the cache.
98
  *
99
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object type object.
100
+ * @param string $name Cache name.
101
  * @return mixed
102
  */
103
  public function get_meta( $object, $name = null ) {
104
+ $meta = new Smart_Custom_Fields_Meta( $object );
105
+ $id = $meta->get_id();
106
+ $type = $meta->get_type();
107
+ $meta_type = $meta->get_meta_type();
108
  if ( ! empty( $id ) && ! empty( $type ) && ! empty( $meta_type ) ) {
109
  if ( is_null( $name ) ) {
110
  if ( isset( $this->meta[ $meta_type . '_' . $type . '_' . $id ] ) ) {
119
  }
120
 
121
  /**
122
+ * Clear caches.
123
  */
124
  public function clear_meta() {
125
  $this->meta = array();
128
  /**
129
  * Saving to cache that enabled custom field settings in the post type or the role or the term.
130
  *
131
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object type object.
132
+ * @param array $settings_posts Settings.
133
  */
134
  public function save_settings_posts( $object, $settings_posts ) {
135
+ $meta = new Smart_Custom_Fields_Meta( $object );
136
+ $type = $meta->get_type( false );
137
+ $meta_type = $meta->get_meta_type();
138
  $this->settings_posts[ $meta_type . '_' . $type ] = $settings_posts;
139
  }
140
 
141
  /**
142
  * Getting cache that enabled custom field settings in the post type or the role or the term.
143
  *
144
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object type object.
145
  * @return array|null
146
  */
147
  public function get_settings_posts( $object ) {
148
+ $meta = new Smart_Custom_Fields_Meta( $object );
149
+ $type = $meta->get_type( false );
150
+ $meta_type = $meta->get_meta_type();
151
  if ( isset( $this->settings_posts[ $meta_type . '_' . $type ] ) ) {
152
  return $this->settings_posts[ $meta_type . '_' . $type ];
153
  }
154
  }
155
 
156
  /**
157
+ * Clear the $settings_posts.
158
  */
159
  public function clear_settings_posts() {
160
  $this->settings_posts = array();
161
  }
162
 
163
  /**
164
+ * Saving the Setting object to cache.
165
  *
166
+ * @param int $settings_post_id Settings id.
167
+ * @param Smart_Custom_Fields_Setting $setting Smart_Custom_Fields_Setting object.
168
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object type object.
169
  */
170
+ public function save_settings( $settings_post_id, $setting, $object = null ) {
171
  if ( ! is_null( $object ) ) {
172
+ $meta = new Smart_Custom_Fields_Meta( $object );
173
+ $id = $meta->get_id();
174
+ $meta_type = $meta->get_meta_type();
175
  }
176
  if ( ! empty( $meta_type ) && ! empty( $id ) ) {
177
+ $this->settings[ $settings_post_id ][ $meta_type . '_' . $id ] = $setting;
178
  } else {
179
+ $this->settings[ $settings_post_id ][0] = $setting;
180
  }
181
  }
182
 
189
  * There isn't a thing of the General ... false
190
  * If there the data for the specified $meta_type + $id ... Smart_Custom_Fields_Setting
191
  *
192
+ * @param int $settings_post_id Settings id.
193
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object type object.
194
  * @return Smart_Custom_Fields_Setting|false|null
195
  */
196
  public function get_settings( $settings_post_id, $object = null ) {
197
  if ( ! is_null( $object ) ) {
198
+ $meta = new Smart_Custom_Fields_Meta( $object );
199
+ $id = $meta->get_id();
200
+ $meta_type = $meta->get_meta_type();
201
  }
202
 
203
  if ( isset( $this->settings[ $settings_post_id ] ) ) {
220
  }
221
 
222
  /**
223
+ * Saving the delimited identification data of the repeated multi-value items to cache.
224
  *
225
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object type object.
226
+ * @param mixed $repeat_multiple_data Repeat multiple data.
227
  */
228
  public function save_repeat_multiple_data( $object, $repeat_multiple_data ) {
229
+ $meta = new Smart_Custom_Fields_Meta( $object );
230
+ $id = $meta->get_id();
231
+ $type = $meta->get_type();
232
+ $meta_type = $meta->get_meta_type();
233
  if ( ! empty( $id ) && ! empty( $type ) && ! empty( $meta_type ) ) {
234
  $this->repeat_multiple_data[ $meta_type . '_' . $type . '_' . $id ] = $repeat_multiple_data;
235
  }
236
  }
237
 
238
  /**
239
+ * Getting delimited identification data of the repeated multi-value items from cache.
240
  *
241
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Object type object.
242
  * @return mixed
243
  */
244
  public function get_repeat_multiple_data( $object ) {
245
+ $meta = new Smart_Custom_Fields_Meta( $object );
246
+ $id = $meta->get_id();
247
+ $type = $meta->get_type();
248
+ $meta_type = $meta->get_meta_type();
249
  if ( ! empty( $id ) && ! empty( $type ) ) {
250
  if ( isset( $this->repeat_multiple_data[ $meta_type . '_' . $type . '_' . $id ] ) ) {
251
  return $this->repeat_multiple_data[ $meta_type . '_' . $type . '_' . $id ];
254
  }
255
 
256
  /**
257
+ * Clear delimited identification data of the repeated multi-value items cache.
258
  */
259
  public function clear_repeat_multiple_data() {
260
  $this->repeat_multiple_data = array();
classes/models/class.group.php CHANGED
@@ -1,31 +1,31 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Group
4
- * Version : 1.0.0
5
- * Author : inc2734
6
- * Created : September 23, 2014
7
- * Modified : February 27, 2015
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Group {
12
 
13
  /**
14
- * Group name
15
  *
16
  * @var string
17
  */
18
  protected $name = null;
19
 
20
  /**
21
- * Array of field objects
22
  *
23
  * @var array
24
  */
25
  protected $fields = array();
26
 
27
  /**
28
- * Whether repeating group
29
  *
30
  * @var bool
31
  */
@@ -34,25 +34,25 @@ class Smart_Custom_Fields_Group {
34
  /**
35
  * __construct
36
  *
37
- * @param string $group_name
38
- * @param bool $repeat
39
- * @param array $_fields
40
  */
41
  public function __construct( $group_name = null, $repeat = false, array $_fields = array() ) {
42
  $this->name = $group_name;
43
- $this->repeat = ( $repeat === true ) ? true : false;
44
  $fields = array();
45
  foreach ( $_fields as $field_attributes ) {
46
- $Field = SCF::get_form_field_instance( $field_attributes['type'] );
47
- if ( ! is_a( $Field, 'Smart_Custom_Fields_Field_Base' ) ) {
48
  continue;
49
  }
50
  foreach ( $field_attributes as $key => $value ) {
51
- $Field->set( $key, $value );
52
  }
53
 
54
- if ( ! empty( $Field ) ) {
55
- $fields[ $Field->get( 'name' ) ] = $Field;
56
  }
57
  }
58
  $this->fields = $fields;
@@ -80,9 +80,9 @@ class Smart_Custom_Fields_Group {
80
  }
81
 
82
  /**
83
- * Getting the field
84
  *
85
- * @param string $field_name
86
  * @return Smart_Custom_Fields_Field_Base|null
87
  */
88
  public function get_field( $field_name ) {
@@ -93,7 +93,7 @@ class Smart_Custom_Fields_Group {
93
  }
94
 
95
  /**
96
- * Whether repeating group
97
  *
98
  * @return bool
99
  */
@@ -102,20 +102,20 @@ class Smart_Custom_Fields_Group {
102
  }
103
 
104
  /**
105
- * Displaying "hide" if $key isn't empty
106
  *
107
- * @param string $key
108
  */
109
- private function add_hide_class( $key ) {
110
- if ( ! $key ) {
111
  echo 'hide';
112
  }
113
  }
114
 
115
  /**
116
- * Displaying the option fields in custom field settings page ( Common )
117
  *
118
- * @param int $group_key
119
  */
120
  public function display_options( $group_key ) {
121
  ?>
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Group class.
10
  */
11
  class Smart_Custom_Fields_Group {
12
 
13
  /**
14
+ * Group name.
15
  *
16
  * @var string
17
  */
18
  protected $name = null;
19
 
20
  /**
21
+ * Array of field objects.
22
  *
23
  * @var array
24
  */
25
  protected $fields = array();
26
 
27
  /**
28
+ * Whether repeating group.
29
  *
30
  * @var bool
31
  */
34
  /**
35
  * __construct
36
  *
37
+ * @param string $group_name Gruop name.
38
+ * @param bool $repeat If repeat, set true.
39
+ * @param array $_fields Fields.
40
  */
41
  public function __construct( $group_name = null, $repeat = false, array $_fields = array() ) {
42
  $this->name = $group_name;
43
+ $this->repeat = true === $repeat ? true : false;
44
  $fields = array();
45
  foreach ( $_fields as $field_attributes ) {
46
+ $field = SCF::get_form_field_instance( $field_attributes['type'] );
47
+ if ( ! is_a( $field, 'Smart_Custom_Fields_Field_Base' ) ) {
48
  continue;
49
  }
50
  foreach ( $field_attributes as $key => $value ) {
51
+ $field->set( $key, $value );
52
  }
53
 
54
+ if ( ! empty( $field ) ) {
55
+ $fields[ $field->get( 'name' ) ] = $field;
56
  }
57
  }
58
  $this->fields = $fields;
80
  }
81
 
82
  /**
83
+ * Getting the field.
84
  *
85
+ * @param string $field_name Field name.
86
  * @return Smart_Custom_Fields_Field_Base|null
87
  */
88
  public function get_field( $field_name ) {
93
  }
94
 
95
  /**
96
+ * Whether repeating group.
97
  *
98
  * @return bool
99
  */
102
  }
103
 
104
  /**
105
+ * Displaying "hide" if $repeatable is empty.
106
  *
107
+ * @param string $repeatable Repeatable.
108
  */
109
+ private function add_hide_class( $repeatable ) {
110
+ if ( ! $repeatable ) {
111
  echo 'hide';
112
  }
113
  }
114
 
115
  /**
116
+ * Displaying the option fields in custom field settings page ( Common ).
117
  *
118
+ * @param int $group_key Group key.
119
  */
120
  public function display_options( $group_key ) {
121
  ?>
classes/models/class.meta.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Meta
4
- * Version : 2.1.0
5
- * Author : inc2734
6
- * Created : March 17, 2015
7
- * Modified : September 30, 2016
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Meta {
12
 
@@ -16,21 +16,21 @@ class Smart_Custom_Fields_Meta {
16
  protected $object;
17
 
18
  /**
19
- * What meta data
20
  *
21
- * @var string post or user or term or option
22
  */
23
  protected $meta_type = 'post';
24
 
25
  /**
26
- * Post ID or User ID or Term ID or Menu slug
27
  *
28
  * @var int
29
  */
30
  protected $id;
31
 
32
  /**
33
- * Post Type or Role or Taxonomy or Menu slug
34
  *
35
  * @var string
36
  * @deprecated
@@ -38,14 +38,18 @@ class Smart_Custom_Fields_Meta {
38
  protected $type;
39
 
40
  /**
41
- * Post Type or Roles or Taxonomy or Menu slug
42
  *
43
  * @var array
44
  */
45
  protected $types = array();
46
 
47
  /**
48
- * @param WP_Post|WP_User|WP_Term|stdClass $object
 
 
 
 
49
  */
50
  public function __construct( $object ) {
51
  $this->object = $object;
@@ -98,14 +102,15 @@ class Smart_Custom_Fields_Meta {
98
  }
99
 
100
  /**
101
- * Getting type ( Post type or Role or Taxonomy or Menu slug )
102
  *
103
  * @deprecated
104
- * @param bool $accept_revision If post type, whether allow revision post type
 
105
  * @return string
106
  */
107
  public function get_type( $accept_revision = true ) {
108
- if ( $this->meta_type === 'post' && ! $accept_revision ) {
109
  $public_post_type = $this->get_public_post_type( $this->id );
110
  return $public_post_type[0];
111
  }
@@ -113,27 +118,28 @@ class Smart_Custom_Fields_Meta {
113
  }
114
 
115
  /**
116
- * Getting type ( Post type or Role or Taxonomy or Menu slug )
117
  *
118
- * @param bool $accept_revision If post type, whether allow revision post type
119
  * @return array
120
  */
121
  public function get_types( $accept_revision = true ) {
122
- if ( $this->meta_type === 'post' && ! $accept_revision ) {
123
  return $this->get_public_post_type( $this->id );
124
  }
125
  return $this->types;
126
  }
127
 
128
  /**
129
- * Getting post type
130
- * To feel good also Post ID of the revision
131
  *
132
- * @param int $post_id
133
  * @return array
134
  */
135
  protected function get_public_post_type( $post_id ) {
136
- if ( $public_post_id = wp_is_post_revision( $post_id ) ) {
 
137
  $post = get_post( $public_post_id );
138
  } else {
139
  $post = get_post( $post_id );
@@ -145,7 +151,7 @@ class Smart_Custom_Fields_Meta {
145
  }
146
 
147
  /**
148
- * Object with this meta data is whether saved
149
  * Post ... If auto-draft, not saved (new posts in)
150
  * Profile or Taxonomy or option ... Since not display only after saving.
151
  * So if all of meta data is empty,
@@ -153,8 +159,8 @@ class Smart_Custom_Fields_Meta {
153
  *
154
  * @return bool
155
  */
156
- public function is_saved( $key = null ) {
157
- if ( $this->meta_type === 'post' && get_post_status( $this->get_id() ) === 'auto-draft' ) {
158
  return false;
159
  }
160
  if ( ! $this->get() ) {
@@ -166,11 +172,11 @@ class Smart_Custom_Fields_Meta {
166
  /**
167
  * The metadata is wheter saved.
168
  *
169
- * @param string $key
170
  * @return bool
171
  */
172
  public function is_saved_the_key( $key ) {
173
- if ( $this->meta_type === 'post' && get_post_status( $this->get_id() ) === 'auto-draft' ) {
174
  return false;
175
  }
176
 
@@ -186,13 +192,13 @@ class Smart_Custom_Fields_Meta {
186
  }
187
 
188
  /**
189
- * Less than WordPress 4.4 compatibility for term meta
190
  * More than 4.4 are saved in meta. So if that use the meta data.
191
  *
192
  * @return bool
193
  */
194
  public function maybe_4_3_term_meta() {
195
- if ( $this->meta_type == 'term' ) {
196
  if ( ! get_metadata( $this->meta_type, $this->id ) && get_option( $this->get_option_name() ) ) {
197
  return true;
198
  }
@@ -201,10 +207,10 @@ class Smart_Custom_Fields_Meta {
201
  }
202
 
203
  /**
204
- * Getting the meta data
205
  *
206
- * @param string|null $key
207
- * @param bool $single false ... return array, true ... return string
208
  * @return string|array
209
  */
210
  public function get( $key = '', $single = false ) {
@@ -214,22 +220,23 @@ class Smart_Custom_Fields_Meta {
214
  $meta = $this->get_option_metadata( $key, $single );
215
  }
216
 
217
- if ( $key === SCF_Config::PREFIX . 'repeat-multiple-data' ) {
218
  return $meta;
219
  }
220
 
221
  $settings = SCF::get_settings( $this->object );
222
  if ( $key ) {
223
- foreach ( $settings as $Setting ) {
224
- $fields = $Setting->get_fields();
225
  if ( ! empty( $fields[ $key ] ) ) {
226
  return $meta;
227
  }
228
  }
229
  } else {
230
  if ( is_array( $meta ) ) {
231
- foreach ( $settings as $Setting ) {
232
- $fields = $Setting->get_fields();
 
233
  foreach ( $meta as $meta_key => $meta_value ) {
234
  if ( isset( $fields[ $meta_key ] ) ) {
235
  $metas[ $meta_key ] = $meta[ $meta_key ];
@@ -238,7 +245,7 @@ class Smart_Custom_Fields_Meta {
238
  }
239
  }
240
  }
241
- if ( isset( $metas ) ) {
242
  return $metas;
243
  }
244
  if ( $single ) {
@@ -250,8 +257,8 @@ class Smart_Custom_Fields_Meta {
250
  /**
251
  * Getting option like meta data.
252
  *
253
- * @param string|null $key
254
- * @param bool $single false ... return array, true ... return string
255
  * @return string|array
256
  */
257
  protected function get_option_metadata( $key, $single ) {
@@ -280,10 +287,10 @@ class Smart_Custom_Fields_Meta {
280
  /**
281
  * Updating meta data. If the meta data not exist, adding it.
282
  *
283
- * @param string $key
284
- * @param mixed $value
285
- * @param mixed $prev_value If specified, it overwrites the only ones of this value
286
- * @return int|false Meta ID
287
  */
288
  public function update( $key, $value, $prev_value = '' ) {
289
  $return = false;
@@ -303,16 +310,16 @@ class Smart_Custom_Fields_Meta {
303
  /**
304
  * Updating the option like meta data. If the meta data not exist, adding it.
305
  *
306
- * @param string $key
307
- * @param mixed $value
308
- * @param mixed $prev_value If specified, it overwrites the only ones of this value
309
  * @return bool
310
  */
311
  protected function update_option_metadata( $key, $value, $prev_value ) {
312
  $option_name = $this->get_option_name();
313
  $option = get_option( $option_name );
314
  if ( isset( $option[ $key ] ) ) {
315
- if ( $prev_value !== '' ) {
316
  foreach ( $option[ $key ] as $option_key => $option_value ) {
317
  if ( $prev_value === $option_value ) {
318
  $option[ $key ][ $option_key ] = $value;
@@ -332,12 +339,12 @@ class Smart_Custom_Fields_Meta {
332
  }
333
 
334
  /**
335
- * Adding the meta data
336
  *
337
- * @param string $key
338
- * @param mixed $value
339
- * @param bool $unique Whether the key to the unique
340
- * @return int|false Meta ID
341
  */
342
  public function add( $key, $value, $unique = false ) {
343
  $return = false;
@@ -355,11 +362,11 @@ class Smart_Custom_Fields_Meta {
355
  }
356
 
357
  /**
358
- * Adding the option like meta data
359
  *
360
- * @param string $key
361
- * @param mixed $value
362
- * @param bool $unique Whether the key to the unique
363
  * @return bool
364
  */
365
  protected function add_option_metadata( $key, $value, $unique ) {
@@ -368,16 +375,16 @@ class Smart_Custom_Fields_Meta {
368
  if ( ! $unique || ! isset( $option[ $key ] ) ) {
369
  $option[ $key ][] = $value;
370
  $option = stripslashes_deep( $option );
371
- $return = update_option( $option_name, $option, false );
372
  }
373
  return false;
374
  }
375
 
376
  /**
377
- * Deleting the meta data
378
  *
379
- * @param string $key
380
- * @param mixed $value If specified, it deletes the only ones of this value
381
  * @return bool
382
  */
383
  public function delete( $key = '', $value = '' ) {
@@ -394,22 +401,22 @@ class Smart_Custom_Fields_Meta {
394
  }
395
 
396
  /**
397
- * Deleting the option like meta data
398
  *
399
- * @param string $key
400
- * @param mixed $value If specified, it deletes the only ones of this value
401
  * @return bool
402
  */
403
  protected function delete_option_metadata( $key, $value ) {
404
  $option_name = $this->get_option_name();
405
  $option = get_option( $option_name );
406
 
407
- if ( isset( $option[ $key ] ) && $value === '' ) {
408
  unset( $option[ $key ] );
409
  return update_option( $option_name, $option );
410
  }
411
 
412
- if ( isset( $option[ $key ] ) && $value !== '' ) {
413
  foreach ( $option[ $key ] as $option_key => $option_value ) {
414
  if ( $option_value === $value ) {
415
  unset( $option[ $key ][ $option_key ] );
@@ -421,7 +428,7 @@ class Smart_Custom_Fields_Meta {
421
  }
422
 
423
  /**
424
- * Delete all term meta for less than WordPress 4.3
425
  */
426
  public function delete_term_meta_for_wp43() {
427
  $option_name = $this->get_option_name();
@@ -429,11 +436,11 @@ class Smart_Custom_Fields_Meta {
429
  }
430
 
431
  /**
432
- * Saving the meta data based on the posted data
433
  *
434
- * @param array $POST
435
  */
436
- public function save( array $POST ) {
437
  // For repeated multi-value items identification
438
  $repeat_multiple_data = array();
439
 
@@ -446,30 +453,30 @@ class Smart_Custom_Fields_Meta {
446
 
447
  $this->delete( SCF_Config::PREFIX . 'repeat-multiple-data' );
448
 
449
- if ( ! isset( $POST[ SCF_Config::NAME ] ) ) {
450
  return;
451
  }
452
 
453
  $settings = SCF::get_settings( $this->object );
454
  $saved_data = array();
455
 
456
- foreach ( $settings as $Setting ) {
457
- $groups = $Setting->get_groups();
458
- foreach ( $groups as $Group ) {
459
- $fields = $Group->get_fields();
460
- foreach ( $fields as $Field ) {
461
- $field_name = $Field->get( 'name' );
462
- if ( ! isset( $POST[ SCF_Config::NAME ][ $field_name ] ) ) {
463
  continue;
464
  }
465
- $saved_data[ $field_name ] = $POST[ SCF_Config::NAME ][ $field_name ];
466
 
467
  $this->delete( $field_name );
468
- if ( $Field->get_attribute( 'allow-multiple-data' ) ) {
469
  $multiple_data_fields[] = $field_name;
470
  }
471
 
472
- if ( $Group->is_repeatable() && $Field->get_attribute( 'allow-multiple-data' ) ) {
473
  $repeat_multiple_data_fields = $saved_data[ $field_name ];
474
  foreach ( $repeat_multiple_data_fields as $values ) {
475
  if ( is_array( $values ) ) {
@@ -489,7 +496,7 @@ class Smart_Custom_Fields_Meta {
489
 
490
  foreach ( $saved_data as $name => $values ) {
491
  foreach ( $values as $value ) {
492
- if ( in_array( $name, $multiple_data_fields ) && $value === '' ) {
493
  continue;
494
  }
495
  if ( ! is_array( $value ) ) {
@@ -504,20 +511,20 @@ class Smart_Custom_Fields_Meta {
504
  }
505
 
506
  /**
507
- * Restore the data from the revision
508
  *
509
- * @param WP_Post $revision
510
  */
511
  public function restore( $revision ) {
512
- if ( $this->meta_type !== 'post' || is_null( $this->object ) || ! is_a( $revision, 'WP_Post' ) ) {
513
  return;
514
  }
515
 
516
  $settings = SCF::get_settings( $this->object );
517
- foreach ( $settings as $Setting ) {
518
- $fields = $Setting->get_fields();
519
- foreach ( $fields as $Field ) {
520
- $field_name = $Field->get( 'name' );
521
  $this->delete( $field_name );
522
  $value = SCF::get( $field_name, $revision->ID );
523
  if ( is_array( $value ) ) {
@@ -546,7 +553,9 @@ class Smart_Custom_Fields_Meta {
546
  }
547
 
548
  /**
549
- * Getting option name for saved options table
 
 
550
  */
551
  public function get_option_name() {
552
  return sprintf(
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Meta class.
10
  */
11
  class Smart_Custom_Fields_Meta {
12
 
16
  protected $object;
17
 
18
  /**
19
+ * What meta data.
20
  *
21
+ * @var string post or user or term or option.
22
  */
23
  protected $meta_type = 'post';
24
 
25
  /**
26
+ * Post ID or User ID or Term ID or Menu slug.
27
  *
28
  * @var int
29
  */
30
  protected $id;
31
 
32
  /**
33
+ * Post Type or Role or Taxonomy or Menu slug.
34
  *
35
  * @var string
36
  * @deprecated
38
  protected $type;
39
 
40
  /**
41
+ * Post Type or Roles or Taxonomy or Menu slug.
42
  *
43
  * @var array
44
  */
45
  protected $types = array();
46
 
47
  /**
48
+ * __construct
49
+ *
50
+ * @param WP_Post|WP_User|WP_Term|stdClass $object Meta object type object.
51
+ *
52
+ * @throws \Exception If object type not found.
53
  */
54
  public function __construct( $object ) {
55
  $this->object = $object;
102
  }
103
 
104
  /**
105
+ * Getting type ( Post type or Role or Taxonomy or Menu slug ).
106
  *
107
  * @deprecated
108
+ *
109
+ * @param bool $accept_revision If post type, whether allow revision post type.
110
  * @return string
111
  */
112
  public function get_type( $accept_revision = true ) {
113
+ if ( 'post' === $this->meta_type && ! $accept_revision ) {
114
  $public_post_type = $this->get_public_post_type( $this->id );
115
  return $public_post_type[0];
116
  }
118
  }
119
 
120
  /**
121
+ * Getting type ( Post type or Role or Taxonomy or Menu slug ).
122
  *
123
+ * @param bool $accept_revision If post type, whether allow revision post type.
124
  * @return array
125
  */
126
  public function get_types( $accept_revision = true ) {
127
+ if ( 'post' === $this->meta_type && ! $accept_revision ) {
128
  return $this->get_public_post_type( $this->id );
129
  }
130
  return $this->types;
131
  }
132
 
133
  /**
134
+ * Getting post type.
135
+ * To feel good also Post ID of the revision.
136
  *
137
+ * @param int $post_id Post id.
138
  * @return array
139
  */
140
  protected function get_public_post_type( $post_id ) {
141
+ $public_post_id = wp_is_post_revision( $post_id );
142
+ if ( $public_post_id ) {
143
  $post = get_post( $public_post_id );
144
  } else {
145
  $post = get_post( $post_id );
151
  }
152
 
153
  /**
154
+ * Object with this meta data is whether saved.
155
  * Post ... If auto-draft, not saved (new posts in)
156
  * Profile or Taxonomy or option ... Since not display only after saving.
157
  * So if all of meta data is empty,
159
  *
160
  * @return bool
161
  */
162
+ public function is_saved() {
163
+ if ( 'post' === $this->meta_type && 'auto-draft' === get_post_status( $this->get_id() ) ) {
164
  return false;
165
  }
166
  if ( ! $this->get() ) {
172
  /**
173
  * The metadata is wheter saved.
174
  *
175
+ * @param string $key Meta key.
176
  * @return bool
177
  */
178
  public function is_saved_the_key( $key ) {
179
+ if ( 'post' === $this->meta_type && 'auto-draft' === get_post_status( $this->get_id() ) ) {
180
  return false;
181
  }
182
 
192
  }
193
 
194
  /**
195
+ * Less than WordPress 4.4 compatibility for term meta.
196
  * More than 4.4 are saved in meta. So if that use the meta data.
197
  *
198
  * @return bool
199
  */
200
  public function maybe_4_3_term_meta() {
201
+ if ( 'term' === $this->meta_type ) {
202
  if ( ! get_metadata( $this->meta_type, $this->id ) && get_option( $this->get_option_name() ) ) {
203
  return true;
204
  }
207
  }
208
 
209
  /**
210
+ * Getting the meta data.
211
  *
212
+ * @param string|null $key Field key.
213
+ * @param bool $single false ... return array, true ... return string.
214
  * @return string|array
215
  */
216
  public function get( $key = '', $single = false ) {
220
  $meta = $this->get_option_metadata( $key, $single );
221
  }
222
 
223
+ if ( SCF_Config::PREFIX . 'repeat-multiple-data' === $key ) {
224
  return $meta;
225
  }
226
 
227
  $settings = SCF::get_settings( $this->object );
228
  if ( $key ) {
229
+ foreach ( $settings as $setting ) {
230
+ $fields = $setting->get_fields();
231
  if ( ! empty( $fields[ $key ] ) ) {
232
  return $meta;
233
  }
234
  }
235
  } else {
236
  if ( is_array( $meta ) ) {
237
+ $metas = [];
238
+ foreach ( $settings as $setting ) {
239
+ $fields = $setting->get_fields();
240
  foreach ( $meta as $meta_key => $meta_value ) {
241
  if ( isset( $fields[ $meta_key ] ) ) {
242
  $metas[ $meta_key ] = $meta[ $meta_key ];
245
  }
246
  }
247
  }
248
+ if ( ! empty( $metas ) ) {
249
  return $metas;
250
  }
251
  if ( $single ) {
257
  /**
258
  * Getting option like meta data.
259
  *
260
+ * @param string|null $key Option key.
261
+ * @param bool $single false ... return array, true ... return string.
262
  * @return string|array
263
  */
264
  protected function get_option_metadata( $key, $single ) {
287
  /**
288
  * Updating meta data. If the meta data not exist, adding it.
289
  *
290
+ * @param string $key Option key.
291
+ * @param mixed $value Option value.
292
+ * @param mixed $prev_value If specified, it overwrites the only ones of this value.
293
+ * @return int|false
294
  */
295
  public function update( $key, $value, $prev_value = '' ) {
296
  $return = false;
310
  /**
311
  * Updating the option like meta data. If the meta data not exist, adding it.
312
  *
313
+ * @param string $key Option key.
314
+ * @param mixed $value Option value.
315
+ * @param mixed $prev_value If specified, it overwrites the only ones of this value.
316
  * @return bool
317
  */
318
  protected function update_option_metadata( $key, $value, $prev_value ) {
319
  $option_name = $this->get_option_name();
320
  $option = get_option( $option_name );
321
  if ( isset( $option[ $key ] ) ) {
322
+ if ( '' !== $prev_value ) {
323
  foreach ( $option[ $key ] as $option_key => $option_value ) {
324
  if ( $prev_value === $option_value ) {
325
  $option[ $key ][ $option_key ] = $value;
339
  }
340
 
341
  /**
342
+ * Adding the meta data.
343
  *
344
+ * @param string $key Option key.
345
+ * @param mixed $value Option value.
346
+ * @param bool $unique Whether the key to the unique.
347
+ * @return int|false
348
  */
349
  public function add( $key, $value, $unique = false ) {
350
  $return = false;
362
  }
363
 
364
  /**
365
+ * Adding the option like meta data.
366
  *
367
+ * @param string $key Option key.
368
+ * @param mixed $value Option value.
369
+ * @param bool $unique Whether the key to the unique.
370
  * @return bool
371
  */
372
  protected function add_option_metadata( $key, $value, $unique ) {
375
  if ( ! $unique || ! isset( $option[ $key ] ) ) {
376
  $option[ $key ][] = $value;
377
  $option = stripslashes_deep( $option );
378
+ return update_option( $option_name, $option, false );
379
  }
380
  return false;
381
  }
382
 
383
  /**
384
+ * Deleting the meta data.
385
  *
386
+ * @param string $key Meta key.
387
+ * @param mixed $value If specified, it deletes the only ones of this value.
388
  * @return bool
389
  */
390
  public function delete( $key = '', $value = '' ) {
401
  }
402
 
403
  /**
404
+ * Deleting the option like meta data.
405
  *
406
+ * @param string $key Option key.
407
+ * @param mixed $value If specified, it deletes the only ones of this value.
408
  * @return bool
409
  */
410
  protected function delete_option_metadata( $key, $value ) {
411
  $option_name = $this->get_option_name();
412
  $option = get_option( $option_name );
413
 
414
+ if ( isset( $option[ $key ] ) && '' === $value ) {
415
  unset( $option[ $key ] );
416
  return update_option( $option_name, $option );
417
  }
418
 
419
+ if ( isset( $option[ $key ] ) && '' !== $value ) {
420
  foreach ( $option[ $key ] as $option_key => $option_value ) {
421
  if ( $option_value === $value ) {
422
  unset( $option[ $key ][ $option_key ] );
428
  }
429
 
430
  /**
431
+ * Delete all term meta for less than WordPress 4.3.
432
  */
433
  public function delete_term_meta_for_wp43() {
434
  $option_name = $this->get_option_name();
436
  }
437
 
438
  /**
439
+ * Saving the meta data based on the posted data.
440
  *
441
+ * @param array $__post $_POST.
442
  */
443
+ public function save( array $__post ) {
444
  // For repeated multi-value items identification
445
  $repeat_multiple_data = array();
446
 
453
 
454
  $this->delete( SCF_Config::PREFIX . 'repeat-multiple-data' );
455
 
456
+ if ( ! isset( $__post[ SCF_Config::NAME ] ) ) {
457
  return;
458
  }
459
 
460
  $settings = SCF::get_settings( $this->object );
461
  $saved_data = array();
462
 
463
+ foreach ( $settings as $setting ) {
464
+ $groups = $setting->get_groups();
465
+ foreach ( $groups as $group ) {
466
+ $fields = $group->get_fields();
467
+ foreach ( $fields as $field ) {
468
+ $field_name = $field->get( 'name' );
469
+ if ( ! isset( $__post[ SCF_Config::NAME ][ $field_name ] ) ) {
470
  continue;
471
  }
472
+ $saved_data[ $field_name ] = $__post[ SCF_Config::NAME ][ $field_name ];
473
 
474
  $this->delete( $field_name );
475
+ if ( $field->get_attribute( 'allow-multiple-data' ) ) {
476
  $multiple_data_fields[] = $field_name;
477
  }
478
 
479
+ if ( $group->is_repeatable() && $field->get_attribute( 'allow-multiple-data' ) ) {
480
  $repeat_multiple_data_fields = $saved_data[ $field_name ];
481
  foreach ( $repeat_multiple_data_fields as $values ) {
482
  if ( is_array( $values ) ) {
496
 
497
  foreach ( $saved_data as $name => $values ) {
498
  foreach ( $values as $value ) {
499
+ if ( in_array( $name, $multiple_data_fields, true ) && '' === $value ) {
500
  continue;
501
  }
502
  if ( ! is_array( $value ) ) {
511
  }
512
 
513
  /**
514
+ * Restore the data from the revision.
515
  *
516
+ * @param WP_Post $revision The revision post.
517
  */
518
  public function restore( $revision ) {
519
+ if ( 'post' !== $this->meta_type || is_null( $this->object ) || ! is_a( $revision, 'WP_Post' ) ) {
520
  return;
521
  }
522
 
523
  $settings = SCF::get_settings( $this->object );
524
+ foreach ( $settings as $setting ) {
525
+ $fields = $setting->get_fields();
526
+ foreach ( $fields as $field ) {
527
+ $field_name = $field->get( 'name' );
528
  $this->delete( $field_name );
529
  $value = SCF::get( $field_name, $revision->ID );
530
  if ( is_array( $value ) ) {
553
  }
554
 
555
  /**
556
+ * Getting option name for saved options table.
557
+ *
558
+ * @return string
559
  */
560
  public function get_option_name() {
561
  return sprintf(
classes/models/class.options-page.php CHANGED
@@ -1,53 +1,68 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Options_Page
4
- * Version : 1.0.0
5
- * Author : inc2734
6
- * Created : May 29, 2014
7
- * Modified :
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Options_Page {
12
 
13
  /**
 
 
14
  * @var string
15
  */
16
  protected $page_title;
17
 
18
  /**
 
 
19
  * @var string
20
  */
21
  protected $menu_title;
22
 
23
  /**
 
 
24
  * @var string
25
  */
26
  protected $capability;
27
 
28
  /**
 
 
29
  * @var string
30
  */
31
  protected $menu_slug;
32
 
33
  /**
 
 
34
  * @var string
35
  */
36
  protected $icon_url;
37
 
38
  /**
 
 
39
  * @var int
40
  */
41
  protected $position;
42
 
43
  /**
 
 
44
  * @see https://developer.wordpress.org/reference/functions/add_menu_page/
45
- * @param string $page_title
46
- * @param string $menu_title
47
- * @param string $capability
48
- * @param string $menu_slug
49
- * @param string $icon_url
50
- * @param int $position
 
51
  */
52
  public function __construct( $page_title, $menu_title, $capability, $menu_slug, $icon_url = '', $position = null ) {
53
  $this->page_title = $page_title;
@@ -59,6 +74,9 @@ class Smart_Custom_Fields_Options_Page {
59
  add_action( 'admin_menu', array( $this, 'add_options_page_menu' ) );
60
  }
61
 
 
 
 
62
  public function add_options_page_menu() {
63
  return add_menu_page(
64
  $this->page_title,
@@ -71,15 +89,18 @@ class Smart_Custom_Fields_Options_Page {
71
  );
72
  }
73
 
 
 
 
74
  public function display() {
75
- $Option = SCF::generate_option_object( $_GET['page'] );
76
- if ( ! $Option ) {
77
  return;
78
  }
79
  ?>
80
  <div class="wrap">
81
- <h3><?php echo esc_html( $Option->menu_title ); ?></h3>
82
- <?php do_action( SCF_Config::PREFIX . 'custom-options-page', $Option ); ?>
83
  </div>
84
  <?php
85
  }
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Options_Page class.
10
  */
11
  class Smart_Custom_Fields_Options_Page {
12
 
13
  /**
14
+ * The text to be displayed in the title tags of the page when the menu is selected.
15
+ *
16
  * @var string
17
  */
18
  protected $page_title;
19
 
20
  /**
21
+ * The text to be used for the menu.
22
+ *
23
  * @var string
24
  */
25
  protected $menu_title;
26
 
27
  /**
28
+ * The capability required for this menu to be displayed to the user.
29
+ *
30
  * @var string
31
  */
32
  protected $capability;
33
 
34
  /**
35
+ * The slug name to refer to this menu by. Should be unique for this menu page and only include lowercase alphanumeric, dashes, and underscores characters to be compatible with sanitize_key().
36
+ *
37
  * @var string
38
  */
39
  protected $menu_slug;
40
 
41
  /**
42
+ * The URL to the icon to be used for this menu.
43
+ *
44
  * @var string
45
  */
46
  protected $icon_url;
47
 
48
  /**
49
+ * The position in the menu order this item should appear.
50
+ *
51
  * @var int
52
  */
53
  protected $position;
54
 
55
  /**
56
+ * __construct
57
+ *
58
  * @see https://developer.wordpress.org/reference/functions/add_menu_page/
59
+ *
60
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected.
61
+ * @param string $menu_title The text to be used for the menu.
62
+ * @param string $capability The capability required for this menu to be displayed to the user.
63
+ * @param string $menu_slug The slug name to refer to this menu by. Should be unique for this menu page and only include lowercase alphanumeric, dashes, and underscores characters to be compatible with sanitize_key().
64
+ * @param string $icon_url The URL to the icon to be used for this menu.
65
+ * @param int $position The position in the menu order this item should appear.
66
  */
67
  public function __construct( $page_title, $menu_title, $capability, $menu_slug, $icon_url = '', $position = null ) {
68
  $this->page_title = $page_title;
74
  add_action( 'admin_menu', array( $this, 'add_options_page_menu' ) );
75
  }
76
 
77
+ /**
78
+ * Add options page menu.
79
+ */
80
  public function add_options_page_menu() {
81
  return add_menu_page(
82
  $this->page_title,
89
  );
90
  }
91
 
92
+ /**
93
+ * Display option.
94
+ */
95
  public function display() {
96
+ $option = SCF::generate_option_object( $_GET['page'] );
97
+ if ( ! $option ) {
98
  return;
99
  }
100
  ?>
101
  <div class="wrap">
102
+ <h3><?php echo esc_html( $option->menu_title ); ?></h3>
103
+ <?php do_action( SCF_Config::PREFIX . 'custom-options-page', $option ); ?>
104
  </div>
105
  <?php
106
  }
classes/models/class.revisions.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Revisions
4
- * Version : 1.1.6
5
- * Author : inc2734
6
- * Created : September 23, 2014
7
- * Modified : August 24, 2016
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Revisions {
12
 
@@ -36,22 +36,22 @@ class Smart_Custom_Fields_Revisions {
36
  /**
37
  * リビジョンから復元するときに呼び出される
38
  *
39
- * @param int $post_id
40
- * @param int $revision_id
41
  */
42
  public function wp_restore_post_revision( $post_id, $revision_id ) {
43
  $post = get_post( $post_id );
44
  $revision = get_post( $revision_id );
45
 
46
- $Meta = new Smart_Custom_Fields_Meta( $post );
47
- $Meta->restore( $revision );
48
  }
49
 
50
  /**
51
  * リビジョンデータを保存
52
  * *_post_meta はリビジョンIDのときに自動的に本物IDに変換して処理してしまうので、*_metadata を使うこと
53
  *
54
- * @param int $post_id リビジョンの投稿ID
55
  */
56
  public function wp_insert_post( $post_id ) {
57
  if ( ! isset( $_POST[ SCF_Config::NAME ] ) ) {
@@ -70,18 +70,18 @@ class Smart_Custom_Fields_Revisions {
70
  SCF_Config::PREFIX . 'fields-nonce'
71
  );
72
 
73
- $Meta = new Smart_Custom_Fields_Meta( get_post( $post_id ) );
74
- $Meta->save( $_POST );
75
  }
76
 
77
  /**
78
  * プレビューのときはプレビューのメタデータを返す。ただし、アイキャッチはリビジョンが無いので除外する
79
  *
80
- * @param mixed $value
81
- * @param int $post_id
82
- * @param string $meta_key
83
- * @param bool $single
84
- * @return mixed $value
85
  */
86
  public function get_post_metadata( $value, $post_id, $meta_key, $single ) {
87
  if ( ! is_preview() ) {
@@ -93,7 +93,7 @@ class Smart_Custom_Fields_Revisions {
93
  }
94
 
95
  $preview_id = $this->get_preview_id( $post_id );
96
- if ( $preview_id && $meta_key !== '_thumbnail_id' ) {
97
  if ( $post_id !== $preview_id ) {
98
  $value = get_post_meta( $preview_id, $meta_key, $single );
99
  }
@@ -104,14 +104,15 @@ class Smart_Custom_Fields_Revisions {
104
  /**
105
  * プレビューの Post ID を返す
106
  *
107
- * @param int $post_id
108
- * @return int $preview_id
109
  */
110
  protected function get_preview_id( $post_id ) {
111
  global $post;
112
  $preview_id = 0;
113
  if ( isset( $post->ID ) && intval( $post->ID ) === intval( $post_id ) ) {
114
- if ( is_preview() && $preview = wp_get_post_autosave( $post_id ) ) {
 
115
  $preview_id = $preview->ID;
116
  }
117
  }
@@ -121,8 +122,8 @@ class Smart_Custom_Fields_Revisions {
121
  /**
122
  * リビジョン比較画面でメタデータを表示させるためにキーを追加する
123
  *
124
- * @param array $fields
125
- * @return array $fields
126
  */
127
  public function _wp_post_revision_fields( $fields ) {
128
  $fields[ SCF_Config::PREFIX . 'debug-preview' ] = esc_html__( 'Smart Custom Fields', 'smart-custom-fields' );
@@ -142,9 +143,9 @@ class Smart_Custom_Fields_Revisions {
142
  /**
143
  * リビジョン比較画面にメタデータを表示
144
  *
145
- * @param $value
146
- * @param $column
147
- * @param array $post
148
  * @return string
149
  */
150
  public function _wp_post_revision_field_debug_preview( $value, $column, $post ) {
@@ -178,9 +179,9 @@ class Smart_Custom_Fields_Revisions {
178
  /**
179
  * false ならリビジョンとして保存される
180
  *
181
- * @param bool $check_for_changes
182
- * @param WP_Post $last_revision 最新のリビジョン
183
- * @param WP_Post $post 現在の投稿
184
  * @return bool
185
  */
186
  public function wp_save_post_revision_check_for_changes( $check_for_changes, $last_revision, $post ) {
@@ -196,6 +197,8 @@ class Smart_Custom_Fields_Revisions {
196
  if ( isset( $_POST[ SCF_Config::NAME ] ) ) {
197
  $serialized_post_meta = serialize( $post_meta );
198
  $serialized_send_data = $_POST[ SCF_Config::NAME ];
 
 
199
  if ( $serialized_post_meta != $serialized_send_data ) {
200
  return false;
201
  }
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Revisions class.
10
  */
11
  class Smart_Custom_Fields_Revisions {
12
 
36
  /**
37
  * リビジョンから復元するときに呼び出される
38
  *
39
+ * @param int $post_id The post id.
40
+ * @param int $revision_id The revision post id.
41
  */
42
  public function wp_restore_post_revision( $post_id, $revision_id ) {
43
  $post = get_post( $post_id );
44
  $revision = get_post( $revision_id );
45
 
46
+ $meta = new Smart_Custom_Fields_Meta( $post );
47
+ $meta->restore( $revision );
48
  }
49
 
50
  /**
51
  * リビジョンデータを保存
52
  * *_post_meta はリビジョンIDのときに自動的に本物IDに変換して処理してしまうので、*_metadata を使うこと
53
  *
54
+ * @param int $post_id The revision post id.
55
  */
56
  public function wp_insert_post( $post_id ) {
57
  if ( ! isset( $_POST[ SCF_Config::NAME ] ) ) {
70
  SCF_Config::PREFIX . 'fields-nonce'
71
  );
72
 
73
+ $meta = new Smart_Custom_Fields_Meta( get_post( $post_id ) );
74
+ $meta->save( $_POST );
75
  }
76
 
77
  /**
78
  * プレビューのときはプレビューのメタデータを返す。ただし、アイキャッチはリビジョンが無いので除外する
79
  *
80
+ * @param mixed $value The value to return, either a single metadata value or an array of values depending on the value of $single. Default null.
81
+ * @param int $post_id ID of the object metadata is for.
82
+ * @param string $meta_key Metadata key.
83
+ * @param bool $single Whether to return only the first value of the specified $meta_key.
84
+ * @return mixed
85
  */
86
  public function get_post_metadata( $value, $post_id, $meta_key, $single ) {
87
  if ( ! is_preview() ) {
93
  }
94
 
95
  $preview_id = $this->get_preview_id( $post_id );
96
+ if ( $preview_id && '_thumbnail_id' !== $meta_key ) {
97
  if ( $post_id !== $preview_id ) {
98
  $value = get_post_meta( $preview_id, $meta_key, $single );
99
  }
104
  /**
105
  * プレビューの Post ID を返す
106
  *
107
+ * @param int $post_id The post id.
108
+ * @return int
109
  */
110
  protected function get_preview_id( $post_id ) {
111
  global $post;
112
  $preview_id = 0;
113
  if ( isset( $post->ID ) && intval( $post->ID ) === intval( $post_id ) ) {
114
+ $preview = wp_get_post_autosave( $post_id );
115
+ if ( is_preview() && $preview ) {
116
  $preview_id = $preview->ID;
117
  }
118
  }
122
  /**
123
  * リビジョン比較画面でメタデータを表示させるためにキーを追加する
124
  *
125
+ * @param array $fields List of fields to revision. Contains 'post_title', 'post_content', and 'post_excerpt' by default.
126
+ * @return array
127
  */
128
  public function _wp_post_revision_fields( $fields ) {
129
  $fields[ SCF_Config::PREFIX . 'debug-preview' ] = esc_html__( 'Smart Custom Fields', 'smart-custom-fields' );
143
  /**
144
  * リビジョン比較画面にメタデータを表示
145
  *
146
+ * @param string $value The current revision field to compare to or from.
147
+ * @param string $column The current revision field.
148
+ * @param WP_Post $post The revision post object to compare to or from.
149
  * @return string
150
  */
151
  public function _wp_post_revision_field_debug_preview( $value, $column, $post ) {
179
  /**
180
  * false ならリビジョンとして保存される
181
  *
182
+ * @param bool $check_for_changes Whether to check for changes before saving a new revision. Default true.
183
+ * @param WP_Post $last_revision The last revision post object.
184
+ * @param WP_Post $post The post object.
185
  * @return bool
186
  */
187
  public function wp_save_post_revision_check_for_changes( $check_for_changes, $last_revision, $post ) {
197
  if ( isset( $_POST[ SCF_Config::NAME ] ) ) {
198
  $serialized_post_meta = serialize( $post_meta );
199
  $serialized_send_data = $_POST[ SCF_Config::NAME ];
200
+
201
+ // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
202
  if ( $serialized_post_meta != $serialized_send_data ) {
203
  return false;
204
  }
classes/models/class.setting.php CHANGED
@@ -1,31 +1,31 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Setting
4
- * Version : 1.0.0
5
- * Author : inc2734
6
- * Created : September 23, 2014
7
- * Modified : February 27, 2015
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Setting {
12
 
13
  /**
14
- * Post ID of custom field settings page
15
  *
16
  * @var string
17
  */
18
  protected $id;
19
 
20
  /**
21
- * Title of custom field settings page
22
  *
23
  * @var title
24
  */
25
  protected $title;
26
 
27
  /**
28
- * Array of the saved group objects
29
  *
30
  * @var array
31
  */
@@ -34,7 +34,8 @@ class Smart_Custom_Fields_Setting {
34
  /**
35
  * __construct
36
  *
37
- * @param int $post_id
 
38
  */
39
  public function __construct( $id, $title ) {
40
  $this->id = $id;
@@ -64,7 +65,7 @@ class Smart_Custom_Fields_Setting {
64
  }
65
 
66
  /**
67
- * Getting the post ID
68
  *
69
  * @return string
70
  */
@@ -73,7 +74,7 @@ class Smart_Custom_Fields_Setting {
73
  }
74
 
75
  /**
76
- * Getting the post title
77
  *
78
  * @return string
79
  */
@@ -82,7 +83,7 @@ class Smart_Custom_Fields_Setting {
82
  }
83
 
84
  /**
85
- * Getting the group objects
86
  *
87
  * @return array
88
  */
@@ -91,41 +92,41 @@ class Smart_Custom_Fields_Setting {
91
  }
92
 
93
  /**
94
- * Getting together the fields in each group
95
  *
96
  * @return array
97
  */
98
  public function get_fields() {
99
  $groups = $this->get_groups();
100
  $fields = array();
101
- foreach ( $groups as $Group ) {
102
- $fields = array_merge( $fields, $Group->get_fields() );
103
  }
104
  return $fields;
105
  }
106
 
107
  /**
108
- * Adding group to the tail
109
- * If the argument is not, adding an empty group
110
  *
111
- * @param string $group_name
112
- * @param bool $repeat
113
- * @param array $_fields
114
  */
115
  public function add_group( $group_name = null, $repeat = false, array $fields = array() ) {
116
- $Group = $this->new_group( $group_name, $repeat, $fields );
117
- $group_name = $Group->get_name();
118
  if ( $group_name ) {
119
- $this->groups[ $group_name ] = $Group;
120
  } else {
121
- $this->groups[] = $Group;
122
  }
123
  }
124
 
125
  /**
126
- * Getting group
127
  *
128
- * @param string $group_name
129
  * @return Smart_Custom_Fields_Group|false
130
  */
131
  public function get_group( $group_name ) {
@@ -136,24 +137,24 @@ class Smart_Custom_Fields_Setting {
136
  }
137
 
138
  /**
139
- * Adding group to the head
140
- * If the argument is not, adding an empty group
141
  *
142
- * @param string $group_name
143
- * @param bool $repeat
144
- * @param array $_fields
145
  */
146
  public function add_group_unshift( $group_name = null, $repeat = false, array $fields = array() ) {
147
- $Group = $this->new_group( $group_name, $repeat, $fields );
148
- array_unshift( $this->groups, $Group );
149
  }
150
 
151
  /**
152
- * Getting generated new group
153
  *
154
- * @param string $group_name
155
- * @param bool $repeat
156
- * @param array $_fields
157
  */
158
  protected function new_group( $group_name, $repeat, $fields ) {
159
  return new Smart_Custom_Fields_Group( $group_name, $repeat, $fields );
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Setting class.
10
  */
11
  class Smart_Custom_Fields_Setting {
12
 
13
  /**
14
+ * Post ID of custom field settings page.
15
  *
16
  * @var string
17
  */
18
  protected $id;
19
 
20
  /**
21
+ * Title of custom field settings page.
22
  *
23
  * @var title
24
  */
25
  protected $title;
26
 
27
  /**
28
+ * Array of the saved group objects.
29
  *
30
  * @var array
31
  */
34
  /**
35
  * __construct
36
  *
37
+ * @param int $id Post ID of custom field settings page.
38
+ * @param string $title Title of custom field settings page.
39
  */
40
  public function __construct( $id, $title ) {
41
  $this->id = $id;
65
  }
66
 
67
  /**
68
+ * Getting the post ID.
69
  *
70
  * @return string
71
  */
74
  }
75
 
76
  /**
77
+ * Getting the post title.
78
  *
79
  * @return string
80
  */
83
  }
84
 
85
  /**
86
+ * Getting the group objects.
87
  *
88
  * @return array
89
  */
92
  }
93
 
94
  /**
95
+ * Getting together the fields in each group.
96
  *
97
  * @return array
98
  */
99
  public function get_fields() {
100
  $groups = $this->get_groups();
101
  $fields = array();
102
+ foreach ( $groups as $group ) {
103
+ $fields = array_merge( $fields, $group->get_fields() );
104
  }
105
  return $fields;
106
  }
107
 
108
  /**
109
+ * Adding group to the tail.
110
+ * If the argument is not, adding an empty group.
111
  *
112
+ * @param string $group_name Gruop name.
113
+ * @param bool $repeat If repeat, set true.
114
+ * @param array $fields Fields.
115
  */
116
  public function add_group( $group_name = null, $repeat = false, array $fields = array() ) {
117
+ $group = $this->new_group( $group_name, $repeat, $fields );
118
+ $group_name = $group->get_name();
119
  if ( $group_name ) {
120
+ $this->groups[ $group_name ] = $group;
121
  } else {
122
+ $this->groups[] = $group;
123
  }
124
  }
125
 
126
  /**
127
+ * Getting group.
128
  *
129
+ * @param string $group_name Gruop name.
130
  * @return Smart_Custom_Fields_Group|false
131
  */
132
  public function get_group( $group_name ) {
137
  }
138
 
139
  /**
140
+ * Adding group to the head.
141
+ * If the argument is not, adding an empty group.
142
  *
143
+ * @param string $group_name Gruop name.
144
+ * @param bool $repeat If repeat, set true.
145
+ * @param array $fields Fields.
146
  */
147
  public function add_group_unshift( $group_name = null, $repeat = false, array $fields = array() ) {
148
+ $group = $this->new_group( $group_name, $repeat, $fields );
149
+ array_unshift( $this->groups, $group );
150
  }
151
 
152
  /**
153
+ * Getting generated new group.
154
  *
155
+ * @param string $group_name Gruop name.
156
+ * @param bool $repeat If repeat, set true.
157
+ * @param array $fields Fields.
158
  */
159
  protected function new_group( $group_name, $repeat, $fields ) {
160
  return new Smart_Custom_Fields_Group( $group_name, $repeat, $fields );
classes/models/class.yoast-seo-analysis.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * Smart_Custom_Fields_Yoast_SEO_Analysis
4
- * Version : 1.0.0
5
- * Author : robssanches
6
- * Created : July 11, 2018
7
- * Modified : July 11, 2018
8
- * License : GPLv2 or later
9
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  */
11
  class Smart_Custom_Fields_Yoast_SEO_Analysis {
12
 
@@ -19,10 +19,8 @@ class Smart_Custom_Fields_Yoast_SEO_Analysis {
19
 
20
  /**
21
  * Loading resources.
22
- *
23
- * @param string $hook
24
  */
25
- public function admin_enqueue_scripts( $hook ) {
26
  wp_enqueue_script(
27
  SCF_Config::PREFIX . 'yoast-seo-analysis',
28
  plugins_url( SCF_Config::NAME ) . '/js/yoast-seo-analysis.js',
1
  <?php
2
  /**
3
+ * @package smart-custom-fields
4
+ * @author inc2734
5
+ * @license GPL-2.0+
6
+ */
7
+
8
+ /**
9
+ * Smart_Custom_Fields_Yoast_SEO_Analysis class.
10
  */
11
  class Smart_Custom_Fields_Yoast_SEO_Analysis {
12
 
19
 
20
  /**
21
  * Loading resources.
 
 
22
  */
23
+ public function admin_enqueue_scripts() {
24
  wp_enqueue_script(
25
  SCF_Config::PREFIX . 'yoast-seo-analysis',
26
  plugins_url( SCF_Config::NAME ) . '/js/yoast-seo-analysis.js',
composer.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type": "wordpress-plugin",
3
+ "license": "GPL-2.0-or-later",
4
+ "authors": [
5
+ {
6
+ "name": "Takashi Kitajima",
7
+ "email": "inc@2inc.org",
8
+ "homepage": "https://2inc.org"
9
+ },
10
+ {
11
+ "name": "Toshihiro Kanai",
12
+ "email": "i@miruc.co",
13
+ "homepage": "https://miruc.co/",
14
+ "role": "Developer"
15
+ }
16
+ ],
17
+ "require": {
18
+ "php": ">=5.6"
19
+ },
20
+ "require-dev": {
21
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.7",
22
+ "squizlabs/php_codesniffer": "^3.5",
23
+ "phpcompatibility/php-compatibility": "^9.3",
24
+ "wp-coding-standards/wpcs": "^2.3",
25
+ "sirbrillig/phpcs-variable-analysis": "^2.10",
26
+ "wp-phpunit/wp-phpunit": "^5.6"
27
+ },
28
+ "scripts" :{
29
+ "format": "phpcbf --standard=./.phpcs.xml.dist --report-summary --report-source",
30
+ "lint": "phpcs --standard=./.phpcs.xml.dist"
31
+ }
32
+ }
composer.lock ADDED
@@ -0,0 +1,361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_readme": [
3
+ "This file locks the dependencies of your project to a known state",
4
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5
+ "This file is @generated automatically"
6
+ ],
7
+ "content-hash": "ce00d02a64946066cc95ae9b80fb784f",
8
+ "packages": [],
9
+ "packages-dev": [
10
+ {
11
+ "name": "dealerdirect/phpcodesniffer-composer-installer",
12
+ "version": "v0.7.1",
13
+ "source": {
14
+ "type": "git",
15
+ "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
16
+ "reference": "fe390591e0241955f22eb9ba327d137e501c771c"
17
+ },
18
+ "dist": {
19
+ "type": "zip",
20
+ "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/fe390591e0241955f22eb9ba327d137e501c771c",
21
+ "reference": "fe390591e0241955f22eb9ba327d137e501c771c",
22
+ "shasum": ""
23
+ },
24
+ "require": {
25
+ "composer-plugin-api": "^1.0 || ^2.0",
26
+ "php": ">=5.3",
27
+ "squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0"
28
+ },
29
+ "require-dev": {
30
+ "composer/composer": "*",
31
+ "phpcompatibility/php-compatibility": "^9.0",
32
+ "sensiolabs/security-checker": "^4.1.0"
33
+ },
34
+ "type": "composer-plugin",
35
+ "extra": {
36
+ "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
37
+ },
38
+ "autoload": {
39
+ "psr-4": {
40
+ "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
41
+ }
42
+ },
43
+ "notification-url": "https://packagist.org/downloads/",
44
+ "license": [
45
+ "MIT"
46
+ ],
47
+ "authors": [
48
+ {
49
+ "name": "Franck Nijhof",
50
+ "email": "franck.nijhof@dealerdirect.com",
51
+ "homepage": "http://www.frenck.nl",
52
+ "role": "Developer / IT Manager"
53
+ }
54
+ ],
55
+ "description": "PHP_CodeSniffer Standards Composer Installer Plugin",
56
+ "homepage": "http://www.dealerdirect.com",
57
+ "keywords": [
58
+ "PHPCodeSniffer",
59
+ "PHP_CodeSniffer",
60
+ "code quality",
61
+ "codesniffer",
62
+ "composer",
63
+ "installer",
64
+ "phpcs",
65
+ "plugin",
66
+ "qa",
67
+ "quality",
68
+ "standard",
69
+ "standards",
70
+ "style guide",
71
+ "stylecheck",
72
+ "tests"
73
+ ],
74
+ "support": {
75
+ "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues",
76
+ "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer"
77
+ },
78
+ "time": "2020-12-07T18:04:37+00:00"
79
+ },
80
+ {
81
+ "name": "phpcompatibility/php-compatibility",
82
+ "version": "9.3.5",
83
+ "source": {
84
+ "type": "git",
85
+ "url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
86
+ "reference": "9fb324479acf6f39452e0655d2429cc0d3914243"
87
+ },
88
+ "dist": {
89
+ "type": "zip",
90
+ "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243",
91
+ "reference": "9fb324479acf6f39452e0655d2429cc0d3914243",
92
+ "shasum": ""
93
+ },
94
+ "require": {
95
+ "php": ">=5.3",
96
+ "squizlabs/php_codesniffer": "^2.3 || ^3.0.2"
97
+ },
98
+ "conflict": {
99
+ "squizlabs/php_codesniffer": "2.6.2"
100
+ },
101
+ "require-dev": {
102
+ "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0"
103
+ },
104
+ "suggest": {
105
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.",
106
+ "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
107
+ },
108
+ "type": "phpcodesniffer-standard",
109
+ "notification-url": "https://packagist.org/downloads/",
110
+ "license": [
111
+ "LGPL-3.0-or-later"
112
+ ],
113
+ "authors": [
114
+ {
115
+ "name": "Wim Godden",
116
+ "homepage": "https://github.com/wimg",
117
+ "role": "lead"
118
+ },
119
+ {
120
+ "name": "Juliette Reinders Folmer",
121
+ "homepage": "https://github.com/jrfnl",
122
+ "role": "lead"
123
+ },
124
+ {
125
+ "name": "Contributors",
126
+ "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors"
127
+ }
128
+ ],
129
+ "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.",
130
+ "homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
131
+ "keywords": [
132
+ "compatibility",
133
+ "phpcs",
134
+ "standards"
135
+ ],
136
+ "support": {
137
+ "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues",
138
+ "source": "https://github.com/PHPCompatibility/PHPCompatibility"
139
+ },
140
+ "time": "2019-12-27T09:44:58+00:00"
141
+ },
142
+ {
143
+ "name": "sirbrillig/phpcs-variable-analysis",
144
+ "version": "v2.11.2",
145
+ "source": {
146
+ "type": "git",
147
+ "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git",
148
+ "reference": "3fad28475bfbdbf8aa5c440f8a8f89824983d85e"
149
+ },
150
+ "dist": {
151
+ "type": "zip",
152
+ "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/3fad28475bfbdbf8aa5c440f8a8f89824983d85e",
153
+ "reference": "3fad28475bfbdbf8aa5c440f8a8f89824983d85e",
154
+ "shasum": ""
155
+ },
156
+ "require": {
157
+ "php": ">=5.4.0",
158
+ "squizlabs/php_codesniffer": "^3.5"
159
+ },
160
+ "require-dev": {
161
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
162
+ "limedeck/phpunit-detailed-printer": "^3.1 || ^4.0 || ^5.0",
163
+ "phpstan/phpstan": "^0.11.8",
164
+ "phpunit/phpunit": "^5.0 || ^6.5 || ^7.0 || ^8.0",
165
+ "sirbrillig/phpcs-import-detection": "^1.1"
166
+ },
167
+ "type": "phpcodesniffer-standard",
168
+ "autoload": {
169
+ "psr-4": {
170
+ "VariableAnalysis\\": "VariableAnalysis/"
171
+ }
172
+ },
173
+ "notification-url": "https://packagist.org/downloads/",
174
+ "license": [
175
+ "BSD-2-Clause"
176
+ ],
177
+ "authors": [
178
+ {
179
+ "name": "Sam Graham",
180
+ "email": "php-codesniffer-variableanalysis@illusori.co.uk"
181
+ },
182
+ {
183
+ "name": "Payton Swick",
184
+ "email": "payton@foolord.com"
185
+ }
186
+ ],
187
+ "description": "A PHPCS sniff to detect problems with variables.",
188
+ "support": {
189
+ "issues": "https://github.com/sirbrillig/phpcs-variable-analysis/issues",
190
+ "source": "https://github.com/sirbrillig/phpcs-variable-analysis",
191
+ "wiki": "https://github.com/sirbrillig/phpcs-variable-analysis/wiki"
192
+ },
193
+ "time": "2021-07-06T23:45:17+00:00"
194
+ },
195
+ {
196
+ "name": "squizlabs/php_codesniffer",
197
+ "version": "3.6.0",
198
+ "source": {
199
+ "type": "git",
200
+ "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
201
+ "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625"
202
+ },
203
+ "dist": {
204
+ "type": "zip",
205
+ "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625",
206
+ "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625",
207
+ "shasum": ""
208
+ },
209
+ "require": {
210
+ "ext-simplexml": "*",
211
+ "ext-tokenizer": "*",
212
+ "ext-xmlwriter": "*",
213
+ "php": ">=5.4.0"
214
+ },
215
+ "require-dev": {
216
+ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
217
+ },
218
+ "bin": [
219
+ "bin/phpcs",
220
+ "bin/phpcbf"
221
+ ],
222
+ "type": "library",
223
+ "extra": {
224
+ "branch-alias": {
225
+ "dev-master": "3.x-dev"
226
+ }
227
+ },
228
+ "notification-url": "https://packagist.org/downloads/",
229
+ "license": [
230
+ "BSD-3-Clause"
231
+ ],
232
+ "authors": [
233
+ {
234
+ "name": "Greg Sherwood",
235
+ "role": "lead"
236
+ }
237
+ ],
238
+ "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
239
+ "homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
240
+ "keywords": [
241
+ "phpcs",
242
+ "standards"
243
+ ],
244
+ "support": {
245
+ "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
246
+ "source": "https://github.com/squizlabs/PHP_CodeSniffer",
247
+ "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
248
+ },
249
+ "time": "2021-04-09T00:54:41+00:00"
250
+ },
251
+ {
252
+ "name": "wp-coding-standards/wpcs",
253
+ "version": "2.3.0",
254
+ "source": {
255
+ "type": "git",
256
+ "url": "https://github.com/WordPress/WordPress-Coding-Standards.git",
257
+ "reference": "7da1894633f168fe244afc6de00d141f27517b62"
258
+ },
259
+ "dist": {
260
+ "type": "zip",
261
+ "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7da1894633f168fe244afc6de00d141f27517b62",
262
+ "reference": "7da1894633f168fe244afc6de00d141f27517b62",
263
+ "shasum": ""
264
+ },
265
+ "require": {
266
+ "php": ">=5.4",
267
+ "squizlabs/php_codesniffer": "^3.3.1"
268
+ },
269
+ "require-dev": {
270
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6",
271
+ "phpcompatibility/php-compatibility": "^9.0",
272
+ "phpcsstandards/phpcsdevtools": "^1.0",
273
+ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
274
+ },
275
+ "suggest": {
276
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically."
277
+ },
278
+ "type": "phpcodesniffer-standard",
279
+ "notification-url": "https://packagist.org/downloads/",
280
+ "license": [
281
+ "MIT"
282
+ ],
283
+ "authors": [
284
+ {
285
+ "name": "Contributors",
286
+ "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors"
287
+ }
288
+ ],
289
+ "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions",
290
+ "keywords": [
291
+ "phpcs",
292
+ "standards",
293
+ "wordpress"
294
+ ],
295
+ "support": {
296
+ "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues",
297
+ "source": "https://github.com/WordPress/WordPress-Coding-Standards",
298
+ "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki"
299
+ },
300
+ "time": "2020-05-13T23:57:56+00:00"
301
+ },
302
+ {
303
+ "name": "wp-phpunit/wp-phpunit",
304
+ "version": "5.8.1",
305
+ "source": {
306
+ "type": "git",
307
+ "url": "https://github.com/wp-phpunit/wp-phpunit.git",
308
+ "reference": "0b89ad32feae22f3a39e63e44117d6e56bdeed69"
309
+ },
310
+ "dist": {
311
+ "type": "zip",
312
+ "url": "https://api.github.com/repos/wp-phpunit/wp-phpunit/zipball/0b89ad32feae22f3a39e63e44117d6e56bdeed69",
313
+ "reference": "0b89ad32feae22f3a39e63e44117d6e56bdeed69",
314
+ "shasum": ""
315
+ },
316
+ "type": "library",
317
+ "autoload": {
318
+ "files": [
319
+ "__loaded.php"
320
+ ]
321
+ },
322
+ "notification-url": "https://packagist.org/downloads/",
323
+ "license": [
324
+ "GPL-2.0-or-later"
325
+ ],
326
+ "authors": [
327
+ {
328
+ "name": "Evan Mattson",
329
+ "email": "me@aaemnnost.tv"
330
+ },
331
+ {
332
+ "name": "WordPress Community",
333
+ "homepage": "https://wordpress.org/about/"
334
+ }
335
+ ],
336
+ "description": "WordPress core PHPUnit library",
337
+ "homepage": "https://github.com/wp-phpunit",
338
+ "keywords": [
339
+ "phpunit",
340
+ "test",
341
+ "wordpress"
342
+ ],
343
+ "support": {
344
+ "docs": "https://github.com/wp-phpunit/docs",
345
+ "issues": "https://github.com/wp-phpunit/issues",
346
+ "source": "https://github.com/wp-phpunit/wp-phpunit"
347
+ },
348
+ "time": "2021-09-09T19:11:29+00:00"
349
+ }
350
+ ],
351
+ "aliases": [],
352
+ "minimum-stability": "stable",
353
+ "stability-flags": [],
354
+ "prefer-stable": false,
355
+ "prefer-lowest": false,
356
+ "platform": {
357
+ "php": ">=5.6"
358
+ },
359
+ "platform-dev": [],
360
+ "plugin-api-version": "2.0.0"
361
+ }
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Smart Custom Fields ===
2
- Contributors: inc2734, toro_unit, mimosafa, hideokamoto, hisako-isaka, kurudrive, hanamura, justinticktock, designhehe, mayukojpn, hogetan, robssanches, mirucon, sysbird
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: 5.5.0
7
- Stable tag: 4.1.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -129,6 +129,10 @@ You can translate this plugin into your language by using [GlotPress](https://tr
129
 
130
  == Changelog ==
131
 
 
 
 
 
132
  = 4.1.5 =
133
  * Fix ajax bug.
134
 
1
  === Smart Custom Fields ===
2
+ Contributors: inc2734, toro_unit, mimosafa, hideokamoto, hisako-isaka, kurudrive, hanamura, justinticktock, designhehe, mayukojpn, hogetan, robssanches, mirucon, sysbird, kengyu-nakamura, fuyuan9
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: 5.8
7
+ Stable tag: 4.2.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
129
 
130
  == Changelog ==
131
 
132
+ = 4.1.6
133
+ * Some updates by [@kengyu](https://github.com/kengyu)
134
+ * Add filter hook smart-cf-rest_api_post_type by [@fuyuan9](https://github.com/fuyuan9)
135
+
136
  = 4.1.5 =
137
  * Fix ajax bug.
138
 
smart-custom-fields.php CHANGED
@@ -3,13 +3,21 @@
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: 4.1.5
7
  * Author: inc2734
8
  * Author URI: https://2inc.org
9
  * Text Domain: smart-custom-fields
10
  * Domain Path: /languages
11
  * License: GPLv2 or later
12
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
 
 
 
 
 
 
 
 
13
  */
14
  class Smart_Custom_Fields {
15
 
@@ -107,21 +115,25 @@ class Smart_Custom_Fields {
107
  }
108
 
109
  /**
110
- * Run management screens
111
  *
112
- * @param WP_Screen $screen
113
  */
114
  public function current_screen( $screen ) {
115
  // 一覧画面
116
- if ( $screen->id === 'edit-' . SCF_Config::NAME ) {
 
117
  }
 
118
  // 新規作成・編集画面
119
- elseif ( $screen->id === SCF_Config::NAME ) {
120
  require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.settings.php';
121
  new Smart_Custom_Fields_Controller_Settings();
 
122
  }
 
123
  // その他の新規作成・編集画面
124
- elseif ( in_array( $screen->id, get_post_types() ) ) {
125
  $post_id = $this->get_post_id_in_admin();
126
  if ( SCF::get_settings( SCF::generate_post_object( $post_id, $screen->id ) ) ) {
127
  require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.controller-base.php';
@@ -129,18 +141,22 @@ class Smart_Custom_Fields {
129
  new Smart_Custom_Fields_Revisions();
130
  new Smart_Custom_Fields_Controller_Editor();
131
  }
 
132
  }
 
133
  // プロフィール編集画面
134
- elseif ( in_array( $screen->id, array( 'profile', 'user-edit' ) ) ) {
135
  $user_id = $this->get_user_id_in_admin();
136
  if ( SCF::get_settings( get_userdata( $user_id ) ) ) {
137
  require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.controller-base.php';
138
  require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.profile.php';
139
  new Smart_Custom_Fields_Controller_Profile();
140
  }
 
141
  }
 
142
  // タグ、カテゴリー、タクソノミー
143
- elseif ( $screen->taxonomy ) {
144
  $term_id = $this->get_term_id_in_admin();
145
  if ( $term_id ) {
146
  $term = get_term( $term_id, $screen->taxonomy );
@@ -150,19 +166,18 @@ class Smart_Custom_Fields {
150
  new Smart_Custom_Fields_Controller_Taxonomy();
151
  }
152
  }
 
153
  }
154
- // オプションページ
155
- else {
156
- $menu_slug = preg_replace( '/^toplevel_page_(.+)$/', '$1', $screen->id );
157
- $options_pages = SCF::get_options_pages();
158
 
159
- if ( array_key_exists( $menu_slug, $options_pages ) ) {
160
- $Option = SCF::generate_option_object( $menu_slug );
161
- if ( SCF::get_settings( $Option ) ) {
162
- require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.controller-base.php';
163
- require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.option.php';
164
- new Smart_Custom_Fields_Controller_Option();
165
- }
 
 
166
  }
167
  }
168
  }
@@ -205,7 +220,7 @@ class Smart_Custom_Fields {
205
  * Hooking the process that it want to fire when the ajax request.
206
  */
207
  public function ajax_request() {
208
- $Ajax = new Smart_Custom_Fields_Ajax();
209
  }
210
 
211
  /**
@@ -257,7 +272,7 @@ class Smart_Custom_Fields {
257
  $user_id = $_GET['user_id'];
258
  } elseif ( ! empty( $_POST['user_id'] ) ) {
259
  $user_id = $_POST['user_id'];
260
- } elseif ( $screen->id === 'profile' ) {
261
  $current_user = wp_get_current_user();
262
  $user_id = $current_user->ID;
263
  }
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: 4.2.0
7
  * Author: inc2734
8
  * Author URI: https://2inc.org
9
  * Text Domain: smart-custom-fields
10
  * Domain Path: /languages
11
  * License: GPLv2 or later
12
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
+ *
14
+ * @package smart-custom-fields
15
+ * @author inc2734
16
+ * @license GPL-2.0+
17
+ */
18
+
19
+ /**
20
+ * Main class.
21
  */
22
  class Smart_Custom_Fields {
23
 
115
  }
116
 
117
  /**
118
+ * Run management screens.
119
  *
120
+ * @param WP_Screen $screen Current WP_Screen object.
121
  */
122
  public function current_screen( $screen ) {
123
  // 一覧画面
124
+ if ( 'edit-' . SCF_Config::NAME === $screen->id ) {
125
+ return;
126
  }
127
+
128
  // 新規作成・編集画面
129
+ if ( SCF_Config::NAME === $screen->id ) {
130
  require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.settings.php';
131
  new Smart_Custom_Fields_Controller_Settings();
132
+ return;
133
  }
134
+
135
  // その他の新規作成・編集画面
136
+ if ( in_array( $screen->id, get_post_types(), true ) ) {
137
  $post_id = $this->get_post_id_in_admin();
138
  if ( SCF::get_settings( SCF::generate_post_object( $post_id, $screen->id ) ) ) {
139
  require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.controller-base.php';
141
  new Smart_Custom_Fields_Revisions();
142
  new Smart_Custom_Fields_Controller_Editor();
143
  }
144
+ return;
145
  }
146
+
147
  // プロフィール編集画面
148
+ if ( in_array( $screen->id, array( 'profile', 'user-edit' ), true ) ) {
149
  $user_id = $this->get_user_id_in_admin();
150
  if ( SCF::get_settings( get_userdata( $user_id ) ) ) {
151
  require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.controller-base.php';
152
  require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.profile.php';
153
  new Smart_Custom_Fields_Controller_Profile();
154
  }
155
+ return;
156
  }
157
+
158
  // タグ、カテゴリー、タクソノミー
159
+ if ( $screen->taxonomy ) {
160
  $term_id = $this->get_term_id_in_admin();
161
  if ( $term_id ) {
162
  $term = get_term( $term_id, $screen->taxonomy );
166
  new Smart_Custom_Fields_Controller_Taxonomy();
167
  }
168
  }
169
+ return;
170
  }
 
 
 
 
171
 
172
+ // オプションページ
173
+ $menu_slug = preg_replace( '/^toplevel_page_(.+)$/', '$1', $screen->id );
174
+ $options_pages = SCF::get_options_pages();
175
+ if ( array_key_exists( $menu_slug, $options_pages ) ) {
176
+ $option = SCF::generate_option_object( $menu_slug );
177
+ if ( SCF::get_settings( $option ) ) {
178
+ require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.controller-base.php';
179
+ require_once plugin_dir_path( __FILE__ ) . 'classes/controller/class.option.php';
180
+ new Smart_Custom_Fields_Controller_Option();
181
  }
182
  }
183
  }
220
  * Hooking the process that it want to fire when the ajax request.
221
  */
222
  public function ajax_request() {
223
+ new Smart_Custom_Fields_Ajax();
224
  }
225
 
226
  /**
272
  $user_id = $_GET['user_id'];
273
  } elseif ( ! empty( $_POST['user_id'] ) ) {
274
  $user_id = $_POST['user_id'];
275
+ } elseif ( 'profile' === $screen->id ) {
276
  $current_user = wp_get_current_user();
277
  $user_id = $current_user->ID;
278
  }
vendor/autoload.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload.php @generated by Composer
4
+
5
+ require_once __DIR__ . '/composer/autoload_real.php';
6
+
7
+ return ComposerAutoloaderInit26af049b6f0f389bc85dab8067eb205a::getLoader();
vendor/composer/ClassLoader.php ADDED
@@ -0,0 +1,572 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Composer.
5
+ *
6
+ * (c) Nils Adermann <naderman@naderman.de>
7
+ * Jordi Boggiano <j.boggiano@seld.be>
8
+ *
9
+ * For the full copyright and license information, please view the LICENSE
10
+ * file that was distributed with this source code.
11
+ */
12
+
13
+ namespace Composer\Autoload;
14
+
15
+ /**
16
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17
+ *
18
+ * $loader = new \Composer\Autoload\ClassLoader();
19
+ *
20
+ * // register classes with namespaces
21
+ * $loader->add('Symfony\Component', __DIR__.'/component');
22
+ * $loader->add('Symfony', __DIR__.'/framework');
23
+ *
24
+ * // activate the autoloader
25
+ * $loader->register();
26
+ *
27
+ * // to enable searching the include path (eg. for PEAR packages)
28
+ * $loader->setUseIncludePath(true);
29
+ *
30
+ * In this example, if you try to use a class in the Symfony\Component
31
+ * namespace or one of its children (Symfony\Component\Console for instance),
32
+ * the autoloader will first look for the class under the component/
33
+ * directory, and it will then fallback to the framework/ directory if not
34
+ * found before giving up.
35
+ *
36
+ * This class is loosely based on the Symfony UniversalClassLoader.
37
+ *
38
+ * @author Fabien Potencier <fabien@symfony.com>
39
+ * @author Jordi Boggiano <j.boggiano@seld.be>
40
+ * @see https://www.php-fig.org/psr/psr-0/
41
+ * @see https://www.php-fig.org/psr/psr-4/
42
+ */
43
+ class ClassLoader
44
+ {
45
+ /** @var ?string */
46
+ private $vendorDir;
47
+
48
+ // PSR-4
49
+ /**
50
+ * @var array[]
51
+ * @psalm-var array<string, array<string, int>>
52
+ */
53
+ private $prefixLengthsPsr4 = array();
54
+ /**
55
+ * @var array[]
56
+ * @psalm-var array<string, array<int, string>>
57
+ */
58
+ private $prefixDirsPsr4 = array();
59
+ /**
60
+ * @var array[]
61
+ * @psalm-var array<string, string>
62
+ */
63
+ private $fallbackDirsPsr4 = array();
64
+
65
+ // PSR-0
66
+ /**
67
+ * @var array[]
68
+ * @psalm-var array<string, array<string, string[]>>
69
+ */
70
+ private $prefixesPsr0 = array();
71
+ /**
72
+ * @var array[]
73
+ * @psalm-var array<string, string>
74
+ */
75
+ private $fallbackDirsPsr0 = array();
76
+
77
+ /** @var bool */
78
+ private $useIncludePath = false;
79
+
80
+ /**
81
+ * @var string[]
82
+ * @psalm-var array<string, string>
83
+ */
84
+ private $classMap = array();
85
+
86
+ /** @var bool */
87
+ private $classMapAuthoritative = false;
88
+
89
+ /**
90
+ * @var bool[]
91
+ * @psalm-var array<string, bool>
92
+ */
93
+ private $missingClasses = array();
94
+
95
+ /** @var ?string */
96
+ private $apcuPrefix;
97
+
98
+ /**
99
+ * @var self[]
100
+ */
101
+ private static $registeredLoaders = array();
102
+
103
+ /**
104
+ * @param ?string $vendorDir
105
+ */
106
+ public function __construct($vendorDir = null)
107
+ {
108
+ $this->vendorDir = $vendorDir;
109
+ }
110
+
111
+ /**
112
+ * @return string[]
113
+ */
114
+ public function getPrefixes()
115
+ {
116
+ if (!empty($this->prefixesPsr0)) {
117
+ return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
118
+ }
119
+
120
+ return array();
121
+ }
122
+
123
+ /**
124
+ * @return array[]
125
+ * @psalm-return array<string, array<int, string>>
126
+ */
127
+ public function getPrefixesPsr4()
128
+ {
129
+ return $this->prefixDirsPsr4;
130
+ }
131
+
132
+ /**
133
+ * @return array[]
134
+ * @psalm-return array<string, string>
135
+ */
136
+ public function getFallbackDirs()
137
+ {
138
+ return $this->fallbackDirsPsr0;
139
+ }
140
+
141
+ /**
142
+ * @return array[]
143
+ * @psalm-return array<string, string>
144
+ */
145
+ public function getFallbackDirsPsr4()
146
+ {
147
+ return $this->fallbackDirsPsr4;
148
+ }
149
+
150
+ /**
151
+ * @return string[] Array of classname => path
152
+ * @psalm-var array<string, string>
153
+ */
154
+ public function getClassMap()
155
+ {
156
+ return $this->classMap;
157
+ }
158
+
159
+ /**
160
+ * @param string[] $classMap Class to filename map
161
+ * @psalm-param array<string, string> $classMap
162
+ *
163
+ * @return void
164
+ */
165
+ public function addClassMap(array $classMap)
166
+ {
167
+ if ($this->classMap) {
168
+ $this->classMap = array_merge($this->classMap, $classMap);
169
+ } else {
170
+ $this->classMap = $classMap;
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Registers a set of PSR-0 directories for a given prefix, either
176
+ * appending or prepending to the ones previously set for this prefix.
177
+ *
178
+ * @param string $prefix The prefix
179
+ * @param string[]|string $paths The PSR-0 root directories
180
+ * @param bool $prepend Whether to prepend the directories
181
+ *
182
+ * @return void
183
+ */
184
+ public function add($prefix, $paths, $prepend = false)
185
+ {
186
+ if (!$prefix) {
187
+ if ($prepend) {
188
+ $this->fallbackDirsPsr0 = array_merge(
189
+ (array) $paths,
190
+ $this->fallbackDirsPsr0
191
+ );
192
+ } else {
193
+ $this->fallbackDirsPsr0 = array_merge(
194
+ $this->fallbackDirsPsr0,
195
+ (array) $paths
196
+ );
197
+ }
198
+
199
+ return;
200
+ }
201
+
202
+ $first = $prefix[0];
203
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
204
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
205
+
206
+ return;
207
+ }
208
+ if ($prepend) {
209
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
210
+ (array) $paths,
211
+ $this->prefixesPsr0[$first][$prefix]
212
+ );
213
+ } else {
214
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
215
+ $this->prefixesPsr0[$first][$prefix],
216
+ (array) $paths
217
+ );
218
+ }
219
+ }
220
+
221
+ /**
222
+ * Registers a set of PSR-4 directories for a given namespace, either
223
+ * appending or prepending to the ones previously set for this namespace.
224
+ *
225
+ * @param string $prefix The prefix/namespace, with trailing '\\'
226
+ * @param string[]|string $paths The PSR-4 base directories
227
+ * @param bool $prepend Whether to prepend the directories
228
+ *
229
+ * @throws \InvalidArgumentException
230
+ *
231
+ * @return void
232
+ */
233
+ public function addPsr4($prefix, $paths, $prepend = false)
234
+ {
235
+ if (!$prefix) {
236
+ // Register directories for the root namespace.
237
+ if ($prepend) {
238
+ $this->fallbackDirsPsr4 = array_merge(
239
+ (array) $paths,
240
+ $this->fallbackDirsPsr4
241
+ );
242
+ } else {
243
+ $this->fallbackDirsPsr4 = array_merge(
244
+ $this->fallbackDirsPsr4,
245
+ (array) $paths
246
+ );
247
+ }
248
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
249
+ // Register directories for a new namespace.
250
+ $length = strlen($prefix);
251
+ if ('\\' !== $prefix[$length - 1]) {
252
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
253
+ }
254
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
255
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
256
+ } elseif ($prepend) {
257
+ // Prepend directories for an already registered namespace.
258
+ $this->prefixDirsPsr4[$prefix] = array_merge(
259
+ (array) $paths,
260
+ $this->prefixDirsPsr4[$prefix]
261
+ );
262
+ } else {
263
+ // Append directories for an already registered namespace.
264
+ $this->prefixDirsPsr4[$prefix] = array_merge(
265
+ $this->prefixDirsPsr4[$prefix],
266
+ (array) $paths
267
+ );
268
+ }
269
+ }
270
+
271
+ /**
272
+ * Registers a set of PSR-0 directories for a given prefix,
273
+ * replacing any others previously set for this prefix.
274
+ *
275
+ * @param string $prefix The prefix
276
+ * @param string[]|string $paths The PSR-0 base directories
277
+ *
278
+ * @return void
279
+ */
280
+ public function set($prefix, $paths)
281
+ {
282
+ if (!$prefix) {
283
+ $this->fallbackDirsPsr0 = (array) $paths;
284
+ } else {
285
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
286
+ }
287
+ }
288
+
289
+ /**
290
+ * Registers a set of PSR-4 directories for a given namespace,
291
+ * replacing any others previously set for this namespace.
292
+ *
293
+ * @param string $prefix The prefix/namespace, with trailing '\\'
294
+ * @param string[]|string $paths The PSR-4 base directories
295
+ *
296
+ * @throws \InvalidArgumentException
297
+ *
298
+ * @return void
299
+ */
300
+ public function setPsr4($prefix, $paths)
301
+ {
302
+ if (!$prefix) {
303
+ $this->fallbackDirsPsr4 = (array) $paths;
304
+ } else {
305
+ $length = strlen($prefix);
306
+ if ('\\' !== $prefix[$length - 1]) {
307
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
308
+ }
309
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
310
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
311
+ }
312
+ }
313
+
314
+ /**
315
+ * Turns on searching the include path for class files.
316
+ *
317
+ * @param bool $useIncludePath
318
+ *
319
+ * @return void
320
+ */
321
+ public function setUseIncludePath($useIncludePath)
322
+ {
323
+ $this->useIncludePath = $useIncludePath;
324
+ }
325
+
326
+ /**
327
+ * Can be used to check if the autoloader uses the include path to check
328
+ * for classes.
329
+ *
330
+ * @return bool
331
+ */
332
+ public function getUseIncludePath()
333
+ {
334
+ return $this->useIncludePath;
335
+ }
336
+
337
+ /**
338
+ * Turns off searching the prefix and fallback directories for classes
339
+ * that have not been registered with the class map.
340
+ *
341
+ * @param bool $classMapAuthoritative
342
+ *
343
+ * @return void
344
+ */
345
+ public function setClassMapAuthoritative($classMapAuthoritative)
346
+ {
347
+ $this->classMapAuthoritative = $classMapAuthoritative;
348
+ }
349
+
350
+ /**
351
+ * Should class lookup fail if not found in the current class map?
352
+ *
353
+ * @return bool
354
+ */
355
+ public function isClassMapAuthoritative()
356
+ {
357
+ return $this->classMapAuthoritative;
358
+ }
359
+
360
+ /**
361
+ * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
362
+ *
363
+ * @param string|null $apcuPrefix
364
+ *
365
+ * @return void
366
+ */
367
+ public function setApcuPrefix($apcuPrefix)
368
+ {
369
+ $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
370
+ }
371
+
372
+ /**
373
+ * The APCu prefix in use, or null if APCu caching is not enabled.
374
+ *
375
+ * @return string|null
376
+ */
377
+ public function getApcuPrefix()
378
+ {
379
+ return $this->apcuPrefix;
380
+ }
381
+
382
+ /**
383
+ * Registers this instance as an autoloader.
384
+ *
385
+ * @param bool $prepend Whether to prepend the autoloader or not
386
+ *
387
+ * @return void
388
+ */
389
+ public function register($prepend = false)
390
+ {
391
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
392
+
393
+ if (null === $this->vendorDir) {
394
+ return;
395
+ }
396
+
397
+ if ($prepend) {
398
+ self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
399
+ } else {
400
+ unset(self::$registeredLoaders[$this->vendorDir]);
401
+ self::$registeredLoaders[$this->vendorDir] = $this;
402
+ }
403
+ }
404
+
405
+ /**
406
+ * Unregisters this instance as an autoloader.
407
+ *
408
+ * @return void
409
+ */
410
+ public function unregister()
411
+ {
412
+ spl_autoload_unregister(array($this, 'loadClass'));
413
+
414
+ if (null !== $this->vendorDir) {
415
+ unset(self::$registeredLoaders[$this->vendorDir]);
416
+ }
417
+ }
418
+
419
+ /**
420
+ * Loads the given class or interface.
421
+ *
422
+ * @param string $class The name of the class
423
+ * @return true|null True if loaded, null otherwise
424
+ */
425
+ public function loadClass($class)
426
+ {
427
+ if ($file = $this->findFile($class)) {
428
+ includeFile($file);
429
+
430
+ return true;
431
+ }
432
+
433
+ return null;
434
+ }
435
+
436
+ /**
437
+ * Finds the path to the file where the class is defined.
438
+ *
439
+ * @param string $class The name of the class
440
+ *
441
+ * @return string|false The path if found, false otherwise
442
+ */
443
+ public function findFile($class)
444
+ {
445
+ // class map lookup
446
+ if (isset($this->classMap[$class])) {
447
+ return $this->classMap[$class];
448
+ }
449
+ if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
450
+ return false;
451
+ }
452
+ if (null !== $this->apcuPrefix) {
453
+ $file = apcu_fetch($this->apcuPrefix.$class, $hit);
454
+ if ($hit) {
455
+ return $file;
456
+ }
457
+ }
458
+
459
+ $file = $this->findFileWithExtension($class, '.php');
460
+
461
+ // Search for Hack files if we are running on HHVM
462
+ if (false === $file && defined('HHVM_VERSION')) {
463
+ $file = $this->findFileWithExtension($class, '.hh');
464
+ }
465
+
466
+ if (null !== $this->apcuPrefix) {
467
+ apcu_add($this->apcuPrefix.$class, $file);
468
+ }
469
+
470
+ if (false === $file) {
471
+ // Remember that this class does not exist.
472
+ $this->missingClasses[$class] = true;
473
+ }
474
+
475
+ return $file;
476
+ }
477
+
478
+ /**
479
+ * Returns the currently registered loaders indexed by their corresponding vendor directories.
480
+ *
481
+ * @return self[]
482
+ */
483
+ public static function getRegisteredLoaders()
484
+ {
485
+ return self::$registeredLoaders;
486
+ }
487
+
488
+ /**
489
+ * @param string $class
490
+ * @param string $ext
491
+ * @return string|false
492
+ */
493
+ private function findFileWithExtension($class, $ext)
494
+ {
495
+ // PSR-4 lookup
496
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
497
+
498
+ $first = $class[0];
499
+ if (isset($this->prefixLengthsPsr4[$first])) {
500
+ $subPath = $class;
501
+ while (false !== $lastPos = strrpos($subPath, '\\')) {
502
+ $subPath = substr($subPath, 0, $lastPos);
503
+ $search = $subPath . '\\';
504
+ if (isset($this->prefixDirsPsr4[$search])) {
505
+ $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
506
+ foreach ($this->prefixDirsPsr4[$search] as $dir) {
507
+ if (file_exists($file = $dir . $pathEnd)) {
508
+ return $file;
509
+ }
510
+ }
511
+ }
512
+ }
513
+ }
514
+
515
+ // PSR-4 fallback dirs
516
+ foreach ($this->fallbackDirsPsr4 as $dir) {
517
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
518
+ return $file;
519
+ }
520
+ }
521
+
522
+ // PSR-0 lookup
523
+ if (false !== $pos = strrpos($class, '\\')) {
524
+ // namespaced class name
525
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
526
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
527
+ } else {
528
+ // PEAR-like class name
529
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
530
+ }
531
+
532
+ if (isset($this->prefixesPsr0[$first])) {
533
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
534
+ if (0 === strpos($class, $prefix)) {
535
+ foreach ($dirs as $dir) {
536
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
537
+ return $file;
538
+ }
539
+ }
540
+ }
541
+ }
542
+ }
543
+
544
+ // PSR-0 fallback dirs
545
+ foreach ($this->fallbackDirsPsr0 as $dir) {
546
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
547
+ return $file;
548
+ }
549
+ }
550
+
551
+ // PSR-0 include paths.
552
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
553
+ return $file;
554
+ }
555
+
556
+ return false;
557
+ }
558
+ }
559
+
560
+ /**
561
+ * Scope isolated include.
562
+ *
563
+ * Prevents access to $this/self from included files.
564
+ *
565
+ * @param string $file
566
+ * @return void
567
+ * @private
568
+ */
569
+ function includeFile($file)
570
+ {
571
+ include $file;
572
+ }
vendor/composer/InstalledVersions.php ADDED
@@ -0,0 +1,337 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Composer.
5
+ *
6
+ * (c) Nils Adermann <naderman@naderman.de>
7
+ * Jordi Boggiano <j.boggiano@seld.be>
8
+ *
9
+ * For the full copyright and license information, please view the LICENSE
10
+ * file that was distributed with this source code.
11
+ */
12
+
13
+ namespace Composer;
14
+
15
+ use Composer\Autoload\ClassLoader;
16
+ use Composer\Semver\VersionParser;
17
+
18
+ /**
19
+ * This class is copied in every Composer installed project and available to all
20
+ *
21
+ * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
22
+ *
23
+ * To require its presence, you can require `composer-runtime-api ^2.0`
24
+ */
25
+ class InstalledVersions
26
+ {
27
+ private static $installed;
28
+ private static $canGetVendors;
29
+ private static $installedByVendor = array();
30
+
31
+ /**
32
+ * Returns a list of all package names which are present, either by being installed, replaced or provided
33
+ *
34
+ * @return string[]
35
+ * @psalm-return list<string>
36
+ */
37
+ public static function getInstalledPackages()
38
+ {
39
+ $packages = array();
40
+ foreach (self::getInstalled() as $installed) {
41
+ $packages[] = array_keys($installed['versions']);
42
+ }
43
+
44
+ if (1 === \count($packages)) {
45
+ return $packages[0];
46
+ }
47
+
48
+ return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
49
+ }
50
+
51
+ /**
52
+ * Returns a list of all package names with a specific type e.g. 'library'
53
+ *
54
+ * @param string $type
55
+ * @return string[]
56
+ * @psalm-return list<string>
57
+ */
58
+ public static function getInstalledPackagesByType($type)
59
+ {
60
+ $packagesByType = array();
61
+
62
+ foreach (self::getInstalled() as $installed) {
63
+ foreach ($installed['versions'] as $name => $package) {
64
+ if (isset($package['type']) && $package['type'] === $type) {
65
+ $packagesByType[] = $name;
66
+ }
67
+ }
68
+ }
69
+
70
+ return $packagesByType;
71
+ }
72
+
73
+ /**
74
+ * Checks whether the given package is installed
75
+ *
76
+ * This also returns true if the package name is provided or replaced by another package
77
+ *
78
+ * @param string $packageName
79
+ * @param bool $includeDevRequirements
80
+ * @return bool
81
+ */
82
+ public static function isInstalled($packageName, $includeDevRequirements = true)
83
+ {
84
+ foreach (self::getInstalled() as $installed) {
85
+ if (isset($installed['versions'][$packageName])) {
86
+ return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
87
+ }
88
+ }
89
+
90
+ return false;
91
+ }
92
+
93
+ /**
94
+ * Checks whether the given package satisfies a version constraint
95
+ *
96
+ * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
97
+ *
98
+ * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
99
+ *
100
+ * @param VersionParser $parser Install composer/semver to have access to this class and functionality
101
+ * @param string $packageName
102
+ * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
103
+ * @return bool
104
+ */
105
+ public static function satisfies(VersionParser $parser, $packageName, $constraint)
106
+ {
107
+ $constraint = $parser->parseConstraints($constraint);
108
+ $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
109
+
110
+ return $provided->matches($constraint);
111
+ }
112
+
113
+ /**
114
+ * Returns a version constraint representing all the range(s) which are installed for a given package
115
+ *
116
+ * It is easier to use this via isInstalled() with the $constraint argument if you need to check
117
+ * whether a given version of a package is installed, and not just whether it exists
118
+ *
119
+ * @param string $packageName
120
+ * @return string Version constraint usable with composer/semver
121
+ */
122
+ public static function getVersionRanges($packageName)
123
+ {
124
+ foreach (self::getInstalled() as $installed) {
125
+ if (!isset($installed['versions'][$packageName])) {
126
+ continue;
127
+ }
128
+
129
+ $ranges = array();
130
+ if (isset($installed['versions'][$packageName]['pretty_version'])) {
131
+ $ranges[] = $installed['versions'][$packageName]['pretty_version'];
132
+ }
133
+ if (array_key_exists('aliases', $installed['versions'][$packageName])) {
134
+ $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
135
+ }
136
+ if (array_key_exists('replaced', $installed['versions'][$packageName])) {
137
+ $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
138
+ }
139
+ if (array_key_exists('provided', $installed['versions'][$packageName])) {
140
+ $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
141
+ }
142
+
143
+ return implode(' || ', $ranges);
144
+ }
145
+
146
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
147
+ }
148
+
149
+ /**
150
+ * @param string $packageName
151
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
152
+ */
153
+ public static function getVersion($packageName)
154
+ {
155
+ foreach (self::getInstalled() as $installed) {
156
+ if (!isset($installed['versions'][$packageName])) {
157
+ continue;
158
+ }
159
+
160
+ if (!isset($installed['versions'][$packageName]['version'])) {
161
+ return null;
162
+ }
163
+
164
+ return $installed['versions'][$packageName]['version'];
165
+ }
166
+
167
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
168
+ }
169
+
170
+ /**
171
+ * @param string $packageName
172
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
173
+ */
174
+ public static function getPrettyVersion($packageName)
175
+ {
176
+ foreach (self::getInstalled() as $installed) {
177
+ if (!isset($installed['versions'][$packageName])) {
178
+ continue;
179
+ }
180
+
181
+ if (!isset($installed['versions'][$packageName]['pretty_version'])) {
182
+ return null;
183
+ }
184
+
185
+ return $installed['versions'][$packageName]['pretty_version'];
186
+ }
187
+
188
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
189
+ }
190
+
191
+ /**
192
+ * @param string $packageName
193
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
194
+ */
195
+ public static function getReference($packageName)
196
+ {
197
+ foreach (self::getInstalled() as $installed) {
198
+ if (!isset($installed['versions'][$packageName])) {
199
+ continue;
200
+ }
201
+
202
+ if (!isset($installed['versions'][$packageName]['reference'])) {
203
+ return null;
204
+ }
205
+
206
+ return $installed['versions'][$packageName]['reference'];
207
+ }
208
+
209
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
210
+ }
211
+
212
+ /**
213
+ * @param string $packageName
214
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
215
+ */
216
+ public static function getInstallPath($packageName)
217
+ {
218
+ foreach (self::getInstalled() as $installed) {
219
+ if (!isset($installed['versions'][$packageName])) {
220
+ continue;
221
+ }
222
+
223
+ return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
224
+ }
225
+
226
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
227
+ }
228
+
229
+ /**
230
+ * @return array
231
+ * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
232
+ */
233
+ public static function getRootPackage()
234
+ {
235
+ $installed = self::getInstalled();
236
+
237
+ return $installed[0]['root'];
238
+ }
239
+
240
+ /**
241
+ * Returns the raw installed.php data for custom implementations
242
+ *
243
+ * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
244
+ * @return array[]
245
+ * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
246
+ */
247
+ public static function getRawData()
248
+ {
249
+ @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
250
+
251
+ if (null === self::$installed) {
252
+ // only require the installed.php file if this file is loaded from its dumped location,
253
+ // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
254
+ if (substr(__DIR__, -8, 1) !== 'C') {
255
+ self::$installed = include __DIR__ . '/installed.php';
256
+ } else {
257
+ self::$installed = array();
258
+ }
259
+ }
260
+
261
+ return self::$installed;
262
+ }
263
+
264
+ /**
265
+ * Returns the raw data of all installed.php which are currently loaded for custom implementations
266
+ *
267
+ * @return array[]
268
+ * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
269
+ */
270
+ public static function getAllRawData()
271
+ {
272
+ return self::getInstalled();
273
+ }
274
+
275
+ /**
276
+ * Lets you reload the static array from another file
277
+ *
278
+ * This is only useful for complex integrations in which a project needs to use
279
+ * this class but then also needs to execute another project's autoloader in process,
280
+ * and wants to ensure both projects have access to their version of installed.php.
281
+ *
282
+ * A typical case would be PHPUnit, where it would need to make sure it reads all
283
+ * the data it needs from this class, then call reload() with
284
+ * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
285
+ * the project in which it runs can then also use this class safely, without
286
+ * interference between PHPUnit's dependencies and the project's dependencies.
287
+ *
288
+ * @param array[] $data A vendor/composer/installed.php data set
289
+ * @return void
290
+ *
291
+ * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
292
+ */
293
+ public static function reload($data)
294
+ {
295
+ self::$installed = $data;
296
+ self::$installedByVendor = array();
297
+ }
298
+
299
+ /**
300
+ * @return array[]
301
+ * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
302
+ */
303
+ private static function getInstalled()
304
+ {
305
+ if (null === self::$canGetVendors) {
306
+ self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
307
+ }
308
+
309
+ $installed = array();
310
+
311
+ if (self::$canGetVendors) {
312
+ foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
313
+ if (isset(self::$installedByVendor[$vendorDir])) {
314
+ $installed[] = self::$installedByVendor[$vendorDir];
315
+ } elseif (is_file($vendorDir.'/composer/installed.php')) {
316
+ $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
317
+ if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
318
+ self::$installed = $installed[count($installed) - 1];
319
+ }
320
+ }
321
+ }
322
+ }
323
+
324
+ if (null === self::$installed) {
325
+ // only require the installed.php file if this file is loaded from its dumped location,
326
+ // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
327
+ if (substr(__DIR__, -8, 1) !== 'C') {
328
+ self::$installed = require __DIR__ . '/installed.php';
329
+ } else {
330
+ self::$installed = array();
331
+ }
332
+ }
333
+ $installed[] = self::$installed;
334
+
335
+ return $installed;
336
+ }
337
+ }
vendor/composer/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Copyright (c) Nils Adermann, Jordi Boggiano
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished
9
+ to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+
vendor/composer/autoload_classmap.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_classmap.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
10
+ );
vendor/composer/autoload_namespaces.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_namespaces.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_psr4.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_psr4.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_real.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_real.php @generated by Composer
4
+
5
+ class ComposerAutoloaderInit26af049b6f0f389bc85dab8067eb205a
6
+ {
7
+ private static $loader;
8
+
9
+ public static function loadClassLoader($class)
10
+ {
11
+ if ('Composer\Autoload\ClassLoader' === $class) {
12
+ require __DIR__ . '/ClassLoader.php';
13
+ }
14
+ }
15
+
16
+ /**
17
+ * @return \Composer\Autoload\ClassLoader
18
+ */
19
+ public static function getLoader()
20
+ {
21
+ if (null !== self::$loader) {
22
+ return self::$loader;
23
+ }
24
+
25
+ require __DIR__ . '/platform_check.php';
26
+
27
+ spl_autoload_register(array('ComposerAutoloaderInit26af049b6f0f389bc85dab8067eb205a', 'loadClassLoader'), true, true);
28
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
29
+ spl_autoload_unregister(array('ComposerAutoloaderInit26af049b6f0f389bc85dab8067eb205a', 'loadClassLoader'));
30
+
31
+ $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
32
+ if ($useStaticLoader) {
33
+ require __DIR__ . '/autoload_static.php';
34
+
35
+ call_user_func(\Composer\Autoload\ComposerStaticInit26af049b6f0f389bc85dab8067eb205a::getInitializer($loader));
36
+ } else {
37
+ $map = require __DIR__ . '/autoload_namespaces.php';
38
+ foreach ($map as $namespace => $path) {
39
+ $loader->set($namespace, $path);
40
+ }
41
+
42
+ $map = require __DIR__ . '/autoload_psr4.php';
43
+ foreach ($map as $namespace => $path) {
44
+ $loader->setPsr4($namespace, $path);
45
+ }
46
+
47
+ $classMap = require __DIR__ . '/autoload_classmap.php';
48
+ if ($classMap) {
49
+ $loader->addClassMap($classMap);
50
+ }
51
+ }
52
+
53
+ $loader->register(true);
54
+
55
+ return $loader;
56
+ }
57
+ }
vendor/composer/autoload_static.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_static.php @generated by Composer
4
+
5
+ namespace Composer\Autoload;
6
+
7
+ class ComposerStaticInit26af049b6f0f389bc85dab8067eb205a
8
+ {
9
+ public static $classMap = array (
10
+ 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
11
+ );
12
+
13
+ public static function getInitializer(ClassLoader $loader)
14
+ {
15
+ return \Closure::bind(function () use ($loader) {
16
+ $loader->classMap = ComposerStaticInit26af049b6f0f389bc85dab8067eb205a::$classMap;
17
+
18
+ }, null, ClassLoader::class);
19
+ }
20
+ }
vendor/composer/installed.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ {
2
+ "packages": [],
3
+ "dev": false,
4
+ "dev-package-names": []
5
+ }
vendor/composer/installed.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php return array(
2
+ 'root' => array(
3
+ 'pretty_version' => '4.2.0',
4
+ 'version' => '4.2.0.0',
5
+ 'type' => 'wordpress-plugin',
6
+ 'install_path' => __DIR__ . '/../../',
7
+ 'aliases' => array(),
8
+ 'reference' => '2fbb6663febe4235a0e0ee6525de9e73c7a40657',
9
+ 'name' => '__root__',
10
+ 'dev' => false,
11
+ ),
12
+ 'versions' => array(
13
+ '__root__' => array(
14
+ 'pretty_version' => '4.2.0',
15
+ 'version' => '4.2.0.0',
16
+ 'type' => 'wordpress-plugin',
17
+ 'install_path' => __DIR__ . '/../../',
18
+ 'aliases' => array(),
19
+ 'reference' => '2fbb6663febe4235a0e0ee6525de9e73c7a40657',
20
+ 'dev_requirement' => false,
21
+ ),
22
+ ),
23
+ );
vendor/composer/platform_check.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // platform_check.php @generated by Composer
4
+
5
+ $issues = array();
6
+
7
+ if (!(PHP_VERSION_ID >= 50600)) {
8
+ $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running ' . PHP_VERSION . '.';
9
+ }
10
+
11
+ if ($issues) {
12
+ if (!headers_sent()) {
13
+ header('HTTP/1.1 500 Internal Server Error');
14
+ }
15
+ if (!ini_get('display_errors')) {
16
+ if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
17
+ fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
18
+ } elseif (!headers_sent()) {
19
+ echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
20
+ }
21
+ }
22
+ trigger_error(
23
+ 'Composer detected issues in your platform: ' . implode(' ', $issues),
24
+ E_USER_ERROR
25
+ );
26
+ }