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


PHP ot_wpml_register_string函数代码示例

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


在下文中一共展示了ot_wpml_register_string函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ot_validate_setting

 function ot_validate_setting($input, $type, $field_id, $wmpl_id = '')
 {
     /* exit early if missing data */
     if (!$input || !$type || !$field_id) {
         return $input;
     }
     $input = apply_filters('ot_validate_setting', $input, $type, $field_id);
     /* WPML Register and Unregister strings */
     if (!empty($wmpl_id)) {
         /* Allow filtering on the WPML option types */
         $single_string_types = apply_filters('ot_wpml_option_types', array('text', 'textarea', 'textarea-simple'));
         if (in_array($type, $single_string_types)) {
             if (!empty($input)) {
                 ot_wpml_register_string($wmpl_id, $input);
             } else {
                 ot_wpml_unregister_string($wmpl_id);
             }
         }
     }
     if ('background' == $type) {
         $input['background-color'] = ot_validate_setting($input['background-color'], 'colorpicker', $field_id);
         $input['background-image'] = ot_validate_setting($input['background-image'], 'upload', $field_id);
         // Loop over array and check for values
         foreach ((array) $input as $key => $value) {
             if (!empty($value)) {
                 $has_value = true;
             }
         }
         // No value; set to empty
         if (!isset($has_value)) {
             $input = '';
         }
     } else {
         if ('colorpicker' == $type) {
             /* return empty & set error */
             if (0 === preg_match('/^#([a-f0-9]{6}|[a-f0-9]{3})$/i', $input)) {
                 $input = '';
                 add_settings_error('option-tree', 'invalid_hex', __('The Colorpicker only allows valid hexadecimal values.', 'option-tree'), 'error');
             }
         } else {
             if (in_array($type, array('css', 'text', 'textarea', 'textarea-simple'))) {
                 if (!current_user_can('unfiltered_html') && OT_ALLOW_UNFILTERED_HTML == false) {
                     $input = wp_kses_post($input);
                 }
             } else {
                 if ('measurement' == $type) {
                     $input[0] = sanitize_text_field($input[0]);
                     // No value; set to empty
                     if (empty($input[0]) && empty($input[1])) {
                         $input = '';
                     }
                 } else {
                     if ('typography' == $type && isset($input['font-color'])) {
                         $input['font-color'] = ot_validate_setting($input['font-color'], 'colorpicker', $field_id);
                         // Loop over array and check for values
                         foreach ($input as $key => $value) {
                             if (!empty($value)) {
                                 $has_value = true;
                             }
                         }
                         // No value; set to empty
                         if (!isset($has_value)) {
                             $input = '';
                         }
                     } else {
                         if ('upload' == $type) {
                             $input = sanitize_text_field($input);
                         } else {
                             if ('gallery' == $type) {
                                 $input = trim($input);
                             } else {
                                 if ('social-links' == $type) {
                                     // Loop over array and check for values, plus sanitize the text field
                                     foreach ((array) $input as $key => $value) {
                                         if (!empty($value)) {
                                             $has_value = true;
                                             $input[$key] = sanitize_text_field($value);
                                         }
                                     }
                                     // No value; set to empty
                                     if (!isset($has_value)) {
                                         $input = '';
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $input = apply_filters('ot_after_validate_setting', $input, $type, $field_id);
     return $input;
 }
开发者ID:ElectricEasel,项目名称:reflection,代码行数:94,代码来源:ot-functions-admin.php

示例2: ot_validate_setting

 function ot_validate_setting($input, $type, $field_id, $wmpl_id = '')
 {
     /* exit early if missing data */
     if (!$input || !$type || !$field_id) {
         return $input;
     }
     $input = apply_filters('ot_validate_setting', $input, $type, $field_id);
     /* WPML Register and Unregister strings */
     if (!empty($wmpl_id)) {
         /* Allow filtering on the WPML option types */
         $single_string_types = apply_filters('ot_wpml_option_types', array('text', 'textarea', 'textarea-simple'));
         if (in_array($type, $single_string_types)) {
             if (!empty($input)) {
                 ot_wpml_register_string($wmpl_id, $input);
             } else {
                 ot_wpml_unregister_string($wmpl_id);
             }
         }
     }
     if ('background' == $type) {
         $input['background-color'] = ot_validate_setting($input['background-color'], 'colorpicker', $field_id);
         $input['background-image'] = ot_validate_setting($input['background-image'], 'upload', $field_id);
         // Loop over array and check for values
         foreach ((array) $input as $key => $value) {
             if (!empty($value)) {
                 $has_value = true;
             }
         }
         // No value; set to empty
         if (!isset($has_value)) {
             $input = '';
         }
     } else {
         if ('border' == $type) {
             // Loop over array and set errors or unset key from array.
             foreach ($input as $key => $value) {
                 // Validate width
                 if ($key == 'width' && !empty($value) && !is_numeric($value)) {
                     $input[$key] = '0';
                     add_settings_error('option-tree', 'invalid_border_width', sprintf(__('The %s input field for %s only allows numeric values.', 'option-tree'), '<code>width</code>', '<code>' . $field_id . '</code>'), 'error');
                 }
                 // Validate color
                 if ($key == 'color' && !empty($value) && 0 === preg_match('/^#([a-f0-9]{6}|[a-f0-9]{3})$/i', $value)) {
                     $input[$key] = '';
                     $value = '';
                     add_settings_error('option-tree', 'invalid_hex', __('The Colorpicker only allows valid hexadecimal values.', 'option-tree'), 'error');
                 }
                 // Unset keys with empty values.
                 if (empty($value)) {
                     unset($input[$key]);
                 }
             }
             if (empty($input)) {
                 $input = '';
             }
         } else {
             if ('box-shadow' == $type) {
                 // Validate inset
                 $input['inset'] = isset($input['inset']) ? 'inset' : '';
                 // Validate offset-x
                 $input['offset-x'] = ot_validate_setting($input['offset-x'], 'text', $field_id);
                 // Validate offset-y
                 $input['offset-y'] = ot_validate_setting($input['offset-y'], 'text', $field_id);
                 // Validate blur-radius
                 $input['blur-radius'] = ot_validate_setting($input['blur-radius'], 'text', $field_id);
                 // Validate spread-radius
                 $input['spread-radius'] = ot_validate_setting($input['spread-radius'], 'text', $field_id);
                 // Validate color
                 $input['color'] = ot_validate_setting($input['color'], 'colorpicker', $field_id);
                 // Unset keys with empty values.
                 foreach ($input as $key => $value) {
                     if (empty($value)) {
                         unset($input[$key]);
                     }
                 }
                 // Set empty array to empty string.
                 if (empty($input)) {
                     $input = '';
                 }
             } else {
                 if ('colorpicker' == $type) {
                     /* return empty & set error */
                     if (0 === preg_match('/^#([a-f0-9]{6}|[a-f0-9]{3})$/i', $input)) {
                         $input = '';
                         add_settings_error('option-tree', 'invalid_hex', sprintf(__('The %s Colorpicker only allows valid hexadecimal values.', 'option-tree'), '<code>' . $field_id . '</code>'), 'error');
                     }
                 } else {
                     if ('colorpicker-opacity' == $type) {
                         // Validate color
                         $input['color'] = ot_validate_setting($input['color'], 'colorpicker', $field_id);
                         // Unset keys with empty values.
                         foreach ($input as $key => $value) {
                             if (empty($value)) {
                                 unset($input[$key]);
                             }
                         }
                         // Set empty array to empty string.
                         if (empty($input)) {
                             $input = '';
                         }
//.........这里部分代码省略.........
开发者ID:ardiqghenatya,项目名称:web4,代码行数:101,代码来源:ot-functions-admin.php


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