Meta Box - Version 4.3.6

Version Description

  • Bug fix: fatal error in PHP 5.2 (continue)
  • Improvement: allow register meta boxes via filter
Download this release

Release Info

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

Code changes from version 4.3.5 to 4.3.6

Files changed (6) hide show
  1. inc/fields/oembed.php +1 -1
  2. inc/helpers.php +326 -293
  3. inc/init.php +21 -0
  4. inc/meta-box.php +2 -1
  5. meta-box.php +2 -1
  6. readme.txt +5 -1
inc/fields/oembed.php CHANGED
@@ -74,7 +74,7 @@ if ( ! class_exists( 'RWMB_OEmbed_Field' ) )
74
  $field['id'],
75
  $meta,
76
  $field['size'],
77
- __( 'Show embed', 'rwmb' ),
78
  $meta ? self::get_embed( $meta ) : ''
79
  );
80
  }
74
  $field['id'],
75
  $meta,
76
  $field['size'],
77
+ __( 'Preview', 'rwmb' ),
78
  $meta ? self::get_embed( $meta ) : ''
79
  );
80
  }
inc/helpers.php CHANGED
@@ -7,343 +7,376 @@
7
  // Prevent loading this file directly
8
  defined( 'ABSPATH' ) || exit;
9
 
10
- add_shortcode( 'rwmb_meta', 'rwmb_meta_shortcode' );
11
-
12
- /**
13
- * Shortcode to display meta value
14
- *
15
- * @param $atts Array of shortcode attributes, same as rwmb_meta function, but has more "meta_key" parameter
16
- * @see rwmb_meta function below
17
- *
18
- * @return string
19
- */
20
- function rwmb_meta_shortcode( $atts )
21
  {
22
- $atts = wp_parse_args( $atts, array(
23
- 'type' => 'text',
24
- 'post_id' => get_the_ID(),
25
- ) );
26
- if ( empty( $atts['meta_key'] ) )
27
- return '';
28
-
29
- $meta = rwmb_meta( $atts['meta_key'], $atts, $atts['post_id'] );
30
-
31
- // Get uploaded files info
32
- if ( in_array( $atts['type'], array( 'file', 'file_advanced' ) ) )
33
  {
34
- $content = '<ul>';
35
- foreach ( $meta as $file )
 
 
 
 
36
  {
37
- $content .= sprintf(
38
- '<li><a href="%s" title="%s">%s</a></li>',
39
- $file['url'],
40
- $file['title'],
41
- $file['name']
42
- );
43
  }
44
- $content .= '</ul>';
45
- }
46
 
47
- // Get uploaded images info
48
- elseif ( in_array( $atts['type'], array( 'image', 'plupload_image', 'thickbox_image', 'image_advanced' ) ) )
49
- {
50
- $content = '<ul>';
51
- foreach ( $meta as $image )
 
 
 
 
52
  {
53
- // Link thumbnail to full size image?
54
- if ( isset( $atts['link'] ) && $atts['link'] )
 
 
 
 
 
 
 
 
 
55
  {
56
- $content .= sprintf(
57
- '<li><a href="%s" title="%s"><img src="%s" alt="%s" title="%s" /></a></li>',
58
- $image['full_url'],
59
- $image['title'],
60
- $image['url'],
61
- $image['alt'],
62
- $image['title']
63
- );
 
 
 
64
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  else
66
  {
67
- $content .= sprintf(
68
- '<li><img src="%s" alt="%s" title="%s" /></li>',
69
- $image['url'],
70
- $image['alt'],
71
- $image['title']
72
- );
73
  }
 
 
74
  }
75
- $content .= '</ul>';
76
- }
77
 
78
- // Get post terms
79
- elseif ( 'taxonomy' == $atts['type'] )
80
- {
81
- $content = '<ul>';
82
- foreach ( $meta as $term )
 
 
 
 
 
83
  {
84
- $content .= sprintf(
85
- '<li><a href="%s" title="%s">%s</a></li>',
86
- get_term_link( $term, $atts['taxonomy'] ),
87
- $term->name,
88
- $term->name
89
- );
90
- }
91
- $content .= '</ul>';
92
- }
93
 
94
- // Normal multiple fields: checkbox_list, select with multiple values
95
- elseif ( is_array( $meta ) )
96
- {
97
- $content = '<ul><li>' . implode( '</li><li>', $meta ) . '</li></ul>';
98
- }
99
 
100
- else
101
- {
102
- $content = $meta;
103
- }
104
 
105
- return apply_filters( __FUNCTION__, $content );
106
- }
107
 
108
- /**
109
- * Get post meta
110
- *
111
- * @param string $key Meta key. Required.
112
- * @param int|null $post_id Post ID. null for current post. Optional
113
- * @param array $args Array of arguments. Optional.
114
- *
115
- * @return mixed
116
- */
117
- function rwmb_meta( $key, $args = array(), $post_id = null )
118
- {
119
- $post_id = empty( $post_id ) ? get_the_ID() : $post_id;
 
120
 
121
- $args = wp_parse_args( $args, array(
122
- 'type' => 'text',
123
- ) );
 
124
 
125
- // Set 'multiple' for fields based on 'type'
126
- if ( !isset( $args['multiple'] ) )
127
- $args['multiple'] = in_array( $args['type'], array( 'checkbox_list', 'file', 'file_advanced', 'image', 'image_advanced', 'plupload_image', 'thickbox_image' ) );
 
 
128
 
129
- $meta = get_post_meta( $post_id, $key, !$args['multiple'] );
 
 
 
 
 
 
 
 
 
130
 
131
- // Get uploaded files info
132
- if ( in_array( $args['type'], array( 'file', 'file_advanced' ) ) )
133
- {
134
- if ( is_array( $meta ) && !empty( $meta ) )
135
- {
136
- $files = array();
137
- foreach ( $meta as $id )
138
  {
139
- $files[$id] = rwmb_file_info( $id );
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  }
141
- $meta = $files;
142
- }
143
- }
144
 
145
- // Get uploaded images info
146
- elseif ( in_array( $args['type'], array( 'image', 'plupload_image', 'thickbox_image', 'image_advanced' ) ) )
147
- {
148
- global $wpdb;
149
-
150
- $meta = $wpdb->get_col( $wpdb->prepare( "
151
- SELECT meta_value FROM $wpdb->postmeta
152
- WHERE post_id = %d AND meta_key = '%s'
153
- ORDER BY meta_id ASC
154
- ", $post_id, $key ) );
155
 
156
- if ( is_array( $meta ) && !empty( $meta ) )
157
- {
158
- $images = array();
159
- foreach ( $meta as $id )
160
  {
161
- $images[$id] = rwmb_image_info( $id, $args );
162
  }
163
- $meta = $images;
 
164
  }
165
- }
166
 
167
- // Get terms
168
- elseif ( 'taxonomy_advanced' == $args['type'] )
169
- {
170
- if ( !empty( $args['taxonomy'] ) )
 
 
 
 
171
  {
172
- $term_ids = array_map( 'intval', array_filter( explode( ',', $meta . ',' ) ) );
173
-
174
- $meta = array();
175
- foreach ( $term_ids as $term_id )
176
- {
177
- $meta[] = get_term( $term_id, $args['taxonomy'] );
178
- }
 
179
  }
180
- else
 
 
 
 
 
 
 
 
 
181
  {
182
- $meta = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  }
184
- }
185
 
186
- // Get post terms
187
- elseif ( 'taxonomy' == $args['type'] )
188
- {
189
- $meta = empty( $args['taxonomy'] ) ? array() : wp_get_post_terms( $post_id, $args['taxonomy'] );
190
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
 
192
- // Get map
193
- elseif ( 'map' == $args['type'] )
194
- {
195
- $meta = rwmb_meta_map( $key, $args, $post_id );
196
- }
 
 
197
 
198
- return apply_filters( __FUNCTION__, $meta, $key, $args, $post_id );
199
- }
 
 
 
 
 
 
 
 
 
 
200
 
201
- /**
202
- * Get uploaded file information
203
- *
204
- * @param int $id Attachment file ID (post ID). Required.
205
- *
206
- * @return array|bool False if file not found. Array of (id, name, path, url) on success
207
- */
208
- function rwmb_file_info( $id )
209
- {
210
- $path = get_attached_file( $id );
211
- return array(
212
- 'ID' => $id,
213
- 'name' => basename( $path ),
214
- 'path' => $path,
215
- 'url' => wp_get_attachment_url( $id ),
216
- 'title' => get_the_title( $id ),
217
- );
218
- }
219
 
220
- /**
221
- * Get uploaded image information
222
- *
223
- * @param int $id Attachment image ID (post ID). Required.
224
- * @param array $args Array of arguments (for size). Required.
225
- *
226
- * @return array|bool False if file not found. Array of (id, name, path, url) on success
227
- */
228
- function rwmb_image_info( $id, $args = array() )
229
- {
230
- $args = wp_parse_args( $args, array(
231
- 'size' => 'thumbnail',
232
- ) );
233
-
234
- $img_src = wp_get_attachment_image_src( $id, $args['size'] );
235
- if ( empty( $img_src ) )
236
- return false;
237
-
238
- $attachment = get_post( $id );
239
- $path = get_attached_file( $id );
240
- return array(
241
- 'ID' => $id,
242
- 'name' => basename( $path ),
243
- 'path' => $path,
244
- 'url' => $img_src[0],
245
- 'width' => $img_src[1],
246
- 'height' => $img_src[2],
247
- 'full_url' => wp_get_attachment_url( $id ),
248
- 'title' => $attachment->post_title,
249
- 'caption' => $attachment->post_excerpt,
250
- 'description' => $attachment->post_content,
251
- 'alt' => get_post_meta( $id, '_wp_attachment_image_alt', true ),
252
- );
253
  }
254
 
255
  /**
256
- * Display map using Google API
257
  *
258
- * @param string $key Meta key
259
- * @param array $args Map parameter
260
- * @param int|null $post_id Post ID
261
  *
262
- * @return string
263
  */
264
- function rwmb_meta_map( $key, $args = array(), $post_id = null )
265
  {
266
- $post_id = empty( $post_id ) ? get_the_ID() : $post_id;
267
- $loc = get_post_meta( $post_id, $key, true );
268
- if ( !$loc )
269
- return '';
270
-
271
- $parts = array_map( 'trim', explode( ',', $loc ) );
272
-
273
- // No zoom entered, set it to 14 by default
274
- if ( count( $parts ) < 3 )
275
- $parts[2] = 14;
276
-
277
- // Map parameters
278
- $args = wp_parse_args( $args, array(
279
- 'width' => '640px',
280
- 'height' => '480px',
281
- 'zoom' => $parts[2], // Default to 'zoom' level set in admin, but can be overwritten
282
- 'marker' => true, // Display marker?
283
- 'marker_title' => '', // Marker title, when hover
284
- 'info_window' => '', // Content of info window (when click on marker). HTML allowed
285
- ) );
286
-
287
- // Counter to display multiple maps on same page
288
- static $counter = 0;
289
-
290
- $html = sprintf(
291
- '<div id="rwmb-map-canvas-%d" style="width:%s;height:%s"></div>',
292
- $counter,
293
- $args['width'],
294
- $args['height']
295
- );
296
-
297
- // Load Google Maps script only when needed
298
- $html .= '<script>if ( typeof google !== "object" || typeof google.maps !== "object" )
299
- document.write(\'<script src="//maps.google.com/maps/api/js?sensor=false"><\/script>\')</script>';
300
- $html .= '<script>
301
- ( function()
302
- {
303
- ';
304
-
305
- $html .= sprintf( '
306
- var center = new google.maps.LatLng( %s, %s ),
307
- mapOptions = {
308
- center: center,
309
- zoom: %d,
310
- mapTypeId: google.maps.MapTypeId.ROADMAP
311
- },
312
- map = new google.maps.Map( document.getElementById( "rwmb-map-canvas-%d" ), mapOptions );',
313
- $parts[0], $parts[1],
314
- $args['zoom'],
315
- $counter
316
- );
317
-
318
- if ( $args['marker'] )
319
- {
320
- $html .= sprintf( '
321
- var marker = new google.maps.Marker( {
322
- position: center,
323
- map: map%s
324
- } );',
325
- $args['marker_title'] ? ', title: "' . $args['marker_title'] . '"' : ''
326
- );
327
-
328
- if ( $args['info_window'] )
329
- {
330
- $html .= sprintf( '
331
- var infoWindow = new google.maps.InfoWindow( {
332
- content: "%s"
333
- } );
334
-
335
- google.maps.event.addListener( marker, "click", function()
336
- {
337
- infoWindow.open( map, marker );
338
- } );',
339
- $args['info_window']
340
- );
341
- }
342
- }
343
-
344
- $html .= '} )();
345
- </script>';
346
-
347
- $counter++;
348
- return $html;
349
  }
7
  // Prevent loading this file directly
8
  defined( 'ABSPATH' ) || exit;
9
 
10
+ if ( ! class_exists( 'RWMB_Helper' ) )
 
 
 
 
 
 
 
 
 
 
11
  {
12
+ /**
13
+ * Wrapper class for helper functions
14
+ */
15
+ class RWMB_Helper
 
 
 
 
 
 
 
16
  {
17
+ /**
18
+ * Do actions when class is loaded
19
+ *
20
+ * @return void
21
+ */
22
+ static function on_load()
23
  {
24
+ add_shortcode( 'rwmb_meta', array( __CLASS__, 'shortcode' ) );
 
 
 
 
 
25
  }
 
 
26
 
27
+ /**
28
+ * Shortcode to display meta value
29
+ *
30
+ * @param $atts Array of shortcode attributes, same as meta() function, but has more "meta_key" parameter
31
+ * @see meta() function below
32
+ *
33
+ * @return string
34
+ */
35
+ static function shortcode( $atts )
36
  {
37
+ $atts = wp_parse_args( $atts, array(
38
+ 'type' => 'text',
39
+ 'post_id' => get_the_ID(),
40
+ ) );
41
+ if ( empty( $atts['meta_key'] ) )
42
+ return '';
43
+
44
+ $meta = self::meta( $atts['meta_key'], $atts, $atts['post_id'] );
45
+
46
+ // Get uploaded files info
47
+ if ( in_array( $atts['type'], array( 'file', 'file_advanced' ) ) )
48
  {
49
+ $content = '<ul>';
50
+ foreach ( $meta as $file )
51
+ {
52
+ $content .= sprintf(
53
+ '<li><a href="%s" title="%s">%s</a></li>',
54
+ $file['url'],
55
+ $file['title'],
56
+ $file['name']
57
+ );
58
+ }
59
+ $content .= '</ul>';
60
  }
61
+
62
+ // Get uploaded images info
63
+ elseif ( in_array( $atts['type'], array( 'image', 'plupload_image', 'thickbox_image', 'image_advanced' ) ) )
64
+ {
65
+ $content = '<ul>';
66
+ foreach ( $meta as $image )
67
+ {
68
+ // Link thumbnail to full size image?
69
+ if ( isset( $atts['link'] ) && $atts['link'] )
70
+ {
71
+ $content .= sprintf(
72
+ '<li><a href="%s" title="%s"><img src="%s" alt="%s" title="%s" /></a></li>',
73
+ $image['full_url'],
74
+ $image['title'],
75
+ $image['url'],
76
+ $image['alt'],
77
+ $image['title']
78
+ );
79
+ }
80
+ else
81
+ {
82
+ $content .= sprintf(
83
+ '<li><img src="%s" alt="%s" title="%s" /></li>',
84
+ $image['url'],
85
+ $image['alt'],
86
+ $image['title']
87
+ );
88
+ }
89
+ }
90
+ $content .= '</ul>';
91
+ }
92
+
93
+ // Get post terms
94
+ elseif ( 'taxonomy' == $atts['type'] )
95
+ {
96
+ $content = '<ul>';
97
+ foreach ( $meta as $term )
98
+ {
99
+ $content .= sprintf(
100
+ '<li><a href="%s" title="%s">%s</a></li>',
101
+ get_term_link( $term, $atts['taxonomy'] ),
102
+ $term->name,
103
+ $term->name
104
+ );
105
+ }
106
+ $content .= '</ul>';
107
+ }
108
+
109
+ // Normal multiple fields: checkbox_list, select with multiple values
110
+ elseif ( is_array( $meta ) )
111
+ {
112
+ $content = '<ul><li>' . implode( '</li><li>', $meta ) . '</li></ul>';
113
+ }
114
+
115
  else
116
  {
117
+ $content = $meta;
 
 
 
 
 
118
  }
119
+
120
+ return apply_filters( __FUNCTION__, $content );
121
  }
 
 
122
 
123
+ /**
124
+ * Get post meta
125
+ *
126
+ * @param string $key Meta key. Required.
127
+ * @param int|null $post_id Post ID. null for current post. Optional
128
+ * @param array $args Array of arguments. Optional.
129
+ *
130
+ * @return mixed
131
+ */
132
+ static function meta( $key, $args = array(), $post_id = null )
133
  {
134
+ $post_id = empty( $post_id ) ? get_the_ID() : $post_id;
 
 
 
 
 
 
 
 
135
 
136
+ $args = wp_parse_args( $args, array(
137
+ 'type' => 'text',
138
+ ) );
 
 
139
 
140
+ // Set 'multiple' for fields based on 'type'
141
+ if ( !isset( $args['multiple'] ) )
142
+ $args['multiple'] = in_array( $args['type'], array( 'checkbox_list', 'file', 'file_advanced', 'image', 'image_advanced', 'plupload_image', 'thickbox_image' ) );
 
143
 
144
+ $meta = get_post_meta( $post_id, $key, !$args['multiple'] );
 
145
 
146
+ // Get uploaded files info
147
+ if ( in_array( $args['type'], array( 'file', 'file_advanced' ) ) )
148
+ {
149
+ if ( is_array( $meta ) && !empty( $meta ) )
150
+ {
151
+ $files = array();
152
+ foreach ( $meta as $id )
153
+ {
154
+ $files[$id] = self::file_info( $id );
155
+ }
156
+ $meta = $files;
157
+ }
158
+ }
159
 
160
+ // Get uploaded images info
161
+ elseif ( in_array( $args['type'], array( 'image', 'plupload_image', 'thickbox_image', 'image_advanced' ) ) )
162
+ {
163
+ global $wpdb;
164
 
165
+ $meta = $wpdb->get_col( $wpdb->prepare( "
166
+ SELECT meta_value FROM $wpdb->postmeta
167
+ WHERE post_id = %d AND meta_key = '%s'
168
+ ORDER BY meta_id ASC
169
+ ", $post_id, $key ) );
170
 
171
+ if ( is_array( $meta ) && !empty( $meta ) )
172
+ {
173
+ $images = array();
174
+ foreach ( $meta as $id )
175
+ {
176
+ $images[$id] = self::image_info( $id, $args );
177
+ }
178
+ $meta = $images;
179
+ }
180
+ }
181
 
182
+ // Get terms
183
+ elseif ( 'taxonomy_advanced' == $args['type'] )
 
 
 
 
 
184
  {
185
+ if ( !empty( $args['taxonomy'] ) )
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
+ {
197
+ $meta = array();
198
+ }
199
  }
 
 
 
200
 
201
+ // Get post terms
202
+ elseif ( 'taxonomy' == $args['type'] )
203
+ {
204
+ $meta = empty( $args['taxonomy'] ) ? array() : wp_get_post_terms( $post_id, $args['taxonomy'] );
205
+ }
 
 
 
 
 
206
 
207
+ // Get map
208
+ elseif ( 'map' == $args['type'] )
 
 
209
  {
210
+ $meta = self::map( $key, $args, $post_id );
211
  }
212
+
213
+ return apply_filters( __FUNCTION__, $meta, $key, $args, $post_id );
214
  }
 
215
 
216
+ /**
217
+ * Get uploaded file information
218
+ *
219
+ * @param int $id Attachment file ID (post ID). Required.
220
+ *
221
+ * @return array|bool False if file not found. Array of (id, name, path, url) on success
222
+ */
223
+ static function file_info( $id )
224
  {
225
+ $path = get_attached_file( $id );
226
+ return array(
227
+ 'ID' => $id,
228
+ 'name' => basename( $path ),
229
+ 'path' => $path,
230
+ 'url' => wp_get_attachment_url( $id ),
231
+ 'title' => get_the_title( $id ),
232
+ );
233
  }
234
+
235
+ /**
236
+ * Get uploaded image information
237
+ *
238
+ * @param int $id Attachment image ID (post ID). Required.
239
+ * @param array $args Array of arguments (for size). Required.
240
+ *
241
+ * @return array|bool False if file not found. Array of (id, name, path, url) on success
242
+ */
243
+ static function image_info( $id, $args = array() )
244
  {
245
+ $args = wp_parse_args( $args, array(
246
+ 'size' => 'thumbnail',
247
+ ) );
248
+
249
+ $img_src = wp_get_attachment_image_src( $id, $args['size'] );
250
+ if ( empty( $img_src ) )
251
+ return false;
252
+
253
+ $attachment = get_post( $id );
254
+ $path = get_attached_file( $id );
255
+ return array(
256
+ 'ID' => $id,
257
+ 'name' => basename( $path ),
258
+ 'path' => $path,
259
+ 'url' => $img_src[0],
260
+ 'width' => $img_src[1],
261
+ 'height' => $img_src[2],
262
+ 'full_url' => wp_get_attachment_url( $id ),
263
+ 'title' => $attachment->post_title,
264
+ 'caption' => $attachment->post_excerpt,
265
+ 'description' => $attachment->post_content,
266
+ 'alt' => get_post_meta( $id, '_wp_attachment_image_alt', true ),
267
+ );
268
  }
 
269
 
270
+ /**
271
+ * Display map using Google API
272
+ *
273
+ * @param string $key Meta key
274
+ * @param array $args Map parameter
275
+ * @param int|null $post_id Post ID
276
+ *
277
+ * @return string
278
+ */
279
+ static function map( $key, $args = array(), $post_id = null )
280
+ {
281
+ $post_id = empty( $post_id ) ? get_the_ID() : $post_id;
282
+ $loc = get_post_meta( $post_id, $key, true );
283
+ if ( !$loc )
284
+ return '';
285
+
286
+ $parts = array_map( 'trim', explode( ',', $loc ) );
287
+
288
+ // No zoom entered, set it to 14 by default
289
+ if ( count( $parts ) < 3 )
290
+ $parts[2] = 14;
291
+
292
+ // Map parameters
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
303
+ static $counter = 0;
304
+
305
+ $html = sprintf(
306
+ '<div id="rwmb-map-canvas-%d" style="width:%s;height:%s"></div>',
307
+ $counter,
308
+ $args['width'],
309
+ $args['height']
310
+ );
311
 
312
+ // Load Google Maps script only when needed
313
+ $html .= '<script>if ( typeof google !== "object" || typeof google.maps !== "object" )
314
+ document.write(\'<script src="//maps.google.com/maps/api/js?sensor=false"><\/script>\')</script>';
315
+ $html .= '<script>
316
+ ( function()
317
+ {
318
+ ';
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
 
333
+ if ( $args['marker'] )
334
+ {
335
+ $html .= sprintf( '
336
+ var marker = new google.maps.Marker( {
337
+ position: center,
338
+ map: map%s
339
+ } );',
340
+ $args['marker_title'] ? ', title: "' . $args['marker_title'] . '"' : ''
341
+ );
 
 
 
 
 
 
 
 
 
342
 
343
+ if ( $args['info_window'] )
344
+ {
345
+ $html .= sprintf( '
346
+ var infoWindow = new google.maps.InfoWindow( {
347
+ content: "%s"
348
+ } );
349
+
350
+ google.maps.event.addListener( marker, "click", function()
351
+ {
352
+ infoWindow.open( map, marker );
353
+ } );',
354
+ $args['info_window']
355
+ );
356
+ }
357
+ }
358
+
359
+ $html .= '} )();
360
+ </script>';
361
+
362
+ $counter++;
363
+ return $html;
364
+ }
365
+ }
366
+
367
+ RWMB_Helper::on_load();
 
 
 
 
 
 
 
 
368
  }
369
 
370
  /**
371
+ * Get post meta
372
  *
373
+ * @param string $key Meta key. Required.
374
+ * @param int|null $post_id Post ID. null for current post. Optional
375
+ * @param array $args Array of arguments. Optional.
376
  *
377
+ * @return mixed
378
  */
379
+ function rwmb_meta( $key, $args = array(), $post_id = null )
380
  {
381
+ return RWMB_Helper::meta( $key, $args, $post_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
  }
inc/init.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ add_action( 'admin_init', 'rwmb_register_meta_boxes' );
3
+
4
+ /**
5
+ * Register meta boxes via a filter
6
+ * Advantages:
7
+ * - prevents incorrect hook
8
+ * - prevents duplicated global variables
9
+ * - allows users to remove/hide registered meta boxes
10
+ * - no need to check for class existences
11
+ *
12
+ * @return void
13
+ */
14
+ function rwmb_register_meta_boxes()
15
+ {
16
+ $meta_boxes = apply_filters( 'rwmb_meta_boxes', array() );
17
+ foreach ( $meta_boxes as $meta_box )
18
+ {
19
+ new RW_Meta_Box( $meta_box );
20
+ }
21
+ }
inc/meta-box.php CHANGED
@@ -688,7 +688,8 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
688
  */
689
  static function do_field_actions( $field, $method )
690
  {
691
- call_user_func_array( array( __CLASS__, 'apply_field_filters' ), func_get_args() );
 
692
  }
693
 
694
  /**
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
  /**
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.5
7
  Author: Rilwis
8
  Author URI: http://www.deluxeblogtips.com
9
  License: GPL2+
@@ -45,4 +45,5 @@ if ( is_admin() )
45
 
46
  // Main file
47
  require_once RWMB_INC_DIR . 'meta-box.php';
 
48
  }
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+
45
 
46
  // Main file
47
  require_once RWMB_INC_DIR . 'meta-box.php';
48
+ require_once RWMB_INC_DIR . 'init.php';
49
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.5
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
 
@@ -58,6 +58,10 @@ To getting started with the plugin API, please read [this tutorial](http://www.d
58
 
59
  == Changelog ==
60
 
 
 
 
 
61
  = 4.3.5 =
62
  * Bug fix: fatal error in PHP 5.2
63
  * Bug fix: save empty values of clonable fields
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
 
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
64
+
65
  = 4.3.5 =
66
  * Bug fix: fatal error in PHP 5.2
67
  * Bug fix: save empty values of clonable fields