Version Description
- Improvement: the plugin translation is now handled in translate.wordpress.org. While the plugin keeps old translation as backward compatibility, it's recommended to translate everything in translate.wordpress.org. Language packs will be automatically updated by WordPress.
- Improvement: rewrite code for
file_advanced
andimage_advanced
, which share the same code base. These fields are now clonable and not autosave (you have to save post to save files)! Props @funkatronic. - Improvement: restyle clone icon, sort clone icon and add clone button for better UI. The new UI now is compatible with
color
anddate
fields - Improvement: separate validation module into 1 class, for better code structure
- Improvement: add
pattern
attribute forurl
field - Improvement: improve code quality
- Fix: missing "checked" when clone radio
- Fix: language file name for Dutch
- Fix: oembed not render preview if provider is added via
wp_embed_register_handler
Download this release
Release Info
Developer | rilwis |
Plugin | Meta Box |
Version | 4.6 |
Comparing to | |
See all releases |
Code changes from version 4.5.7 to 4.6
- css/color.css +1 -8
- css/media.css +125 -0
- css/select.css +3 -7
- css/style.css +39 -8
- inc/common.php +14 -20
- inc/field.php +12 -6
- inc/fields/color.php +1 -2
- inc/fields/file-advanced.php +2 -117
- inc/fields/hidden.php +1 -1
- inc/fields/image-advanced.php +23 -101
- inc/fields/media.php +255 -0
- inc/fields/oembed.php +7 -0
- inc/fields/post.php +2 -0
- inc/fields/select-advanced.php +1 -1
- inc/fields/taxonomy-advanced.php +1 -2
- inc/fields/taxonomy.php +2 -42
- inc/fields/url.php +3 -2
- inc/helpers.php +8 -4
- inc/init.php +1 -1
- inc/meta-box.php +40 -56
- inc/validation.php +48 -0
- js/clone.js +12 -8
- js/color.js +16 -28
- js/date.js +3 -3
- js/file-advanced.js +0 -91
- js/image-advanced.js +0 -90
- js/map.js +0 -1
- js/media.js +309 -0
- js/validate.js +25 -16
- lang/{ar.mo → meta-box-ar.mo} +0 -0
- lang/{de_DE.mo → meta-box-de_DE.mo} +0 -0
- lang/{es_ES.mo → meta-box-es_ES.mo} +0 -0
- lang/{fa_IR.mo → meta-box-fa_IR.mo} +0 -0
- lang/{fr_FR.mo → meta-box-fr_FR.mo} +0 -0
- lang/{it_IT.mo → meta-box-it_IT.mo} +0 -0
- lang/{nb_NO.mo → meta-box-nb_NO.mo} +0 -0
- lang/{nl.mo → meta-box-nl_NL.mo} +0 -0
- lang/{pl_PL.mo → meta-box-pl_PL.mo} +0 -0
- lang/{pt_BR.mo → meta-box-pt_BR.mo} +0 -0
- lang/{sv_SE.mo → meta-box-sv_SE.mo} +0 -0
- lang/{tr_TR.mo → meta-box-tr_TR.mo} +0 -0
- lang/{zh_CN.mo → meta-box-zh_CN.mo} +0 -0
- lang/vi.mo +0 -0
- meta-box.php +15 -12
- readme.txt +13 -1
css/color.css
CHANGED
@@ -1,14 +1,7 @@
|
|
1 |
-
.rwmb-color-picker {
|
2 |
-
display: none; /* Hidden by default */
|
3 |
-
z-index: 100;
|
4 |
-
background: rgb(238, 238, 238);
|
5 |
-
border: 1px solid rgb(204, 204, 204);
|
6 |
-
position: absolute;
|
7 |
-
}
|
8 |
.rwmb-color-wrapper .wp-picker-container {
|
9 |
position: relative;
|
10 |
}
|
11 |
.rwmb-color-wrapper .wp-picker-holder {
|
12 |
position: absolute;
|
13 |
-
z-index:
|
14 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
.rwmb-color-wrapper .wp-picker-container {
|
2 |
position: relative;
|
3 |
}
|
4 |
.rwmb-color-wrapper .wp-picker-holder {
|
5 |
position: absolute;
|
6 |
+
z-index: 9;
|
7 |
}
|
css/media.css
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.rwmb-media-list {
|
2 |
+
margin: 0 0 5px;
|
3 |
+
overflow: hidden;
|
4 |
+
}
|
5 |
+
.rwmb-media-item {
|
6 |
+
overflow: hidden;
|
7 |
+
margin-bottom: 10px;
|
8 |
+
}
|
9 |
+
.rwmb-media-preview {
|
10 |
+
width: 60px;
|
11 |
+
float: left;
|
12 |
+
position: relative;
|
13 |
+
}
|
14 |
+
.rwmb-media-preview:before {
|
15 |
+
content: '';
|
16 |
+
display: block;
|
17 |
+
padding-top: 100%;
|
18 |
+
}
|
19 |
+
.rwmb-media-content {
|
20 |
+
position: absolute;
|
21 |
+
overflow: hidden;
|
22 |
+
top: 0;
|
23 |
+
left: 0;
|
24 |
+
bottom: 0;
|
25 |
+
right: 0;
|
26 |
+
}
|
27 |
+
.rwmb-media-content .centered {
|
28 |
+
position: absolute;
|
29 |
+
top: 0;
|
30 |
+
left: 0;
|
31 |
+
width: 100%;
|
32 |
+
height: 100%;
|
33 |
+
-webkit-transform: translate(50%, 50%);
|
34 |
+
-ms-transform: translate(50%, 50%);
|
35 |
+
transform: translate(50%, 50%);
|
36 |
+
}
|
37 |
+
.rwmb-media-content img {
|
38 |
+
-webkit-transform: translate(-50%, -50%);
|
39 |
+
-ms-transform: translate(-50%, -50%);
|
40 |
+
transform: translate(-50%, -50%);
|
41 |
+
max-height: 100%;
|
42 |
+
max-width: 100%;
|
43 |
+
border-radius: 3px;
|
44 |
+
}
|
45 |
+
.rwmb-media-info {
|
46 |
+
margin-left: 65px;
|
47 |
+
}
|
48 |
+
.rwmb-media-info a {
|
49 |
+
text-decoration: none;
|
50 |
+
}
|
51 |
+
.rwmb-media-info p,
|
52 |
+
.rwmb-media-info h4 {
|
53 |
+
margin: 0 0 2px;
|
54 |
+
}
|
55 |
+
.rwmb-edit-media,
|
56 |
+
.rwmb-remove-media {
|
57 |
+
font-size: 11px;
|
58 |
+
color: inherit;
|
59 |
+
}
|
60 |
+
.rwmb-edit-media .dashicons,
|
61 |
+
.rwmb-remove-media .dashicons {
|
62 |
+
font-size: 12px;
|
63 |
+
width: 12px;
|
64 |
+
height: 12px;
|
65 |
+
vertical-align: middle;
|
66 |
+
}
|
67 |
+
|
68 |
+
/* Add more button */
|
69 |
+
.rwmb-media-view .rwmb-add-media {
|
70 |
+
padding-left: 5px;
|
71 |
+
margin-right: 5px;
|
72 |
+
}
|
73 |
+
|
74 |
+
/* Status */
|
75 |
+
.rwmb-media-status {
|
76 |
+
display: inline-block;
|
77 |
+
text-decoration: none;
|
78 |
+
font-size: 13px;
|
79 |
+
line-height: 26px;
|
80 |
+
height: 28px;
|
81 |
+
}
|
82 |
+
|
83 |
+
/* Image */
|
84 |
+
.rwmb-image-item {
|
85 |
+
position: relative;
|
86 |
+
float: left;
|
87 |
+
padding: 0;
|
88 |
+
margin: 0 5px 5px 0;
|
89 |
+
box-sizing: border-box;
|
90 |
+
width: 150px;
|
91 |
+
}
|
92 |
+
.rwmb-image-item .rwmb-media-preview {
|
93 |
+
width: 150px;
|
94 |
+
}
|
95 |
+
.rwmb-image-item .dashicons {
|
96 |
+
font-size: 20px;
|
97 |
+
width: 20px;
|
98 |
+
height: 20px;
|
99 |
+
}
|
100 |
+
.rwmb-media-bar {
|
101 |
+
position: absolute;
|
102 |
+
z-index: 10;
|
103 |
+
display: none;
|
104 |
+
right: 5px;
|
105 |
+
top: 5px;
|
106 |
+
color: #fff;
|
107 |
+
}
|
108 |
+
.rwmb-media-bar a {
|
109 |
+
text-decoration: none;
|
110 |
+
color: inherit;
|
111 |
+
}
|
112 |
+
.rwmb-overlay {
|
113 |
+
position: absolute;
|
114 |
+
top: 0;
|
115 |
+
bottom: 0;
|
116 |
+
left: 0;
|
117 |
+
right: 0;
|
118 |
+
background: rgba(0, 0, 0, .6);
|
119 |
+
display: none;
|
120 |
+
}
|
121 |
+
.rwmb-image-item:hover .rwmb-media-bar,
|
122 |
+
.rwmb-image-item:hover .rwmb-overlay {
|
123 |
+
display: block;
|
124 |
+
cursor: move;
|
125 |
+
}
|
css/select.css
CHANGED
@@ -1,8 +1,4 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
min-width: 200px;
|
4 |
-
}
|
5 |
-
|
6 |
-
#post-body .rwmb-select-all {
|
7 |
margin-top: 5px;
|
8 |
-
}
|
1 |
+
.rwmb-select-all-none {
|
2 |
+
display: block;
|
|
|
|
|
|
|
|
|
3 |
margin-top: 5px;
|
4 |
+
}
|
css/style.css
CHANGED
@@ -1,16 +1,27 @@
|
|
1 |
/* =Styles for 'normal' meta boxes
|
2 |
-------------------------------------------------------------- */
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
.rwmb-field {
|
|
|
|
|
5 |
margin: 0 0 10px;
|
6 |
}
|
7 |
.rwmb-label,
|
8 |
.rwmb-input {
|
9 |
-
display: inline-block;
|
10 |
vertical-align: top;
|
|
|
11 |
}
|
12 |
.rwmb-label {
|
13 |
-
width:
|
14 |
}
|
15 |
.rwmb-label.required > span {
|
16 |
color: #c00;
|
@@ -43,21 +54,41 @@
|
|
43 |
.rwmb-clone > input[type='checkbox'] {
|
44 |
margin: 6px 0 0 4px;
|
45 |
}
|
46 |
-
.rwmb-button {
|
47 |
-
float: right;
|
48 |
-
}
|
49 |
.rwmb-button.remove-clone {
|
|
|
|
|
|
|
|
|
|
|
50 |
position: absolute;
|
51 |
top: 0;
|
52 |
right: 0;
|
53 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
.rwmb-clone-icon {
|
55 |
cursor: move;
|
56 |
background: url(../img/drag_icon.gif) no-repeat;
|
57 |
height: 23px;
|
58 |
width: 15px;
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
|
63 |
/* Fix empty block below admin footer (issue #24) */
|
@@ -73,7 +104,7 @@ label.error {
|
|
73 |
input.error,
|
74 |
textarea.error,
|
75 |
select.error {
|
76 |
-
border: #c00
|
77 |
background: #ffebe8 !important;
|
78 |
}
|
79 |
|
1 |
/* =Styles for 'normal' meta boxes
|
2 |
-------------------------------------------------------------- */
|
3 |
|
4 |
+
/* Clearfix for field */
|
5 |
+
.rwmb-field:before,
|
6 |
+
.rwmb-field:after {
|
7 |
+
content: " ";
|
8 |
+
display: table;
|
9 |
+
}
|
10 |
+
.rwmb-field:after {
|
11 |
+
clear: both;
|
12 |
+
}
|
13 |
.rwmb-field {
|
14 |
+
*zoom: 1;
|
15 |
+
|
16 |
margin: 0 0 10px;
|
17 |
}
|
18 |
.rwmb-label,
|
19 |
.rwmb-input {
|
|
|
20 |
vertical-align: top;
|
21 |
+
float: left;
|
22 |
}
|
23 |
.rwmb-label {
|
24 |
+
width: 25%;
|
25 |
}
|
26 |
.rwmb-label.required > span {
|
27 |
color: #c00;
|
54 |
.rwmb-clone > input[type='checkbox'] {
|
55 |
margin: 6px 0 0 4px;
|
56 |
}
|
|
|
|
|
|
|
57 |
.rwmb-button.remove-clone {
|
58 |
+
text-decoration: none;
|
59 |
+
color: #fff;
|
60 |
+
background: #c00;
|
61 |
+
border-radius: 50%;
|
62 |
+
display: inline-block;
|
63 |
position: absolute;
|
64 |
top: 0;
|
65 |
right: 0;
|
66 |
}
|
67 |
+
.remove-clone:focus {
|
68 |
+
outline: 0;
|
69 |
+
box-shadow: none;
|
70 |
+
}
|
71 |
+
.rwmb-button.add-clone {
|
72 |
+
margin-top: 5px;
|
73 |
+
}
|
74 |
.rwmb-clone-icon {
|
75 |
cursor: move;
|
76 |
background: url(../img/drag_icon.gif) no-repeat;
|
77 |
height: 23px;
|
78 |
width: 15px;
|
79 |
+
vertical-align: top;
|
80 |
+
display: inline-block;
|
81 |
+
position: absolute;
|
82 |
+
left: 0;
|
83 |
+
top: 0;
|
84 |
+
}
|
85 |
+
.rwmb-clone-placeholder {
|
86 |
+
background: #fcf8e3;
|
87 |
+
border: 1px solid #faebcc;
|
88 |
+
display: block;
|
89 |
+
}
|
90 |
+
.rwmb-sort-clone {
|
91 |
+
padding-left: 15px;
|
92 |
}
|
93 |
|
94 |
/* Fix empty block below admin footer (issue #24) */
|
104 |
input.error,
|
105 |
textarea.error,
|
106 |
select.error {
|
107 |
+
border-color: #c00 !important;
|
108 |
background: #ffebe8 !important;
|
109 |
}
|
110 |
|
inc/common.php
CHANGED
@@ -1,51 +1,46 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
// Prevent loading this file directly
|
3 |
defined( 'ABSPATH' ) || exit;
|
4 |
|
5 |
if ( ! class_exists( 'RWMB_Common' ) )
|
6 |
{
|
7 |
/**
|
8 |
-
*
|
9 |
-
* Independent from meta box/field classes
|
10 |
*/
|
11 |
class RWMB_Common
|
12 |
{
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
* @return void
|
17 |
*/
|
18 |
-
public static function
|
19 |
{
|
20 |
-
|
21 |
|
22 |
$plugin = 'meta-box/meta-box.php';
|
23 |
add_filter( "plugin_action_links_$plugin", array( __CLASS__, 'plugin_links' ) );
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
-
* Load plugin translation
|
28 |
-
*
|
29 |
* @return void
|
30 |
*/
|
31 |
public static function load_textdomain()
|
32 |
{
|
33 |
-
|
34 |
-
$locale = get_locale();
|
35 |
-
$dir = trailingslashit( RWMB_DIR . 'lang' );
|
36 |
-
$mofile = "{$dir}{$locale}.mo";
|
37 |
-
|
38 |
-
// In themes/plugins/mu-plugins directory
|
39 |
-
load_textdomain( 'meta-box', $mofile );
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
-
* Add links to Documentation and Extensions in plugin's list of action links
|
44 |
*
|
45 |
* @since 4.3.11
|
46 |
-
*
|
47 |
* @param array $links Array of action links
|
48 |
-
*
|
49 |
* @return array
|
50 |
*/
|
51 |
public static function plugin_links( $links )
|
@@ -54,8 +49,7 @@ if ( ! class_exists( 'RWMB_Common' ) )
|
|
54 |
$links[] = '<a href="http://metabox.io/plugins/">' . __( 'Extensions', 'meta-box' ) . '</a>';
|
55 |
return $links;
|
56 |
}
|
57 |
-
|
58 |
}
|
59 |
|
60 |
-
RWMB_Common::
|
61 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Handle common actions for the plugin: load text domain, add plugin links.
|
4 |
+
*
|
5 |
+
* @package Meta Box
|
6 |
+
*/
|
7 |
+
|
8 |
// Prevent loading this file directly
|
9 |
defined( 'ABSPATH' ) || exit;
|
10 |
|
11 |
if ( ! class_exists( 'RWMB_Common' ) )
|
12 |
{
|
13 |
/**
|
14 |
+
* Class that handle actions for the plugin.
|
|
|
15 |
*/
|
16 |
class RWMB_Common
|
17 |
{
|
18 |
/**
|
19 |
+
* Add actions when class is loaded.
|
|
|
20 |
* @return void
|
21 |
*/
|
22 |
+
public static function load()
|
23 |
{
|
24 |
+
add_action( 'plugins_loaded', array( __CLASS__, 'load_textdomain' ) );
|
25 |
|
26 |
$plugin = 'meta-box/meta-box.php';
|
27 |
add_filter( "plugin_action_links_$plugin", array( __CLASS__, 'plugin_links' ) );
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
+
* Load plugin translation.
|
|
|
32 |
* @return void
|
33 |
*/
|
34 |
public static function load_textdomain()
|
35 |
{
|
36 |
+
load_plugin_textdomain( 'meta-box', false, plugin_basename( RWMB_DIR ) . '/lang/' );
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
+
* Add links to Documentation and Extensions in plugin's list of action links.
|
41 |
*
|
42 |
* @since 4.3.11
|
|
|
43 |
* @param array $links Array of action links
|
|
|
44 |
* @return array
|
45 |
*/
|
46 |
public static function plugin_links( $links )
|
49 |
$links[] = '<a href="http://metabox.io/plugins/">' . __( 'Extensions', 'meta-box' ) . '</a>';
|
50 |
return $links;
|
51 |
}
|
|
|
52 |
}
|
53 |
|
54 |
+
RWMB_Common::load();
|
55 |
}
|
inc/field.php
CHANGED
@@ -34,7 +34,7 @@ if ( ! class_exists( 'RWMB_Field ' ) )
|
|
34 |
*/
|
35 |
static function show( $field, $saved )
|
36 |
{
|
37 |
-
|
38 |
|
39 |
$field_class = RW_Meta_Box::get_class_name( $field );
|
40 |
$meta = call_user_func( array( $field_class, 'meta' ), $post->ID, $saved, $field );
|
@@ -69,7 +69,7 @@ if ( ! class_exists( 'RWMB_Field ' ) )
|
|
69 |
|
70 |
/**
|
71 |
* Note: $meta must contain value so that the foreach loop runs!
|
72 |
-
* @see
|
73 |
*/
|
74 |
foreach ( $meta as $index => $sub_meta )
|
75 |
{
|
@@ -85,7 +85,12 @@ if ( ! class_exists( 'RWMB_Field ' ) )
|
|
85 |
$sub_field['field_name'] .= '[]';
|
86 |
|
87 |
// Wrap field HTML in a div with class="rwmb-clone" if needed
|
88 |
-
$
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
// Drag clone icon
|
91 |
if ( $field['sort_clone'] )
|
@@ -241,7 +246,7 @@ if ( ! class_exists( 'RWMB_Field ' ) )
|
|
241 |
*/
|
242 |
static function add_clone_button( $field )
|
243 |
{
|
244 |
-
$text = apply_filters( 'rwmb_add_clone_button_text', __( '+', 'meta-box' ), $field );
|
245 |
return "<a href='#' class='rwmb-button button-primary add-clone'>$text</a>";
|
246 |
}
|
247 |
|
@@ -254,8 +259,9 @@ if ( ! class_exists( 'RWMB_Field ' ) )
|
|
254 |
*/
|
255 |
static function remove_clone_button( $field )
|
256 |
{
|
257 |
-
$
|
258 |
-
|
|
|
259 |
}
|
260 |
|
261 |
/**
|
34 |
*/
|
35 |
static function show( $field, $saved )
|
36 |
{
|
37 |
+
$post = get_post();
|
38 |
|
39 |
$field_class = RW_Meta_Box::get_class_name( $field );
|
40 |
$meta = call_user_func( array( $field_class, 'meta' ), $post->ID, $saved, $field );
|
69 |
|
70 |
/**
|
71 |
* Note: $meta must contain value so that the foreach loop runs!
|
72 |
+
* @see meta()
|
73 |
*/
|
74 |
foreach ( $meta as $index => $sub_meta )
|
75 |
{
|
85 |
$sub_field['field_name'] .= '[]';
|
86 |
|
87 |
// Wrap field HTML in a div with class="rwmb-clone" if needed
|
88 |
+
$class = "rwmb-clone rwmb-{$field['type']}-clone";
|
89 |
+
if ( $field['sort_clone'] )
|
90 |
+
{
|
91 |
+
$class .= ' rwmb-sort-clone';
|
92 |
+
}
|
93 |
+
$input_html = "<div class='$class'>";
|
94 |
|
95 |
// Drag clone icon
|
96 |
if ( $field['sort_clone'] )
|
246 |
*/
|
247 |
static function add_clone_button( $field )
|
248 |
{
|
249 |
+
$text = apply_filters( 'rwmb_add_clone_button_text', __( '+ Add more', 'meta-box' ), $field );
|
250 |
return "<a href='#' class='rwmb-button button-primary add-clone'>$text</a>";
|
251 |
}
|
252 |
|
259 |
*/
|
260 |
static function remove_clone_button( $field )
|
261 |
{
|
262 |
+
$icon = '<i class="dashicons dashicons-minus"></i>';
|
263 |
+
$text = apply_filters( 'rwmb_remove_clone_button_text', $icon, $field );
|
264 |
+
return "<a href='#' class='rwmb-button remove-clone'>$text</a>";
|
265 |
}
|
266 |
|
267 |
/**
|
inc/fields/color.php
CHANGED
@@ -28,8 +28,7 @@ if ( ! class_exists( 'RWMB_Color_Field' ) )
|
|
28 |
static function html( $meta, $field )
|
29 |
{
|
30 |
return sprintf(
|
31 |
-
'<input class="rwmb-color" type="text" name="%s" id="%s" value="%s" size="%s"
|
32 |
-
<div class="rwmb-color-picker"></div>',
|
33 |
$field['field_name'],
|
34 |
empty( $field['clone'] ) ? $field['id'] : '',
|
35 |
$meta,
|
28 |
static function html( $meta, $field )
|
29 |
{
|
30 |
return sprintf(
|
31 |
+
'<input class="rwmb-color" type="text" name="%s" id="%s" value="%s" size="%s">',
|
|
|
32 |
$field['field_name'],
|
33 |
empty( $field['clone'] ) ? $field['id'] : '',
|
34 |
$meta,
|
inc/fields/file-advanced.php
CHANGED
@@ -2,123 +2,8 @@
|
|
2 |
// Prevent loading this file directly
|
3 |
defined( 'ABSPATH' ) || exit;
|
4 |
|
5 |
-
require_once RWMB_FIELDS_DIR . '
|
6 |
if ( ! class_exists( 'RWMB_File_Advanced_Field' ) )
|
7 |
{
|
8 |
-
class RWMB_File_Advanced_Field extends
|
9 |
-
{
|
10 |
-
/**
|
11 |
-
* Enqueue scripts and styles
|
12 |
-
*
|
13 |
-
* @return void
|
14 |
-
*/
|
15 |
-
static function admin_enqueue_scripts()
|
16 |
-
{
|
17 |
-
parent::admin_enqueue_scripts();
|
18 |
-
|
19 |
-
// Make sure scripts for new media uploader in WordPress 3.5 is enqueued
|
20 |
-
wp_enqueue_media();
|
21 |
-
wp_enqueue_script( 'rwmb-file-advanced', RWMB_JS_URL . 'file-advanced.js', array( 'jquery', 'underscore' ), RWMB_VER, true );
|
22 |
-
wp_localize_script( 'rwmb-file-advanced', 'rwmbFileAdvanced', array(
|
23 |
-
'frameTitle' => __( 'Select Files', 'meta-box' ),
|
24 |
-
) );
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Add actions
|
29 |
-
*
|
30 |
-
* @return void
|
31 |
-
*/
|
32 |
-
static function add_actions()
|
33 |
-
{
|
34 |
-
parent::add_actions();
|
35 |
-
|
36 |
-
// Attach images via Ajax
|
37 |
-
add_action( 'wp_ajax_rwmb_attach_file', array( __CLASS__, 'wp_ajax_attach_file' ) );
|
38 |
-
add_action( 'print_media_templates', array( __CLASS__, 'print_templates' ) );
|
39 |
-
}
|
40 |
-
|
41 |
-
static function wp_ajax_attach_file()
|
42 |
-
{
|
43 |
-
$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0;
|
44 |
-
$field_id = isset( $_POST['field_id'] ) ? $_POST['field_id'] : 0;
|
45 |
-
$attachment_ids = isset( $_POST['attachment_ids'] ) ? (array) $_POST['attachment_ids'] : array();
|
46 |
-
|
47 |
-
check_ajax_referer( "rwmb-attach-file_{$field_id}" );
|
48 |
-
foreach ( $attachment_ids as $attachment_id )
|
49 |
-
{
|
50 |
-
add_post_meta( $post_id, $field_id, $attachment_id, false );
|
51 |
-
}
|
52 |
-
|
53 |
-
wp_send_json_success();
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Get field HTML
|
58 |
-
*
|
59 |
-
* @param mixed $meta
|
60 |
-
* @param array $field
|
61 |
-
*
|
62 |
-
* @return string
|
63 |
-
*/
|
64 |
-
static function html( $meta, $field )
|
65 |
-
{
|
66 |
-
$i18n_title = apply_filters( 'rwmb_file_advanced_select_string', _x( 'Select or Upload Files', 'file upload', 'meta-box' ), $field );
|
67 |
-
$attach_nonce = wp_create_nonce( "rwmb-attach-file_{$field['id']}" );
|
68 |
-
|
69 |
-
// Uploaded files
|
70 |
-
$html = self::get_uploaded_files( $meta, $field );
|
71 |
-
|
72 |
-
// Show form upload
|
73 |
-
$classes = array( 'button', 'rwmb-file-advanced-upload', 'hide-if-no-js', 'new-files' );
|
74 |
-
if ( ! empty( $field['max_file_uploads'] ) && count( $meta ) >= (int) $field['max_file_uploads'] )
|
75 |
-
$classes[] = 'hidden';
|
76 |
-
|
77 |
-
$classes = implode( ' ', $classes );
|
78 |
-
$html .= "<a href='#' class='{$classes}' data-attach_file_nonce={$attach_nonce}>{$i18n_title}</a>";
|
79 |
-
|
80 |
-
return $html;
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Get field value
|
85 |
-
* It's the combination of new (uploaded) images and saved images
|
86 |
-
*
|
87 |
-
* @param array $new
|
88 |
-
* @param array $old
|
89 |
-
* @param int $post_id
|
90 |
-
* @param array $field
|
91 |
-
*
|
92 |
-
* @return array|mixed
|
93 |
-
*/
|
94 |
-
static function value( $new, $old, $post_id, $field )
|
95 |
-
{
|
96 |
-
$new = (array) $new;
|
97 |
-
|
98 |
-
return array_unique( array_merge( $old, $new ) );
|
99 |
-
}
|
100 |
-
|
101 |
-
static function print_templates()
|
102 |
-
{
|
103 |
-
$i18n_delete = apply_filters( 'rwmb_file_delete_string', _x( 'Delete', 'file upload', 'meta-box' ) );
|
104 |
-
$i18n_edit = apply_filters( 'rwmb_file_edit_string', _x( 'Edit', 'file upload', 'meta-box' ) );
|
105 |
-
?>
|
106 |
-
<script id="tmpl-rwmb-file-advanced" type="text/html">
|
107 |
-
<# _.each( attachments, function( attachment ) { #>
|
108 |
-
<li id="item_{{{ attachment.id }}}">
|
109 |
-
<div class="rwmb-icon">
|
110 |
-
<img src="<# if ( attachment.type == 'image' ){ #>{{{ attachment.sizes.thumbnail.url }}}<# } else { #>{{{ attachment.icon }}}<# } #>">
|
111 |
-
</div>
|
112 |
-
<div class="rwmb-info">
|
113 |
-
<a href="{{{ attachment.url }}}" target="_blank">{{{ attachment.title }}}</a>
|
114 |
-
<p>{{{ attachment.mime }}}</p>
|
115 |
-
<a title="<?php echo esc_attr( $i18n_edit ); ?>" href="{{{ attachment.editLink }}}" target="_blank"><?php echo esc_html( $i18n_edit ); ?></a> |
|
116 |
-
<a title="<?php echo esc_attr( $i18n_delete ); ?>" class="rwmb-delete-file" href="#" data-attachment_id="{{{ attachment.id }}}"><?php echo esc_html( $i18n_delete ); ?></a>
|
117 |
-
</div>
|
118 |
-
</li>
|
119 |
-
<# } ); #>
|
120 |
-
</script>
|
121 |
-
<?php
|
122 |
-
}
|
123 |
-
}
|
124 |
}
|
2 |
// Prevent loading this file directly
|
3 |
defined( 'ABSPATH' ) || exit;
|
4 |
|
5 |
+
require_once RWMB_FIELDS_DIR . 'media.php';
|
6 |
if ( ! class_exists( 'RWMB_File_Advanced_Field' ) )
|
7 |
{
|
8 |
+
class RWMB_File_Advanced_Field extends RWMB_Media_Field {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
}
|
inc/fields/hidden.php
CHANGED
@@ -20,7 +20,7 @@ if ( ! class_exists( 'RWMB_Hidden_Field' ) )
|
|
20 |
'<input type="hidden" class="rwmb-hidden" name="%s" id="%s" value="%s">',
|
21 |
$field['field_name'],
|
22 |
$field['id'],
|
23 |
-
$
|
24 |
);
|
25 |
}
|
26 |
}
|
20 |
'<input type="hidden" class="rwmb-hidden" name="%s" id="%s" value="%s">',
|
21 |
$field['field_name'],
|
22 |
$field['id'],
|
23 |
+
$meta
|
24 |
);
|
25 |
}
|
26 |
}
|
inc/fields/image-advanced.php
CHANGED
@@ -2,60 +2,24 @@
|
|
2 |
// Prevent loading this file directly
|
3 |
defined( 'ABSPATH' ) || exit;
|
4 |
|
5 |
-
require_once RWMB_FIELDS_DIR . '
|
6 |
if ( ! class_exists( 'RWMB_Image_Advanced_Field' ) )
|
7 |
{
|
8 |
-
class RWMB_Image_Advanced_Field extends
|
9 |
{
|
10 |
/**
|
11 |
-
*
|
12 |
*
|
13 |
-
* @
|
14 |
-
*/
|
15 |
-
static function admin_enqueue_scripts()
|
16 |
-
{
|
17 |
-
parent::admin_enqueue_scripts();
|
18 |
-
|
19 |
-
// Make sure scripts for new media uploader in WordPress 3.5 is enqueued
|
20 |
-
wp_enqueue_media();
|
21 |
-
wp_enqueue_script( 'rwmb-image-advanced', RWMB_JS_URL . 'image-advanced.js', array( 'jquery', 'underscore' ), RWMB_VER, true );
|
22 |
-
wp_localize_script( 'rwmb-image-advanced', 'rwmbImageAdvanced', array(
|
23 |
-
'frameTitle' => __( 'Select Images', 'meta-box' ),
|
24 |
-
) );
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Add actions
|
29 |
-
*
|
30 |
-
* @return void
|
31 |
-
*/
|
32 |
-
static function add_actions()
|
33 |
-
{
|
34 |
-
// Do same actions as file field
|
35 |
-
parent::add_actions();
|
36 |
-
|
37 |
-
// Attach images via Ajax
|
38 |
-
add_action( 'wp_ajax_rwmb_attach_media', array( __CLASS__, 'wp_ajax_attach_media' ) );
|
39 |
-
add_action( 'print_media_templates', array( __CLASS__, 'print_templates' ) );
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Ajax callback for attaching media to field
|
44 |
*
|
45 |
-
* @return
|
46 |
*/
|
47 |
-
static function
|
48 |
{
|
49 |
-
$
|
50 |
-
$
|
51 |
-
$attachment_ids = isset( $_POST['attachment_ids'] ) ? (array) $_POST['attachment_ids'] : array();
|
52 |
|
53 |
-
|
54 |
-
foreach ( $attachment_ids as $attachment_id )
|
55 |
-
{
|
56 |
-
add_post_meta( $post_id, $field_id, $attachment_id, false );
|
57 |
-
}
|
58 |
-
wp_send_json_success();
|
59 |
}
|
60 |
|
61 |
/**
|
@@ -67,64 +31,22 @@ if ( ! class_exists( 'RWMB_Image_Advanced_Field' ) )
|
|
67 |
* @return string
|
68 |
*/
|
69 |
static function html( $meta, $field )
|
70 |
-
{
|
71 |
-
$
|
72 |
-
$
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
$
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
|
85 |
return $html;
|
86 |
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Get field value
|
90 |
-
* It's the combination of new (uploaded) images and saved images
|
91 |
-
*
|
92 |
-
* @param array $new
|
93 |
-
* @param array $old
|
94 |
-
* @param int $post_id
|
95 |
-
* @param array $field
|
96 |
-
*
|
97 |
-
* @return array|mixed
|
98 |
-
*/
|
99 |
-
static function value( $new, $old, $post_id, $field )
|
100 |
-
{
|
101 |
-
$new = (array) $new;
|
102 |
-
|
103 |
-
return array_unique( array_merge( $old, $new ) );
|
104 |
-
}
|
105 |
-
|
106 |
-
static function print_templates()
|
107 |
-
{
|
108 |
-
$i18n_delete = apply_filters( 'rwmb_image_delete_string', _x( 'Delete', 'image upload', 'meta-box' ) );
|
109 |
-
$i18n_edit = apply_filters( 'rwmb_image_edit_string', _x( 'Edit', 'image upload', 'meta-box' ) );
|
110 |
-
?>
|
111 |
-
<script id="tmpl-rwmb-image-advanced" type="text/html">
|
112 |
-
<# _.each( attachments, function( attachment ) { #>
|
113 |
-
<li id="item_{{{ attachment.id }}}">
|
114 |
-
<# if ( attachment.sizes.hasOwnProperty( 'thumbnail' ) ) { #>
|
115 |
-
<img src="{{{ attachment.sizes.thumbnail.url }}}">
|
116 |
-
<# } else { #>
|
117 |
-
<img src="{{{ attachment.sizes.full.url }}}">
|
118 |
-
<# } #>
|
119 |
-
<div class="rwmb-image-bar">
|
120 |
-
<a title="<?php echo esc_attr( $i18n_edit ); ?>" class="rwmb-edit-file" href="{{{ attachment.editLink }}}" target="_blank"><?php echo esc_html( $i18n_edit ); ?></a> |
|
121 |
-
<a title="<?php echo esc_attr( $i18n_delete ); ?>" class="rwmb-delete-file" href="#" data-attachment_id="{{{ attachment.id }}}">×</a>
|
122 |
-
</div>
|
123 |
-
</li>
|
124 |
-
<# } ); #>
|
125 |
-
</script>
|
126 |
-
<?php
|
127 |
-
}
|
128 |
-
|
129 |
}
|
130 |
}
|
2 |
// Prevent loading this file directly
|
3 |
defined( 'ABSPATH' ) || exit;
|
4 |
|
5 |
+
require_once RWMB_FIELDS_DIR . 'media.php';
|
6 |
if ( ! class_exists( 'RWMB_Image_Advanced_Field' ) )
|
7 |
{
|
8 |
+
class RWMB_Image_Advanced_Field extends RWMB_Media_Field
|
9 |
{
|
10 |
/**
|
11 |
+
* Normalize parameters for field
|
12 |
*
|
13 |
+
* @param array $field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
*
|
15 |
+
* @return array
|
16 |
*/
|
17 |
+
static function normalize_field( $field )
|
18 |
{
|
19 |
+
$field = parent::normalize_field( $field );
|
20 |
+
$field['mime_type'] = 'image';
|
|
|
21 |
|
22 |
+
return $field;
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
|
25 |
/**
|
31 |
* @return string
|
32 |
*/
|
33 |
static function html( $meta, $field )
|
34 |
+
{
|
35 |
+
$i18n_add = apply_filters( 'rwmb_media_add_string', _x( '+ Add Media', 'media', 'meta-box' ) );
|
36 |
+
$meta = (array) $meta;
|
37 |
+
$meta = implode( ',', $meta );
|
38 |
+
$html = sprintf(
|
39 |
+
'<input type="hidden" name="%s" value="%s" class="rwmb-image-advanced">
|
40 |
+
<div class="rwmb-media-view" data-mime-type="%s" data-max-files="%s" data-force-delete="%s"></div>',
|
41 |
+
$field['field_name'],
|
42 |
+
esc_attr( $meta ),
|
43 |
+
$field['mime_type'],
|
44 |
+
$field['max_file_uploads'] ,
|
45 |
+
$field['force_delete'] ? 'true' : 'false',
|
46 |
+
$i18n_add
|
47 |
+
);
|
48 |
|
49 |
return $html;
|
50 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
}
|
inc/fields/media.php
ADDED
@@ -0,0 +1,255 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Prevent loading this file directly
|
3 |
+
defined( 'ABSPATH' ) || exit;
|
4 |
+
|
5 |
+
if ( ! class_exists( 'RWMB_Media_Field' ) )
|
6 |
+
{
|
7 |
+
class RWMB_Media_Field extends RWMB_Field
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* Enqueue scripts and styles
|
11 |
+
*
|
12 |
+
* @return void
|
13 |
+
*/
|
14 |
+
static function admin_enqueue_scripts()
|
15 |
+
{
|
16 |
+
wp_enqueue_media();
|
17 |
+
wp_enqueue_style( 'rwmb-media', RWMB_CSS_URL . 'media.css', array(), RWMB_VER );
|
18 |
+
wp_enqueue_script( 'rwmb-media', RWMB_JS_URL . 'media.js', array( 'jquery-ui-sortable', 'underscore', 'backbone' ), RWMB_VER, true );
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Add actions
|
23 |
+
*
|
24 |
+
* @return void
|
25 |
+
*/
|
26 |
+
static function add_actions()
|
27 |
+
{
|
28 |
+
// Print attachment templates
|
29 |
+
add_action( 'print_media_templates', array( __CLASS__, 'print_templates' ) );
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Get field HTML
|
34 |
+
*
|
35 |
+
* @param mixed $meta
|
36 |
+
* @param array $field
|
37 |
+
*
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
static function html( $meta, $field )
|
41 |
+
{
|
42 |
+
$meta = (array) $meta;
|
43 |
+
$meta = implode( ',', $meta );
|
44 |
+
$html = sprintf(
|
45 |
+
'<input type="hidden" name="%s" value="%s" class="rwmb-media">
|
46 |
+
<div class="rwmb-media-view" data-mime-type="%s" data-max-files="%s" data-force-delete="%s"></div>',
|
47 |
+
$field['field_name'],
|
48 |
+
esc_attr( $meta ),
|
49 |
+
$field['mime_type'],
|
50 |
+
$field['max_file_uploads'],
|
51 |
+
$field['force_delete'] ? 'true' : 'false'
|
52 |
+
);
|
53 |
+
|
54 |
+
return $html;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Normalize parameters for field
|
59 |
+
*
|
60 |
+
* @param array $field
|
61 |
+
*
|
62 |
+
* @return array
|
63 |
+
*/
|
64 |
+
static function normalize_field( $field )
|
65 |
+
{
|
66 |
+
$field = wp_parse_args( $field, array(
|
67 |
+
'std' => array(),
|
68 |
+
'mime_type' => '',
|
69 |
+
'max_file_uploads' => 0,
|
70 |
+
'force_delete' => false,
|
71 |
+
) );
|
72 |
+
|
73 |
+
$field['multiple'] = false;
|
74 |
+
|
75 |
+
return $field;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Get meta value
|
80 |
+
*
|
81 |
+
* @param int $post_id
|
82 |
+
* @param bool $saved
|
83 |
+
* @param array $field
|
84 |
+
*
|
85 |
+
* @return mixed
|
86 |
+
*/
|
87 |
+
static function meta( $post_id, $saved, $field )
|
88 |
+
{
|
89 |
+
$field['multiple'] = true;
|
90 |
+
return parent::meta( $post_id, $saved, $field );
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Get field value
|
95 |
+
* It's the combination of new (uploaded) images and saved images
|
96 |
+
*
|
97 |
+
* @param array $new
|
98 |
+
* @param array $old
|
99 |
+
* @param int $post_id
|
100 |
+
* @param array $field
|
101 |
+
*
|
102 |
+
* @return array|mixed
|
103 |
+
*/
|
104 |
+
static function value( $new, $old, $post_id, $field )
|
105 |
+
{
|
106 |
+
if ( $field['clone'] )
|
107 |
+
{
|
108 |
+
foreach ( $new as &$value )
|
109 |
+
{
|
110 |
+
$value = explode( ',', $value );
|
111 |
+
}
|
112 |
+
}
|
113 |
+
else
|
114 |
+
{
|
115 |
+
$new = explode( ',', $new );
|
116 |
+
}
|
117 |
+
return $new;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Save meta value
|
122 |
+
*
|
123 |
+
* @param $new
|
124 |
+
* @param $old
|
125 |
+
* @param $post_id
|
126 |
+
* @param $field
|
127 |
+
*/
|
128 |
+
static function save( $new, $old, $post_id, $field )
|
129 |
+
{
|
130 |
+
$name = $field['id'];
|
131 |
+
|
132 |
+
delete_post_meta( $post_id, $name );
|
133 |
+
|
134 |
+
if ( '' === $new || array() === $new )
|
135 |
+
{
|
136 |
+
return;
|
137 |
+
}
|
138 |
+
|
139 |
+
// If field is cloneable, value is saved as a single entry in the database
|
140 |
+
if ( $field['clone'] )
|
141 |
+
{
|
142 |
+
$new = (array) $new;
|
143 |
+
$new = array_filter( $new );
|
144 |
+
update_post_meta( $post_id, $name, $new );
|
145 |
+
return;
|
146 |
+
}
|
147 |
+
else
|
148 |
+
{
|
149 |
+
foreach ( $new as $new_value )
|
150 |
+
{
|
151 |
+
add_post_meta( $post_id, $name, $new_value, false );
|
152 |
+
}
|
153 |
+
return;
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Template for media item
|
159 |
+
* @return void
|
160 |
+
*/
|
161 |
+
static function print_templates()
|
162 |
+
{
|
163 |
+
$i18n_add = apply_filters( 'rwmb_media_add_string', _x( '+ Add Media', 'media', 'meta-box' ) );
|
164 |
+
$i18n_remove = apply_filters( 'rwmb_media_remove_string', _x( 'Remove', 'media', 'meta-box' ) );
|
165 |
+
$i18n_edit = apply_filters( 'rwmb_media_edit_string', _x( 'Edit', 'media', 'meta-box' ) );
|
166 |
+
$i18n_view = apply_filters( 'rwmb_media_view_string', _x( 'View', 'media', 'meta-box' ) );
|
167 |
+
$i18n_single_files = apply_filters( 'rwmb_media_single_files_string', _x( ' file', 'media', 'meta-box' ) );
|
168 |
+
$i18n_multiple_files = apply_filters( 'rwmb_media_multiple_files_string', _x( ' files', 'media', 'meta-box' ) );
|
169 |
+
$i18n_title = _x( 'No Title', 'media', 'meta-box' );
|
170 |
+
?>
|
171 |
+
<script id="tmpl-rwmb-media-item" type="text/html">
|
172 |
+
<div class="rwmb-media-preview">
|
173 |
+
<div class="rwmb-media-content">
|
174 |
+
<div class="centered">
|
175 |
+
<# if ( 'image' === data.type && data.sizes ) { #>
|
176 |
+
<# if ( data.sizes.thumbnail ) { #>
|
177 |
+
<img src="{{{ data.sizes.thumbnail.url }}}">
|
178 |
+
<# } else { #>
|
179 |
+
<img src="{{{ data.sizes.full.url }}}">
|
180 |
+
<# } #>
|
181 |
+
<# } else { #>
|
182 |
+
<# if ( data.image && data.image.src && data.image.src !== data.icon ) { #>
|
183 |
+
<img src="{{ data.image.src }}" />
|
184 |
+
<# } else { #>
|
185 |
+
<img src="{{ data.icon }}" />
|
186 |
+
<# } #>
|
187 |
+
<# } #>
|
188 |
+
</div>
|
189 |
+
</div>
|
190 |
+
</div>
|
191 |
+
<div class="rwmb-media-info">
|
192 |
+
<h4>
|
193 |
+
<a href="{{{ data.url }}}" target="_blank" title="<?php echo esc_attr( $i18n_view ); ?>">
|
194 |
+
<# if( data.title ) { #> {{{ data.title }}}
|
195 |
+
<# } else { #> <?php echo esc_attr( $i18n_title ); ?>
|
196 |
+
<# } #>
|
197 |
+
</a>
|
198 |
+
</h4>
|
199 |
+
<p>{{{ data.mime }}}</p>
|
200 |
+
<p>
|
201 |
+
<a class="rwmb-edit-media" title="<?php echo esc_attr( $i18n_edit ); ?>" href="{{{ data.editLink }}}" target="_blank">
|
202 |
+
<span class="dashicons dashicons-edit"></span><?php echo esc_attr( $i18n_edit ); ?>
|
203 |
+
</a>
|
204 |
+
<a href="#" class="rwmb-remove-media" title="<?php echo esc_attr( $i18n_remove ); ?>">
|
205 |
+
<span class="dashicons dashicons-no-alt"></span><?php echo esc_attr( $i18n_remove ); ?>
|
206 |
+
</a>
|
207 |
+
</p>
|
208 |
+
</div>
|
209 |
+
</script>
|
210 |
+
|
211 |
+
<script id="tmpl-rwmb-image-item" type="text/html">
|
212 |
+
<div class="rwmb-media-preview">
|
213 |
+
<div class="rwmb-media-content">
|
214 |
+
<div class="centered">
|
215 |
+
<# if ( 'image' === data.type && data.sizes ) { #>
|
216 |
+
<# if ( data.sizes.thumbnail ) { #>
|
217 |
+
<img src="{{{ data.sizes.thumbnail.url }}}">
|
218 |
+
<# } else { #>
|
219 |
+
<img src="{{{ data.sizes.full.url }}}">
|
220 |
+
<# } #>
|
221 |
+
<# } else { #>
|
222 |
+
<# if ( data.image && data.image.src && data.image.src !== data.icon ) { #>
|
223 |
+
<img src="{{ data.image.src }}" />
|
224 |
+
<# } else { #>
|
225 |
+
<img src="{{ data.icon }}" />
|
226 |
+
<# } #>
|
227 |
+
<# } #>
|
228 |
+
</div>
|
229 |
+
</div>
|
230 |
+
</div>
|
231 |
+
<div class="rwmb-overlay"></div>
|
232 |
+
<div class="rwmb-media-bar">
|
233 |
+
<a class="rwmb-edit-media" title="<?php echo esc_attr( $i18n_edit ); ?>" href="{{{ data.editLink }}}" target="_blank">
|
234 |
+
<span class="dashicons dashicons-edit"></span>
|
235 |
+
</a>
|
236 |
+
<a href="#" class="rwmb-remove-media" title="<?php echo esc_attr( $i18n_remove ); ?>">
|
237 |
+
<span class="dashicons dashicons-no-alt"></span>
|
238 |
+
</a>
|
239 |
+
</div>
|
240 |
+
</script>
|
241 |
+
|
242 |
+
<script id="tmpl-rwmb-add-media" type="text/html">
|
243 |
+
<?php echo $i18n_add; ?>
|
244 |
+
</script>
|
245 |
+
|
246 |
+
<script id="tmpl-rwmb-media-status" type="text/html">
|
247 |
+
<# if ( data.maxFiles > 0 ) { #>
|
248 |
+
{{{ data.items }}}/{{{ data.maxFiles }}}
|
249 |
+
<# if ( data.items > 1 || data.items < 1 ) { #> <?php echo $i18n_multiple_files; ?> <# } else {#> <?php echo $i18n_single_files; ?> <# } #>
|
250 |
+
<# } #>
|
251 |
+
</script>
|
252 |
+
<?php
|
253 |
+
}
|
254 |
+
}
|
255 |
+
}
|
inc/fields/oembed.php
CHANGED
@@ -50,8 +50,15 @@ if ( ! class_exists( 'RWMB_OEmbed_Field' ) )
|
|
50 |
*/
|
51 |
static function get_embed( $url )
|
52 |
{
|
|
|
53 |
$embed = @wp_oembed_get( $url );
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
return $embed ? $embed : __( 'Embed HTML not available.', 'meta-box' );
|
56 |
}
|
57 |
|
50 |
*/
|
51 |
static function get_embed( $url )
|
52 |
{
|
53 |
+
// Try oembed first
|
54 |
$embed = @wp_oembed_get( $url );
|
55 |
|
56 |
+
// If no oembed provides found, try WordPress auto embed
|
57 |
+
if ( ! $embed )
|
58 |
+
{
|
59 |
+
$embed = $GLOBALS['wp_embed']->shortcode( array(), $url );
|
60 |
+
}
|
61 |
+
|
62 |
return $embed ? $embed : __( 'Embed HTML not available.', 'meta-box' );
|
63 |
}
|
64 |
|
inc/fields/post.php
CHANGED
@@ -137,6 +137,8 @@ if ( ! class_exists( 'RWMB_Post_Field' ) )
|
|
137 |
while ( $query->have_posts() )
|
138 |
{
|
139 |
$post = $query->next_post();
|
|
|
|
|
140 |
$options[$post->ID] = $post->post_title;
|
141 |
}
|
142 |
}
|
137 |
while ( $query->have_posts() )
|
138 |
{
|
139 |
$post = $query->next_post();
|
140 |
+
$title = apply_filters( 'rwmb_post_field_title', $post->post_title, $post );
|
141 |
+
$title = apply_filters( "rwmb_{$field['id']}_field_title", $title, $post );
|
142 |
$options[$post->ID] = $post->post_title;
|
143 |
}
|
144 |
}
|
inc/fields/select-advanced.php
CHANGED
@@ -69,7 +69,7 @@ if ( ! class_exists( 'RWMB_Select_Advanced_Field' ) )
|
|
69 |
|
70 |
$field['js_options'] = wp_parse_args( $field['js_options'], array(
|
71 |
'allowClear' => true,
|
72 |
-
'width' => '
|
73 |
'placeholder' => $field['placeholder'],
|
74 |
) );
|
75 |
|
69 |
|
70 |
$field['js_options'] = wp_parse_args( $field['js_options'], array(
|
71 |
'allowClear' => true,
|
72 |
+
'width' => 'off',
|
73 |
'placeholder' => $field['placeholder'],
|
74 |
) );
|
75 |
|
inc/fields/taxonomy-advanced.php
CHANGED
@@ -54,8 +54,7 @@ if ( ! class_exists( 'RWMB_Taxonomy_Advanced_Field' ) )
|
|
54 |
static function meta( $post_id, $saved, $field )
|
55 |
{
|
56 |
$meta = get_post_meta( $post_id, $field['id'], true );
|
57 |
-
$meta =
|
58 |
-
|
59 |
return $meta;
|
60 |
}
|
61 |
|
54 |
static function meta( $post_id, $saved, $field )
|
55 |
{
|
56 |
$meta = get_post_meta( $post_id, $field['id'], true );
|
57 |
+
$meta = wp_parse_id_list( $meta );
|
|
|
58 |
return $meta;
|
59 |
}
|
60 |
|
inc/fields/taxonomy.php
CHANGED
@@ -169,6 +169,7 @@ if ( ! class_exists( 'RWMB_Taxonomy_Field' ) )
|
|
169 |
{
|
170 |
if ( ! isset( $elements[$parent] ) )
|
171 |
return '';
|
|
|
172 |
$terms = $elements[$parent];
|
173 |
$field['options'] = self::get_options( $terms );
|
174 |
|
@@ -298,48 +299,7 @@ if ( ! class_exists( 'RWMB_Taxonomy_Field' ) )
|
|
298 |
*/
|
299 |
static function the_value( $field, $args = array(), $post_id = null )
|
300 |
{
|
301 |
-
|
302 |
-
$value = call_user_func( array( $class, 'get_value' ), $field, $args, $post_id );
|
303 |
-
if ( ! $value || is_wp_error( $value ) )
|
304 |
-
return '';
|
305 |
-
|
306 |
-
$function = array( $class, 'get_option_label' );
|
307 |
-
|
308 |
-
if ( $field['clone'] )
|
309 |
-
{
|
310 |
-
$output = '<ul>';
|
311 |
-
if ( $field['multiple'] )
|
312 |
-
{
|
313 |
-
foreach ( $value as $subvalue )
|
314 |
-
{
|
315 |
-
$output .= '<li>';
|
316 |
-
array_walk_recursive( $subvalue, $function, $field );
|
317 |
-
$output .= '<ul><li>' . implode( '</li><li>', $subvalue ) . '</li></ul>';
|
318 |
-
$output .= '</li>';
|
319 |
-
}
|
320 |
-
}
|
321 |
-
else
|
322 |
-
{
|
323 |
-
array_walk_recursive( $value, $function, $field );
|
324 |
-
$output = '<li>' . implode( '</li><li>', $value ) . '</li>';
|
325 |
-
}
|
326 |
-
$output .= '</ul>';
|
327 |
-
}
|
328 |
-
else
|
329 |
-
{
|
330 |
-
if ( $field['multiple'] )
|
331 |
-
{
|
332 |
-
array_walk_recursive( $value, $function, $field );
|
333 |
-
$output = '<ul><li>' . implode( '</li><li>', $value ) . '</li></ul>';
|
334 |
-
}
|
335 |
-
else
|
336 |
-
{
|
337 |
-
call_user_func_array( $function, array( &$value, 0, $field ) );
|
338 |
-
$output = $value;
|
339 |
-
}
|
340 |
-
}
|
341 |
-
|
342 |
-
return $output;
|
343 |
}
|
344 |
|
345 |
/**
|
169 |
{
|
170 |
if ( ! isset( $elements[$parent] ) )
|
171 |
return '';
|
172 |
+
$meta = empty( $meta ) ? array() : ( ! is_array( $meta ) ? array() : $meta );
|
173 |
$terms = $elements[$parent];
|
174 |
$field['options'] = self::get_options( $terms );
|
175 |
|
299 |
*/
|
300 |
static function the_value( $field, $args = array(), $post_id = null )
|
301 |
{
|
302 |
+
return RWMB_Select_Field::the_value( $field, $args, $post_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
}
|
304 |
|
305 |
/**
|
inc/fields/url.php
CHANGED
@@ -20,12 +20,13 @@ if ( ! class_exists( 'RWMB_URL_Field' ) )
|
|
20 |
static function html( $meta, $field )
|
21 |
{
|
22 |
return sprintf(
|
23 |
-
'<input type="url" class="rwmb-url" name="%s" id="%s" value="%s" size="%s" placeholder="%s"/>',
|
24 |
$field['field_name'],
|
25 |
$field['id'],
|
26 |
$meta,
|
27 |
$field['size'],
|
28 |
-
$field['placeholder']
|
|
|
29 |
);
|
30 |
}
|
31 |
|
20 |
static function html( $meta, $field )
|
21 |
{
|
22 |
return sprintf(
|
23 |
+
'<input type="url" class="rwmb-url" name="%s" id="%s" value="%s" size="%s" placeholder="%s" %s/>',
|
24 |
$field['field_name'],
|
25 |
$field['id'],
|
26 |
$meta,
|
27 |
$field['size'],
|
28 |
+
$field['placeholder'],
|
29 |
+
$field['pattern'] ? 'pattern="' .$field['pattern'] . '"' : ''
|
30 |
);
|
31 |
}
|
32 |
|
inc/helpers.php
CHANGED
@@ -60,8 +60,6 @@ if ( ! class_exists( 'RWMB_Helper' ) )
|
|
60 |
'type' => 'text',
|
61 |
'multiple' => false,
|
62 |
) );
|
63 |
-
|
64 |
-
|
65 |
|
66 |
// Always set 'multiple' true for following field types
|
67 |
if ( in_array( $args['type'], array( 'checkbox_list', 'file', 'file_advanced', 'image', 'image_advanced', 'plupload_image', 'thickbox_image' ) ) )
|
@@ -137,11 +135,17 @@ if ( ! class_exists( 'RWMB_Helper' ) )
|
|
137 |
'multiple' => false,
|
138 |
'clone' => false,
|
139 |
);
|
140 |
-
$meta
|
141 |
}
|
|
|
142 |
elseif ( 'oembed' == $args['type'] )
|
143 |
{
|
144 |
-
$
|
|
|
|
|
|
|
|
|
|
|
145 |
}
|
146 |
return apply_filters( 'rwmb_meta', $meta, $key, $args, $post_id );
|
147 |
}
|
60 |
'type' => 'text',
|
61 |
'multiple' => false,
|
62 |
) );
|
|
|
|
|
63 |
|
64 |
// Always set 'multiple' true for following field types
|
65 |
if ( in_array( $args['type'], array( 'checkbox_list', 'file', 'file_advanced', 'image', 'image_advanced', 'plupload_image', 'thickbox_image' ) ) )
|
135 |
'multiple' => false,
|
136 |
'clone' => false,
|
137 |
);
|
138 |
+
$meta = RWMB_Map_Field::the_value( $field, $args, $post_id );
|
139 |
}
|
140 |
+
// Display oembed content
|
141 |
elseif ( 'oembed' == $args['type'] )
|
142 |
{
|
143 |
+
$field = array(
|
144 |
+
'id' => $key,
|
145 |
+
'clone' => isset( $args['clone'] ) ? $args['clone'] : false,
|
146 |
+
'multiple' => isset( $args['multiple'] ) ? $args['multiple'] : false,
|
147 |
+
);
|
148 |
+
$meta = RWMB_OEmbed_Field::the_value( $field, $args, $post_id );
|
149 |
}
|
150 |
return apply_filters( 'rwmb_meta', $meta, $key, $args, $post_id );
|
151 |
}
|
inc/init.php
CHANGED
@@ -37,7 +37,7 @@ add_action( 'edit_page_form', 'rwmb_fix_page_template' );
|
|
37 |
* @return void
|
38 |
* @since 4.3.10
|
39 |
*/
|
40 |
-
function rwmb_fix_page_template( $post )
|
41 |
{
|
42 |
$template = get_post_meta( $post->ID, '_wp_page_template', true );
|
43 |
$page_templates = wp_get_theme()->get_page_templates();
|
37 |
* @return void
|
38 |
* @since 4.3.10
|
39 |
*/
|
40 |
+
function rwmb_fix_page_template( WP_Post $post )
|
41 |
{
|
42 |
$template = get_post_meta( $post->ID, '_wp_page_template', true );
|
43 |
$page_templates = wp_get_theme()->get_page_templates();
|
inc/meta-box.php
CHANGED
@@ -31,11 +31,6 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
|
|
31 |
*/
|
32 |
public $types;
|
33 |
|
34 |
-
/**
|
35 |
-
* @var array Validation information
|
36 |
-
*/
|
37 |
-
public $validation;
|
38 |
-
|
39 |
/**
|
40 |
* @var bool Used to prevent duplicated calls like revisions, manual hook to wp_insert_post, etc.
|
41 |
*/
|
@@ -57,9 +52,8 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
|
|
57 |
return;
|
58 |
|
59 |
// Assign meta box values to local variables and add it's missed values
|
60 |
-
$this->meta_box
|
61 |
-
$this->fields
|
62 |
-
$this->validation = &$this->meta_box['validation'];
|
63 |
|
64 |
// Allow users to show/hide meta box
|
65 |
// 1st action applies to all meta boxes
|
@@ -86,10 +80,10 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
|
|
86 |
// Hide meta box if it's set 'default_hidden'
|
87 |
add_filter( 'default_hidden_meta_boxes', array( $this, 'hide' ), 10, 2 );
|
88 |
|
89 |
-
// Save post meta
|
90 |
-
foreach( $this->meta_box['post_types'] as $post_type )
|
91 |
{
|
92 |
-
if( 'attachment' === $post_type )
|
93 |
{
|
94 |
// Attachment uses other hooks
|
95 |
// @see wp_update_post(), wp_insert_attachment()
|
@@ -100,7 +94,7 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
|
|
100 |
{
|
101 |
add_action( "save_post_{$post_type}", array( $this, 'save_post' ) );
|
102 |
}
|
103 |
-
}
|
104 |
}
|
105 |
|
106 |
/**
|
@@ -110,39 +104,38 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
|
|
110 |
*/
|
111 |
function admin_enqueue_scripts()
|
112 |
{
|
113 |
-
|
114 |
-
|
115 |
-
// Enqueue scripts and styles for registered pages (post types) only
|
116 |
-
if ( 'post' != $screen->base || ! in_array( $screen->post_type, $this->meta_box['post_types'] ) )
|
117 |
return;
|
118 |
|
119 |
wp_enqueue_style( 'rwmb', RWMB_CSS_URL . 'style.css', array(), RWMB_VER );
|
120 |
|
121 |
// Load clone script conditionally
|
122 |
-
$
|
123 |
-
$fields = self::get_fields( $this->fields );
|
124 |
-
|
125 |
foreach ( $fields as $field )
|
126 |
{
|
127 |
if ( $field['clone'] )
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
}
|
133 |
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
if ( $this->validation )
|
138 |
{
|
139 |
-
|
140 |
-
wp_enqueue_script( 'rwmb-validate', RWMB_JS_URL . 'validate.js', array( 'jquery-validate' ), RWMB_VER, true );
|
141 |
}
|
142 |
|
143 |
// Auto save
|
144 |
if ( $this->meta_box['autosave'] )
|
145 |
wp_enqueue_script( 'rwmb-autosave', RWMB_JS_URL . 'autosave.js', array( 'jquery' ), RWMB_VER, true );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
}
|
147 |
|
148 |
/**
|
@@ -199,11 +192,7 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
|
|
199 |
*/
|
200 |
function hide( $hidden, $screen )
|
201 |
{
|
202 |
-
if (
|
203 |
-
'post' === $screen->base
|
204 |
-
&& in_array( $screen->post_type, $this->meta_box['post_types'] )
|
205 |
-
&& $this->meta_box['default_hidden']
|
206 |
-
)
|
207 |
{
|
208 |
$hidden[] = $this->meta_box['id'];
|
209 |
}
|
@@ -218,7 +207,7 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
|
|
218 |
*/
|
219 |
function show()
|
220 |
{
|
221 |
-
|
222 |
|
223 |
$saved = self::has_been_saved( $post->ID, $this->fields );
|
224 |
|
@@ -241,27 +230,6 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
|
|
241 |
call_user_func( array( self::get_class_name( $field ), 'show' ), $field, $saved );
|
242 |
}
|
243 |
|
244 |
-
// Include validation settings for this meta-box
|
245 |
-
if ( isset( $this->validation ) && $this->validation )
|
246 |
-
{
|
247 |
-
echo '
|
248 |
-
<script>
|
249 |
-
if ( typeof rwmb == "undefined" )
|
250 |
-
{
|
251 |
-
var rwmb = {
|
252 |
-
validationOptions : jQuery.parseJSON( \'' , json_encode( $this->validation ) , '\' ),
|
253 |
-
summaryMessage : "' , esc_js( __( 'Please correct the errors highlighted below and try again.', 'meta-box' ) ) , '"
|
254 |
-
};
|
255 |
-
}
|
256 |
-
else
|
257 |
-
{
|
258 |
-
var tempOptions = jQuery.parseJSON( \'' , json_encode( $this->validation ) . '\' );
|
259 |
-
jQuery.extend( true, rwmb.validationOptions, tempOptions );
|
260 |
-
}
|
261 |
-
</script>
|
262 |
-
';
|
263 |
-
}
|
264 |
-
|
265 |
// Allow users to add custom code after meta box content
|
266 |
// 1st action applies to all meta boxes
|
267 |
// 2nd action applies to only current meta box
|
@@ -483,5 +451,21 @@ if ( ! class_exists( 'RW_Meta_Box' ) )
|
|
483 |
|
484 |
return false;
|
485 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
486 |
}
|
487 |
}
|
31 |
*/
|
32 |
public $types;
|
33 |
|
|
|
|
|
|
|
|
|
|
|
34 |
/**
|
35 |
* @var bool Used to prevent duplicated calls like revisions, manual hook to wp_insert_post, etc.
|
36 |
*/
|
52 |
return;
|
53 |
|
54 |
// Assign meta box values to local variables and add it's missed values
|
55 |
+
$this->meta_box = self::normalize( $meta_box );
|
56 |
+
$this->fields = &$this->meta_box['fields'];
|
|
|
57 |
|
58 |
// Allow users to show/hide meta box
|
59 |
// 1st action applies to all meta boxes
|
80 |
// Hide meta box if it's set 'default_hidden'
|
81 |
add_filter( 'default_hidden_meta_boxes', array( $this, 'hide' ), 10, 2 );
|
82 |
|
83 |
+
// Save post meta
|
84 |
+
foreach ( $this->meta_box['post_types'] as $post_type )
|
85 |
{
|
86 |
+
if ( 'attachment' === $post_type )
|
87 |
{
|
88 |
// Attachment uses other hooks
|
89 |
// @see wp_update_post(), wp_insert_attachment()
|
94 |
{
|
95 |
add_action( "save_post_{$post_type}", array( $this, 'save_post' ) );
|
96 |
}
|
97 |
+
}
|
98 |
}
|
99 |
|
100 |
/**
|
104 |
*/
|
105 |
function admin_enqueue_scripts()
|
106 |
{
|
107 |
+
if ( ! $this->is_edit_screen() )
|
|
|
|
|
|
|
108 |
return;
|
109 |
|
110 |
wp_enqueue_style( 'rwmb', RWMB_CSS_URL . 'style.css', array(), RWMB_VER );
|
111 |
|
112 |
// Load clone script conditionally
|
113 |
+
$fields = self::get_fields( $this->fields );
|
|
|
|
|
114 |
foreach ( $fields as $field )
|
115 |
{
|
116 |
if ( $field['clone'] )
|
117 |
+
{
|
118 |
+
wp_enqueue_script( 'rwmb-clone', RWMB_JS_URL . 'clone.js', array( 'jquery' ), RWMB_VER, true );
|
119 |
+
break;
|
120 |
+
}
|
121 |
}
|
122 |
|
123 |
+
// Enqueue scripts and styles for fields
|
124 |
+
foreach ( $fields as $field )
|
|
|
|
|
125 |
{
|
126 |
+
call_user_func( array( self::get_class_name( $field ), 'admin_enqueue_scripts' ) );
|
|
|
127 |
}
|
128 |
|
129 |
// Auto save
|
130 |
if ( $this->meta_box['autosave'] )
|
131 |
wp_enqueue_script( 'rwmb-autosave', RWMB_JS_URL . 'autosave.js', array( 'jquery' ), RWMB_VER, true );
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Allow developers to enqueue more scripts and styles
|
135 |
+
*
|
136 |
+
* @param RW_Meta_Box $object Meta Box object
|
137 |
+
*/
|
138 |
+
do_action( 'rwmb_enqueue_scripts', $this );
|
139 |
}
|
140 |
|
141 |
/**
|
192 |
*/
|
193 |
function hide( $hidden, $screen )
|
194 |
{
|
195 |
+
if ( $this->is_edit_screen( $screen ) && $this->meta_box['default_hidden'] )
|
|
|
|
|
|
|
|
|
196 |
{
|
197 |
$hidden[] = $this->meta_box['id'];
|
198 |
}
|
207 |
*/
|
208 |
function show()
|
209 |
{
|
210 |
+
$post = get_post();
|
211 |
|
212 |
$saved = self::has_been_saved( $post->ID, $this->fields );
|
213 |
|
230 |
call_user_func( array( self::get_class_name( $field ), 'show' ), $field, $saved );
|
231 |
}
|
232 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
// Allow users to add custom code after meta box content
|
234 |
// 1st action applies to all meta boxes
|
235 |
// 2nd action applies to only current meta box
|
451 |
|
452 |
return false;
|
453 |
}
|
454 |
+
|
455 |
+
/**
|
456 |
+
* Check if we're on the right edit screen.
|
457 |
+
*
|
458 |
+
* @param WP_Screen $screen Screen object. Optional. Use current screen object by default.
|
459 |
+
*
|
460 |
+
* @return bool
|
461 |
+
*/
|
462 |
+
function is_edit_screen( $screen = null )
|
463 |
+
{
|
464 |
+
if ( ! ( $screen instanceof WP_Screen ) )
|
465 |
+
{
|
466 |
+
$screen = get_current_screen();
|
467 |
+
}
|
468 |
+
return 'post' == $screen->base && in_array( $screen->post_type, $this->meta_box['post_types'] );
|
469 |
+
}
|
470 |
}
|
471 |
}
|
inc/validation.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Validation module
|
4 |
+
* @package Meta Box
|
5 |
+
*/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Validation class
|
9 |
+
*/
|
10 |
+
class RWMB_Validation
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Add hooks when module is loaded
|
14 |
+
*/
|
15 |
+
public static function load()
|
16 |
+
{
|
17 |
+
add_action( 'rwmb_after', array( __CLASS__, 'rules' ) );
|
18 |
+
add_action( 'rwmb_enqueue_scripts', array( __CLASS__, 'scripts' ) );
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Output validation rules of each meta box
|
23 |
+
* The rules are outputted in [data-rules] attribute of an hidden div and will be converted into JSON by JS
|
24 |
+
* @param RW_Meta_Box $object Meta Box object
|
25 |
+
*/
|
26 |
+
public static function rules( RW_Meta_Box $object )
|
27 |
+
{
|
28 |
+
if ( ! empty( $object->meta_box['validation'] ) )
|
29 |
+
{
|
30 |
+
// Use script tag with type="text/html" to prevent browser to render
|
31 |
+
echo '<script type="text/html" class="rwmb-validation-rules hidden" data-rules="' . esc_attr( json_encode( $object->meta_box['validation'] ) ) . '"></script>';
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Enqueue scripts for validation
|
37 |
+
*/
|
38 |
+
public static function scripts()
|
39 |
+
{
|
40 |
+
wp_enqueue_script( 'jquery-validate', RWMB_JS_URL . 'jquery.validate.min.js', array( 'jquery' ), RWMB_VER, true );
|
41 |
+
wp_enqueue_script( 'rwmb-validate', RWMB_JS_URL . 'validate.js', array( 'jquery-validate' ), RWMB_VER, true );
|
42 |
+
wp_localize_script( 'rwmb-validate', 'rwmbValidate', array(
|
43 |
+
'summaryMessage' => __( 'Please correct the errors highlighted below and try again.', 'meta-box' ),
|
44 |
+
) );
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
RWMB_Validation::load();
|
js/clone.js
CHANGED
@@ -92,12 +92,9 @@ jQuery( function ( $ )
|
|
92 |
*/
|
93 |
function clone( $container )
|
94 |
{
|
95 |
-
var $
|
96 |
-
$clone = $
|
97 |
-
$input;
|
98 |
-
|
99 |
-
$clone.insertAfter( $clone_last );
|
100 |
-
$input = $clone.find( ':input[class|="rwmb"]' );
|
101 |
|
102 |
$input.each( function ()
|
103 |
{
|
@@ -105,7 +102,7 @@ jQuery( function ( $ )
|
|
105 |
if ( $field.attr( 'type' ) === 'radio' || $field.attr( 'type' ) === 'checkbox' )
|
106 |
{
|
107 |
// Reset 'checked' attribute
|
108 |
-
$field.
|
109 |
}
|
110 |
else
|
111 |
{
|
@@ -114,6 +111,7 @@ jQuery( function ( $ )
|
|
114 |
}
|
115 |
} );
|
116 |
|
|
|
117 |
cloneIndex.reset( $container );
|
118 |
|
119 |
// Toggle remove buttons
|
@@ -284,7 +282,7 @@ jQuery( function ( $ )
|
|
284 |
return;
|
285 |
}
|
286 |
|
287 |
-
$this.parent().remove();
|
288 |
cloneIndex.reset( $container );
|
289 |
toggleRemoveButtons( $container );
|
290 |
toggleAddButton( $container )
|
@@ -300,6 +298,12 @@ jQuery( function ( $ )
|
|
300 |
$container.sortable( {
|
301 |
handle : '.rwmb-clone-icon',
|
302 |
placeholder: ' rwmb-clone rwmb-clone-placeholder',
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
update : function ()
|
304 |
{
|
305 |
cloneIndex.reset( $container );
|
92 |
*/
|
93 |
function clone( $container )
|
94 |
{
|
95 |
+
var $last = $container.children( '.rwmb-clone:last' ),
|
96 |
+
$clone = $last.clone(),
|
97 |
+
$input = $clone.find( ':input[class|="rwmb"]' );
|
|
|
|
|
|
|
98 |
|
99 |
$input.each( function ()
|
100 |
{
|
102 |
if ( $field.attr( 'type' ) === 'radio' || $field.attr( 'type' ) === 'checkbox' )
|
103 |
{
|
104 |
// Reset 'checked' attribute
|
105 |
+
$field.prop( 'checked', false );
|
106 |
}
|
107 |
else
|
108 |
{
|
111 |
}
|
112 |
} );
|
113 |
|
114 |
+
$clone.insertAfter( $last );
|
115 |
cloneIndex.reset( $container );
|
116 |
|
117 |
// Toggle remove buttons
|
282 |
return;
|
283 |
}
|
284 |
|
285 |
+
$this.parent().trigger( 'remove' ).remove();
|
286 |
cloneIndex.reset( $container );
|
287 |
toggleRemoveButtons( $container );
|
288 |
toggleAddButton( $container )
|
298 |
$container.sortable( {
|
299 |
handle : '.rwmb-clone-icon',
|
300 |
placeholder: ' rwmb-clone rwmb-clone-placeholder',
|
301 |
+
items : '.rwmb-clone',
|
302 |
+
start : function ( event, ui )
|
303 |
+
{
|
304 |
+
// Make the placeholder has the same height as dragged item
|
305 |
+
ui.placeholder.height( ui.item.height() );
|
306 |
+
},
|
307 |
update : function ()
|
308 |
{
|
309 |
cloneIndex.reset( $container );
|
js/color.js
CHANGED
@@ -2,11 +2,20 @@ jQuery( function ( $ )
|
|
2 |
{
|
3 |
'use strict';
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
6 |
{
|
7 |
var $this = $( this ),
|
8 |
-
$
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
// Make sure the value is displayed
|
12 |
if ( !$this.val() )
|
@@ -14,31 +23,10 @@ jQuery( function ( $ )
|
|
14 |
$this.val( '#' );
|
15 |
}
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
if ( $clone_container.length > 0 )
|
20 |
-
{
|
21 |
-
$this.appendTo( $clone_container ).siblings( 'div.wp-picker-container' ).remove();
|
22 |
-
}
|
23 |
-
$this.wpColorPicker();
|
24 |
-
}
|
25 |
-
else
|
26 |
-
{
|
27 |
-
//We use farbtastic if the WordPress color picker widget doesn't exist
|
28 |
-
$color_picker.farbtastic( $this );
|
29 |
-
}
|
30 |
}
|
31 |
|
32 |
-
$( ':input.rwmb-color' ).each(
|
33 |
-
$( '.rwmb-input' )
|
34 |
-
.on( 'clone', ':input.rwmb-color', rwmb_update_color_picker )
|
35 |
-
.on( 'focus', '.rwmb-color', function ()
|
36 |
-
{
|
37 |
-
$( this ).siblings( '.rwmb-color-picker' ).show();
|
38 |
-
return false;
|
39 |
-
} ).on( 'blur', '.rwmb-color', function ()
|
40 |
-
{
|
41 |
-
$( this ).siblings( '.rwmb-color-picker' ).hide();
|
42 |
-
return false;
|
43 |
-
} );
|
44 |
} );
|
2 |
{
|
3 |
'use strict';
|
4 |
|
5 |
+
/**
|
6 |
+
* Show color pickers
|
7 |
+
* @return void
|
8 |
+
*/
|
9 |
+
function initColorPicker()
|
10 |
{
|
11 |
var $this = $( this ),
|
12 |
+
$container = $this.closest( '.rwmb-color-clone' );
|
13 |
+
|
14 |
+
// Clone doesn't have input for color picker, we have to add the input and remove the color picker container
|
15 |
+
if ( $container.length > 0 )
|
16 |
+
{
|
17 |
+
$this.appendTo( $container ).siblings( '.wp-picker-container' ).remove();
|
18 |
+
}
|
19 |
|
20 |
// Make sure the value is displayed
|
21 |
if ( !$this.val() )
|
23 |
$this.val( '#' );
|
24 |
}
|
25 |
|
26 |
+
// Show color picker
|
27 |
+
$this.wpColorPicker();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
|
30 |
+
$( ':input.rwmb-color' ).each( initColorPicker );
|
31 |
+
$( '.rwmb-input' ).on( 'clone', 'input.rwmb-color', initColorPicker );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
} );
|
js/date.js
CHANGED
@@ -6,7 +6,7 @@ jQuery( function ( $ )
|
|
6 |
* Update date picker element
|
7 |
* Used for static & dynamic added elements (when clone)
|
8 |
*/
|
9 |
-
function
|
10 |
{
|
11 |
var $this = $( this ),
|
12 |
options = $this.data( 'options' );
|
@@ -15,6 +15,6 @@ jQuery( function ( $ )
|
|
15 |
$this.removeClass( 'hasDatepicker' ).attr( 'id', '' ).datepicker( options );
|
16 |
}
|
17 |
|
18 |
-
$( ':input.rwmb-date' ).each(
|
19 |
-
$( '.rwmb-input' ).on( 'clone', ':input.rwmb-date',
|
20 |
} );
|
6 |
* Update date picker element
|
7 |
* Used for static & dynamic added elements (when clone)
|
8 |
*/
|
9 |
+
function update()
|
10 |
{
|
11 |
var $this = $( this ),
|
12 |
options = $this.data( 'options' );
|
15 |
$this.removeClass( 'hasDatepicker' ).attr( 'id', '' ).datepicker( options );
|
16 |
}
|
17 |
|
18 |
+
$( ':input.rwmb-date' ).each( update );
|
19 |
+
$( '.rwmb-input' ).on( 'clone', ':input.rwmb-date', update );
|
20 |
} );
|
js/file-advanced.js
DELETED
@@ -1,91 +0,0 @@
|
|
1 |
-
jQuery( function ( $ )
|
2 |
-
{
|
3 |
-
'use strict';
|
4 |
-
|
5 |
-
var template = $( '#tmpl-rwmb-file-advanced' ).html();
|
6 |
-
|
7 |
-
$( 'body' ).on( 'click', '.rwmb-file-advanced-upload', function ( e )
|
8 |
-
{
|
9 |
-
e.preventDefault();
|
10 |
-
|
11 |
-
var $uploadButton = $( this ),
|
12 |
-
$fileList = $uploadButton.siblings( '.rwmb-uploaded' ),
|
13 |
-
maxFileUploads = $fileList.data( 'max_file_uploads' ),
|
14 |
-
mimeType = $fileList.data( 'mime_type' ),
|
15 |
-
msg = maxFileUploads > 1 ? rwmbFile.maxFileUploadsPlural : rwmbFile.maxFileUploadsSingle,
|
16 |
-
frame,
|
17 |
-
frameOptions = {
|
18 |
-
className: 'media-frame rwmb-file-frame',
|
19 |
-
multiple : true,
|
20 |
-
title : rwmbFileAdvanced.frameTitle
|
21 |
-
};
|
22 |
-
|
23 |
-
msg = msg.replace( '%d', maxFileUploads );
|
24 |
-
|
25 |
-
// Create a media frame
|
26 |
-
if ( mimeType )
|
27 |
-
{
|
28 |
-
frameOptions.library = {
|
29 |
-
type: mimeType
|
30 |
-
};
|
31 |
-
}
|
32 |
-
frame = wp.media( frameOptions );
|
33 |
-
|
34 |
-
// Open media uploader
|
35 |
-
frame.open();
|
36 |
-
|
37 |
-
// Remove all attached 'select' event
|
38 |
-
frame.off( 'select' );
|
39 |
-
|
40 |
-
// Handle selection
|
41 |
-
frame.on( 'select', function ()
|
42 |
-
{
|
43 |
-
// Get selections
|
44 |
-
var selection = frame.state().get( 'selection' ).toJSON(),
|
45 |
-
uploaded = $fileList.children().length,
|
46 |
-
ids;
|
47 |
-
|
48 |
-
if ( maxFileUploads > 0 && ( uploaded + selection.length ) > maxFileUploads )
|
49 |
-
{
|
50 |
-
if ( uploaded < maxFileUploads )
|
51 |
-
{
|
52 |
-
selection = selection.slice( 0, maxFileUploads - uploaded );
|
53 |
-
}
|
54 |
-
alert( msg );
|
55 |
-
}
|
56 |
-
|
57 |
-
// Get only files that haven't been added to the list
|
58 |
-
// Also prevent duplication when send ajax request
|
59 |
-
selection = _.filter( selection, function ( attachment )
|
60 |
-
{
|
61 |
-
return $fileList.children( 'li#item_' + attachment.id ).length === 0;
|
62 |
-
} );
|
63 |
-
ids = _.pluck( selection, 'id' );
|
64 |
-
|
65 |
-
if ( ids.length > 0 )
|
66 |
-
{
|
67 |
-
// Attach attachment to field and get HTML
|
68 |
-
var data = {
|
69 |
-
action : 'rwmb_attach_file',
|
70 |
-
post_id : $( '#post_ID' ).val(),
|
71 |
-
field_id : $fileList.data( 'field_id' ),
|
72 |
-
attachment_ids: ids,
|
73 |
-
_ajax_nonce : $uploadButton.data( 'attach_file_nonce' )
|
74 |
-
};
|
75 |
-
$.post( ajaxurl, data, function ( r )
|
76 |
-
{
|
77 |
-
if ( r.success )
|
78 |
-
{
|
79 |
-
$fileList
|
80 |
-
.append( _.template( template, { attachments: selection }, {
|
81 |
-
evaluate : /<#([\s\S]+?)#>/g,
|
82 |
-
interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
|
83 |
-
escape : /\{\{([^\}]+?)\}\}(?!\})/g
|
84 |
-
} ) )
|
85 |
-
.trigger( 'update.rwmbFile' );
|
86 |
-
}
|
87 |
-
}, 'json' );
|
88 |
-
}
|
89 |
-
} );
|
90 |
-
} );
|
91 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/image-advanced.js
DELETED
@@ -1,90 +0,0 @@
|
|
1 |
-
jQuery( function ( $ )
|
2 |
-
{
|
3 |
-
'use strict';
|
4 |
-
|
5 |
-
// Use only one frame for all upload fields
|
6 |
-
var frame,
|
7 |
-
template = $( '#tmpl-rwmb-image-advanced' ).html();
|
8 |
-
|
9 |
-
$( 'body' ).on( 'click', '.rwmb-image-advanced-upload', function ( e )
|
10 |
-
{
|
11 |
-
e.preventDefault();
|
12 |
-
|
13 |
-
var $uploadButton = $( this ),
|
14 |
-
$imageList = $uploadButton.siblings( '.rwmb-images' ),
|
15 |
-
maxFileUploads = $imageList.data( 'max_file_uploads' ),
|
16 |
-
msg = maxFileUploads > 1 ? rwmbFile.maxFileUploadsPlural : rwmbFile.maxFileUploadsSingle;
|
17 |
-
|
18 |
-
msg = msg.replace( '%d', maxFileUploads );
|
19 |
-
|
20 |
-
// Create a frame only if needed
|
21 |
-
if ( !frame )
|
22 |
-
{
|
23 |
-
frame = wp.media( {
|
24 |
-
className: 'media-frame rwmb-media-frame',
|
25 |
-
multiple : true,
|
26 |
-
title : rwmbImageAdvanced.frameTitle,
|
27 |
-
library : {
|
28 |
-
type: 'image'
|
29 |
-
}
|
30 |
-
} );
|
31 |
-
}
|
32 |
-
|
33 |
-
// Open media uploader
|
34 |
-
frame.open();
|
35 |
-
|
36 |
-
// Remove all attached 'select' event
|
37 |
-
frame.off( 'select' );
|
38 |
-
|
39 |
-
// Handle selection
|
40 |
-
frame.on( 'select', function ()
|
41 |
-
{
|
42 |
-
// Get selections
|
43 |
-
var selection = frame.state().get( 'selection' ).toJSON(),
|
44 |
-
uploaded = $imageList.children().length,
|
45 |
-
ids;
|
46 |
-
|
47 |
-
if ( maxFileUploads > 0 && ( uploaded + selection.length ) > maxFileUploads )
|
48 |
-
{
|
49 |
-
if ( uploaded < maxFileUploads )
|
50 |
-
{
|
51 |
-
selection = selection.slice( 0, maxFileUploads - uploaded );
|
52 |
-
}
|
53 |
-
alert( msg );
|
54 |
-
}
|
55 |
-
|
56 |
-
// Get only files that haven't been added to the list
|
57 |
-
// Also prevent duplication when send ajax request
|
58 |
-
selection = _.filter( selection, function ( attachment )
|
59 |
-
{
|
60 |
-
return $imageList.children( 'li#item_' + attachment.id ).length === 0;
|
61 |
-
} );
|
62 |
-
ids = _.pluck( selection, 'id' );
|
63 |
-
|
64 |
-
if ( ids.length > 0 )
|
65 |
-
{
|
66 |
-
var data = {
|
67 |
-
action : 'rwmb_attach_media',
|
68 |
-
post_id : $( '#post_ID' ).val(),
|
69 |
-
field_id : $imageList.data( 'field_id' ),
|
70 |
-
attachment_ids: ids,
|
71 |
-
_ajax_nonce : $uploadButton.data( 'attach_media_nonce' )
|
72 |
-
};
|
73 |
-
|
74 |
-
$.post( ajaxurl, data, function ( r )
|
75 |
-
{
|
76 |
-
if ( r.success )
|
77 |
-
{
|
78 |
-
$imageList
|
79 |
-
.append( _.template( template, { attachments: selection }, {
|
80 |
-
evaluate : /<#([\s\S]+?)#>/g,
|
81 |
-
interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
|
82 |
-
escape : /\{\{([^\}]+?)\}\}(?!\})/g
|
83 |
-
} ) )
|
84 |
-
.trigger( 'update.rwmbFile' );
|
85 |
-
}
|
86 |
-
}, 'json' );
|
87 |
-
}
|
88 |
-
} );
|
89 |
-
} );
|
90 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/map.js
CHANGED
@@ -122,7 +122,6 @@
|
|
122 |
$( '#' + this.addressField ).autocomplete( {
|
123 |
source: function ( request, response )
|
124 |
{
|
125 |
-
// TODO: add 'region' option, to help bias geocoder.
|
126 |
that.geocoder.geocode( {
|
127 |
'address': request.term
|
128 |
}, function ( results )
|
122 |
$( '#' + this.addressField ).autocomplete( {
|
123 |
source: function ( request, response )
|
124 |
{
|
|
|
125 |
that.geocoder.geocode( {
|
126 |
'address': request.term
|
127 |
}, function ( results )
|
js/media.js
ADDED
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
window.rwmb = window.rwmb || {};
|
2 |
+
|
3 |
+
jQuery( function ( $ )
|
4 |
+
{
|
5 |
+
'use strict';
|
6 |
+
|
7 |
+
var views = rwmb.views = rwmb.views || {},
|
8 |
+
MediaField,MediaList, MediaItem, ImageField, ImageList, ImageItem, MediaButton, MediaStatus, UploadButton;
|
9 |
+
|
10 |
+
MediaList = views.MediaList = Backbone.View.extend( {
|
11 |
+
tagName: 'ul',
|
12 |
+
className: 'rwmb-media-list',
|
13 |
+
createItemView: function( options ){
|
14 |
+
return new MediaItem( options );
|
15 |
+
},
|
16 |
+
|
17 |
+
addItemView: function( item ){
|
18 |
+
this.itemViews[item.cid] = this.createItemView( { model: item, collection: this.collection, props: this.props } );
|
19 |
+
this.$el.append( this.itemViews[item.cid].el );
|
20 |
+
},
|
21 |
+
|
22 |
+
render: function(){
|
23 |
+
this.$el.empty();
|
24 |
+
this.collection.each( this.addItemView );
|
25 |
+
},
|
26 |
+
|
27 |
+
initialize: function( options ) {
|
28 |
+
var that = this;
|
29 |
+
this.itemViews = {};
|
30 |
+
this.props = options.props;
|
31 |
+
|
32 |
+
this.listenTo( this.collection, 'add', this.addItemView );
|
33 |
+
|
34 |
+
this.listenTo( this.collection, 'remove', function( item, collection ) {
|
35 |
+
if ( this.itemViews[item.cid] )
|
36 |
+
{
|
37 |
+
this.itemViews[item.cid].remove();
|
38 |
+
delete this.itemViews[item.cid];
|
39 |
+
}
|
40 |
+
} );
|
41 |
+
|
42 |
+
//Sort media using sortable
|
43 |
+
this.$el.sortable( {
|
44 |
+
stop : function ( event, ui )
|
45 |
+
{
|
46 |
+
that.$el.children().each( function ()
|
47 |
+
{
|
48 |
+
var cid = $( this ).data( 'cid' );
|
49 |
+
|
50 |
+
if ( cid )
|
51 |
+
{
|
52 |
+
var model = that.collection.get( cid );
|
53 |
+
if ( model )
|
54 |
+
{
|
55 |
+
that.collection.remove( model );
|
56 |
+
that.collection.add( model );
|
57 |
+
}
|
58 |
+
}
|
59 |
+
} );
|
60 |
+
},
|
61 |
+
delay: 150
|
62 |
+
} );
|
63 |
+
|
64 |
+
this.render();
|
65 |
+
}
|
66 |
+
} );
|
67 |
+
|
68 |
+
ImageList = views.ImageList = MediaList.extend( {
|
69 |
+
createItemView: function( options ){
|
70 |
+
return new ImageItem( options );
|
71 |
+
},
|
72 |
+
} );
|
73 |
+
|
74 |
+
MediaField = views.MediaField = Backbone.View.extend( {
|
75 |
+
events : {
|
76 |
+
'destroy' : function(){
|
77 |
+
if( this.forceDelete ) {
|
78 |
+
_.each( _.clone( this.collection.models ), function( model ) {
|
79 |
+
model.destroy();
|
80 |
+
});
|
81 |
+
}
|
82 |
+
}
|
83 |
+
},
|
84 |
+
|
85 |
+
initialize: function ( options )
|
86 |
+
{
|
87 |
+
var that = this;
|
88 |
+
this.input = $( options.input );
|
89 |
+
this.values = this.input.val().split( ',' );
|
90 |
+
this.props = this.$el.data();
|
91 |
+
|
92 |
+
//Create collection
|
93 |
+
this.collection = new wp.media.model.Attachments();
|
94 |
+
|
95 |
+
//Render
|
96 |
+
this.render();
|
97 |
+
|
98 |
+
//Update input
|
99 |
+
this.listenTo( this.collection, 'add remove reset', _.debounce( function ()
|
100 |
+
{
|
101 |
+
var ids = this.collection.pluck( 'id' );
|
102 |
+
this.input.val( ids.join( ',' ) );
|
103 |
+
}, 500 ) );
|
104 |
+
|
105 |
+
//Limit max files
|
106 |
+
this.listenTo( this.collection, 'add', function( item, collection )
|
107 |
+
{
|
108 |
+
if ( this.props.maxFiles > 0 && this.collection.length > this.props.maxFiles )
|
109 |
+
{
|
110 |
+
this.collection.pop();
|
111 |
+
}
|
112 |
+
} );
|
113 |
+
|
114 |
+
//Load initial media
|
115 |
+
if ( !_.isEmpty( this.values ) )
|
116 |
+
{
|
117 |
+
this.collection.props.set( {
|
118 |
+
query : true,
|
119 |
+
include: this.values,
|
120 |
+
orderby: 'post__in',
|
121 |
+
order : 'ASC',
|
122 |
+
type : this.props.mimeType,
|
123 |
+
perPage: this.props.maxFiles || -1
|
124 |
+
} );
|
125 |
+
this.collection.more();
|
126 |
+
}
|
127 |
+
},
|
128 |
+
|
129 |
+
render: function() {
|
130 |
+
//Empty then add parts
|
131 |
+
this.$el.empty();
|
132 |
+
this.$el.append( new MediaList( { collection: this.collection, props: this.props } ).el );
|
133 |
+
this.$el.append( new MediaButton( { collection: this.collection, props: this.props } ).el );
|
134 |
+
this.$el.append( new MediaStatus( { collection: this.collection, props: this.props } ).el );
|
135 |
+
}
|
136 |
+
} );
|
137 |
+
|
138 |
+
ImageField = views.ImageField = MediaField.extend( {
|
139 |
+
render: function() {
|
140 |
+
this.$el.empty();
|
141 |
+
this.$el.append( new ImageList( { collection: this.collection, props: this.props } ).el );
|
142 |
+
this.$el.append( new MediaButton( { collection: this.collection, props: this.props } ).el );
|
143 |
+
this.$el.append( new MediaStatus( { collection: this.collection, props: this.props } ).el );
|
144 |
+
}
|
145 |
+
} );
|
146 |
+
|
147 |
+
MediaStatus = views.MediaStatus = Backbone.View.extend( {
|
148 |
+
tagName: 'span',
|
149 |
+
className: 'rwmb-media-status',
|
150 |
+
template: wp.template( 'rwmb-media-status' ),
|
151 |
+
initialize: function( options )
|
152 |
+
{
|
153 |
+
this.props = options.props;
|
154 |
+
this.listenTo( this.collection, 'add remove reset', this.render );
|
155 |
+
this.render();
|
156 |
+
},
|
157 |
+
|
158 |
+
render: function(){
|
159 |
+
var data = {
|
160 |
+
items: this.collection.length,
|
161 |
+
maxFiles: this.props.maxFiles
|
162 |
+
};
|
163 |
+
this.$el.html( this.template( data ) );
|
164 |
+
}
|
165 |
+
} );
|
166 |
+
|
167 |
+
MediaButton = views.MediaButton = Backbone.View.extend( {
|
168 |
+
className: 'rwmb-add-media button',
|
169 |
+
tagName: 'a',
|
170 |
+
template: wp.template( 'rwmb-add-media' ),
|
171 |
+
events:
|
172 |
+
{
|
173 |
+
'click': function(){
|
174 |
+
var ids = this.collection.pluck( 'id' );
|
175 |
+
// Destroy the previous collection frame.
|
176 |
+
if ( this._frame )
|
177 |
+
{
|
178 |
+
this.stopListening( this._frame );
|
179 |
+
this._frame.dispose();
|
180 |
+
}
|
181 |
+
|
182 |
+
this._frame = wp.media( {
|
183 |
+
className: 'media-frame rwmb-media-frame',
|
184 |
+
multiple : true,
|
185 |
+
title : 'Select Media',
|
186 |
+
library : {
|
187 |
+
type : this.props.mimeType,
|
188 |
+
exclude: ids
|
189 |
+
}
|
190 |
+
} );
|
191 |
+
|
192 |
+
this.listenTo( this._frame, 'select', function ()
|
193 |
+
{
|
194 |
+
var selection = this._frame.state().get( 'selection' );
|
195 |
+
selection.each( function ( item )
|
196 |
+
{
|
197 |
+
this.collection.add( item );
|
198 |
+
}, this );
|
199 |
+
} );
|
200 |
+
|
201 |
+
this._frame.open();
|
202 |
+
},
|
203 |
+
},
|
204 |
+
render: function()
|
205 |
+
{
|
206 |
+
this.$el.html( this.template( {} ) );
|
207 |
+
return this;
|
208 |
+
},
|
209 |
+
|
210 |
+
initialize: function( options )
|
211 |
+
{
|
212 |
+
this.props = options.props;
|
213 |
+
this.listenTo( this.collection, 'add remove reset', function(){
|
214 |
+
if ( this.props.maxFiles > 0 && this.collection.length >= this.props.maxFiles )
|
215 |
+
{
|
216 |
+
this.$el.hide();
|
217 |
+
}
|
218 |
+
else
|
219 |
+
{
|
220 |
+
this.$el.show();
|
221 |
+
}
|
222 |
+
} );
|
223 |
+
|
224 |
+
this.render();
|
225 |
+
}
|
226 |
+
} );
|
227 |
+
|
228 |
+
UploadButton = views.UploadButton = Backbone.View.extend( {
|
229 |
+
initialize: function( options )
|
230 |
+
{
|
231 |
+
this.props = options.props;
|
232 |
+
this.listenTo( this.collection, 'add remove reset', function(){
|
233 |
+
if ( this.props.maxFiles > 0 && this.collection.length >= this.props.maxFiles )
|
234 |
+
{
|
235 |
+
this.$el.hide();
|
236 |
+
}
|
237 |
+
else
|
238 |
+
{
|
239 |
+
this.$el.show();
|
240 |
+
}
|
241 |
+
} );
|
242 |
+
}
|
243 |
+
} );
|
244 |
+
|
245 |
+
MediaItem = views.MediaItem = Backbone.View.extend( {
|
246 |
+
tagName : 'li',
|
247 |
+
className: 'rwmb-media-item',
|
248 |
+
template : wp.template( 'rwmb-media-item' ),
|
249 |
+
initialize: function ( options )
|
250 |
+
{
|
251 |
+
this.props = options.props;
|
252 |
+
this.render();
|
253 |
+
this.$el.data( 'cid', this.model.cid );
|
254 |
+
this.listenTo( this.model, 'destroy', function( model ) {
|
255 |
+
this.collection.remove( this.model );
|
256 |
+
} );
|
257 |
+
},
|
258 |
+
|
259 |
+
events: {
|
260 |
+
'click .rwmb-remove-media': function ( e )
|
261 |
+
{
|
262 |
+
this.collection.remove( this.model );
|
263 |
+
if( this.props.forceDelete ) {
|
264 |
+
this.model.destroy();
|
265 |
+
}
|
266 |
+
|
267 |
+
return false;
|
268 |
+
}
|
269 |
+
},
|
270 |
+
|
271 |
+
render: function ()
|
272 |
+
{
|
273 |
+
var attrs = _.clone( this.model.attributes );
|
274 |
+
this.$el.html( this.template( attrs ) );
|
275 |
+
return this;
|
276 |
+
}
|
277 |
+
} );
|
278 |
+
|
279 |
+
ImageItem = views.ImageItem = MediaItem.extend( {
|
280 |
+
className: 'rwmb-image-item',
|
281 |
+
template : wp.template( 'rwmb-image-item' ),
|
282 |
+
} );
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Initialize media fields
|
286 |
+
* @return void
|
287 |
+
*/
|
288 |
+
function initMediaField()
|
289 |
+
{
|
290 |
+
new MediaField( { input: this, el: $( this ).siblings( 'div.rwmb-media-view' )} );
|
291 |
+
}
|
292 |
+
|
293 |
+
function initImageField()
|
294 |
+
{
|
295 |
+
new ImageField( { input: this, el: $( this ).siblings( 'div.rwmb-media-view' )} );
|
296 |
+
}
|
297 |
+
|
298 |
+
$( ':input.rwmb-media' ).each( initMediaField );
|
299 |
+
$( '.rwmb-input' ).on( 'clone', ':input.rwmb-media', initMediaField );
|
300 |
+
$( '.rwmb-input' ).on( 'remove', '.rwmb-media-clone', function(){
|
301 |
+
$( this ).find( 'div.rwmb-media-view' ).trigger( 'destroy' );
|
302 |
+
} );
|
303 |
+
|
304 |
+
$( ':input.rwmb-image-advanced' ).each( initImageField );
|
305 |
+
$( '.rwmb-input' ).on( 'clone', ':input.rwmb-image-advanced', initImageField );
|
306 |
+
$( '.rwmb-input' ).on( 'remove', '.rwmb-image_advanced-clone', function(){
|
307 |
+
$( this ).find( 'div.rwmb-media-view' ).trigger( 'destroy' );
|
308 |
+
} );
|
309 |
+
} );
|
js/validate.js
CHANGED
@@ -2,25 +2,34 @@ jQuery( function ( $ )
|
|
2 |
{
|
3 |
'use strict';
|
4 |
|
5 |
-
var $form = $( '#post' )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
//
|
8 |
-
|
9 |
{
|
10 |
-
|
|
|
|
|
|
|
|
|
11 |
{
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
14 |
} );
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
// Re-enable the submit ( publish/update ) button and hide the ajax indicator
|
19 |
-
$( '#publish' ).removeClass( 'button-primary-disabled' );
|
20 |
-
$( '#ajax-loading' ).attr( 'style', '' );
|
21 |
-
$form.siblings( '#message' ).remove();
|
22 |
-
$form.before( '<div id="message" class="error"><p>' + rwmb.summaryMessage + '</p></div>' );
|
23 |
-
};
|
24 |
-
|
25 |
-
$form.validate( rwmb.validationOptions );
|
26 |
} );
|
2 |
{
|
3 |
'use strict';
|
4 |
|
5 |
+
var $form = $( '#post' ),
|
6 |
+
rules = {
|
7 |
+
invalidHandler: function ()
|
8 |
+
{
|
9 |
+
// Re-enable the submit ( publish/update ) button and hide the ajax indicator
|
10 |
+
$( '#publish' ).removeClass( 'button-primary-disabled' );
|
11 |
+
$( '#ajax-loading' ).attr( 'style', '' );
|
12 |
+
$form.siblings( '#message' ).remove();
|
13 |
+
$form.before( '<div id="message" class="error"><p>' + rwmbValidate.summaryMessage + '</p></div>' );
|
14 |
+
}
|
15 |
+
};
|
16 |
|
17 |
+
// Gather all validation rules
|
18 |
+
$( '.rwmb-validation-rules' ).each( function ()
|
19 |
{
|
20 |
+
var subRules = $( this ).data( 'rules' );
|
21 |
+
jQuery.extend( true, rules, subRules );
|
22 |
+
|
23 |
+
// Required field styling
|
24 |
+
$.each( subRules, function ( k, v )
|
25 |
{
|
26 |
+
if ( v['required'] )
|
27 |
+
{
|
28 |
+
$( '#' + k ).parent().siblings( '.rwmb-label' ).addClass( 'required' ).append( '<span>*</span>' );
|
29 |
+
}
|
30 |
+
} );
|
31 |
} );
|
32 |
|
33 |
+
// Execute
|
34 |
+
$form.validate( rules );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
} );
|
lang/{ar.mo → meta-box-ar.mo}
RENAMED
File without changes
|
lang/{de_DE.mo → meta-box-de_DE.mo}
RENAMED
File without changes
|
lang/{es_ES.mo → meta-box-es_ES.mo}
RENAMED
File without changes
|
lang/{fa_IR.mo → meta-box-fa_IR.mo}
RENAMED
File without changes
|
lang/{fr_FR.mo → meta-box-fr_FR.mo}
RENAMED
File without changes
|
lang/{it_IT.mo → meta-box-it_IT.mo}
RENAMED
File without changes
|
lang/{nb_NO.mo → meta-box-nb_NO.mo}
RENAMED
File without changes
|
lang/{nl.mo → meta-box-nl_NL.mo}
RENAMED
File without changes
|
lang/{pl_PL.mo → meta-box-pl_PL.mo}
RENAMED
File without changes
|
lang/{pt_BR.mo → meta-box-pt_BR.mo}
RENAMED
File without changes
|
lang/{sv_SE.mo → meta-box-sv_SE.mo}
RENAMED
File without changes
|
lang/{tr_TR.mo → meta-box-tr_TR.mo}
RENAMED
File without changes
|
lang/{zh_CN.mo → meta-box-zh_CN.mo}
RENAMED
File without changes
|
lang/vi.mo
DELETED
Binary file
|
meta-box.php
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
Plugin Name: Meta Box
|
4 |
-
Plugin URI:
|
5 |
-
Description: Create meta
|
6 |
-
Version: 4.
|
7 |
-
Author: Rilwis
|
8 |
-
Author URI: http://www.deluxeblogtips.com
|
9 |
-
License: GPL2+
|
10 |
-
Text Domain: meta-box
|
11 |
-
Domain Path: /lang/
|
12 |
-
*/
|
13 |
|
14 |
// Prevent loading this file directly
|
15 |
defined( 'ABSPATH' ) || exit;
|
16 |
|
17 |
// Script version, used to add version for scripts and styles
|
18 |
-
define( 'RWMB_VER', '4.
|
19 |
|
20 |
// Define plugin URLs, for fast enqueuing scripts and styles
|
21 |
if ( ! defined( 'RWMB_URL' ) )
|
@@ -43,6 +43,9 @@ foreach ( glob( RWMB_FIELDS_DIR . '*.php' ) as $file )
|
|
43 |
// Meta box class
|
44 |
require_once RWMB_INC_DIR . 'meta-box.php';
|
45 |
|
|
|
|
|
|
|
46 |
// Helper function to retrieve meta value
|
47 |
require_once RWMB_INC_DIR . 'helpers.php';
|
48 |
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Meta Box
|
4 |
+
* Plugin URI: https://metabox.io
|
5 |
+
* Description: Create custom meta boxes and custom fields for any post type in WordPress.
|
6 |
+
* Version: 4.6
|
7 |
+
* Author: Rilwis
|
8 |
+
* Author URI: http://www.deluxeblogtips.com
|
9 |
+
* License: GPL2+
|
10 |
+
* Text Domain: meta-box
|
11 |
+
* Domain Path: /lang/
|
12 |
+
*/
|
13 |
|
14 |
// Prevent loading this file directly
|
15 |
defined( 'ABSPATH' ) || exit;
|
16 |
|
17 |
// Script version, used to add version for scripts and styles
|
18 |
+
define( 'RWMB_VER', '4.6' );
|
19 |
|
20 |
// Define plugin URLs, for fast enqueuing scripts and styles
|
21 |
if ( ! defined( 'RWMB_URL' ) )
|
43 |
// Meta box class
|
44 |
require_once RWMB_INC_DIR . 'meta-box.php';
|
45 |
|
46 |
+
// Validation module
|
47 |
+
require_once RWMB_INC_DIR . 'validation.php';
|
48 |
+
|
49 |
// Helper function to retrieve meta value
|
50 |
require_once RWMB_INC_DIR . 'helpers.php';
|
51 |
|
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, 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: 3.5
|
6 |
Tested up to: 4.3.1
|
7 |
-
Stable tag: 4.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Meta Box plugin is a powerful, professional solution to create custom meta boxes and custom fields for WordPress websites.
|
@@ -75,6 +75,18 @@ To getting started with the plugin API, please read [this tutorial](https://meta
|
|
75 |
|
76 |
== Changelog ==
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
= 4.5.7 =
|
79 |
* Fix: Always set std as value for hidden field
|
80 |
* Fix: `rwmb_meta` now can display rich content from `oembed` field
|
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: 3.5
|
6 |
Tested up to: 4.3.1
|
7 |
+
Stable tag: 4.6
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Meta Box plugin is a powerful, professional solution to create custom meta boxes and custom fields for WordPress websites.
|
75 |
|
76 |
== Changelog ==
|
77 |
|
78 |
+
= 4.6 =
|
79 |
+
|
80 |
+
* Improvement: the plugin translation is now handled in translate.wordpress.org. While the plugin keeps old translation as backward compatibility, it's recommended to translate everything in translate.wordpress.org. Language packs will be automatically updated by WordPress.
|
81 |
+
* Improvement: rewrite code for `file_advanced` and `image_advanced`, which share the same code base. These fields are now clonable and not autosave (you have to save post to save files)! Props @funkatronic.
|
82 |
+
* Improvement: restyle clone icon, sort clone icon and add clone button for better UI. The new UI now is compatible with `color` and `date` fields
|
83 |
+
* Improvement: separate validation module into 1 class, for better code structure
|
84 |
+
* Improvement: add `pattern` attribute for `url` field
|
85 |
+
* Improvement: improve code quality
|
86 |
+
* Fix: missing "checked" when clone radio
|
87 |
+
* Fix: language file name for Dutch
|
88 |
+
* Fix: oembed not render preview if provider is added via `wp_embed_register_handler`
|
89 |
+
|
90 |
= 4.5.7 =
|
91 |
* Fix: Always set std as value for hidden field
|
92 |
* Fix: `rwmb_meta` now can display rich content from `oembed` field
|