/** * Secondary constructor; Any supplied $args override class property defaults. * * @param string $object_type Object type. * @param string $id A specific ID of the control. * @param array $args Control arguments. */ public function init($object_type, $id, $args = array()) { /** * @var $wp_fields WP_Fields_API */ global $wp_fields; parent::init($object_type, $id, $args); // Setup field if (!$this->field) { $this->field = $id; } if ($this->field) { $field = $wp_fields->get_field($this->object_type, $this->field, $this->object_name); if ($field) { $this->add_child($field); } } }
/** * Secondary constructor; Any supplied $args override class property defaults. * * @param string $object_type Object type. * @param string $id A specific ID of the field. Can be a * theme mod or option name. * @param array $args Field arguments. * * @return WP_Fields_API_Field $field */ public function init($object_type, $id, $args = array()) { parent::init($object_type, $id, $args); // Parse the ID for array keys. $this->id_data['keys'] = preg_split('/\\[/', str_replace(']', '', $this->id)); $this->id_data['base'] = array_shift($this->id_data['keys']); // Rebuild the ID. $this->id = $this->id_data['base']; if (!empty($this->id_data['keys'])) { $this->id .= '[' . implode('][', $this->id_data['keys']) . ']'; } }