protected function _registerField(array $aField)
 {
     AdminPageFramework_FieldTypeRegistration::_setFieldResources($aField, $this->oProp, $this->oResource);
     if ($aField['help']) {
         $this->oHelpPane->_addHelpTextForFormFields($aField['title'], $aField['help'], $aField['help_aside']);
     }
     if (isset($this->oProp->aFieldTypeDefinitions[$aField['type']]['hfDoOnRegistration']) && is_callable($this->oProp->aFieldTypeDefinitions[$aField['type']]['hfDoOnRegistration'])) {
         call_user_func_array($this->oProp->aFieldTypeDefinitions[$aField['type']]['hfDoOnRegistration'], array($aField));
     }
 }
 protected function _registerField(array $aField)
 {
     AdminPageFramework_FieldTypeRegistration::_setFieldResources($aField, $this->oProp, $this->oResource);
     if ($aField['help']) {
         $this->addHelpTab(array('page_slug' => $aField['page_slug'], 'page_tab_slug' => $aField['tab_slug'], 'help_tab_title' => $aField['section_title'], 'help_tab_id' => $aField['section_id'], 'help_tab_content' => "<span class='contextual-help-tab-title'>" . $aField['title'] . "</span> - " . PHP_EOL . $aField['help'], 'help_tab_sidebar_content' => $aField['help_aside'] ? $aField['help_aside'] : ""));
     }
     if (isset($this->oProp->aFieldTypeDefinitions[$aField['type']]['hfDoOnRegistration']) && is_callable($this->oProp->aFieldTypeDefinitions[$aField['type']]['hfDoOnRegistration'])) {
         call_user_func_array($this->oProp->aFieldTypeDefinitions[$aField['type']]['hfDoOnRegistration'], array($aField));
     }
 }
 /**
  * Registers a field.
  * 
  * @since 3.0.4
  * @internal
  */
 private function _registerField(array $aField)
 {
     // Load head tag elements for fields.
     AdminPageFramework_FieldTypeRegistration::_setFieldResources($aField, $this->oProp, $this->oResource);
     // Set relevant scripts and styles for the input field.
     // For the contextual help pane,
     if ($aField['help']) {
         $this->oHelpPane->_addHelpTextForFormFields($aField['title'], $aField['help'], $aField['help_aside']);
     }
 }
 /**
  * Registers the setting sections and fields.
  * 
  * This methods passes the stored section and field array contents to the `add_settings_section()` and `add_settings_fields()` functions.
  * Then perform `register_setting()`.
  * 
  * The filters will be applied to the section and field arrays; that means that third-party scripts can modify the arrays.
  * Also they get sorted before being registered based on the set order.
  * 
  * @since       2.0.0
  * @since       2.1.5       Added the ability to define custom field types.
  * @since       3.1.2       Changed the hook from the `admin_menu` to `current_screen` so that the user can add forms in `load_{...}` callback methods.
  * @since       3.1.3       Removed the Settings API related functions entirely.
  * @since       3.3.1       Moved from `AdminPageFramework_Setting_Base`.
  * @remark      This method is not intended to be used by the user.
  * @remark      The callback method for the `load_after_{instantiated class name}` hook.
  * @return      void
  * @internal
  */
 public function _replyToRegisterSettings()
 {
     if (!$this->_isInThePage()) {
         return;
     }
     /* 1. Apply filters to added sections and fields */
     $this->oForm->aSections = $this->oUtil->addAndApplyFilter($this, "sections_{$this->oProp->sClassName}", $this->oForm->aSections);
     foreach ($this->oForm->aFields as $_sSectionID => &$_aFields) {
         $_aFields = $this->oUtil->addAndApplyFilter($this, "fields_{$this->oProp->sClassName}_{$_sSectionID}", $_aFields);
         unset($_aFields);
         // to be safe in PHP especially the same variable name is used in the scope.
     }
     $this->oForm->aFields = $this->oUtil->addAndApplyFilter($this, "fields_{$this->oProp->sClassName}", $this->oForm->aFields);
     /* 2. Format ( sanitize ) the section and field arrays and apply conditions to the sections and fields and drop unnecessary items. */
     // 2-1. Set required properties for formatting.
     $this->oForm->setDefaultPageSlug($this->oProp->sDefaultPageSlug);
     $this->oForm->setOptionKey($this->oProp->sOptionKey);
     $this->oForm->setCallerClassName($this->oProp->sClassName);
     // 2-2. Do format internally stored sections and fields definition arrays.
     $this->oForm->format();
     // 2-3. Now set required properties for conditioning.
     $this->oForm->setCurrentPageSlug(isset($_GET['page']) && $_GET['page'] ? $_GET['page'] : '');
     $this->oForm->setCurrentTabSlug($this->oProp->getCurrentTab());
     // 2-4. Do conditioning.
     $this->oForm->applyConditions();
     $this->oForm->applyFiltersToFields($this, $this->oProp->sClassName);
     // applies filters to the conditioned field definition arrays.
     $this->oForm->setDynamicElements($this->oProp->aOptions);
     // will update $this->oForm->aConditionedFields
     /* 3. Define field types. This class adds filters for the field type definitions so that framework's built-in field types will be added. */
     $this->oProp->aFieldTypeDefinitions = AdminPageFramework_FieldTypeRegistration::register($this->oProp->aFieldTypeDefinitions, $this->oProp->sClassName, $this->oMsg);
     $this->oProp->aFieldTypeDefinitions = $this->oUtil->addAndApplyFilter($this, 'field_types_' . $this->oProp->sClassName, $this->oProp->aFieldTypeDefinitions);
     /* 4. Set up the contextual help pane */
     foreach ($this->oForm->aConditionedSections as $_aSection) {
         if (empty($_aSection['help'])) {
             continue;
         }
         $this->addHelpTab(array('page_slug' => $_aSection['page_slug'], 'page_tab_slug' => $_aSection['tab_slug'], 'help_tab_title' => $_aSection['title'], 'help_tab_id' => $_aSection['section_id'], 'help_tab_content' => $_aSection['help'], 'help_tab_sidebar_content' => $_aSection['help_aside'] ? $_aSection['help_aside'] : ""));
     }
     /* 5. Set head tag and help pane elements */
     foreach ($this->oForm->aConditionedFields as $_sSectionID => $_aSubSectionOrFields) {
         foreach ($_aSubSectionOrFields as $_sSubSectionIndexOrFieldID => $_aSubSectionOrField) {
             // If the iterating item is a sub-section array.
             if (is_numeric($_sSubSectionIndexOrFieldID) && is_int($_sSubSectionIndexOrFieldID + 0)) {
                 $_iSubSectionIndex = $_sSubSectionIndexOrFieldID;
                 $_aSubSection = $_aSubSectionOrField;
                 foreach ($_aSubSection as $__sFieldID => $__aField) {
                     AdminPageFramework_FieldTypeRegistration::_setFieldResources($__aField, $this->oProp, $this->oResource);
                     // Set relevant scripts and styles for the input field.
                 }
                 continue;
             }
             /* 5-1. Add the given field. */
             $aField = $_aSubSectionOrField;
             /* 5-2. Set relevant scripts and styles for the input field. */
             AdminPageFramework_FieldTypeRegistration::_setFieldResources($aField, $this->oProp, $this->oResource);
             // Set relevant scripts and styles for the input field.
             /* 5-3. For the contextual help pane, */
             if (!empty($aField['help'])) {
                 $this->addHelpTab(array('page_slug' => $aField['page_slug'], 'page_tab_slug' => $aField['tab_slug'], 'help_tab_title' => $aField['section_title'], 'help_tab_id' => $aField['section_id'], 'help_tab_content' => "<span class='contextual-help-tab-title'>" . $aField['title'] . "</span> - " . PHP_EOL . $aField['help'], 'help_tab_sidebar_content' => $aField['help_aside'] ? $aField['help_aside'] : ""));
             }
         }
     }
     /* 6. Enable the form - Set the form enabling flag so that the <form></form> tag will be inserted in the page. */
     $this->oProp->bEnableForm = true;
     /* 7. Handle submitted data. */
     $this->_handleSubmittedData();
 }
