• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ot_normalize_css函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ot_insert_css_with_markers

 function ot_insert_css_with_markers($field_id = '', $insertion = '', $meta = false)
 {
     /* missing $field_id or $insertion exit early */
     if ('' == $field_id || '' == $insertion) {
         return;
     }
     /* path to the dynamic.css file */
     $filepath = get_stylesheet_directory() . '/dynamic.css';
     if (is_multisite()) {
         $multisite_filepath = get_stylesheet_directory() . '/dynamic-' . get_current_blog_id() . '.css';
         if (file_exists($multisite_filepath)) {
             $filepath = $multisite_filepath;
         }
     }
     /* allow filter on path */
     $filepath = apply_filters('css_option_file_path', $filepath, $field_id);
     /* grab a copy of the paths array */
     $ot_css_file_paths = get_option('ot_css_file_paths', array());
     if (is_multisite()) {
         $ot_css_file_paths = get_blog_option(get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths);
     }
     /* set the path for this field */
     $ot_css_file_paths[$field_id] = $filepath;
     /* update the paths */
     if (is_multisite()) {
         update_blog_option(get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths);
     } else {
         update_option('ot_css_file_paths', $ot_css_file_paths);
     }
     /* insert CSS into file */
     if (file_exists($filepath)) {
         $insertion = ot_normalize_css($insertion);
         $regex = "/{{([a-zA-Z0-9\\_\\-\\#\\|\\=]+)}}/";
         $marker = $field_id;
         /* Match custom CSS */
         preg_match_all($regex, $insertion, $matches);
         /* Loop through CSS */
         foreach ($matches[0] as $option) {
             $value = '';
             $option_id = str_replace(array('{{', '}}'), '', $option);
             $option_array = explode('|', $option_id);
             $option_type = ot_get_option_type_by_id($option_id);
             /* get the array value */
             if ($meta) {
                 global $post;
                 $value = get_post_meta($post->ID, $option_array[0], true);
             } else {
                 $options = get_option(ot_options_id());
                 if (isset($options[$option_array[0]])) {
                     $value = $options[$option_array[0]];
                 }
             }
             if (is_array($value)) {
                 if (!isset($option_array[1])) {
                     /* Measurement */
                     if (isset($value[0]) && isset($value[1])) {
                         /* set $value with measurement properties */
                         $value = $value[0] . $value[1];
                         /* Colorpicker Opacity */
                     } else {
                         if (isset($value['color']) && isset($value['opacity'])) {
                             /* get the RGB color value */
                             $color = ot_hex2RGB($value['color']);
                             if (is_array($color)) {
                                 $value = 'rgba(' . $color['r'] . ', ' . $color['g'] . ', ' . $color['b'] . ', ' . $value['opacity'] . ')';
                             } else {
                                 if ($color == $value['color']) {
                                     $value = $value['color'];
                                 }
                             }
                             /* Border */
                         } else {
                             if (ot_array_keys_exists($value, array('width', 'unit', 'style', 'color')) && !ot_array_keys_exists($value, array('top', 'right', 'bottom', 'left', 'height', 'inset', 'offset-x', 'offset-y', 'blur-radius', 'spread-radius'))) {
                                 $border = array();
                                 $unit = !empty($value['unit']) ? $value['unit'] : 'px';
                                 if (!empty($value['width'])) {
                                     $border[] = $value['width'] . $unit;
                                 }
                                 if (!empty($value['style'])) {
                                     $border[] = $value['style'];
                                 }
                                 if (!empty($value['color'])) {
                                     $border[] = $value['color'];
                                 }
                                 /* set $value with border properties or empty string */
                                 $value = !empty($border) ? implode(' ', $border) : '';
                                 /* Box Shadow */
                             } else {
                                 if (ot_array_keys_exists($value, array('inset', 'offset-x', 'offset-y', 'blur-radius', 'spread-radius', 'color')) && !ot_array_keys_exists($value, array('width', 'height', 'unit', 'style', 'top', 'right', 'bottom', 'left'))) {
                                     /* set $value with box-shadow properties or empty string */
                                     $value = !empty($value) ? implode(' ', $value) : '';
                                     /* Dimension */
                                 } else {
                                     if (ot_array_keys_exists($value, array('width', 'height', 'unit')) && !ot_array_keys_exists($value, array('style', 'color', 'top', 'right', 'bottom', 'left'))) {
                                         $dimension = array();
                                         $unit = !empty($value['unit']) ? $value['unit'] : 'px';
                                         if (!empty($value['width'])) {
                                             $dimension[] = $value['width'] . $unit;
                                         }
                                         if (!empty($value['height'])) {
//.........这里部分代码省略.........
开发者ID:ardiqghenatya,项目名称:web4,代码行数:101,代码来源:ot-functions-admin.php


示例2: ot_insert_css_with_markers

 function ot_insert_css_with_markers($field_id = '', $insertion = '', $meta = false)
 {
     /* missing $field_id or $insertion exit early */
     if ('' == $field_id || '' == $insertion) {
         return;
     }
     /* path to the dynamic.css file */
     $filepath = get_stylesheet_directory() . '/dynamic.css';
     /* allow filter on path */
     $filepath = apply_filters('css_option_file_path', $filepath, $field_id);
     /* grab a copy of the paths array */
     $ot_css_file_paths = get_option('ot_css_file_paths', array());
     /* set the path for this field */
     $ot_css_file_paths[$field_id] = $filepath;
     /* update the paths */
     update_option('ot_css_file_paths', $ot_css_file_paths);
     /* insert CSS into file */
     if (file_exists($filepath)) {
         $insertion = ot_normalize_css($insertion);
         $regex = "/{{([a-zA-Z0-9\\_\\-\\#\\|\\=]+)}}/";
         $marker = $field_id;
         /* Match custom CSS */
         preg_match_all($regex, $insertion, $matches);
         /* Loop through CSS */
         foreach ($matches[0] as $option) {
             $value = '';
             $option_id = str_replace(array('{{', '}}'), '', $option);
             $option_array = explode('|', $option_id);
             /* get the array value */
             if ($meta) {
                 global $post;
                 $value = get_post_meta($post->ID, $option_array[0], true);
             } else {
                 $options = get_option(ot_options_id());
                 if (isset($options[$option_array[0]])) {
                     $value = $options[$option_array[0]];
                 }
             }
             if (is_array($value)) {
                 if (!isset($option_array[1])) {
                     /* Measurement */
                     if (isset($value[0]) && isset($value[1])) {
                         /* set $value with measurement properties */
                         $value = $value[0] . $value[1];
                         /* typography */
                     } else {
                         if (ot_array_keys_exists($value, array('font-color', 'font-family', 'font-size', 'font-style', 'font-variant', 'font-weight', 'letter-spacing', 'line-height', 'text-decoration', 'text-transform'))) {
                             $font = array();
                             if (!empty($value['font-color'])) {
                                 $font[] = "color: " . $value['font-color'] . ";";
                             }
                             if (!empty($value['font-family'])) {
                                 foreach (ot_recognized_font_families($marker) as $key => $v) {
                                     if ($key == $value['font-family']) {
                                         $font[] = "font-family: " . $v . ";";
                                     }
                                 }
                             }
                             if (!empty($value['font-size'])) {
                                 $font[] = "font-size: " . $value['font-size'] . ";";
                             }
                             if (!empty($value['font-style'])) {
                                 $font[] = "font-style: " . $value['font-style'] . ";";
                             }
                             if (!empty($value['font-variant'])) {
                                 $font[] = "font-variant: " . $value['font-variant'] . ";";
                             }
                             if (!empty($value['font-weight'])) {
                                 $font[] = "font-weight: " . $value['font-weight'] . ";";
                             }
                             if (!empty($value['letter-spacing'])) {
                                 $font[] = "letter-spacing: " . $value['letter-spacing'] . ";";
                             }
                             if (!empty($value['line-height'])) {
                                 $font[] = "line-height: " . $value['line-height'] . ";";
                             }
                             if (!empty($value['text-decoration'])) {
                                 $font[] = "text-decoration: " . $value['text-decoration'] . ";";
                             }
                             if (!empty($value['text-transform'])) {
                                 $font[] = "text-transform: " . $value['text-transform'] . ";";
                             }
                             /* set $value with font properties or empty string */
                             $value = !empty($font) ? implode("\n", $font) : '';
                             /* background */
                         } else {
                             if (ot_array_keys_exists($value, array('background-color', 'background-image', 'background-repeat', 'background-attachment', 'background-position', 'background-size'))) {
                                 $bg = array();
                                 if (!empty($value['background-color'])) {
                                     $bg[] = $value['background-color'];
                                 }
                                 if (!empty($value['background-image'])) {
                                     $bg[] = 'url("' . $value['background-image'] . '")';
                                 }
                                 if (!empty($value['background-repeat'])) {
                                     $bg[] = $value['background-repeat'];
                                 }
                                 if (!empty($value['background-attachment'])) {
                                     $bg[] = $value['background-attachment'];
                                 }
//.........这里部分代码省略.........
开发者ID:ElectricEasel,项目名称:reflection,代码行数:101,代码来源:ot-functions-admin.php


示例3: ot_insert_css_with_markers

 function ot_insert_css_with_markers($field_id = '', $insertion = '', $meta = false)
 {
     /* missing $field_id or $insertion exit early */
     if ('' == $field_id || '' == $insertion) {
         return;
     }
     /* path to the dynamic.css file */
     $filepath = get_stylesheet_directory() . '/dynamic.css';
     if (is_multisite()) {
         $multisite_filepath = get_stylesheet_directory() . '/dynamic-' . get_current_blog_id() . '.css';
         if (file_exists($multisite_filepath)) {
             $filepath = $multisite_filepath;
         }
     }
     /* allow filter on path */
     $filepath = apply_filters('css_option_file_path', $filepath, $field_id);
     /* grab a copy of the paths array */
     $ot_css_file_paths = get_option('ot_css_file_paths', array());
     if (is_multisite()) {
         $ot_css_file_paths = get_blog_option(get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths);
     }
     /* set the path for this field */
     $ot_css_file_paths[$field_id] = $filepath;
     /* update the paths */
     if (is_multisite()) {
         update_blog_option(get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths);
     } else {
         update_option('ot_css_file_paths', $ot_css_file_paths);
     }
     /* insert CSS into file */
     if (file_exists($filepath)) {
         $insertion = ot_normalize_css($insertion);
         $regex = "/{{([a-zA-Z0-9\\_\\-\\#\\|\\=]+)}}/";
         $marker = $field_id;
         /* Match custom CSS */
         preg_match_all($regex, $insertion, $matches);
         /* Loop through CSS */
         foreach ($matches[0] as $option) {
             $value = '';
             $option_array = explode('|', str_replace(array('{{', '}}'), '', $option));
             $option_id = isset($option_array[0]) ? $option_array[0] : '';
             $option_key = isset($option_array[1]) ? $option_array[1] : '';
             $option_type = ot_get_option_type_by_id($option_id);
             $fallback = '';
             // Get the meta array value
             if ($meta) {
                 global $post;
                 $value = get_post_meta($post->ID, $option_id, true);
                 // Get the options array value
             } else {
                 $options = get_option(ot_options_id());
                 if (isset($options[$option_id])) {
                     $value = $options[$option_id];
                 }
             }
             // This in an array of values
             if (is_array($value)) {
                 if (empty($option_key)) {
                     // Measurement
                     if ($option_type == 'measurement') {
                         // Set $value with measurement properties
                         if (isset($value[0]) && isset($value[1])) {
                             $value = $value[0] . $value[1];
                         }
                         // Border
                     } else {
                         if ($option_type == 'border') {
                             $border = array();
                             $unit = !empty($value['unit']) ? $value['unit'] : 'px';
                             if (!empty($value['width'])) {
                                 $border[] = $value['width'] . $unit;
                             }
                             if (!empty($value['style'])) {
                                 $border[] = $value['style'];
                             }
                             if (!empty($value['color'])) {
                                 $border[] = $value['color'];
                             }
                             /* set $value with border properties or empty string */
                             $value = !empty($border) ? implode(' ', $border) : '';
                             // Box Shadow
                         } else {
                             if ($option_type == 'box-shadow') {
                                 /* set $value with box-shadow properties or empty string */
                                 $value = !empty($value) ? implode(' ', $value) : '';
                                 // Dimension
                             } else {
                                 if ($option_type == 'dimension') {
                                     $dimension = array();
                                     $unit = !empty($value['unit']) ? $value['unit'] : 'px';
                                     if (!empty($value['width'])) {
                                         $dimension[] = $value['width'] . $unit;
                                     }
                                     if (!empty($value['height'])) {
                                         $dimension[] = $value['height'] . $unit;
                                     }
                                     // Set $value with dimension properties or empty string
                                     $value = !empty($dimension) ? implode(' ', $dimension) : '';
                                     // Spacing
                                 } else {
//.........这里部分代码省略.........
开发者ID:ex0ample,项目名称:JindaAds,代码行数:101,代码来源:ot-functions-admin.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ot_option_types_array函数代码示例发布时间:2022-05-15
下一篇:
PHP ot_loop_through_sub_settings函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap