Version Description
- Introducing storage interface, which now can be extended for term/user/settings page under the same codebase. With this improvement, helper functions now works for term/user/settings page (require premium extensions).
- Fixed cloning wysiwyg field when tinyMCE mode is turned off (only show quick tags).
- Fixed image_upload & file_upload field doesn't add attachment to post
- Fixed text_list fields not saving correctly when edit not last field.
Download this release
Release Info
Developer | rilwis |
Plugin | Meta Box |
Version | 4.11.2 |
Comparing to | |
See all releases |
Code changes from version 4.11.1 to 4.11.2
- inc/field-registry.php +16 -11
- inc/field.php +21 -8
- inc/fields/input-list.php +1 -1
- inc/fields/taxonomy-advanced.php +7 -4
- inc/fields/taxonomy.php +5 -4
- inc/fields/text-list.php +13 -0
- inc/functions.php +67 -3
- inc/interfaces/storage.php +22 -0
- inc/loader.php +3 -1
- inc/storage-registry.php +33 -0
- inc/storages/post.php +25 -0
- js/clone.js +1 -1
- js/file-upload.js +8 -0
- js/wysiwyg.js +6 -4
- languages/meta-box-fa_IR.mo +0 -0
- languages/meta-box-fa_IR.po +50 -46
- meta-box.php +1 -1
- readme.txt +9 -2
inc/field-registry.php
CHANGED
@@ -33,29 +33,34 @@ class RWMB_Field_Registry {
|
|
33 |
/**
|
34 |
* Add a single field to the registry.
|
35 |
*
|
36 |
-
* @param array $field
|
37 |
-
* @param string $
|
|
|
38 |
*/
|
39 |
-
public function add( $field, $
|
40 |
if ( ! isset( $field['id'] ) ) {
|
41 |
return;
|
42 |
}
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
-
$this->data[ $
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
* Retrieve a field.
|
51 |
*
|
52 |
-
* @param string $id
|
53 |
-
* @param string $
|
|
|
54 |
*
|
55 |
* @return bool|array False or field configuration.
|
56 |
*/
|
57 |
-
public function get( $id, $
|
58 |
-
$
|
59 |
-
return isset( $this->data[ $post_type ][ $id ] ) ? $this->data[ $post_type ][ $id ] : false;
|
60 |
}
|
61 |
}
|
33 |
/**
|
34 |
* Add a single field to the registry.
|
35 |
*
|
36 |
+
* @param array $field Field configuration.
|
37 |
+
* @param string $type Post type|Taxonomy|'user'|Setting page which the field belongs to.
|
38 |
+
* @param string $object_type Object type which the field belongs to.
|
39 |
*/
|
40 |
+
public function add( $field, $type, $object_type = 'post' ) {
|
41 |
if ( ! isset( $field['id'] ) ) {
|
42 |
return;
|
43 |
}
|
44 |
+
|
45 |
+
if ( empty( $this->data[ $object_type ] ) ) {
|
46 |
+
$this->data[ $object_type ] = array();
|
47 |
+
}
|
48 |
+
if ( empty( $this->data[ $object_type ][ $type ] ) ) {
|
49 |
+
$this->data[ $object_type ][ $type ] = array();
|
50 |
}
|
51 |
+
$this->data[ $object_type ][ $type ][ $field['id'] ] = $field;
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
* Retrieve a field.
|
56 |
*
|
57 |
+
* @param string $id A meta box instance id.
|
58 |
+
* @param string $type Post type|Taxonomy|'user'|Setting page which the field belongs to.
|
59 |
+
* @param string $object_type Object type which the field belongs to.
|
60 |
*
|
61 |
* @return bool|array False or field configuration.
|
62 |
*/
|
63 |
+
public function get( $id, $type, $object_type = 'post' ) {
|
64 |
+
return isset( $this->data[ $object_type ][ $type ][ $id ] ) ? $this->data[ $object_type ][ $type ][ $id ] : false;
|
|
|
65 |
}
|
66 |
}
|
inc/field.php
CHANGED
@@ -173,18 +173,25 @@ abstract class RWMB_Field {
|
|
173 |
/**
|
174 |
* Get raw meta value.
|
175 |
*
|
176 |
-
* @param int $
|
177 |
-
* @param array $field
|
|
|
178 |
*
|
179 |
* @return mixed
|
180 |
*/
|
181 |
-
public static function raw_meta( $
|
182 |
if ( empty( $field['id'] ) ) {
|
183 |
return '';
|
184 |
}
|
185 |
|
186 |
-
$
|
187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
}
|
189 |
|
190 |
/**
|
@@ -211,7 +218,7 @@ abstract class RWMB_Field {
|
|
211 |
// Use $field['std'] only when the meta box hasn't been saved (i.e. the first time we run).
|
212 |
$meta = ! $saved ? $field['std'] : $meta;
|
213 |
|
214 |
-
//
|
215 |
if ( $field['multiple'] ) {
|
216 |
if ( $field['clone'] ) {
|
217 |
$meta = (array) $meta;
|
@@ -424,7 +431,7 @@ abstract class RWMB_Field {
|
|
424 |
}
|
425 |
|
426 |
// Get raw meta value in the database, no escape.
|
427 |
-
$value = self::call( $field, 'raw_meta', $post_id );
|
428 |
|
429 |
// Make sure meta value is an array for cloneable and multiple fields.
|
430 |
if ( $field['clone'] || $field['multiple'] ) {
|
@@ -504,7 +511,13 @@ abstract class RWMB_Field {
|
|
504 |
} else {
|
505 |
$field = array_shift( $args );
|
506 |
$method = array_shift( $args );
|
507 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
508 |
}
|
509 |
|
510 |
return call_user_func_array( array( self::get_class_name( $field ), $method ), $args );
|
173 |
/**
|
174 |
* Get raw meta value.
|
175 |
*
|
176 |
+
* @param int $object_id Object ID.
|
177 |
+
* @param array $field Field parameters.
|
178 |
+
* @param array $args Arguments of {@see rwmb_meta()} helper.
|
179 |
*
|
180 |
* @return mixed
|
181 |
*/
|
182 |
+
public static function raw_meta( $object_id, $field, $args = array() ) {
|
183 |
if ( empty( $field['id'] ) ) {
|
184 |
return '';
|
185 |
}
|
186 |
|
187 |
+
$object_type = ! empty( $args['object_type'] ) ? $args['object_type'] : 'post';
|
188 |
+
$storage = rwmb_get_storage( $object_type );
|
189 |
+
|
190 |
+
if ( ! isset( $args['single'] ) ) {
|
191 |
+
$args['single'] = $field['clone'] || ! $field['multiple'];
|
192 |
+
}
|
193 |
+
|
194 |
+
return $storage->get( $object_id, $field['id'], $args );
|
195 |
}
|
196 |
|
197 |
/**
|
218 |
// Use $field['std'] only when the meta box hasn't been saved (i.e. the first time we run).
|
219 |
$meta = ! $saved ? $field['std'] : $meta;
|
220 |
|
221 |
+
// Ensure multiple fields are arrays.
|
222 |
if ( $field['multiple'] ) {
|
223 |
if ( $field['clone'] ) {
|
224 |
$meta = (array) $meta;
|
431 |
}
|
432 |
|
433 |
// Get raw meta value in the database, no escape.
|
434 |
+
$value = self::call( $field, 'raw_meta', $post_id, $args );
|
435 |
|
436 |
// Make sure meta value is an array for cloneable and multiple fields.
|
437 |
if ( $field['clone'] || $field['multiple'] ) {
|
511 |
} else {
|
512 |
$field = array_shift( $args );
|
513 |
$method = array_shift( $args );
|
514 |
+
|
515 |
+
if ( 'raw_meta' === $method ) {
|
516 |
+
// Add field param after object id.
|
517 |
+
array_splice( $args, 1, 0, array( $field ) );
|
518 |
+
} else {
|
519 |
+
$args[] = $field; // Add field as last param.
|
520 |
+
}
|
521 |
}
|
522 |
|
523 |
return call_user_func_array( array( self::get_class_name( $field ), $method ), $args );
|
inc/fields/input-list.php
CHANGED
@@ -86,7 +86,7 @@ class RWMB_Input_List_Field extends RWMB_Choice_Field {
|
|
86 |
* @return string
|
87 |
*/
|
88 |
public static function get_select_all_html( $field ) {
|
89 |
-
if( $field['multiple'] && $field['select_all_none'] ){
|
90 |
return sprintf( '<p><button class="rwmb-input-list-select-all-none" data-name="%s">%s</button></p>', $field['id'], __( 'Select All / None','meta-box' ) );
|
91 |
}
|
92 |
return '';
|
86 |
* @return string
|
87 |
*/
|
88 |
public static function get_select_all_html( $field ) {
|
89 |
+
if ( $field['multiple'] && $field['select_all_none'] ) {
|
90 |
return sprintf( '<p><button class="rwmb-input-list-select-all-none" data-name="%s">%s</button></p>', $field['id'], __( 'Select All / None','meta-box' ) );
|
91 |
}
|
92 |
return '';
|
inc/fields/taxonomy-advanced.php
CHANGED
@@ -62,13 +62,16 @@ class RWMB_Taxonomy_Advanced_Field extends RWMB_Taxonomy_Field {
|
|
62 |
/**
|
63 |
* Get raw meta value.
|
64 |
*
|
65 |
-
* @param int $
|
66 |
-
* @param array $field
|
|
|
67 |
*
|
68 |
* @return mixed
|
69 |
*/
|
70 |
-
public static function raw_meta( $
|
71 |
-
$
|
|
|
|
|
72 |
if ( empty( $meta ) ) {
|
73 |
return $field['multiple'] ? array() : '';
|
74 |
}
|
62 |
/**
|
63 |
* Get raw meta value.
|
64 |
*
|
65 |
+
* @param int $object_id Object ID.
|
66 |
+
* @param array $field Field parameters.
|
67 |
+
* @param array $args Arguments of {@see rwmb_meta()} helper.
|
68 |
*
|
69 |
* @return mixed
|
70 |
*/
|
71 |
+
public static function raw_meta( $object_id, $field, $args = array() ) {
|
72 |
+
$args['single'] = true;
|
73 |
+
$meta = RWMB_Field::raw_meta( $object_id, $field, $args );
|
74 |
+
|
75 |
if ( empty( $meta ) ) {
|
76 |
return $field['multiple'] ? array() : '';
|
77 |
}
|
inc/fields/taxonomy.php
CHANGED
@@ -101,17 +101,18 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
|
|
101 |
/**
|
102 |
* Get raw meta value.
|
103 |
*
|
104 |
-
* @param int $
|
105 |
-
* @param array $field
|
|
|
106 |
*
|
107 |
* @return mixed
|
108 |
*/
|
109 |
-
public static function raw_meta( $
|
110 |
if ( empty( $field['id'] ) ) {
|
111 |
return '';
|
112 |
}
|
113 |
|
114 |
-
$meta = get_the_terms( $
|
115 |
|
116 |
if ( ! is_array( $meta ) || empty( $meta ) ) {
|
117 |
return $field['multiple'] ? array() : '';
|
101 |
/**
|
102 |
* Get raw meta value.
|
103 |
*
|
104 |
+
* @param int $object_id Object ID.
|
105 |
+
* @param array $field Field parameters.
|
106 |
+
* @param array $args Arguments of {@see rwmb_meta()} helper.
|
107 |
*
|
108 |
* @return mixed
|
109 |
*/
|
110 |
+
public static function raw_meta( $object_id, $field, $args = array() ) {
|
111 |
if ( empty( $field['id'] ) ) {
|
112 |
return '';
|
113 |
}
|
114 |
|
115 |
+
$meta = get_the_terms( $object_id, $field['taxonomy'] );
|
116 |
|
117 |
if ( ! is_array( $meta ) || empty( $meta ) ) {
|
118 |
return $field['multiple'] ? array() : '';
|
inc/fields/text-list.php
CHANGED
@@ -76,4 +76,17 @@ class RWMB_Text_List_Field extends RWMB_Multiple_Values_Field {
|
|
76 |
$output .= '</tr>';
|
77 |
return $output;
|
78 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
76 |
$output .= '</tr>';
|
77 |
return $output;
|
78 |
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Save meta value.
|
82 |
+
*
|
83 |
+
* @param mixed $new The submitted meta value.
|
84 |
+
* @param mixed $old The existing meta value.
|
85 |
+
* @param int $post_id The post ID.
|
86 |
+
* @param array $field The field parameters.
|
87 |
+
*/
|
88 |
+
public static function save( $new, $old, $post_id, $field ) {
|
89 |
+
delete_post_meta( $post_id, $field['id'] );
|
90 |
+
parent::save( $new, array(), $post_id, $field );
|
91 |
+
}
|
92 |
}
|
inc/functions.php
CHANGED
@@ -17,7 +17,7 @@ if ( ! function_exists( 'rwmb_meta' ) ) {
|
|
17 |
*/
|
18 |
function rwmb_meta( $key, $args = array(), $post_id = null ) {
|
19 |
$args = wp_parse_args( $args );
|
20 |
-
$field =
|
21 |
|
22 |
/*
|
23 |
* If field is not found, which can caused by registering meta boxes for the backend only or conditional registration.
|
@@ -33,6 +33,35 @@ if ( ! function_exists( 'rwmb_meta' ) ) {
|
|
33 |
}
|
34 |
}
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
if ( ! function_exists( 'rwmb_meta_legacy' ) ) {
|
37 |
/**
|
38 |
* Get post meta.
|
@@ -86,7 +115,7 @@ if ( ! function_exists( 'rwmb_get_value' ) ) {
|
|
86 |
*/
|
87 |
function rwmb_get_value( $field_id, $args = array(), $post_id = null ) {
|
88 |
$args = wp_parse_args( $args );
|
89 |
-
$field =
|
90 |
|
91 |
// Get field value.
|
92 |
$value = $field ? RWMB_Field::call( 'get_value', $field, $args, $post_id ) : false;
|
@@ -119,7 +148,7 @@ if ( ! function_exists( 'rwmb_the_value' ) ) {
|
|
119 |
*/
|
120 |
function rwmb_the_value( $field_id, $args = array(), $post_id = null, $echo = true ) {
|
121 |
$args = wp_parse_args( $args );
|
122 |
-
$field =
|
123 |
|
124 |
if ( ! $field ) {
|
125 |
return '';
|
@@ -194,3 +223,38 @@ if ( ! function_exists( 'rwmb_get_registry' ) ) {
|
|
194 |
return $data[ $type ];
|
195 |
}
|
196 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
*/
|
18 |
function rwmb_meta( $key, $args = array(), $post_id = null ) {
|
19 |
$args = wp_parse_args( $args );
|
20 |
+
$field = rwmb_get_field_data( $key, $args, $post_id );
|
21 |
|
22 |
/*
|
23 |
* If field is not found, which can caused by registering meta boxes for the backend only or conditional registration.
|
33 |
}
|
34 |
}
|
35 |
|
36 |
+
if ( ! function_exists( 'rwmb_get_field_data' ) ) {
|
37 |
+
/**
|
38 |
+
* Get field data.
|
39 |
+
*
|
40 |
+
* @param string $key Meta key. Required.
|
41 |
+
* @param array $args Array of arguments. Optional.
|
42 |
+
* @param int|null $object_id Object ID. null for current post. Optional.
|
43 |
+
*
|
44 |
+
* @return array
|
45 |
+
*/
|
46 |
+
function rwmb_get_field_data( $key, $args = array(), $object_id = null ) {
|
47 |
+
$args = wp_parse_args( $args, array(
|
48 |
+
'object_type' => 'post',
|
49 |
+
) );
|
50 |
+
$type = get_post_type( $object_id );
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Filter meta type from object type and object id.
|
54 |
+
*
|
55 |
+
* @var string Meta type, default is post type name.
|
56 |
+
* @var string Object type.
|
57 |
+
* @var string|int Object id.
|
58 |
+
*/
|
59 |
+
$type = apply_filters( 'rwmb_meta_type', $type, $args['object_type'], $object_id );
|
60 |
+
|
61 |
+
return rwmb_get_registry( 'field' )->get( $key, $type, $args['object_type'] );
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
if ( ! function_exists( 'rwmb_meta_legacy' ) ) {
|
66 |
/**
|
67 |
* Get post meta.
|
115 |
*/
|
116 |
function rwmb_get_value( $field_id, $args = array(), $post_id = null ) {
|
117 |
$args = wp_parse_args( $args );
|
118 |
+
$field = rwmb_get_field_data( $field_id, $args, $post_id );
|
119 |
|
120 |
// Get field value.
|
121 |
$value = $field ? RWMB_Field::call( 'get_value', $field, $args, $post_id ) : false;
|
148 |
*/
|
149 |
function rwmb_the_value( $field_id, $args = array(), $post_id = null, $echo = true ) {
|
150 |
$args = wp_parse_args( $args );
|
151 |
+
$field = rwmb_get_field_data( $field_id, $args, $post_id );
|
152 |
|
153 |
if ( ! $field ) {
|
154 |
return '';
|
223 |
return $data[ $type ];
|
224 |
}
|
225 |
}
|
226 |
+
|
227 |
+
if ( ! function_exists( 'rwmb_get_storage_class_name' ) ) {
|
228 |
+
/**
|
229 |
+
* Get storage class name.
|
230 |
+
*
|
231 |
+
* @param string $object_type Object type. Use post or term.
|
232 |
+
* @return string
|
233 |
+
*/
|
234 |
+
function rwmb_get_storage_class_name( $object_type ) {
|
235 |
+
$object_type = str_replace( array( '-', '_' ), ' ', $object_type );
|
236 |
+
$object_type = ucwords( $object_type );
|
237 |
+
$object_type = str_replace( ' ', '_', $object_type );
|
238 |
+
$class_name = 'RWMB_' . $object_type . '_Storage';
|
239 |
+
|
240 |
+
if ( ! class_exists( $class_name ) ) {
|
241 |
+
$class_name = 'RWMB_Post_Storage';
|
242 |
+
}
|
243 |
+
|
244 |
+
return apply_filters( 'rwmb_storage_class_name', $class_name, $object_type );
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
if ( ! function_exists( 'rwmb_get_storage' ) ) {
|
249 |
+
/**
|
250 |
+
* Get storage instance.
|
251 |
+
*
|
252 |
+
* @param string $object_type Object type. Use post or term.
|
253 |
+
* @return RWMB_Storage_Interface
|
254 |
+
*/
|
255 |
+
function rwmb_get_storage( $object_type ) {
|
256 |
+
$class_name = rwmb_get_storage_class_name( $object_type );
|
257 |
+
|
258 |
+
return rwmb_get_registry( 'storage' )->get( $class_name );
|
259 |
+
}
|
260 |
+
}
|
inc/interfaces/storage.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Storage interface
|
4 |
+
*
|
5 |
+
* @package Meta Box
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Interface RWMB_Storage_Interface
|
10 |
+
*/
|
11 |
+
interface RWMB_Storage_Interface {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Get value from storage.
|
15 |
+
*
|
16 |
+
* @param int $object_id Object id.
|
17 |
+
* @param string $name Field name.
|
18 |
+
* @param array $args Custom arguments..
|
19 |
+
* @return mixed
|
20 |
+
*/
|
21 |
+
public function get( $object_id, $name, $args = array() );
|
22 |
+
}
|
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.11.
|
22 |
|
23 |
list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
|
24 |
|
@@ -77,6 +77,8 @@ class RWMB_Loader {
|
|
77 |
$autoloader->add( RWMB_INC_DIR, 'RWMB_' );
|
78 |
$autoloader->add( RWMB_INC_DIR . 'fields', 'RWMB_', '_Field' );
|
79 |
$autoloader->add( RWMB_INC_DIR . 'walkers', 'RWMB_Walker_' );
|
|
|
|
|
80 |
$autoloader->register();
|
81 |
|
82 |
// Plugin core.
|
18 |
*/
|
19 |
protected function constants() {
|
20 |
// Script version, used to add version for scripts and styles.
|
21 |
+
define( 'RWMB_VER', '4.11.2' );
|
22 |
|
23 |
list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
|
24 |
|
77 |
$autoloader->add( RWMB_INC_DIR, 'RWMB_' );
|
78 |
$autoloader->add( RWMB_INC_DIR . 'fields', 'RWMB_', '_Field' );
|
79 |
$autoloader->add( RWMB_INC_DIR . 'walkers', 'RWMB_Walker_' );
|
80 |
+
$autoloader->add( RWMB_INC_DIR . 'interfaces', 'RWMB_', '_Interface' );
|
81 |
+
$autoloader->add( RWMB_INC_DIR . 'storages', 'RWMB_', '_Storage' );
|
82 |
$autoloader->register();
|
83 |
|
84 |
// Plugin core.
|
inc/storage-registry.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Storage registry class
|
4 |
+
*
|
5 |
+
* @package Meta Box
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class RWMB_Storage_Registry
|
10 |
+
*/
|
11 |
+
class RWMB_Storage_Registry {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* List storage instances.
|
15 |
+
*
|
16 |
+
* @var array
|
17 |
+
*/
|
18 |
+
protected $storages = array();
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Get storage instance.
|
22 |
+
*
|
23 |
+
* @param string $class_name Storage class name.
|
24 |
+
* @return RWMB_Storage_Interface
|
25 |
+
*/
|
26 |
+
public function get( $class_name ) {
|
27 |
+
if ( empty( $this->storages[ $class_name ] ) ) {
|
28 |
+
$this->storages[ $class_name ] = new $class_name();
|
29 |
+
}
|
30 |
+
|
31 |
+
return $this->storages[ $class_name ];
|
32 |
+
}
|
33 |
+
}
|
inc/storages/post.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Post storage
|
4 |
+
*
|
5 |
+
* @package Meta Box
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class RWMB_Post_Storage
|
10 |
+
*/
|
11 |
+
class RWMB_Post_Storage implements RWMB_Storage_Interface {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Get value from storage.
|
15 |
+
*
|
16 |
+
* @param int $object_id Object id.
|
17 |
+
* @param string $name Field name.
|
18 |
+
* @param array $args Custom arguments.
|
19 |
+
* @return mixed
|
20 |
+
*/
|
21 |
+
public function get( $object_id, $name, $args = array() ) {
|
22 |
+
$single = ! empty( $args['single'] );
|
23 |
+
return get_post_meta( $object_id, $name, $single );
|
24 |
+
}
|
25 |
+
}
|
js/clone.js
CHANGED
@@ -48,7 +48,7 @@ jQuery( function ( $ ) {
|
|
48 |
after = after || '';
|
49 |
alternative = alternative || true;
|
50 |
|
51 |
-
var regex = new RegExp( cloneIndex.escapeRegex( before ) + '(\\d+)' + cloneIndex.escapeRegex( after ) ),
|
52 |
newValue = before + index + after;
|
53 |
|
54 |
return regex.test( value ) ? value.replace( regex, newValue ) : (alternative ? value + newValue : value );
|
48 |
after = after || '';
|
49 |
alternative = alternative || true;
|
50 |
|
51 |
+
var regex = new RegExp( cloneIndex.escapeRegex( before ) + '(\\d+)' + cloneIndex.escapeRegex( after ) + '$' ),
|
52 |
newValue = before + index + after;
|
53 |
|
54 |
return regex.test( value ) ? value.replace( regex, newValue ) : (alternative ? value + newValue : value );
|
js/file-upload.js
CHANGED
@@ -72,6 +72,14 @@ jQuery( function ( $ ) {
|
|
72 |
this.plupload.required_features.send_binary_string = true;
|
73 |
}
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
// Initialize the plupload instance.
|
76 |
this.uploader = new plupload.Uploader( this.plupload );
|
77 |
this.uploader.init();
|
72 |
this.plupload.required_features.send_binary_string = true;
|
73 |
}
|
74 |
|
75 |
+
if ( $('#post_ID').length && $('#post_ID').val() ) {
|
76 |
+
if ( -1 === this.plupload.url.indexOf('?') ) {
|
77 |
+
this.plupload.url += "?post_id=" + $('#post_ID').val();
|
78 |
+
} else {
|
79 |
+
this.plupload.url += "&post_id=" + $('#post_ID').val();
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
// Initialize the plupload instance.
|
84 |
this.uploader = new plupload.Uploader( this.plupload );
|
85 |
this.uploader.init();
|
js/wysiwyg.js
CHANGED
@@ -28,9 +28,11 @@ jQuery( function ( $ ) {
|
|
28 |
updateDom( $wrapper, id );
|
29 |
|
30 |
// TinyMCE
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
34 |
|
35 |
// Quick tags
|
36 |
if ( typeof quicktags === 'function' && tinyMCEPreInit.qtInit.hasOwnProperty( originalId ) ) {
|
@@ -54,7 +56,7 @@ jQuery( function ( $ ) {
|
|
54 |
if ( /_\d+$/.test( currentId ) ) {
|
55 |
currentId = currentId.replace( /_\d+$/, '' );
|
56 |
}
|
57 |
-
if ( tinyMCEPreInit.mceInit.hasOwnProperty( currentId ) ) {
|
58 |
id = currentId;
|
59 |
return false; // Immediately stop the .each() loop
|
60 |
}
|
28 |
updateDom( $wrapper, id );
|
29 |
|
30 |
// TinyMCE
|
31 |
+
if ( tinyMCEPreInit.mceInit.hasOwnProperty( originalId ) ) {
|
32 |
+
var settings = tinyMCEPreInit.mceInit[originalId];
|
33 |
+
settings.selector = '#' + id;
|
34 |
+
tinymce.init( settings );
|
35 |
+
}
|
36 |
|
37 |
// Quick tags
|
38 |
if ( typeof quicktags === 'function' && tinyMCEPreInit.qtInit.hasOwnProperty( originalId ) ) {
|
56 |
if ( /_\d+$/.test( currentId ) ) {
|
57 |
currentId = currentId.replace( /_\d+$/, '' );
|
58 |
}
|
59 |
+
if ( tinyMCEPreInit.mceInit.hasOwnProperty( currentId ) || tinyMCEPreInit.qtInit.hasOwnProperty( currentId ) ) {
|
60 |
id = currentId;
|
61 |
return false; // Immediately stop the .each() loop
|
62 |
}
|
languages/meta-box-fa_IR.mo
CHANGED
Binary file
|
languages/meta-box-fa_IR.po
CHANGED
@@ -4,18 +4,19 @@ msgid ""
|
|
4 |
msgstr ""
|
5 |
"Project-Id-Version: Meta Box 4.8.7\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/meta-box\n"
|
7 |
-
"POT-Creation-Date: 2017-05-
|
|
|
|
|
|
|
|
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
11 |
-
"PO-Revision-Date: 2017-05-13 22:51+0430\n"
|
12 |
-
"Language-Team: Meta Box <admin@metabox.io>\n"
|
13 |
"X-Generator: Poedit 1.8.6\n"
|
14 |
-
"X-Poedit-KeywordsList: __;_x;_e;_ex;_n;_nx;esc_attr__;esc_attr_e;esc_attr_x;
|
|
|
15 |
"X-Poedit-Basepath: ..\n"
|
16 |
-
"Last-Translator: Morteza Gholami <Morteza.Gholami@Yahoo.Com>\n"
|
17 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
18 |
-
"Language: fa_IR\n"
|
19 |
"X-Poedit-SearchPath-0: .\n"
|
20 |
"X-Poedit-SearchPathExcluded-0: js\n"
|
21 |
"X-Poedit-SearchPathExcluded-1: demo\n"
|
@@ -23,20 +24,20 @@ msgstr ""
|
|
23 |
"X-Poedit-SearchPathExcluded-3: css\n"
|
24 |
"X-Poedit-SearchPathExcluded-4: lang\n"
|
25 |
|
26 |
-
#: inc/
|
27 |
-
msgid "+ Add more"
|
28 |
-
msgstr "+ افزودن بیشتر"
|
29 |
-
|
30 |
-
#: inc/core.php:42
|
31 |
msgid "Documentation"
|
32 |
msgstr "مستندات"
|
33 |
|
34 |
-
#: inc/core.php:
|
35 |
msgid "Extensions"
|
36 |
msgstr "افزونهها"
|
37 |
|
38 |
-
#: inc/
|
39 |
-
|
|
|
|
|
|
|
|
|
40 |
msgid "Delete"
|
41 |
msgstr "حذف"
|
42 |
|
@@ -44,93 +45,93 @@ msgstr "حذف"
|
|
44 |
msgid "Click me"
|
45 |
msgstr "کلیک کنید"
|
46 |
|
47 |
-
#: inc/fields/checkbox.php:
|
48 |
msgid "Yes"
|
49 |
msgstr "بله"
|
50 |
|
51 |
-
#: inc/fields/checkbox.php:
|
52 |
msgid "No"
|
53 |
msgstr "خیر"
|
54 |
|
55 |
-
#: inc/fields/file-input.php:
|
56 |
msgid "Select File"
|
57 |
msgstr "انتخاب فایل"
|
58 |
|
59 |
-
#: inc/fields/file-input.php:
|
60 |
msgid "Select"
|
61 |
msgstr "انتخاب"
|
62 |
|
63 |
-
#: inc/fields/file-input.php:
|
64 |
msgid "Remove"
|
65 |
msgstr "حذف"
|
66 |
|
67 |
-
#: inc/fields/file.php:
|
68 |
#, php-format
|
69 |
msgid "You may only upload maximum %d file"
|
70 |
msgstr "شما تنها میبایست نهایتا %d فایل بارگذاری کنید"
|
71 |
|
72 |
-
#: inc/fields/file.php:
|
73 |
#, php-format
|
74 |
msgid "You may only upload maximum %d files"
|
75 |
msgstr "شما تنها میبایست نهایتا %d فایل بارگذاری کنید"
|
76 |
|
77 |
-
#: inc/fields/file.php:
|
78 |
msgid "Error: Cannot delete file"
|
79 |
msgstr "خطا: عدم توانایی حذف فایل"
|
80 |
|
81 |
-
#: inc/fields/file.php:
|
82 |
-
msgid "Upload Files"
|
83 |
-
msgstr "بارگذاری فایلها"
|
84 |
-
|
85 |
-
#: inc/fields/file.php:90
|
86 |
msgid "+ Add new file"
|
87 |
msgstr "+ افزودن فایل جدید"
|
88 |
|
89 |
-
#: inc/fields/file.php:
|
90 |
msgid "Edit"
|
91 |
msgstr "ویرایش"
|
92 |
|
93 |
-
#: inc/fields/
|
|
|
|
|
|
|
|
|
94 |
msgid "Key"
|
95 |
msgstr "کلید"
|
96 |
|
97 |
-
#: inc/fields/key-value.php:
|
98 |
msgid "Value"
|
99 |
msgstr "مقدار"
|
100 |
|
101 |
-
#: inc/fields/map.php:
|
102 |
msgid "Find Address"
|
103 |
msgstr "پیدا کردن آدرس"
|
104 |
|
105 |
-
#: inc/fields/media.php:
|
106 |
msgid "+ Add Media"
|
107 |
msgstr "+ افزودن رسانه"
|
108 |
|
109 |
-
#: inc/fields/media.php:
|
110 |
msgid " file"
|
111 |
msgstr " فایل"
|
112 |
|
113 |
-
#: inc/fields/media.php:
|
114 |
msgid " files"
|
115 |
msgstr " فایلها"
|
116 |
|
117 |
-
#: inc/fields/media.php:
|
118 |
msgid "View"
|
119 |
msgstr "نمایش"
|
120 |
|
121 |
-
#: inc/fields/media.php:
|
122 |
msgid "No Title"
|
123 |
msgstr "بدون عنوان"
|
124 |
|
125 |
-
#: inc/fields/media.php:
|
126 |
msgid "Select Files"
|
127 |
msgstr "انتخاب فایلها"
|
128 |
|
129 |
-
#: inc/fields/media.php:
|
130 |
msgid "or"
|
131 |
msgstr "یا"
|
132 |
|
133 |
-
#: inc/fields/media.php:
|
134 |
msgid "Drop files here to upload"
|
135 |
msgstr "فایلها را برای بارگذاری اینجا بیاندازید"
|
136 |
|
@@ -142,28 +143,28 @@ msgstr "قراردادن HTML امکانپذیر نیست"
|
|
142 |
msgid "Preview"
|
143 |
msgstr "پیشنمایش"
|
144 |
|
145 |
-
#: inc/fields/post.php:
|
146 |
msgid "Select a post"
|
147 |
msgstr "انتخاب یک پست"
|
148 |
|
149 |
-
#: inc/fields/post.php:41 inc/fields/taxonomy.php:
|
150 |
#, php-format
|
151 |
msgid "Select a %s"
|
152 |
msgstr "انتخاب یک %s"
|
153 |
|
154 |
-
#: inc/fields/select-advanced.php:
|
155 |
msgid "Select an item"
|
156 |
msgstr "انتخاب یک آیتم"
|
157 |
|
158 |
-
#: inc/fields/select.php:
|
159 |
msgid "All"
|
160 |
msgstr "همه"
|
161 |
|
162 |
-
#: inc/fields/select.php:
|
163 |
msgid "None"
|
164 |
msgstr "هیچکدام"
|
165 |
|
166 |
-
#: inc/fields/taxonomy.php:
|
167 |
msgid "Select a term"
|
168 |
msgstr "انتخاب یک دسته"
|
169 |
|
@@ -171,10 +172,13 @@ msgstr "انتخاب یک دسته"
|
|
171 |
msgid "Upload Images"
|
172 |
msgstr "بارگذاری تصاویر"
|
173 |
|
174 |
-
#: inc/fields/user.php:
|
175 |
msgid "Select an user"
|
176 |
msgstr "انتخاب یک کاربر"
|
177 |
|
178 |
#: inc/validation.php:47
|
179 |
msgid "Please correct the errors highlighted below and try again."
|
180 |
msgstr "لطفا خطاهای پررنگ شده زیر را تصحیح و مجددا تلاش نمایید."
|
|
|
|
|
|
4 |
msgstr ""
|
5 |
"Project-Id-Version: Meta Box 4.8.7\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/meta-box\n"
|
7 |
+
"POT-Creation-Date: 2017-05-20 18:41+0430\n"
|
8 |
+
"PO-Revision-Date: 2017-05-20 18:46+0430\n"
|
9 |
+
"Last-Translator: Morteza Gholami <Morteza.Gholami@Yahoo.Com>\n"
|
10 |
+
"Language-Team: Meta Box <admin@metabox.io>\n"
|
11 |
+
"Language: fa_IR\n"
|
12 |
"MIME-Version: 1.0\n"
|
13 |
"Content-Type: text/plain; charset=UTF-8\n"
|
14 |
"Content-Transfer-Encoding: 8bit\n"
|
|
|
|
|
15 |
"X-Generator: Poedit 1.8.6\n"
|
16 |
+
"X-Poedit-KeywordsList: __;_x;_e;_ex;_n;_nx;esc_attr__;esc_attr_e;esc_attr_x;"
|
17 |
+
"esc_html__;esc_html_e;esc_html_x;_n_noop;_nx_noop\n"
|
18 |
"X-Poedit-Basepath: ..\n"
|
|
|
19 |
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
|
20 |
"X-Poedit-SearchPath-0: .\n"
|
21 |
"X-Poedit-SearchPathExcluded-0: js\n"
|
22 |
"X-Poedit-SearchPathExcluded-1: demo\n"
|
24 |
"X-Poedit-SearchPathExcluded-3: css\n"
|
25 |
"X-Poedit-SearchPathExcluded-4: lang\n"
|
26 |
|
27 |
+
#: inc/core.php:33
|
|
|
|
|
|
|
|
|
28 |
msgid "Documentation"
|
29 |
msgstr "مستندات"
|
30 |
|
31 |
+
#: inc/core.php:34
|
32 |
msgid "Extensions"
|
33 |
msgstr "افزونهها"
|
34 |
|
35 |
+
#: inc/field.php:343
|
36 |
+
msgid "+ Add more"
|
37 |
+
msgstr "+ افزودن بیشتر"
|
38 |
+
|
39 |
+
#: inc/fields/autocomplete.php:20 inc/fields/autocomplete.php:81
|
40 |
+
#: inc/fields/autocomplete.php:93 inc/fields/file.php:143
|
41 |
msgid "Delete"
|
42 |
msgstr "حذف"
|
43 |
|
45 |
msgid "Click me"
|
46 |
msgstr "کلیک کنید"
|
47 |
|
48 |
+
#: inc/fields/checkbox.php:50
|
49 |
msgid "Yes"
|
50 |
msgstr "بله"
|
51 |
|
52 |
+
#: inc/fields/checkbox.php:50
|
53 |
msgid "No"
|
54 |
msgstr "خیر"
|
55 |
|
56 |
+
#: inc/fields/file-input.php:19
|
57 |
msgid "Select File"
|
58 |
msgstr "انتخاب فایل"
|
59 |
|
60 |
+
#: inc/fields/file-input.php:38 inc/fields/select.php:87
|
61 |
msgid "Select"
|
62 |
msgstr "انتخاب"
|
63 |
|
64 |
+
#: inc/fields/file-input.php:40 inc/fields/media.php:27
|
65 |
msgid "Remove"
|
66 |
msgstr "حذف"
|
67 |
|
68 |
+
#: inc/fields/file.php:21
|
69 |
#, php-format
|
70 |
msgid "You may only upload maximum %d file"
|
71 |
msgstr "شما تنها میبایست نهایتا %d فایل بارگذاری کنید"
|
72 |
|
73 |
+
#: inc/fields/file.php:23
|
74 |
#, php-format
|
75 |
msgid "You may only upload maximum %d files"
|
76 |
msgstr "شما تنها میبایست نهایتا %d فایل بارگذاری کنید"
|
77 |
|
78 |
+
#: inc/fields/file.php:79
|
79 |
msgid "Error: Cannot delete file"
|
80 |
msgstr "خطا: عدم توانایی حذف فایل"
|
81 |
|
82 |
+
#: inc/fields/file.php:93
|
|
|
|
|
|
|
|
|
83 |
msgid "+ Add new file"
|
84 |
msgstr "+ افزودن فایل جدید"
|
85 |
|
86 |
+
#: inc/fields/file.php:144 inc/fields/media.php:28
|
87 |
msgid "Edit"
|
88 |
msgstr "ویرایش"
|
89 |
|
90 |
+
#: inc/fields/input-list.php:90
|
91 |
+
msgid "Select All / None"
|
92 |
+
msgstr "انتخاب همه / هیچکدام"
|
93 |
+
|
94 |
+
#: inc/fields/key-value.php:126
|
95 |
msgid "Key"
|
96 |
msgstr "کلید"
|
97 |
|
98 |
+
#: inc/fields/key-value.php:127
|
99 |
msgid "Value"
|
100 |
msgstr "مقدار"
|
101 |
|
102 |
+
#: inc/fields/map.php:62
|
103 |
msgid "Find Address"
|
104 |
msgstr "پیدا کردن آدرس"
|
105 |
|
106 |
+
#: inc/fields/media.php:24
|
107 |
msgid "+ Add Media"
|
108 |
msgstr "+ افزودن رسانه"
|
109 |
|
110 |
+
#: inc/fields/media.php:25
|
111 |
msgid " file"
|
112 |
msgstr " فایل"
|
113 |
|
114 |
+
#: inc/fields/media.php:26
|
115 |
msgid " files"
|
116 |
msgstr " فایلها"
|
117 |
|
118 |
+
#: inc/fields/media.php:29
|
119 |
msgid "View"
|
120 |
msgstr "نمایش"
|
121 |
|
122 |
+
#: inc/fields/media.php:30
|
123 |
msgid "No Title"
|
124 |
msgstr "بدون عنوان"
|
125 |
|
126 |
+
#: inc/fields/media.php:33
|
127 |
msgid "Select Files"
|
128 |
msgstr "انتخاب فایلها"
|
129 |
|
130 |
+
#: inc/fields/media.php:34
|
131 |
msgid "or"
|
132 |
msgstr "یا"
|
133 |
|
134 |
+
#: inc/fields/media.php:35
|
135 |
msgid "Drop files here to upload"
|
136 |
msgstr "فایلها را برای بارگذاری اینجا بیاندازید"
|
137 |
|
143 |
msgid "Preview"
|
144 |
msgstr "پیشنمایش"
|
145 |
|
146 |
+
#: inc/fields/post.php:36
|
147 |
msgid "Select a post"
|
148 |
msgstr "انتخاب یک پست"
|
149 |
|
150 |
+
#: inc/fields/post.php:41 inc/fields/taxonomy.php:52
|
151 |
#, php-format
|
152 |
msgid "Select a %s"
|
153 |
msgstr "انتخاب یک %s"
|
154 |
|
155 |
+
#: inc/fields/select-advanced.php:45
|
156 |
msgid "Select an item"
|
157 |
msgstr "انتخاب یک آیتم"
|
158 |
|
159 |
+
#: inc/fields/select.php:87
|
160 |
msgid "All"
|
161 |
msgstr "همه"
|
162 |
|
163 |
+
#: inc/fields/select.php:87
|
164 |
msgid "None"
|
165 |
msgstr "هیچکدام"
|
166 |
|
167 |
+
#: inc/fields/taxonomy.php:47
|
168 |
msgid "Select a term"
|
169 |
msgstr "انتخاب یک دسته"
|
170 |
|
172 |
msgid "Upload Images"
|
173 |
msgstr "بارگذاری تصاویر"
|
174 |
|
175 |
+
#: inc/fields/user.php:30
|
176 |
msgid "Select an user"
|
177 |
msgstr "انتخاب یک کاربر"
|
178 |
|
179 |
#: inc/validation.php:47
|
180 |
msgid "Please correct the errors highlighted below and try again."
|
181 |
msgstr "لطفا خطاهای پررنگ شده زیر را تصحیح و مجددا تلاش نمایید."
|
182 |
+
|
183 |
+
#~ msgid "Upload Files"
|
184 |
+
#~ msgstr "بارگذاری فایلها"
|
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.11.
|
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.11.2
|
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: 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.1
|
6 |
-
Tested up to: 4.7.
|
7 |
-
Stable tag: 4.11.
|
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.
|
@@ -128,6 +128,13 @@ To getting started with the plugin, please read [this tutorial](https://metabox.
|
|
128 |
|
129 |
== Changelog ==
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
= 4.11.1 =
|
132 |
|
133 |
* Added button for "Check/Uncheck all options" in input list field when type is `checkbox_list`. Props @mrbrazzi.
|
3 |
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.1
|
6 |
+
Tested up to: 4.7.5
|
7 |
+
Stable tag: 4.11.2
|
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.
|
128 |
|
129 |
== Changelog ==
|
130 |
|
131 |
+
= 4.11.2 =
|
132 |
+
|
133 |
+
* Introducing storage interface, which now can be extended for term/user/settings page under the same codebase. With this improvement, helper functions now works for term/user/settings page (require premium extensions).
|
134 |
+
* Fixed cloning wysiwyg field when tinyMCE mode is turned off (only show quick tags).
|
135 |
+
* Fixed image_upload & file_upload field doesn't add attachment to post
|
136 |
+
* Fixed text_list fields not saving correctly when edit not last field.
|
137 |
+
|
138 |
= 4.11.1 =
|
139 |
|
140 |
* Added button for "Check/Uncheck all options" in input list field when type is `checkbox_list`. Props @mrbrazzi.
|