Meta Box - Version 4.12.6

Version Description

Download this release

Release Info

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

Code changes from version 4.12.5 to 4.12.6

css/image-advanced.css DELETED
@@ -1,45 +0,0 @@
1
- .rwmb-image-item .rwmb-media-preview {
2
- width: auto;
3
- float: none;
4
- }
5
-
6
- /* Image */
7
- .rwmb-image-item.thumbnail {
8
- width: 150px;
9
- }
10
- .rwmb-image-item.medium {
11
- width: 300px;
12
- }
13
- .rwmb-image-item.large {
14
- width: 1024px;
15
- }
16
-
17
- .rwmb-media-bar {
18
- position: absolute;
19
- z-index: 10;
20
- right: 12px;
21
- top: 12px;
22
- color: #fff;
23
- opacity: 0;
24
- transition: opacity .2s;
25
- }
26
- .rwmb-media-bar a {
27
- text-decoration: none;
28
- color: inherit;
29
- }
30
- .rwmb-overlay {
31
- position: absolute;
32
- top: 8px;
33
- bottom: 8px;
34
- left: 8px;
35
- right: 8px;
36
- background: #000;
37
- opacity: 0;
38
- transition: opacity .2s;
39
- }
40
- .rwmb-image-item:hover .rwmb-media-bar {
41
- opacity: 1;
42
- }
43
- .rwmb-image-item:hover .rwmb-overlay {
44
- opacity: .6;
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
css/image.css CHANGED
@@ -1,63 +1,66 @@
1
- /* Uploaded image */
2
- .rwmb-image-wrapper .rwmb-uploaded {
 
 
 
 
3
  overflow: hidden;
4
  }
5
- .rwmb-image-wrapper .rwmb-uploaded li {
6
- margin: 0 10px 10px 0;
 
7
  float: left;
8
- width: 150px;
9
- height: 150px;
 
 
 
10
  text-align: center;
11
- cursor: move;
12
- position: relative;
13
- transition: width .25s, opacity .25s;
 
 
 
14
  }
15
- .rwmb-image-wrapper .rwmb-uploaded img {
16
  width: 150px;
17
- height: 150px;
18
  }
19
- .rwmb-image-bar {
20
- color: #fff;
21
- font-weight: bold;
22
- background: #000;
23
- background: rgba(0, 0, 0, .5);
24
- position: absolute;
25
- top: 0;
26
- right: 0;
27
- padding: 5px;
28
- display: none;
29
- text-align: center;
30
  }
31
- li:hover .rwmb-image-bar {
32
- display: block;
33
  }
34
- .rwmb-image-bar a {
 
 
 
 
 
 
 
35
  color: #fff;
36
- font-weight: bold;
37
- text-decoration: none;
38
- vertical-align: middle;
39
  }
40
- .rwmb-image-bar a.rwmb-file-delete {
41
- font-size: 23px;
42
- width: 18px;
43
- font-weight: normal;
44
  }
45
- .rwmb-image-wrapper .rwmb-uploaded li.removed {
46
- width: 0;
47
- margin: 0;
 
 
 
 
 
48
  opacity: 0;
 
49
  }
50
- .rwmb-image-wrapper .rwmb-uploaded li.removed:after {
51
- content: ' ';
52
- position: absolute;
53
- top: 0;
54
- left: 0;
55
- right: 0;
56
- bottom: 0;
57
- z-index: 2;
58
- opacity: .4;
59
- background-color: #f00;
60
  }
61
- .rwmb-image-wrapper .rwmb-uploaded li.ui-state-highlight {
62
- background: #ddd;
63
  }
1
+ .rwmb-image-wrapper .rwmb-uploaded:empty {
2
+ display: none;
3
+ }
4
+ .rwmb-uploaded:not(:empty) {
5
+ display: block;
6
+ margin: -8px 0 0 -8px;
7
  overflow: hidden;
8
  }
9
+ /* Re-add WP core UI style to make sure frontend works */
10
+ .rwmb-image-item {
11
+ position: relative;
12
  float: left;
13
+ padding: 8px;
14
+ margin: 0;
15
+ color: #444;
16
+ cursor: pointer;
17
+ list-style: none;
18
  text-align: center;
19
+ -webkit-user-select: none;
20
+ -moz-user-select: none;
21
+ -ms-user-select: none;
22
+ user-select: none;
23
+ width: 25%;
24
+ box-sizing: border-box;
25
  }
26
+ .rwmb-image-item.thumbnail {
27
  width: 150px;
 
28
  }
29
+ .rwmb-image-item.medium {
30
+ width: 300px;
 
 
 
 
 
 
 
 
 
31
  }
32
+ .rwmb-image-item.large {
33
+ width: 1024px;
34
  }
35
+
36
+ .rwmb-image-actions {
37
+ position: absolute;
38
+ z-index: 2;
39
+ right: 12px;
40
+ top: 12px;
41
+ opacity: 0;
42
+ transition: opacity .2s;
43
  color: #fff;
 
 
 
44
  }
45
+ .rwmb-image-edit,
46
+ .rwmb-image-delete {
47
+ color: inherit;
48
+ text-decoration: none;
49
  }
50
+ .rwmb-image-overlay {
51
+ position: absolute;
52
+ z-index: 1;
53
+ top: 8px;
54
+ bottom: 8px;
55
+ left: 8px;
56
+ right: 8px;
57
+ background: #000;
58
  opacity: 0;
59
+ transition: opacity .2s;
60
  }
61
+ .rwmb-image-item:hover .rwmb-image-actions {
62
+ opacity: 1;
 
 
 
 
 
 
 
 
63
  }
64
+ .rwmb-image-item:hover .rwmb-image-overlay {
65
+ opacity: .6;
66
  }
css/style.css CHANGED
@@ -26,8 +26,8 @@
26
  .rwmb-label > label {
27
  font-weight: 600;
28
  }
29
- .rwmb-label.required > span {
30
- color: #c00;
31
  font-weight: bold;
32
  margin-left: 3px;
33
  }
@@ -95,15 +95,15 @@
95
  }
96
 
97
  /* jQuery validation */
98
- label.error {
99
- padding-left: 3px;
100
- color: red;
101
- }
102
- input.error,
103
- textarea.error,
104
- select.error {
105
- border-color: #c00 !important;
106
- background: #ffebe8 !important;
107
  }
108
 
109
  /* Utilities
26
  .rwmb-label > label {
27
  font-weight: 600;
28
  }
29
+ .rwmb-required {
30
+ color: #dc3232;
31
  font-weight: bold;
32
  margin-left: 3px;
33
  }
95
  }
96
 
97
  /* jQuery validation */
98
+ p.rwmb-error {
99
+ color: #dc3232;
100
+ margin: 2px 0 5px;
101
+ }
102
+ input.rwmb-error.rwmb-error,
103
+ textarea.rwmb-error,
104
+ select.rwmb-error {
105
+ border-color: #dc3232;
106
+ background: #ffebe8;
107
  }
108
 
