Example #1
0
 /**
  * Init our settings
  */
 public function init()
 {
     // Add a section to the permalinks page
     $this->wp->addSettingsSection('jigoshop-permalink', __('Product permalink base', 'jigoshop'), array($this, 'settings'), 'permalink');
     // Add our settings
     $this->wp->addSettingsField('jigoshop_product_category_slug', __('Product category base', 'jigoshop'), array($this, 'product_category_slug_input'), 'permalink', 'optional');
     $this->wp->addSettingsField('jigoshop_product_tag_slug', __('Product tag base', 'jigoshop'), array($this, 'product_tag_slug_input'), 'permalink', 'optional');
 }
Example #2
0
 /**
  * Registers setting item.
  */
 public function register()
 {
     // Weed out all admin pages except the Jigoshop Settings page hits
     if (!in_array($this->wp->getPageNow(), array('admin.php', 'options.php'))) {
         return;
     }
     $screen = $this->wp->getCurrentScreen();
     if (!in_array($screen->base, array('jigoshop_page_' . self::NAME, 'options'))) {
         return;
     }
     $this->wp->registerSetting(self::NAME, Options::NAME, array($this, 'validate'));
     $tab = $this->getCurrentTab();
     $tab = $this->tabs[$tab];
     // Workaround for PHP pre-5.4
     $that = $this;
     /** @var TabInterface $tab */
     $sections = $this->wp->applyFilters('jigoshop/admin/settings/tab/' . $tab->getSlug(), $tab->getSections(), $tab);
     foreach ($sections as $section) {
         $this->wp->addSettingsSection($section['id'], $section['title'], function () use($tab, $section, $that) {
             $that->displaySection($tab, $section);
         }, self::NAME);
         foreach ($section['fields'] as $field) {
             $field = $this->validateField($field);
             $this->wp->addSettingsField($field['id'], $field['title'], array($this, 'displayField'), self::NAME, $section['id'], $field);
         }
     }
 }