本文整理汇总了PHP中ot_sanitize_option_id函数的典型用法代码示例。如果您正苦于以下问题:PHP ot_sanitize_option_id函数的具体用法?PHP ot_sanitize_option_id怎么用?PHP ot_sanitize_option_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ot_sanitize_option_id函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ot_validate_settings_array
function ot_validate_settings_array($settings = array())
{
/* validate settings */
if (count($settings) > 0) {
/* fix numeric keys since drag & drop will change them */
$settings = array_values($settings);
/* loop through settings */
foreach ($settings as $k => $setting) {
/* remove from array if missing values */
if (!isset($setting['label']) && !isset($setting['id']) || '' == $setting['label'] && '' == $setting['id']) {
unset($settings[$k]);
} else {
/* validate label */
if ('' != $setting['label']) {
$settings[$k]['label'] = wp_kses_post($setting['label']);
}
/* missing label set to unfiltered ID */
if (!isset($setting['label']) || '' == $setting['label']) {
$settings[$k]['label'] = $setting['id'];
/* missing ID set to label */
} else {
if (!isset($setting['id']) || '' == $setting['id']) {
$setting['id'] = wp_kses_post($setting['label']);
}
}
/* sanitize ID once everything has been checked first */
$settings[$k]['id'] = ot_sanitize_option_id(wp_kses_post($setting['id']));
}
/* validate description */
if ('' != $setting['desc']) {
$settings[$k]['desc'] = wp_kses_post($setting['desc']);
}
/* validate choices */
if (isset($setting['choices'])) {
/* loop through choices */
foreach ($setting['choices'] as $ck => $choice) {
/* remove from array if missing values */
if (!isset($choice['label']) && !isset($choice['value']) || '' == $choice['label'] && '' == $choice['value']) {
unset($setting['choices'][$ck]);
} else {
/* missing label set to unfiltered ID */
if (!isset($choice['label']) || '' == $choice['label']) {
$setting['choices'][$ck]['label'] = wp_kses_post($choice['value']);
/* missing value set to label */
} else {
if (!isset($choice['value']) || '' == $choice['value']) {
$setting['choices'][$ck]['value'] = ot_sanitize_option_id(wp_kses_post($choice['label']));
}
}
}
}
/* update keys and push new array values */
$settings[$k]['choices'] = array_values($setting['choices']);
}
/* validate sub settings */
if (isset($setting['settings'])) {
$settings[$k]['settings'] = ot_validate_settings_array($setting['settings']);
}
}
}
/* return array but strip those damn slashes out first!!! */
return ot_stripslashes($settings);
}
示例2: rj_taxonomy_ot_save_settings
function rj_taxonomy_ot_save_settings()
{
if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'rj-ot-taxonomy_metabox') {
rj_ot_admin_scriptss();
rj_ot_admin_styless();
wp_enqueue_script('rj_ot_taxonomy_script', plugin_dir_url(dirname(__FILE__)) . 'js/taxonomy-ot-metabox-ui-settings.js');
}
/* check and verify import settings nonce */
if (isset($_POST['option_tree_settings_nonce']) && wp_verify_nonce($_POST['option_tree_settings_nonce'], 'rj_option_tree_settings_form') && isset($_GET['page']) && $_GET['page'] == 'rj-ot-taxonomy_metabox') {
/* 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) {
//.........这里部分代码省略.........