Пример #1
0
 /**
  * Render a field row
  * @since 1.0.0
  */
 public function render_field()
 {
     // If field is requesting to not be shown on the front-end
     if (!is_admin() && !$this->args('on_front')) {
         return;
     }
     // If field is requesting to be conditionally shown
     if (is_callable($this->args('show_on_cb')) && !call_user_func($this->args('show_on_cb'), $this)) {
         return;
     }
     $classes = 'cmb-type-' . sanitize_html_class($this->type());
     $classes .= ' cmb2_id_' . sanitize_html_class($this->id());
     $classes .= $this->args('repeatable') ? ' cmb-repeat' : '';
     $classes .= $this->group ? ' cmb-repeat-group-field' : '';
     // 'inline' flag, or _inline in the field type, set to true
     $classes .= $this->args('inline') ? ' cmb-inline' : '';
     printf("<li class=\"cmb-row %s\">\n", $classes);
     if ('title' == $this->type() || !$this->args('show_names')) {
         echo "\t<div class=\"cmb-td\">\n";
         if (!$this->args('show_names')) {
             $style = 'title' == $this->type() ? ' style="display:none;"' : '';
             printf("\n<label%s for=\"%s\">%s</label>\n", $style, $this->id(), $this->args('name'));
         }
     } else {
         printf('<div class="cmb-th"><label for="%1$s">%2$s</label></div>', $this->id(), $this->args('name'));
         echo "\n\t<div class=\"cmb-td\">\n";
     }
     echo $this->args('before');
     $this_type = new CMB2_Types($this);
     $this_type->render();
     echo $this->args('after');
     echo "\n\t</div>\n</li>";
 }
Пример #2
0
 /**
  * Default field render callback
  * @since 2.1.1
  */
 public function render_field_callback()
 {
     // If field is requesting to not be shown on the front-end
     if (!is_admin() && !$this->args('on_front')) {
         return;
     }
     // If field is requesting to be conditionally shown
     if (!$this->should_show()) {
         return;
     }
     $this->peform_param_callback('before_row');
     printf("<div class=\"cmb-row %s\">\n", $this->row_classes());
     if (!$this->args('show_names')) {
         echo "\n\t<div class=\"cmb-td\">\n";
         $this->peform_param_callback('label_cb');
     } else {
         if ($this->get_param_callback_result('label_cb', false)) {
             echo '<div class="cmb-th">', $this->peform_param_callback('label_cb'), '</div>';
         }
         echo "\n\t<div class=\"cmb-td\">\n";
     }
     $this->peform_param_callback('before');
     $field_type = new CMB2_Types($this);
     $field_type->render();
     $this->peform_param_callback('after');
     echo "\n\t</div>\n</div>";
     $this->peform_param_callback('after_row');
     // For chaining
     return $this;
 }
Пример #3
0
 /**
  * Render a field row
  * @since 1.0.0
  */
 public function render_field()
 {
     // If field is requesting to not be shown on the front-end
     if (!is_admin() && !$this->args('on_front')) {
         return;
     }
     // If field is requesting to be conditionally shown
     if (is_callable($this->args('show_on_cb')) && !call_user_func($this->args('show_on_cb'), $this)) {
         return;
     }
     $this->peform_param_callback('before_row');
     printf("<div class=\"cmb-row %s\">\n", $this->row_classes());
     if ('title' == $this->type() || !$this->args('show_names')) {
         echo "\t<div class=\"cmb-td\">\n";
         if (!$this->args('show_names')) {
             $style = 'title' == $this->type() ? '' : ' style="display:none;"';
             printf("\n<label%s for=\"%s\">%s</label>\n", $style, $this->id(), $this->args('name'));
         }
     } else {
         if ($this->args('name')) {
             printf('<div class="cmb-th"><label for="%1$s">%2$s</label></div>', $this->id(), $this->args('name'));
         }
         echo "\n\t<div class=\"cmb-td\">\n";
     }
     $this->peform_param_callback('before');
     $this_type = new CMB2_Types($this);
     $this_type->render();
     $this->peform_param_callback('after');
     echo "\n\t</div>\n</div>";
     $this->peform_param_callback('after_row');
 }