当前位置: 首页>>代码示例>>PHP>>正文


PHP ot_validate_settings_array函数代码示例

本文整理汇总了PHP中ot_validate_settings_array函数的典型用法代码示例。如果您正苦于以下问题:PHP ot_validate_settings_array函数的具体用法?PHP ot_validate_settings_array怎么用?PHP ot_validate_settings_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ot_validate_settings_array函数的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);
 }
开发者ID:ElectricEasel,项目名称:reflection,代码行数:63,代码来源:ot-functions-admin.php

示例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) {
//.........这里部分代码省略.........
开发者ID:rajilesh,项目名称:optiontree-metabox-ui,代码行数:101,代码来源:taxonomy_meta_box.php


注:本文中的ot_validate_settings_array函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。