Meta Box - Version 4.2.1

Version Description

  • Bug fix: not save wysiwyg field in full screen mode. Link
  • Bug fix: default value for select/checkbox_list. Link
  • Bug fix: duplicated append test to date picker
  • Bug fix: incorrect enqueue styles, issue #166
  • Improvement: initial new field type map
Download this release

Release Info

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

Code changes from version 4.2 to 4.2.1

demo/map.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ add_action( 'admin_init', 'test_register_meta_boxes' );
3
+ function test_register_meta_boxes()
4
+ {
5
+ if ( !class_exists( 'RW_Meta_Box' ) )
6
+ return;
7
+
8
+ $meta_box = array(
9
+ 'title' => 'Google Map',
10
+ 'fields' => array(
11
+ array(
12
+ 'id' => 'address',
13
+ 'name' => 'Address',
14
+ 'type' => 'text',
15
+ 'std' => 'Hanoi, Vietnam',
16
+ ),
17
+ array(
18
+ 'id' => 'loc',
19
+ 'name' => 'Location',
20
+ 'type' => 'map',
21
+ 'std' => '-6.233406,-35.049906,15', // 'latitude,longitude[,zoom]' (zoom is optional)
22
+ 'style' => 'width: 500px; height: 500px',
23
+ 'address_field' => 'address', // Name of text field where address is entered. Can be list of text fields, separated by commas (for ex. city, state)
24
+ ),
25
+ ),
26
+ );
27
+
28
+ new RW_Meta_Box( $meta_box );
29
+ }
inc/classes/meta-box.php CHANGED
@@ -91,7 +91,7 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
91
  if ( 'post' != $screen->base || ! in_array( $screen->post_type, $this->meta_box['pages'] ) )
92
  return;
93
 
94
- wp_enqueue_style( 'rwmb', RWMB_CSS_URL . 'style.css', RWMB_VER );
95
 
96
  // Load clone script conditionally
97
  $has_clone = false;
@@ -403,7 +403,15 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
403
  */
404
  function save_post( $post_id )
