コード例 #1
0
ファイル: database.php プロジェクト: isatrio/Unyson
/**
 * Get extension's settings option value from the database
 *
 * @param string $extension_name
 * @param string|null $option_id
 * @param null|mixed $default_value If no option found in the database, this value will be returned
 * @param null|bool $get_original_value Original value is that with no translations and other changes
 *
 * @return mixed|null
 */
function fw_get_db_ext_settings_option($extension_name, $option_id = null, $default_value = null, $get_original_value = null)
{
    if (!($extension = fw()->extensions->get($extension_name))) {
        trigger_error('Invalid extension: ' . $extension_name, E_USER_WARNING);
        return null;
    }
    $value = FW_WP_Option::get('fw_ext_settings_options:' . $extension_name, $option_id, $default_value, $get_original_value);
    if (is_null($value)) {
        /**
         * Maybe the options was never saved or the given option id does not exists
         * Extract the default values from the options array and try to find there the option id
         */
        $cache_key = 'fw_default_options_values/ext_settings:' . $extension_name;
        try {
            $all_options_values = FW_Cache::get($cache_key);
        } catch (FW_Cache_Not_Found_Exception $e) {
            // extract the default values from options array
            $all_options_values = fw_get_options_values_from_input($extension->get_settings_options(), array());
            FW_Cache::set($cache_key, $all_options_values);
        }
        if (empty($option_id)) {
            // option id not specified, return all options values
            return $all_options_values;
        } else {
            return fw_akg($option_id, $all_options_values, $default_value);
        }
    } else {
        return $value;
    }
}
コード例 #2
0
 public function get_favorites()
 {
     return FW_WP_Option::get($this->key, 'type', array());
 }
コード例 #3
0
ファイル: database.php プロジェクト: AdsonCicilioti/Unyson
/**
 * Get some extension's data from database
 *
 * @param string $extension_name Name of the extension that owns the data
 * @param string|null $multi_key The key of the data you want to get. null - all data
 * @param null|bool $get_original_value  Original value is that with no translations and other changes
 * @return mixed|null
 */
function fw_get_db_extension_data($extension_name, $multi_key = null, $get_original_value = null)
{
    if (!fw()->extensions->get($extension_name)) {
        trigger_error('Invalid extension: ' . $extension_name, E_USER_WARNING);
        return;
    }
    if ($multi_key) {
        $multi_key = $extension_name . '/' . $multi_key;
    } else {
        $multi_key = $extension_name;
    }
    return FW_WP_Option::get('fw_extensions', $multi_key, $get_original_value);
}
コード例 #4
0
ファイル: database.php プロジェクト: puriwp/Theme-Framework
 protected function get_values($item_id, array $extra_data = array())
 {
     return FW_WP_Option::get('fw_ext_settings_options:' . $item_id, null, array());
 }