109
  /* Utilities
inc/about/about.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Add about page for the Meta Box plugin.
4
+ *
5
+ * @package Meta Box
6
+ */
7
+
8
+ /**
9
+ * About page class.
10
+ */
11
+ class RWMB_About {
12
+ /**
13
+ * Plugin data.
14
+ *
15
+ * @var array
16
+ */
17
+ protected $plugin;
18
+
19
+ /**
20
+ * Init hooks.
21
+ */
22
+ public function init() {
23
+ if ( ! function_exists( 'get_plugin_data' ) ) {
24
+ include ABSPATH . 'wp-admin/includes/plugin.php';
25
+ }
26
+ $this->plugin = get_plugin_data( RWMB_DIR . 'meta-box.php' );
27
+
28
+ // Add links to about page in the plugin action links.
29
+ add_filter( 'plugin_action_links_meta-box/meta-box.php', array( $this, 'plugin_links' ) );
30
+
31
+ // Add a hidden about page.
32
+ add_action( 'admin_menu', array( $this, 'register_page' ) );
33
+ add_action( 'admin_head', array( $this, 'hide_page' ) );
34
+
35
+ // Enqueue scripts and styles for about page.
36
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
37
+
38
+ // Redirect to about page after activation.
39
+ add_action( 'activated_plugin', array( $this, 'redirect' ), 10, 2 );
40
+ }
41
+
42
+ /**
43
+ * Add links to About page.
44
+ *
45
+ * @param array $links Array of plugin links.
46
+ *
47
+ * @return array
48
+ */
49
+ public function plugin_links( $links ) {
50
+ $links[] = '<a href="' . esc_url( admin_url( 'index.php?page=meta-box-about' ) ) . '">' . esc_html__( 'About', 'meta-box' ) . '</a>';
51
+ return $links;
52
+ }
53
+
54
+ /**
55
+ * Register admin page.
56
+ */
57
+ public function register_page() {
58
+ add_dashboard_page(
59
+ __( 'Welcome to Meta Box', 'meta-box' ),
60
+ __( 'Welcome to Meta Box', 'meta-box' ),
61
+ 'activate_plugins',
62
+ 'meta-box-about',
63
+ array( $this, 'render' )
64
+ );
65
+ }
66
+
67
+ /**
68
+ * Hide about page from the admin menu.
69
+ */
70
+ public function hide_page() {
71
+ remove_submenu_page( 'index.php', 'meta-box-about' );
72
+ }
73
+
74
+ /**
75
+ * Render admin page.
76
+ */
77
+ public function render() {
78
+ ?>
79
+ <div class="wrap about-wrap">
80
+ <?php include dirname( __FILE__ ) . '/sections/welcome.php'; ?>
81
+ <?php include dirname( __FILE__ ) . '/sections/tabs.php'; ?>
82
+ <?php include dirname( __FILE__ ) . '/sections/getting-started.php'; ?>
83
+ </div>
84
+ <?php
85
+ }
86
+
87
+ /**
88
+ * Enqueue CSS and JS.
89
+ */
90
+ public function enqueue() {
91
+ $screen = get_current_screen();
92
+ if ( 'dashboard_page_meta-box-about' !== $screen->id ) {
93
+ return;
94
+ }
95
+ wp_enqueue_style( 'meta-box-about', RWMB_URL . 'inc/about/css/style.css' );
96
+ wp_enqueue_script( 'meta-box-about', RWMB_URL . 'inc/about/js/script.js', array( 'jquery' ), '', true );
97
+ }
98
+
99
+ /**
100
+ * Redirect to about page after Meta Box has been activated.
101
+ *
102
+ * @param string $plugin Path to the main plugin file from plugins directory.
103
+ * @param bool $network_wide Whether to enable the plugin for all sites in the network
104
+ * or just the current site. Multisite only. Default is false.
105
+ */
106
+ public function redirect( $plugin, $network_wide ) {
107
+ if ( ! $network_wide && 'meta-box/meta-box.php' === $plugin && ! $this->is_bundled() ) {
108
+ wp_safe_redirect( admin_url( 'index.php?page=meta-box-about' ) );
109
+ die;
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Check if Meta Box is bundled by TGM Activation Class.
115
+ */
116
+ protected function is_bundled() {
117
+ // @codingStandardsIgnoreLine
118
+ foreach ( $_REQUEST as $key => $value ) {
119
+ if ( false !== strpos( $key, 'tgmpa' ) || false !== strpos( $value, 'tgmpa' ) ) {
120
+ return true;
121
+ }
122
+ }
123
+ return false;
124
+ }
125
+ }
inc/about/css/style.css ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .about-wrap .wp-badge {
2
+ background-image: url(../images/meta-box.png);
3
+ background-color: #fff;
4
+ color: #222;
5
+ text-transform: uppercase;
6
+ font-weight: bold;
7
+ text-decoration: none;
8
+ }
9
+
10
+ .wp-badge:hover {
11
+ text-decoration: none;
12
+ }
13
+
14
+ .feature-section.two-col {
15
+ align-items: flex-start;
16
+ }
17
+
18
+ .feature-section.two-col h3:not(:first-child) {
19
+ margin-top: 3em;
20
+ }
21
+
22
+ .feature-section img {
23
+ display: block;
24
+ box-shadow: 0 0 20px rgba(0, 0, 0, .1);
25
+ }
26
+
27
+ .nav-tab-active:focus {
28
+ box-shadow: none;
29
+ }
30
+
31
+ .gt-tab-pane {
32
+ display: none;
33
+ }
34
+
35
+ .gt-is-active {
36
+ display: block;
37
+ }
38
+
39
+ .screenshot {
40
+ display: block;
41
+ margin: 3em auto;
42
+ }
43
+ .col ul {
44
+ font-size: 14px;
45
+ margin: 2em 0;
46
+ }
47
+
48
+ .col li a {
49
+ text-decoration: none;
50
+ }
51
+
52
+ .col .dashicons {
53
+ color: #82878c;
54
+ padding-right: 5px;
55
+ font-size: 16px;
56
+ vertical-align: middle;
57
+ }
inc/about/images/meta-box.png ADDED
Binary file
inc/about/images/online-generator.png ADDED
Binary file
inc/about/js/script.js ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ( function ( $ ) {
2
+ 'use strict';
3
+
4
+ function tabs() {
5
+ var $container = $( '.nav-tab-wrapper' ),
6
+ $tabs = $container.find( '.nav-tab' ),
7
+ $panes = $( '.gt-tab-pane' );
8
+
9
+ $container.on( 'click', '.nav-tab', function ( e ) {
10
+ e.preventDefault();
11
+
12
+ $tabs.removeClass( 'nav-tab-active' );
13
+ $( this ).addClass( 'nav-tab-active' );
14
+
15
+ $panes.removeClass( 'gt-is-active' );
16
+ $panes.filter( $( this ).attr( 'href' ) ).addClass( 'gt-is-active' );
17
+ } );
18
+ }
19
+
20
+ // Auto activate tabs when DOM ready.
21
+ $( tabs );
22
+ } ( jQuery ) );
inc/about/sections/getting-started.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Getting started section.
4
+ *
5
+ * @package Meta Box
6
+ * @subpackage MB Custom Post Type
7
+ */
8
+
9
+ ?>
10
+ <div id="getting-started" class="gt-tab-pane gt-is-active">
11
+ <div class="feature-section two-col">
12
+ <div class="col">
13
+ <h3><?php esc_html_e( 'Getting Started With Online Generator', 'meta-box' ); ?></h3>
14
+ <p><?php esc_html_e( 'The fastest way to getting started with Meta Box is use our online generator to generate meta boxes with custom fields. It provides a friendly UI for you to create meta boxes and custom fields just by drag and drop fields.', 'meta-box' ); ?><p>
15
+
16
+ <a class="screenshot" href="https://metabox.io/online-generator/?utm_source=plugin_about_page&utm_medium=link_generator&utm_campaign=meta_box_about_page" target="_blank"><img src="<?php echo esc_url( RWMB_URL . 'inc/about/images/online-generator.png' ); ?>" alt="<?php esc_attr_e( 'online generator', 'meta-box' ); ?>"></a>
17
+
18
+ <p><a href="<?php echo esc_url( 'https://metabox.io/online-generator/?utm_source=plugin_about_page&utm_medium=button_generator&utm_campaign=meta_box_about_page' ); ?>" class="button button-primary"><?php esc_html_e( 'Go to Online Generator', 'meta-box' ); ?></a></p>
19
+ </div>
20
+
21
+ <div class="col">
22
+ <h3><?php esc_html_e( 'Understand The Basics', 'meta-box' ); ?></h3>
23
+ <p><?php esc_html_e( 'Meta Box doesn\'t have any admin page for configuration or settings. Instead of that, it provides a very powerful API to speed up the process of creating meta boxes and custom fields. It might take you a little time at first, but then you\'ll love the way it work because it helps you do and customize almost everything.', 'meta-box' ); ?><p>
24
+ <p><a href="<?php echo esc_url( 'https://docs.metabox.io/quick-start/?utm_source=plugin_about_page&utm_medium=button_docs&utm_campaign=meta_box_about_page' ); ?>" class="button button-primary"><?php esc_html_e( 'Learn More', 'meta-box' ); ?></a></p>
25
+
26
+ <h3><?php esc_html_e( 'Extensions', 'meta-box' ); ?></h3>
27
+ <p><?php esc_html_e( 'Wanna more features that transform your WordPress website into a powerful CMS? Check out some extensions below:', 'meta-box' ); ?><p>
28
+ <ul>
29
+ <li><a target="_blank" href="https://metabox.io/plugins/meta-box-group/?utm_source=plugin_about_page&utm_medium=link_group&utm_campaign=meta_box_about_page"><span class="dashicons dashicons-welcome-widgets-menus"></span> <?php esc_html_e( 'Meta Box Group', 'meta-box' ); ?></a></li>
30
+ <li><a target="_blank" href="https://metabox.io/plugins/meta-box-conditional-logic/?utm_source=plugin_about_page&utm_medium=link_conditional&utm_campaign=meta_box_about_page"><span class="dashicons dashicons-yes"></span> <?php esc_html_e( 'Meta Box Conditional Logic', 'meta-box' ); ?></a></li>
31
+ <li><a target="_blank" href="https://metabox.io/plugins/mb-settings-page/?utm_source=plugin_about_page&utm_medium=link_settings&utm_campaign=meta_box_about_page"><span class="dashicons dashicons-admin-generic"></span> <?php esc_html_e( 'MB Settings Page', 'meta-box' ); ?></a></li>
32
+ <li><a target="_blank" href="https://metabox.io/plugins/mb-term-meta/?utm_source=plugin_about_page&utm_medium=link_term&utm_campaign=meta_box_about_page"><span class="dashicons dashicons-image-filter"></span> <?php esc_html_e( 'MB Term Meta', 'meta-box' ); ?></a></li>
33
+ </ul>
34
+ <p><a target="_blank" class="button button-primary" href="https://metabox.io/plugins/?utm_source=plugin_about_page&utm_medium=button_extensions&utm_campaign=meta_box_about_page"><?php esc_html_e( 'More Extensions', 'meta-box' ); ?></a>
35
+ </div>
36
+ </div>
37
+ <hr>
38
+ <div class="return-to-dashboard">
39
+ <a href="https://metabox.io/plugins/?utm_source=plugin_about_page&utm_medium=link_home&utm_campaign=meta_box_about_page"><?php esc_html_e( 'Go to MetaBox.IO &rarr;', 'meta-box' ); ?></a>
40
+ </div>
41
+ </div>
inc/about/sections/tabs.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Tabs navigation.
4
+ *
5
+ * @package Meta Box
6
+ * @subpackage MB Custom Post Type
7
+ */
8
+
9
+ ?>
10
+ <h2 class="nav-tab-wrapper">
11
+ <a href="#getting-started" class="nav-tab nav-tab-active"><?php esc_html_e( 'Getting Started', 'meta-box' ); ?></a>
12
+ </h2>
inc/about/sections/welcome.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Welcome section.
4
+ *
5
+ * @package Meta Box
6
+ * @subpackage MB Custom Post Type
7
+ */
8
+
9
+ ?>
10
+ <h1>
11
+ <?php
12
+ // Translators: %1$s - Plugin name, %2$s - Plugin version.
13
+ echo esc_html( sprintf( __( 'Welcome to %1$s %2$s', 'meta-box' ), $this->plugin['Name'], $this->plugin['Version'] ) );
14
+ ?>
15
+ </h1>
16
+ <div class="about-text"><?php esc_html_e( 'This plugin is a lightweight and powerful toolkit that helps you to create custom meta boxes and custom fields in WordPress fast and easy. Follow the instruction below to get started.', 'meta-box' ); ?></div>
17
+ <a target="_blank" href="<?php echo esc_url( 'https://metabox.io/?utm_source=plugin_about_page&utm_medium=badge_link&utm_campaign=meta_box_about' ); ?>" class="wp-badge"><?php echo esc_html( $this->plugin['Name'] ); ?></a>
inc/autoloader.php CHANGED
@@ -92,6 +92,7 @@ class RWMB_Autoloader {
92
  'sanitizer',
93
  'media-modal',
94
  'wpml',
 
95
 
96
  // Walkers.
97
  'walkers/walker',
92
  'sanitizer',
93
  'media-modal',
94
  'wpml',
95
+ 'about/about.php',
96
 
97
  // Walkers.
98
  'walkers/walker',
inc/core.php CHANGED
@@ -32,7 +32,7 @@ class RWMB_Core {
32
  * @return array
33
  */
34
  public function plugin_links( $links ) {
35
- $links[] = '<a href="https://metabox.io/docs/">' . esc_html__( 'Documentation', 'meta-box' ) . '</a>';
36
  $links[] = '<a href="https://metabox.io/plugins/">' . esc_html__( 'Extensions', 'meta-box' ) . '</a>';
37
  return $links;
38
  }
32
  * @return array
33
  */
34
  public function plugin_links( $links ) {
35
+ $links[] = '<a href="https://docs.metabox.io">' . esc_html__( 'Documentation', 'meta-box' ) . '</a>';
36
  $links[] = '<a href="https://metabox.io/plugins/">' . esc_html__( 'Extensions', 'meta-box' ) . '</a>';
37
  return $links;
38
  }
inc/field.php CHANGED
@@ -481,23 +481,26 @@ abstract class RWMB_Field {
481
  return '';
482
  }
483
 
484
- return self::call( 'format_value', $field, $value );
485
  }
486
 
487
  /**
488
  * Format value for the helper functions.
489
  *
490
- * @param array $field Field parameters.
491
- * @param string|array $value The field meta value.
 
 
 
492
  * @return string
493
  */
494
- public static function format_value( $field, $value ) {
495
  if ( ! is_array( $value ) ) {
496
- return self::call( 'format_single_value', $field, $value );
497
  }
498
  $output = '<ul>';
499
  foreach ( $value as $subvalue ) {
500
- $output .= '<li>' . self::call( 'format_value', $field, $subvalue ) . '</li>';
501
  }
502
  $output .= '</ul>';
503
  return $output;
@@ -506,11 +509,14 @@ abstract class RWMB_Field {
506
  /**
507
  * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
508
  *
509
- * @param array $field Field parameters.
510
- * @param string $value The value.
 
 
 
511
  * @return string
512
  */
513
- public static function format_single_value( $field, $value ) {
514
  return $value;
515
  }
516
 
481
  return '';
482
  }
483
 
484
+ return self::call( 'format_value', $field, $value, $args, $post_id );
485
  }
486
 
487
  /**
488
  * Format value for the helper functions.
489
  *
490
+ * @param array $field Field parameters.
491
+ * @param string|array $value The field meta value.
492
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
493
+ * @param int|null $post_id Post ID. null for current post. Optional.
494
+ *
495
  * @return string
496
  */
497
+ public static function format_value( $field, $value, $args, $post_id ) {
498
  if ( ! is_array( $value ) ) {
499
+ return self::call( 'format_single_value', $field, $value, $args, $post_id );
500
  }
501
  $output = '<ul>';
502
  foreach ( $value as $subvalue ) {
503
+ $output .= '<li>' . self::call( 'format_value', $field, $subvalue, $args, $post_id ) . '</li>';
504
  }
505
  $output .= '</ul>';
506
  return $output;
509
  /**
510
  * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
511
  *
512
+ * @param array $field Field parameters.
513
+ * @param string $value The value.
514
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
515
+ * @param int|null $post_id Post ID. null for current post. Optional.
516
+ *
517
  * @return string
518
  */
519
+ public static function format_single_value( $field, $value, $args, $post_id ) {
520
  return $value;
521
  }
522
 
inc/fields/checkbox.php CHANGED
@@ -40,13 +40,16 @@ class RWMB_Checkbox_Field extends RWMB_Input_Field {
40
  }
41
 
42
  /**
43
- * Format a single value for the helper functions.
 
 
 
 
 
44
  *
45
- * @param array $field Field parameters.
46
- * @param string $value The value.
47
  * @return string
48
  */
49
- public static function format_single_value( $field, $value ) {
50
  return $value ? __( 'Yes', 'meta-box' ) : __( 'No', 'meta-box' );
51
  }
52
  }
40
  }
41
 
42
  /**
43
+ * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
44
+ *
45
+ * @param array $field Field parameters.
46
+ * @param string $value The value.
47
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
48
+ * @param int|null $post_id Post ID. null for current post. Optional.
49
  *
 
 
50
  * @return string
51
  */
52
+ public static function format_single_value( $field, $value, $args, $post_id ) {
53
  return $value ? __( 'Yes', 'meta-box' ) : __( 'No', 'meta-box' );
54
  }
55
  }
inc/fields/choice.php CHANGED
@@ -106,13 +106,16 @@ abstract class RWMB_Choice_Field extends RWMB_Field {
106
  }
107
 
108
  /**
109
- * Format a single value for the helper functions.
 
 
 
 
 
110
  *
111
- * @param array $field Field parameters.
112
- * @param string $value Meta value.
113
  * @return string
114
  */
115
- public static function format_single_value( $field, $value ) {
116
  return self::call( 'get_option_label', $field, $value );
117
  }
118
 
106
  }