405
  {
406
- global $post_type;
 
 
 
 
 
 
 
 
407
  $post_type_object = get_post_type_object( $post_type );
408
 
409
  // Check whether:
91
  if ( 'post' != $screen->base || ! in_array( $screen->post_type, $this->meta_box['pages'] ) )
92
  return;
93
 
94
+ wp_enqueue_style( 'rwmb', RWMB_CSS_URL . 'style.css', array(), RWMB_VER );
95
 
96
  // Load clone script conditionally
97
  $has_clone = false;
403
  */
404
  function save_post( $post_id )
405
  {
406
+ // Get proper post type. @link http://www.deluxeblogtips.com/forums/viewtopic.php?id=161
407
+ $post_type = null;
408
+ $post = get_post( $post_id );
409
+
410
+ if ( $post )
411
+ $post_type = $post->post_type;
412
+ elseif ( isset( $_POST['post_type'] ) && post_type_exists( $_POST['post_type'] ) )
413
+ $post_type = $_POST['post_type'];
414
+
415
  $post_type_object = get_post_type_object( $post_type );
416
 
417
  // Check whether:
inc/fields/checkbox-list.php CHANGED
@@ -52,7 +52,13 @@ if ( ! class_exists( 'RWMB_Checkbox_List_Field' ) )
52
  */
53
  static function meta( $meta, $post_id, $saved, $field )
54
  {
55
- return (array) get_post_meta( $post_id, $field['id'], $field['clone'] );
 
 
 
 
 
 
56
  }
57
 
58
  /**
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;
62
  }
63
 
64
  /**
inc/fields/file_single.php DELETED
@@ -1,198 +0,0 @@
1
- <?php
2
- // Prevent loading this file directly
3
- defined( 'ABSPATH' ) || exit;
4
-
5
- if ( ! class_exists( 'RWMB_File_Field' ) )
6
- {
7
- class RWMB_File_Field
8
- {
9
- /**
10
- * Enqueue scripts and styles
11
- *
12
- * @return void
13
- */
14
- static function admin_enqueue_scripts()
15
- {
16
- wp_enqueue_script( 'rwmb-file', RWMB_JS_URL . 'file.js', array( 'jquery', 'wp-ajax-response' ), RWMB_VER, true );
17
- }
18
-
19
- /**
20
- * Add actions
21
- *
22
- * @return void
23
- */
24
- static function add_actions()
25
- {
26
- // Add data encoding type for file uploading
27
- add_action( 'post_edit_form_tag', array( __CLASS__, 'post_edit_form_tag' ) );
28
-
29
- // Delete file via Ajax
30
- add_action( 'wp_ajax_rwmb_delete_file', array( __CLASS__, 'wp_ajax_delete_file' ) );
31
- }
32
-
33
- /**
34
- * Add data encoding type for file uploading
35
- *
36
- * @return void
37
- */
38
- static function post_edit_form_tag()
39
- {
40
- echo ' enctype="multipart/form-data"';
41
- }
42
-
43
- /**
44
- * Ajax callback for deleting files.
45
- * Modified from a function used by "Verve Meta Boxes" plugin
46
- *
47
- * @link http://goo.gl/LzYSq
48
- * @return void
49
- */
50
- static function wp_ajax_delete_file()
51
- {
52
- $post_id = isset( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : 0;
53
- $field_id = isset( $_POST['field_id'] ) ? $_POST['field_id'] : 0;
54
- $attachment_id = isset( $_POST['attachment_id'] ) ? intval( $_POST['attachment_id'] ) : 0;
55
-
56
- check_admin_referer( "rwmb-delete-file_{$field_id}" );
57
-
58
- delete_post_meta( $post_id, $field_id, $attachment_id );
59
- $ok = wp_delete_attachment( $attachment_id );
60
-
61
- if ( $ok )
62
- RW_Meta_Box::ajax_response( '', 'success' );
63
- else
64
- RW_Meta_Box::ajax_response( __( 'Error: Cannot delete file', 'rwmb' ), 'error' );
65
- }
66
-
67
- /**
68
- * Get field HTML
69
- *
70
- * @param string $html
71
- * @param mixed $meta
72
- * @param array $field
73
- *
74
- * @return string
75
- */
76
- static function html( $html, $meta, $field )
77
- {
78
- $i18n_delete = _x( 'Delete', 'file upload', 'rwmb' );
79
-
80
- $html = wp_nonce_field( "rwmb-delete-file_{$field['id']}", "nonce-delete-file_{$field['id']}", false, false );
81
-
82
- if ( $meta )
83
- {
84
- $html .= '<ol class="rwmb-uploaded">';
85
- $li = '<li>%s (<a title="%s" class="rwmb-delete-file" href="#" data-field_id="%s" data-attachment_id="%s">%s</a>)</li>';
86
-
87
- $attachment = wp_get_attachment_link( $meta );
88
- $html .= sprintf(
89
- $li,
90
- $attachment,
91
- $i18n_delete,
92
- $field['id'],
93
- $meta,
94
- $i18n_delete
95
- );
96
-
97
- $html .= '</ol>';
98
- }
99
-
100
- // Show form upload
101
- $html .= sprintf(
102
- '<input type="file" name="%s" />',
103
- $field['field_name']
104
- );
105
-
106
- return $html;
107
- }
108
-
109
- /**
110
- * Get meta values to save
111
- *
112
- * @param mixed $new
113
- * @param mixed $old
114
- * @param int $post_id
115
- * @param array $field
116
- *
117
- * @return array|mixed
118
- */
119
- static function value( $new, $old, $post_id, $field )
120
- {
121
- $name = $field['id'];
122
- if ( empty( $_FILES[$name] ) )
123
- return $new;
124
-
125
- $new = array();
126
- if ( $field['clone'] )
127
- $files = self::fix_file_array( $_FILES[$name] );
128
- else
129
- $files = array( $_FILES[$name] );
130
-
131
- foreach ( $files as $file_item )
132
- {
133
- $file = wp_handle_upload( $file_item, array( 'test_form' => false ) );
134
-
135
- if ( ! isset( $file['file'] ) )
136
- continue;
137
-
138
- $file_name = $file['file'];
139
-
140
- $attachment = array(
141
- 'post_mime_type' => $file['type'],
142
- 'guid' => $file['url'],
143
- 'post_parent' => $post_id,
144
- 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $file_name ) ),
145
- 'post_content' => '',
146
- );
147
- $id = wp_insert_attachment( $attachment, $file_name, $post_id );
148
-
149
- if ( ! is_wp_error( $id ) )
150
- {
151
- wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file_name ) );
152
-
153
- // Save file ID in meta field
154
- $new[] = $id;
155
- }
156
- }
157
-
158
- return $field['clone'] ? $new : array_shift( $new );
159
- }
160
-
161
- /**
162
- * Fixes the odd indexing of multiple file uploads from the format:
163
- * $_FILES['field']['key']['index']
164
- * To the more standard and appropriate:
165
- * $_FILES['field']['index']['key']
166
- *
167
- * @param array $files
168
- *
169
- * @return array
170
- */
171
- static function fix_file_array( $files )
172
- {
173
- $output = array();
174
- foreach ( $files as $key => $list )
175
- {
176
- foreach ( $list as $index => $value )
177
- {
178
- $output[$index][$key] = $value;
179
- }
180
- }
181
- return $output;
182
- }
183
-
184
- /**
185
- * Normalize parameters for field
186
- *
187
- * @param array $field
188
- *
189
- * @return array
190
- */
191
- // static function normalize_field( $field )
192
- // {
193
- // $field['multiple'] = true;
194
- // $field['std'] = empty( $field['std'] ) ? array() : $field['std'];
195
- // return $field;
196
- // }
197
- }
198
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/fields/map.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Prevent loading this file directly
3
+ defined( 'ABSPATH' ) || exit;
4
+
5
+ if ( !class_exists( 'RWMB_Map_Field' ) )
6
+ {
7
+ class RWMB_Map_Field
8
+ {
9
+ /**
10
+ * Enqueue scripts and styles
11
+ *
12
+ * @return void
13
+ */
14
+ static function admin_enqueue_scripts()
15
+ {
16
+ wp_enqueue_script( 'googlemap', 'http://maps.google.com/maps/api/js?sensor=false', array(), '', true );
17
+ wp_enqueue_script( 'rwmb-map', RWMB_JS_URL . 'map.js', array( 'jquery', 'googlemap' ), RWMB_VER, true );
18
+ }
19
+
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
+
33
+ $html = sprintf(
34
+ '<div class="rwmb-map-canvas" style="%s"></div>
35
+ <input type="hidden" name="%s" id="rwmb-map-coordinate" value="%s" />',
36
+ isset( $field['style'] ) ? $field['style'] : '',
37
+ $field['field_name'],
38
+ $meta
39
+ );
40
+
41
+ if ( $address )
42
+ {
43
+ $html .= sprintf(
44
+ '<button class="button" type="button" id="rwmb-map-goto-address-button" value="%s" onclick="geocodeAddress(this.value);">%s</button>',
45
+ is_array( $address ) ? implode( ',', $address ) : $address,
46
+ __( 'Find Address', 'rwmb' )
47
+ );
48
+ }
49
+ return $html;
50
+ }
51
+ }
52
+ }
inc/fields/select.php CHANGED
@@ -2,18 +2,18 @@
2
  // Prevent loading this file directly
