Ejemplo n.º 1
0
 /**
  * Get field HTML
  *
  * @param string $html
  * @param mixed  $meta
  * @param array  $field
  *
  * @return string
  */
 static function html($html, $meta, $field)
 {
     if (!is_array($meta)) {
         $meta = (array) $meta;
     }
     $i18n_msg = _x('Uploaded files', 'image upload', 'rwmb');
     $i18n_title = _x('Upload files', 'image upload', 'rwmb');
     // Filter to change the drag & drop box background string
     $i18n_drop = apply_filters('rwmb_upload_drop_string', _x('Drop images here', 'image upload', 'rwmb'));
     $i18n_or = _x('or', 'image upload', 'rwmb');
     $i18n_select = _x('Select Files', 'image upload', 'rwmb');
     $img_prefix = $field['id'];
     $html = wp_nonce_field("rwmb-delete-file_{$field['id']}", "nonce-delete-file_{$field['id']}", false, false);
     $html .= wp_nonce_field("rwmb-reorder-images_{$field['id']}", "nonce-reorder-images_{$field['id']}", false, false);
     $html .= wp_nonce_field("rwmb-upload-images_{$field['id']}", "nonce-upload-images_{$field['id']}", false, false);
     $html .= "<input type='hidden' class='field-id rwmb-image-prefix' value='{$field['id']}' />";
     // Uploaded images
     $html .= "<div id='{$img_prefix}-container'>";
     // Check for max_file_uploads
     $class = 'rwmb-drag-drop hide-if-no-js';
     if (!empty($field['max_file_uploads'])) {
         $max_file_uploads = (int) $field['max_file_uploads'];
         $html .= "<input class='max_file_uploads' type='hidden' value='{$max_file_uploads}' />";
         if (count($meta) >= $max_file_uploads) {
             $class = RW_Meta_Box::add_cssclass('hidden', $class);
         }
     }
     $html .= "<h4 class='rwmb-uploaded-title'>{$i18n_msg}</h4>";
     $html .= "<ul class='rwmb-images rwmb-uploaded'>";
     foreach ($meta as $image) {
         $html .= self::img_html($image);
     }
     $html .= '</ul>';
     // Show form upload
     $html .= "\n\t\t\t\t<h4>{$i18n_title}</h4>\n\t\t\t\t<div id='{$img_prefix}-dragdrop' class='{$class}'>\n\t\t\t\t\t<div class = 'rwmb-drag-drop-inside'>\n\t\t\t\t\t\t<p>{$i18n_drop}</p>\n\t\t\t\t\t\t<p>{$i18n_or}</p>\n\t\t\t\t\t\t<p><input id='{$img_prefix}-browse-button' type='button' value='{$i18n_select}' class='button' /></p>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t";
     $html .= '</div>';
     return $html;
 }