107
 
108
  /**
109
+ * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
110
+ *
111
+ * @param array $field Field parameters.
112
+ * @param string $value The value.
113
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
114
+ * @param int|null $post_id Post ID. null for current post. Optional.
115
  *
 
 
116
  * @return string
117
  */
118
+ public static function format_single_value( $field, $value, $args, $post_id ) {
119
  return self::call( 'get_option_label', $field, $value );
120
  }
121
 
inc/fields/color.php CHANGED
@@ -69,13 +69,16 @@ class RWMB_Color_Field extends RWMB_Text_Field {
69
  }
70
 
71
  /**
72
- * Format a single value for the helper functions.
 
 
 
 
 
73
  *
74
- * @param array $field Field parameters.
75
- * @param string $value The value.
76
  * @return string
77
  */
78
- public static function format_single_value( $field, $value ) {
79
  return sprintf( "<span style='display:inline-block;width:20px;height:20px;border-radius:50%%;background:%s;'></span>", $value );
80
  }
81
  }
69
  }
70
 
71
  /**
72
+ * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
73
+ *
74
+ * @param array $field Field parameters.
75
+ * @param string $value The value.
76
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
77
+ * @param int|null $post_id Post ID. null for current post. Optional.
78
  *
 
 
79
  * @return string
80
  */
