Inheritance: extends AdminPageFramework_WPUtility_SystemInformation
 /**
  * Extracts the version number from the page contents.
  * 
  * @return      string
  */
 private function _getVersion()
 {
     $_oUtil = new AdminPageFramework_WPUtility();
     $_sPageBody = $this->_getPageBody();
     $_aHeaders = $_oUtil->getScriptData($_sPageBody, '', array('version' => 'Version'));
     return $_oUtil->getElement($_aHeaders, 'version', '');
 }
 /**
  * Triggered when the tab is loaded.
  */
 public function replyToAddFormElements($oAdminPage)
 {
     // Section
     $oAdminPage->addSettingSections($this->sPageSlug, array('section_id' => $this->sSectionID, 'tab_slug' => $this->sTabSlug, 'title' => __('Autocomplete Custom Field Type', 'admin-page-framework-demo'), 'description' => __('This field will show predefined list when the user type something on the input field.', 'admin-page-framework-demo')));
     // Fields
     $oAdminPage->addSettingFields($this->sSectionID, array('type' => 'autocomplete', 'field_id' => 'autocomplete_field', 'title' => __('Default', 'admin-page-framework-demo'), 'description' => __('By default, all the post titles will be fetched in the background and will pop up.', 'admin-page-framework-demo')), array('type' => 'autocomplete', 'field_id' => 'autocomplete_local_data', 'title' => __('Local Data', 'admin-page-framework-demo'), 'settings' => array(array('id' => 7, 'name' => 'Ruby'), array('id' => 11, 'name' => 'Python'), array('id' => 13, 'name' => 'JavaScript'), array('id' => 17, 'name' => 'ActionScript'), array('id' => 19, 'name' => 'Scheme'), array('id' => 23, 'name' => 'Lisp'), array('id' => 29, 'name' => 'C#'), array('id' => 31, 'name' => 'Fortran'), array('id' => 37, 'name' => 'Visual Basic'), array('id' => 41, 'name' => 'C'), array('id' => 43, 'name' => 'C++'), array('id' => 47, 'name' => 'Java')), 'settings2' => array('theme' => 'mac', 'hintText' => __('Type a programming language.', 'admin-page-framework-demo'), 'prePopulate' => array(array('id' => 3, 'name' => 'PHP'), array('id' => 5, 'name' => 'APS'))), 'description' => __('Predefined items are Ruby, Python, JavaScript, ActionScript, Scheme, Lisp, C#, Fortran, Vidual Basic, C, C++, Java.', 'admin-page-framework-demo')), array('type' => 'autocomplete', 'field_id' => 'autocomplete_custom_post_type', 'title' => __('Custom Post Type', 'admin-page-framework-demo'), 'settings' => add_query_arg(array('request' => 'autocomplete', 'post_type' => 'apf_posts') + $_GET, admin_url(AdminPageFramework_WPUtility::getPageNow())), 'settings2' => array('tokenLimit' => 5, 'preventDuplicates' => true, 'theme' => 'facebook', 'searchDelay' => 50), 'description' => __('To set a custom post type, you need to construct the query url. This field is for the titles of this demo plugin\'s custom post type.', 'admin-page-framework-demo')), array('type' => 'autocomplete', 'field_id' => 'autocomplete_mixed_field_types', 'title' => __('Mixed Post Types', 'admin-page-framework-demo'), 'settings' => add_query_arg(array('request' => 'autocomplete', 'post_types' => 'post, page, apf_posts', 'post_status' => 'publish, private') + $_GET, admin_url(AdminPageFramework_WPUtility::getPageNow())), 'settings2' => array('theme' => 'admin_page_framework'), 'description' => __('To search from multiple post types use the <code>post_types</code> argument (not <code>post_type</code>) and pass comma delimited post type slugs.', 'admin-page-framework-demo')), array('type' => 'autocomplete', 'field_id' => 'autocomplete_repeatable_field', 'title' => __('Repeatable', 'admin-page-framework-demo'), 'repeatable' => true), array('type' => 'autocomplete', 'field_id' => 'autocomplete_users', 'title' => __('Search Users', 'admin-page-framework-demo'), 'settings' => add_query_arg(array('request' => 'autocomplete', 'type' => 'user') + $_GET, admin_url(AdminPageFramework_WPUtility::getPageNow())), 'settings2' => array('theme' => 'admin_page_framework', 'hintText' => __('Type a user name.', 'auto-post'), 'preventDuplicates' => true), 'description' => __('To search users, pass the <code>user</code> to the <code>type</code> argument.', 'admin-page-framework-demo')));
 }
 public static function FlushRewriteRules()
 {
     $_bIsFlushed = isset(self::$_bIsFlushed) ? self::$_bIsFlushed : false;
     if ($_bIsFlushed) {
         return;
     }
     flush_rewrite_rules();
     self::$_bIsFlushed = true;
 }
 public function _replyToSetPageLoadInfoInFooter()
 {
     if (isset($_GET['page']) && $_GET['page']) {
         return;
     }
     if (AdminPageFramework_WPUtility::getCurrentPostType() == $this->oProp->sPostType || AdminPageFramework_WPUtility::isPostDefinitionPage($this->oProp->sPostType) || AdminPageFramework_WPUtility::isCustomTaxonomyPage($this->oProp->sPostType)) {
         add_filter('update_footer', array($this, '_replyToGetPageLoadInfo'), 999);
     }
 }
