/** * Sets the aOptions property array in the property object. * * This array will be referred later in the getFieldOutput() method. * * @since unknown * @since 3.0.0 the scope is changed to protected as the taxonomy field class redefines it. * @internal * @todo Add the `options_{instantiated class name}` filter. */ protected function _setOptionArray($iPostID, $aFields) { if (!is_array($aFields)) { return; } if (!is_numeric($iPostID) || !is_int($iPostID + 0)) { return; } $this->oProp->aOptions = is_array($this->oProp->aOptions) ? $this->oProp->aOptions : array(); foreach ($aFields as $_sSectionID => $_aFields) { if ('_default' == $_sSectionID) { foreach ($_aFields as $_aField) { $this->oProp->aOptions[$_aField['field_id']] = get_post_meta($iPostID, $_aField['field_id'], true); } } $this->oProp->aOptions[$_sSectionID] = get_post_meta($iPostID, $_sSectionID, true); } // Apply the filter to let third party scripts to set own options array. $this->oProp->aOptions = AdminPageFramework_WPUtility::addAndApplyFilter($this, 'options_' . $this->oProp->sClassName, $this->oProp->aOptions); $_aLastInput = isset($_GET['field_errors']) && $_GET['field_errors'] ? $this->oProp->aLastInput : array(); $this->oProp->aOptions = empty($this->oProp->aOptions) ? array() : AdminPageFramework_WPUtility::getAsArray($this->oProp->aOptions); $this->oProp->aOptions = $_aLastInput + $this->oProp->aOptions; }
protected function _getOptions() { return AdminPageFramework_WPUtility::addAndApplyFilter($GLOBALS['aAdminPageFramework']['aPageClasses'][$this->sClassName], 'options_' . $this->sClassName, $this->sOptionKey ? get_site_option($this->sOptionKey, array()) : array()); }
/** * Returns the option array. * * @since 3.1.0 * @since 3.3.0 Forced to return an array as it is possible that the options value get modified by third party scripts. * @internal * @return array The options array. */ protected function _getOptions() { $_aOptions = AdminPageFramework_WPUtility::addAndApplyFilter($this->oCaller, 'options_' . $this->sClassName, $this->sOptionKey ? get_option($this->sOptionKey, array()) : array()); // @todo examine whether it is appropriate to merge with $_aLastInput or it should be done in the getSavedOptions() factory method. // It seems it is better to merge the last input array here because this method is only called once when the aOptions property is first accessed // while getSavedOptions() method is called every time a field is processed for outputs. // However, in getSavedOptions, also the last input array is merged when the 'confirmation' query key is set, // that should be done here. $_aLastInput = isset($_GET['field_errors']) && $_GET['field_errors'] ? $this->_getLastInput() : array(); $_aOptions = empty($_aOptions) ? array() : AdminPageFramework_WPUtility::getAsArray($_aOptions); $_aOptions = $_aLastInput + $_aOptions; return $_aOptions; }