Version Description
- Fixed a bug that wysiwyg fields became tinymce default format when content editor mode is text.
- Change the comment in English.
Download this release
Release Info
Developer | inc2734 |
Plugin | Smart Custom Fields |
Version | 1.6.4 |
Comparing to | |
See all releases |
Code changes from version 1.6.3 to 1.6.4
- classes/class.scf.php +100 -94
- classes/controller/class.controller-base.php +28 -28
- classes/controller/class.editor.php +2 -2
- classes/controller/class.profile.php +3 -3
- classes/controller/class.settings.php +13 -13
- classes/controller/class.taxonomy.php +5 -5
- classes/fields/class.field-boolean.php +27 -27
- classes/fields/class.field-check.php +6 -6
- classes/fields/class.field-colorpicker.php +9 -9
- classes/fields/class.field-datepicker.php +16 -11
- classes/fields/class.field-file.php +6 -6
- classes/fields/class.field-image.php +6 -6
- classes/fields/class.field-radio.php +6 -6
- classes/fields/class.field-relation.php +11 -11
- classes/fields/class.field-select.php +6 -6
- classes/fields/class.field-text.php +6 -6
- classes/fields/class.field-textarea.php +6 -6
- classes/fields/class.field-wysiwyg.php +12 -15
- classes/models/class.abstract-field-base.php +28 -28
- classes/models/class.ajax.php +2 -2
- classes/models/class.group.php +13 -13
- classes/models/class.meta.php +40 -40
- classes/models/class.setting.php +23 -21
- js/editor.js +6 -3
- readme.txt +5 -1
- smart-custom-fields.php +12 -11
classes/class.scf.php
CHANGED
@@ -11,41 +11,41 @@
|
|
11 |
class SCF {
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
* @var array
|
16 |
*/
|
17 |
protected static $fields = array();
|
18 |
|
19 |
/**
|
20 |
-
*
|
21 |
-
*
|
22 |
* @var array
|
23 |
*/
|
24 |
protected static $cache = array();
|
25 |
|
26 |
/**
|
27 |
-
*
|
28 |
-
*
|
29 |
* @var array
|
30 |
*/
|
31 |
protected static $settings_posts_cache = array();
|
32 |
|
33 |
/**
|
34 |
-
*
|
35 |
-
*
|
36 |
* @var array
|
37 |
*/
|
38 |
public static $settings_cache = array();
|
39 |
|
40 |
/**
|
41 |
-
*
|
42 |
-
*
|
43 |
* @var array
|
44 |
*/
|
45 |
protected static $repeat_multiple_data_cache = array();
|
46 |
|
47 |
/**
|
48 |
-
*
|
49 |
*/
|
50 |
public static function clear_all_cache() {
|
51 |
self::clear_cache();
|
@@ -55,7 +55,7 @@ class SCF {
|
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
-
*
|
59 |
*
|
60 |
* @param int $post_id
|
61 |
* @return array
|
@@ -70,15 +70,15 @@ class SCF {
|
|
70 |
return null;
|
71 |
}
|
72 |
|
73 |
-
//
|
74 |
-
//
|
75 |
return self::get_all_meta( get_post( $post_id ) );
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
-
*
|
80 |
*
|
81 |
-
* @param string $name
|
82 |
* @param int $post_id
|
83 |
* @return mixed
|
84 |
*/
|
@@ -91,17 +91,17 @@ class SCF {
|
|
91 |
if ( empty( $post_id ) ) {
|
92 |
return;
|
93 |
}
|
94 |
-
|
95 |
-
//
|
96 |
-
//
|
97 |
return self::get_meta( get_post( $post_id ), $name );
|
98 |
}
|
99 |
|
100 |
/**
|
101 |
-
|
102 |
*
|
103 |
* @param int $user_id
|
104 |
-
* @param string $name
|
105 |
* @return mixed
|
106 |
*/
|
107 |
public static function get_user_meta( $user_id, $name = null ) {
|
@@ -109,22 +109,22 @@ class SCF {
|
|
109 |
return;
|
110 |
}
|
111 |
|
112 |
-
// $name
|
113 |
if ( $name === null ) {
|
114 |
return self::get_all_meta( get_userdata( $user_id ) );
|
115 |
}
|
116 |
-
|
117 |
-
//
|
118 |
-
//
|
119 |
return self::get_meta( get_userdata( $user_id ), $name );
|
120 |
}
|
121 |
|
122 |
/**
|
123 |
-
|
124 |
*
|
125 |
* @param int $term_id
|
126 |
* @param string $taxonomy_name
|
127 |
-
* @param string $name
|
128 |
* @return mixed
|
129 |
*/
|
130 |
public static function get_term_meta( $term_id, $taxonomy_name, $name = null ) {
|
@@ -132,21 +132,21 @@ class SCF {
|
|
132 |
return;
|
133 |
}
|
134 |
|
135 |
-
// $name
|
136 |
if ( $name === null ) {
|
137 |
return self::get_all_meta( get_term( $term_id, $taxonomy_name ) );
|
138 |
}
|
139 |
-
|
140 |
-
//
|
141 |
-
//
|
142 |
return self::get_meta( get_term( $term_id, $taxonomy_name ), $name );
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
-
*
|
147 |
*
|
148 |
* @param WP_Post|WP_User|object $object
|
149 |
-
* @param string $name
|
150 |
* @return mixed
|
151 |
*/
|
152 |
protected static function get_meta( $object, $name ) {
|
@@ -159,7 +159,7 @@ class SCF {
|
|
159 |
|
160 |
$settings = self::get_settings( $object );
|
161 |
foreach ( $settings as $Setting ) {
|
162 |
-
//
|
163 |
$Group = $Setting->get_group( $name );
|
164 |
if ( $Group ) {
|
165 |
$values_by_group = self::get_values_by_group( $object, $Group );
|
@@ -167,7 +167,7 @@ class SCF {
|
|
167 |
return $values_by_group;
|
168 |
}
|
169 |
|
170 |
-
//
|
171 |
$groups = $Setting->get_groups();
|
172 |
foreach ( $groups as $Group ) {
|
173 |
$Field = $Group->get_field( $name );
|
@@ -182,9 +182,9 @@ class SCF {
|
|
182 |
}
|
183 |
|
184 |
/**
|
185 |
-
|
186 |
*
|
187 |
-
* @param WP_Post|WP_User|
|
188 |
* @return mixed
|
189 |
*/
|
190 |
protected static function get_all_meta( $object ) {
|
@@ -215,7 +215,7 @@ class SCF {
|
|
215 |
}
|
216 |
|
217 |
/**
|
218 |
-
*
|
219 |
*
|
220 |
* @param int $post_id
|
221 |
* @return int
|
@@ -231,9 +231,9 @@ class SCF {
|
|
231 |
}
|
232 |
|
233 |
/**
|
234 |
-
*
|
235 |
*
|
236 |
-
* @param WP_Post|WP_User|
|
237 |
* @param string $name
|
238 |
* @param mixed $data
|
239 |
*/
|
@@ -248,9 +248,9 @@ class SCF {
|
|
248 |
}
|
249 |
|
250 |
/**
|
251 |
-
*
|
252 |
*
|
253 |
-
* @param WP_Post|WP_User|
|
254 |
* @param string $name
|
255 |
* @return mixed
|
256 |
*/
|
@@ -273,16 +273,17 @@ class SCF {
|
|
273 |
}
|
274 |
|
275 |
/**
|
276 |
-
*
|
277 |
*/
|
278 |
public static function clear_cache() {
|
279 |
self::$cache = array();
|
280 |
}
|
281 |
|
282 |
/**
|
283 |
-
*
|
|
|
284 |
*
|
285 |
-
* @param WP_Post|WP_User|
|
286 |
* @param Smart_Custom_Fields_Group $Group
|
287 |
* @return mixed
|
288 |
*/
|
@@ -312,11 +313,11 @@ class SCF {
|
|
312 |
}
|
313 |
|
314 |
/**
|
315 |
-
*
|
316 |
*
|
317 |
-
* @param WP_Post|WP_User|
|
318 |
* @param array $field
|
319 |
-
* @param bool $is_repeatable
|
320 |
* @return mixed $post_meta
|
321 |
*/
|
322 |
protected static function get_value_by_field( $object, $Field, $is_repeatable ) {
|
@@ -327,7 +328,7 @@ class SCF {
|
|
327 |
|
328 |
$Meta = new Smart_Custom_Fields_Meta( $object );
|
329 |
|
330 |
-
//
|
331 |
$field_type = $Field->get_attribute( 'type' );
|
332 |
$repeat_multiple_data = self::get_repeat_multiple_data( $object );
|
333 |
if ( is_array( $repeat_multiple_data ) && isset( $repeat_multiple_data[$field_name] ) ) {
|
@@ -348,7 +349,7 @@ class SCF {
|
|
348 |
$meta[$repeat_multiple_key] = $value;
|
349 |
}
|
350 |
}
|
351 |
-
//
|
352 |
else {
|
353 |
$single = true;
|
354 |
if ( $Field->get_attribute( 'allow-multiple-data' ) || $is_repeatable ) {
|
@@ -365,7 +366,7 @@ class SCF {
|
|
365 |
}
|
366 |
|
367 |
/**
|
368 |
-
*
|
369 |
*
|
370 |
* @param Smart_Custom_Fields_Field_Base $Field
|
371 |
* @param bool $single
|
@@ -394,11 +395,11 @@ class SCF {
|
|
394 |
return $default_sanitized;
|
395 |
}
|
396 |
|
397 |
-
//
|
398 |
if ( $single ) {
|
399 |
return $default;
|
400 |
}
|
401 |
-
//
|
402 |
else {
|
403 |
if ( is_array( $default ) ) {
|
404 |
return $default;
|
@@ -411,9 +412,9 @@ class SCF {
|
|
411 |
}
|
412 |
|
413 |
/**
|
414 |
-
*
|
415 |
*
|
416 |
-
* @param WP_Post|WP_User|
|
417 |
* @param array $settings_posts
|
418 |
*/
|
419 |
protected static function save_settings_posts_cache( $object, $settings_posts ) {
|
@@ -424,9 +425,9 @@ class SCF {
|
|
424 |
}
|
425 |
|
426 |
/**
|
427 |
-
|
428 |
*
|
429 |
-
* @param WP_Post|WP_User|
|
430 |
* @return array|null
|
431 |
*/
|
432 |
public static function get_settings_posts_cache( $object ) {
|
@@ -439,16 +440,16 @@ class SCF {
|
|
439 |
}
|
440 |
|
441 |
/**
|
442 |
-
*
|
443 |
*/
|
444 |
public static function clear_settings_posts_cache() {
|
445 |
self::$settings_posts_cache = array();
|
446 |
}
|
447 |
|
448 |
/**
|
449 |
-
|
450 |
*
|
451 |
-
* @param WP_Post|WP_User|
|
452 |
* @return array $settings
|
453 |
*/
|
454 |
public static function get_settings_posts( $object ) {
|
@@ -497,10 +498,10 @@ class SCF {
|
|
497 |
}
|
498 |
|
499 |
/**
|
500 |
-
* Setting
|
501 |
*
|
502 |
* @param int $settings_post_id
|
503 |
-
* @param WP_post|WP_User|
|
504 |
* @param Smart_Custom_Fields_Setting $Setting
|
505 |
*/
|
506 |
protected static function save_settings_cache( $settings_post_id, $Setting, $object = null ) {
|
@@ -517,16 +518,16 @@ class SCF {
|
|
517 |
}
|
518 |
|
519 |
/**
|
520 |
-
* Setting
|
521 |
-
*
|
522 |
-
*
|
523 |
-
*
|
524 |
-
*
|
525 |
-
*
|
526 |
-
*
|
527 |
*
|
528 |
* @param int $settings_post_id
|
529 |
-
* @param WP_post|WP_User $object
|
530 |
* @return Smart_Custom_Fields_Setting|false|null
|
531 |
*/
|
532 |
public static function get_settings_cache( $settings_post_id, $object = null ) {
|
@@ -549,16 +550,16 @@ class SCF {
|
|
549 |
}
|
550 |
|
551 |
/**
|
552 |
-
*
|
553 |
*/
|
554 |
public static function clear_settings_cache() {
|
555 |
self::$settings_cache = array();
|
556 |
}
|
557 |
|
558 |
/**
|
559 |
-
* Setting
|
560 |
*
|
561 |
-
* @param WP_Post|WP_User|
|
562 |
* @return array $settings
|
563 |
*/
|
564 |
public static function get_settings( $object ) {
|
@@ -570,6 +571,10 @@ class SCF {
|
|
570 |
// 投稿IDで出し分けされているカスタムフィールド設定を持つ投稿の場合、
|
571 |
// プレビュー画面ではIDが変わって表示されなくなってしまうため、
|
572 |
// プレビュー画面の場合は元の投稿(プレビューの親)から設定の再取得が必要
|
|
|
|
|
|
|
|
|
573 |
if ( $meta_type === 'post' && $object->post_type === 'revision' ) {
|
574 |
$object = get_post( $object->post_parent );
|
575 |
}
|
@@ -592,7 +597,7 @@ class SCF {
|
|
592 |
}
|
593 |
|
594 |
/**
|
595 |
-
* Setting
|
596 |
*
|
597 |
* @param WP_Post $object
|
598 |
* @param array $settings_posts
|
@@ -641,7 +646,7 @@ class SCF {
|
|
641 |
}
|
642 |
|
643 |
/**
|
644 |
-
|
645 |
*
|
646 |
* @param WP_User $object
|
647 |
* @param array $settings_posts
|
@@ -664,9 +669,9 @@ class SCF {
|
|
664 |
}
|
665 |
|
666 |
/**
|
667 |
-
|
668 |
*
|
669 |
-
* @param
|
670 |
* @param array $settings_posts
|
671 |
* @return array
|
672 |
*/
|
@@ -675,9 +680,9 @@ class SCF {
|
|
675 |
}
|
676 |
|
677 |
/**
|
678 |
-
*
|
679 |
*
|
680 |
-
* @param WP_Post|WP_User|
|
681 |
* @param mixed $repeat_multiple_data
|
682 |
*/
|
683 |
protected static function save_repeat_multiple_data_cache( $object, $repeat_multiple_data ) {
|
@@ -691,9 +696,9 @@ class SCF {
|
|
691 |
}
|
692 |
|
693 |
/**
|
694 |
-
*
|
695 |
*
|
696 |
-
* @param WP_Post|WP_User|
|
697 |
* @return mixed
|
698 |
*/
|
699 |
protected static function get_repeat_multiple_data_cache( $object ) {
|
@@ -709,16 +714,16 @@ class SCF {
|
|
709 |
}
|
710 |
|
711 |
/**
|
712 |
-
*
|
713 |
*/
|
714 |
public static function clear_repeat_multiple_data_cache() {
|
715 |
self::$repeat_multiple_data_cache = array();
|
716 |
}
|
717 |
|
718 |
/**
|
719 |
-
|
720 |
*
|
721 |
-
* @param WP_Post|WP_User|
|
722 |
* @return array
|
723 |
*/
|
724 |
public static function get_repeat_multiple_data( $object ) {
|
@@ -738,7 +743,7 @@ class SCF {
|
|
738 |
}
|
739 |
|
740 |
/**
|
741 |
-
* null
|
742 |
*
|
743 |
* @param mixed $value
|
744 |
* @return bool
|
@@ -754,7 +759,7 @@ class SCF {
|
|
754 |
}
|
755 |
|
756 |
/**
|
757 |
-
*
|
758 |
*
|
759 |
* @param Smart_Custom_Fields_Field_Base $instance
|
760 |
*/
|
@@ -766,9 +771,9 @@ class SCF {
|
|
766 |
}
|
767 |
|
768 |
/**
|
769 |
-
*
|
770 |
*
|
771 |
-
* @param string $type
|
772 |
* @param Smart_Custom_Fields_Field_Base
|
773 |
*/
|
774 |
public static function get_form_field_instance( $type ) {
|
@@ -778,7 +783,7 @@ class SCF {
|
|
778 |
}
|
779 |
|
780 |
/**
|
781 |
-
*
|
782 |
*
|
783 |
* @return array
|
784 |
*/
|
@@ -791,10 +796,10 @@ class SCF {
|
|
791 |
}
|
792 |
|
793 |
/**
|
794 |
-
*
|
795 |
-
*
|
796 |
*
|
797 |
-
* @param WP_Post|WP_User|
|
798 |
* @param string $field_name
|
799 |
* @return Smart_Custom_Fields_Field_Base|null
|
800 |
*/
|
@@ -812,7 +817,7 @@ class SCF {
|
|
812 |
}
|
813 |
|
814 |
/**
|
815 |
-
*
|
816 |
*
|
817 |
* @param string $choices
|
818 |
* @return array
|
@@ -829,17 +834,18 @@ class SCF {
|
|
829 |
}
|
830 |
|
831 |
/**
|
832 |
-
* Setting
|
833 |
*
|
834 |
* @param string $id
|
835 |
* @param string $title
|
|
|
836 |
*/
|
837 |
public static function add_setting( $id, $title ) {
|
838 |
return new Smart_Custom_Fields_Setting( $id, $title );
|
839 |
}
|
840 |
|
841 |
/**
|
842 |
-
*
|
843 |
*/
|
844 |
protected static function debug_cache_message( $message ) {
|
845 |
if ( defined( 'SCF_DEBUG_CACHE' ) && SCF_DEBUG_CACHE === true ) {
|
11 |
class SCF {
|
12 |
|
13 |
/**
|
14 |
+
* Array of the registered fields ( Smart_Custom_Fields_Field_Base )
|
15 |
* @var array
|
16 |
*/
|
17 |
protected static $fields = array();
|
18 |
|
19 |
/**
|
20 |
+
* Getting data proccesses is heavy. So saved getted data to $cache.
|
21 |
+
* Using post_id as key.
|
22 |
* @var array
|
23 |
*/
|
24 |
protected static $cache = array();
|
25 |
|
26 |
/**
|
27 |
+
* Getting data proccesses is heavy. So saved getted data to $settings_posts_cache.
|
28 |
+
* Using post_type as key.
|
29 |
* @var array
|
30 |
*/
|
31 |
protected static $settings_posts_cache = array();
|
32 |
|
33 |
/**
|
34 |
+
* Getting data proccesses is heavy. So saved getted data to $settings_cache.
|
35 |
+
* Using post_type as key.
|
36 |
* @var array
|
37 |
*/
|
38 |
public static $settings_cache = array();
|
39 |
|
40 |
/**
|
41 |
+
* Getting data proccesses is heavy. So saved getted data to $repeat_multiple_data_cache.
|
42 |
+
* Using post_id as key.
|
43 |
* @var array
|
44 |
*/
|
45 |
protected static $repeat_multiple_data_cache = array();
|
46 |
|
47 |
/**
|
48 |
+
* Clear all caches.
|
49 |
*/
|
50 |
public static function clear_all_cache() {
|
51 |
self::clear_cache();
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
+
* Getting all of the post meta data to feel good
|
59 |
*
|
60 |
* @param int $post_id
|
61 |
* @return array
|
70 |
return null;
|
71 |
}
|
72 |
|
73 |
+
// Don't output meta data that not save in the SCF settings page
|
74 |
+
// Getting the settings data, judged to output meta data.
|
75 |
return self::get_all_meta( get_post( $post_id ) );
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
+
* Getting the post meta data to feel good
|
80 |
*
|
81 |
+
* @param string $name group name or field name
|
82 |
* @param int $post_id
|
83 |
* @return mixed
|
84 |
*/
|
91 |
if ( empty( $post_id ) ) {
|
92 |
return;
|
93 |
}
|
94 |
+
|
95 |
+
// Don't output meta data that not save in the SCF settings page
|
96 |
+
// Getting the settings data, judged to output meta data.
|
97 |
return self::get_meta( get_post( $post_id ), $name );
|
98 |
}
|
99 |
|
100 |
/**
|
101 |
+
* Getting the user meta data to feel good
|
102 |
*
|
103 |
* @param int $user_id
|
104 |
+
* @param string $name group name or field name
|
105 |
* @return mixed
|
106 |
*/
|
107 |
public static function get_user_meta( $user_id, $name = null ) {
|
109 |
return;
|
110 |
}
|
111 |
|
112 |
+
// If $name is null, return the all meta data.
|
113 |
if ( $name === null ) {
|
114 |
return self::get_all_meta( get_userdata( $user_id ) );
|
115 |
}
|
116 |
+
|
117 |
+
// Don't output meta data that not save in the SCF settings page.
|
118 |
+
// Getting the settings data, judged to output meta data.
|
119 |
return self::get_meta( get_userdata( $user_id ), $name );
|
120 |
}
|
121 |
|
122 |
/**
|
123 |
+
* Getting the term meta data to feel good
|
124 |
*
|
125 |
* @param int $term_id
|
126 |
* @param string $taxonomy_name
|
127 |
+
* @param string $name group name or field name
|
128 |
* @return mixed
|
129 |
*/
|
130 |
public static function get_term_meta( $term_id, $taxonomy_name, $name = null ) {
|
132 |
return;
|
133 |
}
|
134 |
|
135 |
+
// If $name is null, return the all meta data.
|
136 |
if ( $name === null ) {
|
137 |
return self::get_all_meta( get_term( $term_id, $taxonomy_name ) );
|
138 |
}
|
139 |
+
|
140 |
+
// Don't output meta data that not save in the SCF settings page
|
141 |
+
// Getting the settings data, judged to output meta data.
|
142 |
return self::get_meta( get_term( $term_id, $taxonomy_name ), $name );
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
+
* Getting any meta data to feel good
|
147 |
*
|
148 |
* @param WP_Post|WP_User|object $object
|
149 |
+
* @param string $name group name or field name
|
150 |
* @return mixed
|
151 |
*/
|
152 |
protected static function get_meta( $object, $name ) {
|
159 |
|
160 |
$settings = self::get_settings( $object );
|
161 |
foreach ( $settings as $Setting ) {
|
162 |
+
// If $name matches the group name, returns fields in the group as array.
|
163 |
$Group = $Setting->get_group( $name );
|
164 |
if ( $Group ) {
|
165 |
$values_by_group = self::get_values_by_group( $object, $Group );
|
167 |
return $values_by_group;
|
168 |
}
|
169 |
|
170 |
+
// If $name doesn't matche the group name, returns the field that matches.
|
171 |
$groups = $Setting->get_groups();
|
172 |
foreach ( $groups as $Group ) {
|
173 |
$Field = $Group->get_field( $name );
|
182 |
}
|
183 |
|
184 |
/**
|
185 |
+
* Getting all of any meta data to feel good
|
186 |
*
|
187 |
+
* @param WP_Post|WP_User|WP_Term $object
|
188 |
* @return mixed
|
189 |
*/
|
190 |
protected static function get_all_meta( $object ) {
|
215 |
}
|
216 |
|
217 |
/**
|
218 |
+
* If in preview, return the preview post ID
|
219 |
*
|
220 |
* @param int $post_id
|
221 |
* @return int
|
231 |
}
|
232 |
|
233 |
/**
|
234 |
+
* Saving to cache
|
235 |
*
|
236 |
+
* @param WP_Post|WP_User|WP_Term $object
|
237 |
* @param string $name
|
238 |
* @param mixed $data
|
239 |
*/
|
248 |
}
|
249 |
|
250 |
/**
|
251 |
+
* Getting the cache
|
252 |
*
|
253 |
+
* @param WP_Post|WP_User|WP_Term $object
|
254 |
* @param string $name
|
255 |
* @return mixed
|
256 |
*/
|
273 |
}
|
274 |
|
275 |
/**
|
276 |
+
* Clear caches
|
277 |
*/
|
278 |
public static function clear_cache() {
|
279 |
self::$cache = array();
|
280 |
}
|
281 |
|
282 |
/**
|
283 |
+
* Getting the meta data of the group
|
284 |
+
* When group, Note the point that returned data are repetition
|
285 |
*
|
286 |
+
* @param WP_Post|WP_User|WP_Term $object
|
287 |
* @param Smart_Custom_Fields_Group $Group
|
288 |
* @return mixed
|
289 |
*/
|
313 |
}
|
314 |
|
315 |
/**
|
316 |
+
* Getting the meta data of the field
|
317 |
*
|
318 |
+
* @param WP_Post|WP_User|WP_Term $object
|
319 |
* @param array $field
|
320 |
+
* @param bool $is_repeatable Whether the group that this field belongs is repetition
|
321 |
* @return mixed $post_meta
|
322 |
*/
|
323 |
protected static function get_value_by_field( $object, $Field, $is_repeatable ) {
|
328 |
|
329 |
$Meta = new Smart_Custom_Fields_Meta( $object );
|
330 |
|
331 |
+
// In the case of multi-value items in the loop
|
332 |
$field_type = $Field->get_attribute( 'type' );
|
333 |
$repeat_multiple_data = self::get_repeat_multiple_data( $object );
|
334 |
if ( is_array( $repeat_multiple_data ) && isset( $repeat_multiple_data[$field_name] ) ) {
|
349 |
$meta[$repeat_multiple_key] = $value;
|
350 |
}
|
351 |
}
|
352 |
+
// Other than that
|
353 |
else {
|
354 |
$single = true;
|
355 |
if ( $Field->get_attribute( 'allow-multiple-data' ) || $is_repeatable ) {
|
366 |
}
|
367 |
|
368 |
/**
|
369 |
+
* Return the default value
|
370 |
*
|
371 |
* @param Smart_Custom_Fields_Field_Base $Field
|
372 |
* @param bool $single
|
395 |
return $default_sanitized;
|
396 |
}
|
397 |
|
398 |
+
// Return string
|
399 |
if ( $single ) {
|
400 |
return $default;
|
401 |
}
|
402 |
+
// Return array
|
403 |
else {
|
404 |
if ( is_array( $default ) ) {
|
405 |
return $default;
|
412 |
}
|
413 |
|
414 |
/**
|
415 |
+
* Saving to cache that enabled custom field settings in the post type or the role or the term.
|
416 |
*
|
417 |
+
* @param WP_Post|WP_User|WP_Term $object
|
418 |
* @param array $settings_posts
|
419 |
*/
|
420 |
protected static function save_settings_posts_cache( $object, $settings_posts ) {
|
425 |
}
|
426 |
|
427 |
/**
|
428 |
+
* Getting cache that enabled custom field settings in the post type or the role or the term.
|
429 |
*
|
430 |
+
* @param WP_Post|WP_User|WP_Term $object
|
431 |
* @return array|null
|
432 |
*/
|
433 |
public static function get_settings_posts_cache( $object ) {
|
440 |
}
|
441 |
|
442 |
/**
|
443 |
+
* Clear the $settings_posts_cache
|
444 |
*/
|
445 |
public static function clear_settings_posts_cache() {
|
446 |
self::$settings_posts_cache = array();
|
447 |
}
|
448 |
|
449 |
/**
|
450 |
+
* Getting enabled custom field settings in the post type or the role or the term.
|
451 |
*
|
452 |
+
* @param WP_Post|WP_User|WP_Term $object
|
453 |
* @return array $settings
|
454 |
*/
|
455 |
public static function get_settings_posts( $object ) {
|
498 |
}
|
499 |
|
500 |
/**
|
501 |
+
* Saving the Setting object to cache
|
502 |
*
|
503 |
* @param int $settings_post_id
|
504 |
+
* @param WP_post|WP_User|WP_term $object
|
505 |
* @param Smart_Custom_Fields_Setting $Setting
|
506 |
*/
|
507 |
protected static function save_settings_cache( $settings_post_id, $Setting, $object = null ) {
|
518 |
}
|
519 |
|
520 |
/**
|
521 |
+
* Getting the Setting object cache
|
522 |
+
* If there isn't the custom field settings ... null
|
523 |
+
* If there is custom field settings
|
524 |
+
* If there is no data for the specified $ meta_type + $id
|
525 |
+
* There is a thing of the General ... Smart_Custom_Fields_Setting
|
526 |
+
* There isn't a thing of the General ... false
|
527 |
+
* If there the data for the specified $meta_type + $id ... Smart_Custom_Fields_Setting
|
528 |
*
|
529 |
* @param int $settings_post_id
|
530 |
+
* @param WP_post|WP_User|WP_Term $object
|
531 |
* @return Smart_Custom_Fields_Setting|false|null
|
532 |
*/
|
533 |
public static function get_settings_cache( $settings_post_id, $object = null ) {
|
550 |
}
|
551 |
|
552 |
/**
|
553 |
+
* Clear the $settings_cache
|
554 |
*/
|
555 |
public static function clear_settings_cache() {
|
556 |
self::$settings_cache = array();
|
557 |
}
|
558 |
|
559 |
/**
|
560 |
+
* Getting array of the Setting object
|
561 |
*
|
562 |
+
* @param WP_Post|WP_User|WP_Term $object
|
563 |
* @return array $settings
|
564 |
*/
|
565 |
public static function get_settings( $object ) {
|
571 |
// 投稿IDで出し分けされているカスタムフィールド設定を持つ投稿の場合、
|
572 |
// プレビュー画面ではIDが変わって表示されなくなってしまうため、
|
573 |
// プレビュー画面の場合は元の投稿(プレビューの親)から設定の再取得が必要
|
574 |
+
|
575 |
+
// IF the post that has custom field settings according to post ID,
|
576 |
+
// don't display because the post ID would change in preview.
|
577 |
+
// So if in preview, re-getting post ID from original post (parent of the preview).
|
578 |
if ( $meta_type === 'post' && $object->post_type === 'revision' ) {
|
579 |
$object = get_post( $object->post_parent );
|
580 |
}
|
597 |
}
|
598 |
|
599 |
/**
|
600 |
+
* Getting the Setting object for post
|
601 |
*
|
602 |
* @param WP_Post $object
|
603 |
* @param array $settings_posts
|
646 |
}
|
647 |
|
648 |
/**
|
649 |
+
* Getting the Setting object for user
|
650 |
*
|
651 |
* @param WP_User $object
|
652 |
* @param array $settings_posts
|
669 |
}
|
670 |
|
671 |
/**
|
672 |
+
* Getting the Setting object for term
|
673 |
*
|
674 |
+
* @param WP_Term $object
|
675 |
* @param array $settings_posts
|
676 |
* @return array
|
677 |
*/
|
680 |
}
|
681 |
|
682 |
/**
|
683 |
+
* Saving the delimited identification data of the repeated multi-value items to cache
|
684 |
*
|
685 |
+
* @param WP_Post|WP_User|WP_Term $object
|
686 |
* @param mixed $repeat_multiple_data
|
687 |
*/
|
688 |
protected static function save_repeat_multiple_data_cache( $object, $repeat_multiple_data ) {
|
696 |
}
|
697 |
|
698 |
/**
|
699 |
+
* Getting delimited identification data of the repeated multi-value items from cache
|
700 |
*
|
701 |
+
* @param WP_Post|WP_User|WP_Term $object
|
702 |
* @return mixed
|
703 |
*/
|
704 |
protected static function get_repeat_multiple_data_cache( $object ) {
|
714 |
}
|
715 |
|
716 |
/**
|
717 |
+
* Clear delimited identification data of the repeated multi-value items cache
|
718 |
*/
|
719 |
public static function clear_repeat_multiple_data_cache() {
|
720 |
self::$repeat_multiple_data_cache = array();
|
721 |
}
|
722 |
|
723 |
/**
|
724 |
+
* Getting delimited identification data of the repeated multi-value items
|
725 |
*
|
726 |
+
* @param WP_Post|WP_User|WP_Term $object
|
727 |
* @return array
|
728 |
*/
|
729 |
public static function get_repeat_multiple_data( $object ) {
|
743 |
}
|
744 |
|
745 |
/**
|
746 |
+
* Return true if null or empty value
|
747 |
*
|
748 |
* @param mixed $value
|
749 |
* @return bool
|
759 |
}
|
760 |
|
761 |
/**
|
762 |
+
* Adding the available form field object
|
763 |
*
|
764 |
* @param Smart_Custom_Fields_Field_Base $instance
|
765 |
*/
|
771 |
}
|
772 |
|
773 |
/**
|
774 |
+
* Getting the available form field object
|
775 |
*
|
776 |
+
* @param string $type type of the form field
|
777 |
* @param Smart_Custom_Fields_Field_Base
|
778 |
*/
|
779 |
public static function get_form_field_instance( $type ) {
|
783 |
}
|
784 |
|
785 |
/**
|
786 |
+
* Getting all available form field object
|
787 |
*
|
788 |
* @return array
|
789 |
*/
|
796 |
}
|
797 |
|
798 |
/**
|
799 |
+
* Getting custom fields that saved custo field settings page
|
800 |
+
* Note that not return only one even define multiple fields with the same name of the field name
|
801 |
*
|
802 |
+
* @param WP_Post|WP_User|WP_Term $object
|
803 |
* @param string $field_name
|
804 |
* @return Smart_Custom_Fields_Field_Base|null
|
805 |
*/
|
817 |
}
|
818 |
|
819 |
/**
|
820 |
+
* Convert to array from newline delimiter $choices
|
821 |
*
|
822 |
* @param string $choices
|
823 |
* @return array
|
834 |
}
|
835 |
|
836 |
/**
|
837 |
+
* Return generated Setting object
|
838 |
*
|
839 |
* @param string $id
|
840 |
* @param string $title
|
841 |
+
* @return Smart_Custom_Fields_Setting
|
842 |
*/
|
843 |
public static function add_setting( $id, $title ) {
|
844 |
return new Smart_Custom_Fields_Setting( $id, $title );
|
845 |
}
|
846 |
|
847 |
/**
|
848 |
+
* Print cache usage
|
849 |
*/
|
850 |
protected static function debug_cache_message( $message ) {
|
851 |
if ( defined( 'SCF_DEBUG_CACHE' ) && SCF_DEBUG_CACHE === true ) {
|
classes/controller/class.controller-base.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
class Smart_Custom_Fields_Controller_Base {
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
* @var array
|
16 |
*/
|
17 |
protected $fields = array();
|
@@ -24,7 +24,7 @@ class Smart_Custom_Fields_Controller_Base {
|
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
-
*
|
28 |
*
|
29 |
* @param string $hook
|
30 |
*/
|
@@ -50,10 +50,10 @@ class Smart_Custom_Fields_Controller_Base {
|
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
-
*
|
54 |
*
|
55 |
-
* @param WP_Post|WP_User|
|
56 |
-
* @param array $callback_args
|
57 |
*/
|
58 |
public function display_meta_box( $object, $callback_args ) {
|
59 |
$groups = $callback_args['args'];
|
@@ -72,8 +72,8 @@ class Smart_Custom_Fields_Controller_Base {
|
|
72 |
}
|
73 |
$this->display_tr( $object, $is_repeatable, $Group->get_fields(), $index );
|
74 |
|
75 |
-
//
|
76 |
-
//
|
77 |
if ( $is_repeatable &&
|
78 |
isset( $tables[$group_key + 1 ] ) &&
|
79 |
$tables[$group_key + 1 ]->get_name() === $Group->get_name() ) {
|
@@ -90,10 +90,10 @@ class Smart_Custom_Fields_Controller_Base {
|
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
-
*
|
94 |
*
|
95 |
* @param array $data
|
96 |
-
* @param WP_Post|WP_User|
|
97 |
*/
|
98 |
protected function save( $data, $object ) {
|
99 |
check_admin_referer(
|
@@ -106,11 +106,11 @@ class Smart_Custom_Fields_Controller_Base {
|
|
106 |
}
|
107 |
|
108 |
/**
|
109 |
-
*
|
110 |
*
|
111 |
-
* @param WP_Post|WP_User|
|
112 |
-
* @param array $groups
|
113 |
-
* @return array $tables
|
114 |
*/
|
115 |
protected function get_tables( $object, $groups ) {
|
116 |
$Meta = new Smart_Custom_Fields_Meta( $object );
|
@@ -118,8 +118,8 @@ class Smart_Custom_Fields_Controller_Base {
|
|
118 |
$repeat_multiple_data = SCF::get_repeat_multiple_data( $object );
|
119 |
$tables = array();
|
120 |
foreach ( $groups as $Group ) {
|
121 |
-
//
|
122 |
-
//
|
123 |
if ( $Group->is_repeatable() === true ) {
|
124 |
$loop_count = 1;
|
125 |
$fields = $Group->get_fields();
|
@@ -128,9 +128,9 @@ class Smart_Custom_Fields_Controller_Base {
|
|
128 |
$meta = $Meta->get( $field_name );
|
129 |
if ( is_array( $meta ) ) {
|
130 |
$meta_count = count( $meta );
|
131 |
-
//
|
132 |
if ( $meta_count > 1 ) {
|
133 |
-
//
|
134 |
if ( $Field->get_attribute( 'allow-multiple-data' ) ) {
|
135 |
if ( is_array( $repeat_multiple_data ) && isset( $repeat_multiple_data[$field_name] ) ) {
|
136 |
$repeat_multiple_data_count = count( $repeat_multiple_data[$field_name] );
|
@@ -139,7 +139,7 @@ class Smart_Custom_Fields_Controller_Base {
|
|
139 |
}
|
140 |
}
|
141 |
}
|
142 |
-
//
|
143 |
else {
|
144 |
if ( $loop_count < $meta_count ) {
|
145 |
$loop_count = $meta_count;
|
@@ -161,9 +161,9 @@ class Smart_Custom_Fields_Controller_Base {
|
|
161 |
}
|
162 |
|
163 |
/**
|
164 |
-
*
|
165 |
*
|
166 |
-
* @param WP_Post|WP_User|
|
167 |
* @param Smart_Custom_Fields_Field_Base $Field
|
168 |
* @param int $index
|
169 |
* @return array or null
|
@@ -182,7 +182,7 @@ class Smart_Custom_Fields_Controller_Base {
|
|
182 |
|
183 |
$value = $Meta->get( $field_name );
|
184 |
|
185 |
-
//
|
186 |
$repeat_multiple_data = SCF::get_repeat_multiple_data( $object );
|
187 |
if ( is_array( $repeat_multiple_data ) && isset( $repeat_multiple_data[$field_name] ) ) {
|
188 |
$now_num = 0;
|
@@ -190,7 +190,7 @@ class Smart_Custom_Fields_Controller_Base {
|
|
190 |
$now_num = $repeat_multiple_data[$field_name][$index];
|
191 |
}
|
192 |
|
193 |
-
//
|
194 |
$_temp = array_slice( $repeat_multiple_data[$field_name], 0, $index );
|
195 |
$sum = array_sum( $_temp );
|
196 |
$start = $sum;
|
@@ -203,9 +203,9 @@ class Smart_Custom_Fields_Controller_Base {
|
|
203 |
}
|
204 |
|
205 |
/**
|
206 |
-
*
|
207 |
*
|
208 |
-
* @param WP_Post|WP_User|
|
209 |
* @param Smart_Custom_Fields_Field_Base $Field
|
210 |
* @param int $index
|
211 |
* @return string or null
|
@@ -229,9 +229,9 @@ class Smart_Custom_Fields_Controller_Base {
|
|
229 |
}
|
230 |
|
231 |
/**
|
232 |
-
*
|
233 |
*
|
234 |
-
* @param WP_Post|WP_User|
|
235 |
* @param bool $is_repeat
|
236 |
* @param array $fields
|
237 |
* @param int, null $index
|
@@ -269,11 +269,11 @@ class Smart_Custom_Fields_Controller_Base {
|
|
269 |
$field_label = $field_name;
|
270 |
}
|
271 |
|
272 |
-
//
|
273 |
if ( $Field->get_attribute( 'allow-multiple-data' ) ) {
|
274 |
$value = $this->get_multiple_data_field_value( $object, $Field, $index );
|
275 |
}
|
276 |
-
//
|
277 |
else {
|
278 |
$value = $this->get_single_data_field_value( $object, $Field, $index );
|
279 |
}
|
11 |
class Smart_Custom_Fields_Controller_Base {
|
12 |
|
13 |
/**
|
14 |
+
* Array of the form field objects
|
15 |
* @var array
|
16 |
*/
|
17 |
protected $fields = array();
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
+
* Loading resources for edit page.
|
28 |
*
|
29 |
* @param string $hook
|
30 |
*/
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
+
* Display custom fields in edit page.
|
54 |
*
|
55 |
+
* @param WP_Post|WP_User|WP_Term $object
|
56 |
+
* @param array $callback_args custom field setting information
|
57 |
*/
|
58 |
public function display_meta_box( $object, $callback_args ) {
|
59 |
$groups = $callback_args['args'];
|
72 |
}
|
73 |
$this->display_tr( $object, $is_repeatable, $Group->get_fields(), $index );
|
74 |
|
75 |
+
// If in the loop, count up the index.
|
76 |
+
// If exit the loop, reset the count.
|
77 |
if ( $is_repeatable &&
|
78 |
isset( $tables[$group_key + 1 ] ) &&
|
79 |
$tables[$group_key + 1 ]->get_name() === $Group->get_name() ) {
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
+
* Saving posted data
|
94 |
*
|
95 |
* @param array $data
|
96 |
+
* @param WP_Post|WP_User|WP_Term $object
|
97 |
*/
|
98 |
protected function save( $data, $object ) {
|
99 |
check_admin_referer(
|
106 |
}
|
107 |
|
108 |
/**
|
109 |
+
* Generating array for displaying the custom fields
|
110 |
*
|
111 |
+
* @param WP_Post|WP_User|WP_Term $object
|
112 |
+
* @param array $groups Settings from custom field settings page
|
113 |
+
* @return array $tables Array for displaying a table for custom fields
|
114 |
*/
|
115 |
protected function get_tables( $object, $groups ) {
|
116 |
$Meta = new Smart_Custom_Fields_Meta( $object );
|
118 |
$repeat_multiple_data = SCF::get_repeat_multiple_data( $object );
|
119 |
$tables = array();
|
120 |
foreach ( $groups as $Group ) {
|
121 |
+
// If in the loop, Added groupgs by the amount of the loop.
|
122 |
+
// Added only one if setting is repetition but not loop (Ex, new registration)
|
123 |
if ( $Group->is_repeatable() === true ) {
|
124 |
$loop_count = 1;
|
125 |
$fields = $Group->get_fields();
|
128 |
$meta = $Meta->get( $field_name );
|
129 |
if ( is_array( $meta ) ) {
|
130 |
$meta_count = count( $meta );
|
131 |
+
// When the same name of the custom field is a multiple (checbox or loop)
|
132 |
if ( $meta_count > 1 ) {
|
133 |
+
// checkbox
|
134 |
if ( $Field->get_attribute( 'allow-multiple-data' ) ) {
|
135 |
if ( is_array( $repeat_multiple_data ) && isset( $repeat_multiple_data[$field_name] ) ) {
|
136 |
$repeat_multiple_data_count = count( $repeat_multiple_data[$field_name] );
|
139 |
}
|
140 |
}
|
141 |
}
|
142 |
+
// other than checkbox
|
143 |
else {
|
144 |
if ( $loop_count < $meta_count ) {
|
145 |
$loop_count = $meta_count;
|
161 |
}
|
162 |
|
163 |
/**
|
164 |
+
* Getting the multi-value field meta data.
|
165 |
*
|
166 |
+
* @param WP_Post|WP_User|WP_Term $object
|
167 |
* @param Smart_Custom_Fields_Field_Base $Field
|
168 |
* @param int $index
|
169 |
* @return array or null
|
182 |
|
183 |
$value = $Meta->get( $field_name );
|
184 |
|
185 |
+
// in the loop
|
186 |
$repeat_multiple_data = SCF::get_repeat_multiple_data( $object );
|
187 |
if ( is_array( $repeat_multiple_data ) && isset( $repeat_multiple_data[$field_name] ) ) {
|
188 |
$now_num = 0;
|
190 |
$now_num = $repeat_multiple_data[$field_name][$index];
|
191 |
}
|
192 |
|
193 |
+
// The index is starting point to refer to the total of the previous number than me ($index)
|
194 |
$_temp = array_slice( $repeat_multiple_data[$field_name], 0, $index );
|
195 |
$sum = array_sum( $_temp );
|
196 |
$start = $sum;
|
203 |
}
|
204 |
|
205 |
/**
|
206 |
+
* Getting the non multi-value field meta data.
|
207 |
*
|
208 |
+
* @param WP_Post|WP_User|WP_Term $object
|
209 |
* @param Smart_Custom_Fields_Field_Base $Field
|
210 |
* @param int $index
|
211 |
* @return string or null
|
229 |
}
|
230 |
|
231 |
/**
|
232 |
+
* Displaying tr element for table of custom fields
|
233 |
*
|
234 |
+
* @param WP_Post|WP_User|WP_Term $object
|
235 |
* @param bool $is_repeat
|
236 |
* @param array $fields
|
237 |
* @param int, null $index
|
269 |
$field_label = $field_name;
|
270 |
}
|
271 |
|
272 |
+
// When multi-value field
|
273 |
if ( $Field->get_attribute( 'allow-multiple-data' ) ) {
|
274 |
$value = $this->get_multiple_data_field_value( $object, $Field, $index );
|
275 |
}
|
276 |
+
// When non multi-value field
|
277 |
else {
|
278 |
$value = $this->get_single_data_field_value( $object, $Field, $index );
|
279 |
}
|
classes/controller/class.editor.php
CHANGED
@@ -20,7 +20,7 @@ class Smart_Custom_Fields_Controller_Editor extends Smart_Custom_Fields_Controll
|
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
-
*
|
24 |
*
|
25 |
* @param string $post_type
|
26 |
* @param WP_Post $post
|
@@ -41,7 +41,7 @@ class Smart_Custom_Fields_Controller_Editor extends Smart_Custom_Fields_Controll
|
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
-
*
|
45 |
*
|
46 |
* @param int $post_id
|
47 |
*/
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
+
* Displaying custom fields in post edit page
|
24 |
*
|
25 |
* @param string $post_type
|
26 |
* @param WP_Post $post
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
+
* Saving meta data from custom fields in post edit page
|
45 |
*
|
46 |
* @param int $post_id
|
47 |
*/
|
classes/controller/class.profile.php
CHANGED
@@ -22,7 +22,7 @@ class Smart_Custom_Fields_Controller_Profile extends Smart_Custom_Fields_Control
|
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
*
|
27 |
* @param string $hook
|
28 |
*/
|
@@ -35,7 +35,7 @@ class Smart_Custom_Fields_Controller_Profile extends Smart_Custom_Fields_Control
|
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
-
*
|
39 |
*
|
40 |
* @param WP_User $user
|
41 |
*/
|
@@ -56,7 +56,7 @@ class Smart_Custom_Fields_Controller_Profile extends Smart_Custom_Fields_Control
|
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
-
*
|
60 |
*
|
61 |
* @param int $user_id
|
62 |
*/
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
+
* Loading resources for profile edit page
|
26 |
*
|
27 |
* @param string $hook
|
28 |
*/
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
+
* Displaying custom fields
|
39 |
*
|
40 |
* @param WP_User $user
|
41 |
*/
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
+
* Saving meta data from custom fields in profile edit page.
|
60 |
*
|
61 |
* @param int $user_id
|
62 |
*/
|
classes/controller/class.settings.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
class Smart_Custom_Fields_Controller_Settings {
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
* @var array
|
16 |
*/
|
17 |
private $optgroups = array();
|
@@ -45,7 +45,7 @@ class Smart_Custom_Fields_Controller_Settings {
|
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
-
*
|
49 |
*/
|
50 |
public function admin_enqueue_scripts() {
|
51 |
do_action( SCF_Config::PREFIX . 'before-settings-enqueue-scripts' );
|
@@ -68,7 +68,7 @@ class Smart_Custom_Fields_Controller_Settings {
|
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
-
*
|
72 |
*/
|
73 |
public function add_meta_boxes() {
|
74 |
add_meta_box(
|
@@ -101,7 +101,7 @@ class Smart_Custom_Fields_Controller_Settings {
|
|
101 |
}
|
102 |
|
103 |
/**
|
104 |
-
* $key
|
105 |
*
|
106 |
* @param string $key
|
107 |
*/
|
@@ -112,7 +112,7 @@ class Smart_Custom_Fields_Controller_Settings {
|
|
112 |
}
|
113 |
|
114 |
/**
|
115 |
-
*
|
116 |
*/
|
117 |
public function display_meta_box() {
|
118 |
$Setting = SCF::add_setting( get_the_ID(), get_the_title() );
|
@@ -193,7 +193,7 @@ class Smart_Custom_Fields_Controller_Settings {
|
|
193 |
}
|
194 |
|
195 |
/**
|
196 |
-
*
|
197 |
*/
|
198 |
public function display_meta_box_condition_post() {
|
199 |
$post_types = get_post_types( array(
|
@@ -230,7 +230,7 @@ class Smart_Custom_Fields_Controller_Settings {
|
|
230 |
}
|
231 |
|
232 |
/**
|
233 |
-
*
|
234 |
*/
|
235 |
public function display_meta_box_condition_profile() {
|
236 |
$roles = get_editable_roles();
|
@@ -254,7 +254,7 @@ class Smart_Custom_Fields_Controller_Settings {
|
|
254 |
}
|
255 |
|
256 |
/**
|
257 |
-
*
|
258 |
*/
|
259 |
public function display_meta_box_condition_taxonomy() {
|
260 |
$taxonomies = get_taxonomies( array(
|
@@ -280,7 +280,7 @@ class Smart_Custom_Fields_Controller_Settings {
|
|
280 |
}
|
281 |
|
282 |
/**
|
283 |
-
*
|
284 |
*
|
285 |
* @param int $post_id
|
286 |
*/
|
@@ -298,14 +298,14 @@ class Smart_Custom_Fields_Controller_Settings {
|
|
298 |
|
299 |
$data = array();
|
300 |
foreach ( $_POST[SCF_Config::NAME] as $group_key => $group_value ) {
|
301 |
-
// $group_key = 0
|
302 |
if ( $group_key === 0 ) {
|
303 |
continue;
|
304 |
}
|
305 |
if ( !empty( $group_value['fields'] ) && count( $group_value['fields'] ) > 1 ) {
|
306 |
$fields = array();
|
307 |
foreach ( $group_value['fields'] as $field_key => $field_value ) {
|
308 |
-
// $field_key = 0
|
309 |
if ( $field_key === 0 ) {
|
310 |
continue;
|
311 |
}
|
@@ -323,8 +323,8 @@ class Smart_Custom_Fields_Controller_Settings {
|
|
323 |
$group_value['repeat'] = false;
|
324 |
}
|
325 |
|
326 |
-
// repeat
|
327 |
-
// true
|
328 |
if ( !( isset( $group_value['repeat'] ) && $group_value['repeat'] === true && !empty( $group_value['group-name'] ) ) ) {
|
329 |
$group_value['group-name'] = $group_key;
|
330 |
}
|
11 |
class Smart_Custom_Fields_Controller_Settings {
|
12 |
|
13 |
/**
|
14 |
+
* Selectbox choices of the field selection
|
15 |
* @var array
|
16 |
*/
|
17 |
private $optgroups = array();
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* Loading resources
|
49 |
*/
|
50 |
public function admin_enqueue_scripts() {
|
51 |
do_action( SCF_Config::PREFIX . 'before-settings-enqueue-scripts' );
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
+
* Adding meta boxes
|
72 |
*/
|
73 |
public function add_meta_boxes() {
|
74 |
add_meta_box(
|
101 |
}
|
102 |
|
103 |
/**
|
104 |
+
* Displaying "hide" if $key isn't empty
|
105 |
*
|
106 |
* @param string $key
|
107 |
*/
|
112 |
}
|
113 |
|
114 |
/**
|
115 |
+
* Displaying custom fields
|
116 |
*/
|
117 |
public function display_meta_box() {
|
118 |
$Setting = SCF::add_setting( get_the_ID(), get_the_title() );
|
193 |
}
|
194 |
|
195 |
/**
|
196 |
+
* Displaying the meta box to set the display conditions for post edit page
|
197 |
*/
|
198 |
public function display_meta_box_condition_post() {
|
199 |
$post_types = get_post_types( array(
|
230 |
}
|
231 |
|
232 |
/**
|
233 |
+
* Displaying the meta box to set the display conditions for profile edit page
|
234 |
*/
|
235 |
public function display_meta_box_condition_profile() {
|
236 |
$roles = get_editable_roles();
|
254 |
}
|
255 |
|
256 |
/**
|
257 |
+
* Displaying the meta box to set the display conditions for term edit page
|
258 |
*/
|
259 |
public function display_meta_box_condition_taxonomy() {
|
260 |
$taxonomies = get_taxonomies( array(
|
280 |
}
|
281 |
|
282 |
/**
|
283 |
+
* Saving settings
|
284 |
*
|
285 |
* @param int $post_id
|
286 |
*/
|
298 |
|
299 |
$data = array();
|
300 |
foreach ( $_POST[SCF_Config::NAME] as $group_key => $group_value ) {
|
301 |
+
// $group_key = 0 is hidden field so don't save
|
302 |
if ( $group_key === 0 ) {
|
303 |
continue;
|
304 |
}
|
305 |
if ( !empty( $group_value['fields'] ) && count( $group_value['fields'] ) > 1 ) {
|
306 |
$fields = array();
|
307 |
foreach ( $group_value['fields'] as $field_key => $field_value ) {
|
308 |
+
// $field_key = 0 is hidden field so don't save
|
309 |
if ( $field_key === 0 ) {
|
310 |
continue;
|
311 |
}
|
323 |
$group_value['repeat'] = false;
|
324 |
}
|
325 |
|
326 |
+
// If "repeat" isn't true, empty name
|
327 |
+
// If "repeat" is true and name is empty, assign index
|
328 |
if ( !( isset( $group_value['repeat'] ) && $group_value['repeat'] === true && !empty( $group_value['group-name'] ) ) ) {
|
329 |
$group_value['group-name'] = $group_key;
|
330 |
}
|
classes/controller/class.taxonomy.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
class Smart_Custom_Fields_Controller_Taxonomy extends Smart_Custom_Fields_Controller_Base {
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
* @var string
|
16 |
*/
|
17 |
protected $taxonomy;
|
@@ -29,7 +29,7 @@ class Smart_Custom_Fields_Controller_Taxonomy extends Smart_Custom_Fields_Contro
|
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
-
*
|
33 |
*
|
34 |
* @param string $hook
|
35 |
*/
|
@@ -42,7 +42,7 @@ class Smart_Custom_Fields_Controller_Taxonomy extends Smart_Custom_Fields_Contro
|
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
-
*
|
46 |
*
|
47 |
* @param object $term
|
48 |
*/
|
@@ -62,7 +62,7 @@ class Smart_Custom_Fields_Controller_Taxonomy extends Smart_Custom_Fields_Contro
|
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
-
*
|
66 |
*
|
67 |
* @param int $term_id
|
68 |
* @param string $taxonomy
|
@@ -80,7 +80,7 @@ class Smart_Custom_Fields_Controller_Taxonomy extends Smart_Custom_Fields_Contro
|
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
-
*
|
84 |
*
|
85 |
* @param int $term_id
|
86 |
* @param int $term_taxonomy_id
|
11 |
class Smart_Custom_Fields_Controller_Taxonomy extends Smart_Custom_Fields_Controller_Base {
|
12 |
|
13 |
/**
|
14 |
+
* Taxonomy NAME
|
15 |
* @var string
|
16 |
*/
|
17 |
protected $taxonomy;
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
+
* Loading resources for term edit page
|
33 |
*
|
34 |
* @param string $hook
|
35 |
*/
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
+
* Displaying custom fields in term edit page
|
46 |
*
|
47 |
* @param object $term
|
48 |
*/
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
+
* Saving meta data from custom fields in term edit page
|
66 |
*
|
67 |
* @param int $term_id
|
68 |
* @param string $taxonomy
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
+
* Delete meta data
|
84 |
*
|
85 |
* @param int $term_id
|
86 |
* @param int $term_taxonomy_id
|
classes/fields/class.field-boolean.php
CHANGED
@@ -13,7 +13,7 @@
|
|
13 |
class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
|
14 |
|
15 |
/**
|
16 |
-
*
|
17 |
*
|
18 |
* @return array
|
19 |
*/
|
@@ -27,7 +27,7 @@ class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
|
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
-
*
|
31 |
*
|
32 |
* @return array
|
33 |
*/
|
@@ -41,11 +41,10 @@ class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
|
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
-
*
|
45 |
-
*
|
46 |
-
* @param int $index インデックス番号
|
47 |
-
* @param mixed $value 保存されている値(check のときだけ配列)
|
48 |
*
|
|
|
|
|
49 |
* @return string html
|
50 |
*/
|
51 |
public function get_field( $index, $value ) {
|
@@ -72,7 +71,7 @@ class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
|
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
-
*
|
76 |
*
|
77 |
* @param int $group_key
|
78 |
* @param int $field_key
|
@@ -86,16 +85,18 @@ class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
|
|
86 |
|
87 |
<label>
|
88 |
<input type="radio"
|
89 |
-
|
90 |
-
|
91 |
-
<?php checked( 1, $this->get( 'default' ) ); ?>
|
|
|
92 |
<span><?php echo esc_html( $this->get( 'true_label' ) ); ?> ( true )</span>
|
93 |
</label>
|
94 |
<label>
|
95 |
<input type="radio"
|
96 |
-
|
97 |
-
|
98 |
-
<?php checked( 0, $this->get( 'default' ) ); ?>
|
|
|
99 |
<span><?php echo esc_html( $this->get( 'false_label' ) ); ?> ( false )</span>
|
100 |
</label>
|
101 |
|
@@ -106,38 +107,37 @@ class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
|
|
106 |
<th><?php esc_html_e( 'TRUE Label', 'smart-custom-fields' ); ?></th>
|
107 |
<td>
|
108 |
<input type="text"
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
</td>
|
114 |
</tr>
|
115 |
<tr>
|
116 |
<th><?php esc_html_e( 'FALSE Label', 'smart-custom-fields' ); ?></th>
|
117 |
<td>
|
118 |
<input type="text"
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
</td>
|
124 |
</tr>
|
125 |
<tr>
|
126 |
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
127 |
<td>
|
128 |
<input type="text"
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
</td>
|
134 |
</tr>
|
135 |
<?php
|
136 |
}
|
137 |
|
138 |
-
|
139 |
/**
|
140 |
-
*
|
141 |
*
|
142 |
* @param int|string $value
|
143 |
* @param string $field_type
|
13 |
class Smart_Custom_Fields_Field_Boolean extends Smart_Custom_Fields_Field_Base {
|
14 |
|
15 |
/**
|
16 |
+
* Set the required items
|
17 |
*
|
18 |
* @return array
|
19 |
*/
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
+
* Set the non required items
|
31 |
*
|
32 |
* @return array
|
33 |
*/
|
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 ) {
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
+
* Displaying the option fields in custom field settings page
|
75 |
*
|
76 |
* @param int $group_key
|
77 |
* @param int $field_key
|
85 |
|
86 |
<label>
|
87 |
<input type="radio"
|
88 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'default' ) ); ?>"
|
89 |
+
value="1"
|
90 |
+
<?php checked( 1, $this->get( 'default' ) ); ?>
|
91 |
+
/>
|
92 |
<span><?php echo esc_html( $this->get( 'true_label' ) ); ?> ( true )</span>
|
93 |
</label>
|
94 |
<label>
|
95 |
<input type="radio"
|
96 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'default' ) ); ?>"
|
97 |
+
value="0"
|
98 |
+
<?php checked( 0, $this->get( 'default' ) ); ?>
|
99 |
+
/>
|
100 |
<span><?php echo esc_html( $this->get( 'false_label' ) ); ?> ( false )</span>
|
101 |
</label>
|
102 |
|
107 |
<th><?php esc_html_e( 'TRUE Label', 'smart-custom-fields' ); ?></th>
|
108 |
<td>
|
109 |
<input type="text"
|
110 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'true_label' ) ); ?>"
|
111 |
+
class="widefat"
|
112 |
+
value="<?php echo esc_attr( $this->get( 'true_label' ) ); ?>"
|
113 |
+
/>
|
114 |
</td>
|
115 |
</tr>
|
116 |
<tr>
|
117 |
<th><?php esc_html_e( 'FALSE Label', 'smart-custom-fields' ); ?></th>
|
118 |
<td>
|
119 |
<input type="text"
|
120 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'false_label' ) ); ?>"
|
121 |
+
class="widefat"
|
122 |
+
value="<?php echo esc_attr( $this->get( 'false_label' ) ); ?>"
|
123 |
+
/>
|
124 |
</td>
|
125 |
</tr>
|
126 |
<tr>
|
127 |
<th><?php esc_html_e( 'Notes', 'smart-custom-fields' ); ?></th>
|
128 |
<td>
|
129 |
<input type="text"
|
130 |
+
name="<?php echo esc_attr( $this->get_field_name_in_setting( $group_key, $field_key, 'notes' ) ); ?>"
|
131 |
+
class="widefat"
|
132 |
+
value="<?php echo esc_attr( $this->get( 'notes' ) ); ?>"
|
133 |
+
/>
|
134 |
</td>
|
135 |
</tr>
|
136 |
<?php
|
137 |
}
|
138 |
|
|
|
139 |
/**
|
140 |
+
* Validating when displaying meta data
|
141 |
*
|
142 |
* @param int|string $value
|
143 |
* @param string $field_type
|
classes/fields/class.field-check.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
class Smart_Custom_Fields_Field_Check extends Smart_Custom_Fields_Field_Base {
|
12 |
|
13 |
/**
|
14 |
-
*
|
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 |
-
*
|
29 |
*
|
30 |
* @return array
|
31 |
*/
|
@@ -39,10 +39,10 @@ class Smart_Custom_Fields_Field_Check extends Smart_Custom_Fields_Field_Base {
|
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
-
*
|
43 |
*
|
44 |
-
* @param int $index
|
45 |
-
* @param
|
46 |
* @return string html
|
47 |
*/
|
48 |
public function get_field( $index, $value ) {
|
@@ -72,7 +72,7 @@ class Smart_Custom_Fields_Field_Check extends Smart_Custom_Fields_Field_Base {
|
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
-
*
|
76 |
*
|
77 |
* @param int $group_key
|
78 |
* @param int $field_key
|
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 |
*/
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
+
* Getting the field
|
43 |
*
|
44 |
+
* @param int $index
|
45 |
+
* @param array $value
|
46 |
* @return string html
|
47 |
*/
|
48 |
public function get_field( $index, $value ) {
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
+
* Displaying the option fields in custom field settings page
|
76 |
*
|
77 |
* @param int $group_key
|
78 |
* @param int $field_key
|
classes/fields/class.field-colorpicker.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Base {
|
12 |
|
13 |
/**
|
14 |
-
*
|
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 |
-
*
|
36 |
*
|
37 |
* @return array
|
38 |
*/
|
@@ -44,7 +44,7 @@ class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Ba
|
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
-
*
|
48 |
*/
|
49 |
public function editor_enqueue_scripts() {
|
50 |
wp_enqueue_style( 'wp-color-picker' );
|
@@ -58,7 +58,7 @@ class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Ba
|
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
-
*
|
62 |
*/
|
63 |
public function settings_enqueue_scripts() {
|
64 |
wp_enqueue_style( 'wp-color-picker' );
|
@@ -72,10 +72,10 @@ class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Ba
|
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
-
*
|
76 |
*
|
77 |
-
* @param int $index
|
78 |
-
* @param
|
79 |
* @return string html
|
80 |
*/
|
81 |
public function get_field( $index, $value ) {
|
@@ -91,7 +91,7 @@ class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Ba
|
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
-
*
|
95 |
*
|
96 |
* @param int $group_key
|
97 |
* @param int $field_key
|
@@ -119,4 +119,4 @@ class Smart_Custom_Fields_Field_Colorpicker extends Smart_Custom_Fields_Field_Ba
|
|
119 |
</tr>
|
120 |
<?php
|
121 |
}
|
122 |
-
}
|
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 |
*/
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
+
* Loading resources for editor
|
48 |
*/
|
49 |
public function editor_enqueue_scripts() {
|
50 |
wp_enqueue_style( 'wp-color-picker' );
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
+
* Loading resources for editor for custom field settings page
|
62 |
*/
|
63 |
public function settings_enqueue_scripts() {
|
64 |
wp_enqueue_style( 'wp-color-picker' );
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
+
* Getting the field
|
76 |
*
|
77 |
+
* @param int $index
|
78 |
+
* @param string $value
|
79 |
* @return string html
|
80 |
*/
|
81 |
public function get_field( $index, $value ) {
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
+
* Displaying the option fields in custom field settings page
|
95 |
*
|
96 |
* @param int $group_key
|
97 |
* @param int $field_key
|
119 |
</tr>
|
120 |
<?php
|
121 |
}
|
122 |
+
}
|
classes/fields/class.field-datepicker.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Base {
|
12 |
|
13 |
/**
|
14 |
-
*
|
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 |
-
*
|
36 |
*
|
37 |
* @return array
|
38 |
*/
|
@@ -47,7 +47,7 @@ class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Bas
|
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
-
*
|
51 |
*/
|
52 |
public function editor_enqueue_scripts() {
|
53 |
global $wp_scripts;
|
@@ -69,7 +69,7 @@ class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Bas
|
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
-
*
|
73 |
*/
|
74 |
public function settings_enqueue_scripts() {
|
75 |
global $wp_scripts;
|
@@ -91,10 +91,10 @@ class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Bas
|
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
-
*
|
95 |
*
|
96 |
-
* @param int $index
|
97 |
-
* @param
|
98 |
* @return string html
|
99 |
*/
|
100 |
public function get_field( $index, $value ) {
|
@@ -113,7 +113,7 @@ class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Bas
|
|
113 |
}
|
114 |
|
115 |
/**
|
116 |
-
*
|
117 |
*
|
118 |
* @param int $group_key
|
119 |
* @param int $field_key
|
@@ -198,9 +198,9 @@ class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Bas
|
|
198 |
}
|
199 |
|
200 |
/**
|
201 |
-
*
|
202 |
*
|
203 |
-
* @return string json_encode
|
204 |
*/
|
205 |
protected function get_data_js() {
|
206 |
$js = array(
|
@@ -208,7 +208,8 @@ class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Bas
|
|
208 |
'changeYear' => true,
|
209 |
'changeMonth' => true,
|
210 |
);
|
211 |
-
|
|
|
212 |
if ( get_locale() === 'ja' ) {
|
213 |
$js = array_merge( $js, array(
|
214 |
'yearSuffix' => '年',
|
@@ -230,15 +231,19 @@ class Smart_Custom_Fields_Field_Datepicker extends Smart_Custom_Fields_Field_Bas
|
|
230 |
)
|
231 |
) );
|
232 |
}
|
|
|
233 |
if ( $this->get( 'date_format' ) ) {
|
234 |
$js['dateFormat'] = $this->get( 'date_format' );
|
235 |
}
|
|
|
236 |
if ( $this->get( 'max_date' ) ) {
|
237 |
$js['maxDate'] = $this->get( 'max_date' );
|
238 |
}
|
|
|
239 |
if ( $this->get( 'min_date' ) ) {
|
240 |
$js['minDate'] = $this->get( 'min_date' );
|
241 |
}
|
|
|
242 |
return json_encode( $js );
|
243 |
}
|
244 |
}
|
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 |
*/
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* Loading resources for editor
|
51 |
*/
|
52 |
public function editor_enqueue_scripts() {
|
53 |
global $wp_scripts;
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
+
* Loading resources for editor for custom field settings page
|
73 |
*/
|
74 |
public function settings_enqueue_scripts() {
|
75 |
global $wp_scripts;
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
+
* Getting the field
|
95 |
*
|
96 |
+
* @param int $index
|
97 |
+
* @param string $value
|
98 |
* @return string html
|
99 |
*/
|
100 |
public function get_field( $index, $value ) {
|
113 |
}
|
114 |
|
115 |
/**
|
116 |
+
* Displaying the option fields in custom field settings page
|
117 |
*
|
118 |
* @param int $group_key
|
119 |
* @param int $field_key
|
198 |
}
|
199 |
|
200 |
/**
|
201 |
+
* Return datepicker option with json_encode
|
202 |
*
|
203 |
+
* @return string option with json_encode
|
204 |
*/
|
205 |
protected function get_data_js() {
|
206 |
$js = array(
|
208 |
'changeYear' => true,
|
209 |
'changeMonth' => true,
|
210 |
);
|
211 |
+
|
212 |
+
// If locale is Japanese, change in Japanese notation
|
213 |
if ( get_locale() === 'ja' ) {
|
214 |
$js = array_merge( $js, array(
|
215 |
'yearSuffix' => '年',
|
231 |
)
|
232 |
) );
|
233 |
}
|
234 |
+
|
235 |
if ( $this->get( 'date_format' ) ) {
|
236 |
$js['dateFormat'] = $this->get( 'date_format' );
|
237 |
}
|
238 |
+
|
239 |
if ( $this->get( 'max_date' ) ) {
|
240 |
$js['maxDate'] = $this->get( 'max_date' );
|
241 |
}
|
242 |
+
|
243 |
if ( $this->get( 'min_date' ) ) {
|
244 |
$js['minDate'] = $this->get( 'min_date' );
|
245 |
}
|
246 |
+
|
247 |
return json_encode( $js );
|
248 |
}
|
249 |
}
|
classes/fields/class.field-file.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
class Smart_Custom_Fields_Field_File extends Smart_Custom_Fields_Field_Base {
|
12 |
|
13 |
/**
|
14 |
-
*
|
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 |
-
*
|
28 |
*
|
29 |
* @return array
|
30 |
*/
|
@@ -35,10 +35,10 @@ class Smart_Custom_Fields_Field_File extends Smart_Custom_Fields_Field_Base {
|
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
-
*
|
39 |
*
|
40 |
-
* @param int $index
|
41 |
-
* @param
|
42 |
* @return string html
|
43 |
*/
|
44 |
public function get_field( $index, $value ) {
|
@@ -81,7 +81,7 @@ class Smart_Custom_Fields_Field_File extends Smart_Custom_Fields_Field_Base {
|
|
81 |
}
|
82 |
|
83 |
/**
|
84 |
-
*
|
85 |
*
|
86 |
* @param int $group_key
|
87 |
* @param int $field_key
|
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 |
*/
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
+
* Getting the field
|
39 |
*
|
40 |
+
* @param int $index
|
41 |
+
* @param string $value
|
42 |
* @return string html
|
43 |
*/
|
44 |
public function get_field( $index, $value ) {
|
81 |
}
|
82 |
|
83 |
/**
|
84 |
+
* Displaying the option fields in custom field settings page
|
85 |
*
|
86 |
* @param int $group_key
|
87 |
* @param int $field_key
|
classes/fields/class.field-image.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
class Smart_Custom_Fields_Field_Image extends Smart_Custom_Fields_Field_Base {
|
12 |
|
13 |
/**
|
14 |
-
*
|
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 |
-
*
|
28 |
*
|
29 |
* @return array
|
30 |
*/
|
@@ -36,10 +36,10 @@ class Smart_Custom_Fields_Field_Image extends Smart_Custom_Fields_Field_Base {
|
|
36 |
}
|
37 |
|
38 |
/**
|
39 |
-
*
|
40 |
*
|
41 |
-
* @param int $index
|
42 |
-
* @param
|
43 |
* @return string html
|
44 |
*/
|
45 |
public function get_field( $index, $value ) {
|
@@ -82,7 +82,7 @@ class Smart_Custom_Fields_Field_Image extends Smart_Custom_Fields_Field_Base {
|
|
82 |
}
|
83 |
|
84 |
/**
|
85 |
-
*
|
86 |
*
|
87 |
* @param int $group_key
|
88 |
* @param int $field_key
|
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 |
*/
|
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 ) {
|
82 |
}
|
83 |
|
84 |
/**
|
85 |
+
* Displaying the option fields in custom field settings page
|
86 |
*
|
87 |
* @param int $group_key
|
88 |
* @param int $field_key
|
classes/fields/class.field-radio.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
class Smart_Custom_Fields_Field_Radio extends Smart_Custom_Fields_Field_Base {
|
12 |
|
13 |
/**
|
14 |
-
*
|
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 |
-
*
|
28 |
*
|
29 |
* @return array
|
30 |
*/
|
@@ -38,10 +38,10 @@ class Smart_Custom_Fields_Field_Radio extends Smart_Custom_Fields_Field_Base {
|
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
-
*
|
42 |
*
|
43 |
-
* @param int $index
|
44 |
-
* @param
|
45 |
* @return string html
|
46 |
*/
|
47 |
public function get_field( $index, $value ) {
|
@@ -71,7 +71,7 @@ class Smart_Custom_Fields_Field_Radio extends Smart_Custom_Fields_Field_Base {
|
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
-
*
|
75 |
*
|
76 |
* @param int $group_key
|
77 |
* @param int $field_key
|
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 |
*/
|
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 ) {
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
+
* Displaying the option fields in custom field settings page
|
75 |
*
|
76 |
* @param int $group_key
|
77 |
* @param int $field_key
|
classes/fields/class.field-relation.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
class Smart_Custom_Fields_Field_Relation extends Smart_Custom_Fields_Field_Base {
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
*
|
16 |
* @return array
|
17 |
*/
|
@@ -28,7 +28,7 @@ class Smart_Custom_Fields_Field_Relation extends Smart_Custom_Fields_Field_Base
|
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
-
*
|
32 |
*
|
33 |
* @return array
|
34 |
*/
|
@@ -40,7 +40,7 @@ class Smart_Custom_Fields_Field_Relation extends Smart_Custom_Fields_Field_Base
|
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
-
*
|
44 |
*
|
45 |
* @param string $hook
|
46 |
*/
|
@@ -62,7 +62,7 @@ class Smart_Custom_Fields_Field_Relation extends Smart_Custom_Fields_Field_Base
|
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
-
*
|
66 |
*/
|
67 |
public function relational_posts_search() {
|
68 |
check_ajax_referer( SCF_Config::NAME . '-relation', 'nonce' );
|
@@ -105,10 +105,10 @@ class Smart_Custom_Fields_Field_Relation extends Smart_Custom_Fields_Field_Base
|
|
105 |
}
|
106 |
|
107 |
/**
|
108 |
-
*
|
109 |
*
|
110 |
-
* @param int $index
|
111 |
-
* @param
|
112 |
* @return string html
|
113 |
*/
|
114 |
public function get_field( $index, $value ) {
|
@@ -120,7 +120,7 @@ class Smart_Custom_Fields_Field_Relation extends Smart_Custom_Fields_Field_Base
|
|
120 |
}
|
121 |
$posts_per_page = get_option( 'posts_per_page' );
|
122 |
|
123 |
-
//
|
124 |
$choices_posts = get_posts( array(
|
125 |
'post_type' => $post_type,
|
126 |
'order' => 'ASC',
|
@@ -136,7 +136,7 @@ class Smart_Custom_Fields_Field_Relation extends Smart_Custom_Fields_Field_Base
|
|
136 |
$choices_li[] = sprintf( '<li data-id="%d">%s</li>', $_post->ID, $post_title );
|
137 |
}
|
138 |
|
139 |
-
//
|
140 |
$selected_posts = array();
|
141 |
if ( !empty( $value ) && is_array( $value ) ) {
|
142 |
foreach ( $value as $post_id ) {
|
@@ -202,7 +202,7 @@ class Smart_Custom_Fields_Field_Relation extends Smart_Custom_Fields_Field_Base
|
|
202 |
}
|
203 |
|
204 |
/**
|
205 |
-
*
|
206 |
*
|
207 |
* @param int $group_key
|
208 |
* @param int $field_key
|
@@ -244,7 +244,7 @@ class Smart_Custom_Fields_Field_Relation extends Smart_Custom_Fields_Field_Base
|
|
244 |
}
|
245 |
|
246 |
/**
|
247 |
-
*
|
248 |
*
|
249 |
* @param array $value
|
250 |
* @param string $field_type
|
11 |
class Smart_Custom_Fields_Field_Relation 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 |
*/
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
+
* Loading resources
|
44 |
*
|
45 |
* @param string $hook
|
46 |
*/
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
+
* Process that loading post when clicking post load button
|
66 |
*/
|
67 |
public function relational_posts_search() {
|
68 |
check_ajax_referer( SCF_Config::NAME . '-relation', 'nonce' );
|
105 |
}
|
106 |
|
107 |
/**
|
108 |
+
* Getting the field
|
109 |
*
|
110 |
+
* @param int $index
|
111 |
+
* @param array $value
|
112 |
* @return string html
|
113 |
*/
|
114 |
public function get_field( $index, $value ) {
|
120 |
}
|
121 |
$posts_per_page = get_option( 'posts_per_page' );
|
122 |
|
123 |
+
// choicse
|
124 |
$choices_posts = get_posts( array(
|
125 |
'post_type' => $post_type,
|
126 |
'order' => 'ASC',
|
136 |
$choices_li[] = sprintf( '<li data-id="%d">%s</li>', $_post->ID, $post_title );
|
137 |
}
|
138 |
|
139 |
+
// selected
|
140 |
$selected_posts = array();
|
141 |
if ( !empty( $value ) && is_array( $value ) ) {
|
142 |
foreach ( $value as $post_id ) {
|
202 |
}
|
203 |
|
204 |
/**
|
205 |
+
* Displaying the option fields in custom field settings page
|
206 |
*
|
207 |
* @param int $group_key
|
208 |
* @param int $field_key
|
244 |
}
|
245 |
|
246 |
/**
|
247 |
+
* Validating when displaying meta data
|
248 |
*
|
249 |
* @param array $value
|
250 |
* @param string $field_type
|
classes/fields/class.field-select.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
class Smart_Custom_Fields_Field_Select extends Smart_Custom_Fields_Field_Base {
|
12 |
|
13 |
/**
|
14 |
-
*
|
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 |
-
*
|
28 |
*
|
29 |
* @return array
|
30 |
*/
|
@@ -37,10 +37,10 @@ class Smart_Custom_Fields_Field_Select extends Smart_Custom_Fields_Field_Base {
|
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
-
*
|
41 |
*
|
42 |
-
* @param int $index
|
43 |
-
* @param
|
44 |
* @return string html
|
45 |
*/
|
46 |
public function get_field( $index, $value ) {
|
@@ -65,7 +65,7 @@ class Smart_Custom_Fields_Field_Select extends Smart_Custom_Fields_Field_Base {
|
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
-
*
|
69 |
*
|
70 |
* @param int $group_key
|
71 |
* @param int $field_key
|
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 |
*/
|
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 ) {
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
+
* Displaying the option fields in custom field settings page
|
69 |
*
|
70 |
* @param int $group_key
|
71 |
* @param int $field_key
|
classes/fields/class.field-text.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
class Smart_Custom_Fields_Field_Text extends Smart_Custom_Fields_Field_Base {
|
12 |
|
13 |
/**
|
14 |
-
*
|
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 |
-
*
|
28 |
*
|
29 |
* @return array
|
30 |
*/
|
@@ -36,10 +36,10 @@ class Smart_Custom_Fields_Field_Text extends Smart_Custom_Fields_Field_Base {
|
|
36 |
}
|
37 |
|
38 |
/**
|
39 |
-
*
|
40 |
*
|
41 |
-
* @param int $index
|
42 |
-
* @param
|
43 |
* @return string html
|
44 |
*/
|
45 |
public function get_field( $index, $value ) {
|
@@ -54,7 +54,7 @@ class Smart_Custom_Fields_Field_Text extends Smart_Custom_Fields_Field_Base {
|
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
-
*
|
58 |
*
|
59 |
* @param int $group_key
|
60 |
* @param int $field_key
|
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 |
*/
|
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 ) {
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
+
* Displaying the option fields in custom field settings page
|
58 |
*
|
59 |
* @param int $group_key
|
60 |
* @param int $field_key
|
classes/fields/class.field-textarea.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
class Smart_Custom_Fields_Field_Textarea extends Smart_Custom_Fields_Field_Base {
|
12 |
|
13 |
/**
|
14 |
-
*
|
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 |
-
*
|
28 |
*
|
29 |
* @return array
|
30 |
*/
|
@@ -36,10 +36,10 @@ class Smart_Custom_Fields_Field_Textarea extends Smart_Custom_Fields_Field_Base
|
|
36 |
}
|
37 |
|
38 |
/**
|
39 |
-
*
|
40 |
*
|
41 |
-
* @param int $index
|
42 |
-
* @param
|
43 |
* @return string html
|
44 |
*/
|
45 |
public function get_field( $index, $value ) {
|
@@ -54,7 +54,7 @@ class Smart_Custom_Fields_Field_Textarea extends Smart_Custom_Fields_Field_Base
|
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
-
*
|
58 |
*
|
59 |
* @param int $group_key
|
60 |
* @param int $field_key
|
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 |
*/
|
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 ) {
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
+
* Displaying the option fields in custom field settings page
|
58 |
*
|
59 |
* @param int $group_key
|
60 |
* @param int $field_key
|
classes/fields/class.field-wysiwyg.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
|
12 |
|
13 |
/**
|
14 |
-
*
|
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 |
-
*
|
33 |
*
|
34 |
* @return array
|
35 |
*/
|
@@ -41,15 +41,11 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
|
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
-
* TinyMCE
|
45 |
*/
|
46 |
public function editor_enqueue_scripts() {
|
47 |
add_action( 'after_wp_tiny_mce', array( $this, 'after_wp_tiny_mce' ) );
|
48 |
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* JS の読み込み
|
52 |
-
*/
|
53 |
public function after_wp_tiny_mce() {
|
54 |
printf(
|
55 |
'<script type="text/javascript" src="%s"></script>',
|
@@ -58,7 +54,8 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
|
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
-
*
|
|
|
62 |
*/
|
63 |
protected function after_loaded() {
|
64 |
add_action( 'admin_footer', array( $this, 'admin_footer' ) );
|
@@ -72,10 +69,10 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
|
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
-
*
|
76 |
*
|
77 |
-
* @param int $index
|
78 |
-
* @param
|
79 |
* @return string html
|
80 |
*/
|
81 |
public function get_field( $index, $value ) {
|
@@ -103,7 +100,7 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
|
|
103 |
}
|
104 |
|
105 |
/**
|
106 |
-
*
|
107 |
*
|
108 |
* @param int $group_key
|
109 |
* @param int $field_key
|
@@ -133,7 +130,7 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
|
|
133 |
}
|
134 |
|
135 |
/**
|
136 |
-
*
|
137 |
*
|
138 |
* @param string $editor_id
|
139 |
* @return string
|
@@ -148,7 +145,7 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
|
|
148 |
}
|
149 |
|
150 |
/**
|
151 |
-
*
|
152 |
*
|
153 |
* @param mixed $value
|
154 |
* @param string $field_type
|
@@ -170,7 +167,7 @@ class Smart_Custom_Fields_Field_Wysiwyg extends Smart_Custom_Fields_Field_Base {
|
|
170 |
}
|
171 |
|
172 |
/**
|
173 |
-
*
|
174 |
*
|
175 |
* @param string $value
|
176 |
* @return string
|
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 |
*/
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
+
* Loading js after loading TinyMCE in editor page
|
45 |
*/
|
46 |
public function editor_enqueue_scripts() {
|
47 |
add_action( 'after_wp_tiny_mce', array( $this, 'after_wp_tiny_mce' ) );
|
48 |
}
|
|
|
|
|
|
|
|
|
49 |
public function after_wp_tiny_mce() {
|
50 |
printf(
|
51 |
'<script type="text/javascript" src="%s"></script>',
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
+
* Processing to be executed immediately after the field initialization
|
58 |
+
* If not exec this, taxonomy and profile wysiwyg has js error.
|
59 |
*/
|
60 |
protected function after_loaded() {
|
61 |
add_action( 'admin_footer', array( $this, 'admin_footer' ) );
|
69 |
}
|
70 |
|
71 |
/**
|
72 |
+
* Getting the field
|
73 |
*
|
74 |
+
* @param int $index
|
75 |
+
* @param string $value
|
76 |
* @return string html
|
77 |
*/
|
78 |
public function get_field( $index, $value ) {
|
100 |
}
|
101 |
|
102 |
/**
|
103 |
+
* Displaying the option fields in custom field settings page
|
104 |
*
|
105 |
* @param int $group_key
|
106 |
* @param int $field_key
|
130 |
}
|
131 |
|
132 |
/**
|
133 |
+
* Return the media button
|
134 |
*
|
135 |
* @param string $editor_id
|
136 |
* @return string
|
145 |
}
|
146 |
|
147 |
/**
|
148 |
+
* Validating when displaying meta data
|
149 |
*
|
150 |
* @param mixed $value
|
151 |
* @param string $field_type
|
167 |
}
|
168 |
|
169 |
/**
|
170 |
+
* Hooking functions that is hooked to the_content
|
171 |
*
|
172 |
* @param string $value
|
173 |
* @return string
|
classes/models/class.abstract-field-base.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
abstract class Smart_Custom_Fields_Field_Base {
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
* @var array
|
16 |
*/
|
17 |
protected $attributes = array(
|
@@ -22,12 +22,12 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
22 |
);
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
* @var array
|
27 |
*/
|
28 |
protected $options = array(
|
29 |
-
'name' => '',
|
30 |
-
'label' => '',
|
31 |
);
|
32 |
|
33 |
/**
|
@@ -54,38 +54,38 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
-
*
|
58 |
*
|
59 |
* @return array
|
60 |
*/
|
61 |
abstract protected function init();
|
62 |
|
63 |
/**
|
64 |
-
*
|
65 |
*
|
66 |
* @return array
|
67 |
*/
|
68 |
abstract protected function options();
|
69 |
|
70 |
/**
|
71 |
-
*
|
72 |
*/
|
73 |
protected function after_loaded() {
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
-
*
|
78 |
*
|
79 |
-
* @param int $index
|
80 |
-
* @param mixed $value
|
81 |
* @return string html
|
82 |
*/
|
83 |
abstract public function get_field( $index, $value );
|
84 |
|
85 |
/**
|
86 |
-
*
|
87 |
*
|
88 |
-
* @param array $attributes
|
89 |
* @return array
|
90 |
*/
|
91 |
public function field_select( $attributes ) {
|
@@ -94,7 +94,7 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
94 |
}
|
95 |
|
96 |
/**
|
97 |
-
*
|
98 |
*
|
99 |
* @param int $group_key
|
100 |
* @param int $field_key
|
@@ -136,7 +136,7 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
136 |
}
|
137 |
|
138 |
/**
|
139 |
-
*
|
140 |
*
|
141 |
* @param int $group_key
|
142 |
* @param int $field_key
|
@@ -155,10 +155,10 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
155 |
}
|
156 |
|
157 |
/**
|
158 |
-
*
|
159 |
*
|
160 |
-
* @param string $name
|
161 |
-
* @param string $index
|
162 |
* @return string
|
163 |
*/
|
164 |
protected function get_field_name_in_editor( $index ) {
|
@@ -171,10 +171,10 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
171 |
}
|
172 |
|
173 |
/**
|
174 |
-
*
|
175 |
-
*
|
176 |
*
|
177 |
-
* @param string $index
|
178 |
* @return bool $disabled
|
179 |
*/
|
180 |
protected function get_disable_attribute( $index ) {
|
@@ -186,7 +186,7 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
186 |
}
|
187 |
|
188 |
/**
|
189 |
-
*
|
190 |
*
|
191 |
* @param int $group_key
|
192 |
* @param int $field_key
|
@@ -204,9 +204,9 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
204 |
}
|
205 |
|
206 |
/**
|
207 |
-
*
|
208 |
*
|
209 |
-
* @param string $key
|
210 |
* @return mixed
|
211 |
*/
|
212 |
public function get( $key ) {
|
@@ -216,10 +216,10 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
216 |
}
|
217 |
|
218 |
/**
|
219 |
-
*
|
220 |
*
|
221 |
-
* @param string $key
|
222 |
-
* @param mixed $value
|
223 |
*/
|
224 |
public function set( $key, $value ) {
|
225 |
if ( array_key_exists( $key, $this->options ) ) {
|
@@ -228,9 +228,9 @@ abstract class Smart_Custom_Fields_Field_Base {
|
|
228 |
}
|
229 |
|
230 |
/**
|
231 |
-
*
|
232 |
*
|
233 |
-
* @param string $key
|
234 |
* @return mixed
|
235 |
*/
|
236 |
public function get_attribute( $key ) {
|
11 |
abstract class Smart_Custom_Fields_Field_Base {
|
12 |
|
13 |
/**
|
14 |
+
* Internal attribute value of this field
|
15 |
* @var array
|
16 |
*/
|
17 |
protected $attributes = array(
|
22 |
);
|
23 |
|
24 |
/**
|
25 |
+
* Options of this field
|
26 |
* @var array
|
27 |
*/
|
28 |
protected $options = array(
|
29 |
+
'name' => '',
|
30 |
+
'label' => '',
|
31 |
);
|
32 |
|
33 |
/**
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
+
* Set the required items
|
58 |
*
|
59 |
* @return array
|
60 |
*/
|
61 |
abstract protected function init();
|
62 |
|
63 |
/**
|
64 |
+
* Set the non required items
|
65 |
*
|
66 |
* @return array
|
67 |
*/
|
68 |
abstract protected function options();
|
69 |
|
70 |
/**
|
71 |
+
* Processing to be executed immediately after the field initialization
|
72 |
*/
|
73 |
protected function after_loaded() {
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
+
* Getting the field
|
78 |
*
|
79 |
+
* @param int $index
|
80 |
+
* @param mixed $value
|
81 |
* @return string html
|
82 |
*/
|
83 |
abstract public function get_field( $index, $value );
|
84 |
|
85 |
/**
|
86 |
+
* Adding the type of this field to fields selection in custom field settings page
|
87 |
*
|
88 |
+
* @param array $attributes List of fields that belong to the optgroup
|
89 |
* @return array
|
90 |
*/
|
91 |
public function field_select( $attributes ) {
|
94 |
}
|
95 |
|
96 |
/**
|
97 |
+
* Displaying the option fields in custom field settings page ( Common )
|
98 |
*
|
99 |
* @param int $group_key
|
100 |
* @param int $field_key
|
136 |
}
|
137 |
|
138 |
/**
|
139 |
+
* Displaying the option fields in custom field settings page ( original )
|
140 |
*
|
141 |
* @param int $group_key
|
142 |
* @param int $field_key
|
155 |
}
|
156 |
|
157 |
/**
|
158 |
+
* Getting the name attribute in editor page
|
159 |
*
|
160 |
+
* @param string $name
|
161 |
+
* @param string $index
|
162 |
* @return string
|
163 |
*/
|
164 |
protected function get_field_name_in_editor( $index ) {
|
171 |
}
|
172 |
|
173 |
/**
|
174 |
+
* Whether to disabled
|
175 |
+
* Return true only when the null because data that all users have saved when $index is not null
|
176 |
*
|
177 |
+
* @param string $index
|
178 |
* @return bool $disabled
|
179 |
*/
|
180 |
protected function get_disable_attribute( $index ) {
|
186 |
}
|
187 |
|
188 |
/**
|
189 |
+
* Getting the name attribute in custom field settings page
|
190 |
*
|
191 |
* @param int $group_key
|
192 |
* @param int $field_key
|
204 |
}
|
205 |
|
206 |
/**
|
207 |
+
* Getting saved option value
|
208 |
*
|
209 |
+
* @param string $key key of the data
|
210 |
* @return mixed
|
211 |
*/
|
212 |
public function get( $key ) {
|
216 |
}
|
217 |
|
218 |
/**
|
219 |
+
* Set option value
|
220 |
*
|
221 |
+
* @param string $key
|
222 |
+
* @param mixed $value
|
223 |
*/
|
224 |
public function set( $key, $value ) {
|
225 |
if ( array_key_exists( $key, $this->options ) ) {
|
228 |
}
|
229 |
|
230 |
/**
|
231 |
+
* Getting the attribute value
|
232 |
*
|
233 |
+
* @param string $key
|
234 |
* @return mixed
|
235 |
*/
|
236 |
public function get_attribute( $key ) {
|
classes/models/class.ajax.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
class Smart_Custom_Fields_Ajax {
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
*/
|
16 |
public function __construct() {
|
17 |
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
@@ -20,7 +20,7 @@ class Smart_Custom_Fields_Ajax {
|
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
-
*
|
24 |
*
|
25 |
* @param int $term_id
|
26 |
* @param int $term_taxonomy_id
|
11 |
class Smart_Custom_Fields_Ajax {
|
12 |
|
13 |
/**
|
14 |
+
* Hooking the process that it want to fire when the ajax request.
|
15 |
*/
|
16 |
public function __construct() {
|
17 |
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
+
* Deleting term meta
|
24 |
*
|
25 |
* @param int $term_id
|
26 |
* @param int $term_taxonomy_id
|
classes/models/class.group.php
CHANGED
@@ -11,19 +11,19 @@
|
|
11 |
class Smart_Custom_Fields_Group {
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
* @var string
|
16 |
*/
|
17 |
protected $name = null;
|
18 |
|
19 |
/**
|
20 |
-
*
|
21 |
* @var array
|
22 |
*/
|
23 |
protected $fields = array();
|
24 |
|
25 |
/**
|
26 |
-
*
|
27 |
* @var bool
|
28 |
*/
|
29 |
protected $repeat = false;
|
@@ -31,9 +31,9 @@ class Smart_Custom_Fields_Group {
|
|
31 |
/**
|
32 |
* __construct
|
33 |
*
|
34 |
-
* @param string $group_name
|
35 |
-
* @param bool $repeat
|
36 |
-
* @param array $_fields
|
37 |
*/
|
38 |
public function __construct( $group_name = null, $repeat = false, array $_fields = array() ) {
|
39 |
$this->name = $group_name;
|
@@ -56,7 +56,7 @@ class Smart_Custom_Fields_Group {
|
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
-
*
|
60 |
*
|
61 |
* @return string
|
62 |
*/
|
@@ -68,7 +68,7 @@ class Smart_Custom_Fields_Group {
|
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
-
*
|
72 |
*
|
73 |
* @return array
|
74 |
*/
|
@@ -77,9 +77,9 @@ class Smart_Custom_Fields_Group {
|
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
-
*
|
81 |
*
|
82 |
-
* @param string $field_name
|
83 |
* @return Smart_Custom_Fields_Field_Base|null
|
84 |
*/
|
85 |
public function get_field( $field_name ) {
|
@@ -90,7 +90,7 @@ class Smart_Custom_Fields_Group {
|
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
-
*
|
94 |
*
|
95 |
* @return bool
|
96 |
*/
|
@@ -99,7 +99,7 @@ class Smart_Custom_Fields_Group {
|
|
99 |
}
|
100 |
|
101 |
/**
|
102 |
-
* $key
|
103 |
*
|
104 |
* @param string $key
|
105 |
*/
|
@@ -110,7 +110,7 @@ class Smart_Custom_Fields_Group {
|
|
110 |
}
|
111 |
|
112 |
/**
|
113 |
-
*
|
114 |
*
|
115 |
* @param int $group_key
|
116 |
*/
|
11 |
class Smart_Custom_Fields_Group {
|
12 |
|
13 |
/**
|
14 |
+
* Group name
|
15 |
* @var string
|
16 |
*/
|
17 |
protected $name = null;
|
18 |
|
19 |
/**
|
20 |
+
* Array of field objects
|
21 |
* @var array
|
22 |
*/
|
23 |
protected $fields = array();
|
24 |
|
25 |
/**
|
26 |
+
* Whether repeating group
|
27 |
* @var bool
|
28 |
*/
|
29 |
protected $repeat = false;
|
31 |
/**
|
32 |
* __construct
|
33 |
*
|
34 |
+
* @param string $group_name
|
35 |
+
* @param bool $repeat
|
36 |
+
* @param array $_fields
|
37 |
*/
|
38 |
public function __construct( $group_name = null, $repeat = false, array $_fields = array() ) {
|
39 |
$this->name = $group_name;
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
+
* Getting group name
|
60 |
*
|
61 |
* @return string
|
62 |
*/
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
+
* Getting fields that saved in this settings page
|
72 |
*
|
73 |
* @return array
|
74 |
*/
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
+
* Getting the field
|
81 |
*
|
82 |
+
* @param string $field_name
|
83 |
* @return Smart_Custom_Fields_Field_Base|null
|
84 |
*/
|
85 |
public function get_field( $field_name ) {
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
+
* Whether repeating group
|
94 |
*
|
95 |
* @return bool
|
96 |
*/
|
99 |
}
|
100 |
|
101 |
/**
|
102 |
+
* Displaying "hide" if $key isn't empty
|
103 |
*
|
104 |
* @param string $key
|
105 |
*/
|
110 |
}
|
111 |
|
112 |
/**
|
113 |
+
* Displaying the option fields in custom field settings page ( Common )
|
114 |
*
|
115 |
* @param int $group_key
|
116 |
*/
|
classes/models/class.meta.php
CHANGED
@@ -11,30 +11,30 @@
|
|
11 |
class Smart_Custom_Fields_Meta {
|
12 |
|
13 |
/**
|
14 |
-
* @var WP_Post|WP_User|
|
15 |
*/
|
16 |
protected $object;
|
17 |
|
18 |
/**
|
19 |
-
*
|
20 |
* @var string post or user or term
|
21 |
*/
|
22 |
protected $meta_type = 'post';
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
* @var int
|
27 |
*/
|
28 |
protected $id;
|
29 |
|
30 |
/**
|
31 |
-
*
|
32 |
* @var string
|
33 |
*/
|
34 |
protected $type;
|
35 |
|
36 |
/**
|
37 |
-
* @param WP_Post|WP_User|
|
38 |
*/
|
39 |
public function __construct( $object ) {
|
40 |
if ( !function_exists( 'get_editable_roles' ) ) {
|
@@ -67,7 +67,7 @@ class Smart_Custom_Fields_Meta {
|
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
-
*
|
71 |
*
|
72 |
* @return string post or user or term
|
73 |
*/
|
@@ -76,7 +76,7 @@ class Smart_Custom_Fields_Meta {
|
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
-
*
|
80 |
*
|
81 |
* @return int
|
82 |
*/
|
@@ -85,9 +85,9 @@ class Smart_Custom_Fields_Meta {
|
|
85 |
}
|
86 |
|
87 |
/**
|
88 |
-
*
|
89 |
*
|
90 |
-
* @param bool $accept_revision
|
91 |
* @return string
|
92 |
*/
|
93 |
public function get_type( $accept_revision = true ) {
|
@@ -98,7 +98,8 @@ class Smart_Custom_Fields_Meta {
|
|
98 |
}
|
99 |
|
100 |
/**
|
101 |
-
*
|
|
|
102 |
*
|
103 |
* @param int $post_id
|
104 |
* @return string
|
@@ -116,11 +117,11 @@ class Smart_Custom_Fields_Meta {
|
|
116 |
}
|
117 |
|
118 |
/**
|
119 |
-
*
|
120 |
-
*
|
121 |
-
*
|
122 |
-
*
|
123 |
-
*
|
124 |
*
|
125 |
* @return bool
|
126 |
*/
|
@@ -135,10 +136,10 @@ class Smart_Custom_Fields_Meta {
|
|
135 |
}
|
136 |
|
137 |
/**
|
138 |
-
*
|
139 |
*
|
140 |
-
* @param string $key
|
141 |
-
* @param bool $single false
|
142 |
* @return string|array
|
143 |
*/
|
144 |
public function get( $key = '', $single = false ) {
|
@@ -204,7 +205,7 @@ class Smart_Custom_Fields_Meta {
|
|
204 |
return $option;
|
205 |
}
|
206 |
|
207 |
-
// get_metadata
|
208 |
if ( $single ) {
|
209 |
return '';
|
210 |
}
|
@@ -213,11 +214,11 @@ class Smart_Custom_Fields_Meta {
|
|
213 |
}
|
214 |
|
215 |
/**
|
216 |
-
*
|
217 |
*
|
218 |
-
* @param string $key
|
219 |
-
* @param mixed $value
|
220 |
-
* @param mixed $prev_value
|
221 |
* @return int|false Meta ID
|
222 |
*/
|
223 |
public function update( $key, $value, $prev_value = '' ) {
|
@@ -255,11 +256,11 @@ class Smart_Custom_Fields_Meta {
|
|
255 |
}
|
256 |
|
257 |
/**
|
258 |
-
*
|
259 |
*
|
260 |
-
* @param string $key
|
261 |
-
* @param mixed $value
|
262 |
-
* @param bool $unique
|
263 |
* @return int|false Meta ID
|
264 |
*/
|
265 |
public function add( $key, $value, $unique = false ) {
|
@@ -284,10 +285,10 @@ class Smart_Custom_Fields_Meta {
|
|
284 |
}
|
285 |
|
286 |
/**
|
287 |
-
*
|
288 |
*
|
289 |
-
* @param string $key
|
290 |
-
* @param mixed $value
|
291 |
* @return bool
|
292 |
*/
|
293 |
public function delete( $key = '', $value = '' ) {
|
@@ -328,16 +329,15 @@ class Smart_Custom_Fields_Meta {
|
|
328 |
}
|
329 |
|
330 |
/**
|
331 |
-
*
|
332 |
*
|
333 |
-
* @param array $POST
|
334 |
*/
|
335 |
public function save( array $POST ) {
|
336 |
-
//
|
337 |
-
// 判別できなくなるのでわかるように保存しておく
|
338 |
$repeat_multiple_data = array();
|
339 |
|
340 |
-
//
|
341 |
$multiple_data_fields = array();
|
342 |
|
343 |
switch ( $this->meta_type ) {
|
@@ -410,7 +410,7 @@ class Smart_Custom_Fields_Meta {
|
|
410 |
}
|
411 |
|
412 |
/**
|
413 |
-
*
|
414 |
*
|
415 |
* @param WP_Post $revision
|
416 |
*/
|
@@ -438,16 +438,16 @@ class Smart_Custom_Fields_Meta {
|
|
438 |
foreach ( $value as $val ) {
|
439 |
if ( is_array( $val ) ) {
|
440 |
foreach ( $val as $v ) {
|
441 |
-
//
|
442 |
$this->add( $field_name, $v );
|
443 |
}
|
444 |
} else {
|
445 |
-
//
|
446 |
$this->add( $field_name, $val );
|
447 |
}
|
448 |
}
|
449 |
} else {
|
450 |
-
//
|
451 |
$this->add( $field_name, $value );
|
452 |
}
|
453 |
}
|
@@ -460,7 +460,7 @@ class Smart_Custom_Fields_Meta {
|
|
460 |
}
|
461 |
|
462 |
/**
|
463 |
-
* options
|
464 |
*/
|
465 |
protected function get_option_name() {
|
466 |
return sprintf(
|
11 |
class Smart_Custom_Fields_Meta {
|
12 |
|
13 |
/**
|
14 |
+
* @var WP_Post|WP_User|WP_Term
|
15 |
*/
|
16 |
protected $object;
|
17 |
|
18 |
/**
|
19 |
+
* What meta data
|
20 |
* @var string post or user or term
|
21 |
*/
|
22 |
protected $meta_type = 'post';
|
23 |
|
24 |
/**
|
25 |
+
* Post ID or User ID or Term ID
|
26 |
* @var int
|
27 |
*/
|
28 |
protected $id;
|
29 |
|
30 |
/**
|
31 |
+
* Post Type or Role or Taxonomy
|
32 |
* @var string
|
33 |
*/
|
34 |
protected $type;
|
35 |
|
36 |
/**
|
37 |
+
* @param WP_Post|WP_User|WP_Term $object
|
38 |
*/
|
39 |
public function __construct( $object ) {
|
40 |
if ( !function_exists( 'get_editable_roles' ) ) {
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
+
* Getting the meta type
|
71 |
*
|
72 |
* @return string post or user or term
|
73 |
*/
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
+
* Getting object ID
|
80 |
*
|
81 |
* @return int
|
82 |
*/
|
85 |
}
|
86 |
|
87 |
/**
|
88 |
+
* Getting type ( Post type or Role or Taxonomy )
|
89 |
*
|
90 |
+
* @param bool $accept_revision If post type, whether allow revision post type
|
91 |
* @return string
|
92 |
*/
|
93 |
public function get_type( $accept_revision = true ) {
|
98 |
}
|
99 |
|
100 |
/**
|
101 |
+
* Getting post type
|
102 |
+
* To feel good also Post ID of the revision
|
103 |
*
|
104 |
* @param int $post_id
|
105 |
* @return string
|
117 |
}
|
118 |
|
119 |
/**
|
120 |
+
* Object with this meta data is whether saved
|
121 |
+
* Post ... If auto-draft, not saved (new posts in)
|
122 |
+
* Profile or Taxonomy ... Since not display only after saving.
|
123 |
+
* So if all of meta data is empty,
|
124 |
+
* It is determined that not saved
|
125 |
*
|
126 |
* @return bool
|
127 |
*/
|
136 |
}
|
137 |
|
138 |
/**
|
139 |
+
* Getting the meta data
|
140 |
*
|
141 |
+
* @param string $key
|
142 |
+
* @param bool $single false ... return array, true ... return string
|
143 |
* @return string|array
|
144 |
*/
|
145 |
public function get( $key = '', $single = false ) {
|
205 |
return $option;
|
206 |
}
|
207 |
|
208 |
+
// get_metadata() return entry string, so this method also same behavior
|
209 |
if ( $single ) {
|
210 |
return '';
|
211 |
}
|
214 |
}
|
215 |
|
216 |
/**
|
217 |
+
* Updating meta data. If the meta data not exist, adding it.
|
218 |
*
|
219 |
+
* @param string $key
|
220 |
+
* @param mixed $value
|
221 |
+
* @param mixed $prev_value If specified, it overwrites the only ones of this value
|
222 |
* @return int|false Meta ID
|
223 |
*/
|
224 |
public function update( $key, $value, $prev_value = '' ) {
|
256 |
}
|
257 |
|
258 |
/**
|
259 |
+
* Adding the meta data
|
260 |
*
|
261 |
+
* @param string $key
|
262 |
+
* @param mixed $value
|
263 |
+
* @param bool $unique Whether the key to the unique
|
264 |
* @return int|false Meta ID
|
265 |
*/
|
266 |
public function add( $key, $value, $unique = false ) {
|
285 |
}
|
286 |
|
287 |
/**
|
288 |
+
* Deleting the meta data
|
289 |
*
|
290 |
+
* @param string $key
|
291 |
+
* @param mixed $value If specified, it deletes the only ones of this value
|
292 |
* @return bool
|
293 |
*/
|
294 |
public function delete( $key = '', $value = '' ) {
|
329 |
}
|
330 |
|
331 |
/**
|
332 |
+
* Saving the meta data based on the posted data
|
333 |
*
|
334 |
+
* @param array $POST
|
335 |
*/
|
336 |
public function save( array $POST ) {
|
337 |
+
// For repeated multi-value items identification
|
|
|
338 |
$repeat_multiple_data = array();
|
339 |
|
340 |
+
// Retruning empty value when multi-value is empty, it doesn't save
|
341 |
$multiple_data_fields = array();
|
342 |
|
343 |
switch ( $this->meta_type ) {
|
410 |
}
|
411 |
|
412 |
/**
|
413 |
+
* Restore the data from the revision
|
414 |
*
|
415 |
* @param WP_Post $revision
|
416 |
*/
|
438 |
foreach ( $value as $val ) {
|
439 |
if ( is_array( $val ) ) {
|
440 |
foreach ( $val as $v ) {
|
441 |
+
// Repeated multi-value items
|
442 |
$this->add( $field_name, $v );
|
443 |
}
|
444 |
} else {
|
445 |
+
// Repeated single-value items or Non repeated multi-value items
|
446 |
$this->add( $field_name, $val );
|
447 |
}
|
448 |
}
|
449 |
} else {
|
450 |
+
// Non repeated single-value item
|
451 |
$this->add( $field_name, $value );
|
452 |
}
|
453 |
}
|
460 |
}
|
461 |
|
462 |
/**
|
463 |
+
* Getting option name for saved options table
|
464 |
*/
|
465 |
protected function get_option_name() {
|
466 |
return sprintf(
|
classes/models/class.setting.php
CHANGED
@@ -11,19 +11,19 @@
|
|
11 |
class Smart_Custom_Fields_Setting {
|
12 |
|
13 |
/**
|
14 |
-
*
|
15 |
* @var string
|
16 |
*/
|
17 |
protected $id;
|
18 |
|
19 |
/**
|
20 |
-
*
|
21 |
* @var title
|
22 |
*/
|
23 |
protected $title;
|
24 |
|
25 |
/**
|
26 |
-
*
|
27 |
* @var array
|
28 |
*/
|
29 |
protected $groups = array();
|
@@ -58,7 +58,7 @@ class Smart_Custom_Fields_Setting {
|
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
-
*
|
62 |
*
|
63 |
* @return string
|
64 |
*/
|
@@ -67,7 +67,7 @@ class Smart_Custom_Fields_Setting {
|
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
-
*
|
71 |
*
|
72 |
* @return string
|
73 |
*/
|
@@ -76,7 +76,7 @@ class Smart_Custom_Fields_Setting {
|
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
-
*
|
80 |
*
|
81 |
* @return array
|
82 |
*/
|
@@ -85,7 +85,7 @@ class Smart_Custom_Fields_Setting {
|
|
85 |
}
|
86 |
|
87 |
/**
|
88 |
-
*
|
89 |
*
|
90 |
* @return array
|
91 |
*/
|
@@ -99,11 +99,12 @@ class Smart_Custom_Fields_Setting {
|
|
99 |
}
|
100 |
|
101 |
/**
|
102 |
-
*
|
|
|
103 |
*
|
104 |
-
* @param string
|
105 |
-
* @param bool
|
106 |
-
* @param array $_fields
|
107 |
*/
|
108 |
public function add_group( $group_name = null, $repeat = false, array $fields = array() ) {
|
109 |
$Group = $this->new_group( $group_name, $repeat, $fields );
|
@@ -116,9 +117,9 @@ class Smart_Custom_Fields_Setting {
|
|
116 |
}
|
117 |
|
118 |
/**
|
119 |
-
*
|
120 |
*
|
121 |
-
* @param string $group_name
|
122 |
* @return Smart_Custom_Fields_Group|false
|
123 |
*/
|
124 |
public function get_group( $group_name ) {
|
@@ -129,11 +130,12 @@ class Smart_Custom_Fields_Setting {
|
|
129 |
}
|
130 |
|
131 |
/**
|
132 |
-
*
|
|
|
133 |
*
|
134 |
-
* @param string
|
135 |
-
* @param bool
|
136 |
-
* @param array $_fields
|
137 |
*/
|
138 |
public function add_group_unshift( $group_name = null, $repeat = false, array $fields = array() ) {
|
139 |
$Group = $this->new_group( $group_name, $repeat, $fields );
|
@@ -141,11 +143,11 @@ class Smart_Custom_Fields_Setting {
|
|
141 |
}
|
142 |
|
143 |
/**
|
144 |
-
*
|
145 |
*
|
146 |
-
* @param string
|
147 |
-
* @param bool
|
148 |
-
* @param array $_fields
|
149 |
*/
|
150 |
protected function new_group( $group_name, $repeat, $fields ) {
|
151 |
return new Smart_Custom_Fields_Group( $group_name, $repeat, $fields );
|
11 |
class Smart_Custom_Fields_Setting {
|
12 |
|
13 |
/**
|
14 |
+
* Post ID of custom field settings page
|
15 |
* @var string
|
16 |
*/
|
17 |
protected $id;
|
18 |
|
19 |
/**
|
20 |
+
* Title of custom field settings page
|
21 |
* @var title
|
22 |
*/
|
23 |
protected $title;
|
24 |
|
25 |
/**
|
26 |
+
* Array of the saved group objects
|
27 |
* @var array
|
28 |
*/
|
29 |
protected $groups = array();
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
+
* Getting the post ID
|
62 |
*
|
63 |
* @return string
|
64 |
*/
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
+
* Getting the post title
|
71 |
*
|
72 |
* @return string
|
73 |
*/
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
+
* Getting the group objects
|
80 |
*
|
81 |
* @return array
|
82 |
*/
|
85 |
}
|
86 |
|
87 |
/**
|
88 |
+
* Getting together the fields in each group
|
89 |
*
|
90 |
* @return array
|
91 |
*/
|
99 |
}
|
100 |
|
101 |
/**
|
102 |
+
* Adding group to the tail
|
103 |
+
* If the argument is not, adding an empty group
|
104 |
*
|
105 |
+
* @param string $group_name
|
106 |
+
* @param bool $repeat
|
107 |
+
* @param array $_fields
|
108 |
*/
|
109 |
public function add_group( $group_name = null, $repeat = false, array $fields = array() ) {
|
110 |
$Group = $this->new_group( $group_name, $repeat, $fields );
|
117 |
}
|
118 |
|
119 |
/**
|
120 |
+
* Getting group
|
121 |
*
|
122 |
+
* @param string $group_name
|
123 |
* @return Smart_Custom_Fields_Group|false
|
124 |
*/
|
125 |
public function get_group( $group_name ) {
|
130 |
}
|
131 |
|
132 |
/**
|
133 |
+
* Adding group to the head
|
134 |
+
* If the argument is not, adding an empty group
|
135 |
*
|
136 |
+
* @param string $group_name
|
137 |
+
* @param bool $repeat
|
138 |
+
* @param array $_fields
|
139 |
*/
|
140 |
public function add_group_unshift( $group_name = null, $repeat = false, array $fields = array() ) {
|
141 |
$Group = $this->new_group( $group_name, $repeat, $fields );
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
+
* Getting generated new group
|
147 |
*
|
148 |
+
* @param string $group_name
|
149 |
+
* @param bool $repeat
|
150 |
+
* @param array $_fields
|
151 |
*/
|
152 |
protected function new_group( $group_name, $repeat, $fields ) {
|
153 |
return new Smart_Custom_Fields_Group( $group_name, $repeat, $fields );
|
js/editor.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
/**
|
2 |
* editor.js
|
3 |
-
* Version : 1.3.
|
4 |
* Author : inc2734
|
5 |
* Created : September 23, 2014
|
6 |
-
* Modified :
|
7 |
* License : GPLv2 or later
|
8 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
*/
|
@@ -28,9 +28,11 @@ jQuery( function( $ ) {
|
|
28 |
|
29 |
var init;
|
30 |
if ( typeof tinyMCEPreInit.mceInit.content !== 'undefined' ) {
|
|
|
31 |
init = $.extend( true, {}, tinyMCEPreInit.mceInit.content );
|
32 |
init.selector = '#' + editor_id;
|
33 |
} else {
|
|
|
34 |
init = {
|
35 |
content_css: ['../wp-includes/js/tinymce/skins/wordpress/wp-content.css', '../wp-content/plugins/smart-custom-fields/css/wysiwyg.css'],
|
36 |
menubar: false,
|
@@ -46,7 +48,8 @@ jQuery( function( $ ) {
|
|
46 |
};
|
47 |
}
|
48 |
tinyMCEPreInit.mceInit[editor_id] = init;
|
49 |
-
tinymce.
|
|
|
50 |
}
|
51 |
} );
|
52 |
|
1 |
/**
|
2 |
* editor.js
|
3 |
+
* Version : 1.3.2
|
4 |
* Author : inc2734
|
5 |
* Created : September 23, 2014
|
6 |
+
* Modified : December 2, 2015
|
7 |
* License : GPLv2 or later
|
8 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
*/
|
28 |
|
29 |
var init;
|
30 |
if ( typeof tinyMCEPreInit.mceInit.content !== 'undefined' ) {
|
31 |
+
console.log( 1 );
|
32 |
init = $.extend( true, {}, tinyMCEPreInit.mceInit.content );
|
33 |
init.selector = '#' + editor_id;
|
34 |
} else {
|
35 |
+
console.log( 2 );
|
36 |
init = {
|
37 |
content_css: ['../wp-includes/js/tinymce/skins/wordpress/wp-content.css', '../wp-content/plugins/smart-custom-fields/css/wysiwyg.css'],
|
38 |
menubar: false,
|
48 |
};
|
49 |
}
|
50 |
tinyMCEPreInit.mceInit[editor_id] = init;
|
51 |
+
tinymce.init( init );
|
52 |
+
//tinymce.execCommand( 'mceAddEditor', false, editor_id );
|
53 |
}
|
54 |
} );
|
55 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.amazon.co.jp/registry/wishlist/39ANKRNSTNW40
|
|
4 |
Tags: plugin, custom field, custom, field, meta, meta field, repeat, repeatable
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 4.4-beta3
|
7 |
-
Stable tag: 1.6.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -86,6 +86,10 @@ You can send your own language pack to me.
|
|
86 |
|
87 |
== Changelog ==
|
88 |
|
|
|
|
|
|
|
|
|
89 |
= 1.6.3 =
|
90 |
* Fixed a bug that metadata that isn't defined by Smart Custom Fields can't get in preview.
|
91 |
|
4 |
Tags: plugin, custom field, custom, field, meta, meta field, repeat, repeatable
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 4.4-beta3
|
7 |
+
Stable tag: 1.6.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
86 |
|
87 |
== Changelog ==
|
88 |
|
89 |
+
= 1.6.4 =
|
90 |
+
* Fixed a bug that wysiwyg fields became tinymce default format when content editor mode is text.
|
91 |
+
* Change the comment in English.
|
92 |
+
|
93 |
= 1.6.3 =
|
94 |
* Fixed a bug that metadata that isn't defined by Smart Custom Fields can't get in preview.
|
95 |
|
smart-custom-fields.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin name: Smart Custom Fields
|
4 |
* Plugin URI: https://github.com/inc2734/smart-custom-fields/
|
5 |
* Description: Smart Custom Fields is a simple plugin that management custom fields.
|
6 |
-
* Version: 1.6.
|
7 |
* Author: inc2734
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created: October 9, 2014
|
@@ -25,7 +25,7 @@ class Smart_Custom_Fields {
|
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
-
*
|
29 |
*/
|
30 |
public function plugins_loaded() {
|
31 |
load_plugin_textdomain (
|
@@ -38,7 +38,7 @@ class Smart_Custom_Fields {
|
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
-
*
|
42 |
*/
|
43 |
public function after_setup_theme() {
|
44 |
do_action( SCF_Config::PREFIX . 'load' );
|
@@ -68,7 +68,7 @@ class Smart_Custom_Fields {
|
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
-
*
|
72 |
*/
|
73 |
public static function uninstall() {
|
74 |
$cf_posts = get_posts( array(
|
@@ -95,7 +95,7 @@ class Smart_Custom_Fields {
|
|
95 |
}
|
96 |
|
97 |
/**
|
98 |
-
*
|
99 |
*
|
100 |
* @param WP_Screen $screen
|
101 |
*/
|
@@ -150,7 +150,8 @@ class Smart_Custom_Fields {
|
|
150 |
}
|
151 |
|
152 |
/**
|
153 |
-
*
|
|
|
154 |
*/
|
155 |
public function register_post_type() {
|
156 |
$labels = array(
|
@@ -183,14 +184,14 @@ class Smart_Custom_Fields {
|
|
183 |
}
|
184 |
|
185 |
/**
|
186 |
-
*
|
187 |
*/
|
188 |
public function ajax_request() {
|
189 |
$Ajax = new Smart_Custom_Fields_Ajax();
|
190 |
}
|
191 |
|
192 |
/**
|
193 |
-
*
|
194 |
*/
|
195 |
public function admin_menu() {
|
196 |
add_menu_page(
|
@@ -212,7 +213,7 @@ class Smart_Custom_Fields {
|
|
212 |
}
|
213 |
|
214 |
/**
|
215 |
-
*
|
216 |
*
|
217 |
* @return int
|
218 |
*/
|
@@ -227,7 +228,7 @@ class Smart_Custom_Fields {
|
|
227 |
}
|
228 |
|
229 |
/**
|
230 |
-
*
|
231 |
*
|
232 |
* @return int
|
233 |
*/
|
@@ -246,7 +247,7 @@ class Smart_Custom_Fields {
|
|
246 |
}
|
247 |
|
248 |
/**
|
249 |
-
*
|
250 |
*
|
251 |
* @return int
|
252 |
*/
|
3 |
* Plugin name: Smart Custom Fields
|
4 |
* Plugin URI: https://github.com/inc2734/smart-custom-fields/
|
5 |
* Description: Smart Custom Fields is a simple plugin that management custom fields.
|
6 |
+
* Version: 1.6.4
|
7 |
* Author: inc2734
|
8 |
* Author URI: http://2inc.org
|
9 |
* Created: October 9, 2014
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
+
* Loading translation files
|
29 |
*/
|
30 |
public function plugins_loaded() {
|
31 |
load_plugin_textdomain (
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* Loading classes
|
42 |
*/
|
43 |
public function after_setup_theme() {
|
44 |
do_action( SCF_Config::PREFIX . 'load' );
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
+
* Uninstall proccesses
|
72 |
*/
|
73 |
public static function uninstall() {
|
74 |
$cf_posts = get_posts( array(
|
95 |
}
|
96 |
|
97 |
/**
|
98 |
+
* Run management screens
|
99 |
*
|
100 |
* @param WP_Screen $screen
|
101 |
*/
|
150 |
}
|
151 |
|
152 |
/**
|
153 |
+
* Registering custom post type.
|
154 |
+
* Run the menu display in a different method.
|
155 |
*/
|
156 |
public function register_post_type() {
|
157 |
$labels = array(
|
184 |
}
|
185 |
|
186 |
/**
|
187 |
+
* Hooking the process that it want to fire when the ajax request.
|
188 |
*/
|
189 |
public function ajax_request() {
|
190 |
$Ajax = new Smart_Custom_Fields_Ajax();
|
191 |
}
|
192 |
|
193 |
/**
|
194 |
+
* Adding menus in management screen.
|
195 |
*/
|
196 |
public function admin_menu() {
|
197 |
add_menu_page(
|
213 |
}
|
214 |
|
215 |
/**
|
216 |
+
* Getting the post ID in post editing page.
|
217 |
*
|
218 |
* @return int
|
219 |
*/
|
228 |
}
|
229 |
|
230 |
/**
|
231 |
+
* Getting the user ID in profile and user editing pages.
|
232 |
*
|
233 |
* @return int
|
234 |
*/
|
247 |
}
|
248 |
|
249 |
/**
|
250 |
+
* Getting the term ID in term editing page.
|
251 |
*
|
252 |
* @return int
|
253 |
*/
|