/** * Registering the Sections, Fields, and Settings. * * This function is registered with the 'admin_init' hook. * * @since 0.4.0 */ public function admin_init() { $taxes = of_cme_supported_taxonomies(); $defaults = of_cme_get_defaults(); foreach ($taxes as $tax) { $taxonomy_object = get_taxonomy($tax); $section = $this->name . '_' . $tax; if (false == get_option($section)) { add_option($section, apply_filters($section . '_default_settings', $defaults)); } $args = array($section, get_option($section)); add_settings_section($tax, sprintf(__('%s Metabox', $this->name), $taxonomy_object->labels->name), '', $section); add_settings_field('type', __('Option Type', $this->name), array($this, 'type_callback'), $section, $tax, $args); add_settings_field('context', __('Position (Context)', $this->name), array($this, 'context_callback'), $section, $tax, $args); add_settings_field('priority', __('Priority', $this->name), array($this, 'priority_callback'), $section, $tax, $args); add_settings_field('metabox_title', __('Title', $this->name), array($this, 'title_callback'), $section, $tax, $args); add_settings_field('indent', __('Indent', $this->name), array($this, 'indent_callback'), $section, $tax, $args); add_settings_field('allow_new_terms', __('Allow new terms', $this->name), array($this, 'allow_new_terms_callback'), $section, $tax, $args); register_setting($section, $section, array($this, 'validate_inputs')); } }
/** * Customize taxonomy metaboxes * * @since 0.3.0 */ public function customize_taxonomy_metaboxes() { $taxes = of_cme_supported_taxonomies(); foreach ($taxes as $tax) { $defaults = of_cme_get_defaults(); $options = get_option($this->name . '_' . $tax); $options = wp_parse_args($options, $defaults); $type = $options['type']; if ($type != 'checkbox') { ${$tax . "_metabox"} = new Taxonomy_Single_Term($tax, array(), $type); ${$tax . "_metabox"}->set('force_selection', true); unset($defaults['type']); foreach ($defaults as $key => $v) { $value = $options[$key]; ${$tax . "_metabox"}->set($key, $value); } } } }
?> <!-- This file should primarily consist of HTML with a little bit of PHP. --> <div class="wrap"> <div id="icon-themes" class="icon32"></div> <h2><?php echo esc_html(get_admin_page_title()); ?> </h2> <?php // settings_errors(); ?> <?php $taxes = of_cme_supported_taxonomies(); if (isset($_GET['tab'])) { $active_tab = $_GET['tab']; } else { $active_tab = isset($taxes[0]) ? $taxes[0] : ''; } ?> <h2 class="nav-tab-wrapper"> <?php foreach ($taxes as $tax) { ?> <a href="?page=category-metabox-enhanced&tab=<?php echo $tax; ?> " class="nav-tab <?php