/** * Build configuration * * @return object This class instance */ public function build() { // Making sure we do not run this twice if ($this->already_built) { return $this; } // Run configuration hooks $this->runHooks(); // Build configuration items if ($build_config = $this->config->get('build.all')) { foreach ($build_config as $section_name => $configs) { foreach ($configs as $config_obj) { // Merge with current environment configuration, if it exists $env_config_path = "build.{$this->current_env}.{$section_name}." . $config_obj->getId(); if ($env_config = $this->config->get($env_config_path)) { $config_obj = $config_obj->merge($env_config); } // Build configuration item $config_obj->build(); } } } // Mark configuration as built $this->already_built = true; return $this; }
/** * Sets default labels based on singular and plural names for this post type * * @return void */ protected function __setDefaultLabels() { $singular = $this->config->get('singular_name'); $plural = $this->config->get('plural_name'); $labels = array('name' => __($plural), 'singular_name' => __($singular), 'menu_name' => __($plural), 'all_items' => __($plural), 'add_new' => __('Add ' . $singular), 'add_new_item' => __('Add new ' . $singular), 'edit_item' => __('Edit ' . $singular), 'new_item' => __('New ' . $singular), 'view_item' => __('View ' . $singular), 'search_items' => __('Search ' . $plural), 'not_found' => __('There are no ' . $plural), 'not_found_in_trash' => __('There are no ' . $plural . ' in trash'), 'parent_item_colon' => __('Parent ' . $singular . ':')); $this->setLabels($labels); }
/** * Sets default labels based on singular and plural names * * @return void */ private function __setDefaultLabels() { $singular = $this->config->get('singular_name'); $plural = $this->config->get('plural_name'); $labels = array('name' => _x($plural, 'taxonomy general name'), 'singular_name' => _x($singular, 'taxonomy singular name'), 'search_items' => __('Search ' . $plural), 'all_items' => __('All ' . $plural), 'parent_item' => __('Parent ' . $singular), 'parent_item_colon' => __('Parent ' . $singular . ':'), 'edit_item' => __('Edit ' . $singular), 'update_item' => __('Update ' . $singular), 'add_new_item' => __('Add New ' . $singular), 'new_item_name' => __('New ' . $singular . ' Name'), 'menu_name' => __($plural)); $this->setLabels($labels); }
/** * Returns element children HTML * * @return string Element children HTML */ public function getChildrenHtml() { $html = ''; if (!$this->isSelfClosing()) { $children = $this->config->get('children') ?: []; if ($children) { foreach ($children as $child) { if (is_string($child)) { $html .= $child; } else { $html .= $child->getHtml(); } } } } return $html; }
/** * Renders tabbed UI * * @return void */ protected function renderTabs() { $tabs = $this->getTabs(); $page_url = $this->config->get('url'); $current_tab = isset($_GET['tab']) ? $_GET['tab'] : $tabs[0]->getId(); ?> <h2 class="nav-tab-wrapper"> <?php foreach ($tabs as $tab) { ?> <a href="<?php echo $page_url . '&tab=' . $tab->getId(); ?> " class="nav-tab<?php if ($current_tab == $tab->getId()) { echo ' nav-tab-active'; } ?> "> <?php echo $tab->getTitle(); ?> </a> <?php } ?> </h2> <div style="padding-top:30px;"> <?php foreach ($tabs as $tab) { if ($current_tab == $tab->getId()) { settings_fields($tab->getId()); $tab->render(); } } ?> </div> <?php }
/** * Checks if the target var key have a value * * @param string $key Target var key * @return boolean True if there is a value, false otherwise */ public function varHasValue($key) { return $this->vars->hasKey($key) && $this->vars->get($key) != '' ? true : false; }
/** * Returns data stored on target key * * @param string $key * @return mixed */ public function get($key) { return $this->data->get($key); }
/** * Returns a single option * * @param string $key Option key * @return mixed Option value */ public function getOption($key) { return $this->options->get($key); }
/** * Returns callback arguments * * @return array */ public function getCallbackArgs() { return $this->config->get('callback_args'); }
/** * Returns Api URL prefix * * @return string */ public function getBaseUrl() { return trim($this->config->get('base_url'), '/') . '/'; }