Exemplo n.º 5
0
 private function _getScript()
 {
     // Ensure this inline script is rendered only once.
     if (self::$_bInlineScriptLoaded) {
         return '';
     }
     self::$_bInlineScriptLoaded = true;
     return "<script async defer id='github-bjs' src='" . AdminPageFramework_WPUtility::resolveSRC(APFDEMO_DIRNAME . '/third-party/github-custom-field-type/asset/github-buttons/buttons.js') . "'>" . "</script>";
 }
 public function __construct($sPostType, $aArgs = array(), $sCallerPath = null, $sTextDomain = 'admin-page-framework')
 {
     if (empty($sPostType)) {
         return;
     }
     $this->oProp = new AdminPageFramework_Property_PostType($this, $sCallerPath ? trim($sCallerPath) : (is_admin() && isset($GLOBALS['pagenow']) && in_array($GLOBALS['pagenow'], array('edit.php', 'post.php', 'post-new.php', 'plugins.php', 'tags.php', 'edit-tags.php')) ? AdminPageFramework_Utility::getCallerScriptPath(__FILE__) : null), get_class($this), 'publish_posts', $sTextDomain, 'post_type');
     $this->oProp->sPostType = AdminPageFramework_WPUtility::sanitizeSlug($sPostType);
     $this->oProp->aPostTypeArgs = $aArgs;
     parent::__construct($this->oProp);
     $this->oUtil->addAndDoAction($this, "start_{$this->oProp->sClassName}", $this);
 }
 public function getValue()
 {
     $_aParams = func_get_args();
     $_aDimensionalKeys = $_aParams + array(null, null);
     $_mDefault = null;
     if (is_array($_aDimensionalKeys[0])) {
         $_mDefault = $_aDimensionalKeys[1];
         $_aDimensionalKeys = $_aDimensionalKeys[0];
     }
     return AdminPageFramework_WPUtility::getOption($this->oProp->sOptionKey, empty($_aParams) ? null : $_aDimensionalKeys, $_mDefault, $this->getSavedOptions() + $this->oProp->getDefaultOptions($this->oForm->aFields));
 }
 function start_el(&$sOutput, $oTerm, $iDepth = 0, $aArgs = array(), $iCurrentObjectID = 0)
 {
     $aArgs = $aArgs + array('_name_prefix' => null, '_input_id_prefix' => null, '_attributes' => array(), '_selected_items' => array(), 'taxonomy' => null, 'disabled' => null);
     $_iID = $oTerm->term_id;
     $_sTaxonomySlug = empty($aArgs['taxonomy']) ? 'category' : $aArgs['taxonomy'];
     $_sID = "{$aArgs['_input_id_prefix']}_{$_sTaxonomySlug}_{$_iID}";
     $_sPostCount = $aArgs['show_post_count'] ? " <span class='font-lighter'>(" . $oTerm->count . ")</span>" : '';
     $_aInputAttributes = isset($_aInputAttributes[$_iID]) ? $_aInputAttributes[$_iID] + $aArgs['_attributes'] : $aArgs['_attributes'];
     $_aInputAttributes = array('id' => $_sID, 'value' => 1, 'type' => 'checkbox', 'name' => "{$aArgs['_name_prefix']}[{$_iID}]", 'checked' => in_array($_iID, (array) $aArgs['_selected_items']) ? 'checked' : null) + $_aInputAttributes + array('class' => null);
     $_aInputAttributes['class'] .= ' apf_checkbox';
     $_aLiTagAttributes = array('id' => "list-{$_sID}", 'class' => 'category-list', 'title' => $oTerm->description);
     $sOutput .= "\n" . "<li " . AdminPageFramework_WPUtility::getAttributes($_aLiTagAttributes) . ">" . "<label for='{$_sID}' class='taxonomy-checklist-label'>" . "<input value='0' type='hidden' name='" . $_aInputAttributes['name'] . "' class='apf_checkbox' />" . "<input " . AdminPageFramework_WPUtility::getAttributes($_aInputAttributes) . " />" . esc_html(apply_filters('the_category', $oTerm->name)) . $_sPostCount . "</label>";
 }
 /**
  * Modifies the variable string the opening 'li' tag of the list.
  * 
  * @param       string      $sOutput        
  * @param       object      $oTerm        
  * @param       integer     $iDepth
  * @param       array       $aArgs          The argument passed from the field output.
  * <h4>Structure</h4>
  *  - show_option_all       (string)    Text to display for showing all categories. default: ``
  *  - show_option_none      (string)    Text to display for showing no categories. e.g. `__( 'No categories' )`
  *  - orderby               (string)    Accepts 'name' or 'ID'. What column to use for ordering the terms. e.g. `name`. default: `ID`
  *  - order                 (string)    What direction to order categories. Accepts 'ASC' (ascending) or 'DESC' (descending). default: `ASC`
  *  - title_li              (string)    The string that is inserted before the list starts. Default: __( 'Categories' ),
  *  - echo                  (boolean|integer)   Whether to echo the output or return the output string value.
  *  - hierarchical          (boolean)   Whether to show the terms in a hierarchical structure. 
  *  - depth                 (integer)   The max level to display the hierarchical depth. Default: 0.
  *  - hide_empty            (boolean|integer) Whether to hide terms that have no post associated.
  *  - pad_counts            (boolean|integer) Whether to sum up the post count with the child post counts.
  *  - number                (integer)   The maximum number of terms to display. Default 0.
  *  - exclude               (string)    Comma separated term ID(s) to exclude from the list.
  *  - include               (string)    Comma separated term ID(s) to include in the list.
  *  - child_of              (integer)   Term ID to retrieve child terms of. If multiple taxonomies are passed, $child_of is ignored. Default 0.
  * 
  *  <h4>Not Checked Yet</h4>
  *  - feed                 => '', 
  *  - feed_type             => '',
  *  - feed_image            => '', 
  *  - exclude_tree          => '',  
  *  - current_category      => 0,
  *  - class                 => categories,
  * 
  * <h4>Unverified Items</h4>
  *  - taxonomy              => 'category', // 'post_tag' or any other registered taxonomy slug will work. side note: the framework option will be used
  *  - has_children          => 1,
  *  - option_none_value     (mixed)     Value to use when no taxonomy term is selected.     
  *  - show_count            (bool|int)  Whether to show how many posts are associated with the term. default: `0`  side note: did not take effect
  *  - style                 (string)    'list', side note: Could not confirm whether there are other option besides 'list'.
  *  - use_desc_for_title    (boolean|int) default is 1 - Whether to use the category description as the title attribute. side note: the framework enables this by default.
  * @param       integer     $iCurrentObjectID
  */
 function start_el(&$sOutput, $oTerm, $iDepth = 0, $aArgs = array(), $iCurrentObjectID = 0)
 {
     $aArgs = $aArgs + array('name' => null, 'disabled' => null, 'selected' => array(), 'input_id' => null, 'attributes' => array(), 'taxonomy' => null);
     // Local variables
     $_iID = $oTerm->term_id;
     $_sTaxonomySlug = empty($aArgs['taxonomy']) ? 'category' : $aArgs['taxonomy'];
     $_sID = "{$aArgs['input_id']}_{$_sTaxonomySlug}_{$_iID}";
     // Post count
     $_sPostCount = $aArgs['show_post_count'] ? " <span class='font-lighter'>(" . $oTerm->count . ")</span>" : '';
     // Attributes
     $_aInputAttributes = isset($_aInputAttributes[$_iID]) ? $_aInputAttributes[$_iID] + $aArgs['attributes'] : $aArgs['attributes'];
     $_aInputAttributes = array('id' => $_sID, 'value' => 1, 'type' => 'checkbox', 'name' => "{$aArgs['name']}[{$_iID}]", 'checked' => in_array($_iID, (array) $aArgs['selected']) ? 'checked' : null) + $_aInputAttributes;
     $_aInputAttributes['class'] .= ' apf_checkbox';
     $_aLiTagAttributes = array('id' => "list-{$_sID}", 'class' => 'category-list', 'title' => $oTerm->description);
     // Output - the variable is by reference so the modification takes effect
     $sOutput .= "\n" . "<li " . AdminPageFramework_WPUtility::generateAttributes($_aLiTagAttributes) . ">" . "<label for='{$_sID}' class='taxonomy-checklist-label'>" . "<input value='0' type='hidden' name='{$aArgs['name']}[{$_iID}]' class='apf_checkbox' />" . "<input " . AdminPageFramework_WPUtility::generateAttributes($_aInputAttributes) . " />" . esc_html(apply_filters('the_category', $oTerm->name)) . $_sPostCount . "</label>";
     /* no need to close the </li> tag since it is dealt in the end_el() method. */
 }
 public function __construct($sPostType, $aArguments = array(), $sCallerPath = null, $sTextDomain = 'admin-page-framework')
 {
     if (empty($sPostType)) {
         return;
     }
     $_sProprtyClassName = isset($this->aSubClassNames['oProp']) ? $this->aSubClassNames['oProp'] : 'AdminPageFramework_Property_' . $this->_sStructureType;
     $this->oProp = new $_sProprtyClassName($this, $this->_getCallerScriptPath($sCallerPath), get_class($this), 'publish_posts', $sTextDomain, $this->_sStructureType);
     $this->oProp->sPostType = AdminPageFramework_WPUtility::sanitizeSlug($sPostType);
     $this->oProp->aPostTypeArgs = $aArguments;
     parent::__construct($this->oProp);
 }
 protected function _getOptions()
 {
     return AdminPageFramework_WPUtility::addAndApplyFilter($GLOBALS['aAdminPageFramework']['aPageClasses'][$this->sClassName], 'options_' . $this->sClassName, $this->sOptionKey ? get_site_option($this->sOptionKey, array()) : array());
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * Retrieves the specified field value stored in the options by field ID.
  * 
  * <h4>Example</h4>
  * <code>
  *  $this->addSettingFields(
  *      'number_section',  // section id
  *      array( 
  *          'field_id'          => 'preset_field',
  *          'title'             => __( 'Preset', 'admin-page-framework-demo' ),
  *          'type'              => 'number',
  *      ),
  *      array( 
  *          'field_id'          => 'value_based_on_preset',
  *          'title'             => __( 'Value Based on Preset', 'admin-page-framework-demo' ),
  *          'type'              => 'number',
  *          'default'           => 10 + ( int ) $this->getValue( 
  *              'number_section',   // section id
  *              'preset_field'      // field id
  *          ),
  *      ),    
  *  );
  * </code>
  * 
  * @since       3.3.0
  * @since       3.3.5           Made it respect last input arrays.
  * @param       The key that points the dimensional array key of the options array.
  */
 public function getValue()
 {
     $_aParams = func_get_args();
     return AdminPageFramework_WPUtility::getOption($this->oProp->sOptionKey, $_aParams, null, $this->getSavedOptions() + $this->oProp->getDefaultOptions($this->oForm->aFields));
 }
 public function __construct($sPostType, $aArguments = array(), $sCallerPath = null, $sTextDomain = 'admin-page-framework')
 {
     if (empty($sPostType)) {
         return;
     }
     $this->oProp = new AdminPageFramework_Property_post_type($this, $this->_getCallerScriptPath($sCallerPath), get_class($this), 'publish_posts', $sTextDomain, 'post_type');
     $this->oProp->sPostType = AdminPageFramework_WPUtility::sanitizeSlug($sPostType);
     $this->oProp->aPostTypeArgs = $aArguments;
     parent::__construct($this->oProp);
 }
 /**
  * Returns the specified option value.
  * 
  * @since       3.5.0
  */
 public function get()
 {
     $_mDefault = null;
     $_aKeys = func_get_args();
     if (!isset($_aKeys[0])) {
         return null;
     }
     if (is_array($_aKeys[0])) {
         $_aKeys = $_aKeys[0];
         $_mDefault = isset($_aKeys[1]) ? $_aKeys[1] : null;
     }
     // Now either the section ID or field ID is given.
     return AdminPageFramework_WPUtility::getArrayValueByArrayKeys($this->aOptions, $_aKeys, $_mDefault);
 }
 public static function showDeprecationNotice($sDeprecated, $sAlternative = '', $sProgramName = '')
 {
     $sProgramName = $sProgramName ? $sProgramName : self::getFrameworkName();
     parent::showDeprecationNotice($sDeprecated, $sAlternative, $sProgramName);
 }
Exemplo n.º 18
0
 /**
  * Inserts
  */
 public function replyToInsertDonationButton($sContent)
 {
     return "<div class='donate'>" . "<a href='" . esc_url('http://en.michaeluno.jp/donate') . "' target='_blank' >" . "<img src='" . AdminPageFramework_WPUtility::resolveSRC(APFDEMO_DIRNAME . '/asset/image/donation.gif') . "' alt='" . esc_attr(__('Please donate!', 'admin-page-framework')) . "' />" . "</a>" . "</div>" . $sContent;
 }
 public static function flushRewriteRules()
 {
     if (self::$_bIsFlushed) {
         return;
     }
     flush_rewrite_rules();
     self::$_bIsFlushed = true;
 }
 /**
  * Returns the last user form input array.
  * 
  * @remark      This temporary data is not always set. This is only set when the form needs to show a confirmation message to the user such as for sending an email.
  * @since       3.3.0
  * @since       3.4.1       Moved from `AdminPageFramework_Property_Page`.
  * @internal
  * @return      array   The last input array.
  */
 protected function _getLastInput()
 {
     $_vValue = AdminPageFramework_WPUtility::getTransient('apf_tfd' . md5('temporary_form_data_' . $this->sClassName . get_current_user_id()));
     if (is_array($_vValue)) {
         return $_vValue;
     }
     return array();
 }
 public static function getOption($sOptionKey, $asKey = null, $vDefault = null)
 {
     return AdminPageFramework_WPUtility::getOption($sOptionKey, $asKey, $vDefault);
 }
 public function getValue()
 {
     $_aDimensionalKeys = func_get_args();
     return AdminPageFramework_WPUtility::getOption($this->oProp->sOptionKey, empty($_aDimensionalKeys) ? null : $_aDimensionalKeys, null, $this->getSavedOptions() + $this->oProp->getDefaultOptions($this->oForm->aFields));
 }