81
+ public static function format_single_value( $field, $value, $args, $post_id ) {
82
  return sprintf( "<span style='display:inline-block;width:20px;height:20px;border-radius:50%%;background:%s;'></span>", $value );
83
  }
84
  }
inc/fields/datetime.php CHANGED
@@ -240,4 +240,24 @@ class RWMB_Datetime_Field extends RWMB_Text_Field {
240
  . $field['js_options']['separator']
241
  . strtr( $field['js_options']['timeFormat'], self::$time_formats );
242
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
  }
240
  . $field['js_options']['separator']
241
  . strtr( $field['js_options']['timeFormat'], self::$time_formats );
242
  }
243
+
244
+ /**
245
+ * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
246
+ *
247
+ * @param array $field Field parameters.
248
+ * @param string $value The value.
249
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
250
+ * @param int|null $post_id Post ID. null for current post. Optional.
251
+ *
252
+ * @return string
253
+ */
254
+ public static function format_single_value( $field, $value, $args, $post_id ) {
255
+ if ( ! isset( $args['format'] ) ) {
256
+ return $value;
257
+ }
258
+ if ( ! $field['timestamp'] ) {
259
+ $value = strtotime( $value );
260
+ }
261
+ return date( $args['format'], $value );
262
+ }
263
  }
