Meta Box - Version 4.3.7

Version Description

  • Bug fix: use WP_Query instead of query_posts to be compatible with WPML
  • Bug fix: get_called_class function in PHP < 5.3
  • Bug fix: clone now works for slider field
  • Bug fix: fix cloning URL field
  • Bug fix: hidden drop area if no max_file_uploads defined
  • Improvement: added composer.json
  • Improvement: add Chinese language
  • Improvement: better check for duplication when save post
  • Improvement: new image_select file, which is "radio image", e.g. select a radio value by selecting image
  • Improvement: new file_input field, which allows to upload files or enter file URL
  • Improvement: separate core code for meta box and fields
  • Improvement: allow to add more map options in helper function
  • Improvement: allow to pass more arguments to "get_terms" function when getting meta value with "rwmb_meta"
Download this release

Release Info

Developer rilwis
Plugin Icon 128x128 Meta Box
Version 4.3.7
Comparing to
See all releases

Code changes from version 4.3.6 to 4.3.7

Files changed (53) hide show
  1. css/image-select.css +21 -0
  2. css/oembed.css +3 -0
  3. css/style.css +6 -11
  4. inc/common.php +18 -2
  5. inc/field.php +303 -0
  6. inc/fields/button.php +2 -3
  7. inc/fields/checkbox-list.php +6 -10
  8. inc/fields/checkbox.php +2 -3
  9. inc/fields/color.php +2 -3
  10. inc/fields/date.php +2 -3
  11. inc/fields/datetime.php +2 -3
  12. inc/fields/divider.php +3 -5
  13. inc/fields/email.php +1 -3
  14. inc/fields/fieldset-text.php +63 -69
  15. inc/fields/file-advanced.php +1 -3
  16. inc/fields/file-input.php +62 -0
  17. inc/fields/file.php +5 -11
  18. inc/fields/heading.php +3 -5
  19. inc/fields/hidden.php +2 -3
  20. inc/fields/image-advanced.php +2 -3
  21. inc/fields/image-select.php +62 -0
  22. inc/fields/image.php +3 -5
  23. inc/fields/map.php +2 -3
  24. inc/fields/number.php +2 -3
  25. inc/fields/oembed.php +1 -2
  26. inc/fields/password.php +1 -2
  27. inc/fields/plupload-image.php +2 -3
  28. inc/fields/post.php +15 -14
  29. inc/fields/radio.php +2 -3
  30. inc/fields/range.php +2 -3
  31. inc/fields/select-advanced.php +1 -2
  32. inc/fields/select.php +4 -6
  33. inc/fields/slider.php +3 -4
  34. inc/fields/taxonomy-advanced.php +1 -2
  35. inc/fields/taxonomy.php +9 -11
  36. inc/fields/text-list.php +8 -13
  37. inc/fields/text.php +2 -3
  38. inc/fields/textarea.php +2 -3
  39. inc/fields/thickbox-image.php +1 -2
  40. inc/fields/time.php +2 -3
  41. inc/fields/url.php +2 -3
  42. inc/fields/wysiwyg.php +2 -3
  43. inc/helpers.php +34 -13
  44. inc/meta-box.php +26 -308
  45. js/file-input.js +40 -0
  46. js/image-select.js +21 -0
  47. js/map.js +2 -0
  48. js/plupload-image.js +1 -1
  49. js/slider.js +12 -7
  50. lang/zh_CN.mo +0 -0
  51. lang/zh_CN.po +384 -0
  52. meta-box.php +3 -2
  53. readme.txt +19 -4
css/image-select.css ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .rwmb-image-select {
2
+ display: inline-block;
3
+ width: 80px;
4
+ height: 80px;
5
+ float: left;
6
+ margin: 0 10px 10px 0;
7
+ border: 3px solid #d8d8d8;
8
+ border-radius: 3px;
9
+ padding: 1px;
10
+ }
11
+ .rwmb-image-select img {
12
+ width: 100%;
13
+ height: 100%;
14
+ }
15
+ .rwmb-image-select:hover,
16
+ .rwmb-image-select.rwmb-active {
17
+ border-color: #0074a2;
18
+ }
19
+ .rwmb-image-select input {
20
+ display: none;
21
+ }
css/oembed.css CHANGED
@@ -5,4 +5,7 @@
5
  }
6
  .rwmb-oembed-wrapper .embed-code {
7
  margin-top: 1em;
 
 
 
8
  }
5
  }
6
  .rwmb-oembed-wrapper .embed-code {
7
  margin-top: 1em;
8
+ }
9
+ .rwmb-oembed-wrapper .embed-code iframe {
10
+ max-width: 100%;
11
  }
css/style.css CHANGED
@@ -34,25 +34,20 @@
34
  /* Clone */
35
  .rwmb-clone {
36
  min-height: 24px;
 
 
37
  }
38
  .rwmb-clone > input[type="radio"],
39
  .rwmb-clone > input[type="checkbox"] {
40
  margin: 6px 0 0 4px;
41
  }
42
  .rwmb-button {
43
- display: inline;
44
  float: right;
45
  }
46
-
47
- /* Fix width to not overlap button for cloned sliders */
48
- .rwmb-clone .rwmb-slider {
49
- width: 80%;
50
- margin: 6px 0 0;
51
- }
52
-
53
- /* Fix buttons after sliders */
54
- .clearfix + .rwmb-button {
55
- margin-top: -16px;
56
  }
57
 
58
  /* Fix empty block below admin footer (issue #24) */
34
  /* Clone */
35
  .rwmb-clone {
36
  min-height: 24px;
37
+ margin-bottom: 5px;
38
+ position: relative;
39
  }
40
  .rwmb-clone > input[type="radio"],
41
  .rwmb-clone > input[type="checkbox"] {
42
  margin: 6px 0 0 4px;
43
  }
44
  .rwmb-button {
 
45
  float: right;
46
  }
47
+ .rwmb-button.remove-clone {
48
+ position: absolute;
49
+ top: 0;
50
+ right: 0;
 
 
 
 
 
 
51
  }
52
 
53
  /* Fix empty block below admin footer (issue #24) */
inc/common.php CHANGED
@@ -2,7 +2,7 @@
2
  // Prevent loading this file directly
3
  defined( 'ABSPATH' ) || exit;
4
 
5
- if ( ! class_exists( 'RWMB_Common' ) )
6
  {
7
  /**
8
  * Common functions for the plugin
@@ -29,7 +29,7 @@ if ( ! class_exists( 'RWMB_Common' ) )
29
  {
30
  // l18n translation files
31
  $locale = get_locale();
32
- $dir = trailingslashit( RWMB_DIR . 'lang' );
33
  $mofile = "{$dir}{$locale}.mo";
34
 
35
  // In themes/plugins/mu-plugins directory
@@ -38,4 +38,20 @@ if ( ! class_exists( 'RWMB_Common' ) )
38
  }
39
 
40
  RWMB_Common::on_load();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  }
2
  // Prevent loading this file directly
3
  defined( 'ABSPATH' ) || exit;
4
 
5
+ if ( !class_exists( 'RWMB_Common' ) )
6
  {
7
  /**
8
  * Common functions for the plugin
29
  {
30
  // l18n translation files
31
  $locale = get_locale();
32
+ $dir = trailingslashit( RWMB_DIR . 'lang' );
33
  $mofile = "{$dir}{$locale}.mo";
34
 
35
  // In themes/plugins/mu-plugins directory
38
  }
39
 
40
  RWMB_Common::on_load();
41
+ }
42
+
43
+ if ( !function_exists( 'get_called_class' ) )
44
+ {
45
+ /**
46
+ * Get called class, used for PHP version < 5.3 only
47
+ * @return bool|string
48
+ */
49
+ function get_called_class()
50
+ {
51
+ $t = debug_backtrace();
52
+ $t = $t[0];
53
+ if ( isset( $t['object'] ) && $t['object'] instanceof $t['class'] )
54
+ return get_class( $t['object'] );
55
+ return false;
56
+ }
57
  }
