本文整理汇总了PHP中fw_akg函数的典型用法代码示例。如果您正苦于以下问题:PHP fw_akg函数的具体用法?PHP fw_akg怎么用?PHP fw_akg使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fw_akg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* @param int $post_id
* @param string $multi_key 'abc' or 'ab/c/def'
* @param bool|null $get_original_value Original value from db, no changes and translations
* @return mixed|null
*/
public static function get($post_id, $multi_key, $get_original_value = null)
{
if ($get_original_value === null) {
$get_original_value = is_admin();
}
if (empty($multi_key)) {
trigger_error('Key not specified', E_USER_WARNING);
return null;
}
$multi_key = explode('/', $multi_key);
$key = array_shift($multi_key);
$multi_key = implode('/', $multi_key);
$cache_key = self::$cache_key . '/' . $post_id . '/' . $key;
try {
$values = FW_Cache::get($cache_key);
} catch (FW_Cache_Not_Found_Exception $e) {
$values = array();
$values['original'] = get_post_meta($post_id, $key, true);
$values['prepared'] = fw_prepare_option_value($values['original']);
FW_Cache::set($cache_key, $values);
}
if (empty($multi_key)) {
return $values[$get_original_value ? 'original' : 'prepared'];
} else {
return fw_akg($multi_key, $values[$get_original_value ? 'original' : 'prepared']);
}
}
示例2: fw_akg
/**
* Recursively find a key's value in array
*
* @param string $keys 'a/b/c'
* @param array|object $array_or_object
* @param null|mixed $default_value
* @param string $keys_delimiter
* @return null|mixed
*/
function fw_akg($keys, &$array_or_object, $default_value = null, $keys_delimiter = '/')
{
if (!is_array($keys)) {
$keys = explode($keys_delimiter, (string) $keys);
}
$key_or_property = array_shift($keys);
if ($key_or_property === null) {
return $default_value;
}
$is_object = is_object($array_or_object);
if ($is_object) {
if (!property_exists($array_or_object, $key_or_property)) {
return $default_value;
}
} else {
if (!is_array($array_or_object) || !array_key_exists($key_or_property, $array_or_object)) {
return $default_value;
}
}
if (isset($keys[0])) {
// not used count() for performance reasons
if ($is_object) {
return fw_akg($keys, $array_or_object->{$key_or_property}, $default_value);
} else {
return fw_akg($keys, $array_or_object[$key_or_property], $default_value);
}
} else {
if ($is_object) {
return $array_or_object->{$key_or_property};
} else {
return $array_or_object[$key_or_property];
}
}
}
示例3: after
public function after($data = array())
{
$update_actions = array('extensions_page' => fw_html_tag('a', array('href' => fw_akg('extensions_page_link', $data, '#'), 'title' => __('Go to extensions page', 'fw'), 'target' => '_parent'), __('Return to Extensions page', 'fw')));
$this->feedback(implode(' | ', (array) $update_actions));
if ($this->result) {
// used for popup ajax form submit result
$this->feedback('<span success></span>');
}
}
示例4: get
/**
* @param string $option_name
* @param string|null $specific_multi_key 'ab/c/def'
* @param null|mixed $default_value If no option found in the database, this value will be returned
* @param bool|null $get_original_value REMOVED https://github.com/ThemeFuse/Unyson/issues/1676
* @return mixed|null
*/
public static function get($option_name, $specific_multi_key = null, $default_value = null, $get_original_value = null)
{
if (!is_null($get_original_value)) {
_doing_it_wrong(__FUNCTION__, '$get_original_value parameter was removed', 'Unyson 2.5.8');
}
$value = get_option($option_name, null);
if (empty($specific_multi_key) && $specific_multi_key !== '0') {
return is_null($value) ? $default_value : $value;
} else {
return fw_akg($specific_multi_key, $value, $default_value);
}
}
示例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: _load
/**
* {@inheritdoc}
*/
protected function _load($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());
return fw_akg($option['fw-storage']['key'], $wp_option_value, $value);
} else {
return get_option($wp_option, $value);
}
} else {
return $value;
}
}
示例7: 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
示例8: _render
protected function _render($atts, $content = null, $tag = '')
{
if (!isset($atts['data_provider']['population_method'])) {
trigger_error(__('No events provider specified for calendar shortcode', 'fw'));
return '<b>Calendar Placeholder</b>';
}
$this->load_data();
$provider = $atts['data_provider']['population_method'];
if (!isset($this->data[$provider])) {
trigger_error(sprintf(__('Unknown events provider "%s" specified for calendar shortcode', 'fw'), $provider));
return '<b>Calendar Placeholder</b>';
}
$ajax_params = apply_filters('fw_shortcode_calendar_ajax_params', array(), $provider, fw_akg('data_provider/' . $provider, $atts));
if (is_array($ajax_params)) {
$ajax_params = array_merge($ajax_params, array('data_provider' => $provider));
} else {
$ajax_params = array('data_provider' => $provider);
}
$wrapper_atts = array('data-extends-ajax-params' => json_encode($ajax_params), 'data-ajax-url' => admin_url('admin-ajax.php'), 'data-template' => $atts['template'], 'data-template-path' => $this->get_declared_URI('/views/'), 'data-first-day' => $atts['first_week_day']);
if ($provider === 'custom') {
$rows = fw_akg('data_provider/custom/custom_events', $atts, array());
$event_sources = array();
if (empty($rows) === false) {
$key = 0;
foreach ($rows as $row) {
if (empty($row['calendar_date_range']['from']) || empty($row['calendar_date_range']['to'])) {
continue;
}
$event_sources[$key]['id'] = $key;
$start = new DateTime($row['calendar_date_range']['from'], new DateTimeZone('GMT'));
$end = new DateTime($row['calendar_date_range']['to'], new DateTimeZone('GMT'));
//set end of all_day event time 23:59:59
if ($start == $end and $end->format('H:i') === '00:00') {
$end->modify('+23 hour');
$end->modify('+59 minutes');
$end->modify('+59 second');
}
$event_sources[$key]['start'] = $start->format('U');
$event_sources[$key]['end'] = $end->format('U');
$event_sources[$key]['title'] = htmlspecialchars_decode($row['title']);
$event_sources[$key]['url'] = $row['url'];
$key++;
}
}
$wrapper_atts['data-event-source'] = json_encode($event_sources);
}
$this->enqueue_static();
return fw_render_view($this->locate_path('/views/view.php'), compact('atts', 'content', 'tag', 'wrapper_atts'));
}
示例9: fw_ext_builder_get_item_width
/**
* Get builder item width data
*
* Default widths are specified in the config, but some builder types can have custom widths
*
* Usage example:
* <div class="<?php echo esc_attr(fw_ext_builder_get_item_width('builder-type', $item['width'] .'/frontend_class')) ?>" >
*
* @param string $builder_type Builder option type (some builders can have different item widths)
* @param null|string $width_id Specify width id (accepts multikey) or leave empty to get all widths
* @param null|mixed $default_value Return this value if specified key does not exist
* @return array
*/
function fw_ext_builder_get_item_width($builder_type, $width_id = null, $default_value = null)
{
try {
$cache_key = fw()->extensions->get('builder')->get_cache_key('item_widths/' . $builder_type);
$widths = FW_Cache::get($cache_key);
} catch (FW_Cache_Not_Found_Exception $e) {
$widths = apply_filters('fw_builder_item_widths:' . $builder_type, fw()->extensions->get('builder')->get_config('default_item_widths'));
FW_Cache::set($cache_key, $widths);
}
if (is_null($width_id)) {
return $widths;
} else {
return fw_akg($width_id, $widths, $default_value);
}
}
示例10: get_config
public function get_config($key = null)
{
if (!$this->config) {
$config_path = $this->path . '/config.php';
if (file_exists($config_path)) {
$vars = fw_get_variables_from_file($config_path, array('cfg' => null));
$this->config = $vars['cfg'];
}
}
if (!is_array($this->config)) {
return null;
} else {
return $key === null ? $this->config : fw_akg($key, $this->config);
}
}
示例11: get
/**
* @param string $option_name
* @param string|null $specific_multi_key 'ab/c/def'
* @param null|mixed $default_value If no option found in the database, this value will be returned
* @param bool|null $get_original_value Original value from db, no changes and translations
* @return mixed|null
*/
public static function get($option_name, $specific_multi_key = null, $default_value = null, $get_original_value = null)
{
if ($get_original_value === null) {
$get_original_value = is_admin();
}
$cache_key = self::$cache_key . '/' . $option_name;
try {
$values = FW_Cache::get($cache_key);
} catch (FW_Cache_Not_Found_Exception $e) {
$values = array();
$values['original'] = get_option($option_name, null);
$values['prepared'] = fw_prepare_option_value($values['original']);
FW_Cache::set($cache_key, $values);
}
return fw_akg(($get_original_value ? 'original' : 'prepared') . (empty($specific_multi_key) ? '' : '/' . $specific_multi_key), $values, $default_value);
}
示例12: _load
/**
* {@inheritdoc}
*/
protected function _load($id, array $option, $value, array $params)
{
if ($post_id = $this->get_post_id($option, $params)) {
$meta_id = $this->get_meta_id($id, $option, $params);
$meta_value = get_post_meta($post_id, $meta_id, true);
if ($meta_value === '' && is_array($value)) {
return $value;
}
if (isset($option['fw-storage']['key'])) {
return fw_akg($option['fw-storage']['key'], $meta_value, $value);
} else {
return $meta_value;
}
} else {
return $value;
}
}
示例13: _render
/**
* @internal
* {@inheritdoc}
*/
protected function _render($id, $option, $data)
{
$options_array = $this->prepare_option($id, $option);
unset($option['attr']['name'], $option['attr']['value']);
if ($option['show_borders']) {
$option['attr']['class'] .= ' fw-option-type-multi-picker-with-borders';
} else {
$option['attr']['class'] .= ' fw-option-type-multi-picker-without-borders';
}
reset($option['picker']);
$picker_key = key($option['picker']);
$picker_type = $option['picker'][$picker_key]['type'];
$picker = $option['picker'][$picker_key];
if (!is_string($picker_value = fw()->backend->option_type($picker_type)->get_value_from_input($picker, isset($data['value'][$picker_key]) ? $data['value'][$picker_key] : null))) {
/**
* Extract the string value that is used as array key
*/
switch ($picker_type) {
case 'icon-v2':
$picker_value = fw_akg('type', $picker_value, 'icon-font');
break;
default:
if (!is_string($picker_value = apply_filters('fw:option-type:multi-picker:string-value:' . $picker_type, $picker_value))) {
trigger_error('[multi-picker] Cannot detect string value for picker type ' . $picker_type, E_USER_WARNING);
$picker_value = '?';
}
}
}
$skip_first = true;
foreach ($options_array as $group_id => &$group) {
if ($skip_first) {
$skip_first = false;
continue;
// first is picker
}
if ($group_id === $id . '-' . $picker_value) {
continue;
// skip selected choice options
}
$options_array[$group_id]['attr']['data-options-template'] = fw()->backend->render_options($options_array[$group_id]['options'], $data['value'], array('id_prefix' => $data['id_prefix'] . $id . '-', 'name_prefix' => $data['name_prefix'] . '[' . $id . ']'));
$options_array[$group_id]['options'] = array();
}
return '<div ' . fw_attr_to_html($option['attr']) . '>' . fw()->backend->render_options($options_array, $data['value'], array('id_prefix' => $data['id_prefix'] . $id . '-', 'name_prefix' => $data['name_prefix'] . '[' . $id . ']')) . '</div>';
}
示例14: _render
protected function _render($id, $option, $data)
{
$wrapper_attr = $option['attr'];
$moment_format = $option['datetime-picker']['moment-format'];
$wrapper_attr['data-min-date'] = fw_akg('datetime-picker/minDate', $option, false);
$wrapper_attr['data-max-date'] = fw_akg('datetime-picker/maxDate', $option, false);
$wrapper_attr['data-extra-formats'] = isset($option['datetime-picker']['extra-formats']) ? json_encode($option['datetime-picker']['extra-formats']) : '';
$wrapper_attr['data-datetime-attr'] = json_encode($option['datetime-picker']);
unset($option['datetime-picker']['moment-format'], $option['datetime-picker']['extra-formats'], $option['attr']['class'], $wrapper_attr['name'], $wrapper_attr['id'], $wrapper_attr['value']);
if (isset($option['datetime-picker']['value'])) {
unset($option['datetime-picker']['value']);
}
$option['datetime-picker']['scrollInput'] = false;
$option['datetime-picker']['lang'] = substr(get_locale(), 0, 2);
$option['attr']['data-moment-format'] = $moment_format;
echo '<div ' . fw_attr_to_html($wrapper_attr) . ' >';
echo fw()->backend->option_type('text')->render($id, $option, $data);
echo '</div>';
}
示例15: get
/**
* @param string $meta_type
* @param int $object_id
* @param string $multi_key 'abc' or 'ab/c/def'
* @param null|mixed $default_value If no option found in the database, this value will be returned
* @param bool|null $get_original_value REMOVED https://github.com/ThemeFuse/Unyson/issues/1676
*
* @return mixed|null
*/
public static function get($meta_type, $object_id, $multi_key, $default_value = null, $get_original_value = null)
{
if (!is_null($get_original_value)) {
_doing_it_wrong(__FUNCTION__, '$get_original_value parameter was removed', 'Unyson 2.5.8');
}
if (empty($multi_key)) {
trigger_error('Key not specified', E_USER_WARNING);
return null;
}
$multi_key = explode('/', $multi_key);
$key = array_shift($multi_key);
$multi_key = implode('/', $multi_key);
$value = get_metadata($meta_type, $object_id, $key, true);
if (empty($multi_key) && $multi_key !== '0') {
return $value;
} else {
return fw_akg($multi_key, $value, $default_value);
}
}