3
  defined( 'ABSPATH' ) || exit;
4
 
5
- if ( ! class_exists( 'RWMB_Select_Field' ) )
6
  {
7
  class RWMB_Select_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-select', RWMB_CSS_URL.'select.css', RWMB_VER );
17
  }
18
 
19
  /**
@@ -27,9 +27,6 @@ if ( ! class_exists( 'RWMB_Select_Field' ) )
27
  */
28
  static function html( $html, $meta, $field )
29
  {
30
- if ( ! is_array( $meta ) )
31
- $meta = (array) $meta;
32
-
33
  $html = sprintf(
34
  '<select class="rwmb-select" name="%s" id="%s"%s>',
35
  $field['field_name'],
@@ -71,7 +68,12 @@ if ( ! class_exists( 'RWMB_Select_Field' ) )
71
  static function meta( $meta, $post_id, $saved, $field )
72
  {
73
  $single = $field['clone'] || !$field['multiple'];
74
- return (array) get_post_meta( $post_id, $field['id'], $single );
 
 
 
 
 
75
  }
76
 
77
  /**
2
  // Prevent loading this file directly
3
  defined( 'ABSPATH' ) || exit;
4
 
5
+ if ( !class_exists( 'RWMB_Select_Field' ) )
6
  {
7
  class RWMB_Select_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-select', RWMB_CSS_URL . 'select.css', array(), RWMB_VER );
17
  }
18
 
19
  /**
27
  */
28
  static function html( $html, $meta, $field )
29
  {
 
 
 
30
  $html = sprintf(
31
  '<select class="rwmb-select" name="%s" id="%s"%s>',
32
  $field['field_name'],
68
  static function meta( $meta, $post_id, $saved, $field )
69
  {
70
  $single = $field['clone'] || !$field['multiple'];
71
+ $meta = get_post_meta( $post_id, $field['id'], $single );
72
+ $meta = ( !$saved && '' === $meta || array() === $meta ) ? $field['std'] : $meta;
73
+
74
+ $meta = array_map( 'esc_attr', (array) $meta );
75
+
76
+ return $meta;
77
  }
78
 
79
  /**
inc/fields/wysiwyg.php CHANGED
@@ -2,24 +2,24 @@
2
  // Prevent loading this file directly
3
  defined( 'ABSPATH' ) || exit;
4
 
5
- if ( ! class_exists( 'RWMB_Wysiwyg_Field' ) )
6
  {
7
  class RWMB_Wysiwyg_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-meta-box-wysiwyg', RWMB_CSS_URL.'wysiwyg.css', RWMB_VER );
17
  }
18
 
19
  /**
20
  * Add field actions
21
  *
22
- * @return void
23
  */
24
  static function add_actions()
25
  {
@@ -99,7 +99,7 @@ if ( ! class_exists( 'RWMB_Wysiwyg_Field' ) )
99
 
100
  $field['options'] = wp_parse_args( $field['options'], array(
101
  'editor_class' => 'rwmb-wysiwyg',
102
- 'dfw' => true, // Use default WordPress full screen UI
103
  ) );
104
 
105
  // Keep the filter to be compatible with previous versions
2
  // Prevent loading this file directly
3
  defined( 'ABSPATH' ) || exit;
4
 
5
+ if ( !class_exists( 'RWMB_Wysiwyg_Field' ) )
6
  {
7
  class RWMB_Wysiwyg_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-meta-box-wysiwyg', RWMB_CSS_URL . 'wysiwyg.css', array(), RWMB_VER );
17
  }
18
 
19
  /**
20
  * Add field actions
21
  *
22
+ * @return void
23
  */
24
  static function add_actions()
25
  {
99
 
100
  $field['options'] = wp_parse_args( $field['options'], array(
101
  'editor_class' => 'rwmb-wysiwyg',
102
+ 'dfw' => true, // Use default WordPress full screen UI
103
  ) );
104
 
105
  // Keep the filter to be compatible with previous versions
js/clone.js CHANGED
@@ -1,4 +1,4 @@
1
- jQuery( document ).ready( function ( $ )
2
  {
3
  toggle_remove_buttons();
4
 
@@ -15,7 +15,7 @@ jQuery( document ).ready( function ( $ )
15
  $input.val( '' );
16
 
17
  // Get the field name, and increment
18
- name = $input.attr( 'name' ).replace( /\[(\d+)\]/, function ( match, p1 )
19
  {
20
  return '[' + ( parseInt( p1 ) + 1 ) + ']';
21
  } );
@@ -44,7 +44,7 @@ jQuery( document ).ready( function ( $ )
44
  }
45
 
46
  // Add more clones
47
- $( '.add-clone' ).click( function ()
48
  {
49
  var $input = $( this ).parents( '.rwmb-input' ),
50
  $clone_group = $( this ).parents( '.rwmb-field' ).attr( "clone-group" );
@@ -59,7 +59,7 @@ jQuery( document ).ready( function ( $ )
59
  var $clone_group_list = $metabox.find( 'div[clone-group="' + $clone_group + '"]' );
60
 
61
  $.each( $clone_group_list.find( '.rwmb-input' ),
62
- function ( key, value )
63
  {
64
  add_cloned_fields( $( value ) );
65
  } );
@@ -73,7 +73,7 @@ jQuery( document ).ready( function ( $ )
73
  } );
74
 
75
  // Remove clones
76
- $( '.rwmb-input' ).delegate( '.remove-clone', 'click', function ()
77
  {
78
  var $this = $( this ),
79
  $input = $this.parents( '.rwmb-input' ),
@@ -92,7 +92,7 @@ jQuery( document ).ready( function ( $ )
92
  var $index = $this.parent().index();
93
 
94
  $.each( $clone_group_list.find( '.rwmb-input' ),
95
- function ( key, value )
96
  {
97
  $( value ).children( '.rwmb-clone' ).eq( $index ).remove();
98
 
@@ -123,7 +123,7 @@ jQuery( document ).ready( function ( $ )
123
  var $button;
124
  if ( !$el )
125
  $el = $( '.rwmb-field' );
126
- $el.each( function ()
127
  {
128
  $button = $( this ).find( '.remove-clone' );
129
  $button.length < 2 ? $button.hide() : $button.show();
1
+ jQuery( document ).ready( function( $ )
2
  {
3
  toggle_remove_buttons();
4
 
15
  $input.val( '' );
16
 
17
  // Get the field name, and increment
18
+ name = $input.attr( 'name' ).replace( /\[(\d+)\]/, function( match, p1 )
19
  {
20
  return '[' + ( parseInt( p1 ) + 1 ) + ']';
21
  } );
44
  }
45
 
46
  // Add more clones
47
+ $( '.add-clone' ).click( function()
48
  {
49
  var $input = $( this ).parents( '.rwmb-input' ),
50
  $clone_group = $( this ).parents( '.rwmb-field' ).attr( "clone-group" );
59
  var $clone_group_list = $metabox.find( 'div[clone-group="' + $clone_group + '"]' );
60
 
61
  $.each( $clone_group_list.find( '.rwmb-input' ),
62
+ function( key, value )
63
  {
64
  add_cloned_fields( $( value ) );
65
  } );
73
  } );
74
 
75
  // Remove clones
76
+ $( '.rwmb-input' ).delegate( '.remove-clone', 'click', function()
77
  {
78
  var $this = $( this ),
79
  $input = $this.parents( '.rwmb-input' ),
92
  var $index = $this.parent().index();
93
 
94
  $.each( $clone_group_list.find( '.rwmb-input' ),
95
+ function( key, value )
96
  {
97
  $( value ).children( '.rwmb-clone' ).eq( $index ).remove();
98
 
123
  var $button;
124
  if ( !$el )
125
  $el = $( '.rwmb-field' );
126
+ $el.each( function()
127
  {
128
  $button = $( this ).find( '.remove-clone' );
129
  $button.length < 2 ? $button.hide() : $button.show();
js/color.js CHANGED
@@ -11,14 +11,14 @@ function rwmb_update_color_picker()
11
  $input = $this.siblings( 'input.rwmb-color' );
12
 
13
  // Make sure the value is displayed
14
- if ( ! $input.val() )
15
  $input.val( '#' );
16
 
17
  $this.farbtastic( $input );
18
  } );
19
  }
20
 
21
- jQuery( document ).ready( function($)
22
  {
23
  $( '.rwmb-input' ).delegate( '.rwmb-color', 'focus', function()
24
  {
11
  $input = $this.siblings( 'input.rwmb-color' );
12
 
13
  // Make sure the value is displayed
14
+ if ( !$input.val() )
15
  $input.val( '#' );
16
 
17
  $this.farbtastic( $input );
18
  } );
19
  }
20
 
21
+ jQuery( document ).ready( function( $ )
22
  {
23
  $( '.rwmb-input' ).delegate( '.rwmb-color', 'focus', function()
24
  {
js/date.js CHANGED
@@ -11,11 +11,12 @@ function rwmb_update_date_picker()
11
  var $this = $( this ),
12
  options = $this.data( 'options' );
13
 
14
- $this.removeClass( 'hasDatepicker' ).attr( 'id', '' ).datepicker( options );
 
15
  } );
16
  }
17
 
18
- jQuery( document ).ready( function($)
19
  {
20
  rwmb_update_date_picker();
21
  } );
11
  var $this = $( this ),
12
  options = $this.data( 'options' );
13
 
14
+ $this.siblings( '.ui-datepicker-append' ).remove(); // Remove appended text
15
+ $this.removeClass( 'hasDatepicker' ).datepicker( options );
16
  } );
17
  }
18
 
19
+ jQuery( document ).ready( function()
20
  {
21
  rwmb_update_date_picker();
22
  } );
js/datetime.js CHANGED
@@ -11,11 +11,12 @@ function rwmb_update_datetime_picker()
11
  var $this = $( this ),
12
  options = $this.data( 'options' );
13
 
14
- $this.removeClass( 'hasDatepicker' ).attr( 'id', '' ).datetimepicker( options );
 
15
  } );
16
  }
17
 
18
- jQuery( document ).ready( function($)
19
  {
20
  rwmb_update_datetime_picker();
21
  } );
11
  var $this = $( this ),
12
  options = $this.data( 'options' );
13
 
14
+ $this.siblings( '.ui-datepicker-append' ).remove(); // Remove appended text
15
+ $this.removeClass( 'hasDatepicker' ).datepicker( options );
16
  } );
17
  }
18
 
19
+ jQuery( document ).ready( function()
20
  {
21
  rwmb_update_datetime_picker();
22
  } );
js/file.js CHANGED
@@ -1,7 +1,7 @@
1
- jQuery( document ).ready( function ( $ )
2
  {
3
  // Add more file
4
- $( '.rwmb-add-file' ).click( function ()
5
  {
6
  var $this = $( this ), $first = $this.parent().find( '.file-input:first' );
7
 
@@ -11,7 +11,7 @@ jQuery( document ).ready( function ( $ )
11
  } );
12
 
13
  // Delete file via Ajax
14
- $( '.rwmb-uploaded' ).delegate( '.rwmb-delete-file', 'click', function ()
15
  {
16
  var $this = $( this ),
17
  $parent = $this.parents( 'li' ),
@@ -24,7 +24,7 @@ jQuery( document ).ready( function ( $ )
24
  attachment_id: $this.data( 'attachment_id' )
25
  };
26
 
27
- $.post( ajaxurl, data, function ( r )
28
  {
29
  var res = wpAjax.parseAjaxResponse( r, 'ajax-response' );
30
 
1
+ jQuery( document ).ready( function( $ )
2
  {
3
  // Add more file
4
+ $( '.rwmb-add-file' ).click( function()
5
  {
6
  var $this = $( this ), $first = $this.parent().find( '.file-input:first' );
7
 
11
  } );
12
 
13
  // Delete file via Ajax
14
+ $( '.rwmb-uploaded' ).delegate( '.rwmb-delete-file', 'click', function()
15
  {
16
  var $this = $( this ),
17
  $parent = $this.parents( 'li' ),
24
  attachment_id: $this.data( 'attachment_id' )
25
  };
26
 
27
+ $.post( ajaxurl, data, function( r )
28
  {
29
  var res = wpAjax.parseAjaxResponse( r, 'ajax-response' );
30
 
js/image.js CHANGED
@@ -1,21 +1,21 @@
1
- jQuery( document ).ready( function($)
2
  {
3
  // Reorder images
4
  $( '.rwmb-images' ).each( function()
5
  {
6
- var $this = $(this),
7
- field_id = $this.parents( '.rwmb-field' ).find( '.field-id' ).val(),
8
- data = {
9
  action : 'rwmb_reorder_images',
10
- _wpnonce: $('#nonce-reorder-images_' + field_id).val(),
11
- post_id : $('#post_ID').val(),
12
  field_id: field_id
13
  };
14
- $this.sortable(
15
- {
16
  placeholder: 'ui-state-highlight',
17
- items: 'li',
18
- update: function () {
 
19
  data.order = $this.sortable( 'serialize' );
20
 
21
  $.post( ajaxurl, data, function( r )
1
+ jQuery( document ).ready( function( $ )
2
  {
3
  // Reorder images
4
  $( '.rwmb-images' ).each( function()
5
  {
6
+ var $this = $( this ),
7
+ field_id = $this.parents( '.rwmb-field' ).find( '.field-id' ).val(),
8
+ data = {
9
  action : 'rwmb_reorder_images',
10
+ _wpnonce: $( '#nonce-reorder-images_' + field_id ).val(),
11
+ post_id : $( '#post_ID' ).val(),
12
  field_id: field_id
13
  };
14
+ $this.sortable( {
 
15
  placeholder: 'ui-state-highlight',
16
+ items : 'li',
17
+ update : function()
18
+ {
19
  data.order = $this.sortable( 'serialize' );
20
 
21
  $.post( ajaxurl, data, function( r )
js/map.js ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var marker, map, geocoder;
2
+
3
+ jQuery( document ).ready( function ()
4
+ {
5
+ var latlng = new google.maps.LatLng( 53.346881, -6.258860 );
6
+ map = new google.maps.Map( jQuery( '.rwmb-map-canvas' )[0], {zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP} );
7
+ marker = new google.maps.Marker( {position: latlng, map: map, draggable: true} );
8
+ geocoder = new google.maps.Geocoder();
9
+ google.maps.event.addListener( map, 'click', function ( event )
10
+ {
11
+ marker.setPosition( event.latLng );
12
+ updatePositionInput( event.latLng );
13
+ } );
14
+ google.maps.event.addListener( marker, 'drag', function ( event )
15
+ {
16
+ updatePositionInput( event.latLng );
17
+ } );
18
+ updatePositionMarker();
19
+ } );
20
+
21
+ function updatePositionInput( latLng )
22
+ {
23
+ jQuery( '#rwmb-map-coordinate' ).val( latLng.lat() + ',' + latLng.lng() );
24
+ }
25
+
26
+ function updatePositionMarker()
27
+ {
28
+ var coord = jQuery( '#rwmb-map-coordinate' ).val(),
29
+ addressField = jQuery( '#rwmb-map-goto-address-button' ).val(),
30
+ l, zoom;
31
+
32
+ if ( coord )
33
+ {
34
+ l = coord.split( ',' );
35
+ marker.setPosition( new google.maps.LatLng( l[0], l[1] ) );
36
+ zoom = l.length > 2 ? parseInt( l[2] ) : 15;
37
+
38
+ map.setCenter( marker.position );
39
+ map.setZoom( zoom );
40
+ }
41
+ else
42
+ if ( addressField )
43
+ geocodeAddress( addressField );
44
+ }
45
+
46
+ function geocodeAddress( addressField )
47
+ {
48
+ var address = '',
49
+ fieldList = addressField.split( ',' ),
50
+ loop;
51
+
52
+ for ( loop = 0; loop < fieldList.length; loop++ )
53
+ {
54
+ address += jQuery( '#' + fieldList[loop] ).val();
55
+ }
56
+
57
+ address = address.replace( /\n/g, ',' );
58
+ address = address.replace( /,,/g, ',' );
59
+ geocoder.geocode( {'address': address}, function ( results, status )
60
+ {
61
+ if ( status == google.maps.GeocoderStatus.OK )
62
+ {
63
+ updatePositionInput( results[0].geometry.location );
64
+ marker.setPosition( results[0].geometry.location );
65
+ map.setCenter( marker.position );
66
+ map.setZoom( 15 );
67
+ }
68
+ } );
69
+ }
js/plupload-image.js CHANGED
@@ -1,4 +1,4 @@
1
- jQuery( document ).ready( function($)
2
  {
3
  // Object containing all the plupload uploaders
4
  var rwmb_image_uploaders = {},
@@ -8,7 +8,7 @@ jQuery( document ).ready( function($)
8
  // Note that we can have multiple upload forms in the page, so relative path to current element is important
9
  $( '.rwmb-uploaded' ).each( function()
10
  {
11
- var $this = $(this),
12
  $lis = $this.children(),
13
  $title = $this.siblings( '.rwmb-uploaded-title' );
14
  if ( 0 == $lis.length )
@@ -22,7 +22,7 @@ jQuery( document ).ready( function($)
22
  $( '.rwmb-images' ).on( 'click', '.rwmb-delete-file', function()
23
  {
24
  // Check if we need to show drop target
25
- var $images = $(this).parents( '.rwmb-images' ),
26
  uploaded = $images.children().length - 1, // -1 for the one we just deleted
27
  $dragndrop = $images.siblings( '.rwmb-drag-drop' );
28
 
@@ -124,7 +124,7 @@ jQuery( document ).ready( function($)
124
  var res = wpAjax.parseAjaxResponse( $.parseXML( response.response ), 'ajax-response' );
125
  false === res.errors ? $( 'li#' + file.id ).replaceWith( res.responses[0].data ) : remove_error( file );
126
  } );
127
- });
128
 
129
  /**
130
  * Helper functions
@@ -141,10 +141,10 @@ jQuery( document ).ready( function($)
141
  .addClass( 'rwmb-image-error' )
142
  .delay( 1600 )
143
  .fadeOut( 'slow', function()
144
- {
145
- $(this).remove();
146
- }
147
- );
148
  }
149
 
150
  /**
@@ -167,4 +167,4 @@ jQuery( document ).ready( function($)
167
  {
168
  $( '#' + file.id + '-throbber' ).html( "<img class='rwmb-loader' height='64' width='64' src='" + RWMB.url + "img/loader.gif'/>" );
169
  }
170
- });
1
+ jQuery( document ).ready( function( $ )
2
  {
3
  // Object containing all the plupload uploaders
4
  var rwmb_image_uploaders = {},
8
  // Note that we can have multiple upload forms in the page, so relative path to current element is important
9
  $( '.rwmb-uploaded' ).each( function()
10
  {
11
+ var $this = $( this ),
12
  $lis = $this.children(),
13
  $title = $this.siblings( '.rwmb-uploaded-title' );
14
  if ( 0 == $lis.length )
22
  $( '.rwmb-images' ).on( 'click', '.rwmb-delete-file', function()
23
  {
24
  // Check if we need to show drop target
25
+ var $images = $( this ).parents( '.rwmb-images' ),
26
  uploaded = $images.children().length - 1, // -1 for the one we just deleted
27
  $dragndrop = $images.siblings( '.rwmb-drag-drop' );
28
 
124
  var res = wpAjax.parseAjaxResponse( $.parseXML( response.response ), 'ajax-response' );
125
  false === res.errors ? $( 'li#' + file.id ).replaceWith( res.responses[0].data ) : remove_error( file );
126
  } );
127
+ } );
128
 
129
  /**
130
  * Helper functions
141
  .addClass( 'rwmb-image-error' )
142
  .delay( 1600 )
143
  .fadeOut( 'slow', function()
144
+ {
145
+ $( this ).remove();
146
+ }
147
+ );
148
  }
149
 
150
  /**
167
  {
168
  $( '#' + file.id + '-throbber' ).html( "<img class='rwmb-loader' height='64' width='64' src='" + RWMB.url + "img/loader.gif'/>" );
169
  }
170
+ } );
js/slider.js CHANGED
@@ -1,4 +1,4 @@
1
- jQuery( document ).ready( function ( $ )
2
  {
3
  var
4
  id = null
@@ -9,7 +9,7 @@ jQuery( document ).ready( function ( $ )
9
  , value = null
10
  , update = null
11
  ;
12
- $( '.rwmb-slider' ).each( function ( i, val )
13
  {
14
  id = $( val ).attr( 'id' );
15
  el = $( '#' + id );
@@ -40,7 +40,7 @@ jQuery( document ).ready( function ( $ )
40
  el.slider(
41
  {
42
  value: value,
43
- slide: function ( event, ui )
44
  {
45
  $( input ).val( ui.value );
46
  $( update ).text( ui.value + ' ' + format );
1
+ jQuery( document ).ready( function( $ )
2
  {
3
  var
4
  id = null
9
  , value = null
10
  , update = null
11
  ;
12
+ $( '.rwmb-slider' ).each( function( i, val )
13
  {
14
  id = $( val ).attr( 'id' );
15
  el = $( '#' + id );
40
  el.slider(
41
  {
42
  value: value,
43
+ slide: function( event, ui )
44
  {
45
  $( input ).val( ui.value );
46
  $( update ).text( ui.value + ' ' + format );
js/taxonomy.js CHANGED
@@ -1,4 +1,4 @@
1
- jQuery( document ).ready( function($)
2
  {
3
  $( '.rw-taxonomy-tree input:checkbox' ).change( function()
4
  {
@@ -8,20 +8,21 @@ jQuery( document ).ready( function($)
8
  $childList.removeClass( 'hidden' );
9
  else
10
  {
11
- $('input', $childList).removeAttr('checked');
12
  $childList.addClass( 'hidden' );
13
  }
14
  } );
15
-
16
  $( '.rw-taxonomy-tree select' ).change( function()
17
  {
18
  var $this = $( this ),
19
  $childList = $this.parent().find( 'div.rw-taxonomy-tree' ),
20
  $value = $this.val();
21
- $childList.removeClass('active').addClass('disabled').find('select').each(function(){
22
- $(this).val($('options:first', this).val()).attr("disabled", "disabled")
23
- });
24
- $childList.filter('#rwmb-taxonomy-' + $value).removeClass('disabled').addClass('active').children('select').removeAttr('disabled');
25
-
 
26
  } );
27
  } );
1
+ jQuery( document ).ready( function( $ )
2
  {
3
  $( '.rw-taxonomy-tree input:checkbox' ).change( function()
4
  {
8
  $childList.removeClass( 'hidden' );
9
  else
10
  {
11
+ $( 'input', $childList ).removeAttr( 'checked' );
12
  $childList.addClass( 'hidden' );
13
  }
14
  } );
15
+
16
  $( '.rw-taxonomy-tree select' ).change( function()
17
  {
18
  var $this = $( this ),
19
  $childList = $this.parent().find( 'div.rw-taxonomy-tree' ),
20
  $value = $this.val();
21
+ $childList.removeClass( 'active' ).addClass( 'disabled' ).find( 'select' ).each( function()
22
+ {
23
+ $( this ).val( $( 'options:first', this ).val() ).attr( "disabled", "disabled" )
24
+ } );
25
+ $childList.filter( '#rwmb-taxonomy-' + $value ).removeClass( 'disabled' ).addClass( 'active' ).children( 'select' ).removeAttr( 'disabled' );
26
+
27
  } );
28
  } );
js/thickbox-image.js CHANGED
@@ -8,7 +8,8 @@ jQuery( document ).ready( function( $ )
8
  field_id = $this.attr( 'rel' ),
9
  backup = window.send_to_editor;
10
 
11
- window.send_to_editor = function( html ) {
 
12
  var $img = $( '<div />' ).append( html ).find( 'img' ),
13
  url = $img.attr( 'src' ),
14
  img_class = $img.attr( 'class' ),
8
  field_id = $this.attr( 'rel' ),
9
  backup = window.send_to_editor;
10
 
11
+ window.send_to_editor = function( html )
12
+ {
13
  var $img = $( '<div />' ).append( html ).find( 'img' ),
14
  url = $img.attr( 'src' ),
15
  img_class = $img.attr( 'class' ),
js/time.js CHANGED
@@ -11,11 +11,12 @@ function rwmb_update_time_picker()
11
  var $this = $( this ),
12
  options = $this.data( 'options' );
13
 
14
- $this.removeClass( 'hasDatepicker' ).attr( 'id', '' ).datetimepicker( options );
 
15
  } );
16
  }
17
 
18
- jQuery( document ).ready( function($)
19
  {
20
  rwmb_update_time_picker();
21
  } );
11
  var $this = $( this ),
12
  options = $this.data( 'options' );
13
 
14
+ $this.siblings( '.ui-datepicker-append' ).remove(); // Remove appended text
15
+ $this.removeClass( 'hasDatepicker' ).datepicker( options );
16
  } );
17
  }
18
 
19
+ jQuery( document ).ready( function()
20
  {
21
  rwmb_update_time_picker();
22
  } );
js/validate.js CHANGED
@@ -1,4 +1,4 @@
1
- jQuery( document ).ready( function ( $ )
2
  {
3
  var $form = $( '#post' );
4
 
@@ -13,9 +13,9 @@ jQuery( document ).ready( function ( $ )
13
  {
14
  // Re-enable the submit ( publish/update ) button and hide the ajax indicator
15
  $( '#publish' ).removeClass( 'button-primary-disabled' );
16
- $( '#ajax-loading' ).attr( 'style','' );
17
  $form.siblings( '#message' ).remove();
18
- $form.before( '<div id="message" class="error"><p>' + rwmb.summaryMessage + '</p></div>' );
19
  };
20
 
21
  $form.validate( rwmb.validationOptions );
1
+ jQuery( document ).ready( function( $ )
2
  {
3
  var $form = $( '#post' );
4
 
13
  {
14
  // Re-enable the submit ( publish/update ) button and hide the ajax indicator
15
  $( '#publish' ).removeClass( 'button-primary-disabled' );
16
+ $( '#ajax-loading' ).attr( 'style', '' );
17
  $form.siblings( '#message' ).remove();
18
+ $form.before( '<div id="message" class="error"><p>' + rwmb.summaryMessage + '</p></div>' );
19
  };
20
 
21
  $form.validate( rwmb.validationOptions );
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.2
7
  Author: Rilwis
8
  Author URI: http://www.deluxeblogtips.com
9
  License: GPL2+
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.2.1
7
  Author: Rilwis
8
  Author URI: http://www.deluxeblogtips.com
9
  License: GPL2+
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.0
6
  Tested up to: 3.4.2
7
- Stable tag: 4.2
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
 
@@ -59,6 +59,13 @@ To getting started with the plugin API, please read [this tutorial](http://www.d
59
 
60
  == Changelog ==
61
 
 
 
 
 
 
 
 
62
  = 4.2 =
63
  * Bug fix: save only last element of `select` field with `multiple` values. [Link](http://wordpress.org/support/topic/plugin-meta-box-multiple-declaration-for-select-fields-no-longer-working?replies=5#post-3254534)
64
  * Improvement: add `js_options` attribute for `date`, `datetime`, `time` fields to adjust jQuery date/datetime picker options. See `demo/demo.php` for usage
4
  Tags: meta-box, custom-fields, custom-field, meta, meta-boxes
5
  Requires at least: 3.0
6
  Tested up to: 3.4.2
7
+ Stable tag: 4.2.1
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
 
59
 
60
  == Changelog ==
61
 
62
+ = 4.2.1 =
63
+ * Bug fix: not save wysiwyg field in full screen mode. [Link](http://www.deluxeblogtips.com/forums/viewtopic.php?id=161)
64
+ * Bug fix: default value for select/checkbox_list. [Link](http://www.deluxeblogtips.com/forums/viewtopic.php?id=174)
65
+ * Bug fix: duplicated append test to `date` picker
66
+ * Bug fix: incorrect enqueue styles, issue #166
67
+ * Improvement: initial new field type `map`
68
+
69
  = 4.2 =
70
  * Bug fix: save only last element of `select` field with `multiple` values. [Link](http://wordpress.org/support/topic/plugin-meta-box-multiple-declaration-for-select-fields-no-longer-working?replies=5#post-3254534)
71
  * Improvement: add `js_options` attribute for `date`, `datetime`, `time` fields to adjust jQuery date/datetime picker options. See `demo/demo.php` for usage