inc/field.php ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists( 'RWMB_Field ' ) )
3
+ {
4
+ class RWMB_Field
5
+ {
6
+ /**
7
+ * Add actions
8
+ *
9
+ * @return void
10
+ */
11
+ static function add_actions() {}
12
+
13
+ /**
14
+ * Enqueue scripts and styles
15
+ *
16
+ * @return void
17
+ */
18
+ static function admin_enqueue_scripts() {}
19
+
20
+ /**
21
+ * Show field HTML
22
+ *
23
+ * @param array $field
24
+ * @param bool $saved
25
+ *
26
+ * @return string
27
+ */
28
+ static function show( $field, $saved )
29
+ {
30
+ global $post;
31
+
32
+ $meta = call_user_func( array( get_called_class(), 'meta' ), $post->ID, $saved, $field );
33
+
34
+ $group = ''; // Empty the clone-group field
35
+ $type = $field['type'];
36
+ $id = $field['id'];
37
+
38
+ $begin = call_user_func( array( get_called_class(), 'begin_html' ), $meta, $field );
39
+
40
+ // Apply filter to field begin HTML
41
+ // 1st filter applies to all fields
42
+ // 2nd filter applies to all fields with the same type
43
+ // 3rd filter applies to current field only
44
+ $begin = apply_filters( 'rwmb_begin_html', $begin, $field, $meta );
45
+ $begin = apply_filters( "rwmb_{$type}_begin_html", $begin, $field, $meta );
46
+ $begin = apply_filters( "rwmb_{$id}_begin_html", $begin, $field, $meta );
47
+
48
+ // Separate code for cloneable and non-cloneable fields to make easy to maintain
49
+
50
+ // Cloneable fields
51
+ if ( $field['clone'] )
52
+ {
53
+ if ( isset( $field['clone-group'] ) )
54
+ $group = " clone-group='{$field['clone-group']}'";
55
+
56
+ $meta = (array) $meta;
57
+
58
+ $field_html = '';
59
+
60
+ foreach ( $meta as $index => $sub_meta )
61
+ {
62
+ $sub_field = $field;
63
+ $sub_field['field_name'] = $field['field_name'] . "[{$index}]";
64
+ if ( $field['multiple'] )
65
+ $sub_field['field_name'] .= '[]';
66
+
67
+ // Wrap field HTML in a div with class="rwmb-clone" if needed
68
+ $input_html = '<div class="rwmb-clone">';
69
+
70
+ // Call separated methods for displaying each type of field
71
+ $input_html .= call_user_func( array( get_called_class(), 'html' ), $sub_meta, $sub_field );
72
+
73
+ // Apply filter to field HTML
74
+ // 1st filter applies to all fields with the same type
75
+ // 2nd filter applies to current field only
76
+ $input_html = apply_filters( "rwmb_{$type}_html", $input_html, $field, $sub_meta );
77
+ $input_html = apply_filters( "rwmb_{$id}_html", $input_html, $field, $sub_meta );
78
+
79
+ // Add clone button
80
+ $input_html .= self::clone_button();
81
+
82
+ $input_html .= '</div>';
83
+
84
+ $field_html .= $input_html;
85
+ }
86
+ }
87
+ // Non-cloneable fields
88
+ else
89
+ {
90
+ // Call separated methods for displaying each type of field
91
+ $field_html = call_user_func( array( get_called_class(), 'html' ), $meta, $field );
92
+
93
+ // Apply filter to field HTML
94
+ // 1st filter applies to all fields with the same type
95
+ // 2nd filter applies to current field only
96
+ $field_html = apply_filters( "rwmb_{$type}_html", $field_html, $field, $meta );
97
+ $field_html = apply_filters( "rwmb_{$id}_html", $field_html, $field, $meta );
98
+ }
99
+
100
+ $end = call_user_func( array( get_called_class(), 'end_html' ), $meta, $field );
101
+
102
+ // Apply filter to field end HTML
103
+ // 1st filter applies to all fields
104
+ // 2nd filter applies to all fields with the same type
105
+ // 3rd filter applies to current field only
106
+ $end = apply_filters( 'rwmb_end_html', $end, $field, $meta );
107
+ $end = apply_filters( "rwmb_{$type}_end_html", $end, $field, $meta );
108
+ $end = apply_filters( "rwmb_{$id}_end_html", $end, $field, $meta );
109
+
110
+ // Apply filter to field wrapper
111
+ // This allow users to change whole HTML markup of the field wrapper (i.e. table row)
112
+ // 1st filter applies to all fields with the same type
113
+ // 2nd filter applies to current field only
114
+ $html = apply_filters( "rwmb_{$type}_wrapper_html", "{$begin}{$field_html}{$end}", $field, $meta );
115
+ $html = apply_filters( "rwmb_{$id}_wrapper_html", $html, $field, $meta );
116
+
117
+ // Display label and input in DIV and allow user-defined classes to be appended
118
+ $classes = array( 'rwmb-field', "rwmb-{$type}-wrapper" );
119
+ if ( 'hidden' === $field['type'] )
120
+ $classes[] = 'hidden';
121
+ if ( !empty( $field['required'] ) )
122
+ $classes[] = 'required';
123
+ if ( !empty( $field['class'] ) )
124
+ $classes[] = $field['class'];
125
+
126
+ printf(
127
+ $field['before'] . '<div class="%s"%s>%s</div>' . $field['after'],
128
+ implode( ' ', $classes ),
129
+ $group,
130
+ $html
131
+ );
132
+ }
133
+
134
+ /**
135
+ * Get field HTML
136
+ *
137
+ * @param mixed $meta
138
+ * @param array $field
139
+ *
140
+ * @return string
141
+ */
142
+ static function html( $meta, $field )
143
+ {
144
+ return '';
145
+ }
146
+
147
+ /**
148
+ * Show begin HTML markup for fields
149
+ *
150
+ * @param mixed $meta
151
+ * @param array $field
152
+ *
153
+ * @return string
154
+ */
155
+ static function begin_html( $meta, $field )
156
+ {
157
+ if ( empty( $field['name'] ) )
158
+ return '<div class="rwmb-input">';
159
+
160
+ return sprintf(
161
+ '<div class="rwmb-label">
162
+ <label for="%s">%s</label>
163
+ </div>
164
+ <div class="rwmb-input">',
165
+ $field['id'],
166
+ $field['name']
167
+ );
168
+ }
169
+
170
+ /**
171
+ * Show end HTML markup for fields
172
+ *
173
+ * @param mixed $meta
174
+ * @param array $field
175
+ *
176
+ * @return string
177
+ */
178
+ static function end_html( $meta, $field )
179
+ {
180
+ $id = $field['id'];
181
+
182
+ $button = '';
183
+ if ( $field['clone'] )
184
+ $button = '<a href="#" class="rwmb-button button-primary add-clone">' . __( '+', 'rwmb' ) . '</a>';
185
+
186
+ $desc = !empty( $field['desc'] ) ? "<p id='{$id}_description' class='description'>{$field['desc']}</p>" : '';
187
+
188
+ // Closes the container
189
+ $html = "{$button}{$desc}</div>";
190
+
191
+ return $html;
192
+ }
193
+
194
+ /**
195
+ * Add clone button
196
+ *
197
+ * @return string $html
198
+ */
199
+ static function clone_button()
200
+ {
201
+ return '<a href="#" class="rwmb-button button remove-clone">' . __( '&#8211;', 'rwmb' ) . '</a>';
202
+ }
203
+
204
+ /**
205
+ * Get meta value
206
+ *
207
+ * @param int $post_id
208
+ * @param bool $saved
209
+ * @param array $field
210
+ *
211
+ * @return mixed
212
+ */
213
+ static function meta( $post_id, $saved, $field )
214
+ {
215
+ $meta = get_post_meta( $post_id, $field['id'], !$field['multiple'] );
216
+
217
+ // Use $field['std'] only when the meta box hasn't been saved (i.e. the first time we run)
218
+ $meta = ( !$saved && '' === $meta || array() === $meta ) ? $field['std'] : $meta;
219
+
220
+ // Escape attributes for non-wysiwyg fields
221
+ if ( 'wysiwyg' !== $field['type'] )
222
+ $meta = is_array( $meta ) ? array_map( 'esc_attr', $meta ) : esc_attr( $meta );
223
+
224
+ $meta = apply_filters( "rwmb_{$field['type']}_meta", $meta );
225
+ $meta = apply_filters( "rwmb_{$field['id']}_meta", $meta );
226
+
227
+ return $meta;
228
+ }
229
+
230
+ /**
231
+ * Set value of meta before saving into database
232
+ *
233
+ * @param mixed $new
234
+ * @param mixed $old
235
+ * @param int $post_id
236
+ * @param array $field
237
+ *
238
+ * @return int
239
+ */
240
+ static function value( $new, $old, $post_id, $field )
241
+ {
242
+ return $new;
243
+ }
244
+
245
+ /**
246
+ * Save meta value
247
+ *
248
+ * @param $new
249
+ * @param $old
250
+ * @param $post_id
251
+ * @param $field
252
+ */
253
+ static function save( $new, $old, $post_id, $field )
254
+ {
255
+ $name = $field['id'];
256
+
257
+ if ( '' === $new || array() === $new )
258
+ {
259
+ delete_post_meta( $post_id, $name );
260
+ return;
261
+ }
262
+
263
+ if ( $field['multiple'] )
264
+ {
265
+ foreach ( $new as $new_value )
266
+ {
267
+ if ( !in_array( $new_value, $old ) )
268
+ add_post_meta( $post_id, $name, $new_value, false );
269
+ }
270
+ foreach ( $old as $old_value )
271
+ {
272
+ if ( !in_array( $old_value, $new ) )
273
+ delete_post_meta( $post_id, $name, $old_value );
274
+ }
275
+ }
276
+ else
277
+ {
278
+ if ( $field['clone'] )
279
+ {
280
+ $new = (array) $new;
281
+ foreach ( $new as $k => $v )
282
+ {
283
+ if ( '' === $v )
284
+ unset( $new[$k] );
285
+ }
286
+ }
287
+ update_post_meta( $post_id, $name, $new );
288
+ }
289
+ }
290
+
291
+ /**
292
+ * Normalize parameters for field
293
+ *
294
+ * @param array $field
295
+ *
296
+ * @return array
297
+ */
298
+ static function normalize_field( $field )
299
+ {
300
+ return $field;
301
+ }
302
+ }
303
+ }
inc/fields/button.php CHANGED
@@ -4,18 +4,17 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( ! class_exists( 'RWMB_Button_Field' ) )
6
  {
7
- class RWMB_Button_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
12
- * @param string $html
13
  * @param mixed $meta
14
  * @param array $field
15
  *
16
  * @return string
17
  */
18
- static function html( $html, $meta, $field )
19
  {
20
  return sprintf(
21
  '<a href="#" id="%s" class="button hide-if-no-js">%s</a>',
4
 
5
  if ( ! class_exists( 'RWMB_Button_Field' ) )
6
  {
7
+ class RWMB_Button_Field extends RWMB_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
 
12
  * @param mixed $meta
13
  * @param array $field
14
  *
15
  * @return string
16
  */
17
+ static function html( $meta, $field )
18
  {
19
  return sprintf(
20
  '<a href="#" id="%s" class="button hide-if-no-js">%s</a>',
inc/fields/checkbox-list.php CHANGED
@@ -4,22 +4,21 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( ! class_exists( 'RWMB_Checkbox_List_Field' ) )
6
  {
7
- class RWMB_Checkbox_List_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
12
- * @param string $html
13
  * @param mixed $meta
14
  * @param array $field
15
  *
16
  * @return string
17
  */
18
- static function html( $html, $meta, $field )
19
  {
20
  $meta = (array) $meta;
21
  $html = array();
22
- $tpl = '<label><input type="checkbox" class="rwmb-checkbox-list" name="%s" value="%s" %s /> %s</label>';
23
 
24
  foreach ( $field['options'] as $value => $label )
25
  {
@@ -31,7 +30,7 @@ if ( ! class_exists( 'RWMB_Checkbox_List_Field' ) )
31
  $label
32
  );
33
  }
34
- return implode( '<br />', $html );
35
  }
36
 
37
  /**
@@ -43,19 +42,16 @@ if ( ! class_exists( 'RWMB_Checkbox_List_Field' ) )
43
  *
44
  * TODO: A good way to ALWAYS save values in single entry in DB, while maintaining backward compatibility
45
  *
46
- * @param $meta
47
  * @param $post_id
48
  * @param $saved
49
  * @param $field
50
  *
51
  * @return array
52
  */
53
- static function meta( $meta, $post_id, $saved, $field )
54
  {
55
  $meta = get_post_meta( $post_id, $field['id'], $field['clone'] );
56
-
57
  $meta = ( !$saved && '' === $meta || array() === $meta ) ? $field['std'] : $meta;
58
-
59
  $meta = array_map( 'esc_attr', (array) $meta );
60
 
61
  return $meta;
@@ -77,7 +73,7 @@ if ( ! class_exists( 'RWMB_Checkbox_List_Field' ) )
77
  {
78
  if ( !$field['clone'] )
79
  {
80
- RW_Meta_Box::save( $new, $old, $post_id, $field );
81
  return;
82
  }
83
 
4
 
5
  if ( ! class_exists( 'RWMB_Checkbox_List_Field' ) )
6
  {
7
+ class RWMB_Checkbox_List_Field extends RWMB_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
 
12
  * @param mixed $meta
13
  * @param array $field
14
  *
15
  * @return string
16
  */
17
+ static function html( $meta, $field )
18
  {
19
  $meta = (array) $meta;
20
  $html = array();
21
+ $tpl = '<label><input type="checkbox" class="rwmb-checkbox-list" name="%s" value="%s"%s> %s</label>';
22
 
23
  foreach ( $field['options'] as $value => $label )
24
  {
30
  $label
31
  );
32
  }
33
+ return implode( '<br>', $html );
34
  }
35
 
36
  /**
42
  *
43
  * TODO: A good way to ALWAYS save values in single entry in DB, while maintaining backward compatibility
44
  *
 
45
  * @param $post_id
46
  * @param $saved
47
  * @param $field
48
  *
49
  * @return array
50
  */
51
+ static function meta( $post_id, $saved, $field )
52
  {
53
  $meta = get_post_meta( $post_id, $field['id'], $field['clone'] );
 
54
  $meta = ( !$saved && '' === $meta || array() === $meta ) ? $field['std'] : $meta;
 
55
  $meta = array_map( 'esc_attr', (array) $meta );
56
 
57
  return $meta;
73
  {
74
  if ( !$field['clone'] )
75
  {
76
+ parent::save( $new, $old, $post_id, $field );
77
  return;
78
  }
79
 
inc/fields/checkbox.php CHANGED
@@ -4,18 +4,17 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( ! class_exists( 'RWMB_Checkbox_Field' ) )
6
  {
7
- class RWMB_Checkbox_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
12
- * @param string $html
13
  * @param mixed $meta
14
  * @param array $field
15
  *
16
  * @return string
17
  */
18
- static function html( $html, $meta, $field )
19
  {
20
  return sprintf(
21
  '<input type="checkbox" class="rwmb-checkbox" name="%s" id="%s" value="1" %s />',
4
 
5
  if ( ! class_exists( 'RWMB_Checkbox_Field' ) )
6
  {
7
+ class RWMB_Checkbox_Field extends RWMB_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
 
12
  * @param mixed $meta
13
  * @param array $field
14
  *
15
  * @return string
16
  */
17
+ static function html( $meta, $field )
18
  {
19
  return sprintf(
20
  '<input type="checkbox" class="rwmb-checkbox" name="%s" id="%s" value="1" %s />',
inc/fields/color.php CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( ! class_exists( 'RWMB_Color_Field' ) )
6
  {
7
- class RWMB_Color_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
@@ -20,13 +20,12 @@ if ( ! class_exists( 'RWMB_Color_Field' ) )
20
  /**
21
  * Get field HTML
22
  *
23
- * @param string $html
24
  * @param mixed $meta
25
  * @param array $field
26
  *
27
  * @return string
28
  */
29
- static function html( $html, $meta, $field )
30
  {
31
  return sprintf(
32
  '<input class="rwmb-color" type="text" name="%s" id="%s" value="%s" size="%s" />
4
 
5
  if ( ! class_exists( 'RWMB_Color_Field' ) )
6
  {
7
+ class RWMB_Color_Field extends RWMB_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
20
  /**
21
  * Get field HTML
22
  *
 
23
  * @param mixed $meta
24
  * @param array $field
25
  *
26
  * @return string
27
  */
28
+ static function html( $meta, $field )
29
  {
30
  return sprintf(
31
  '<input class="rwmb-color" type="text" name="%s" id="%s" value="%s" size="%s" />
inc/fields/date.php CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( !class_exists( 'RWMB_Date_Field' ) )
6
  {
7
- class RWMB_Date_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
@@ -35,13 +35,12 @@ if ( !class_exists( 'RWMB_Date_Field' ) )
35
  /**
36
  * Get field HTML
37
  *
38
- * @param string $html
39
  * @param mixed $meta
40
  * @param array $field
41
  *
42
  * @return string
43
  */
44
- static function html( $html, $meta, $field )
45
  {
46
  return sprintf(
47
  '<input type="text" class="rwmb-date" name="%s" value="%s" id="%s" size="%s" data-options="%s" />',
4
 
5
  if ( !class_exists( 'RWMB_Date_Field' ) )
6
  {
7
+ class RWMB_Date_Field extends RWMB_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
35
  /**
36
  * Get field HTML
37
  *
 
38
  * @param mixed $meta
39
  * @param array $field
40
  *
41
  * @return string
42
  */
43
+ static function html( $meta, $field )
44
  {
45
  return sprintf(
46
  '<input type="text" class="rwmb-date" name="%s" value="%s" id="%s" size="%s" data-options="%s" />',
inc/fields/datetime.php CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( !class_exists( 'RWMB_Datetime_Field' ) )
6
  {
7
- class RWMB_Datetime_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
@@ -45,13 +45,12 @@ if ( !class_exists( 'RWMB_Datetime_Field' ) )
45
  /**
46
  * Get field HTML
47
  *
48
- * @param string $html
49
  * @param mixed $meta
50
  * @param array $field
51
  *
52
  * @return string
53
  */
54
- static function html( $html, $meta, $field )
55
  {
56
  return sprintf(
57
  '<input type="text" class="rwmb-datetime" name="%s" value="%s" id="%s" size="%s" data-options="%s">',
4
 
5
  if ( !class_exists( 'RWMB_Datetime_Field' ) )
6
  {
7
+ class RWMB_Datetime_Field extends RWMB_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
45
  /**
46
  * Get field HTML
47
  *
 
48
  * @param mixed $meta
49
  * @param array $field
50
  *
51
  * @return string
52
  */
53
+ static function html( $meta, $field )
54
  {
55
  return sprintf(
56
  '<input type="text" class="rwmb-datetime" name="%s" value="%s" id="%s" size="%s" data-options="%s">',
inc/fields/divider.php CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( ! class_exists( 'RWMB_Divider_Field' ) )
6
  {
7
- class RWMB_Divider_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
@@ -19,13 +19,12 @@ if ( ! class_exists( 'RWMB_Divider_Field' ) )
19
  /**
20
  * Show begin HTML markup for fields
21
  *
22
- * @param string $html
23
  * @param mixed $meta
24
  * @param array $field
25
  *
26
  * @return string
27
  */
28
- static function begin_html( $html, $meta, $field )
29
  {
30
  return '<hr>';
31
  }
@@ -33,13 +32,12 @@ if ( ! class_exists( 'RWMB_Divider_Field' ) )
33
  /**
34
  * Show end HTML markup for fields
35
  *
36
- * @param string $html
37
  * @param mixed $meta
38
  * @param array $field
39
  *
40
  * @return string
41
  */
42
- static function end_html( $html, $meta, $field )
43
  {
44
  return '';
45
  }
4
 
5
  if ( ! class_exists( 'RWMB_Divider_Field' ) )
6
  {
7
+ class RWMB_Divider_Field extends RWMB_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
19
  /**
20
  * Show begin HTML markup for fields
21
  *
 
22
  * @param mixed $meta
23
  * @param array $field
24
  *
25
  * @return string
26
  */
27
+ static function begin_html( $meta, $field )
28
  {
29
  return '<hr>';
30
  }
32
  /**
33
  * Show end HTML markup for fields
34
  *
 
35
  * @param mixed $meta
36
  * @param array $field
37
  *
38
  * @return string
39
  */
40
+ static function end_html( $meta, $field )
41
  {
42
  return '';
43
  }
inc/fields/email.php CHANGED
@@ -12,13 +12,12 @@ if ( !class_exists( 'RWMB_Email_Field' ) )
12
  /**
13
  * Get field HTML
14
  *
15
- * @param string $html
16
  * @param mixed $meta
17
  * @param array $field
18
  *
19
  * @return string
20
  */
21
- static function html( $html, $meta, $field )
22
  {
23
  return sprintf(
24
  '<input type="email" class="rwmb-email" name="%s" id="%s" value="%s" size="%s" placeholder="%s"/>',
@@ -30,7 +29,6 @@ if ( !class_exists( 'RWMB_Email_Field' ) )
30
  );
31
  }
32
 
33
-
34
  /**
35
  * Sanitize email
36
  *
12
  /**
13
  * Get field HTML
14
  *
 
15
  * @param mixed $meta
16
  * @param array $field
17
  *
18
  * @return string
19
  */
20
+ static function html( $meta, $field )
21
  {
22
  return sprintf(
23
  '<input type="email" class="rwmb-email" name="%s" id="%s" value="%s" size="%s" placeholder="%s"/>',
29
  );
30
  }
31
 
 
32
  /**
33
  * Sanitize email
34
  *
inc/fields/fieldset-text.php CHANGED
@@ -2,82 +2,76 @@
2
  // Prevent loading this file directly
3
  defined( 'ABSPATH' ) || exit;
4
 
5
- if ( ! class_exists( 'RWMB_Fieldset_Text_Field' ) )
6
  {
7
- class RWMB_Fieldset_Text_Field
8
- {
9
- /**
10
- * Get field HTML
11
- *
12
- * @param string $html
13
- * @param mixed $meta
14
- * @param array $field
15
- *
16
- * @return string
17
- */
18
- static function html( $html, $meta, $field )
19
- {
20
- $out = '';
21
 
22
- if (count($meta)==1 && trim($meta[0])=='') {
23
- $meta = "";
24
- }
25
 
26
- $html = array();
27
- $before = '<fieldset><legend>'.$field['desc'].'</legend>';
28
- $after = '</fieldset>';
29
-
30
- $tpl = '<label>%s <input type="text" class="rwmb-fieldset-text" name="%s[%s][%d]" placeholder="%s" value="%s" /></label>';
31
-
32
- for($n=0;$n<$field['rows'];$n++) {
33
- foreach( $field['options'] as $k => $v ) {
34
- $fid = $field['id'];
35
- if (is_array($meta) && !empty($meta)) {
36
- $html[] = sprintf($tpl, $k, $fid, $v, $n, $k, $meta[$v][$n]);
37
- } else {
38
- $html[] = sprintf($tpl, $k, $fid, $v, $n, $k, '');
39
- }
40
- }
41
- $html[] = "<br/>\n";
42
- }
43
 
44
- $out = $before . implode( ' ', $html ) . $after;
45
- return $out;
46
- }
 
 
 
 
 
 
 
 
 
47
 
48
- /**
49
- * Get meta value
50
- *
51
- * @param $meta
52
- * @param $post_id
53
- * @param $saved
54
- * @param $field
55
- *
56
- * @return array
57
- */
58
- static function meta( $meta, $post_id, $saved, $field )
59
- {
60
- $meta = get_post_meta( $post_id, $field['id'] );
61
 
62
- if (is_array($meta) && !empty($meta)) {
63
- $meta = $meta[0];
64
- }
 
 
 
 
 
 
 
 
 
65
 
66
- return $meta;
67
- }
68
 
69
- /**
70
- * Save meta value
71
- *
72
- * @param $new
73
- * @param $old
74
- * @param $post_id
75
- * @param $field
76
- */
77
- static function save( $new, $old, $post_id, $field )
78
- {
79
- update_post_meta($post_id, $field['id'], $new, $old);
80
- }
81
 
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
83
  }
2
  // Prevent loading this file directly
3
  defined( 'ABSPATH' ) || exit;
4
 
5
+ if ( !class_exists( 'RWMB_Fieldset_Text_Field' ) )
6
  {
7
+ class RWMB_Fieldset_Text_Field extends RWMB_Field
8
+ {
9
+ /**
10
+ * Get field HTML
11
+ *
12
+ * @param mixed $meta
13
+ * @param array $field
14
+ *
15
+ * @return string
16
+ */
17
+ static function html( $meta, $field )
18
+ {
19
+ if ( count( $meta ) == 1 && trim( $meta[0] ) == '' )
20
+ $meta = '';
21
 
22
+ $html = array();
23
+ $before = '<fieldset><legend>' . $field['desc'] . '</legend>';
24
+ $after = '</fieldset>';
25
 
26
+ $tpl = '<label>%s <input type="text" class="rwmb-fieldset-text" name="%s[%s][%d]" placeholder="%s" value="%s" /></label>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
+ for ( $n = 0; $n < $field['rows']; $n++ )
29
+ {
30
+ foreach ( $field['options'] as $k => $v )
31
+ {
32
+ $fid = $field['id'];
33
+ if ( is_array( $meta ) && !empty( $meta ) )
34
+ $html[] = sprintf( $tpl, $k, $fid, $v, $n, $k, $meta[$v][$n] );
35
+ else
36
+ $html[] = sprintf( $tpl, $k, $fid, $v, $n, $k, '' );
37
+ }
38
+ $html[] = '<br>';
39
+ }
40
 
41
+ $out = $before . implode( ' ', $html ) . $after;
42
+ return $out;
43
+ }
 
 
 
 
 
 
 
 
 
 
44
 
45
+ /**
46
+ * Get meta value
47
+ *
48
+ * @param $post_id
49
+ * @param $saved
50
+ * @param $field
51
+ *
52
+ * @return array
53
+ */
54
+ static function meta( $post_id, $saved, $field )
55
+ {
56
+ $meta = get_post_meta( $post_id, $field['id'] );
57
 
58
+ if ( is_array( $meta ) && !empty( $meta ) )
59
+ $meta = $meta[0];
60
 
61
+ return $meta;
62
+ }
 
 
 
 
 
 
 
 
 
 
63
 
64
+ /**
65
+ * Save meta value
66
+ *
67
+ * @param $new
68
+ * @param $old
69
+ * @param $post_id
70
+ * @param $field
71
+ */
72
+ static function save( $new, $old, $post_id, $field )
73
+ {
74
+ update_post_meta( $post_id, $field['id'], $new, $old );
75
+ }
76
+ }
77
  }
inc/fields/file-advanced.php CHANGED
@@ -51,17 +51,15 @@ if ( ! class_exists( 'RWMB_File_Advanced_Field' ) )
51
  wp_send_json_success();
52
  }
53
 
54
-
55
  /**
56
  * Get field HTML
57
  *
58
- * @param string $html
59
  * @param mixed $meta
60
  * @param array $field
61
  *
62
  * @return string
63
  */
64
- static function html( $html, $meta, $field )
65
  {
66
  $i18n_title = apply_filters( 'rwmb_file_advanced_select_string', _x( 'Select or Upload Files', 'file upload', 'rwmb' ), $field );
67
  $attach_nonce = wp_create_nonce( "rwmb-attach-file_{$field['id']}" );
51
  wp_send_json_success();
52
  }
53
 
 
54
  /**
55
  * Get field HTML
56
  *
 
57
  * @param mixed $meta
58
  * @param array $field
59
  *
60
  * @return string
61
  */
62
+ static function html( $meta, $field )
63
  {
64
  $i18n_title = apply_filters( 'rwmb_file_advanced_select_string', _x( 'Select or Upload Files', 'file upload', 'rwmb' ), $field );
65
  $attach_nonce = wp_create_nonce( "rwmb-attach-file_{$field['id']}" );
inc/fields/file-input.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists( 'RWMB_File_Input_Field' ) )
3
+ {
4
+ class RWMB_File_Input_Field extends RWMB_Field
5
+ {
6
+ /**
7
+ * Enqueue scripts and styles
8
+ *
9
+ * @return void
10
+ */
11
+ static function admin_enqueue_scripts()
12
+ {
13
+ // Make sure scripts for new media uploader in WordPress 3.5 is enqueued
14
+ wp_enqueue_media();
15
+ wp_enqueue_script( 'rwmb-file-input', RWMB_JS_URL . 'file-input.js', array( 'jquery' ), RWMB_VER, true );
16
+ wp_localize_script( 'rwmb-file-input', 'rwmbFileInput', array(
17
+ 'frameTitle' => __( 'Select File', 'rwmb' ),
18
+ ) );
19
+ }
20
+
21
+ /**
22
+ * Get field HTML
23
+ *
24
+ * @param mixed $meta
25
+ * @param array $field
26
+ *
27
+ * @return string
28
+ */
29
+ static function html( $meta, $field )
30
+ {
31
+ return sprintf(
32
+ '<input type="text" class="rwmb-file-input" name="%s" id="%s" value="%s" placeholder="%s" size="%s">
33
+ <a href="#" class="rwmb-file-input-select button-primary">%s</a>
34
+ <a href="#" class="rwmb-file-input-remove button %s">%s</a>',
35
+ $field['field_name'],
36
+ $field['id'],
37
+ $meta,
38
+ $field['placeholder'],
39
+ $field['size'],
40
+ __( 'Select', 'rwmb' ),
41
+ $meta ? '' : 'hidden',
42
+ __( 'Remove', 'rwmb' )
43
+ );
44
+ }
45
+
46
+ /**
47
+ * Normalize parameters for field
48
+ *
49
+ * @param array $field
50
+ *
51
+ * @return array
52
+ */
53
+ static function normalize_field( $field )
54
+ {
55
+ $field = wp_parse_args( $field, array(
56
+ 'size' => 30,
57
+ 'placeholder' => '',
58
+ ) );
59
+ return $field;
60
+ }
61
+ }
62
+ }
inc/fields/file.php CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( ! class_exists( 'RWMB_File_Field' ) )
6
  {
7
- class RWMB_File_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
@@ -73,13 +73,12 @@ if ( ! class_exists( 'RWMB_File_Field' ) )
73
  /**
74
  * Get field HTML
75
  *
76
- * @param string $html
77
  * @param mixed $meta
78
  * @param array $field
79
  *
80
  * @return string
81
  */
82
- static function html( $html, $meta, $field )
83
  {
84
  $i18n_title = apply_filters( 'rwmb_file_upload_string', _x( 'Upload Files', 'file upload', 'rwmb' ), $field );
85
  $i18n_more = apply_filters( 'rwmb_file_add_string', _x( '+ Add new file', 'file upload', 'rwmb' ), $field );
@@ -258,21 +257,16 @@ if ( ! class_exists( 'RWMB_File_Field' ) )
258
  /**
259
  * Standard meta retrieval
260
  *
261
- * @param mixed $meta
262
  * @param int $post_id
263
  * @param array $field
264
  * @param bool $saved
265
  *
266
  * @return mixed
267
  */
268
- static function meta( $meta, $post_id, $saved, $field )
269
  {
270
- $meta = RW_Meta_Box::meta( $meta, $post_id, $saved, $field );
271
-
272
- if ( empty( $meta ) )
273
- return array();
274
-
275
- return (array) $meta;
276
  }
277
  }
278
  }
4
 
5
  if ( ! class_exists( 'RWMB_File_Field' ) )
6
  {
7
+ class RWMB_File_Field extends RWMB_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
73
  /**
74
  * Get field HTML
75
  *
 
76
  * @param mixed $meta
77
  * @param array $field
78
  *
79
  * @return string
80
  */
81
+ static function html( $meta, $field )
82
  {
83
  $i18n_title = apply_filters( 'rwmb_file_upload_string', _x( 'Upload Files', 'file upload', 'rwmb' ), $field );
84
  $i18n_more = apply_filters( 'rwmb_file_add_string', _x( '+ Add new file', 'file upload', 'rwmb' ), $field );
257
  /**
258
  * Standard meta retrieval
259
  *
 
260
  * @param int $post_id
261
  * @param array $field
262
  * @param bool $saved
263
  *
264
  * @return mixed
265
  */
266
+ static function meta( $post_id, $saved, $field )
267
  {
268
+ $meta = parent::meta( $post_id, $saved, $field );
269
+ return empty( $meta ) ? array() : (array) $meta;
 
 
 
 
270
  }
271
  }
272
  }
inc/fields/heading.php CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( ! class_exists( 'RWMB_Heading_Field' ) )
6
  {
7
- class RWMB_Heading_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
@@ -19,13 +19,12 @@ if ( ! class_exists( 'RWMB_Heading_Field' ) )
19
  /**
20
  * Show begin HTML markup for fields
21
  *
22
- * @param string $html
23
  * @param mixed $meta
24
  * @param array $field
25
  *
26
  * @return string
27
  */
28
- static function begin_html( $html, $meta, $field )
29
  {
30
  return sprintf(
31
  '<h4>%s</h4>',
@@ -36,13 +35,12 @@ if ( ! class_exists( 'RWMB_Heading_Field' ) )
36
  /**
37
  * Show end HTML markup for fields
38
  *
39
- * @param string $html
40
  * @param mixed $meta
41
  * @param array $field
42
  *
43
  * @return string
44
  */
45
- static function end_html( $html, $meta, $field )
46
  {
47
  return '';
48
  }
4
 
5
  if ( ! class_exists( 'RWMB_Heading_Field' ) )
6
  {
7
+ class RWMB_Heading_Field extends RWMB_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
19
  /**
20
  * Show begin HTML markup for fields
21
  *
 
22
  * @param mixed $meta
23
  * @param array $field
24
  *
25
  * @return string
26
  */
27
+ static function begin_html( $meta, $field )
28
  {
29
  return sprintf(
30
  '<h4>%s</h4>',
35
  /**
36
  * Show end HTML markup for fields
37
  *
 
38
  * @param mixed $meta
39
  * @param array $field
40
  *
41
  * @return string
42
  */
43
+ static function end_html( $meta, $field )
44
  {
45
  return '';
46
  }
inc/fields/hidden.php CHANGED
@@ -4,18 +4,17 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( ! class_exists( 'RWMB_Hidden_Field' ) )
6
  {
7
- class RWMB_Hidden_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
12
- * @param string $html
13
  * @param mixed $meta
14
  * @param array $field
15
  *
16
  * @return string
17
  */
18
- static function html( $html, $meta, $field )
19
  {
20
  return sprintf(
21
  '<input type="hidden" class="rwmb-hidden" name="%s" id="%s" value="%s" />',
4
 
5
  if ( ! class_exists( 'RWMB_Hidden_Field' ) )
6
  {
7
+ class RWMB_Hidden_Field extends RWMB_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
 
12
  * @param mixed $meta
13
  * @param array $field
14
  *
15
  * @return string
16
  */
17
+ static function html( $meta, $field )
18
  {
19
  return sprintf(
20
  '<input type="hidden" class="rwmb-hidden" name="%s" id="%s" value="%s" />',
inc/fields/image-advanced.php CHANGED
@@ -60,19 +60,18 @@ if ( ! class_exists( 'RWMB_Image_Advanced_Field' ) )
60
  /**
61
  * Get field HTML
62
  *
63
- * @param string $html
64
  * @param mixed $meta
65
  * @param array $field
66
  *
67
  * @return string
68
  */
69
- static function html( $html, $meta, $field )
70
  {
71
  $i18n_title = apply_filters( 'rwmb_image_advanced_select_string', _x( 'Select or Upload Images', 'image upload', 'rwmb' ), $field );
72
  $attach_nonce = wp_create_nonce( "rwmb-attach-media_{$field['id']}" );
73
 
74
  // Uploaded images
75
- $html .= self::get_uploaded_images( $meta, $field );
76
 
77
  // Show form upload
78
  $classes = array( 'button', 'rwmb-image-advanced-upload', 'hide-if-no-js', 'new-files' );
60
  /**
61
  * Get field HTML
62
  *
 
63
  * @param mixed $meta
64
  * @param array $field
65
  *
66
  * @return string
67
  */
68
+ static function html( $meta, $field )
69
  {
70
  $i18n_title = apply_filters( 'rwmb_image_advanced_select_string', _x( 'Select or Upload Images', 'image upload', 'rwmb' ), $field );
71
  $attach_nonce = wp_create_nonce( "rwmb-attach-media_{$field['id']}" );
72
 
73
  // Uploaded images
74
+ $html = self::get_uploaded_images( $meta, $field );
75
 
76
  // Show form upload
77
  $classes = array( 'button', 'rwmb-image-advanced-upload', 'hide-if-no-js', 'new-files' );
inc/fields/image-select.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Prevent loading this file directly
3
+ defined( 'ABSPATH' ) || exit;
4
+
5
+ if ( ! class_exists( 'RWMB_Image_Select_Field' ) )
6
+ {
7
+ class RWMB_Image_Select_Field extends RWMB_Field
8
+ {
9
+ /**
10
+ * Enqueue scripts and styles
11
+ *
12
+ * @return void
13
+ */
14
+ static function admin_enqueue_scripts()
15
+ {
16
+ wp_enqueue_style( 'rwmb-image-select', RWMB_CSS_URL . 'image-select.css', array(), RWMB_VER );
17
+ wp_enqueue_script( 'rwmb-image-select', RWMB_JS_URL . 'image-select.js', array( 'jquery' ), RWMB_VER, true );
18
+ }
19
+
20
+ /**
21
+ * Get field HTML
22
+ *
23
+ * @param mixed $meta
24
+ * @param array $field
25
+ *
26
+ * @return string
27
+ */
28
+ static function html( $meta, $field )
29
+ {
30
+ $html = array();
31
+ $tpl = '<label class="rwmb-image-select"><img src="%s"><input type="%s" class="hidden" name="%s" value="%s"%s></label>';
32
+
33
+ $meta = (array) $meta;
34
+ foreach ( $field['options'] as $value => $image )
35
+ {
36
+ $html[] = sprintf(
37
+ $tpl,
38
+ $image,
39
+ $field['multiple'] ? 'checkbox' : 'radio',
40
+ $field['field_name'],
41
+ $value,
42
+ checked( in_array( $value, $meta ), true, false )
43
+ );
44
+ }
45
+
46
+ return implode( ' ', $html );
47
+ }
48
+
49
+ /**
50
+ * Normalize parameters for field
51
+ *
52
+ * @param array $field
53
+ *
54
+ * @return array
55
+ */
56
+ static function normalize_field( $field )
57
+ {
58
+ $field['field_name'] .= $field['multiple'] ? '[]' : '';
59
+ return $field;
60
+ }
61
+ }
62
+ }
inc/fields/image.php CHANGED
@@ -60,19 +60,18 @@ if ( ! class_exists( 'RWMB_Image_Field' ) )
60
  /**
61
  * Get field HTML
62
  *
63
- * @param string $html
64
  * @param mixed $meta
65
  * @param array $field
66
  *
67
  * @return string
68
  */
69
- static function html( $html, $meta, $field )
70
  {
71
  $i18n_title = apply_filters( 'rwmb_image_upload_string', _x( 'Upload Images', 'image upload', 'rwmb' ), $field );
72
  $i18n_more = apply_filters( 'rwmb_image_add_string', _x( '+ Add new image', 'image upload', 'rwmb' ), $field );
73
 
74
  // Uploaded images
75
- $html .= self::get_uploaded_images( $meta, $field );
76
 
77
  // Show form upload
78
  $html .= sprintf(
@@ -162,14 +161,13 @@ if ( ! class_exists( 'RWMB_Image_Field' ) )
162
  /**
163
  * Standard meta retrieval
164
  *
165
- * @param mixed $meta
166
  * @param int $post_id
167
  * @param array $field
168
  * @param bool $saved
169
  *
170
  * @return mixed
171
  */
172
- static function meta( $meta, $post_id, $saved, $field )
173
  {
174
  global $wpdb;
175
 
60
  /**
61
  * Get field HTML
62
  *
 
63
  * @param mixed $meta
64
  * @param array $field
65
  *
66
  * @return string
67
  */
68
+ static function html( $meta, $field )
69
  {
70
  $i18n_title = apply_filters( 'rwmb_image_upload_string', _x( 'Upload Images', 'image upload', 'rwmb' ), $field );
71
  $i18n_more = apply_filters( 'rwmb_image_add_string', _x( '+ Add new image', 'image upload', 'rwmb' ), $field );
72
 
73
  // Uploaded images
74
+ $html = self::get_uploaded_images( $meta, $field );
75
 
76
  // Show form upload
77
  $html .= sprintf(
161
  /**
162
  * Standard meta retrieval
163
  *
 
164
  * @param int $post_id
165
  * @param array $field
166
  * @param bool $saved
167
  *
168
  * @return mixed
169
  */
170
+ static function meta( $post_id, $saved, $field )
171
  {
172
  global $wpdb;
173
 
inc/fields/map.php CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( !class_exists( 'RWMB_Map_Field' ) )
6
  {
7
- class RWMB_Map_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
@@ -20,13 +20,12 @@ if ( !class_exists( 'RWMB_Map_Field' ) )
20
  /**
21
  * Get field HTML
22
  *
23
- * @param string $html
24
  * @param mixed $meta
25
  * @param array $field
26
  *
27
  * @return string
28
  */
29
- static function html( $html, $meta, $field )
30
  {
31
  $address = isset( $field['address_field'] ) ? $field['address_field'] : false;
32
 
4
 
5
  if ( !class_exists( 'RWMB_Map_Field' ) )
6
  {
7
+ class RWMB_Map_Field extends RWMB_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
20
  /**
21
  * Get field HTML
22
  *
 
23
  * @param mixed $meta
24
  * @param array $field
25
  *
26
  * @return string
27
  */
28
+ static function html( $meta, $field )
29
  {
30
  $address = isset( $field['address_field'] ) ? $field['address_field'] : false;
31
 
inc/fields/number.php CHANGED
@@ -4,18 +4,17 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( !class_exists( 'RWMB_Number_Field' ) )
6
  {
7
- class RWMB_Number_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
12
- * @param string $html
13
  * @param mixed $meta
14
  * @param array $field
15
  *
16
  * @return string
17
  */
18
- static function html( $html, $meta, $field )
19
  {
20
  return sprintf(
21
  '<input type="number" class="rwmb-number" name="%s" id="%s" value="%s" step="%s" min="%s" placeholder="%s"/>',
4
 
5
  if ( !class_exists( 'RWMB_Number_Field' ) )
6
  {
7
+ class RWMB_Number_Field extends RWMB_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
 
12
  * @param mixed $meta
13
  * @param array $field
14
  *
15
  * @return string
16
  */
17
+ static function html( $meta, $field )
18
  {
19
  return sprintf(
20
  '<input type="number" class="rwmb-number" name="%s" id="%s" value="%s" step="%s" min="%s" placeholder="%s"/>',
inc/fields/oembed.php CHANGED
@@ -57,13 +57,12 @@ if ( ! class_exists( 'RWMB_OEmbed_Field' ) )
57
  /**
58
  * Get field HTML
59
  *
60
- * @param string $html
61
  * @param mixed $meta
62
  * @param array $field
63
  *
64
  * @return string
65
  */
66
- static function html( $html, $meta, $field )
67
  {
68
  return sprintf(
69
  '<input type="url" class="rwmb-oembed" name="%s" id="%s" value="%s" size="%s">
57
  /**
58
  * Get field HTML
59
  *
 
60
  * @param mixed $meta
61
  * @param array $field
62
  *
63
  * @return string
64
  */
65
+ static function html( $meta, $field )
66
  {
67
  return sprintf(
68
  '<input type="url" class="rwmb-oembed" name="%s" id="%s" value="%s" size="%s">
inc/fields/password.php CHANGED
@@ -12,13 +12,12 @@ if ( ! class_exists( 'RWMB_Password_Field' ) )
12
  /**
13
  * Get field HTML
14
  *
15
- * @param string $html
16
  * @param mixed $meta
17
  * @param array $field
18
  *
19
  * @return string
20
  */
21
- static function html( $html, $meta, $field )
22
  {
23
  return sprintf(
24
  '<input type="password" class="rwmb-password" name="%s" id="%s" value="%s" size="%s" />',
12
  /**
13
  * Get field HTML
14
  *
 
15
  * @param mixed $meta
16
  * @param array $field
17
  *
18
  * @return string
19
  */
20
+ static function html( $meta, $field )
21
  {
22
  return sprintf(
23
  '<input type="password" class="rwmb-password" name="%s" id="%s" value="%s" size="%s" />',
inc/fields/plupload-image.php CHANGED
@@ -88,13 +88,12 @@ if ( ! class_exists( 'RWMB_Plupload_Image_Field' ) )
88
  /**
89
  * Get field HTML
90
  *
91
- * @param string $html
92
  * @param mixed $meta
93
  * @param array $field
94
  *
95
  * @return string
96
  */
97
- static function html( $html, $meta, $field )
98
  {
99
  if ( ! is_array( $meta ) )
100
  $meta = ( array ) $meta;
@@ -112,7 +111,7 @@ if ( ! class_exists( 'RWMB_Plupload_Image_Field' ) )
112
  $classes[] = 'hidden';
113
 
114
 
115
- $html .= self::get_uploaded_images( $meta, $field );
116
 
117
  // Show form upload
118
  $html .= sprintf(
88
  /**
89
  * Get field HTML
90
  *
 
91
  * @param mixed $meta
92
  * @param array $field
93
  *
94
  * @return string
95
  */
96
+ static function html( $meta, $field )
97
  {
98
  if ( ! is_array( $meta ) )
99
  $meta = ( array ) $meta;
111
  $classes[] = 'hidden';
112
 
113
 
114
+ $html = self::get_uploaded_images( $meta, $field );
115
 
116
  // Show form upload
117
  $html .= sprintf(
inc/fields/post.php CHANGED
@@ -7,7 +7,7 @@ require_once RWMB_FIELDS_DIR . 'select-advanced.php';
7
 
8
  if ( !class_exists( 'RWMB_Post_Field' ) )
9
  {
10
- class RWMB_Post_Field
11
  {
12
  /**
13
  * Enqueue scripts and styles
@@ -22,23 +22,21 @@ if ( !class_exists( 'RWMB_Post_Field' ) )
22
  /**
23
  * Get field HTML
24
  *
25
- * @param string $html
26
  * @param mixed $meta
27
  * @param array $field
28
  *
29
  * @return string
30
  */
31
- static function html( $html, $meta, $field )
32
  {
33
  $field['options'] = self::get_options( $field );
34
  switch ( $field['field_type'] )
35
  {
36
  case 'select':
37
- return RWMB_Select_Field::html( $html, $meta, $field );
38
- break;
39
  case 'select_advanced':
40
  default:
41
- return RWMB_Select_Advanced_Field::html( $html, $meta, $field );
42
  }
43
  }
44
 
@@ -97,21 +95,20 @@ if ( !class_exists( 'RWMB_Post_Field' ) )
97
  *
98
  * @see "save" method for better understanding
99
  *
100
- * @param $meta
101
  * @param $post_id
102
  * @param $saved
103
  * @param $field
104
  *
105
  * @return array
106
  */
107
- static function meta( $meta, $post_id, $saved, $field )
108
  {
109
  if ( isset( $field['parent'] ) && $field['parent'] )
110
  {
111
  $post = get_post( $post_id );
112
  return $post->post_parent;
113
  }
114
- return RWMB_Select_Field::meta( $meta, $post_id, $saved, $field );
115
  }
116
 
117
  /**
@@ -140,11 +137,15 @@ if ( !class_exists( 'RWMB_Post_Field' ) )
140
  */
141
  static function get_options( $field )
142
  {
143
- $results = get_posts( $field['query_args'] );
144
- $options = array();
145
- foreach ( $results as $result )
146
- {
147
- $options[$result->ID] = get_the_title( $result->ID );
 
 
 
 
148
  }
149
  return $options;
150
  }
7
 
8
  if ( !class_exists( 'RWMB_Post_Field' ) )
9
  {
10
+ class RWMB_Post_Field extends RWMB_Field
11
  {
12
  /**
13
  * Enqueue scripts and styles
22
  /**
23
  * Get field HTML
24
  *
 
25
  * @param mixed $meta
26
  * @param array $field
27
  *
28
  * @return string
29
  */
30
+ static function html( $meta, $field )
31
  {
32
  $field['options'] = self::get_options( $field );
33
  switch ( $field['field_type'] )
34
  {
35
  case 'select':
36
+ return RWMB_Select_Field::html( $meta, $field );
 
37
  case 'select_advanced':
38
  default:
39
+ return RWMB_Select_Advanced_Field::html( $meta, $field );
40
  }
41
  }
42
 
95
  *
96
  * @see "save" method for better understanding
97
  *
 
98
  * @param $post_id
99
  * @param $saved
100
  * @param $field
101
  *
102
  * @return array
103
  */
104
+ static function meta( $post_id, $saved, $field )
105
  {
106
  if ( isset( $field['parent'] ) && $field['parent'] )
107
  {
108
  $post = get_post( $post_id );
109
  return $post->post_parent;
110
  }
111
+ return RWMB_Select_Field::meta( $post_id, $saved, $field );
112
  }
113
 
114
  /**
137
  */
138
  static function get_options( $field )
139
  {
140
+ $query = new WP_Query( $field['query_args'] );
141
+ if ( $query->have_posts() ) {
142
+ while( $query->have_posts() )
143
+ {
144
+ $post = $query->next_post();
145
+ $options[$post->ID] = $post->post_title;
146
+ }
147
+ } else {
148
+ $options = array();
149
  }
150
  return $options;
151
  }
inc/fields/radio.php CHANGED
@@ -4,18 +4,17 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( ! class_exists( 'RWMB_Radio_Field' ) )
6
  {
7
- class RWMB_Radio_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
12
- * @param string $html
13
  * @param mixed $meta
14
  * @param array $field
15
  *
16
  * @return string
17
  */
18
- static function html( $html, $meta, $field )
19
  {
20
  $html = array();
21
  $tpl = '<label><input type="radio" class="rwmb-radio" name="%s" value="%s"%s> %s</label>';
4
 
5
  if ( ! class_exists( 'RWMB_Radio_Field' ) )
6
  {
7
+ class RWMB_Radio_Field extends RWMB_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
 
12
  * @param mixed $meta
13
  * @param array $field
14
  *
15
  * @return string
16
  */
17
+ static function html( $meta, $field )
18
  {
19
  $html = array();
20
  $tpl = '<label><input type="radio" class="rwmb-radio" name="%s" value="%s"%s> %s</label>';
inc/fields/range.php CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( !class_exists( 'RWMB_Range_Field' ) )
6
  {
7
- class RWMB_Range_Field
8
  {
9
  /**
10
  * Enqueue styles
@@ -19,13 +19,12 @@ if ( !class_exists( 'RWMB_Range_Field' ) )
19
  /**
20
  * Get field HTML
21
  *
22
- * @param string $html
23
  * @param mixed $meta
24
  * @param array $field
25
  *
26
  * @return string
27
  */
28
- static function html( $html, $meta, $field )
29
  {
30
  return sprintf(
31
  '<input type="range" class="rwmb-range" name="%s" id="%s" value="%s" min="%s" max="%s" step="%s" />',
4
 
5
  if ( !class_exists( 'RWMB_Range_Field' ) )
6
  {
7
+ class RWMB_Range_Field extends RWMB_Field
8
  {
9
  /**
10
  * Enqueue styles
19
  /**
20
  * Get field HTML
21
  *
 
22
  * @param mixed $meta
23
  * @param array $field
24
  *
25
  * @return string
26
  */
27
+ static function html( $meta, $field )
28
  {
29
  return sprintf(
30
  '<input type="range" class="rwmb-range" name="%s" id="%s" value="%s" min="%s" max="%s" step="%s" />',
inc/fields/select-advanced.php CHANGED
@@ -26,13 +26,12 @@ if ( !class_exists( 'RWMB_Select_Advanced_Field' ) )
26
  /**
27
  * Get field HTML
28
  *
29
- * @param string $html
30
  * @param mixed $meta
31
  * @param array $field
32
  *
33
  * @return string
34
  */
35
- static function html( $html, $meta, $field )
36
  {
37
  $html = sprintf(
38
  '<select class="rwmb-select-advanced" name="%s" id="%s" size="%s"%s data-options="%s">',
26
  /**
27
  * Get field HTML
28
  *
 
29
  * @param mixed $meta
30
  * @param array $field
31
  *
32
  * @return string
33
  */
34
+ static function html( $meta, $field )
35
  {
36
  $html = sprintf(
37
  '<select class="rwmb-select-advanced" name="%s" id="%s" size="%s"%s data-options="%s">',
inc/fields/select.php CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( !class_exists( 'RWMB_Select_Field' ) )
6
  {
7
- class RWMB_Select_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
@@ -19,13 +19,12 @@ if ( !class_exists( 'RWMB_Select_Field' ) )
19
  /**
20
  * Get field HTML
21
  *
22
- * @param string $html
23
  * @param mixed $meta
24
  * @param array $field
25
  *
26
  * @return string
27
  */
28
- static function html( $html, $meta, $field )
29
  {
30
  $html = sprintf(
31
  '<select class="rwmb-select" name="%s" id="%s" size="%s"%s>',
@@ -51,14 +50,13 @@ if ( !class_exists( 'RWMB_Select_Field' ) )
51
  *
52
  * TODO: A good way to ALWAYS save values in single entry in DB, while maintaining backward compatibility
53
  *
54
- * @param $meta
55
  * @param $post_id
56
  * @param $saved
57
  * @param $field
58
  *
59
  * @return array
60
  */
61
- static function meta( $meta, $post_id, $saved, $field )
62
  {
63
  $single = $field['clone'] || !$field['multiple'];
64
  $meta = get_post_meta( $post_id, $field['id'], $single );
@@ -85,7 +83,7 @@ if ( !class_exists( 'RWMB_Select_Field' ) )
85
  {
86
  if ( !$field['clone'] )
87
  {
88
- RW_Meta_Box::save( $new, $old, $post_id, $field );
89
  return;
90
  }
91
 
4
 
5
  if ( !class_exists( 'RWMB_Select_Field' ) )
6
  {
7
+ class RWMB_Select_Field extends RWMB_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
19
  /**
20
  * Get field HTML
21
  *
 
22
  * @param mixed $meta
23
  * @param array $field
24
  *
25
  * @return string
26
  */
27
+ static function html( $meta, $field )
28
  {
29
  $html = sprintf(
30
  '<select class="rwmb-select" name="%s" id="%s" size="%s"%s>',
50
  *
51
  * TODO: A good way to ALWAYS save values in single entry in DB, while maintaining backward compatibility
52
  *
 
53
  * @param $post_id
54
  * @param $saved
55
  * @param $field
56
  *
57
  * @return array
58
  */
59
+ static function meta( $post_id, $saved, $field )
60
  {
61
  $single = $field['clone'] || !$field['multiple'];
62
  $meta = get_post_meta( $post_id, $field['id'], $single );
83
  {
84
  if ( !$field['clone'] )
85
  {
86
+ parent::save( $new, $old, $post_id, $field );
87
  return;
88
  }
89
 
inc/fields/slider.php CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( !class_exists( 'RWMB_Slider_Field' ) )
6
  {
7
- class RWMB_Slider_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
@@ -25,19 +25,18 @@ if ( !class_exists( 'RWMB_Slider_Field' ) )
25
  /**
26
  * Get div HTML
27
  *
28
- * @param string $html
29
  * @param mixed $meta
30
  * @param array $field
31
  *
32
  * @return string
33
  */
34
- static function html( $html, $meta, $field )
35
  {
36
  return sprintf(
37
  '<div class="clearfix">
38
  <div class="rwmb-slider" id="%s" data-options="%s"></div>
39
  <span class="rwmb-slider-value-label">%s<span>%s</span>%s</span>
40
- <input type="hidden" name="%s" value="%s" />
41
  </div>',
42
  $field['id'], esc_attr( json_encode( $field['js_options'] ) ),
43
  $field['prefix'], $meta, $field['suffix'],
4
 
5
  if ( !class_exists( 'RWMB_Slider_Field' ) )
6
  {
7
+ class RWMB_Slider_Field extends RWMB_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
25
  /**
26
  * Get div HTML
27
  *
 
28
  * @param mixed $meta
29
  * @param array $field
30
  *
31
  * @return string
32
  */
33
+ static function html( $meta, $field )
34
  {
35
  return sprintf(
36
  '<div class="clearfix">
37
  <div class="rwmb-slider" id="%s" data-options="%s"></div>
38
  <span class="rwmb-slider-value-label">%s<span>%s</span>%s</span>
39
+ <input type="hidden" name="%s" value="%s" class="rwmb-slider-value">
40
  </div>',
41
  $field['id'], esc_attr( json_encode( $field['js_options'] ) ),
42
  $field['prefix'], $meta, $field['suffix'],
inc/fields/taxonomy-advanced.php CHANGED
@@ -45,14 +45,13 @@ if ( ! class_exists( 'RWMB_Taxonomy_Advanced_Field' ) )
45
  /**
46
  * Standard meta retrieval
47
  *
48
- * @param mixed $meta
49
  * @param int $post_id
50
  * @param bool $saved
51
  * @param array $field
52
  *
53
  * @return array
54
  */
55
- static function meta( $meta, $post_id, $saved, $field )
56
  {
57
  $meta = get_post_meta( $post_id, $field['id'], true );
58
  $meta = array_map( 'intval', array_filter( explode( ',', $meta . ',' ) ) );
45
  /**
46
  * Standard meta retrieval
47
  *
 
48
  * @param int $post_id
49
  * @param bool $saved
50
  * @param array $field
51
  *
52
  * @return array
53
  */
54
+ static function meta( $post_id, $saved, $field )
55
  {
56
  $meta = get_post_meta( $post_id, $field['id'], true );
57
  $meta = array_map( 'intval', array_filter( explode( ',', $meta . ',' ) ) );
inc/fields/taxonomy.php CHANGED
@@ -6,7 +6,7 @@ require_once RWMB_FIELDS_DIR . 'checkbox-list.php';
6
 
7
  if ( ! class_exists( 'RWMB_Taxonomy_Field' ) )
8
  {
9
- class RWMB_Taxonomy_Field
10
  {
11
  /**
12
  * Enqueue scripts and styles
@@ -78,13 +78,12 @@ if ( ! class_exists( 'RWMB_Taxonomy_Field' ) )
78
  /**
79
  * Get field HTML
80
  *
81
- * @param $html
82
  * @param $field
83
  * @param $meta
84
  *
85
  * @return string
86
  */
87
- static function html( $html, $meta, $field )
88
  {
89
  $options = $field['options'];
90
  $terms = get_terms( $options['taxonomy'], $options['args'] );
@@ -96,7 +95,7 @@ if ( ! class_exists( 'RWMB_Taxonomy_Field' ) )
96
  switch( $options['type'] )
97
  {
98
  case 'checkbox_list':
99
- $html = RWMB_Checkbox_List_Field::html( $html, $meta, $field );
100
  break;
101
  case 'checkbox_tree':
102
  $elements = self::process_terms( $terms );
@@ -107,11 +106,11 @@ if ( ! class_exists( 'RWMB_Taxonomy_Field' ) )
107
  $html .= self::walk_select_tree( $meta, $field, $elements, $options['parent'], true );
108
  break;
109
  case 'select_advanced':
110
- $html = RWMB_Select_Advanced_Field::html( $html, $meta, $field );
111
  break;
112
  case 'select':
113
  default:
114
- $html = RWMB_Select_Field::html( $html, $meta, $field );
115
  }
116
 
117
  return $html;
@@ -177,7 +176,7 @@ if ( ! class_exists( 'RWMB_Taxonomy_Field' ) )
177
  $classes[] = "rwmb-taxonomy-{$parent}";
178
 
179
  $html = '<div class="' . implode( ' ', $classes ) . '">';
180
- $html .= RWMB_Select_Field::html( $html, $meta, $field );
181
  foreach ( $terms as $term )
182
  {
183
  $html .= self::walk_select_tree( $meta, $field, $elements, $term->term_id, $active && in_array( $term->term_id, $meta ) );
@@ -208,9 +207,9 @@ if ( ! class_exists( 'RWMB_Taxonomy_Field' ) )
208
  /**
209
  * Get options for selects, checkbox list, etc via the terms
210
  *
211
- * @param $terms array of term objects
212
  *
213
- * @param $options array
214
  */
215
  static function get_options( $terms = array() )
216
  {
@@ -242,14 +241,13 @@ if ( ! class_exists( 'RWMB_Taxonomy_Field' ) )
242
  /**
243
  * Standard meta retrieval
244
  *
245
- * @param mixed $meta
246
  * @param int $post_id
247
  * @param bool $saved
248
  * @param array $field
249
  *
250
  * @return array
251
  */
252
- static function meta( $meta, $post_id, $saved, $field )
253
  {
254
  $options = $field['options'];
255
 
6
 
7
  if ( ! class_exists( 'RWMB_Taxonomy_Field' ) )
8
  {
9
+ class RWMB_Taxonomy_Field extends RWMB_Field
10
  {
11
  /**
12
  * Enqueue scripts and styles
78
  /**
79
  * Get field HTML
80
  *
 
81
  * @param $field
82
  * @param $meta
83
  *
84
  * @return string
85
  */
86
+ static function html( $meta, $field )
87
  {
88
  $options = $field['options'];
89
  $terms = get_terms( $options['taxonomy'], $options['args'] );
95
  switch( $options['type'] )
96
  {
97
  case 'checkbox_list':
98
+ $html = RWMB_Checkbox_List_Field::html( $meta, $field );
99
  break;
100
  case 'checkbox_tree':
101
  $elements = self::process_terms( $terms );
106
  $html .= self::walk_select_tree( $meta, $field, $elements, $options['parent'], true );
107
  break;
108
  case 'select_advanced':
109
+ $html = RWMB_Select_Advanced_Field::html( $meta, $field );
110
  break;
111
  case 'select':
112
  default:
113
+ $html = RWMB_Select_Field::html( $meta, $field );
114
  }
115
 
116
  return $html;
176
  $classes[] = "rwmb-taxonomy-{$parent}";
177
 
178
  $html = '<div class="' . implode( ' ', $classes ) . '">';
179
+ $html .= RWMB_Select_Field::html( $meta, $field );
180
  foreach ( $terms as $term )
181
  {
182
  $html .= self::walk_select_tree( $meta, $field, $elements, $term->term_id, $active && in_array( $term->term_id, $meta ) );
207
  /**
208
  * Get options for selects, checkbox list, etc via the terms
209
  *
210
+ * @param array $terms Array of term objects
211
  *
212
+ * @return array
213
  */
214
  static function get_options( $terms = array() )
215
  {
241
  /**
242
  * Standard meta retrieval
243
  *
 
244
  * @param int $post_id
245
  * @param bool $saved
246
  * @param array $field
247
  *
248
  * @return array
249
  */
250
+ static function meta( $post_id, $saved, $field )
251
  {
252
  $options = $field['options'];
253
 
inc/fields/text-list.php CHANGED
@@ -2,22 +2,20 @@
2
  // Prevent loading this file directly
3
  defined( 'ABSPATH' ) || exit;
4
 
5
- if ( ! class_exists( 'RWMB_Text_List_Field' ) )
6
  {
7
- class RWMB_Text_List_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
12
- * @param string $html
13
- * @param mixed $meta
14
- * @param array $field
15
  *
16
  * @return string
17
  */
18
- static function html( $html, $meta, $field )
19
  {
20
- $meta = (array) $meta;
21
  $html = array();
22
  $tpl = '<label><input type="text" class="rwmb-text-list" name="%s" id="%s" value="%s" placeholder="%s"/> %s</label>';
23
 
@@ -44,19 +42,16 @@ if ( ! class_exists( 'RWMB_Text_List_Field' ) )
44
  *
45
  * TODO: A good way to ALWAYS save values in single entry in DB, while maintaining backward compatibility
46
  *
47
- * @param $meta
48
  * @param $post_id
49
  * @param $saved
50
  * @param $field
51
  *
52
  * @return array
53
  */
54
- static function meta( $meta, $post_id, $saved, $field )
55
  {
56
  $meta = get_post_meta( $post_id, $field['id'], $field['clone'] );
57
-
58
  $meta = ( !$saved && '' === $meta || array() === $meta ) ? $field['std'] : $meta;
59
-
60
  $meta = array_map( 'esc_attr', (array) $meta );
61
 
62
  return $meta;
@@ -78,7 +73,7 @@ if ( ! class_exists( 'RWMB_Text_List_Field' ) )
78
  {
79
  if ( !$field['clone'] )
80
  {
81
- RW_Meta_Box::save( $new, $old, $post_id, $field );
82
  return;
83
  }
84
 
@@ -97,7 +92,7 @@ if ( ! class_exists( 'RWMB_Text_List_Field' ) )
97
  */
98
  static function normalize_field( $field )
99
  {
100
- $field['multiple'] = true;
101
  $field['field_name'] = $field['id'];
102
  if ( !$field['clone'] )
103
  $field['field_name'] .= '[]';
2
  // Prevent loading this file directly
3
  defined( 'ABSPATH' ) || exit;
4
 
5
+ if ( !class_exists( 'RWMB_Text_List_Field' ) )
6
  {
7
+ class RWMB_Text_List_Field extends RWMB_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
12
+ * @param mixed $meta
13
+ * @param array $field
 
14
  *
15
  * @return string
16
  */
17
+ static function html( $meta, $field )
18
  {
 
19
  $html = array();
20
  $tpl = '<label><input type="text" class="rwmb-text-list" name="%s" id="%s" value="%s" placeholder="%s"/> %s</label>';
21
 
42
  *
43
  * TODO: A good way to ALWAYS save values in single entry in DB, while maintaining backward compatibility
44
  *
 
45
  * @param $post_id
46
  * @param $saved
47
  * @param $field
48
  *
49
  * @return array
50
  */
51
+ static function meta( $post_id, $saved, $field )
52
  {
53
  $meta = get_post_meta( $post_id, $field['id'], $field['clone'] );
 
54
  $meta = ( !$saved && '' === $meta || array() === $meta ) ? $field['std'] : $meta;
 
55
  $meta = array_map( 'esc_attr', (array) $meta );
56
 
57
  return $meta;
73
  {
74
  if ( !$field['clone'] )
75
  {
76
+ parent::save( $new, $old, $post_id, $field );
77
  return;
78
  }
79
 
92
  */
93
  static function normalize_field( $field )
94
  {
95
+ $field['multiple'] = true;
96
  $field['field_name'] = $field['id'];
97
  if ( !$field['clone'] )
98
  $field['field_name'] .= '[]';
inc/fields/text.php CHANGED
@@ -4,18 +4,17 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( ! class_exists( 'RWMB_Text_Field' ) )
6
  {
7
- class RWMB_Text_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
12
- * @param string $html
13
  * @param mixed $meta
14
  * @param array $field
15
  *
16
  * @return string
17
  */
18
- static function html( $html, $meta, $field )
19
  {
20
  return sprintf(
21
  '<input type="text" class="rwmb-text" name="%s" id="%s" value="%s" placeholder="%s" size="%s" %s>%s',
4
 
5
  if ( ! class_exists( 'RWMB_Text_Field' ) )
6
  {
7
+ class RWMB_Text_Field extends RWMB_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
 
12
  * @param mixed $meta
13
  * @param array $field
14
  *
15
  * @return string
16
  */
17
+ static function html( $meta, $field )
18
  {
19
  return sprintf(
20
  '<input type="text" class="rwmb-text" name="%s" id="%s" value="%s" placeholder="%s" size="%s" %s>%s',
inc/fields/textarea.php CHANGED
@@ -4,18 +4,17 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( ! class_exists( 'RWMB_Textarea_Field' ) )
6
  {
7
- class RWMB_Textarea_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
12
- * @param string $html
13
  * @param mixed $meta
14
  * @param array $field
15
  *
16
  * @return string
17
  */
18
- static function html( $html, $meta, $field )
19
  {
20
  return sprintf(
21
  '<textarea class="rwmb-textarea large-text" name="%s" id="%s" cols="%s" rows="%s" placeholder="%s">%s</textarea>',
4
 
5
  if ( ! class_exists( 'RWMB_Textarea_Field' ) )
6
  {
7
+ class RWMB_Textarea_Field extends RWMB_Field
8
  {
9
  /**
10
  * Get field HTML
11
  *
 
12
  * @param mixed $meta
13
  * @param array $field
14
  *
15
  * @return string
16
  */
17
+ static function html( $meta, $field )
18
  {
19
  return sprintf(
20
  '<textarea class="rwmb-textarea large-text" name="%s" id="%s" cols="%s" rows="%s" placeholder="%s">%s</textarea>',
inc/fields/thickbox-image.php CHANGED
@@ -24,13 +24,12 @@ if ( ! class_exists( 'RWMB_Thickbox_Image_Field' ) )
24
  /**
25
  * Get field HTML
26
  *
27
- * @param string $html
28
  * @param mixed $meta
29
  * @param array $field
30
  *
31
  * @return string
32
  */
33
- static function html( $html, $meta, $field )
34
  {
35
  $i18n_title = apply_filters( 'rwmb_thickbox_image_upload_string', _x( 'Upload Images', 'image upload', 'rwmb' ), $field );
36
 
24
  /**
25
  * Get field HTML
26
  *
 
27
  * @param mixed $meta
28
  * @param array $field
29
  *
30
  * @return string
31
  */
32
+ static function html( $meta, $field )
33
  {
34
  $i18n_title = apply_filters( 'rwmb_thickbox_image_upload_string', _x( 'Upload Images', 'image upload', 'rwmb' ), $field );
35
 
inc/fields/time.php CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( ! class_exists( 'RWMB_Time_Field' ) )
6
  {
7
- class RWMB_Time_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
@@ -33,13 +33,12 @@ if ( ! class_exists( 'RWMB_Time_Field' ) )
33
  /**
34
  * Get field HTML
35
  *
36
- * @param string $html
37
  * @param mixed $meta
38
  * @param array $field
39
  *
40
  * @return string
41
  */
42
- static function html( $html, $meta, $field )
43
  {
44
  return sprintf(
45
  '<input type="text" class="rwmb-time" name="%s" value="%s" id="%s" size="%s" data-options="%s" />',
4
 
5
  if ( ! class_exists( 'RWMB_Time_Field' ) )
6
  {
7
+ class RWMB_Time_Field extends RWMB_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
33
  /**
34
  * Get field HTML
35
  *
 
36
  * @param mixed $meta
37
  * @param array $field
38
  *
39
  * @return string
40
  */
41
+ static function html( $meta, $field )
42
  {
43
  return sprintf(
44
  '<input type="text" class="rwmb-time" name="%s" value="%s" id="%s" size="%s" data-options="%s" />',
inc/fields/url.php CHANGED
@@ -12,13 +12,12 @@ if ( ! class_exists( 'RWMB_URL_Field' ) )
12
  /**
13
  * Get field HTML
14
  *
15
- * @param string $html
16
  * @param mixed $meta
17
  * @param array $field
18
  *
19
  * @return string
20
  */
21
- static function html( $html, $meta, $field )
22
  {
23
  return sprintf(
24
  '<input type="url" class="rwmb-url" name="%s" id="%s" value="%s" size="%s" placeholder="%s"/>',
@@ -42,7 +41,7 @@ if ( ! class_exists( 'RWMB_URL_Field' ) )
42
  */
43
  static function value( $new, $old, $post_id, $field)
44
  {
45
- return esc_url( $new );
46
  }
47
  }
48
  }
12
  /**
13
  * Get field HTML
14
  *
 
15
  * @param mixed $meta
16
  * @param array $field
17
  *
18
  * @return string
19
  */
20
+ static function html( $meta, $field )
21
  {
22
  return sprintf(
23
  '<input type="url" class="rwmb-url" name="%s" id="%s" value="%s" size="%s" placeholder="%s"/>',
41
  */
42
  static function value( $new, $old, $post_id, $field)
43
  {
44
+ return is_array( $new ) ? array_map( 'esc_url', $new ) : esc_url( $new );
45
  }
46
  }
47
  }
inc/fields/wysiwyg.php CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) || exit;
4
 
5
  if ( !class_exists( 'RWMB_Wysiwyg_Field' ) )
6
  {
7
- class RWMB_Wysiwyg_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
@@ -34,13 +34,12 @@ if ( !class_exists( 'RWMB_Wysiwyg_Field' ) )
34
  /**
35
  * Get field HTML
36
  *
37
- * @param string $html
38
  * @param mixed $meta
39
  * @param array $field
40
  *
41
  * @return string
42
  */
43
- static function html( $html, $meta, $field )
44
  {
45
  // Using output buffering because wp_editor() echos directly
46
  ob_start();
4
 
5
  if ( !class_exists( 'RWMB_Wysiwyg_Field' ) )
6
  {
7
+ class RWMB_Wysiwyg_Field extends RWMB_Field
8
  {
9
  /**
10
  * Enqueue scripts and styles
34
  /**
35
  * Get field HTML
36
  *
 
37
  * @param mixed $meta
38
  * @param array $field
39
  *
40
  * @return string
41
  */
42
+ static function html( $meta, $field )
43
  {
44
  // Using output buffering because wp_editor() echos directly
45
  ob_start();
inc/helpers.php CHANGED
@@ -186,11 +186,13 @@ if ( ! class_exists( 'RWMB_Helper' ) )
186
  {
187
  $term_ids = array_map( 'intval', array_filter( explode( ',', $meta . ',' ) ) );
188
 
189
- $meta = array();
190
- foreach ( $term_ids as $term_id )
191
- {
192
- $meta[] = get_term( $term_id, $args['taxonomy'] );
193
- }
 
 
194
  }
195
  else
196
  {
@@ -293,10 +295,14 @@ if ( ! class_exists( 'RWMB_Helper' ) )
293
  $args = wp_parse_args( $args, array(
294
  'width' => '640px',
295
  'height' => '480px',
296
- 'zoom' => $parts[2], // Default to 'zoom' level set in admin, but can be overwritten
297
  'marker' => true, // Display marker?
298
  'marker_title' => '', // Marker title, when hover
299
  'info_window' => '', // Content of info window (when click on marker). HTML allowed
 
 
 
 
 
300
  ) );
301
 
302
  // Counter to display multiple maps on same page
@@ -319,14 +325,29 @@ if ( ! class_exists( 'RWMB_Helper' ) )
319
 
320
  $html .= sprintf( '
321
  var center = new google.maps.LatLng( %s, %s ),
322
- mapOptions = {
323
- center: center,
324
- zoom: %d,
325
- mapTypeId: google.maps.MapTypeId.ROADMAP
326
- },
327
- map = new google.maps.Map( document.getElementById( "rwmb-map-canvas-%d" ), mapOptions );',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  $parts[0], $parts[1],
329
- $args['zoom'],
330
  $counter
331
  );
332
 
186
  {
187
  $term_ids = array_map( 'intval', array_filter( explode( ',', $meta . ',' ) ) );
188
 
189
+ // Allow to pass more arguments to "get_terms"
190
+ $func_args = wp_parse_args( array(
191
+ 'include' => $term_ids,
192
+ 'hide_empty' => false,
193
+ ), $args );
194
+ unset( $func_args['type'], $func_args['taxonomy'], $func_args['multiple'] );
195
+ $meta = get_terms( $args['taxonomy'], $func_args );
196
  }
197
  else
198
  {
295
  $args = wp_parse_args( $args, array(
296
  'width' => '640px',
297
  'height' => '480px',
 
298
  'marker' => true, // Display marker?
299
  'marker_title' => '', // Marker title, when hover
300
  'info_window' => '', // Content of info window (when click on marker). HTML allowed
301
+ 'js_options' => array(),
302
+ ) );
303
+ $args['js_options'] = wp_parse_args( $args['js_options'], array(
304
+ 'zoom' => $parts[2], // Default to 'zoom' level set in admin, but can be overwritten
305
+ 'mapTypeId' => 'ROADMAP', // Map type, see https://developers.google.com/maps/documentation/javascript/reference#MapTypeId
306
  ) );
307
 
308
  // Counter to display multiple maps on same page
325
 
326
  $html .= sprintf( '
327
  var center = new google.maps.LatLng( %s, %s ),
328
+ mapOptions = %s,
329
+ map;
330
+
331
+ switch ( mapOptions.mapTypeId )
332
+ {
333
+ case "ROADMAP":
334
+ mapOptions.mapTypeId = google.maps.MapTypeId.ROADMAP;
335
+ break;
336
+ case "SATELLITE":
337
+ mapOptions.mapTypeId = google.maps.MapTypeId.SATELLITE;
338
+ break;
339
+ case "HYBRID":
340
+ mapOptions.mapTypeId = google.maps.MapTypeId.HYBRID;
341
+ break;
342
+ case "TERRAIN":
343
+ mapOptions.mapTypeId = google.maps.MapTypeId.TERRAIN;
344
+ break;
345
+ }
346
+ mapOptions.center = center;
347
+ map = new google.maps.Map( document.getElementById( "rwmb-map-canvas-%d" ), mapOptions );
348
+ ',
349
  $parts[0], $parts[1],
350
+ json_encode( $args['js_options'] ),
351
  $counter
352
  );
353
 
inc/meta-box.php CHANGED
@@ -36,6 +36,8 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
36
  */
37
  public $validation;
38
 
 
 
39
  /**
40
  * Create meta box based on given data
41
  *
@@ -72,9 +74,7 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
72
  $fields = self::get_fields( $this->fields );
73
  foreach ( $fields as $field )
74
  {
75
- $class = self::get_class_name( $field );
76
- if ( method_exists( $class, 'add_actions' ) )
77
- call_user_func( array( $class, 'add_actions' ) );
78
  }
79
 
80
  // Add meta box
@@ -117,9 +117,7 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
117
  $has_clone = true;
118
 
119
  // Enqueue scripts and styles for fields
120
- $class = self::get_class_name( $field );
121
- if ( method_exists( $class, 'admin_enqueue_scripts' ) )
122
- call_user_func( array( $class, 'admin_enqueue_scripts' ) );
123
  }
124
 
125
  if ( $has_clone )
@@ -228,8 +226,7 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
228
 
229
  foreach ( $this->fields as $field )
230
  {
231
- $meta = self::apply_field_filters( $field, 'meta', '', $post->ID, $saved );
232
- echo self::show_field( $field, $meta );
233
  }
234
 
235
  // Include validation settings for this meta-box
@@ -263,209 +260,6 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
263
  echo '</div>';
264
  }
265
 
266
-
267
- /**
268
- * Callback function to show fields in meta box
269
- *
270
- * @param array $field
271
- * @param string $meta
272
- *
273
- * @return string
274
- */
275
- static function show_field( $field, $meta = '' )
276
- {
277
- $group = ''; // Empty the clone-group field
278
- $type = $field['type'];
279
- $id = $field['id'];
280
-
281
- $meta = apply_filters( "rwmb_{$type}_meta", $meta );
282
- $meta = apply_filters( "rwmb_{$id}_meta", $meta );
283
-
284
- $begin = self::apply_field_filters( $field, 'begin_html', '', $meta );
285
-
286
- // Apply filter to field begin HTML
287
- // 1st filter applies to all fields
288
- // 2nd filter applies to all fields with the same type
289
- // 3rd filter applies to current field only
290
- $begin = apply_filters( 'rwmb_begin_html', $begin, $field, $meta );
291
- $begin = apply_filters( "rwmb_{$type}_begin_html", $begin, $field, $meta );
292
- $begin = apply_filters( "rwmb_{$id}_begin_html", $begin, $field, $meta );
293
-
294
- // Separate code for cloneable and non-cloneable fields to make easy to maintain
295
-
296
- // Cloneable fields
297
- if ( $field['clone'] )
298
- {
299
- if ( isset( $field['clone-group'] ) )
300
- $group = " clone-group='{$field['clone-group']}'";
301
-
302
- $meta = (array) $meta;
303
-
304
- $field_html = '';
305
-
306
- foreach ( $meta as $index => $meta_data )
307
- {
308
- $sub_field = $field;
309
- $sub_field['field_name'] = $field['field_name'] . "[{$index}]";
310
- if ( $field['multiple'] )
311
- $sub_field['field_name'] .= '[]';
312
-
313
- add_filter( "rwmb_{$id}_html", array( __CLASS__, 'add_clone_buttons' ), 10, 3 );
314
-
315
- // Wrap field HTML in a div with class="rwmb-clone" if needed
316
- $input_html = '<div class="rwmb-clone">';
317
-
318
- // Call separated methods for displaying each type of field
319
- $input_html .= self::apply_field_filters( $sub_field, 'html', '', $meta_data );
320
-
321
- // Apply filter to field HTML
322
- // 1st filter applies to all fields with the same type
323
- // 2nd filter applies to current field only
324
- $input_html = apply_filters( "rwmb_{$type}_html", $input_html, $field, $meta_data );
325
- $input_html = apply_filters( "rwmb_{$id}_html", $input_html, $field, $meta_data );
326
-
327
- $input_html .= '</div>';
328
-
329
- $field_html .= $input_html;
330
- }
331
- }
332
- // Non-cloneable fields
333
- else
334
- {
335
- // Call separated methods for displaying each type of field
336
- $field_html = self::apply_field_filters( $field, 'html', '', $meta );
337
-
338
- // Apply filter to field HTML
339
- // 1st filter applies to all fields with the same type
340
- // 2nd filter applies to current field only
341
- $field_html = apply_filters( "rwmb_{$type}_html", $field_html, $field, $meta );
342
- $field_html = apply_filters( "rwmb_{$id}_html", $field_html, $field, $meta );
343
- }
344
-
345
- $end = self::apply_field_filters( $field, 'end_html', '', $meta );
346
-
347
- // Apply filter to field end HTML
348
- // 1st filter applies to all fields
349
- // 2nd filter applies to all fields with the same type
350
- // 3rd filter applies to current field only
351
- $end = apply_filters( 'rwmb_end_html', $end, $field, $meta );
352
- $end = apply_filters( "rwmb_{$type}_end_html", $end, $field, $meta );
353
- $end = apply_filters( "rwmb_{$id}_end_html", $end, $field, $meta );
354
-
355
- // Apply filter to field wrapper
356
- // This allow users to change whole HTML markup of the field wrapper (i.e. table row)
357
- // 1st filter applies to all fields with the same type
358
- // 2nd filter applies to current field only
359
- $html = apply_filters( "rwmb_{$type}_wrapper_html", "{$begin}{$field_html}{$end}", $field, $meta );
360
- $html = apply_filters( "rwmb_{$id}_wrapper_html", $html, $field, $meta );
361
-
362
- // Display label and input in DIV and allow user-defined classes to be appended
363
- $classes = array( 'rwmb-field', "rwmb-{$field['type']}-wrapper" );
364
- if ( 'hidden' === $field['type'] )
365
- $classes[] = 'hidden';
366
- if ( !empty( $field['required'] ) )
367
- $classes[] = 'required';
368
- if ( !empty( $field['class'] ) )
369
- $classes[] = $field['class'];
370
-
371
- return sprintf(
372
- $field['before'] . '<div class="%s"%s>%s</div>' . $field['after'],
373
- implode( ' ', $classes ),
374
- $group,
375
- $html
376
- );
377
- }
378
-
379
- /**
380
- * Show begin HTML markup for fields
381
- *
382
- * @param string $html
383
- * @param mixed $meta
384
- * @param array $field
385
- *
386
- * @return string
387
- */
388
- static function begin_html( $html, $meta, $field )
389
- {
390
- if ( empty( $field['name'] ) )
391
- return '<div class="rwmb-input">';
392
-
393
- return sprintf(
394
- '<div class="rwmb-label">
395
- <label for="%s">%s</label>
396
- </div>
397
- <div class="rwmb-input">',
398
- $field['id'],
399
- $field['name']
400
- );
401
- }
402
-
403
- /**
404
- * Show end HTML markup for fields
405
- *
406
- * @param string $html
407
- * @param mixed $meta
408
- * @param array $field
409
- *
410
- * @return string
411
- */
412
- static function end_html( $html, $meta, $field )
413
- {
414
- $id = $field['id'];
415
-
416
- $button = '';
417
- if ( $field['clone'] )
418
- $button = '<a href="#" class="rwmb-button button-primary add-clone">' . __( '+', 'rwmb' ) . '</a>';
419
-
420
- $desc = ! empty( $field['desc'] ) ? "<p id='{$id}_description' class='description'>{$field['desc']}</p>" : '';
421
-
422
- // Closes the container
423
- $html = "{$button}{$desc}</div>";
424
-
425
- return $html;
426
- }
427
-
428
- /**
429
- * Callback function to add clone buttons on demand
430
- * Hooks on the flight into the "rwmb_{$field_id}_html" filter before the closing div
431
- *
432
- * @param string $html
433
- * @param array $field
434
- * @param mixed $meta_data
435
- *
436
- * @return string $html
437
- */
438
- static function add_clone_buttons( $html, $field, $meta_data )
439
- {
440
- $button = '<a href="#" class="rwmb-button button remove-clone">' . __( '&#8211;', 'rwmb' ) . '</a>';
441
-
442
- return "{$html}{$button}";
443
- }
444
-
445
- /**
446
- * Standard meta retrieval
447
- *
448
- * @param mixed $meta
449
- * @param int $post_id
450
- * @param array $field
451
- * @param bool $saved
452
- *
453
- * @return mixed
454
- */
455
- static function meta( $meta, $post_id, $saved, $field )
456
- {
457
- $meta = get_post_meta( $post_id, $field['id'], !$field['multiple'] );
458
-
459
- // Use $field['std'] only when the meta box hasn't been saved (i.e. the first time we run)
460
- $meta = ( !$saved && '' === $meta || array() === $meta ) ? $field['std'] : $meta;
461
-
462
- // Escape attributes for non-wysiwyg fields
463
- if ( 'wysiwyg' !== $field['type'] )
464
- $meta = is_array( $meta ) ? array_map( 'esc_attr', $meta ) : esc_attr( $meta );
465
-
466
- return $meta;
467
- }
468
-
469
  /**************************************************
470
  SAVE META BOX
471
  **************************************************/
@@ -479,6 +273,11 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
479
  */
480
  function save_post( $post_id )
481
  {
 
 
 
 
 
482
  // Check whether form is submitted properly
483
  $id = $this->meta_box['id'];
484
  if ( empty( $_POST["nonce_{$id}"] ) || !wp_verify_nonce( $_POST["nonce_{$id}"], "rwmb-save-{$id}" ) )
@@ -492,9 +291,6 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
492
  if ( $the_post = wp_is_post_revision( $post_id ) )
493
  $post_id = $the_post;
494
 
495
- // Save post action removed to prevent infinite loops
496
- remove_action( 'save_post', array( $this, 'save_post' ) );
497
-
498
  // Before save action
499
  do_action( 'rwmb_before_save_post', $post_id );
500
  do_action( "rwmb_{$this->meta_box['id']}_before_save_post", $post_id );
@@ -506,7 +302,7 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
506
  $new = isset( $_POST[$name] ) ? $_POST[$name] : ( $field['multiple'] ? array() : '' );
507
 
508
  // Allow field class change the value
509
- $new = self::apply_field_filters( $field, 'value', $new, $old, $post_id );
510
 
511
  // Use filter to change field value
512
  // 1st filter applies to all fields with the same type
@@ -515,63 +311,15 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
515
  $new = apply_filters( "rwmb_{$name}_value", $new, $field, $old );
516
 
517
  // Call defined method to save meta value, if there's no methods, call common one
518
- self::do_field_actions( $field, 'save', $new, $old, $post_id );
519
  }
520
 
521
  // After save action
522
  do_action( 'rwmb_after_save_post', $post_id );
523
  do_action( "rwmb_{$this->meta_box['id']}_after_save_post", $post_id );
524
 
525
- // Reinstate save_post action
526
- add_action( 'save_post', array( $this, 'save_post' ) );
527
- }
528
-
529
- /**
530
- * Common functions for saving field
531
- *
532
- * @param mixed $new
533
- * @param mixed $old
534
- * @param int $post_id
535
- * @param array $field
536
- *
537
- * @return void
538
- */
539
- static function save( $new, $old, $post_id, $field )
540
- {
541
- $name = $field['id'];
542
-
543
- if ( '' === $new || array() === $new )
544
- {
545
- delete_post_meta( $post_id, $name );
546
- return;
547
- }
548
-
549
- if ( $field['multiple'] )
550
- {
551
- foreach ( $new as $new_value )
552
- {
553
- if ( !in_array( $new_value, $old ) )
554
- add_post_meta( $post_id, $name, $new_value, false );
555
- }
556
- foreach ( $old as $old_value )
557
- {
558
- if ( !in_array( $old_value, $new ) )
559
- delete_post_meta( $post_id, $name, $old_value );
560
- }
561
- }
562
- else
563
- {
564
- if ( $field['clone'] )
565
- {
566
- $new = (array) $new;
567
- foreach ( $new as $k => $v )
568
- {
569
- if ( '' === $v )
570
- unset( $new[$k] );
571
- }
572
- }
573
- update_post_meta( $post_id, $name, $new );
574
- }
575
  }
576
 
577
  /**************************************************
@@ -628,7 +376,7 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
628
  ) );
629
 
630
  // Allow field class add/change default field values
631
- $field = self::apply_field_filters( $field, 'normalize_field', $field );
632
 
633
  if ( isset( $field['fields'] ) )
634
  $field['fields'] = self::normalize_fields( $field['fields'] );
@@ -646,50 +394,20 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
646
  */
647
  static function get_class_name( $field )
648
  {
649
- $class = 'RWMB_' . ucwords( $field['type'] ) . '_Field';
650
- if ( class_exists( $class ) )
651
- return $class;
652
 
653
- return false;
654
- }
655
 
656
- /**
657
- * Apply filters by field class, fallback to RW_Meta_Box method
658
- *
659
- * @param array $field
660
- * @param string $method
661
- * @param mixed $value
662
- *
663
- * @return mixed $value
664
- */
665
- static function apply_field_filters( $field, $method, $value )
666
- {
667
- $args = array_slice( func_get_args(), 2 );
668
- $args[] = $field;
669
-
670
- // Call: field class method
671
- // Fallback: RW_Meta_Box method
672
- $class = self::get_class_name( $field );
673
- if ( method_exists( $class, $method ) )
674
- $value = call_user_func_array( array( $class, $method ), $args );
675
- elseif ( method_exists( __CLASS__, $method ) )
676
- $value = call_user_func_array( array( __CLASS__, $method ), $args );
677
-
678
- return $value;
679
- }
680
 
681
- /**
682
- * Call field class method for actions, fallback to RW_Meta_Box method
683
- *
684
- * @param array $field
685
- * @param string $method
686
- *
687
- * @return mixed
688
- */
689
- static function do_field_actions( $field, $method )
690
- {
691
- $args = func_get_args();
692
- call_user_func_array( array( __CLASS__, 'apply_field_filters' ), $args );
693
  }
694
 
695
  /**
36
  */
37
  public $validation;
38
 
39
+ public $saved = false;
40
+
41
  /**
42
  * Create meta box based on given data
43
  *
74
  $fields = self::get_fields( $this->fields );
75
  foreach ( $fields as $field )
76
  {
77
+ call_user_func( array( self::get_class_name( $field ), 'add_actions' ) );
 
 
78
  }
79
 
80
  // Add meta box
117
  $has_clone = true;
118
 
119
  // Enqueue scripts and styles for fields
120
+ call_user_func( array( self::get_class_name( $field ), 'admin_enqueue_scripts' ) );
 
 
121
  }
122
 
123
  if ( $has_clone )
226
 
227
  foreach ( $this->fields as $field )
228
  {
229
+ call_user_func( array( self::get_class_name( $field ), 'show' ), $field, $saved );
 
230
  }
231
 
232
  // Include validation settings for this meta-box
260
  echo '</div>';
261
  }
262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  /**************************************************
264
  SAVE META BOX
265
  **************************************************/
273
  */
274
  function save_post( $post_id )
275
  {
276
+ // Check if this function is called to prevent duplicated calls like revisions, manual hook to wp_insert_post, etc.
277
+ if ( $this->saved === true )
278
+ return;
279
+ $this->saved = true;
280
+
281
  // Check whether form is submitted properly
282
  $id = $this->meta_box['id'];
283
  if ( empty( $_POST["nonce_{$id}"] ) || !wp_verify_nonce( $_POST["nonce_{$id}"], "rwmb-save-{$id}" ) )
291
  if ( $the_post = wp_is_post_revision( $post_id ) )
292
  $post_id = $the_post;
293
 
 
 
 
294
  // Before save action
295
  do_action( 'rwmb_before_save_post', $post_id );
296
  do_action( "rwmb_{$this->meta_box['id']}_before_save_post", $post_id );
302
  $new = isset( $_POST[$name] ) ? $_POST[$name] : ( $field['multiple'] ? array() : '' );
303
 
304
  // Allow field class change the value
305
+ $new = call_user_func( array( self::get_class_name( $field ), 'value' ), $new, $old, $post_id, $field );
306
 
307
  // Use filter to change field value
308
  // 1st filter applies to all fields with the same type
311
  $new = apply_filters( "rwmb_{$name}_value", $new, $field, $old );
312
 
313
  // Call defined method to save meta value, if there's no methods, call common one
314
+ call_user_func( array( self::get_class_name( $field ), 'save' ), $new, $old, $post_id, $field );
315
  }
316
 
317
  // After save action
318
  do_action( 'rwmb_after_save_post', $post_id );
319
  do_action( "rwmb_{$this->meta_box['id']}_after_save_post", $post_id );
320
 
321
+ // Done saving post meta
322
+ $called = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  }
324
 
325
  /**************************************************
376
  ) );
377
 
378
  // Allow field class add/change default field values
379
+ $field = call_user_func( array( self::get_class_name( $field ), 'normalize_field' ), $field );
380
 
381
  if ( isset( $field['fields'] ) )
382
  $field['fields'] = self::normalize_fields( $field['fields'] );
394
  */
395
  static function get_class_name( $field )
396
  {
 
 
 
397
 
398
+ // Convert underscores to whitespace so ucwords works as expected. Otherwise: plupload_image -> Plupload_image instead of Plupload_Image
399
+ $_type = str_replace( '_', ' ', $field['type'] );
400
 
401
+ // Uppercase first words
402
+ $class = 'RWMB_' . ucwords( $_type ) . '_Field';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
403
 
404
+ // Relace whitespace with underscores
405
+ $class = str_replace( ' ', '_', $class );
406
+
407
+ if ( class_exists( $class ) )
408
+ return $class;
409
+
410
+ return false;
 
 
 
 
 
411
  }
412
 
413
  /**
js/file-input.js ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( function( $ )
2
+ {
3
+ var frame;
4
+
5
+ $( 'body' ).on( 'click', '.rwmb-file-input-select', function( e )
6
+ {
7
+ e.preventDefault();
8
+ var $el = $( this );
9
+
10
+ // Create a frame only if needed
11
+ if ( !frame )
12
+ {
13
+ frame = wp.media( {
14
+ className: 'media-frame rwmb-file-frame',
15
+ multiple: false,
16
+ title: rwmbFileInput.frameTitle
17
+ } );
18
+ }
19
+
20
+ // Open media uploader
21
+ frame.open();
22
+
23
+ // Remove all attached 'select' event
24
+ frame.off( 'select' );
25
+
26
+ // Handle selection
27
+ frame.on( 'select', function()
28
+ {
29
+ var url = frame.state().get( 'selection' ).first().toJSON().url;
30
+ $el.siblings( 'input' ).val( url ).siblings( 'a' ).removeClass( 'hidden' );
31
+ } );
32
+ } );
33
+
34
+ // Clear selected images
35
+ $( 'body' ).on( 'click', '.rwmb-file-input-remove', function ( e )
36
+ {
37
+ e.preventDefault();
38
+ $( this ).addClass( 'hidden' ).siblings( 'input' ).val( '' );
39
+ } );
40
+ } );
js/image-select.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( function( $ )
2
+ {
3
+ $( 'body' ).on( 'change', '.rwmb-image-select input', function()
4
+ {
5
+ var $this = $( this ),
6
+ type = $this.attr( 'type' ),
7
+ selected = $this.is( ':checked' ),
8
+ $parent = $this.parent(),
9
+ $others = $parent.siblings();
10
+ if ( selected )
11
+ {
12
+ $parent.addClass( 'rwmb-active' );
13
+ type == 'radio' && $others.removeClass( 'rwmb-active' );
14
+ }
15
+ else
16
+ {
17
+ $parent.removeClass( 'rwmb-active' );
18
+ }
19
+ } );
20
+ $( '.rwmb-image-select input' ).trigger( 'change' );
21
+ } );
js/map.js CHANGED
@@ -179,6 +179,8 @@
179
  {
180
  var field = new mapField( $( this ) );
181
  field.init();
 
 
182
  } );
183
  } );
184
 
179
  {
180
  var field = new mapField( $( this ) );
181
  field.init();
182
+
183
+ $( this ).data('mapController', field);
184
  } );
185
  } );
186
 
js/plupload-image.js CHANGED
@@ -53,7 +53,7 @@ jQuery( function( $ )
53
  }
54
 
55
  // Hide drag & drop section if reach max file uploads
56
- if ( uploaded + files.length >= maxFileUploads )
57
  $dropArea.addClass( 'hidden' );
58
 
59
  max = parseInt( up.settings.max_file_size, 10 );
53
  }
54
 
55
  // Hide drag & drop section if reach max file uploads
56
+ if ( maxFileUploads > 0 && uploaded + files.length >= maxFileUploads )
57
  $dropArea.addClass( 'hidden' );
58
 
59
  max = parseInt( up.settings.max_file_size, 10 );
js/slider.js CHANGED
@@ -1,12 +1,17 @@
1
  jQuery( function( $ )
2
  {
3
- $( '.rwmb-slider' ).each( function()
 
 
 
4
  {
5
- var $this = $( this ),
6
- $input = $this.siblings( 'input' ),
7
- $valueLabel = $this.siblings( '.rwmb-slider-value-label' ).find( 'span' ),
8
  value = $input.val(),
9
- options = $this.data( 'options' );
 
 
10
 
11
  if ( !value )
12
  {
@@ -27,6 +32,6 @@ jQuery( function( $ )
27
  $valueLabel.text( ui.value );
28
  };
29
 
30
- $this.slider( options );
31
- } );
32
  } );
1
  jQuery( function( $ )
2
  {
3
+ $( ':input.rwmb-slider-value' ).each( rwmb_update_slider );
4
+ $( '.rwmb-input' ).on( 'clone', ':input.rwmb-slider-value', rwmb_update_slider );
5
+
6
+ function rwmb_update_slider()
7
  {
8
+ var $input = $( this ),
9
+ $slider = $input.siblings( '.rwmb-slider' ),
10
+ $valueLabel = $slider.siblings( '.rwmb-slider-value-label' ).find( 'span' ),
11
  value = $input.val(),
12
+ options = $slider.data( 'options' );
13
+
14
+ $slider.html( '' );
15
 
16
  if ( !value )
17
  {
32
  $valueLabel.text( ui.value );
33
  };
34
 
35
+ $slider.slider( options );
36
+ }
37
  } );
lang/zh_CN.mo ADDED
Binary file
lang/zh_CN.po ADDED
@@ -0,0 +1,384 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Meta Box Script For WordPress\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2013-06-03 22:19+0700\n"
6
+ "PO-Revision-Date: 2013-11-25 12:07+0800\n"
7
+ "Last-Translator: Amos Lee <iwillhappy1314@gmail.com>\n"
8
+ "Language-Team: Rilwis <rilwis@gmail.com>\n"
9
+ "Language: en_EN\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Poedit-KeywordsList: __;_e;_x:2c,1;_n:1,2;_n_noop:1,2;_nx:1,2;"
14
+ "_nx_noop:1,2\n"
15
+ "X-Poedit-Basepath: .\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
+ "X-Generator: Poedit 1.5.7\n"
18
+ "X-Poedit-SearchPath-0: ..\n"
19
+ "X-Poedit-SearchPath-1: ../inc/fields\n"
20
+
21
+ #: ../demo/all-custom-post-types.php:20
22
+ msgid "Personal Information"
23
+ msgstr "个人信息"
24
+
25
+ #: ../demo/all-custom-post-types.php:25
26
+ msgid "Full name"
27
+ msgstr "全名"
28
+
29
+ #: ../demo/better-include.php:16 ../demo/include-by-ID-or-page-template.php:8
30
+ msgid "Meta Box Title"
31
+ msgstr "元数据盒子标题"
32
+
33
+ #: ../demo/better-include.php:19 ../demo/include-by-ID-or-page-template.php:14
34
+ msgid "Your images"
35
+ msgstr "你的图片"
36
+
37
+ #: ../demo/date-time-js-options.php:11
38
+ msgid "Date Time Picker With JS Options"
39
+ msgstr "日期时间选择"
40
+
41
+ #: ../demo/date-time-js-options.php:15
42
+ msgid "Date"
43
+ msgstr "日期"
44
+
45
+ #: ../demo/date-time-js-options.php:21 ../demo/demo.php:177
46
+ msgid "(yyyy-mm-dd)"
47
+ msgstr "(yyyy-mm-dd)"
48
+
49
+ #: ../demo/date-time-js-options.php:23
50
+ msgid "Select Date"
51
+ msgstr "选择日期"
52
+
53
+ #: ../demo/date-time-js-options.php:24 ../demo/demo.php:178
54
+ msgid "yy-mm-dd"
55
+ msgstr "yy-mm-dd"
56
+
57
+ #: ../demo/date-time-js-options.php:30
58
+ msgid "Datetime"
59
+ msgstr "日期时间"
60
+
61
+ #: ../demo/date-time-js-options.php:41
62
+ msgid "Time"
63
+ msgstr "时间"
64
+
65
+ #: ../demo/demo.php:34
66
+ msgid "Standard Fields"
67
+ msgstr "标准字段"
68
+
69
+ #: ../demo/demo.php:53
70
+ msgid "Text"
71
+ msgstr "文本"
72
+
73
+ #: ../demo/demo.php:57
74
+ msgid "Text description"
75
+ msgstr "文本描述"
76
+
77
+ #: ../demo/demo.php:60
78
+ msgid "Default text value"
79
+ msgstr "默认文本值"
80
+
81
+ #: ../demo/demo.php:66
82
+ msgid "Checkbox"
83
+ msgstr "多选"
84
+
85
+ #: ../demo/demo.php:74
86
+ msgid "Radio"
87
+ msgstr "单选"
88
+
89
+ #: ../demo/demo.php:80 ../demo/demo.php:91 ../demo/demo.php:226
90
+ msgid "Label1"
91
+ msgstr "标签1"
92
+
93
+ #: ../demo/demo.php:81 ../demo/demo.php:92 ../demo/demo.php:227
94
+ msgid "Label2"
95
+ msgstr "标签1"
96
+
97
+ #: ../demo/demo.php:86
98
+ msgid "Select"
99
+ msgstr "选择"
100
+
101
+ #: ../demo/demo.php:96
102
+ msgid "Select an Item"
103
+ msgstr "选择一项"
104
+
105
+ #: ../demo/demo.php:103
106
+ msgid "Hidden value"
107
+ msgstr "隐藏值"
108
+
109
+ #: ../demo/demo.php:107
110
+ msgid "Password"
111
+ msgstr "米秒"
112
+
113
+ #: ../demo/demo.php:113
114
+ msgid "Textarea"
115
+ msgstr "文本段落"
116
+
117
+ #: ../demo/demo.php:114
118
+ msgid "Textarea description"
119
+ msgstr "段落描述"
120
+
121
+ #: ../demo/demo.php:131
122
+ msgid "Password is required"
123
+ msgstr "密码为必填项"
124
+
125
+ #: ../demo/demo.php:132
126
+ msgid "Password must be at least 7 characters"
127
+ msgstr "密码至少为7个字符"
128
+
129
+ #: ../demo/demo.php:140
130
+ msgid "Advanced Fields"
131
+ msgstr "高级字段"
132
+
133
+ #: ../demo/demo.php:145
134
+ msgid "Slider"
135
+ msgstr "滑块"
136
+
137
+ #: ../demo/demo.php:150
138
+ msgid "$"
139
+ msgstr "$"
140
+
141
+ #: ../demo/demo.php:151
142
+ msgid " USD"
143
+ msgstr "USD"
144
+
145
+ #: ../demo/demo.php:162
146
+ msgid "Number"
147
+ msgstr "数字"
148
+
149
+ #: ../demo/demo.php:171
150
+ msgid "Date picker"
151
+ msgstr "日期选择器"
152
+
153
+ #: ../demo/demo.php:186
154
+ msgid "Datetime picker"
155
+ msgstr "日期时间选择器"
156
+
157
+ #: ../demo/demo.php:200
158
+ msgid "Time picker"
159
+ msgstr "时间选择器"
160
+
161
+ #: ../demo/demo.php:215
162
+ msgid "Color picker"
163
+ msgstr "颜色选择器"
164
+
165
+ #: ../demo/demo.php:221
166
+ msgid "Checkbox list"
167
+ msgstr "选择列表"
168
+
169
+ #: ../demo/demo.php:232
170
+ msgid "Email"
171
+ msgstr "邮件"
172
+
173
+ #: ../demo/demo.php:234
174
+ msgid "Email description"
175
+ msgstr "邮件描述"
176
+
177
+ #: ../demo/demo.php:240
178
+ msgid "Range"
179
+ msgstr "区间"
180
+
181
+ #: ../demo/demo.php:242
182
+ msgid "Range description"
183
+ msgstr "区间描述"
184
+
185
+ #: ../demo/demo.php:251
186
+ msgid "URL"
187
+ msgstr "URL"
188
+
189
+ #: ../demo/demo.php:253
190
+ msgid "URL description"
191
+ msgstr "URL描述"
192
+
193
+ #: ../demo/demo.php:259
194
+ msgid "oEmbed"
195
+ msgstr "oEmbed嵌入"
196
+
197
+ #: ../demo/demo.php:261
198
+ msgid "oEmbed description"
199
+ msgstr "oEmbed嵌入描述"
200
+
201
+ #: ../demo/demo.php:266
202
+ msgid "Taxonomy"
203
+ msgstr "分类法"
204
+
205
+ #: ../demo/demo.php:280
206
+ msgid "Posts (Pages)"
207
+ msgstr "文章(页面)"
208
+
209
+ #: ../demo/demo.php:296
210
+ msgid "WYSIWYG / Rich Text Editor"
211
+ msgstr "可视化编辑器"
212
+
213
+ #: ../demo/demo.php:301
214
+ msgid "WYSIWYG default value"
215
+ msgstr "可视化编辑器默认值"
216
+
217
+ #: ../demo/demo.php:312 ../demo/force-delete.php:15
218
+ msgid "File Upload"
219
+ msgstr "文件上传"
220
+
221
+ #: ../demo/demo.php:318
222
+ msgid "File Advanced Upload"
223
+ msgstr "高级文件上传"
224
+
225
+ #: ../demo/demo.php:326 ../demo/force-delete.php:22
226
+ msgid "Image Upload"
227
+ msgstr "图片上选"
228
+
229
+ #: ../demo/demo.php:332 ../demo/force-delete.php:28
230
+ msgid "Thickbox Image Upload"
231
+ msgstr "默认上传"
232
+
233
+ #: ../demo/demo.php:338 ../demo/force-delete.php:35
234
+ msgid "Plupload Image Upload"
235
+ msgstr "拖拽上传"
236
+
237
+ #: ../demo/demo.php:345
238
+ msgid "Image Advanced Upload"
239
+ msgstr "图片高级上传"
240
+
241
+ #: ../demo/force-delete.php:11
242
+ msgid "Test Meta Box"
243
+ msgstr "测试元数据盒子"
244
+
245
+ #: ../demo/map.php:9
246
+ msgid "Google Map"
247
+ msgstr "谷歌地图"
248
+
249
+ #: ../demo/map.php:13
250
+ msgid "Address"
251
+ msgstr "地址"
252
+
253
+ #: ../demo/map.php:15
254
+ msgid "Hanoi, Vietnam"
255
+ msgstr "河南,郑州"
256
+
257
+ #: ../demo/map.php:19
258
+ msgid "Location"
259
+ msgstr "位置"
260
+
261
+ #: ../inc/classes/meta-box.php:220
262
+ msgid "Please correct the errors highlighted below and try again."
263
+ msgstr "请检查并修正高亮错误处,然后重试 。"
264
+
265
+ #: ../inc/classes/meta-box.php:394
266
+ msgid "+"
267
+ msgstr "+"
268
+
269
+ #: ../inc/classes/meta-box.php:416
270
+ msgid "&#8211;"
271
+ msgstr "&#8211;"
272
+
273
+ #: ../inc/fields/file-advanced.php:23
274
+ #, php-format
275
+ msgid "You may only upload maximum %d file"
276
+ msgstr "最多能上传%d 个文件"
277
+
278
+ #: ../inc/fields/file-advanced.php:24
279
+ #, php-format
280
+ msgid "You may only upload maximum %d files"
281
+ msgstr "最多能上传%d 个文件"
282
+
283
+ #: ../inc/fields/file-advanced.php:25
284
+ msgid "Select Files"
285
+ msgstr "选择文件"
286
+
287
+ #: ../inc/fields/file-advanced.php:68
288
+ msgctxt "file upload"
289
+ msgid "Select or Upload Files"
290
+ msgstr "选择或上传文件"
291
+
292
+ #: ../inc/fields/file-advanced.php:104 ../inc/fields/file.php:133
293
+ msgctxt "file upload"
294
+ msgid "Delete"
295
+ msgstr "删除【上传文件】"
296
+
297
+ #: ../inc/fields/file-advanced.php:105 ../inc/fields/file.php:134
298
+ msgctxt "file upload"
299
+ msgid "Edit"
300
+ msgstr "编辑【上传文件】"
301
+
302
+ #: ../inc/fields/file.php:66
303
+ msgid "Error: Cannot delete file"
304
+ msgstr "错误:不能删除文件"
305
+
306
+ #: ../inc/fields/file.php:80
307
+ msgctxt "file upload"
308
+ msgid "Upload Files"
309
+ msgstr "上传文件"
310
+
311
+ #: ../inc/fields/file.php:81
312
+ msgctxt "file upload"
313
+ msgid "+ Add new file"
314
+ msgstr "+ 添加新文件"
315
+
316
+ #: ../inc/fields/image-advanced.php:22
317
+ msgid "Select Images"
318
+ msgstr "选择图片"
319
+
320
+ #: ../inc/fields/image-advanced.php:71
321
+ msgctxt "image upload"
322
+ msgid "Select or Upload Images"
323
+ msgstr "选择或上传图片"
324
+
325
+ #: ../inc/fields/image-advanced.php:107 ../inc/fields/image.php:144
326
+ msgctxt "image upload"
327
+ msgid "Delete"
328
+ msgstr "删除"
329
+
330
+ #: ../inc/fields/image-advanced.php:108 ../inc/fields/image.php:145
331
+ msgctxt "image upload"
332
+ msgid "Edit"
333
+ msgstr "编辑"
334
+
335
+ #: ../inc/fields/image.php:64
336
+ msgid "Order saved"
337
+ msgstr "排序已保存"
338
+
339
+ #: ../inc/fields/image.php:78 ../inc/fields/thickbox-image.php:35
340
+ msgctxt "image upload"
341
+ msgid "Upload Images"
342
+ msgstr "上传图像"
343
+
344
+ #: ../inc/fields/image.php:79
345
+ msgctxt "image upload"
346
+ msgid "+ Add new image"
347
+ msgstr "+ 添加新图像"
348
+
349
+ #: ../inc/fields/map.php:48
350
+ msgid "Find Address"
351
+ msgstr "查找地址"
352
+
353
+ #: ../inc/fields/plupload-image.php:104
354
+ msgctxt "image upload"
355
+ msgid "Drop images here"
356
+ msgstr "拖放图像到这里"
357
+
358
+ #: ../inc/fields/plupload-image.php:105
359
+ msgctxt "image upload"
360
+ msgid "or"
361
+ msgstr "或"
362
+
363
+ #: ../inc/fields/plupload-image.php:106
364
+ msgctxt "image upload"
365
+ msgid "Select Files"
366
+ msgstr "选择文件"
367
+
368
+ #: ../inc/fields/plupload-image.php:181
369
+ msgctxt "image upload"
370
+ msgid "Allowed Image Files"
371
+ msgstr "选择图像文件"
372
+
373
+ #: ../inc/fields/post.php:54
374
+ msgid "Post"
375
+ msgstr "文章"
376
+
377
+ #: ../inc/fields/post.php:68 ../inc/fields/taxonomy.php:40
378
+ #, php-format
379
+ msgid "Select a %s"
380
+ msgstr "选择%s"
381
+
382
+ #: ../inc/fields/select-advanced.php:71
383
+ msgid "Select a value"
384
+ msgstr "选择值"
meta-box.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Meta Box
4
  Plugin URI: http://www.deluxeblogtips.com/meta-box
5
  Description: Create meta box for editing pages in WordPress. Compatible with custom post types since WP 3.0
6
- Version: 4.3.6
7
  Author: Rilwis
8
  Author URI: http://www.deluxeblogtips.com
9
  License: GPL2+
@@ -13,7 +13,7 @@ License: GPL2+
13
  defined( 'ABSPATH' ) || exit;
14
 
15
  // Script version, used to add version for scripts and styles
16
- define( 'RWMB_VER', '4.3.4' );
17
 
18
  // Define plugin URLs, for fast enqueuing scripts and styles
19
  if ( ! defined( 'RWMB_URL' ) )
@@ -36,6 +36,7 @@ require_once RWMB_INC_DIR . 'helpers.php';
36
  if ( is_admin() )
37
  {
38
  require_once RWMB_INC_DIR . 'common.php';
 
39
 
40
  // Field classes
41
  foreach ( glob( RWMB_FIELDS_DIR . '*.php' ) as $file )
3
  Plugin Name: Meta Box
4
  Plugin URI: http://www.deluxeblogtips.com/meta-box
5
  Description: Create meta box for editing pages in WordPress. Compatible with custom post types since WP 3.0
6
+ Version: 4.3.7
7
  Author: Rilwis
8
  Author URI: http://www.deluxeblogtips.com
9
  License: GPL2+
13
  defined( 'ABSPATH' ) || exit;
14
 
15
  // Script version, used to add version for scripts and styles
16
+ define( 'RWMB_VER', '4.3.7' );
17
 
18
  // Define plugin URLs, for fast enqueuing scripts and styles
19
  if ( ! defined( 'RWMB_URL' ) )
36
  if ( is_admin() )
37
  {
38
  require_once RWMB_INC_DIR . 'common.php';
39
+ require_once RWMB_INC_DIR . 'field.php';
40
 
41
  // Field classes
42
  foreach ( glob( RWMB_FIELDS_DIR . '*.php' ) as $file )
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: rilwis, franz-josef-kaiser, Omnicia, funkedgeek, PerWiklander, rua
3
  Donate link: http://www.deluxeblogtips.com/donate
4
  Tags: meta-box, custom-fields, custom-field, meta, meta-boxes
5
  Requires at least: 3.5
6
- Tested up to: 3.6.1
7
- Stable tag: 4.3.6
8
 
9
  Meta Box plugin helps you easily implement multiple meta boxes in editing pages in WordPress. Works with custom post types and various field types.
10
 
@@ -25,10 +25,10 @@ Meta Box plugin provides an API to easily implement custom meta boxes in editing
25
  - color
26
  - date, time, datetime
27
  - divider
28
- - file, file_advanced
29
  - heading
30
  - hidden
31
- - image, thickbox_image, plupload_image, image_advanced
32
  - map
33
  - password
34
  - post
@@ -58,6 +58,21 @@ To getting started with the plugin API, please read [this tutorial](http://www.d
58
 
59
  == Changelog ==
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  = 4.3.6 =
62
  * Bug fix: fatal error in PHP 5.2 (continue)
63
  * Improvement: allow register meta boxes via filter
3
  Donate link: http://www.deluxeblogtips.com/donate
4
  Tags: meta-box, custom-fields, custom-field, meta, meta-boxes
5
  Requires at least: 3.5
6
+ Tested up to: 3.8
7
+ Stable tag: 4.3.7
8
 
9
  Meta Box plugin helps you easily implement multiple meta boxes in editing pages in WordPress. Works with custom post types and various field types.
10
 
25
  - color
26
  - date, time, datetime
27
  - divider
28
+ - file, file_advanced, file_input (allow to upload or paste file URL)
29
  - heading
30
  - hidden
31
+ - image, thickbox_image, plupload_image, image_advanced, image_select (or radio image)
32
  - map
33
  - password
34
  - post
58
 
59
  == Changelog ==
60
 
61
+ = 4.3.7 =
62
+ * Bug fix: use WP_Query instead of `query_posts` to be compatible with WPML
63
+ * Bug fix: `get_called_class` function in PHP < 5.3
64
+ * Bug fix: clone now works for `slider` field
65
+ * Bug fix: fix cloning URL field
66
+ * Bug fix: hidden drop area if no max_file_uploads defined
67
+ * Improvement: added composer.json
68
+ * Improvement: add Chinese language
69
+ * Improvement: better check for duplication when save post
70
+ * Improvement: new `image_select` file, which is "radio image", e.g. select a radio value by selecting image
71
+ * Improvement: new `file_input` field, which allows to upload files or enter file URL
72
+ * Improvement: separate core code for meta box and fields
73
+ * Improvement: allow to add more map options in helper function
74
+ * Improvement: allow to pass more arguments to "get_terms" function when getting meta value with "rwmb_meta"
75
+
76
  = 4.3.6 =
77
  * Bug fix: fatal error in PHP 5.2 (continue)
78
  * Improvement: allow register meta boxes via filter