/**
  * @param FW_Access_Key $access_key
  * @param $type
  *
  * @return FW_Type|null
  * @internal
  * @since 2.5.12
  */
 public function _get_type(FW_Access_Key $access_key, $type)
 {
     if (!isset($this->access_keys[$access_key->get_key()])) {
         trigger_error('Method call denied', E_USER_ERROR);
     }
     return isset($this->types[$type]) ? $this->types[$type] : null;
 }
示例#2
0
/**
 * @param null|string $type
 * @return FW_Option_Storage_Type|FW_Option_Storage_Type[]|null
 * @since 2.5.0
 */
function fw_db_option_storage_type($type = null)
{
    static $types = null;
    if (is_null($types)) {
        $dir = fw_get_framework_directory('/includes/option-storage');
        if (!class_exists('FW_Option_Storage_Type')) {
            require_once $dir . '/class-fw-option-storage-type.php';
        }
        if (!class_exists('_FW_Option_Storage_Type_Register')) {
            require_once $dir . '/class--fw-option-storage-type-register.php';
        }
        $access_key = new FW_Access_Key('fw:option-storage-register');
        $register = new _FW_Option_Storage_Type_Register($access_key->get_key());
        require_once $dir . '/type/class-fw-option-storage-type-post-meta.php';
        $register->register(new FW_Option_Storage_Type_Post_Meta());
        require_once $dir . '/type/class-fw-option-storage-type-wp-option.php';
        $register->register(new FW_Option_Storage_Type_WP_Option());
        do_action('fw:option-storage-types:register', $register);
        $types = $register->_get_types($access_key);
    }
    if (empty($type)) {
        return $types;
    } elseif (isset($types[$type])) {
        return $types[$type];
    } else {
        return null;
    }
}
 /**
  * @param FW_Access_Key $access_key
  *
  * @return FW_Ext_Backups_Task_Type[]
  * @internal
  */
 public function _get_task_types(FW_Access_Key $access_key)
 {
     if ($access_key->get_key() !== 'fw:ext:backups:tasks') {
         trigger_error('Method call denied', E_USER_ERROR);
     }
     return $this->task_types;
 }
 public final function __construct(FW_Access_Key $access_key)
 {
     if ($access_key->get_key() !== 'fw:ext:backups') {
         // only the Backups extension can create instances
         trigger_error(__METHOD__ . ' denied', E_USER_ERROR);
     }
 }
 /**
  * @param FW_Access_Key $access_key
  * @internal
  * This must be called right after an instance of builder item type has been created
  * and was added to the registered array, so it is available through
  * builder->get_item_types()
  */
 public final function _call_init($access_key)
 {
     if ($access_key->get_key() !== 'fw_ext_builder_option_type') {
         trigger_error('Method call not allowed', E_USER_ERROR);
     }
     if (method_exists($this, '_init')) {
         $this->_init();
     }
 }
示例#6
0
 /**
  * @param FW_Access_Key $access_key
  * @param string|FW_Container_Type $container_type_class
  *
  * @internal
  */
 public function _register_container_type(FW_Access_Key $access_key, $container_type_class)
 {
     if ($access_key->get_key() !== 'fw_container_type') {
         trigger_error('Call denied', E_USER_ERROR);
     }
     $this->register_container_type($container_type_class);
 }
示例#7
0
 /**
  * Give extensions possibility to access their active_tree
  * @internal
  */
 public function _get_extension_tree(FW_Access_Key $access_key, $extension_name)
 {
     if ($access_key->get_key() !== 'extension') {
         trigger_error('Call denied', E_USER_ERROR);
     }
     return self::$extension_to_active_tree[$extension_name];
 }
 /**
  * @internal
  * @param FW_Access_Key $access_key
  * @return mixed
  */
 public final function _call_init($access_key)
 {
     if ($access_key->get_key() !== 'fw_extensions') {
         trigger_error(__METHOD__ . ' denied', E_USER_ERROR);
     }
     return $this->_init();
 }
 /**
  * @param FW_Access_Key $access_Key
  * @return int
  * @internal
  * @since 2.0.3
  */
 public function _get_demos_count(FW_Access_Key $access_Key)
 {
     if ($access_Key->get_key() !== 'fw:ext:backups-demo:helper:count') {
         trigger_error('Method call denied', E_USER_ERROR);
     }
     return count($this->get_demos());
 }
 /**
  * @param FW_Access_Key $access_key
  *
  * @return bool
  * @internal
  */
 public function _request_next_step_execution(FW_Access_Key $access_key)
 {
     if (!in_array($access_key->get_key(), array('fw:ext:backups', 'fw:ext:backups-demo'))) {
         trigger_error('Method call denied', E_USER_ERROR);
     }
     if (file_exists($path = $this->get_executed_tasks_path()) && ($mtime = filemtime($path)) && time() - $mtime <= 30) {
         /**
          * Do nothing if the file was modified recently
          * that means the execution is running and no need to do the request
          */
         return;
     }
     return $this->request_next_step_execution();
 }