/** * to_json() * * You can use this method to modify the field properties that are added to the JSON object. * The JSON object is used by the Backbone Model and the Underscore template. * * @param bool $load Should the value be loaded from the database or use the value from the current instance. * @return array */ function to_json($load) { $field_data = parent::to_json($load); // do not delete $field_data = array_merge($field_data, array('example_property' => $this->example_property)); return $field_data; }
public function create_options_page($page_parent = '') { if (!class_exists('\\Carbon_Fields\\Container\\Container')) { return; } Container::make('theme_options', __('Instagram Settings', 'crb'))->set_page_parent($page_parent)->add_fields(array(Field::make('html', 'crb_instagram_settings_html')->set_html(' <div style="position: relative; background: #fff; border: 1px solid #ccc; padding: 10px;"> <h4><strong>' . __('Instagram API requires an Instagram client for communication with 3rd party sites. Here are the steps for creating and setting up an Instagram client:', 'crb') . '</strong></h4> <ol style="font-weight: normal; margin-left: 25px;"> <li>' . sprintf(__('Go to <a href="%1$s" target="_blank">%1$s</a> and log in, if necessary.', 'crb'), 'https://instagram.com/developer/clients/register/') . '</li> <li>' . __('Supply the necessary required fields. <strong>Valid redirect URIs</strong> field must be filled with the value from the <strong>Redirect URI</strong> field below.', 'crb') . '</li> <li>' . __('Click the Register button.', 'crb') . '</li> <li>' . __('On the next screen, copy the following fields: <strong>Client ID, Client Secret</strong> to the below fields.', 'crb') . '</li> <li>' . __('Save the updates using the "Save Changes" button on this page', 'crb') . '</li> <li>' . __('Click the "Authenticate" button and follow the on screen instructions.', 'crb') . '</li> </ol> </div> '), Field::make('text', $this->client->carbon_config_fields['user_name'], __('Username', 'crb')), Field::make('textarea', $this->client->carbon_config_fields['hashtags'], __('Hashtags', 'crb'))->set_help_text(__('Separate hashtags with a comma.', 'crb')), Field::make('text', $this->client->carbon_config_fields['client_id'], __('Client ID', 'crb'))->set_width(50), Field::make('text', $this->client->carbon_config_fields['client_secret'], __('Client Secret', 'crb'))->set_width(50), Field::make('text', $this->client->carbon_config_fields['redirect_uri'], __('Redirect URI', 'crb'))->set_default_value($this->client->get_redirect_uri()), Field::make('html', 'crb_instragram_authenticate')->set_html($this->generate_page_buttons()))); }
/** * A proxy for the abstract field factory method. * * @see Carbon_Fields\Field\Field::factory() **/ public static function factory($type, $name, $label = null) { return Abstract_Field::factory($type, $name, $label); }
/** * Returns an array that holds the field data, suitable for JSON representation. * This data will be available in the Underscore template and the Backbone Model. * * @param bool $load Should the value be loaded from the database or use the value from the current instance. * @return array */ public function to_json($load) { $complex_data = parent::to_json($load); $groups_data = array(); $values_data = array(); foreach ($this->groups as $group) { $groups_data[] = $group->to_json(false); } foreach ($this->values as $fields) { $group = $this->get_group_by_name($fields['type']); unset($fields['type']); $data = array('name' => $group->get_name(), 'label' => $group->get_label(), 'group_id' => $group->get_group_id(), 'fields' => array()); foreach ($fields as $index => $field) { $data['fields'][] = $field->to_json(false); } $values_data[] = $data; } $complex_data = array_merge($complex_data, array('layout' => $this->layout, 'labels' => $this->labels, 'min' => $this->get_min(), 'max' => $this->get_max(), 'multiple_groups' => count($groups_data) > 1, 'groups' => $groups_data, 'value' => $values_data)); return $complex_data; }
/** * Delete the field value(s) from the database. * * @param Field $field The field to delete. */ public function delete(Field $field) { if (isset($this->store_data[$field->get_name()])) { unset($this->store_data[$field->get_name()]); } }
function setup() { $this->field = Field::make('text', 'color'); }
/** * Delete the field value(s) from the database. * * @param Field $field The field to delete. */ public function delete(Field $field) { delete_option($field->get_name()); }
/** * Delete the field value(s) from the database. * * @param Field $field The field to delete. */ public function delete(Field $field) { delete_metadata('term', $this->term_id, $field->get_name(), $field->get_value()); }
/** * @expectedException Carbon_Fields\Exception\Incorrect_Syntax_Exception * @expectedExceptionMessage can't be empty */ public function testFieldNameCantBeEmpty() { Field::make('text', ''); }
/** * Delete the field value(s) from the database. * * @param Field $field The field to delete. */ public function delete(Field $field) { delete_user_meta($this->user_id, $field->get_name(), $field->get_value()); }
/** * Delete the field value(s) from the database. * * @param Field $field The field to delete. */ public function delete(Field $field) { delete_post_meta($this->post_id, $field->get_name(), $field->get_value()); }