本文整理汇总了PHP中fw_aks函数的典型用法代码示例。如果您正苦于以下问题:PHP fw_aks函数的具体用法?PHP fw_aks怎么用?PHP fw_aks使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fw_aks函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
/**
* @param string $meta_type
* @param int $object_id
* @param string $multi_key 'abc' or 'ab/c/def'
* @param array|string|int|bool $set_value
*/
public static function set($meta_type, $object_id, $multi_key, $set_value)
{
if (empty($multi_key)) {
trigger_error('Key not specified', E_USER_WARNING);
return;
}
$multi_key = explode('/', $multi_key);
$key = array_shift($multi_key);
$multi_key = implode('/', $multi_key);
// Make sure meta is added to the post, not a revision.
if ($meta_type === 'post' && ($the_post = wp_is_post_revision($object_id))) {
$object_id = $the_post;
}
$cache_key = self::$cache_key . '/' . $meta_type . '/' . $object_id . '/' . $key;
if (empty($multi_key) && $multi_key !== '0') {
/** Replace entire meta */
fw_update_metadata($meta_type, $object_id, $key, $set_value);
FW_Cache::del($cache_key);
} else {
/** Change only specified key */
$values = array();
$values['original'] = self::get($meta_type, $object_id, $key, true);
$values['prepared'] = self::get($meta_type, $object_id, $key, false);
fw_aks($multi_key, $set_value, $values['original']);
fw_aks($multi_key, fw_prepare_option_value($set_value), $values['prepared']);
FW_Cache::set($cache_key, $values);
fw_update_metadata($meta_type, $object_id, $key, $values['original']);
}
}
示例2: set
/**
* @param int $post_id
* @param string $multi_key 'abc' or 'ab/c/def'
* @param array|string|int|bool $set_value
*/
public static function set($post_id, $multi_key, $set_value)
{
if (empty($multi_key)) {
trigger_error('Key not specified', E_USER_WARNING);
return;
}
$multi_key = explode('/', $multi_key);
$key = array_shift($multi_key);
$multi_key = implode('/', $multi_key);
$cache_key = self::$cache_key . '/' . $post_id . '/' . $key;
if (empty($multi_key) && $multi_key !== '0') {
/** Replace entire meta */
fw_update_post_meta($post_id, $key, $set_value);
FW_Cache::del($cache_key);
} else {
/** Change only specified key */
$values = array();
$values['original'] = self::get($post_id, $key, true);
$values['prepared'] = self::get($post_id, $key, false);
fw_aks($multi_key, $set_value, $values['original']);
fw_aks($multi_key, fw_prepare_option_value($set_value), $values['prepared']);
FW_Cache::set($cache_key, $values);
fw_update_post_meta($post_id, $key, $values['original']);
}
}
示例3: get_set_key
protected static function get_set_key($multikey = null, $set_value = null, &$value)
{
$multikey = self::prepare_key($multikey);
if ($set_value === null) {
// get
return fw_stripslashes_deep_keys($multikey === null ? $value : fw_akg($multikey, $value));
} else {
// set
fw_aks($multikey, fw_addslashes_deep_keys($set_value), $value);
}
}
示例4: set
/**
* Alternative for update_option()
* @param string $option_name
* @param string|null $specific_multi_key
* @param array|string|int|bool $set_value
*/
public static function set($option_name, $specific_multi_key = null, $set_value)
{
if ($specific_multi_key === null) {
// Replace entire option
update_option($option_name, $set_value, false);
} else {
// Change only specified key
$value = self::get($option_name, null, true);
fw_aks($specific_multi_key, $set_value, $value);
update_option($option_name, $value, false);
}
}
示例5: sanitize
public function sanitize($value)
{
$value = json_decode($value, true);
if (is_null($value) || !is_array($value)) {
return null;
}
$POST = array();
foreach ($value as $var) {
fw_aks(fw_html_attr_name_to_array_multi_key($var['name'], true), $var['value'], $POST);
}
$value = fw()->backend->option_type($this->fw_option['type'])->get_value_from_input($this->fw_option, fw_akg(fw_html_attr_name_to_array_multi_key($this->id), $POST));
return $value;
}
示例6: setting_sanitize_callback
public function setting_sanitize_callback($input)
{
$input = json_decode($input, true);
if (is_null($input)) {
return null;
}
$POST = array();
foreach ($input as $var) {
fw_aks(fw_html_attr_name_to_array_multi_key($var['name']), $var['value'], $POST);
}
$value = fw_get_options_values_from_input(array($this->id => $this->fw_option), fw_akg(FW_Option_Type::get_default_name_prefix(), $POST));
$value = array_pop($value);
return $value;
}
开发者ID:alireza--noori,项目名称:initial-portfolio-website-test-,代码行数:14,代码来源:class--fw-customizer-control-option-wrapper.php
示例7: _save
/**
* {@inheritdoc}
*/
protected function _save($id, array $option, $value, array $params)
{
if ($wp_option = $this->get_wp_option($option, $params)) {
if (isset($option['fw-storage']['key'])) {
$wp_option_value = get_option($wp_option, array());
fw_aks($option['fw-storage']['key'], $value, $wp_option_value);
update_option($wp_option, $wp_option_value, false);
unset($wp_option_value);
} else {
update_option($wp_option, $value, false);
}
return fw()->backend->option_type($option['type'])->get_value_from_input(array('type' => $option['type']), null);
} else {
return $value;
}
}
示例8: _save
/**
* {@inheritdoc}
*/
protected function _save($id, array $option, $value, array $params)
{
if ($post_id = $this->get_post_id($option, $params)) {
$meta_id = $this->get_meta_id($id, $option, $params);
if (isset($option['fw-storage']['key'])) {
$meta_value = get_post_meta($post_id, $meta_id, true);
fw_aks($option['fw-storage']['key'], $value, $meta_value);
fw_update_post_meta($post_id, $meta_id, $meta_value);
unset($meta_value);
} else {
fw_update_post_meta($post_id, $meta_id, $value);
}
return fw()->backend->option_type($option['type'])->get_value_from_input(array('type' => $option['type']), null);
} else {
return $value;
}
}
示例9: set
/**
* Alternative for update_option()
* @param string $option_name
* @param string|null $specific_multi_key
* @param array|string|int|bool $set_value
*/
public static function set($option_name, $specific_multi_key = null, $set_value)
{
$cache_key = self::$cache_key . '/' . $option_name;
if ($specific_multi_key === null) {
/** Replace entire option */
update_option($option_name, $set_value, false);
FW_Cache::del($cache_key);
} else {
/** Change only specified key */
$values = array();
$values['original'] = self::get($option_name, null, true);
$values['prepared'] = self::get($option_name, null, false);
fw_aks($specific_multi_key, $set_value, $values['original']);
fw_aks($specific_multi_key, fw_prepare_option_value($set_value), $values['prepared']);
FW_Cache::set($cache_key, $values);
update_option($option_name, $values['original'], false);
}
}
示例10: set
/**
* @param string $meta_type
* @param int $object_id
* @param string $multi_key 'abc' or 'ab/c/def'
* @param array|string|int|bool $set_value
*/
public static function set($meta_type, $object_id, $multi_key, $set_value)
{
if (empty($multi_key)) {
trigger_error('Key not specified', E_USER_WARNING);
return;
}
$multi_key = explode('/', $multi_key);
$key = array_shift($multi_key);
$multi_key = implode('/', $multi_key);
if (empty($multi_key) && $multi_key !== '0') {
// Replace entire meta
fw_update_metadata($meta_type, $object_id, $key, $set_value);
} else {
// Change only specified key
$value = self::get($meta_type, $object_id, $key, true);
fw_aks($multi_key, $set_value, $value);
fw_update_metadata($meta_type, $object_id, $key, $value);
}
}
示例11: set
/**
* @param $keys
* @param $value
* @param $keys_delimiter
*/
public static function set($keys, $value, $keys_delimiter = '/')
{
fw_aks($keys, $value, self::$cache, $keys_delimiter);
self::free_memory();
// call it every time to take care about memory
}
示例12: fw_set_db_customizer_option
/**
* Set a theme customizer option value in database
*
* @param null $option_id Specific option id (accepts multikey). null - all options
* @param mixed $value
*/
function fw_set_db_customizer_option($option_id = null, $value)
{
$db_value = get_theme_mod(FW_Option_Type::get_default_name_prefix(), array());
if (is_null($option_id)) {
$db_value = $value;
} else {
fw_aks($option_id, $value, $db_value);
}
set_theme_mod(FW_Option_Type::get_default_name_prefix(), $db_value);
}
示例13: set
public final function set($item_id = null, $option_id = null, $value, array $extra_data = array())
{
FW_Cache::del($cache_key_values = $this->get_cache_key('values', $item_id, $extra_data));
FW_Cache::del($cache_key_values_processed = $this->get_cache_key('values:processed', $item_id, $extra_data));
try {
$options = FW_Cache::get($cache_key = $this->get_cache_key('options', $item_id, $extra_data));
} catch (FW_Cache_Not_Found_Exception $e) {
FW_Cache::set($cache_key, array());
// prevent recursion
FW_Cache::set($cache_key, $options = fw_extract_only_options($this->get_options($item_id, $extra_data)));
}
$sub_keys = null;
if ($option_id) {
$option_id = explode('/', $option_id);
// 'option_id/sub/keys'
$_option_id = array_shift($option_id);
// 'option_id'
$sub_keys = empty($option_id) ? null : implode('/', $option_id);
// 'sub/keys'
$option_id = $_option_id;
unset($_option_id);
$old_values = is_array($old_values = $this->get_values($item_id, $extra_data)) ? $old_values : array();
$old_value = isset($old_values[$option_id]) ? $old_values[$option_id] : null;
if ($sub_keys) {
// update sub_key in old_value and use the entire value
$new_value = $old_value;
fw_aks($sub_keys, $value, $new_value);
$value = $new_value;
unset($new_value);
$old_value = fw_akg($sub_keys, $old_value);
}
if (isset($options[$option_id])) {
$value = fw()->backend->option_type($options[$option_id]['type'])->storage_save($option_id, $options[$option_id], $value, $this->get_fw_storage_params($item_id, $extra_data));
}
$old_values[$option_id] = $value;
$this->set_values($item_id, $old_values, $extra_data);
unset($old_values);
} else {
$old_value = is_array($old_values = $this->get_values($item_id, $extra_data)) ? $old_values : array();
if (!is_array($value)) {
$value = array();
}
foreach ($value as $_option_id => $_option_value) {
if (isset($options[$_option_id])) {
$value[$_option_id] = fw()->backend->option_type($options[$_option_id]['type'])->storage_save($_option_id, $options[$_option_id], $_option_value, $this->get_fw_storage_params($item_id, $extra_data));
}
}
$this->set_values($item_id, $value, $extra_data);
}
FW_Cache::del($cache_key_values);
// fixes https://github.com/ThemeFuse/Unyson/issues/1538
FW_Cache::del($cache_key_values_processed);
$this->_after_set($item_id, $option_id, $sub_keys, $old_value, $extra_data);
}
示例14: _fw_update_adapter
private function _fw_update_adapter($allowed_places)
{
$db = $this->get_db();
fw_aks('allowed_places', $allowed_places, $db);
update_option($this->wp_option_sidebar_settings, $db, false);
}
示例15: fw_set_db_extension_user_data
/**
* @param int $user_id
* @param string $extension_name
* @param mixed $value
* @param string $keys
*
* In case the extension doesn't exist or is disabled, or the value is equal to previous, returns false
*
* @return bool|int
*/
function fw_set_db_extension_user_data($user_id, $extension_name, $value, $keys = null)
{
if (!fw()->extensions->get($extension_name)) {
trigger_error('Invalid extension: ' . $extension_name, E_USER_WARNING);
return false;
}
$data = get_user_meta($user_id, 'fw_data', true);
if ($keys == null) {
fw_aks($extension_name, $value, $data);
} else {
fw_aks($extension_name . '/' . $keys, $value, $data);
}
return fw_update_user_meta($user_id, 'fw_data', $data);
}