Version Description
Download this release
Release Info
Developer | rilwis |
Plugin | Meta Box |
Version | 4.13.1 |
Comparing to | |
See all releases |
Code changes from version 4.13.0 to 4.13.1
- inc/field.php +25 -3
- inc/fields/background.php +12 -35
- inc/fields/fieldset-text.php +6 -4
- inc/fields/file.php +1 -28
- inc/fields/image-advanced.php +0 -14
- inc/fields/image.php +6 -10
- inc/fields/key-value.php +10 -9
- inc/fields/map.php +34 -24
- inc/fields/single-image.php +0 -20
- inc/fields/text-list.php +3 -3
- inc/loader.php +1 -1
- js/image-advanced.js +2 -2
- meta-box.php +1 -1
- readme.txt +1 -1
inc/field.php
CHANGED
@@ -495,12 +495,34 @@ abstract class RWMB_Field {
|
|
495 |
* @return string
|
496 |
*/
|
497 |
public static function format_value( $field, $value, $args, $post_id ) {
|
498 |
-
if ( !
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
499 |
return self::call( 'format_single_value', $field, $value, $args, $post_id );
|
500 |
}
|
501 |
$output = '<ul>';
|
502 |
-
foreach ( $value as $
|
503 |
-
$output .= '<li>' . self::call( '
|
504 |
}
|
505 |
$output .= '</ul>';
|
506 |
return $output;
|
495 |
* @return string
|
496 |
*/
|
497 |
public static function format_value( $field, $value, $args, $post_id ) {
|
498 |
+
if ( ! $field['clone'] ) {
|
499 |
+
return self::call( 'format_clone_value', $field, $value, $args, $post_id );
|
500 |
+
}
|
501 |
+
$output = '<ul>';
|
502 |
+
foreach ( $value as $clone ) {
|
503 |
+
$output .= '<li>' . self::call( 'format_clone_value', $field, $clone, $args, $post_id ) . '</li>';
|
504 |
+
}
|
505 |
+
$output .= '</ul>';
|
506 |
+
return $output;
|
507 |
+
}
|
508 |
+
|
509 |
+
/**
|
510 |
+
* Format value for a clone.
|
511 |
+
*
|
512 |
+
* @param array $field Field parameters.
|
513 |
+
* @param string|array $value The field meta value.
|
514 |
+
* @param array $args Additional arguments. Rarely used. See specific fields for details.
|
515 |
+
* @param int|null $post_id Post ID. null for current post. Optional.
|
516 |
+
*
|
517 |
+
* @return string
|
518 |
+
*/
|
519 |
+
public static function format_clone_value( $field, $value, $args, $post_id ) {
|
520 |
+
if ( ! $field['multiple'] ) {
|
521 |
return self::call( 'format_single_value', $field, $value, $args, $post_id );
|
522 |
}
|
523 |
$output = '<ul>';
|
524 |
+
foreach ( $value as $single ) {
|
525 |
+
$output .= '<li>' . self::call( 'format_single_value', $field, $single, $args, $post_id ) . '</li>';
|
526 |
}
|
527 |
$output .= '</ul>';
|
528 |
return $output;
|
inc/fields/background.php
CHANGED
@@ -84,15 +84,15 @@ class RWMB_Background_Field extends RWMB_Field {
|
|
84 |
'field_name' => "{$field['field_name']}[position]",
|
85 |
'placeholder' => esc_html__( '-- Background Position --', 'meta-box' ),
|
86 |
'options' => array(
|
87 |
-
'
|
88 |
-
'
|
89 |
-
'
|
90 |
-
'
|
91 |
-
'
|
92 |
-
'
|
93 |
-
'
|
94 |
-
'
|
95 |
-
'
|
96 |
),
|
97 |
) );
|
98 |
$output .= RWMB_Select_Field::html( $meta['position'], $position );
|
@@ -129,34 +129,11 @@ class RWMB_Background_Field extends RWMB_Field {
|
|
129 |
return $output;
|
130 |
}
|
131 |
|
132 |
-
/**
|
133 |
-
* Format value for the helper functions.
|
134 |
-
*
|
135 |
-
* @param array $field Field parameters.
|
136 |
-
* @param string|array $value The field meta value.
|
137 |
-
* @param array $args Additional arguments. Rarely used. See specific fields for details.
|
138 |
-
* @param int|null $post_id Post ID. null for current post. Optional.
|
139 |
-
*
|
140 |
-
* @return string
|
141 |
-
*/
|
142 |
-
public static function format_value( $field, $value, $args, $post_id ) {
|
143 |
-
if ( ! $field['clone'] ) {
|
144 |
-
return self::call( 'format_single_value', $field, $value, $args, $post_id );
|
145 |
-
}
|
146 |
-
$output = '<ul>';
|
147 |
-
foreach ( $value as $subvalue ) {
|
148 |
-
$output .= '<li>' . self::call( 'format_single_value', $field, $subvalue, $args, $post_id ) . '</li>';
|
149 |
-
}
|
150 |
-
$output .= '</ul>';
|
151 |
-
return $output;
|
152 |
-
}
|
153 |
-
|
154 |
-
|
155 |
/**
|
156 |
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
|
157 |
*
|
158 |
* @param array $field Field parameters.
|
159 |
-
* @param
|
160 |
* @param array $args Additional arguments. Rarely used. See specific fields for details.
|
161 |
* @param int|null $post_id Post ID. null for current post. Optional.
|
162 |
*
|
@@ -164,9 +141,9 @@ class RWMB_Background_Field extends RWMB_Field {
|
|
164 |
*/
|
165 |
public static function format_single_value( $field, $value, $args, $post_id ) {
|
166 |
$output = '';
|
167 |
-
$value
|
168 |
foreach ( $value as $key => $subvalue ) {
|
169 |
-
$subvalue
|
170 |
$output .= 'background-' . $key . ': ' . $subvalue . ';';
|
171 |
}
|
172 |
return $output;
|
84 |
'field_name' => "{$field['field_name']}[position]",
|
85 |
'placeholder' => esc_html__( '-- Background Position --', 'meta-box' ),
|
86 |
'options' => array(
|
87 |
+
'top left' => esc_html__( 'Top Left', 'meta-box' ),
|
88 |
+
'top center' => esc_html__( 'Top Center', 'meta-box' ),
|
89 |
+
'top right' => esc_html__( 'Top Right', 'meta-box' ),
|
90 |
+
'center left' => esc_html__( 'Center Left', 'meta-box' ),
|
91 |
+
'center center' => esc_html__( 'Center Center', 'meta-box' ),
|
92 |
+
'center right' => esc_html__( 'Center Right', 'meta-box' ),
|
93 |
+
'bottom left' => esc_html__( 'Bottom Left', 'meta-box' ),
|
94 |
+
'bottom center' => esc_html__( 'Bottom Center', 'meta-box' ),
|
95 |
+
'bottom right' => esc_html__( 'Bottom Right', 'meta-box' ),
|
96 |
),
|
97 |
) );
|
98 |
$output .= RWMB_Select_Field::html( $meta['position'], $position );
|
129 |
return $output;
|
130 |
}
|
131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
/**
|
133 |
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
|
134 |
*
|
135 |
* @param array $field Field parameters.
|
136 |
+
* @param array $value The value.
|
137 |
* @param array $args Additional arguments. Rarely used. See specific fields for details.
|
138 |
* @param int|null $post_id Post ID. null for current post. Optional.
|
139 |
*
|
141 |
*/
|
142 |
public static function format_single_value( $field, $value, $args, $post_id ) {
|
143 |
$output = '';
|
144 |
+
$value = array_filter( $value );
|
145 |
foreach ( $value as $key => $subvalue ) {
|
146 |
+
$subvalue = 'image' === $key ? 'url( "' . esc_url( $subvalue ) . '")' : $subvalue;
|
147 |
$output .= 'background-' . $key . ': ' . $subvalue . ';';
|
148 |
}
|
149 |
return $output;
|
inc/fields/fieldset-text.php
CHANGED
@@ -36,6 +36,7 @@ class RWMB_Fieldset_Text_Field extends RWMB_Text_Field {
|
|
36 |
* Do not show field description.
|
37 |
*
|
38 |
* @param array $field Field parameters.
|
|
|
39 |
* @return string
|
40 |
*/
|
41 |
public static function input_description( $field ) {
|
@@ -46,6 +47,7 @@ class RWMB_Fieldset_Text_Field extends RWMB_Text_Field {
|
|
46 |
* Do not show field description.
|
47 |
*
|
48 |
* @param array $field Field parameters.
|
|
|
49 |
* @return string
|
50 |
*/
|
51 |
public static function label_description( $field ) {
|
@@ -82,13 +84,13 @@ class RWMB_Fieldset_Text_Field extends RWMB_Text_Field {
|
|
82 |
foreach ( $field['options'] as $label ) {
|
83 |
$output .= "<th>$label</th>";
|
84 |
}
|
85 |
-
$output .= '
|
86 |
|
87 |
if ( ! $field['clone'] ) {
|
88 |
-
$output .= self::format_single_value( $field, $value );
|
89 |
} else {
|
90 |
foreach ( $value as $subvalue ) {
|
91 |
-
$output .= self::format_single_value( $field, $subvalue );
|
92 |
}
|
93 |
}
|
94 |
$output .= '</tbody></table>';
|
@@ -99,7 +101,7 @@ class RWMB_Fieldset_Text_Field extends RWMB_Text_Field {
|
|
99 |
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
|
100 |
*
|
101 |
* @param array $field Field parameters.
|
102 |
-
* @param
|
103 |
* @param array $args Additional arguments. Rarely used. See specific fields for details.
|
104 |
* @param int|null $post_id Post ID. null for current post. Optional.
|
105 |
*
|
36 |
* Do not show field description.
|
37 |
*
|
38 |
* @param array $field Field parameters.
|
39 |
+
*
|
40 |
* @return string
|
41 |
*/
|
42 |
public static function input_description( $field ) {
|
47 |
* Do not show field description.
|
48 |
*
|
49 |
* @param array $field Field parameters.
|
50 |
+
*
|
51 |
* @return string
|
52 |
*/
|
53 |
public static function label_description( $field ) {
|
84 |
foreach ( $field['options'] as $label ) {
|
85 |
$output .= "<th>$label</th>";
|
86 |
}
|
87 |
+
$output .= '</tr></thead></tbody>';
|
88 |
|
89 |
if ( ! $field['clone'] ) {
|
90 |
+
$output .= self::format_single_value( $field, $value, $args, $post_id );
|
91 |
} else {
|
92 |
foreach ( $value as $subvalue ) {
|
93 |
+
$output .= self::format_single_value( $field, $subvalue, $args, $post_id );
|
94 |
}
|
95 |
}
|
96 |
$output .= '</tbody></table>';
|
101 |
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
|
102 |
*
|
103 |
* @param array $field Field parameters.
|
104 |
+
* @param array $value The value.
|
105 |
* @param array $args Additional arguments. Rarely used. See specific fields for details.
|
106 |
* @param int|null $post_id Post ID. null for current post. Optional.
|
107 |
*
|
inc/fields/file.php
CHANGED
@@ -337,28 +337,6 @@ class RWMB_File_Field extends RWMB_Field {
|
|
337 |
), wp_get_attachment_metadata( $file ) );
|
338 |
}
|
339 |
|
340 |
-
/**
|
341 |
-
* Format value for the helper functions.
|
342 |
-
*
|
343 |
-
* @param array $field Field parameters.
|
344 |
-
* @param string|array $value The field meta value.
|
345 |
-
* @param array $args Additional arguments. Rarely used. See specific fields for details.
|
346 |
-
* @param int|null $post_id Post ID. null for current post. Optional.
|
347 |
-
*
|
348 |
-
* @return string
|
349 |
-
*/
|
350 |
-
public static function format_value( $field, $value, $args, $post_id ) {
|
351 |
-
if ( ! $field['clone'] ) {
|
352 |
-
return self::call( 'format_single_value', $field, $value, $args, $post_id );
|
353 |
-
}
|
354 |
-
$output = '<ul>';
|
355 |
-
foreach ( $value as $subvalue ) {
|
356 |
-
$output .= '<li>' . self::call( 'format_single_value', $field, $subvalue, $args, $post_id ) . '</li>';
|
357 |
-
}
|
358 |
-
$output .= '</ul>';
|
359 |
-
return $output;
|
360 |
-
}
|
361 |
-
|
362 |
/**
|
363 |
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
|
364 |
*
|
@@ -370,11 +348,6 @@ class RWMB_File_Field extends RWMB_Field {
|
|
370 |
* @return string
|
371 |
*/
|
372 |
public static function format_single_value( $field, $value, $args, $post_id ) {
|
373 |
-
|
374 |
-
foreach ( $value as $file ) {
|
375 |
-
$output .= sprintf( '<li><a href="%s" target="_blank">%s</a></li>', $file['url'], $file['title'] );
|
376 |
-
}
|
377 |
-
$output .= '</ul>';
|
378 |
-
return $output;
|
379 |
}
|
380 |
}
|
337 |
), wp_get_attachment_metadata( $file ) );
|
338 |
}
|
339 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
/**
|
341 |
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
|
342 |
*
|
348 |
* @return string
|
349 |
*/
|
350 |
public static function format_single_value( $field, $value, $args, $post_id ) {
|
351 |
+
return sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $value['url'] ), esc_html( $value['title'] ) );
|
|
|
|
|
|
|
|
|
|
|
352 |
}
|
353 |
}
|
inc/fields/image-advanced.php
CHANGED
@@ -63,20 +63,6 @@ class RWMB_Image_Advanced_Field extends RWMB_Media_Field {
|
|
63 |
return RWMB_Image_Field::file_info( $file, $args );
|
64 |
}
|
65 |
|
66 |
-
/**
|
67 |
-
* Format value for the helper functions.
|
68 |
-
*
|
69 |
-
* @param array $field Field parameters.
|
70 |
-
* @param string|array $value The field meta value.
|
71 |
-
* @param array $args Additional arguments. Rarely used. See specific fields for details.
|
72 |
-
* @param int|null $post_id Post ID. null for current post. Optional.
|
73 |
-
*
|
74 |
-
* @return string
|
75 |
-
*/
|
76 |
-
public static function format_value( $field, $value, $args, $post_id ) {
|
77 |
-
return RWMB_Image_Field::format_value( $field, $value, $args, $post_id );
|
78 |
-
}
|
79 |
-
|
80 |
/**
|
81 |
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
|
82 |
*
|
63 |
return RWMB_Image_Field::file_info( $file, $args );
|
64 |
}
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
/**
|
67 |
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
|
68 |
*
|
inc/fields/image.php
CHANGED
@@ -24,10 +24,11 @@ class RWMB_Image_Field extends RWMB_File_Field {
|
|
24 |
* @param int $file Attachment (file) ID.
|
25 |
* @param int $index File index.
|
26 |
* @param array $field Field data.
|
|
|
27 |
* @return string
|
28 |
*/
|
29 |
protected static function file_html( $file, $index, $field ) {
|
30 |
-
$attributes
|
31 |
|
32 |
return sprintf(
|
33 |
'<li class="rwmb-image-item attachment thumbnail">
|
@@ -63,17 +64,12 @@ class RWMB_Image_Field extends RWMB_File_Field {
|
|
63 |
* @return string
|
64 |
*/
|
65 |
public static function format_single_value( $field, $value, $args, $post_id ) {
|
66 |
-
$output = '<
|
67 |
-
foreach ( $value as $file ) {
|
68 |
-
$img = sprintf( '<img src="%s" alt="%s">', esc_url( $file['url'] ), esc_attr( $file['alt'] ) );
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
}
|
74 |
-
$output .= "<li>$img</li>";
|
75 |
}
|
76 |
-
$output .= '</ul>';
|
77 |
return $output;
|
78 |
}
|
79 |
|
24 |
* @param int $file Attachment (file) ID.
|
25 |
* @param int $index File index.
|
26 |
* @param array $field Field data.
|
27 |
+
*
|
28 |
* @return string
|
29 |
*/
|
30 |
protected static function file_html( $file, $index, $field ) {
|
31 |
+
$attributes = self::get_attributes( $field, $file );
|
32 |
|
33 |
return sprintf(
|
34 |
'<li class="rwmb-image-item attachment thumbnail">
|
64 |
* @return string
|
65 |
*/
|
66 |
public static function format_single_value( $field, $value, $args, $post_id ) {
|
67 |
+
$output = sprintf( '<img src="%s" alt="%s">', esc_url( $value['url'] ), esc_attr( $value['alt'] ) );
|
|
|
|
|
68 |
|
69 |
+
// Link thumbnail to full size image?
|
70 |
+
if ( ! empty( $args['link'] ) ) {
|
71 |
+
$output = sprintf( '<a href="%s" title="%s">%s</a>', esc_url( $value['full_url'] ), esc_attr( $value['title'] ), $output );
|
|
|
|
|
72 |
}
|
|
|
73 |
return $output;
|
74 |
}
|
75 |
|
inc/fields/key-value.php
CHANGED
@@ -14,6 +14,7 @@ class RWMB_Key_Value_Field extends RWMB_Text_Field {
|
|
14 |
*
|
15 |
* @param mixed $meta Meta value.
|
16 |
* @param array $field Field parameters.
|
|
|
17 |
* @return string
|
18 |
*/
|
19 |
public static function html( $meta, $field ) {
|
@@ -27,7 +28,7 @@ class RWMB_Key_Value_Field extends RWMB_Text_Field {
|
|
27 |
$val = isset( $meta[1] ) ? $meta[1] : '';
|
28 |
$attributes = self::get_attributes( $field, $val );
|
29 |
$attributes['placeholder'] = $field['placeholder']['value'];
|
30 |
-
$html
|
31 |
|
32 |
return $html;
|
33 |
}
|
@@ -37,6 +38,7 @@ class RWMB_Key_Value_Field extends RWMB_Text_Field {
|
|
37 |
*
|
38 |
* @param mixed $meta Meta value.
|
39 |
* @param array $field Field parameters.
|
|
|
40 |
* @return string
|
41 |
*/
|
42 |
public static function begin_html( $meta, $field ) {
|
@@ -62,6 +64,7 @@ class RWMB_Key_Value_Field extends RWMB_Text_Field {
|
|
62 |
* Do not show field description.
|
63 |
*
|
64 |
* @param array $field Field parameters.
|
|
|
65 |
* @return string
|
66 |
*/
|
67 |
public static function input_description( $field ) {
|
@@ -72,6 +75,7 @@ class RWMB_Key_Value_Field extends RWMB_Text_Field {
|
|
72 |
* Do not show field description.
|
73 |
*
|
74 |
* @param array $field Field parameters.
|
|
|
75 |
* @return string
|
76 |
*/
|
77 |
public static function label_description( $field ) {
|
@@ -82,6 +86,7 @@ class RWMB_Key_Value_Field extends RWMB_Text_Field {
|
|
82 |
* Escape meta for field output.
|
83 |
*
|
84 |
* @param mixed $meta Meta value.
|
|
|
85 |
* @return mixed
|
86 |
*/
|
87 |
public static function esc_meta( $meta ) {
|
@@ -99,7 +104,7 @@ class RWMB_Key_Value_Field extends RWMB_Text_Field {
|
|
99 |
* @param int $post_id The post ID.
|
100 |
* @param array $field The field parameters.
|
101 |
*
|
102 |
-
* @return
|
103 |
*/
|
104 |
public static function value( $new, $old, $post_id, $field ) {
|
105 |
foreach ( $new as &$arr ) {
|
@@ -115,6 +120,7 @@ class RWMB_Key_Value_Field extends RWMB_Text_Field {
|
|
115 |
* Normalize parameters for field.
|
116 |
*
|
117 |
* @param array $field Field parameters.
|
|
|
118 |
* @return array
|
119 |
*/
|
120 |
public static function normalize( $field ) {
|
@@ -139,12 +145,7 @@ class RWMB_Key_Value_Field extends RWMB_Text_Field {
|
|
139 |
*
|
140 |
* @return string
|
141 |
*/
|
142 |
-
public static function
|
143 |
-
|
144 |
-
foreach ( $value as $subvalue ) {
|
145 |
-
$output .= sprintf( '<li><label>%s:</label> %s</li>', $subvalue[0], $subvalue[1] );
|
146 |
-
}
|
147 |
-
$output .= '</ul>';
|
148 |
-
return $output;
|
149 |
}
|
150 |
}
|
14 |
*
|
15 |
* @param mixed $meta Meta value.
|
16 |
* @param array $field Field parameters.
|
17 |
+
*
|
18 |
* @return string
|
19 |
*/
|
20 |
public static function html( $meta, $field ) {
|
28 |
$val = isset( $meta[1] ) ? $meta[1] : '';
|
29 |
$attributes = self::get_attributes( $field, $val );
|
30 |
$attributes['placeholder'] = $field['placeholder']['value'];
|
31 |
+
$html .= sprintf( '<input %s>', self::render_attributes( $attributes ) );
|
32 |
|
33 |
return $html;
|
34 |
}
|
38 |
*
|
39 |
* @param mixed $meta Meta value.
|
40 |
* @param array $field Field parameters.
|
41 |
+
*
|
42 |
* @return string
|
43 |
*/
|
44 |
public static function begin_html( $meta, $field ) {
|
64 |
* Do not show field description.
|
65 |
*
|
66 |
* @param array $field Field parameters.
|
67 |
+
*
|
68 |
* @return string
|
69 |
*/
|
70 |
public static function input_description( $field ) {
|
75 |
* Do not show field description.
|
76 |
*
|
77 |
* @param array $field Field parameters.
|
78 |
+
*
|
79 |
* @return string
|
80 |
*/
|
81 |
public static function label_description( $field ) {
|
86 |
* Escape meta for field output.
|
87 |
*
|
88 |
* @param mixed $meta Meta value.
|
89 |
+
*
|
90 |
* @return mixed
|
91 |
*/
|
92 |
public static function esc_meta( $meta ) {
|
104 |
* @param int $post_id The post ID.
|
105 |
* @param array $field The field parameters.
|
106 |
*
|
107 |
+
* @return array
|
108 |
*/
|
109 |
public static function value( $new, $old, $post_id, $field ) {
|
110 |
foreach ( $new as &$arr ) {
|
120 |
* Normalize parameters for field.
|
121 |
*
|
122 |
* @param array $field Field parameters.
|
123 |
+
*
|
124 |
* @return array
|
125 |
*/
|
126 |
public static function normalize( $field ) {
|
145 |
*
|
146 |
* @return string
|
147 |
*/
|
148 |
+
public static function format_clone_value( $field, $value, $args, $post_id ) {
|
149 |
+
return sprintf( '<label>%s:</label> %s', $value[0], $value[1] );
|
|
|
|
|
|
|
|
|
|
|
150 |
}
|
151 |
}
|
inc/fields/map.php
CHANGED
@@ -19,8 +19,8 @@ class RWMB_Map_Field extends RWMB_Field {
|
|
19 |
* @link http://googlegeodevelopers.blogspot.com/2016/06/building-for-scale-updates-to-google.html
|
20 |
* @link https://developers.google.com/maps/documentation/javascript/get-api-key
|
21 |
*/
|
22 |
-
$args
|
23 |
-
$field
|
24 |
$google_maps_url = add_query_arg( 'key', $field['api_key'], 'https://maps.google.com/maps/api/js' );
|
25 |
|
26 |
/**
|
@@ -31,7 +31,10 @@ class RWMB_Map_Field extends RWMB_Field {
|
|
31 |
$google_maps_url = apply_filters( 'rwmb_google_maps_url', $google_maps_url );
|
32 |
wp_register_script( 'google-maps', esc_url_raw( $google_maps_url ), array(), '', true );
|
33 |
wp_enqueue_style( 'rwmb-map', RWMB_CSS_URL . 'map.css', array(), RWMB_VER );
|
34 |
-
wp_enqueue_script( 'rwmb-map', RWMB_JS_URL . 'map.js', array(
|
|
|
|
|
|
|
35 |
}
|
36 |
|
37 |
/**
|
@@ -44,7 +47,7 @@ class RWMB_Map_Field extends RWMB_Field {
|
|
44 |
*/
|
45 |
public static function html( $meta, $field ) {
|
46 |
$address = is_array( $field['address_field'] ) ? implode( ',', $field['address_field'] ) : $field['address_field'];
|
47 |
-
$html
|
48 |
'<div class="rwmb-map-field" data-address-field="%s">',
|
49 |
esc_attr( $address )
|
50 |
);
|
@@ -114,23 +117,36 @@ class RWMB_Map_Field extends RWMB_Field {
|
|
114 |
* Display Google maps.
|
115 |
*
|
116 |
* @param array $field Field parameters.
|
117 |
-
* @param array $args Additional arguments
|
118 |
* @param int|null $post_id Post ID. null for current post. Optional.
|
119 |
*
|
120 |
-
* @return
|
121 |
*/
|
122 |
public static function the_value( $field, $args = array(), $post_id = null ) {
|
123 |
-
$value =
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
return '';
|
126 |
}
|
127 |
-
if ( ! $value['zoom'] ) {
|
128 |
-
$value['zoom'] = 14;
|
129 |
-
}
|
130 |
|
131 |
$args = wp_parse_args( $args, array(
|
132 |
-
'latitude' => $
|
133 |
-
'longitude' => $
|
134 |
'width' => '100%',
|
135 |
'height' => '480px',
|
136 |
'marker' => true, // Display marker?
|
@@ -140,24 +156,18 @@ class RWMB_Map_Field extends RWMB_Field {
|
|
140 |
|
141 |
// Default API key, required by Google Maps since June 2016.
|
142 |
// Users should overwrite this key with their own key.
|
143 |
-
'api_key'
|
144 |
) );
|
145 |
|
146 |
-
|
147 |
-
* Enqueue scripts.
|
148 |
-
* API key is get from $field (if found by RWMB_Helper::find_field()) or $args as a fallback.
|
149 |
-
* Note: We still can enqueue script which outputs in the footer.
|
150 |
-
*/
|
151 |
-
$api_key = isset( $field['api_key'] ) ? $field['api_key'] : $args['api_key'];
|
152 |
-
$google_maps_url = add_query_arg( 'key', $api_key, 'https://maps.google.com/maps/api/js' );
|
153 |
|
154 |
/*
|
155 |
* Allows developers load more libraries via a filter.
|
156 |
* @link https://developers.google.com/maps/documentation/javascript/libraries
|
157 |
*/
|
158 |
$google_maps_url = apply_filters( 'rwmb_google_maps_url', $google_maps_url );
|
159 |
-
wp_register_script( 'google-maps', esc_url_raw( $google_maps_url ), array(),
|
160 |
-
wp_enqueue_script( 'rwmb-map-frontend', RWMB_JS_URL . 'map-frontend.js', array( 'google-maps' ),
|
161 |
|
162 |
/*
|
163 |
* Google Maps options.
|
@@ -167,7 +177,7 @@ class RWMB_Map_Field extends RWMB_Field {
|
|
167 |
*/
|
168 |
$args['js_options'] = wp_parse_args( $args['js_options'], array(
|
169 |
// Default to 'zoom' level set in admin, but can be overwritten.
|
170 |
-
'zoom' => $
|
171 |
|
172 |
// Map type, see https://developers.google.com/maps/documentation/javascript/reference#MapTypeId.
|
173 |
'mapTypeId' => 'ROADMAP',
|
19 |
* @link http://googlegeodevelopers.blogspot.com/2016/06/building-for-scale-updates-to-google.html
|
20 |
* @link https://developers.google.com/maps/documentation/javascript/get-api-key
|
21 |
*/
|
22 |
+
$args = func_get_args();
|
23 |
+
$field = $args[0];
|
24 |
$google_maps_url = add_query_arg( 'key', $field['api_key'], 'https://maps.google.com/maps/api/js' );
|
25 |
|
26 |
/**
|
31 |
$google_maps_url = apply_filters( 'rwmb_google_maps_url', $google_maps_url );
|
32 |
wp_register_script( 'google-maps', esc_url_raw( $google_maps_url ), array(), '', true );
|
33 |
wp_enqueue_style( 'rwmb-map', RWMB_CSS_URL . 'map.css', array(), RWMB_VER );
|
34 |
+
wp_enqueue_script( 'rwmb-map', RWMB_JS_URL . 'map.js', array(
|
35 |
+
'jquery-ui-autocomplete',
|
36 |
+
'google-maps',
|
37 |
+
), RWMB_VER, true );
|
38 |
}
|
39 |
|
40 |
/**
|
47 |
*/
|
48 |
public static function html( $meta, $field ) {
|
49 |
$address = is_array( $field['address_field'] ) ? implode( ',', $field['address_field'] ) : $field['address_field'];
|
50 |
+
$html = sprintf(
|
51 |
'<div class="rwmb-map-field" data-address-field="%s">',
|
52 |
esc_attr( $address )
|
53 |
);
|
117 |
* Display Google maps.
|
118 |
*
|
119 |
* @param array $field Field parameters.
|
120 |
+
* @param array $args Additional arguments for the map.
|
121 |
* @param int|null $post_id Post ID. null for current post. Optional.
|
122 |
*
|
123 |
+
* @return string HTML output of the field
|
124 |
*/
|
125 |
public static function the_value( $field, $args = array(), $post_id = null ) {
|
126 |
+
$value = parent::get_value( $field, $args, $post_id );
|
127 |
+
$args = wp_parse_args( $args, array(
|
128 |
+
'api_key' => isset( $field['api_key'] ) ? $field['api_key'] : '',
|
129 |
+
) );
|
130 |
+
return self::render_map( $value, $args );
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Render a map in the frontend.
|
135 |
+
*
|
136 |
+
* @param array $location The [latitude, longitude[, zoom]] location.
|
137 |
+
* @param array $args Additional arguments for the map.
|
138 |
+
*
|
139 |
+
* @return string
|
140 |
+
*/
|
141 |
+
public static function render_map( $location, $args = array() ) {
|
142 |
+
list( $latitude, $longitude, $zoom ) = explode( ',', $location . ',,' );
|
143 |
+
if ( ! $latitude || ! $longitude ) {
|
144 |
return '';
|
145 |
}
|
|
|
|
|
|
|
146 |
|
147 |
$args = wp_parse_args( $args, array(
|
148 |
+
'latitude' => $latitude,
|
149 |
+
'longitude' => $longitude,
|
150 |
'width' => '100%',
|
151 |
'height' => '480px',
|
152 |
'marker' => true, // Display marker?
|
156 |
|
157 |
// Default API key, required by Google Maps since June 2016.
|
158 |
// Users should overwrite this key with their own key.
|
159 |
+
'api_key' => 'AIzaSyC1mUh87SGFyf133tpZQJa-s96p0tgnraQ',
|
160 |
) );
|
161 |
|
162 |
+
$google_maps_url = add_query_arg( 'key', $args['api_key'], 'https://maps.google.com/maps/api/js' );
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
|
164 |
/*
|
165 |
* Allows developers load more libraries via a filter.
|
166 |
* @link https://developers.google.com/maps/documentation/javascript/libraries
|
167 |
*/
|
168 |
$google_maps_url = apply_filters( 'rwmb_google_maps_url', $google_maps_url );
|
169 |
+
wp_register_script( 'google-maps', esc_url_raw( $google_maps_url ), array(), RWMB_VER, true );
|
170 |
+
wp_enqueue_script( 'rwmb-map-frontend', RWMB_JS_URL . 'map-frontend.js', array( 'google-maps' ), RWMB_VER, true );
|
171 |
|
172 |
/*
|
173 |
* Google Maps options.
|
177 |
*/
|
178 |
$args['js_options'] = wp_parse_args( $args['js_options'], array(
|
179 |
// Default to 'zoom' level set in admin, but can be overwritten.
|
180 |
+
'zoom' => $zoom,
|
181 |
|
182 |
// Map type, see https://developers.google.com/maps/documentation/javascript/reference#MapTypeId.
|
183 |
'mapTypeId' => 'ROADMAP',
|
inc/fields/single-image.php
CHANGED
@@ -61,24 +61,4 @@ class RWMB_Single_Image_Field extends RWMB_Image_Advanced_Field {
|
|
61 |
$return = RWMB_Image_Field::file_info( $value, $args );
|
62 |
return $return;
|
63 |
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
|
67 |
-
*
|
68 |
-
* @param array $field Field parameters.
|
69 |
-
* @param array $value The field value.
|
70 |
-
* @param array $args Additional arguments. Rarely used. See specific fields for details.
|
71 |
-
* @param int|null $post_id Post ID. null for current post. Optional.
|
72 |
-
*
|
73 |
-
* @return string
|
74 |
-
*/
|
75 |
-
public static function format_single_value( $field, $value, $args, $post_id ) {
|
76 |
-
$img = sprintf( '<img src="%s" alt="%s">', esc_url( $value['url'] ), esc_attr( $value['alt'] ) );
|
77 |
-
|
78 |
-
// Link thumbnail to full size image?
|
79 |
-
if ( isset( $args['link'] ) && $args['link'] ) {
|
80 |
-
$img = sprintf( '<a href="%s" title="%s">%s</a>', esc_url( $value['full_url'] ), esc_attr( $value['title'] ), $img );
|
81 |
-
}
|
82 |
-
return $img;
|
83 |
-
}
|
84 |
}
|
61 |
$return = RWMB_Image_Field::file_info( $value, $args );
|
62 |
return $return;
|
63 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
}
|
inc/fields/text-list.php
CHANGED
@@ -54,10 +54,10 @@ class RWMB_Text_List_Field extends RWMB_Multiple_Values_Field {
|
|
54 |
$output .= '<tr>';
|
55 |
|
56 |
if ( ! $field['clone'] ) {
|
57 |
-
$output .= self::format_single_value( $field, $value );
|
58 |
} else {
|
59 |
foreach ( $value as $subvalue ) {
|
60 |
-
$output .= self::format_single_value( $field, $subvalue );
|
61 |
}
|
62 |
}
|
63 |
$output .= '</tbody></table>';
|
@@ -68,7 +68,7 @@ class RWMB_Text_List_Field extends RWMB_Multiple_Values_Field {
|
|
68 |
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
|
69 |
*
|
70 |
* @param array $field Field parameters.
|
71 |
-
* @param
|
72 |
* @param array $args Additional arguments. Rarely used. See specific fields for details.
|
73 |
* @param int|null $post_id Post ID. null for current post. Optional.
|
74 |
*
|
54 |
$output .= '<tr>';
|
55 |
|
56 |
if ( ! $field['clone'] ) {
|
57 |
+
$output .= self::format_single_value( $field, $value, $args, $post_id );
|
58 |
} else {
|
59 |
foreach ( $value as $subvalue ) {
|
60 |
+
$output .= self::format_single_value( $field, $subvalue, $args, $post_id );
|
61 |
}
|
62 |
}
|
63 |
$output .= '</tbody></table>';
|
68 |
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
|
69 |
*
|
70 |
* @param array $field Field parameters.
|
71 |
+
* @param array $value The value.
|
72 |
* @param array $args Additional arguments. Rarely used. See specific fields for details.
|
73 |
* @param int|null $post_id Post ID. null for current post. Optional.
|
74 |
*
|
inc/loader.php
CHANGED
@@ -18,7 +18,7 @@ class RWMB_Loader {
|
|
18 |
*/
|
19 |
protected function constants() {
|
20 |
// Script version, used to add version for scripts and styles.
|
21 |
-
define( 'RWMB_VER', '4.13.
|
22 |
|
23 |
list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
|
24 |
|
18 |
*/
|
19 |
protected function constants() {
|
20 |
// Script version, used to add version for scripts and styles.
|
21 |
+
define( 'RWMB_VER', '4.13.1' );
|
22 |
|
23 |
list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
|
24 |
|
js/image-advanced.js
CHANGED
@@ -37,11 +37,11 @@ jQuery( function ( $ ) {
|
|
37 |
* Remove views for uploaded images.
|
38 |
*/
|
39 |
function removeView() {
|
40 |
-
$( this ).
|
41 |
}
|
42 |
|
43 |
$( '.rwmb-image_advanced' ).each( initImageField );
|
44 |
$( document )
|
45 |
-
.on( '
|
46 |
.on( 'after_clone', '.rwmb-image_advanced', initImageField );
|
47 |
} );
|
37 |
* Remove views for uploaded images.
|
38 |
*/
|
39 |
function removeView() {
|
40 |
+
$( this ).siblings( '.rwmb-media-view' ).remove();
|
41 |
}
|
42 |
|
43 |
$( '.rwmb-image_advanced' ).each( initImageField );
|
44 |
$( document )
|
45 |
+
.on( 'clone', '.rwmb-image_advanced', removeView )
|
46 |
.on( 'after_clone', '.rwmb-image_advanced', initImageField );
|
47 |
} );
|
meta-box.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Meta Box
|
4 |
* Plugin URI: https://metabox.io
|
5 |
* Description: Create custom meta boxes and custom fields in WordPress.
|
6 |
-
* Version: 4.13.
|
7 |
* Author: MetaBox.io
|
8 |
* Author URI: https://metabox.io
|
9 |
* License: GPL2+
|
3 |
* Plugin Name: Meta Box
|
4 |
* Plugin URI: https://metabox.io
|
5 |
* Description: Create custom meta boxes and custom fields in WordPress.
|
6 |
+
* Version: 4.13.1
|
7 |
* Author: MetaBox.io
|
8 |
* Author URI: https://metabox.io
|
9 |
* License: GPL2+
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://paypal.me/anhtnt
|
|
4 |
Tags: meta-box, custom fields, custom field, meta, meta-boxes, admin, advanced, custom, edit, field, file, image, magic fields, matrix, more fields, Post, repeater, simple fields, text, textarea, type, cms, fields post
|
5 |
Requires at least: 4.3
|
6 |
Tested up to: 4.9.1
|
7 |
-
Stable tag: 4.13.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Meta Box plugin is a powerful, professional developer toolkit to create custom meta boxes and custom fields for WordPress.
|
4 |
Tags: meta-box, custom fields, custom field, meta, meta-boxes, admin, advanced, custom, edit, field, file, image, magic fields, matrix, more fields, Post, repeater, simple fields, text, textarea, type, cms, fields post
|
5 |
Requires at least: 4.3
|
6 |
Tested up to: 4.9.1
|
7 |
+
Stable tag: 4.13.1
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Meta Box plugin is a powerful, professional developer toolkit to create custom meta boxes and custom fields for WordPress.
|