/** * Determine if we're using file mode or inline mode. * * @return string file/inline */ public static function set_mode() { /** * Check if we're using file mode or inline mode. * This simply checks the dynamic_css_compiler options. */ $mode = Avada()->settings->get('dynamic_css_compiler') ? 'file' : 'inline'; //var_dump('first-mode:'.$mode); //var_dump(self::needs_update()); /** * Additional checks for file mode. */ if ('file' == $mode && self::needs_update()) { /** * Only allow processing 1 file every 5 seconds. */ $current_time = (int) time(); $last_time = (int) get_option('avada_dynamic_css_time'); //var_dump('current-time:' . ( $current_time - $last_time )); if (5 <= $current_time - $last_time) { //var_dump('inside the clt'); /** * If it's been more than 5 seconds since we last compiled a file * then attempt to write to the file. * If the file-write succeeds then set mode to 'file'. * If the file-write fails then set mode to 'inline'. */ $mode = self::can_write() && self::make_css() ? 'file' : 'inline'; /** * If the file exists then set mode to 'file' * If it does not exist then set mode to 'inline'. */ if ('file' == $mode) { $mode = file_exists(self::file('path')) ? 'file' : 'inline'; } } else { /** * It's been less than 5 seconds since we last compiled a CSS file * In order to prevent server meltdowns on weak servers we'll use inline mode instead. */ $mode = 'inline'; } } //var_dump('second-mode:'.$mode); self::$mode = $mode; }
/** * Determine if we're using file mode or inline mode. * * @return string file/inline */ public static function set_mode() { // Check if we're using file mode or inline mode. // This simply checks the dynamic_css_compiler options. $mode = Avada()->settings->get('dynamic_css_compiler') ? 'file' : 'inline'; // ALWAYS use 'inline' mode when in the customizer. global $wp_customize; if ($wp_customize) { return 'inline'; } // Additional checks for file mode. if ('file' == $mode && self::needs_update()) { // Only allow processing 1 file every 5 seconds. $current_time = (int) time(); $last_time = (int) get_option('avada_dynamic_css_time'); if (5 <= $current_time - $last_time) { // If it's been more than 5 seconds since we last compiled a file // then attempt to write to the file. // If the file-write succeeds then set mode to 'file'. // If the file-write fails then set mode to 'inline'. $mode = self::can_write() && self::make_css() ? 'file' : 'inline'; // If the file exists then set mode to 'file' // If it does not exist then set mode to 'inline'. if ('file' == $mode) { $mode = file_exists(self::file('path')) ? 'file' : 'inline'; } } else { // It's been less than 5 seconds since we last compiled a CSS file // In order to prevent server meltdowns on weak servers we'll use inline mode instead. $mode = 'inline'; } } self::$mode = $mode; }