$sv) { $valid = array_key_exists($sk, $o); if (is_array($sv) && !empty($sv)) { $valid = $valid && self::isValidOptionsStructure($o[$sk], $sv); } if (!$valid) { break; } } } return $valid; } /** * Function takes a GMT timestamp and returns a date/time string in the * current timezone and WP format. * @param int $timestamp The GMT timestamp to translate. * @return string The local time in the WP date/time format. */ public static function localDateTimeFromTimestamp($timestamp) { static $gmt_offet = null; static $wp_format = null; if (is_null($gmt_offet)) { $gmt_offet = get_option('gmt_offset'); $wp_format = get_option('date_format').' '.get_option('time_format'); } return date($wp_format, $timestamp + $gmt_offet * 3600); } /** * Compiles any custom CSS plus the default CSS together, * minifying in the process. * @param string $custom The custom CSS to compile. * @return string Compiled CSS, including both standard and any custom. */ public static function compileCustomCss($custom) { $css = file_get_contents(DG_PATH . 'assets/css/style.css'); $css .= str_replace('>', '>', esc_html($custom)); return $css; } /** * Removes all comments & space from CSS string. * Source: http://stackoverflow.com/a/15195752/866618 */ private static function minifyCss($css) { # remove comments first (simplifies the other regex) $re1 = << .*? \*/ ) EOS; $re2 = <<~+-] | !important\b ) \s*+ | # spaces right of ( [ : ( [[(:] ) \s++ | # spaces left of ) ] \s++ ( [])] ) | # spaces left (and right) of : \s++ ( : ) \s*+ # but not in selectors: not followed by a { (?! (?> [^{}"']++ | "(?:[^"\\]++|\\.)*+" | '(?:[^'\\]++|\\.)*+' )*+ { ) | # spaces at beginning/end of string ^ \s++ | \s++ \z | # double spaces to single (\s)\s+ EOS; $css = preg_replace("%$re1%", '$1', $css); return preg_replace("%$re2%", '$1$2$3$4$5$6$7', $css); } /** * Blocks instantiation. All functions are static. */ private function __construct() { } } ?>