inc/fields/fieldset-text.php CHANGED
@@ -70,11 +70,14 @@ class RWMB_Fieldset_Text_Field extends RWMB_Text_Field {
70
  /**
71
  * Format value for the helper functions.
72
  *
73
- * @param array $field Field parameters.
74
- * @param string|array $value Meta value.
 
 
 
75
  * @return string
76
  */
77
- public static function format_value( $field, $value ) {
78
  $output = '<table><thead><tr>';
79
  foreach ( $field['options'] as $label ) {
80
  $output .= "<th>$label</th>";
@@ -93,13 +96,16 @@ class RWMB_Fieldset_Text_Field extends RWMB_Text_Field {
93
  }
94
 
95
  /**
96
- * Format a single value for the helper functions.
 
 
 
 
 
97
  *
98
- * @param array $field Field parameters.
99
- * @param array $value The value.
100
  * @return string
101
  */
102
- public static function format_single_value( $field, $value ) {
103
  $output = '<tr>';
104
  foreach ( $value as $subvalue ) {
105
  $output .= "<td>$subvalue</td>";
70
  /**
71
  * Format value for the helper functions.
72
  *
73
+ * @param array $field Field parameters.
74
+ * @param string|array $value The field meta value.
75
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
76
+ * @param int|null $post_id Post ID. null for current post. Optional.
77
+ *
78
  * @return string
79
  */
80
+ public static function format_value( $field, $value, $args, $post_id ) {
81
  $output = '<table><thead><tr>';
82
  foreach ( $field['options'] as $label ) {
83
  $output .= "<th>$label</th>";
96
  }
97
 
98
  /**
99
+ * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
100
+ *
101
+ * @param array $field Field parameters.
102
+ * @param string $value The value.
103
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
104
+ * @param int|null $post_id Post ID. null for current post. Optional.
105
  *
 
 
106
  * @return string
107
  */
108
+ public static function format_single_value( $field, $value, $args, $post_id ) {
109
  $output = '<tr>';
110
  foreach ( $value as $subvalue ) {
111
  $output .= "<td>$subvalue</td>";
inc/fields/file.php CHANGED
@@ -178,7 +178,6 @@ class RWMB_File_Field extends RWMB_Field {
178
  return $new;
179
  }
180
 
181
-
182
  // Cloneable field.
183
  $counts = self::transform_cloneable( $input );
184
  foreach ( $counts as $clone_index => $count ) {
@@ -341,30 +340,36 @@ class RWMB_File_Field extends RWMB_Field {
341
  /**
342
  * Format value for the helper functions.
343
  *
344
- * @param array $field Field parameters.
345
- * @param string|array $value The field meta value.
 
 
 
346
  * @return string
347
  */
348
- public static function format_value( $field, $value ) {
349
  if ( ! $field['clone'] ) {
350
- return self::call( 'format_single_value', $field, $value );
351
  }
352
  $output = '<ul>';
353
  foreach ( $value as $subvalue ) {
354
- $output .= '<li>' . self::call( 'format_single_value', $field, $subvalue ) . '</li>';
355
  }
356
  $output .= '</ul>';
357
  return $output;
358
  }
359
 
360
  /**
361
- * Format a single value for the helper functions.
 
 
 
 
 
362
  *
363
- * @param array $field Field parameters.
364
- * @param array $value The value.
365
  * @return string
366
  */
367
- public static function format_single_value( $field, $value ) {
368
  $output = '<ul>';
369
  foreach ( $value as $file ) {
370
  $output .= sprintf( '<li><a href="%s" target="_blank">%s</a></li>', $file['url'], $file['title'] );
178
  return $new;
179
  }
180
 
 
181
  // Cloneable field.
182
  $counts = self::transform_cloneable( $input );
183
  foreach ( $counts as $clone_index => $count ) {
340
  /**
341
  * Format value for the helper functions.
342
  *
343
+ * @param array $field Field parameters.
344
+ * @param string|array $value The field meta value.
345
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
346
+ * @param int|null $post_id Post ID. null for current post. Optional.
347
+ *
348
  * @return string
349
  */
350
+ public static function format_value( $field, $value, $args, $post_id ) {
351
  if ( ! $field['clone'] ) {
352
+ return self::call( 'format_single_value', $field, $value, $args, $post_id );
353
  }
354
  $output = '<ul>';
355
  foreach ( $value as $subvalue ) {
356
+ $output .= '<li>' . self::call( 'format_single_value', $field, $subvalue, $args, $post_id ) . '</li>';
357
  }
358
  $output .= '</ul>';
359
  return $output;
360
  }
361
 
362
  /**
363
+ * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
364
+ *
365
+ * @param array $field Field parameters.
366
+ * @param array $value The value.
367
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
368
+ * @param int|null $post_id Post ID. null for current post. Optional.
369
  *
 
 
370
  * @return string
371
  */
372
+ public static function format_single_value( $field, $value, $args, $post_id ) {
373
  $output = '<ul>';
374
  foreach ( $value as $file ) {
375
  $output .= sprintf( '<li><a href="%s" target="_blank">%s</a></li>', $file['url'], $file['title'] );
inc/fields/image-advanced.php CHANGED
@@ -14,7 +14,7 @@ class RWMB_Image_Advanced_Field extends RWMB_Media_Field {
14
  */
15
  public static function admin_enqueue_scripts() {
16
  parent::admin_enqueue_scripts();
17
- wp_enqueue_style( 'rwmb-image-advanced', RWMB_CSS_URL . 'image-advanced.css', array( 'rwmb-media' ), RWMB_VER );
18
  wp_enqueue_script( 'rwmb-image-advanced', RWMB_JS_URL . 'image-advanced.js', array( 'rwmb-media' ), RWMB_VER, true );
19
  }
20
 
@@ -66,23 +66,29 @@ class RWMB_Image_Advanced_Field extends RWMB_Media_Field {
66
  /**
67
  * Format value for the helper functions.
68
  *
69
- * @param array $field Field parameters.
70
- * @param string|array $value The field meta value.
 
 
 
71
  * @return string
72
  */
73
- public static function format_value( $field, $value ) {
74
- return RWMB_Image_Field::format_value( $field, $value );
75
  }
76
 
77
  /**
78
- * Format a single value for the helper functions.
 
 
 
 
 
79
  *
80
- * @param array $field Field parameters.
81
- * @param array $value The value.
82
  * @return string
83
  */
84
- public static function format_single_value( $field, $value ) {
85
- return RWMB_Image_Field::format_single_value( $field, $value );
86
  }
87
 
88
  /**
14
  */
15
  public static function admin_enqueue_scripts() {
16
  parent::admin_enqueue_scripts();
17
+ RWMB_Image_Field::admin_enqueue_scripts();
18
  wp_enqueue_script( 'rwmb-image-advanced', RWMB_JS_URL . 'image-advanced.js', array( 'rwmb-media' ), RWMB_VER, true );
19
  }
20
 
66
  /**
67
  * Format value for the helper functions.
68
  *
69
+ * @param array $field Field parameters.
70
+ * @param string|array $value The field meta value.
71
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
72
+ * @param int|null $post_id Post ID. null for current post. Optional.
73
+ *
74
  * @return string
75
  */
76
+ public static function format_value( $field, $value, $args, $post_id ) {
77
+ return RWMB_Image_Field::format_value( $field, $value, $args, $post_id );
78
  }
79
 
80
  /**
81
+ * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
82
+ *
83
+ * @param array $field Field parameters.
84
+ * @param string $value The value.
85
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
86
+ * @param int|null $post_id Post ID. null for current post. Optional.
87
  *
 
 
88
  * @return string
89
  */
90
+ public static function format_single_value( $field, $value, $args, $post_id ) {
91
+ return RWMB_Image_Field::format_single_value( $field, $value, $args, $post_id );
92
  }
93
 
94
  /**
inc/fields/image-select.php CHANGED
@@ -57,13 +57,16 @@ class RWMB_Image_Select_Field extends RWMB_Field {
57
  }
58
 
59
  /**
60
- * Format a single value for the helper functions.
 
 
 
 
 
61
  *
62
- * @param array $field Field parameters.
63
- * @param string $value The meta value.
64
  * @return string
65
  */
66
- public static function format_single_value( $field, $value ) {
67
  return sprintf( '<img src="%s">', esc_url( $field['options'][ $value ] ) );
68
  }
69
  }
57
  }
58
 
59
  /**
60
+ * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
61
+ *
62
+ * @param array $field Field parameters.
63
+ * @param string $value The value.
64
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
65
+ * @param int|null $post_id Post ID. null for current post. Optional.
66
  *
 
 
67
  * @return string
68
  */
69
+ public static function format_single_value( $field, $value, $args, $post_id ) {
70
  return sprintf( '<img src="%s">', esc_url( $field['options'][ $value ] ) );
71
  }
72
  }
inc/fields/image.php CHANGED
@@ -14,6 +14,7 @@ class RWMB_Image_Field extends RWMB_File_Field {
14
  */
15
  public static function admin_enqueue_scripts() {
16
  parent::admin_enqueue_scripts();
 
17
  wp_enqueue_style( 'rwmb-image', RWMB_CSS_URL . 'image.css', array(), RWMB_VER );
18
  }
19
 
@@ -26,30 +27,42 @@ class RWMB_Image_Field extends RWMB_File_Field {
26
  * @return string
27
  */
28
  protected static function file_html( $file, $index, $field ) {
29
- list( $src ) = wp_get_attachment_image_src( $file, 'thumbnail' );
 
30
  return sprintf(
31
- '<li id="item_%s">
32
- <img src="%s">
33
- <div class="rwmb-image-bar">
34
- <a href="%s" target="_blank"><span class="dashicons dashicons-edit"></span></a> |
35
- <a href="#" class="rwmb-file-delete" data-attachment_id="%s">&times;</a>
 
 
 
 
 
 
 
 
36
  </div>
37
  </li>',
38
- $file,
39
- $src,
40
  get_edit_post_link( $file ),
41
  $file
42
  );
43
  }
44
 
45
  /**
46
- * Format a single value for the helper functions.
 
 
 
 
 
47
  *
48
- * @param array $field Field parameters.
49
- * @param array $value The value.
50
  * @return string
51
  */
52
- public static function format_single_value( $field, $value ) {
53
  $output = '<ul>';
54
  foreach ( $value as $file ) {
55
  $img = sprintf( '<img src="%s" alt="%s">', esc_url( $file['url'] ), esc_attr( $file['alt'] ) );
14
  */
15
  public static function admin_enqueue_scripts() {
16
  parent::admin_enqueue_scripts();
17
+ wp_enqueue_media();
18
  wp_enqueue_style( 'rwmb-image', RWMB_CSS_URL . 'image.css', array(), RWMB_VER );
19
  }
20
 
27
  * @return string
28
  */
29
  protected static function file_html( $file, $index, $field ) {
30
+ $attributes = self::get_attributes( $field, $file );
31
+
32
  return sprintf(
33
+ '<li class="rwmb-image-item attachment thumbnail">
34
+ <input type="hidden" name="%s[%s]" value="%s">
35
+ <div class="attachment-preview">
36
+ <div class="thumbnail">
37
+ <div class="centered">
38
+ %s
39
+ </div>
40
+ </div>
41
+ </div>
42
+ <div class="rwmb-image-overlay"></div>
43
+ <div class="rwmb-image-actions">
44
+ <a href="%s" class="rwmb-image-edit" target="_blank"><span class="dashicons dashicons-edit"></span></a>
45
+ <a href="#" class="rwmb-image-delete rwmb-file-delete" data-attachment_id="%s"><span class="dashicons dashicons-no-alt"></span></a>
46
  </div>
47
  </li>',
48
+ $attributes['name'], $index, $file,
49
+ wp_get_attachment_image( $file, 'thumbnail' ),
50
  get_edit_post_link( $file ),
51
  $file
52
  );
53
  }
54
 
55
  /**
56
+ * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
57
+ *
58
+ * @param array $field Field parameters.
59
+ * @param array $value The value.
60
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
61
+ * @param int|null $post_id Post ID. null for current post. Optional.
62
  *
 
 
63
  * @return string
64
  */
65
+ public static function format_single_value( $field, $value, $args, $post_id ) {
66
  $output = '<ul>';
67
  foreach ( $value as $file ) {
68
  $img = sprintf( '<img src="%s" alt="%s">', esc_url( $file['url'] ), esc_attr( $file['alt'] ) );
inc/fields/key-value.php CHANGED
@@ -132,11 +132,14 @@ class RWMB_Key_Value_Field extends RWMB_Text_Field {
132
  /**
133
  * Format value for the helper functions.
134
  *
135
- * @param array $field Field parameters.
136
- * @param string|array $value The field meta value.
 
 
 
137
  * @return string
138
  */
139
- public static function format_value( $field, $value ) {
140
  $output = '<ul>';
141
  foreach ( $value as $subvalue ) {
142
  $output .= sprintf( '<li><label>%s:</label> %s</li>', $subvalue[0], $subvalue[1] );
132
  /**
133
  * Format value for the helper functions.
134
  *
135
+ * @param array $field Field parameters.
136
+ * @param string|array $value The field meta value.
137
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
138
+ * @param int|null $post_id Post ID. null for current post. Optional.
139
+ *
140
  * @return string
141
  */
142
+ public static function format_value( $field, $value, $args, $post_id ) {
143
  $output = '<ul>';
144
  foreach ( $value as $subvalue ) {
145
  $output .= sprintf( '<li><label>%s:</label> %s</li>', $subvalue[0], $subvalue[1] );
inc/fields/multiple-values.php CHANGED
@@ -34,13 +34,16 @@ abstract class RWMB_Multiple_Values_Field extends RWMB_Field {
34
  }
35
 
36
  /**
37
- * Format a single value for the helper functions.
 
 
 
 
 
38
  *
39
- * @param array $field Field parameters.
40
- * @param string $value The value.
41
  * @return string
42
  */
43
- public static function format_single_value( $field, $value ) {
44
  return $field['options'][ $value ];
45
  }
46
  }
34
  }
35
 
36
  /**
37
+ * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
38
+ *
39
+ * @param array $field Field parameters.
40
+ * @param string $value The value.
41
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
42
+ * @param int|null $post_id Post ID. null for current post. Optional.
43
  *
 
 
44
  * @return string
45
  */
46
+ public static function format_single_value( $field, $value, $args, $post_id ) {
47
  return $field['options'][ $value ];
48
  }
49
  }
inc/fields/oembed.php CHANGED
@@ -94,13 +94,16 @@ class RWMB_OEmbed_Field extends RWMB_Text_Field {
94
  }
95
 
96
  /**
97
- * Format a single value for the helper functions.
 
 
 
 
 
98
  *
99
- * @param array $field Field parameters.
100
- * @param string $value Meta value.
101
  * @return string
102
  */
103
- public static function format_single_value( $field, $value ) {
104
  return self::get_embed( $value );
105
  }
106
  }
94
  }
95
 
96
  /**
97
+ * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
98
+ *
99
+ * @param array $field Field parameters.
100
+ * @param string $value The value.
101
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
102
+ * @param int|null $post_id Post ID. null for current post. Optional.
103
  *
 
 
104
  * @return string
105
  */
106
+ public static function format_single_value( $field, $value, $args, $post_id ) {
107
  return self::get_embed( $value );
108
  }
109
  }
inc/fields/sidebar.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The sidebar select field.
4
+ *
5
+ * @package Meta Box
6
+ */
7
+
8
+ /**
9
+ * Sidebar field class.
10
+ */
11
+ class RWMB_Sidebar_Field extends RWMB_Object_Choice_Field {
12
+ /**
13
+ * Normalize parameters for field.
14
+ *
15
+ * @param array $field Field parameters.
16
+ *
17
+ * @return array
18
+ */
19
+ public static function normalize( $field ) {
20
+ // Set default field args.
21
+ $field = parent::normalize( $field );
22
+
23
+ // Prevent select tree for user since it's not hierarchical.
24
+ $field['field_type'] = 'select_tree' === $field['field_type'] ? 'select' : $field['field_type'];
25
+
26
+ // Set to always flat.
27
+ $field['flatten'] = true;
28
+
29
+ // Set default placeholder.
30
+ $field['placeholder'] = empty( $field['placeholder'] ) ? __( 'Select a sidebar', 'meta-box' ) : $field['placeholder'];
31
+
32
+ return $field;
33
+ }
34
+
35
+ /**
36
+ * Get users.
37
+ *
38
+ * @param array $field Field parameters.
39
+ *
40
+ * @return array
41
+ */
42
+ public static function get_options( $field ) {
43
+ global $wp_registered_sidebars;
44
+ $options = array();
45
+ foreach ( $wp_registered_sidebars as $sidebar ) {
46
+ $options[] = (object) $sidebar;
47
+ }
48
+ return $options;
49
+ }
50
+
51
+ /**
52
+ * Get field names of object to be used by walker.
53
+ *
54
+ * @return array
55
+ */
56
+ public static function get_db_fields() {
57
+ return array(
58
+ 'parent' => 'parent',
59
+ 'id' => 'id',
60
+ 'label' => 'name',
61
+ );
62
+ }
63
+
64
+ /**
65
+ * Get option label.
66
+ *
67
+ * @param array $field Field parameters.
68
+ * @param string $value Option value.
69
+ *
70
+ * @return string
71
+ */
72
+ public static function get_option_label( $field, $value ) {
73
+ if ( ! is_active_sidebar( $value ) ) {
74
+ return '';
75
+ }
76
+ ob_start();
77
+ dynamic_sidebar( $value );
78
+ return ob_get_clean();
79
+ }
80
+ }
inc/fields/text-list.php CHANGED
@@ -39,11 +39,14 @@ class RWMB_Text_List_Field extends RWMB_Multiple_Values_Field {
39
  /**
40
  * Format value for the helper functions.
41
  *
42
- * @param array $field Field parameters.
43
- * @param string|array $value The field meta value.
 
 
 
44
  * @return string
45
  */
46
- public static function format_value( $field, $value ) {
47
  $output = '<table><thead><tr>';
48
  foreach ( $field['options'] as $label ) {
49
  $output .= "<th>$label</th>";
@@ -62,13 +65,16 @@ class RWMB_Text_List_Field extends RWMB_Multiple_Values_Field {
62
  }
63
 
64
  /**
65
- * Format a single value for the helper functions.
 
 
 
 
 
66
  *
67
- * @param array $field Field parameters.
68
- * @param array $value The value.
69
  * @return string
70
  */
71
- public static function format_single_value( $field, $value ) {
72
  $output = '<tr>';
73
  foreach ( $value as $subvalue ) {
74
  $output .= "<td>$subvalue</td>";
39
  /**
40
  * Format value for the helper functions.
41
  *
42
+ * @param array $field Field parameters.
43
+ * @param string|array $value The field meta value.
44
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
45
+ * @param int|null $post_id Post ID. null for current post. Optional.
46
+ *
47
  * @return string
48
  */
49
+ public static function format_value( $field, $value, $args, $post_id ) {
50
  $output = '<table><thead><tr>';
51
  foreach ( $field['options'] as $label ) {
52
  $output .= "<th>$label</th>";
65
  }
66
 
67
  /**
68
+ * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
69
+ *
70
+ * @param array $field Field parameters.
71
+ * @param string $value The value.
72
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
73
+ * @param int|null $post_id Post ID. null for current post. Optional.
74
  *
 
 
75
  * @return string
76
  */
77
+ public static function format_single_value( $field, $value, $args, $post_id ) {
78
  $output = '<tr>';
79
  foreach ( $value as $subvalue ) {
80
  $output .= "<td>$subvalue</td>";
inc/fields/video.php CHANGED
@@ -100,14 +100,16 @@ class RWMB_Video_Field extends RWMB_Media_Field {
100
  }
101
 
102
  /**
103
- * Format a single value for the helper functions.
104
  *
105
- * @param array $field Field parameters.
106
- * @param array $value The value.
 
 
107
  *
108
  * @return string
109
  */
110
- public static function format_single_value( $field, $value ) {
111
  $ids = implode( ',', wp_list_pluck( $value, 'ID' ) );
112
 
113
  return wp_playlist_shortcode( array(
100
  }
101
 
102
  /**
103
+ * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
104
  *
105
+ * @param array $field Field parameters.
106
+ * @param array $value The value.
107
+ * @param array $args Additional arguments. Rarely used. See specific fields for details.
108
+ * @param int|null $post_id Post ID. null for current post. Optional.
109
  *
110
  * @return string
111
  */
112
+ public static function format_single_value( $field, $value, $args, $post_id ) {
113
  $ids = implode( ',', wp_list_pluck( $value, 'ID' ) );
114
 
115
  return wp_playlist_shortcode( array(
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.12.5' );
22
 
23
  list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
24
 
@@ -75,6 +75,7 @@ class RWMB_Loader {
75
  $autoloader = new RWMB_Autoloader();
76
  $autoloader->add( RWMB_INC_DIR, 'RW_' );
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' );
@@ -85,6 +86,9 @@ class RWMB_Loader {
85
  $core = new RWMB_Core();
86
  $core->init();
87
 
 
 
 
88
  // Validation module.
89
  new RWMB_Validation();
90
 
18
  */
19
  protected function constants() {
20
  // Script version, used to add version for scripts and styles.
21
+ define( 'RWMB_VER', '4.12.6' );
22
 
23
  list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
24
 
75
  $autoloader = new RWMB_Autoloader();
76
  $autoloader->add( RWMB_INC_DIR, 'RW_' );
77
  $autoloader->add( RWMB_INC_DIR, 'RWMB_' );
78
+ $autoloader->add( RWMB_INC_DIR . 'about', 'RWMB_' );
79
  $autoloader->add( RWMB_INC_DIR . 'fields', 'RWMB_', '_Field' );
80
  $autoloader->add( RWMB_INC_DIR . 'walkers', 'RWMB_Walker_' );
81
  $autoloader->add( RWMB_INC_DIR . 'interfaces', 'RWMB_', '_Interface' );
86
  $core = new RWMB_Core();
87
  $core->init();
88
 
89
+ $about = new RWMB_About();
90
+ $about->init();
91
+
92
  // Validation module.
93
  new RWMB_Validation();
94
 
inc/templates/image-advanced.php CHANGED
@@ -1,7 +1,7 @@
1
  <script id="tmpl-rwmb-image-item" type="text/html">
2
  <input type="hidden" name="{{{ data.controller.fieldName }}}" value="{{{ data.id }}}" class="rwmb-media-input">
3
- <div class="rwmb-media-preview attachment-preview">
4
- <div class="rwmb-media-content thumbnail">
5
  <div class="centered">
6
  <# if ( 'image' === data.type && data.sizes ) { #>
7
  <# if ( data.sizes[data.controller.imageSize] ) { #>
@@ -19,12 +19,12 @@
19
  </div>
20
  </div>
21
  </div>
22
- <div class="rwmb-overlay"></div>
23
- <div class="rwmb-media-bar">
24
- <a class="rwmb-edit-media" title="{{{ i18nRwmbMedia.edit }}}" href="{{{ data.editLink }}}" target="_blank">
25
  <span class="dashicons dashicons-edit"></span>
26
  </a>
27
- <a href="#" class="rwmb-remove-media" title="{{{ i18nRwmbMedia.remove }}}">
28
  <span class="dashicons dashicons-no-alt"></span>
29
  </a>
30
  </div>
1
  <script id="tmpl-rwmb-image-item" type="text/html">
2
  <input type="hidden" name="{{{ data.controller.fieldName }}}" value="{{{ data.id }}}" class="rwmb-media-input">
3
+ <div class="attachment-preview">
4
+ <div class="thumbnail">
5
  <div class="centered">
6
  <# if ( 'image' === data.type && data.sizes ) { #>
7
  <# if ( data.sizes[data.controller.imageSize] ) { #>
19
  </div>
20
  </div>
21
  </div>
22
+ <div class="rwmb-image-overlay"></div>
23
+ <div class="rwmb-image-actions">
24
+ <a class="rwmb-image-edit rwmb-edit-media" title="{{{ i18nRwmbMedia.edit }}}" href="{{{ data.editLink }}}" target="_blank">
25
  <span class="dashicons dashicons-edit"></span>
26
  </a>
27
+ <a href="#" class="rwmb-image-delete rwmb-remove-media" title="{{{ i18nRwmbMedia.remove }}}">
28
  <span class="dashicons dashicons-no-alt"></span>
29
  </a>
30
  </div>
inc/wpml.php CHANGED
@@ -103,7 +103,7 @@ class RWMB_WPML {
103
  }
104
 
105
  // If the post is the original one: do nothing.
106
- if ( ! $wpml_post_translations->get_source_lang_code( $post_id ) ) {
107
  return $field;
108
  }
109
 
103
  }
104
 
105
  // If the post is the original one: do nothing.
106
+ if ( ! method_exists( $wpml_post_translations, 'get_source_lang_code' ) || ! $wpml_post_translations->get_source_lang_code( $post_id ) ) {
107
  return $field;
108
  }
109
 
js/file.js CHANGED
@@ -58,7 +58,6 @@
58
  */
59
  file.sort = function () {
60
  $( this ).sortable( {
61
- placeholder: 'rwmb-file rwmb-sortable-placeholder',
62
  items: 'li',
63
  start: function ( e, ui ) {
64
  ui.placeholder.height( ui.helper.outerHeight() );
58
  */
59
  file.sort = function () {
60
  $( this ).sortable( {
 
61
  items: 'li',
62
  start: function ( e, ui ) {
63
  ui.placeholder.height( ui.helper.outerHeight() );
js/validate.js CHANGED
@@ -9,7 +9,12 @@ jQuery( function ( $ ) {
9
  $form.siblings( '#message' ).remove();
10
  $form.before( '<div id="message" class="error"><p>' + rwmbValidate.summaryMessage + '</p></div>' );
11
  },
12
- ignore: ':not([class|="rwmb"])'
 
 
 
 
 
13
  };
14
 
15
  // Edit post form.
@@ -33,7 +38,7 @@ jQuery( function ( $ ) {
33
  // Required field styling
34
  $.each( subRules.rules, function ( k, v ) {
35
  if ( v['required'] ) {
36
- $( '#' + k ).parent().siblings( '.rwmb-label' ).addClass( 'required' ).append( '<span>*</span>' );
37
  }
38
  } );
39
  } );
9
  $form.siblings( '#message' ).remove();
10
  $form.before( '<div id="message" class="error"><p>' + rwmbValidate.summaryMessage + '</p></div>' );
11
  },
12
+ ignore: ':not([class|="rwmb"])',
13
+ errorPlacement: function(error, element) {
14
+ error.appendTo( element.closest( '.rwmb-input' ) );
15
+ },
16
+ errorClass: 'rwmb-error',
17
+ errorElement: 'p'
18
  };
19
 
20
  // Edit post form.
38
  // Required field styling
39
  $.each( subRules.rules, function ( k, v ) {
40
  if ( v['required'] ) {
41
+ $( '#' + k ).parent().siblings( '.rwmb-label' ).append( '<span class="rwmb-required">*</span>' );
42
  }
43
  } );
44
  } );
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.12.5
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.12.6
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.3
6
- Tested up to: 4.9
7
- Stable tag: 4.12.5
8
  License: GPLv2 or later
9
 
10
  Meta Box plugin is a powerful, professional developer toolkit to create custom meta boxes and custom fields for WordPress.
3
  Donate link: http://paypal.me/anhtnt
4
  Tags: meta-box, custom fields, custom field, meta, meta-boxes, admin, advanced, custom, edit, field, file, image, magic fields, matrix, more fields, Post, repeater, simple fields, text, textarea, type, cms, fields post
5
  Requires at least: 4.3
6
+ Tested up to: 4.9.1
7
+ Stable tag: 4.12.6
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.