Пример #5
0
 public function _replyToRegisterSettings()
 {
     if (!$this->_isInThePage()) {
         return;
     }
     $this->oForm->aSections = $this->oUtil->addAndApplyFilter($this, "sections_{$this->oProp->sClassName}", $this->oForm->aSections);
     foreach ($this->oForm->aFields as $_sSectionID => &$_aFields) {
         $_aFields = $this->oUtil->addAndApplyFilter($this, "fields_{$this->oProp->sClassName}_{$_sSectionID}", $_aFields);
         unset($_aFields);
     }
     $this->oForm->aFields = $this->oUtil->addAndApplyFilter($this, "fields_{$this->oProp->sClassName}", $this->oForm->aFields);
     $this->oForm->setDefaultPageSlug($this->oProp->sDefaultPageSlug);
     $this->oForm->setOptionKey($this->oProp->sOptionKey);
     $this->oForm->setCallerClassName($this->oProp->sClassName);
     $this->oForm->format();
     $this->oForm->setCurrentPageSlug(isset($_GET['page']) && $_GET['page'] ? $_GET['page'] : '');
     $this->oForm->setCurrentTabSlug($this->oProp->getCurrentTab());
     $this->oForm->applyConditions();
     $this->oForm->applyFiltersToFields($this, $this->oProp->sClassName);
     $this->oForm->setDynamicElements($this->oProp->aOptions);
     $this->oProp->aFieldTypeDefinitions = AdminPageFramework_FieldTypeRegistration::register($this->oProp->aFieldTypeDefinitions, $this->oProp->sClassName, $this->oMsg);
     $this->oProp->aFieldTypeDefinitions = $this->oUtil->addAndApplyFilter($this, 'field_types_' . $this->oProp->sClassName, $this->oProp->aFieldTypeDefinitions);
     foreach ($this->oForm->aConditionedSections as $_aSection) {
         if (empty($_aSection['help'])) {
             continue;
         }
         $this->addHelpTab(array('page_slug' => $_aSection['page_slug'], 'page_tab_slug' => $_aSection['tab_slug'], 'help_tab_title' => $_aSection['title'], 'help_tab_id' => $_aSection['section_id'], 'help_tab_content' => $_aSection['help'], 'help_tab_sidebar_content' => $_aSection['help_aside'] ? $_aSection['help_aside'] : ""));
     }
     foreach ($this->oForm->aConditionedFields as $_sSectionID => $_aSubSectionOrFields) {
         foreach ($_aSubSectionOrFields as $_sSubSectionIndexOrFieldID => $_aSubSectionOrField) {
             if (is_numeric($_sSubSectionIndexOrFieldID) && is_int($_sSubSectionIndexOrFieldID + 0)) {
                 $_iSubSectionIndex = $_sSubSectionIndexOrFieldID;
                 $_aSubSection = $_aSubSectionOrField;
                 foreach ($_aSubSection as $__sFieldID => $__aField) {
                     AdminPageFramework_FieldTypeRegistration::_setFieldResources($__aField, $this->oProp, $this->oResource);
                 }
                 continue;
             }
             $aField = $_aSubSectionOrField;
             AdminPageFramework_FieldTypeRegistration::_setFieldResources($aField, $this->oProp, $this->oResource);
             if (!empty($aField['help'])) {
                 $this->addHelpTab(array('page_slug' => $aField['page_slug'], 'page_tab_slug' => $aField['tab_slug'], 'help_tab_title' => $aField['section_title'], 'help_tab_id' => $aField['section_id'], 'help_tab_content' => "<span class='contextual-help-tab-title'>" . $aField['title'] . "</span> - " . PHP_EOL . $aField['help'], 'help_tab_sidebar_content' => $aField['help_aside'] ? $aField['help_aside'] : ""));
             }
         }
     }
     $this->oProp->bEnableForm = true;
     $this->_handleSubmittedData();
 }