本文整理汇总了PHP中safecss_class函数的典型用法代码示例。如果您正苦于以下问题:PHP safecss_class函数的具体用法?PHP safecss_class怎么用?PHP safecss_class使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了safecss_class函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filter_attr
static function filter_attr($css, $element = 'div')
{
safecss_class();
$css = $element . ' {' . $css . '}';
$csstidy = new csstidy();
$csstidy->optimise = new safecss($csstidy);
$csstidy->set_cfg('remove_bslash', false);
$csstidy->set_cfg('compress_colors', false);
$csstidy->set_cfg('compress_font-weight', false);
$csstidy->set_cfg('discard_invalid_properties', true);
$csstidy->set_cfg('merge_selectors', false);
$csstidy->set_cfg('remove_last_;', false);
$csstidy->set_cfg('css_level', 'CSS3.0');
$css = preg_replace('/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $css);
$css = wp_kses_split($css, array(), array());
$csstidy->parse($css);
$css = $csstidy->print->plain();
$css = str_replace(array("\n", "\r", "\t"), '', $css);
preg_match("/^{$element}\\s*{(.*)}\\s*\$/", $css, $matches);
if (empty($matches[1])) {
return '';
}
return $matches[1];
}
示例2: custom_css_minify
function custom_css_minify($css)
{
if (!$css) {
return '';
}
safecss_class();
$csstidy = new csstidy();
$csstidy->optimise = new safecss($csstidy);
$csstidy->set_cfg('remove_bslash', false);
$csstidy->set_cfg('compress_colors', true);
$csstidy->set_cfg('compress_font-weight', true);
$csstidy->set_cfg('remove_last_;', true);
$csstidy->set_cfg('case_properties', true);
$csstidy->set_cfg('discard_invalid_properties', true);
$csstidy->set_cfg('css_level', 'CSS3.0');
$csstidy->set_cfg('template', 'highest');
$csstidy->parse($css);
return $csstidy->print->plain();
}
示例3: sanitize_css
static function sanitize_css($css)
{
$css = stripslashes($css);
$css = wp_strip_all_tags($css);
if (function_exists('safecss_class')) {
// Stolen from the Custom CSS plugin. Sanitize and clean using CSS tidy if available.
safecss_class();
$csstidy = new csstidy();
$csstidy->optimise = new safecss($csstidy);
$csstidy->set_cfg('remove_bslash', false);
$csstidy->set_cfg('compress_colors', false);
$csstidy->set_cfg('compress_font-weight', false);
$csstidy->set_cfg('discard_invalid_properties', true);
$csstidy->set_cfg('merge_selectors', false);
$csstidy->set_cfg('remove_last_;', false);
$csstidy->set_cfg('css_level', 'CSS3.0');
$css = preg_replace('/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $css);
$csstidy->parse($css);
$css = $csstidy->print->plain();
}
return $css;
}
示例4: inst_css_parser
/**
* If we're not running JetPack, instantiate a custom CSS parser
*/
function inst_css_parser($css = null)
{
if (empty($css)) {
return '';
}
$css = $this->compile_scss($css);
if (!class_exists('safecss_class')) {
require_once plugin_dir_path(dirname(__FILE__)) . '/classes/class-safecss-class.php';
}
safecss_class();
$csstidy = new csstidy();
$csstidy->optimise = new safecss($csstidy);
$csstidy->set_cfg('remove_bslash', false);
$csstidy->set_cfg('compress_colors', true);
$csstidy->set_cfg('compress_font-weight', true);
$csstidy->set_cfg('remove_last_;', true);
$csstidy->set_cfg('case_properties', true);
$csstidy->set_cfg('discard_invalid_properties', true);
$csstidy->set_cfg('css_level', 'CSS3.0');
$csstidy->set_cfg('template', 'highest');
$csstidy->set_cfg('preserve_css', false);
$csstidy->parse($css);
return $csstidy->print->plain();
}
示例5: sanitize_css
/**
* Sanitize the CSS for users without `unfiltered_html`.
*
* @param string $css Input CSS.
* @param array $args Array of CSS options.
*
* @return mixed|string
*/
public static function sanitize_css($css, $args = array())
{
$args = wp_parse_args($args, array('force' => false, 'preprocessor' => null));
if ($args['force'] || !current_user_can('unfiltered_html')) {
$warnings = array();
safecss_class();
$csstidy = new csstidy();
$csstidy->optimise = new safecss($csstidy);
$csstidy->set_cfg('remove_bslash', false);
$csstidy->set_cfg('compress_colors', false);
$csstidy->set_cfg('compress_font-weight', false);
$csstidy->set_cfg('optimise_shorthands', 0);
$csstidy->set_cfg('remove_last_;', false);
$csstidy->set_cfg('case_properties', false);
$csstidy->set_cfg('discard_invalid_properties', true);
$csstidy->set_cfg('css_level', 'CSS3.0');
$csstidy->set_cfg('preserve_css', true);
$csstidy->set_cfg('template', dirname(__FILE__) . '/csstidy/wordpress-standard.tpl');
$prev = $css;
$css = preg_replace('/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $css);
// prevent content: '\3434' from turning into '\\3434'.
$css = str_replace(array('\'\\\\', '"\\\\'), array('\'\\', '"\\'), $css);
if ($css !== $prev) {
$warnings[] = 'preg_replace found stuff';
}
// Some people put weird stuff in their CSS, KSES tends to be greedy.
$css = str_replace('<=', '<=', $css);
$prev = $css;
// Why KSES instead of strip_tags? Who knows?
$css = wp_kses_split($css, array(), array());
$css = str_replace('>', '>', $css);
// kses replaces lone '>' with >
// Why both KSES and strip_tags? Because we just added some '>'.
$css = strip_tags($css);
if ($css != $prev) {
$warnings[] = 'kses found stuff';
}
// if we're not using a preprocessor.
if (!$args['preprocessor']) {
/** This action is documented in modules/custom-css/custom-css.php */
do_action('safecss_parse_pre', $csstidy, $css, $args);
$csstidy->parse($css);
/** This action is documented in modules/custom-css/custom-css.php */
do_action('safecss_parse_post', $csstidy, $warnings, $args);
$css = $csstidy->print->plain();
}
}
return $css;
}
示例6: pixopoint_initiate_safecss
/**
* Initiate SafeCSS
* @since 0.9
*/
function pixopoint_initiate_safecss()
{
safecss_class();
}