/** * Add child object to container * * @param WP_Fields_API_Container $child * @param string $child_type */ public function add_child($child, $child_type = 'control') { if (!isset($this->children[$child_type])) { $this->children[$child_type] = array(); } if (isset($this->sorted[$child_type])) { unset($this->sorted[$child_type]); } // Set parent if ('field' !== $child->container_type) { $child->set_parent($this); } $this->children[$child_type][$child->id] =& $child; }
/** * 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']) . ']'; } }
/** * {@inheritdoc} */ public function check_capabilities() { $field = $this->get_field(); if (!$field || !$field->check_capabilities()) { return false; } $section = $this->get_section(); if ($section && !$section->check_capabilities()) { return false; } return parent::check_capabilities(); }