Version Description
Download this release
Release Info
Developer | rilwis |
Plugin | Meta Box |
Version | 4.18.1 |
Comparing to | |
See all releases |
Code changes from version 4.18.0 to 4.18.1
- inc/autoloader.php +7 -113
- inc/clone.php +1 -1
- inc/fields/file.php +2 -2
- inc/fields/map.php +0 -7
- inc/fields/object-choice.php +1 -1
- inc/fields/osm.php +8 -14
- inc/fields/post.php +6 -3
- inc/fields/taxonomy.php +1 -1
- inc/fields/user.php +24 -4
- inc/functions.php +2 -2
- inc/loader.php +1 -1
- js/map.js +30 -24
- js/osm.js +29 -20
- meta-box.php +1 -1
- readme.txt +2 -2
inc/autoloader.php
CHANGED
@@ -9,7 +9,6 @@
|
|
9 |
* Autoload class
|
10 |
*/
|
11 |
class RWMB_Autoloader {
|
12 |
-
|
13 |
/**
|
14 |
* List of directories to load classes.
|
15 |
*
|
@@ -20,13 +19,13 @@ class RWMB_Autoloader {
|
|
20 |
/**
|
21 |
* Adds a base directory for a class name prefix and/or suffix.
|
22 |
*
|
23 |
-
* @param string $
|
24 |
-
* @param string $prefix
|
25 |
-
* @param string $suffix
|
26 |
*/
|
27 |
-
public function add( $
|
28 |
$this->dirs[] = array(
|
29 |
-
'dir' => trailingslashit( $
|
30 |
'prefix' => $prefix,
|
31 |
'suffix' => $suffix,
|
32 |
);
|
@@ -34,24 +33,15 @@ class RWMB_Autoloader {
|
|
34 |
|
35 |
/**
|
36 |
* Register autoloader for plugin classes.
|
37 |
-
* In PHP 5.3, SPL extension cannot be disabled and it's safe to use autoload.
|
38 |
-
* However, hosting providers can disable it in PHP 5.2. In that case, we provide a fallback for autoload.
|
39 |
-
*
|
40 |
-
* @link http://php.net/manual/en/spl.installation.php
|
41 |
-
* @link https://github.com/rilwis/meta-box/issues/810
|
42 |
*/
|
43 |
public function register() {
|
44 |
spl_autoload_register( array( $this, 'autoload' ) );
|
45 |
-
if ( ! class_exists( 'RWMB_Core' ) ) {
|
46 |
-
$this->fallback();
|
47 |
-
}
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
-
* Autoload
|
52 |
*
|
53 |
* @param string $class Class name.
|
54 |
-
* @return mixed Boolean false if no mapped file can be loaded, or the name of the mapped file that was loaded.
|
55 |
*/
|
56 |
public function autoload( $class ) {
|
57 |
foreach ( $this->dirs as $dir ) {
|
@@ -67,100 +57,7 @@ class RWMB_Autoloader {
|
|
67 |
}
|
68 |
$file = strtolower( str_replace( '_', '-', $file ) ) . '.php';
|
69 |
$file = $dir['dir'] . $file;
|
70 |
-
|
71 |
-
return $file;
|
72 |
-
}
|
73 |
-
}
|
74 |
-
return false;
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Fallback for autoload in PHP 5.2.
|
79 |
-
*/
|
80 |
-
protected function fallback() {
|
81 |
-
$files = array(
|
82 |
-
// Core.
|
83 |
-
'core',
|
84 |
-
'clone',
|
85 |
-
'meta-box',
|
86 |
-
'meta-box-registry',
|
87 |
-
'storage-registry',
|
88 |
-
'interfaces/storage.php',
|
89 |
-
'storages/base.php',
|
90 |
-
'storages/post.php',
|
91 |
-
'validation',
|
92 |
-
'sanitizer',
|
93 |
-
'media-modal',
|
94 |
-
'wpml',
|
95 |
-
'about/about.php',
|
96 |
-
|
97 |
-
// Walkers.
|
98 |
-
'walkers/walker',
|
99 |
-
'walkers/select',
|
100 |
-
'walkers/select-tree',
|
101 |
-
'walkers/input-list',
|
102 |
-
|
103 |
-
// Fields.
|
104 |
-
'field',
|
105 |
-
'field-registry',
|
106 |
-
|
107 |
-
'fields/multiple-values',
|
108 |
-
'fields/autocomplete',
|
109 |
-
'fields/text-list',
|
110 |
-
|
111 |
-
'fields/choice',
|
112 |
-
|
113 |
-
'fields/select',
|
114 |
-
'fields/select-advanced',
|
115 |
-
'fields/select-tree',
|
116 |
-
|
117 |
-
'fields/input-list',
|
118 |
-
'fields/radio',
|
119 |
-
'fields/checkbox-list',
|
120 |
-
|
121 |
-
'fields/object-choice',
|
122 |
-
'fields/post',
|
123 |
-
'fields/taxonomy',
|
124 |
-
'fields/taxonomy-advanced',
|
125 |
-
'fields/user',
|
126 |
-
|
127 |
-
'fields/input',
|
128 |
-
|
129 |
-
'fields/checkbox',
|
130 |
-
'fields/number',
|
131 |
-
'fields/range',
|
132 |
-
|
133 |
-
'fields/text',
|
134 |
-
'fields/color',
|
135 |
-
'fields/datetime',
|
136 |
-
'fields/date',
|
137 |
-
'fields/time',
|
138 |
-
'fields/fieldset-text',
|
139 |
-
'fields/key-value',
|
140 |
-
'fields/oembed',
|
141 |
-
'fields/password',
|
142 |
-
|
143 |
-
'fields/file-input',
|
144 |
-
'fields/file',
|
145 |
-
'fields/image',
|
146 |
-
'fields/image-select',
|
147 |
-
|
148 |
-
'fields/media',
|
149 |
-
'fields/file-upload',
|
150 |
-
'fields/image-advanced',
|
151 |
-
'fields/image-upload',
|
152 |
-
|
153 |
-
'fields/button',
|
154 |
-
'fields/custom-html',
|
155 |
-
'fields/divider',
|
156 |
-
'fields/heading',
|
157 |
-
'fields/map',
|
158 |
-
'fields/slider',
|
159 |
-
'fields/textarea',
|
160 |
-
'fields/wysiwyg',
|
161 |
-
);
|
162 |
-
foreach ( $files as $file ) {
|
163 |
-
$this->require_file( RWMB_INC_DIR . "$file.php" );
|
164 |
}
|
165 |
}
|
166 |
|
@@ -168,13 +65,10 @@ class RWMB_Autoloader {
|
|
168 |
* If a file exists, require it from the file system.
|
169 |
*
|
170 |
* @param string $file The file to require.
|
171 |
-
* @return bool True if the file exists, false if not.
|
172 |
*/
|
173 |
protected function require_file( $file ) {
|
174 |
if ( file_exists( $file ) ) {
|
175 |
require_once $file;
|
176 |
-
return true;
|
177 |
}
|
178 |
-
return false;
|
179 |
}
|
180 |
}
|
9 |
* Autoload class
|
10 |
*/
|
11 |
class RWMB_Autoloader {
|
|
|
12 |
/**
|
13 |
* List of directories to load classes.
|
14 |
*
|
19 |
/**
|
20 |
* Adds a base directory for a class name prefix and/or suffix.
|
21 |
*
|
22 |
+
* @param string $dir A base directory for class files.
|
23 |
+
* @param string $prefix The class name prefix.
|
24 |
+
* @param string $suffix The class name suffix.
|
25 |
*/
|
26 |
+
public function add( $dir, $prefix, $suffix = '' ) {
|
27 |
$this->dirs[] = array(
|
28 |
+
'dir' => trailingslashit( $dir ),
|
29 |
'prefix' => $prefix,
|
30 |
'suffix' => $suffix,
|
31 |
);
|
33 |
|
34 |
/**
|
35 |
* Register autoloader for plugin classes.
|
|
|
|
|
|
|
|
|
|
|
36 |
*/
|
37 |
public function register() {
|
38 |
spl_autoload_register( array( $this, 'autoload' ) );
|
|
|
|
|
|
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
+
* Autoload classes.
|
43 |
*
|
44 |
* @param string $class Class name.
|
|
|
45 |
*/
|
46 |
public function autoload( $class ) {
|
47 |
foreach ( $this->dirs as $dir ) {
|
57 |
}
|
58 |
$file = strtolower( str_replace( '_', '-', $file ) ) . '.php';
|
59 |
$file = $dir['dir'] . $file;
|
60 |
+
$this->require_file( $file );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
}
|
63 |
|
65 |
* If a file exists, require it from the file system.
|
66 |
*
|
67 |
* @param string $file The file to require.
|
|
|
68 |
*/
|
69 |
protected function require_file( $file ) {
|
70 |
if ( file_exists( $file ) ) {
|
71 |
require_once $file;
|
|
|
72 |
}
|
|
|
73 |
}
|
74 |
}
|
inc/clone.php
CHANGED
@@ -63,7 +63,7 @@ class RWMB_Clone {
|
|
63 |
$input_html .= '</div>';
|
64 |
|
65 |
$field_html .= $input_html;
|
66 |
-
}
|
67 |
|
68 |
return $field_html;
|
69 |
}
|
63 |
$input_html .= '</div>';
|
64 |
|
65 |
$field_html .= $input_html;
|
66 |
+
}
|
67 |
|
68 |
return $field_html;
|
69 |
}
|
inc/fields/file.php
CHANGED
@@ -101,7 +101,7 @@ class RWMB_File_Field extends RWMB_Field {
|
|
101 |
*/
|
102 |
if ( $attributes['required'] ) {
|
103 |
$attributes['data-required'] = 1;
|
104 |
-
$attributes['required']
|
105 |
}
|
106 |
|
107 |
$html .= sprintf(
|
@@ -167,7 +167,7 @@ class RWMB_File_Field extends RWMB_Field {
|
|
167 |
if ( $field['upload_dir'] ) {
|
168 |
$data = self::file_info_custom_dir( $file, $field );
|
169 |
} else {
|
170 |
-
$data
|
171 |
'icon' => wp_get_attachment_image( $file, array( 60, 60 ), true ),
|
172 |
'name' => basename( get_attached_file( $file ) ),
|
173 |
'url' => wp_get_attachment_url( $file ),
|
101 |
*/
|
102 |
if ( $attributes['required'] ) {
|
103 |
$attributes['data-required'] = 1;
|
104 |
+
$attributes['required'] = false;
|
105 |
}
|
106 |
|
107 |
$html .= sprintf(
|
167 |
if ( $field['upload_dir'] ) {
|
168 |
$data = self::file_info_custom_dir( $file, $field );
|
169 |
} else {
|
170 |
+
$data = array(
|
171 |
'icon' => wp_get_attachment_image( $file, array( 60, 60 ), true ),
|
172 |
'name' => basename( get_attached_file( $file ) ),
|
173 |
'url' => wp_get_attachment_url( $file ),
|
inc/fields/map.php
CHANGED
@@ -81,13 +81,6 @@ class RWMB_Map_Field extends RWMB_Field {
|
|
81 |
esc_attr( $meta )
|
82 |
);
|
83 |
|
84 |
-
if ( $field['address_field'] ) {
|
85 |
-
$html .= sprintf(
|
86 |
-
'<button class="button rwmb-map-goto-address-button">%s</button>',
|
87 |
-
esc_html__( 'Find Address', 'meta-box' )
|
88 |
-
);
|
89 |
-
}
|
90 |
-
|
91 |
$html .= '</div>';
|
92 |
|
93 |
return $html;
|
81 |
esc_attr( $meta )
|
82 |
);
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
$html .= '</div>';
|
85 |
|
86 |
return $html;
|
inc/fields/object-choice.php
CHANGED
@@ -31,7 +31,7 @@ abstract class RWMB_Object_Choice_Field extends RWMB_Choice_Field {
|
|
31 |
* @return string
|
32 |
*/
|
33 |
public static function html( $meta, $field ) {
|
34 |
-
$html
|
35 |
|
36 |
if ( $field['add_new'] ) {
|
37 |
$html .= self::call( 'add_new_form', $field );
|
31 |
* @return string
|
32 |
*/
|
33 |
public static function html( $meta, $field ) {
|
34 |
+
$html = call_user_func( array( self::get_type_class( $field ), 'html' ), $meta, $field );
|
35 |
|
36 |
if ( $field['add_new'] ) {
|
37 |
$html .= self::call( 'add_new_form', $field );
|
inc/fields/osm.php
CHANGED
@@ -15,11 +15,12 @@ class RWMB_OSM_Field extends RWMB_Field {
|
|
15 |
*/
|
16 |
public static function admin_enqueue_scripts() {
|
17 |
// Because map is a hosted service, it's ok to use hosted Leaflet scripts.
|
18 |
-
wp_enqueue_style( 'leaflet', 'https://unpkg.com/leaflet@1.
|
19 |
-
wp_enqueue_script( 'leaflet', 'https://unpkg.com/leaflet@1.
|
20 |
|
21 |
wp_enqueue_style( 'rwmb-osm', RWMB_CSS_URL . 'osm.css', array( 'leaflet' ), RWMB_VER );
|
22 |
-
wp_enqueue_script( 'rwmb-osm', RWMB_JS_URL . 'osm.js', array( 'jquery', 'leaflet' ), RWMB_VER, true );
|
|
|
23 |
RWMB_Helpers_Field::localize_script_once(
|
24 |
'rwmb-osm',
|
25 |
'RWMB_Osm',
|
@@ -54,13 +55,6 @@ class RWMB_OSM_Field extends RWMB_Field {
|
|
54 |
esc_attr( $meta )
|
55 |
);
|
56 |
|
57 |
-
if ( $field['address_field'] ) {
|
58 |
-
$html .= sprintf(
|
59 |
-
'<button class="button rwmb-osm-goto-address-button">%s</button>',
|
60 |
-
esc_html__( 'Find Address', 'meta-box' )
|
61 |
-
);
|
62 |
-
}
|
63 |
-
|
64 |
$html .= '</div>';
|
65 |
|
66 |
return $html;
|
@@ -107,7 +101,7 @@ class RWMB_OSM_Field extends RWMB_Field {
|
|
107 |
|
108 |
/**
|
109 |
* Output the field value.
|
110 |
-
* Display
|
111 |
*
|
112 |
* @param array $field Field parameters.
|
113 |
* @param array $args Additional arguments for the map.
|
@@ -148,13 +142,13 @@ class RWMB_OSM_Field extends RWMB_Field {
|
|
148 |
)
|
149 |
);
|
150 |
|
151 |
-
wp_enqueue_style( 'leaflet', 'https://unpkg.com/leaflet@1.
|
152 |
-
wp_enqueue_script( 'leaflet', 'https://unpkg.com/leaflet@1.
|
153 |
wp_enqueue_script( 'rwmb-osm-frontend', RWMB_JS_URL . 'osm-frontend.js', array( 'jquery', 'leaflet' ), RWMB_VER, true );
|
154 |
|
155 |
/*
|
156 |
* More Open Street Map options
|
157 |
-
* @link https://leafletjs.com/reference-1.
|
158 |
*/
|
159 |
$args['js_options'] = wp_parse_args(
|
160 |
$args['js_options'],
|
15 |
*/
|
16 |
public static function admin_enqueue_scripts() {
|
17 |
// Because map is a hosted service, it's ok to use hosted Leaflet scripts.
|
18 |
+
wp_enqueue_style( 'leaflet', 'https://unpkg.com/leaflet@1.5.1/dist/leaflet.css', array(), '1.5.1' );
|
19 |
+
wp_enqueue_script( 'leaflet', 'https://unpkg.com/leaflet@1.5.1/dist/leaflet.js', array(), '1.5.1', true );
|
20 |
|
21 |
wp_enqueue_style( 'rwmb-osm', RWMB_CSS_URL . 'osm.css', array( 'leaflet' ), RWMB_VER );
|
22 |
+
wp_enqueue_script( 'rwmb-osm', RWMB_JS_URL . 'osm.js', array( 'jquery', 'jquery-ui-autocomplete', 'leaflet' ), RWMB_VER, true );
|
23 |
+
|
24 |
RWMB_Helpers_Field::localize_script_once(
|
25 |
'rwmb-osm',
|
26 |
'RWMB_Osm',
|
55 |
esc_attr( $meta )
|
56 |
);
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
$html .= '</div>';
|
59 |
|
60 |
return $html;
|
101 |
|
102 |
/**
|
103 |
* Output the field value.
|
104 |
+
* Display Open Street Map using Leaflet
|
105 |
*
|
106 |
* @param array $field Field parameters.
|
107 |
* @param array $args Additional arguments for the map.
|
142 |
)
|
143 |
);
|
144 |
|
145 |
+
wp_enqueue_style( 'leaflet', 'https://unpkg.com/leaflet@1.5.1/dist/leaflet.css', array(), '1.5.1' );
|
146 |
+
wp_enqueue_script( 'leaflet', 'https://unpkg.com/leaflet@1.5.1/dist/leaflet.js', array(), '1.5.1', true );
|
147 |
wp_enqueue_script( 'rwmb-osm-frontend', RWMB_JS_URL . 'osm-frontend.js', array( 'jquery', 'leaflet' ), RWMB_VER, true );
|
148 |
|
149 |
/*
|
150 |
* More Open Street Map options
|
151 |
+
* @link https://leafletjs.com/reference-1.5.0.html#map-option
|
152 |
*/
|
153 |
$args['js_options'] = wp_parse_args(
|
154 |
$args['js_options'],
|
inc/fields/post.php
CHANGED
@@ -66,7 +66,7 @@ class RWMB_Post_Field extends RWMB_Object_Choice_Field {
|
|
66 |
* @return array Field options array.
|
67 |
*/
|
68 |
public static function query( $field ) {
|
69 |
-
$args
|
70 |
$field['query_args'],
|
71 |
array(
|
72 |
'post_type' => $field['post_type'],
|
@@ -79,8 +79,11 @@ class RWMB_Post_Field extends RWMB_Object_Choice_Field {
|
|
79 |
);
|
80 |
|
81 |
// Get from cache to prevent same queries.
|
82 |
-
$
|
83 |
-
$
|
|
|
|
|
|
|
84 |
if ( false !== $options ) {
|
85 |
return $options;
|
86 |
}
|
66 |
* @return array Field options array.
|
67 |
*/
|
68 |
public static function query( $field ) {
|
69 |
+
$args = wp_parse_args(
|
70 |
$field['query_args'],
|
71 |
array(
|
72 |
'post_type' => $field['post_type'],
|
79 |
);
|
80 |
|
81 |
// Get from cache to prevent same queries.
|
82 |
+
$last_changed = wp_cache_get_last_changed( 'posts' );
|
83 |
+
$key = md5( serialize( $args ) );
|
84 |
+
$cache_key = "$key:$last_changed";
|
85 |
+
$options = wp_cache_get( $cache_key, 'meta-box-post-field' );
|
86 |
+
|
87 |
if ( false !== $options ) {
|
88 |
return $options;
|
89 |
}
|
inc/fields/taxonomy.php
CHANGED
@@ -66,7 +66,7 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
|
|
66 |
);
|
67 |
|
68 |
// Prevent cloning for taxonomy field, not for child fields (taxonomy_advanced).
|
69 |
-
if ( 'taxonomy'
|
70 |
$field['clone'] = false;
|
71 |
}
|
72 |
|
66 |
);
|
67 |
|
68 |
// Prevent cloning for taxonomy field, not for child fields (taxonomy_advanced).
|
69 |
+
if ( 'taxonomy' === $field['type'] ) {
|
70 |
$field['clone'] = false;
|
71 |
}
|
72 |
|
inc/fields/user.php
CHANGED
@@ -9,6 +9,24 @@
|
|
9 |
* User field class.
|
10 |
*/
|
11 |
class RWMB_User_Field extends RWMB_Object_Choice_Field {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Normalize parameters for field.
|
14 |
*
|
@@ -50,14 +68,16 @@ class RWMB_User_Field extends RWMB_Object_Choice_Field {
|
|
50 |
);
|
51 |
|
52 |
// Get from cache to prevent same queries.
|
53 |
-
$
|
54 |
-
$
|
|
|
|
|
55 |
if ( false !== $options ) {
|
56 |
return $options;
|
57 |
}
|
58 |
|
59 |
-
$users
|
60 |
-
$options
|
61 |
foreach ( $users as $user ) {
|
62 |
$options[ $user->ID ] = array_merge(
|
63 |
array(
|
9 |
* User field class.
|
10 |
*/
|
11 |
class RWMB_User_Field extends RWMB_Object_Choice_Field {
|
12 |
+
/**
|
13 |
+
* Add actions.
|
14 |
+
*/
|
15 |
+
public static function add_actions() {
|
16 |
+
add_action( 'clean_user_cache', array( __CLASS__, 'update_cache' ) );
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Update object cache to make sure query method below always get the fresh list of users.
|
21 |
+
* Unlike posts and terms, WordPress doesn't set 'last_changed' for users.
|
22 |
+
* So we have to do it ourselves.
|
23 |
+
*
|
24 |
+
* @see clean_post_cache()
|
25 |
+
*/
|
26 |
+
public static function update_cache() {
|
27 |
+
wp_cache_set( 'last_changed', microtime(), 'users' );
|
28 |
+
}
|
29 |
+
|
30 |
/**
|
31 |
* Normalize parameters for field.
|
32 |
*
|
68 |
);
|
69 |
|
70 |
// Get from cache to prevent same queries.
|
71 |
+
$last_changed = wp_cache_get_last_changed( 'users' );
|
72 |
+
$key = md5( serialize( $args ) );
|
73 |
+
$cache_key = "$key:$last_changed";
|
74 |
+
$options = wp_cache_get( $cache_key, 'meta-box-user-field' );
|
75 |
if ( false !== $options ) {
|
76 |
return $options;
|
77 |
}
|
78 |
|
79 |
+
$users = get_users( $args );
|
80 |
+
$options = array();
|
81 |
foreach ( $users as $user ) {
|
82 |
$options[ $user->ID ] = array_merge(
|
83 |
array(
|
inc/functions.php
CHANGED
@@ -109,7 +109,7 @@ if ( ! function_exists( 'rwmb_meta_legacy' ) ) {
|
|
109 |
|
110 |
return RWMB_Field::call( $method, $field, $args, $post_id );
|
111 |
}
|
112 |
-
}
|
113 |
|
114 |
if ( ! function_exists( 'rwmb_get_value' ) ) {
|
115 |
/**
|
@@ -182,7 +182,7 @@ if ( ! function_exists( 'rwmb_the_value' ) ) {
|
|
182 |
|
183 |
return $output;
|
184 |
}
|
185 |
-
}
|
186 |
|
187 |
if ( ! function_exists( 'rwmb_get_object_fields' ) ) {
|
188 |
/**
|
109 |
|
110 |
return RWMB_Field::call( $method, $field, $args, $post_id );
|
111 |
}
|
112 |
+
}
|
113 |
|
114 |
if ( ! function_exists( 'rwmb_get_value' ) ) {
|
115 |
/**
|
182 |
|
183 |
return $output;
|
184 |
}
|
185 |
+
}
|
186 |
|
187 |
if ( ! function_exists( 'rwmb_get_object_fields' ) ) {
|
188 |
/**
|
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.18.
|
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.18.1' );
|
22 |
|
23 |
list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
|
24 |
|
js/map.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/* global google */
|
2 |
|
3 |
-
(function ( $, document, window, google ) {
|
4 |
'use strict';
|
5 |
|
6 |
// Use function construction to store map & DOM elements separately for each instance
|
@@ -28,7 +28,6 @@
|
|
28 |
this.$canvas = this.$container.find( '.rwmb-map-canvas' );
|
29 |
this.canvas = this.$canvas[0];
|
30 |
this.$coordinate = this.$container.find( '.rwmb-map-coordinate' );
|
31 |
-
this.$findButton = this.$container.find( '.rwmb-map-goto-address-button' );
|
32 |
this.addressField = this.$container.data( 'address-field' );
|
33 |
},
|
34 |
|
@@ -64,13 +63,28 @@
|
|
64 |
this.map.setCenter( this.marker.position );
|
65 |
this.map.setZoom( zoom );
|
66 |
} else if ( this.addressField ) {
|
67 |
-
this.geocodeAddress();
|
68 |
}
|
69 |
},
|
70 |
|
71 |
// Add event listeners for 'click' & 'drag'
|
72 |
addListeners: function () {
|
73 |
var that = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
google.maps.event.addListener( this.map, 'click', function ( event ) {
|
75 |
that.marker.setPosition( event.latLng );
|
76 |
that.updateCoordinate( event.latLng );
|
@@ -84,29 +98,18 @@
|
|
84 |
that.updateCoordinate( event.latLng );
|
85 |
} );
|
86 |
|
87 |
-
this.$findButton.on( 'click', function () {
|
88 |
-
that.geocodeAddress();
|
89 |
-
return false;
|
90 |
-
} );
|
91 |
-
|
92 |
/**
|
93 |
* Add a custom event that allows other scripts to refresh the maps when needed
|
94 |
* For example: when maps is in tabs or hidden div.
|
95 |
*
|
96 |
* @see https://developers.google.com/maps/documentation/javascript/reference ('resize' Event)
|
97 |
*/
|
98 |
-
$( window ).on( 'rwmb_map_refresh',
|
99 |
-
that.refresh();
|
100 |
-
} );
|
101 |
|
102 |
// Refresh on meta box hide and show
|
103 |
-
$( document ).on( 'postbox-toggled',
|
104 |
-
that.refresh();
|
105 |
-
} );
|
106 |
// Refresh on sorting meta boxes
|
107 |
-
$( '.meta-box-sortables' ).on( 'sortstop',
|
108 |
-
that.refresh();
|
109 |
-
} );
|
110 |
},
|
111 |
|
112 |
refresh: function () {
|
@@ -132,10 +135,7 @@
|
|
132 |
|
133 |
// If Meta Box Geo Location installed. Do not run auto complete.
|
134 |
if ( $( '.rwmb-geo-binding' ).length ) {
|
135 |
-
$address.on( 'selected_address',
|
136 |
-
that.$findButton.trigger( 'click' );
|
137 |
-
} );
|
138 |
-
|
139 |
return false;
|
140 |
}
|
141 |
|
@@ -149,7 +149,7 @@
|
|
149 |
if ( ! results.length ) {
|
150 |
response( [ {
|
151 |
value: '',
|
152 |
-
label:
|
153 |
} ] );
|
154 |
return;
|
155 |
}
|
@@ -179,15 +179,21 @@
|
|
179 |
},
|
180 |
|
181 |
// Find coordinates by address
|
182 |
-
geocodeAddress: function () {
|
183 |
var address = this.getAddress(),
|
184 |
that = this;
|
185 |
if ( ! address ) {
|
186 |
return;
|
187 |
}
|
188 |
|
|
|
|
|
|
|
189 |
geocoder.geocode( {'address': address}, function ( results, status ) {
|
190 |
if ( status !== google.maps.GeocoderStatus.OK ) {
|
|
|
|
|
|
|
191 |
return;
|
192 |
}
|
193 |
that.map.setCenter( results[0].geometry.location );
|
@@ -260,4 +266,4 @@
|
|
260 |
$( '.rwmb-input' ).on( 'clone', update );
|
261 |
} );
|
262 |
|
263 |
-
})( jQuery, document, window, google );
|
1 |
/* global google */
|
2 |
|
3 |
+
(function ( $, document, window, google, i18n ) {
|
4 |
'use strict';
|
5 |
|
6 |
// Use function construction to store map & DOM elements separately for each instance
|
28 |
this.$canvas = this.$container.find( '.rwmb-map-canvas' );
|
29 |
this.canvas = this.$canvas[0];
|
30 |
this.$coordinate = this.$container.find( '.rwmb-map-coordinate' );
|
|
|
31 |
this.addressField = this.$container.data( 'address-field' );
|
32 |
},
|
33 |
|
63 |
this.map.setCenter( this.marker.position );
|
64 |
this.map.setZoom( zoom );
|
65 |
} else if ( this.addressField ) {
|
66 |
+
this.geocodeAddress( false );
|
67 |
}
|
68 |
},
|
69 |
|
70 |
// Add event listeners for 'click' & 'drag'
|
71 |
addListeners: function () {
|
72 |
var that = this;
|
73 |
+
|
74 |
+
/*
|
75 |
+
* Auto change the map when there's change in address fields.
|
76 |
+
* Works only for multiple address fields as single address field has autocomplete functionality.
|
77 |
+
*/
|
78 |
+
if ( this.addressField.split( ',' ).length > 1 ) {
|
79 |
+
var geocodeAddress = that.geocodeAddress.bind( that );
|
80 |
+
var addressFields = this.addressField.split( ',' ).forEach( function( part ) {
|
81 |
+
var $field = that.findAddressField( part );
|
82 |
+
if ( null !== $field ) {
|
83 |
+
$field.on( 'change', geocodeAddress );
|
84 |
+
}
|
85 |
+
} );
|
86 |
+
}
|
87 |
+
|
88 |
google.maps.event.addListener( this.map, 'click', function ( event ) {
|
89 |
that.marker.setPosition( event.latLng );
|
90 |
that.updateCoordinate( event.latLng );
|
98 |
that.updateCoordinate( event.latLng );
|
99 |
} );
|
100 |
|
|
|
|
|
|
|
|
|
|
|
101 |
/**
|
102 |
* Add a custom event that allows other scripts to refresh the maps when needed
|
103 |
* For example: when maps is in tabs or hidden div.
|
104 |
*
|
105 |
* @see https://developers.google.com/maps/documentation/javascript/reference ('resize' Event)
|
106 |
*/
|
107 |
+
$( window ).on( 'rwmb_map_refresh', that.refresh );
|
|
|
|
|
108 |
|
109 |
// Refresh on meta box hide and show
|
110 |
+
$( document ).on( 'postbox-toggled', that.refresh );
|
|
|
|
|
111 |
// Refresh on sorting meta boxes
|
112 |
+
$( '.meta-box-sortables' ).on( 'sortstop', that.refresh );
|
|
|
|
|
113 |
},
|
114 |
|
115 |
refresh: function () {
|
135 |
|
136 |
// If Meta Box Geo Location installed. Do not run auto complete.
|
137 |
if ( $( '.rwmb-geo-binding' ).length ) {
|
138 |
+
$address.on( 'selected_address', that.geocodeAddress );
|
|
|
|
|
|
|
139 |
return false;
|
140 |
}
|
141 |
|
149 |
if ( ! results.length ) {
|
150 |
response( [ {
|
151 |
value: '',
|
152 |
+
label: i18n.no_results_string
|
153 |
} ] );
|
154 |
return;
|
155 |
}
|
179 |
},
|
180 |
|
181 |
// Find coordinates by address
|
182 |
+
geocodeAddress: function ( notify ) {
|
183 |
var address = this.getAddress(),
|
184 |
that = this;
|
185 |
if ( ! address ) {
|
186 |
return;
|
187 |
}
|
188 |
|
189 |
+
if ( false !== notify ) {
|
190 |
+
notify = true;
|
191 |
+
}
|
192 |
geocoder.geocode( {'address': address}, function ( results, status ) {
|
193 |
if ( status !== google.maps.GeocoderStatus.OK ) {
|
194 |
+
if ( notify ) {
|
195 |
+
alert( i18n.no_results_string );
|
196 |
+
}
|
197 |
return;
|
198 |
}
|
199 |
that.map.setCenter( results[0].geometry.location );
|
266 |
$( '.rwmb-input' ).on( 'clone', update );
|
267 |
} );
|
268 |
|
269 |
+
})( jQuery, document, window, google, RWMB_Map );
|
js/osm.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
( function( $, L ) {
|
2 |
'use strict';
|
3 |
|
4 |
// Use function construction to store map & DOM elements separately for each instance
|
@@ -23,7 +23,6 @@
|
|
23 |
this.$canvas = this.$container.find( '.rwmb-osm-canvas' );
|
24 |
this.canvas = this.$canvas[0];
|
25 |
this.$coordinate = this.$container.find( '.rwmb-osm-coordinate' );
|
26 |
-
this.$findButton = this.$container.find( '.rwmb-osm-goto-address-button' );
|
27 |
this.addressField = this.$container.data( 'address-field' );
|
28 |
},
|
29 |
|
@@ -63,13 +62,28 @@
|
|
63 |
this.map.panTo( latLng );
|
64 |
this.map.setZoom( zoom );
|
65 |
} else if ( this.addressField ) {
|
66 |
-
this.geocodeAddress();
|
67 |
}
|
68 |
},
|
69 |
|
70 |
// Add event listeners for 'click' & 'drag'
|
71 |
addListeners: function () {
|
72 |
var that = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
this.map.on( 'click', function ( event ) {
|
74 |
that.marker.setLatLng( event.latlng );
|
75 |
that.updateCoordinate( event.latlng );
|
@@ -83,29 +97,18 @@
|
|
83 |
that.updateCoordinate( that.marker.getLatLng() );
|
84 |
} );
|
85 |
|
86 |
-
this.$findButton.on( 'click', function ( e ) {
|
87 |
-
e.preventDefault();
|
88 |
-
that.geocodeAddress();
|
89 |
-
} );
|
90 |
-
|
91 |
/**
|
92 |
* Add a custom event that allows other scripts to refresh the maps when needed
|
93 |
* For example: when maps is in tabs or hidden div (this is known issue of Google Maps)
|
94 |
*
|
95 |
* @see https://developers.google.com/maps/documentation/javascript/reference ('resize' Event)
|
96 |
*/
|
97 |
-
$( window ).on( 'rwmb_map_refresh',
|
98 |
-
that.refresh();
|
99 |
-
} );
|
100 |
|
101 |
// Refresh on meta box hide and show
|
102 |
-
$( document ).on( 'postbox-toggled',
|
103 |
-
that.refresh();
|
104 |
-
} );
|
105 |
// Refresh on sorting meta boxes
|
106 |
-
$( '.meta-box-sortables' ).on( 'sortstop',
|
107 |
-
that.refresh();
|
108 |
-
} );
|
109 |
},
|
110 |
|
111 |
refresh: function () {
|
@@ -142,7 +145,7 @@
|
|
142 |
if ( ! results.length ) {
|
143 |
response( [ {
|
144 |
value: '',
|
145 |
-
label:
|
146 |
} ] );
|
147 |
return;
|
148 |
}
|
@@ -173,13 +176,16 @@
|
|
173 |
},
|
174 |
|
175 |
// Find coordinates by address
|
176 |
-
geocodeAddress: function () {
|
177 |
var address = this.getAddress(),
|
178 |
that = this;
|
179 |
if ( ! address ) {
|
180 |
return;
|
181 |
}
|
182 |
|
|
|
|
|
|
|
183 |
$.get( 'https://nominatim.openstreetmap.org/search', {
|
184 |
format: 'json',
|
185 |
q: address,
|
@@ -188,6 +194,9 @@
|
|
188 |
"accept-language": that.$canvas.data( 'language' )
|
189 |
}, function( result ) {
|
190 |
if ( result.length !== 1 ) {
|
|
|
|
|
|
|
191 |
return;
|
192 |
}
|
193 |
var latLng = L.latLng( result[0].lat, result[0].lon );
|
@@ -261,4 +270,4 @@
|
|
261 |
$( '.rwmb-input' ).on( 'clone', update );
|
262 |
} );
|
263 |
|
264 |
-
} )( jQuery, L );
|
1 |
+
( function( $, L, i18n ) {
|
2 |
'use strict';
|
3 |
|
4 |
// Use function construction to store map & DOM elements separately for each instance
|
23 |
this.$canvas = this.$container.find( '.rwmb-osm-canvas' );
|
24 |
this.canvas = this.$canvas[0];
|
25 |
this.$coordinate = this.$container.find( '.rwmb-osm-coordinate' );
|
|
|
26 |
this.addressField = this.$container.data( 'address-field' );
|
27 |
},
|
28 |
|
62 |
this.map.panTo( latLng );
|
63 |
this.map.setZoom( zoom );
|
64 |
} else if ( this.addressField ) {
|
65 |
+
this.geocodeAddress( false );
|
66 |
}
|
67 |
},
|
68 |
|
69 |
// Add event listeners for 'click' & 'drag'
|
70 |
addListeners: function () {
|
71 |
var that = this;
|
72 |
+
|
73 |
+
/*
|
74 |
+
* Auto change the map when there's change in address fields.
|
75 |
+
* Works only for multiple address fields as single address field has autocomplete functionality.
|
76 |
+
*/
|
77 |
+
if ( this.addressField.split( ',' ).length > 1 ) {
|
78 |
+
var geocodeAddress = that.geocodeAddress.bind( that );
|
79 |
+
var addressFields = this.addressField.split( ',' ).forEach( function( part ) {
|
80 |
+
var $field = that.findAddressField( part );
|
81 |
+
if ( null !== $field ) {
|
82 |
+
$field.on( 'change', geocodeAddress );
|
83 |
+
}
|
84 |
+
} );
|
85 |
+
}
|
86 |
+
|
87 |
this.map.on( 'click', function ( event ) {
|
88 |
that.marker.setLatLng( event.latlng );
|
89 |
that.updateCoordinate( event.latlng );
|
97 |
that.updateCoordinate( that.marker.getLatLng() );
|
98 |
} );
|
99 |
|
|
|
|
|
|
|
|
|
|
|
100 |
/**
|
101 |
* Add a custom event that allows other scripts to refresh the maps when needed
|
102 |
* For example: when maps is in tabs or hidden div (this is known issue of Google Maps)
|
103 |
*
|
104 |
* @see https://developers.google.com/maps/documentation/javascript/reference ('resize' Event)
|
105 |
*/
|
106 |
+
$( window ).on( 'rwmb_map_refresh', that.refresh );
|
|
|
|
|
107 |
|
108 |
// Refresh on meta box hide and show
|
109 |
+
$( document ).on( 'postbox-toggled', that.refresh );
|
|
|
|
|
110 |
// Refresh on sorting meta boxes
|
111 |
+
$( '.meta-box-sortables' ).on( 'sortstop', that.refresh );
|
|
|
|
|
112 |
},
|
113 |
|
114 |
refresh: function () {
|
145 |
if ( ! results.length ) {
|
146 |
response( [ {
|
147 |
value: '',
|
148 |
+
label: i18n.no_results_string
|
149 |
} ] );
|
150 |
return;
|
151 |
}
|
176 |
},
|
177 |
|
178 |
// Find coordinates by address
|
179 |
+
geocodeAddress: function ( notify ) {
|
180 |
var address = this.getAddress(),
|
181 |
that = this;
|
182 |
if ( ! address ) {
|
183 |
return;
|
184 |
}
|
185 |
|
186 |
+
if ( false !== notify ) {
|
187 |
+
notify = true;
|
188 |
+
}
|
189 |
$.get( 'https://nominatim.openstreetmap.org/search', {
|
190 |
format: 'json',
|
191 |
q: address,
|
194 |
"accept-language": that.$canvas.data( 'language' )
|
195 |
}, function( result ) {
|
196 |
if ( result.length !== 1 ) {
|
197 |
+
if ( notify ) {
|
198 |
+
alert( i18n.no_results_string );
|
199 |
+
}
|
200 |
return;
|
201 |
}
|
202 |
var latLng = L.latLng( result[0].lat, result[0].lon );
|
270 |
$( '.rwmb-input' ).on( 'clone', update );
|
271 |
} );
|
272 |
|
273 |
+
} )( jQuery, L, RWMB_Osm );
|
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.18.
|
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.18.1
|
7 |
* Author: MetaBox.io
|
8 |
* Author URI: https://metabox.io
|
9 |
* License: GPL2+
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: metabox, rilwis, fitwp, f-j-kaiser, funkatronic, PerWiklander, rua
|
|
3 |
Donate link: https://metabox.io/pricing/
|
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: 5.
|
7 |
-
Stable tag: 4.18.
|
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.
|
3 |
Donate link: https://metabox.io/pricing/
|
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: 5.2
|
7 |
+
Stable tag: 4.18.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.
|