本文整理汇总了PHP中ot_wpml_unregister_string函数的典型用法代码示例。如果您正苦于以下问题:PHP ot_wpml_unregister_string函数的具体用法?PHP ot_wpml_unregister_string怎么用?PHP ot_wpml_unregister_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ot_wpml_unregister_string函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: sanitize_callback
/**
* Sanitize callback for register_setting()
*
* @return string
*
* @access public
* @since 2.0
*/
public function sanitize_callback($input)
{
/* loop through options */
foreach ((array) $this->options as $option) {
/* loop through pages */
foreach ((array) $this->get_pages($option) as $page) {
/* loop through page settings */
foreach ((array) $this->get_the_settings($page) as $setting) {
/* verify setting has a type & value */
if (isset($setting['type']) && isset($input[$setting['id']])) {
/* get the defaults */
$current_settings = get_option('option_tree_settings');
$current_options = get_option($option['id']);
/* validate setting */
if (is_array($input[$setting['id']]) && in_array($setting['type'], array('list-item', 'slider'))) {
/* required title setting */
$required_setting = array(array('id' => 'title', 'label' => __('Title', 'option-tree'), 'desc' => '', 'std' => '', 'type' => 'text', 'rows' => '', 'class' => 'option-tree-setting-title', 'post_type' => '', 'choices' => array()));
/* get the settings array */
$settings = isset($_POST[$setting['id'] . '_settings_array']) ? unserialize(ot_decode($_POST[$setting['id'] . '_settings_array'])) : array();
/* settings are empty for some odd ass reason get the defaults */
if (empty($settings)) {
$settings = 'slider' == $setting['type'] ? ot_slider_settings($setting['id']) : ot_list_item_settings($setting['id']);
}
/* merge the two settings array */
$settings = array_merge($required_setting, $settings);
/* create an empty WPML id array */
$wpml_ids = array();
foreach ($input[$setting['id']] as $k => $setting_array) {
foreach ($settings as $sub_setting) {
/* setup the WPML ID */
$wpml_id = $setting['id'] . '_' . $sub_setting['id'] . '_' . $k;
/* add id to array */
$wpml_ids[] = $wpml_id;
/* verify sub setting has a type & value */
if (isset($sub_setting['type']) && isset($input[$setting['id']][$k][$sub_setting['id']])) {
/* validate setting */
$input[$setting['id']][$k][$sub_setting['id']] = ot_validate_setting($input[$setting['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'], $wpml_id);
}
}
}
} else {
$input[$setting['id']] = ot_validate_setting($input[$setting['id']], $setting['type'], $setting['id'], $setting['id']);
}
}
/* unregister WPML strings that were deleted from lists and sliders */
if (isset($current_settings['settings']) && isset($setting['type']) && in_array($setting['type'], array('list-item', 'slider'))) {
if (!isset($wpml_ids)) {
$wpml_ids = array();
}
foreach ($current_settings['settings'] as $check_setting) {
if ($setting['id'] == $check_setting['id'] && !empty($current_options[$setting['id']])) {
foreach ($current_options[$setting['id']] as $key => $value) {
foreach ($value as $ckey => $cvalue) {
$id = $setting['id'] . '_' . $ckey . '_' . $key;
if (!in_array($id, $wpml_ids)) {
ot_wpml_unregister_string($id);
}
}
}
}
}
}
}
}
}
return $input;
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:75,代码来源:ot-settings-api.php
示例2: ot_save_settings
function ot_save_settings()
{
/* check and verify import settings nonce */
if (isset($_POST['option_tree_settings_nonce']) && wp_verify_nonce($_POST['option_tree_settings_nonce'], 'option_tree_settings_form')) {
/* settings value */
$settings = isset($_POST[ot_settings_id()]) ? $_POST[ot_settings_id()] : '';
/* validate sections */
if (isset($settings['sections'])) {
/* fix numeric keys since drag & drop will change them */
$settings['sections'] = array_values($settings['sections']);
/* loop through sections */
foreach ($settings['sections'] as $k => $section) {
/* remove from array if missing values */
if (!isset($section['title']) && !isset($section['id']) || '' == $section['title'] && '' == $section['id']) {
unset($settings['sections'][$k]);
} else {
/* validate label */
if ('' != $section['title']) {
$settings['sections'][$k]['title'] = wp_kses_post($section['title']);
}
/* missing title set to unfiltered ID */
if (!isset($section['title']) || '' == $section['title']) {
$settings['sections'][$k]['title'] = wp_kses_post($section['id']);
/* missing ID set to title */
} else {
if (!isset($section['id']) || '' == $section['id']) {
$section['id'] = wp_kses_post($section['title']);
}
}
/* sanitize ID once everything has been checked first */
$settings['sections'][$k]['id'] = ot_sanitize_option_id(wp_kses_post($section['id']));
}
}
$settings['sections'] = ot_stripslashes($settings['sections']);
}
/* validate settings by looping over array as many times as it takes */
if (isset($settings['settings'])) {
$settings['settings'] = ot_validate_settings_array($settings['settings']);
}
/* validate contextual_help */
if (isset($settings['contextual_help']['content'])) {
/* fix numeric keys since drag & drop will change them */
$settings['contextual_help']['content'] = array_values($settings['contextual_help']['content']);
/* loop through content */
foreach ($settings['contextual_help']['content'] as $k => $content) {
/* remove from array if missing values */
if (!isset($content['title']) && !isset($content['id']) || '' == $content['title'] && '' == $content['id']) {
unset($settings['contextual_help']['content'][$k]);
} else {
/* validate label */
if ('' != $content['title']) {
$settings['contextual_help']['content'][$k]['title'] = wp_kses_post($content['title']);
}
/* missing title set to unfiltered ID */
if (!isset($content['title']) || '' == $content['title']) {
$settings['contextual_help']['content'][$k]['title'] = wp_kses_post($content['id']);
/* missing ID set to title */
} else {
if (!isset($content['id']) || '' == $content['id']) {
$content['id'] = wp_kses_post($content['title']);
}
}
/* sanitize ID once everything has been checked first */
$settings['contextual_help']['content'][$k]['id'] = ot_sanitize_option_id(wp_kses_post($content['id']));
}
/* validate textarea description */
if (isset($content['content'])) {
$settings['contextual_help']['content'][$k]['content'] = wp_kses_post($content['content']);
}
}
}
/* validate contextual_help sidebar */
if (isset($settings['contextual_help']['sidebar'])) {
$settings['contextual_help']['sidebar'] = wp_kses_post($settings['contextual_help']['sidebar']);
}
$settings['contextual_help'] = ot_stripslashes($settings['contextual_help']);
/* default message */
$message = 'failed';
/* is array: save & show success message */
if (is_array($settings)) {
/* WPML unregister ID's that have been removed */
if (function_exists('icl_unregister_string')) {
$current = get_option(ot_settings_id());
$options = get_option(ot_options_id());
if (isset($current['settings'])) {
/* Empty ID array */
$new_ids = array();
/* Build the WPML IDs array */
foreach ($settings['settings'] as $setting) {
if ($setting['id']) {
$new_ids[] = $setting['id'];
}
}
/* Remove missing IDs from WPML */
foreach ($current['settings'] as $current_setting) {
if (!in_array($current_setting['id'], $new_ids)) {
if (!empty($options[$current_setting['id']]) && in_array($current_setting['type'], array('list-item', 'slider'))) {
foreach ($options[$current_setting['id']] as $key => $value) {
foreach ($value as $ckey => $cvalue) {
ot_wpml_unregister_string($current_setting['id'] . '_' . $ckey . '_' . $key);
//.........这里部分代码省略.........
开发者ID:ElectricEasel,项目名称:reflection,代码行数:101,代码来源:ot-functions-admin.php
注:本文中的ot_wpml_unregister_string函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论