function testHideForTemplate() { $mb = new CMB_Meta_Box(array('title' => 'Test Meta Box', 'pages' => 'post', 'fields' => array(array('id' => 'test', 'name' => 'Test', 'type' => 'text')), 'hide_on' => array('page-template' => 'test.php'))); $this->assertTrue($mb->hide_for_page_template(true)); $_GET['post'] = $this->post->ID; $this->assertFalse($mb->hide_for_page_template(true)); $_GET['post'] = 3; $this->assertTrue($mb->hide_for_page_template(true)); unset($_GET['post']); }
public function html() { $fields = &$this->get_fields(); $value = $this->get_value(); // Reset all field values. foreach ( $fields as $field ) { $field->set_values( array() ); } // Set values for this field. if ( ! empty( $value ) ) { foreach ( $value as $field_id => $field_value ) { $field_value = ( ! empty( $field_value ) ) ? $field_value : array(); if ( ! empty( $fields[$field_id] ) ) { $fields[$field_id]->set_values( (array) $field_value ); } } } ?> <?php if ( $this->args['repeatable'] ) : ?> <button class="cmb-delete-field"> <span class="cmb-delete-field-icon">×</span> <?php echo esc_html( $this->args['string-delete-field'] ); ?> </button> <?php endif; ?> <?php CMB_Meta_Box::layout_fields( $fields ); ?> <?php }
public function html() { $value = $this->value; if (!empty($value)) { foreach ($value as $field => $field_value) { if (!empty($field) && !empty($this->fields[$field])) { $this->fields[$field]->set_values((array) $field_value); } else { if (!empty($this->fields[$field])) { $this->fields[$field]->set_values(array()); } } } } else { foreach ($this->fields as $field) { $field->set_values(array()); } } $field = $this->args; ?> <div class="group <?php echo !empty($field['repeatable']) ? 'cloneable' : ''; ?> " style="position: relative"> <?php if ($this->args['repeatable']) { ?> <span class="cmb_element"> <span class="ui-state-default"> <a class="delete-field ui-icon-circle-close ui-icon">×</a> </span> </span> <?php } ?> <?php CMB_Meta_Box::layout_fields($this->fields); ?> </div> <?php }
public function html() { $field = $this->args; $value = $this->value; $fields = array(); foreach ($this->args['fields'] as $f) { $field_value = isset($this->value[$f['id']]) ? $this->value[$f['id']] : ''; $f['uid'] = $field['id'] . '[' . $f['id'] . ']'; // If it's cloneable , make it an array if ($field['repeatable'] == true) { $f['uid'] .= '[]'; } $class = _cmb_field_class_for_type($f['type']); $f['show_label'] = true; // Todo support for repeatble fields in groups $fields[] = new $class($f['uid'], $f['name'], array($field_value), $f); } ?> <div class="group <?php echo !empty($field['repeatable']) ? 'cloneable' : ''; ?> " style="position: relative"> <?php if (!empty($this->args['name'])) { ?> <h2 class="group-name"><?php echo $this->args['name']; ?> </h2> <?php } ?> <?php if ($this->args['repeatable']) { ?> <a class="delete-field button" style="position: absolute; top: -3px; right: -3px">X</a> <?php } ?> <?php CMB_Meta_Box::layout_fields($fields); ?> </div> <?php }
public function html() { $fields =& $this->get_fields(); $value = $this->value; if (!empty($value)) { foreach ($value as $field_id => $field_value) { if (!empty($field_value) && !empty($fields[$field_id])) { $fields[$field_id]->set_values((array) $field_value); } else { if (!empty($fields[$field_id])) { $fields[$field_id]->set_values(array()); } } } } else { foreach ($fields as &$field) { $field->set_values(array()); } } ?> <?php if ($this->args['repeatable']) { ?> <button class="cmb-delete-field" title="Remove field"><span class="cmb-delete-field-icon">×</span> Remove Group</button> <?php } ?> <?php CMB_Meta_Box::layout_fields($fields); ?> <?php }
public function html() { $field = $this->args; $value = $this->value; if (!empty($value)) { foreach ($value as $field => $field_value) { if (!empty($field)) { $this->fields[$field]->set_values((array) $field_value); } } } ?> <div class="group <?php echo !empty($field['repeatable']) ? 'cloneable' : ''; ?> " style="position: relative"> <?php if ($this->args['repeatable']) { ?> <a class="delete-field button" style="position: absolute; top: -3px; right: -3px">X</a> <?php } ?> <?php CMB_Meta_Box::layout_fields($this->fields); ?> </div> <?php }