How to use generate method of set class

Best Atoum code snippet using set.generate

css-output.php

Source:css-output.php Github

copy

Full Screen

...8if ( ! defined( 'ABSPATH' ) ) {9 exit; // Exit if accessed directly.10}1112if ( ! function_exists( 'generate_base_css' ) ) {13 /**14 * Generate the CSS in the <head> section using the Theme Customizer.15 *16 * @since 0.117 */18 function generate_base_css() {19 $generate_settings = wp_parse_args(20 get_option( 'generate_settings', array() ),21 generate_get_defaults()22 );2324 $css = new GeneratePress_CSS;2526 $css->set_selector( 'body' );27 $css->add_property( 'background-color', esc_attr( $generate_settings['background_color'] ) );28 $css->add_property( 'color', esc_attr( $generate_settings['text_color'] ) );2930 $css->set_selector( 'a, a:visited' );31 $css->add_property( 'color', esc_attr( $generate_settings['link_color'] ) );3233 $css->set_selector( 'a:visited' )->add_property( 'color', esc_attr( $generate_settings['link_color_visited'] ) );3435 $css->set_selector( 'a:hover, a:focus, a:active' );36 $css->add_property( 'color', esc_attr( $generate_settings['link_color_hover'] ) );3738 $css->set_selector( 'body .grid-container' )->add_property( 'max-width', absint( $generate_settings['container_width'] ), false, 'px' );3940 if ( apply_filters( 'generate_do_group_inner_container_style', true ) ) {41 $css->set_selector( '.wp-block-group__inner-container' );42 $css->add_property( 'max-width', absint( $generate_settings['container_width'] ), false, 'px' );43 $css->add_property( 'margin-left', 'auto' );44 $css->add_property( 'margin-right', 'auto' );45 }4647 $nav_drop_point = generate_get_option( 'nav_drop_point' );48 $nav_location = generate_get_navigation_location();4950 if ( ( 'nav-float-right' === $nav_location || 'nav-float-left' === $nav_location ) && $nav_drop_point ) {51 $media_query = sprintf(52 '(max-width: %1$s) and %2$s',53 absint( $nav_drop_point ) . 'px',54 apply_filters( 'generate_not_mobile_menu_media_query', '(min-width: 769px)' )55 );5657 $css->start_media_query( $media_query );58 $css->set_selector( '.inside-header' );59 $css->add_property( 'display', '-ms-flexbox' );60 $css->add_property( 'display', 'flex' );6162 $css->add_property( '-ms-flex-direction', 'column' );63 $css->add_property( 'flex-direction', 'column' );6465 $css->add_property( '-ms-flex-align', 'center' );66 $css->add_property( 'align-items', 'center' );6768 $css->set_selector( '.site-logo, .site-branding' );69 $css->add_property( 'margin-bottom', '1.5em' );7071 $css->set_selector( '#site-navigation' );72 $css->add_property( 'margin', '0 auto' );7374 $css->set_selector( '.header-widget' );75 $css->add_property( 'margin-top', '1.5em' );7677 if ( 'nav-float-left' === generate_get_option( 'nav_position_setting' ) ) {78 $css->set_selector( '.nav-float-left .site-logo,.nav-float-left .site-branding,.nav-float-left .header-widget' );79 $css->add_property( '-webkit-box-ordinal-group', 'initial' );80 $css->add_property( '-ms-flex-order', 'initial' );81 $css->add_property( 'order', 'initial' );82 }83 $css->stop_media_query();84 }8586 if ( generate_get_option( 'logo_width' ) ) {87 $css->set_selector( '.site-header .header-image' );88 $css->add_property( 'width', absint( generate_get_option( 'logo_width' ) ), false, 'px' );89 }9091 do_action( 'generate_base_css', $css );9293 return apply_filters( 'generate_base_css_output', $css->css_output() );94 }95}9697if ( ! function_exists( 'generate_advanced_css' ) ) {98 /**99 * Generate the CSS in the <head> section using the Theme Customizer.100 *101 * @since 0.1102 */103 function generate_advanced_css() {104 $generate_settings = wp_parse_args(105 get_option( 'generate_settings', array() ),106 generate_get_color_defaults()107 );108109 $css = new GeneratePress_CSS;110111 $css->set_selector( '.top-bar' );112 $css->add_property( 'background-color', esc_attr( $generate_settings['top_bar_background_color'] ) );113 $css->add_property( 'color', esc_attr( $generate_settings['top_bar_text_color'] ) );114115 $css->set_selector( '.top-bar a,.top-bar a:visited' );116 $css->add_property( 'color', esc_attr( $generate_settings['top_bar_link_color'] ) );117118 $css->set_selector( '.top-bar a:hover' );119 $css->add_property( 'color', esc_attr( $generate_settings['top_bar_link_color_hover'] ) );120121 $css->set_selector( '.site-header' );122 $css->add_property( 'background-color', esc_attr( $generate_settings['header_background_color'] ) );123 $css->add_property( 'color', esc_attr( $generate_settings['header_text_color'] ) );124125 $css->set_selector( '.site-header a,.site-header a:visited' );126 $css->add_property( 'color', esc_attr( $generate_settings['header_link_color'] ) );127128 $css->set_selector( '.site-header a:hover' );129 $css->add_property( 'color', esc_attr( $generate_settings['header_link_hover_color'] ) );130131 $css->set_selector( '.main-title a,.main-title a:hover,.main-title a:visited' );132 $css->add_property( 'color', esc_attr( $generate_settings['site_title_color'] ) );133134 $css->set_selector( '.site-description' );135 $css->add_property( 'color', esc_attr( $generate_settings['site_tagline_color'] ) );136137 $css->set_selector( '.main-navigation,.main-navigation ul ul' );138 $css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_color'] ) );139140 $css->set_selector( '.main-navigation .main-nav ul li a,.menu-toggle' );141 $css->add_property( 'color', esc_attr( $generate_settings['navigation_text_color'] ) );142143 $css->set_selector( '.main-navigation .main-nav ul li:hover > a,.main-navigation .main-nav ul li:focus > a, .main-navigation .main-nav ul li.sfHover > a' );144 $css->add_property( 'color', esc_attr( $generate_settings['navigation_text_hover_color'] ) );145 $css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_hover_color'] ) );146147 $css->set_selector( 'button.menu-toggle:hover,button.menu-toggle:focus,.main-navigation .mobile-bar-items a,.main-navigation .mobile-bar-items a:hover,.main-navigation .mobile-bar-items a:focus' );148 $css->add_property( 'color', esc_attr( $generate_settings['navigation_text_color'] ) );149150 $css->set_selector( '.main-navigation .main-nav ul li[class*="current-menu-"] > a' );151 $css->add_property( 'color', esc_attr( $generate_settings['navigation_text_current_color'] ) );152 $css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_current_color'] ) );153154 $css->set_selector( '.main-navigation .main-nav ul li[class*="current-menu-"] > a:hover,.main-navigation .main-nav ul li[class*="current-menu-"].sfHover > a' );155 $css->add_property( 'color', esc_attr( $generate_settings['navigation_text_current_color'] ) );156 $css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_current_color'] ) );157158 $navigation_search_background = $generate_settings['navigation_background_hover_color'];159 $navigation_search_text = $generate_settings['navigation_text_hover_color'];160161 if ( '' !== $generate_settings['navigation_search_background_color'] ) {162 $navigation_search_background = $generate_settings['navigation_search_background_color'];163 }164165 if ( '' !== $generate_settings['navigation_search_text_color'] ) {166 $navigation_search_text = $generate_settings['navigation_search_text_color'];167 }168169 $css->set_selector( '.navigation-search input[type="search"],.navigation-search input[type="search"]:active, .navigation-search input[type="search"]:focus, .main-navigation .main-nav ul li.search-item.active > a' );170 $css->add_property( 'color', esc_attr( $navigation_search_text ) );171 $css->add_property( 'background-color', esc_attr( $navigation_search_background ) );172173 if ( '' !== $generate_settings['navigation_search_background_color'] ) {174 $css->add_property( 'opacity', '1' );175 }176177 $css->set_selector( '.main-navigation ul ul' );178 $css->add_property( 'background-color', esc_attr( $generate_settings['subnavigation_background_color'] ) );179180 $css->set_selector( '.main-navigation .main-nav ul ul li a' );181 $css->add_property( 'color', esc_attr( $generate_settings['subnavigation_text_color'] ) );182183 $css->set_selector( '.main-navigation .main-nav ul ul li:hover > a,.main-navigation .main-nav ul ul li:focus > a,.main-navigation .main-nav ul ul li.sfHover > a' );184 $css->add_property( 'color', esc_attr( $generate_settings['subnavigation_text_hover_color'] ) );185 $css->add_property( 'background-color', esc_attr( $generate_settings['subnavigation_background_hover_color'] ) );186187 $css->set_selector( '.main-navigation .main-nav ul ul li[class*="current-menu-"] > a' );188 $css->add_property( 'color', esc_attr( $generate_settings['subnavigation_text_current_color'] ) );189 $css->add_property( 'background-color', esc_attr( $generate_settings['subnavigation_background_current_color'] ) );190191 $css->set_selector( '.main-navigation .main-nav ul ul li[class*="current-menu-"] > a:hover,.main-navigation .main-nav ul ul li[class*="current-menu-"].sfHover > a' );192 $css->add_property( 'color', esc_attr( $generate_settings['subnavigation_text_current_color'] ) );193 $css->add_property( 'background-color', esc_attr( $generate_settings['subnavigation_background_current_color'] ) );194195 $css->set_selector( '.separate-containers .inside-article, .separate-containers .comments-area, .separate-containers .page-header, .one-container .container, .separate-containers .paging-navigation, .inside-page-header' );196 $css->add_property( 'color', esc_attr( $generate_settings['content_text_color'] ) );197 $css->add_property( 'background-color', esc_attr( $generate_settings['content_background_color'] ) );198199 $css->set_selector( '.inside-article a,.inside-article a:visited,.paging-navigation a,.paging-navigation a:visited,.comments-area a,.comments-area a:visited,.page-header a,.page-header a:visited' );200 $css->add_property( 'color', esc_attr( $generate_settings['content_link_color'] ) );201202 $css->set_selector( '.inside-article a:hover,.paging-navigation a:hover,.comments-area a:hover,.page-header a:hover' );203 $css->add_property( 'color', esc_attr( $generate_settings['content_link_hover_color'] ) );204205 $css->set_selector( '.entry-header h1,.page-header h1' );206 $css->add_property( 'color', esc_attr( $generate_settings['content_title_color'] ) );207208 $css->set_selector( '.entry-title a,.entry-title a:visited' );209 $css->add_property( 'color', esc_attr( $generate_settings['blog_post_title_color'] ) );210211 $css->set_selector( '.entry-title a:hover' );212 $css->add_property( 'color', esc_attr( $generate_settings['blog_post_title_hover_color'] ) );213214 $css->set_selector( '.entry-meta' );215 $css->add_property( 'color', esc_attr( $generate_settings['entry_meta_text_color'] ) );216217 $css->set_selector( '.entry-meta a,.entry-meta a:visited' );218 $css->add_property( 'color', esc_attr( $generate_settings['entry_meta_link_color'] ) );219220 $css->set_selector( '.entry-meta a:hover' );221 $css->add_property( 'color', esc_attr( $generate_settings['entry_meta_link_color_hover'] ) );222223 $css->set_selector( 'h1' );224 $css->add_property( 'color', esc_attr( $generate_settings['h1_color'] ) );225226 $css->set_selector( 'h2' );227 $css->add_property( 'color', esc_attr( $generate_settings['h2_color'] ) );228229 $css->set_selector( 'h3' );230 $css->add_property( 'color', esc_attr( $generate_settings['h3_color'] ) );231232 $css->set_selector( 'h4' );233 $css->add_property( 'color', esc_attr( $generate_settings['h4_color'] ) );234235 $css->set_selector( 'h5' );236 $css->add_property( 'color', esc_attr( $generate_settings['h5_color'] ) );237238 $css->set_selector( 'h6' );239 $css->add_property( 'color', esc_attr( $generate_settings['h6_color'] ) );240241 $css->set_selector( '.sidebar .widget' );242 $css->add_property( 'color', esc_attr( $generate_settings['sidebar_widget_text_color'] ) );243 $css->add_property( 'background-color', esc_attr( $generate_settings['sidebar_widget_background_color'] ) );244245 $css->set_selector( '.sidebar .widget a,.sidebar .widget a:visited' );246 $css->add_property( 'color', esc_attr( $generate_settings['sidebar_widget_link_color'] ) );247248 $css->set_selector( '.sidebar .widget a:hover' );249 $css->add_property( 'color', esc_attr( $generate_settings['sidebar_widget_link_hover_color'] ) );250251 $css->set_selector( '.sidebar .widget .widget-title' );252 $css->add_property( 'color', esc_attr( $generate_settings['sidebar_widget_title_color'] ) );253254 $css->set_selector( '.footer-widgets' );255 $css->add_property( 'color', esc_attr( $generate_settings['footer_widget_text_color'] ) );256 $css->add_property( 'background-color', esc_attr( $generate_settings['footer_widget_background_color'] ) );257258 $css->set_selector( '.footer-widgets a,.footer-widgets a:visited' );259 $css->add_property( 'color', esc_attr( $generate_settings['footer_widget_link_color'] ) );260261 $css->set_selector( '.footer-widgets a:hover' );262 $css->add_property( 'color', esc_attr( $generate_settings['footer_widget_link_hover_color'] ) );263264 $css->set_selector( '.footer-widgets .widget-title' );265 $css->add_property( 'color', esc_attr( $generate_settings['footer_widget_title_color'] ) );266267 $css->set_selector( '.site-info' );268 $css->add_property( 'color', esc_attr( $generate_settings['footer_text_color'] ) );269 $css->add_property( 'background-color', esc_attr( $generate_settings['footer_background_color'] ) );270271 $css->set_selector( '.site-info a,.site-info a:visited' );272 $css->add_property( 'color', esc_attr( $generate_settings['footer_link_color'] ) );273274 $css->set_selector( '.site-info a:hover' );275 $css->add_property( 'color', esc_attr( $generate_settings['footer_link_hover_color'] ) );276277 $css->set_selector( '.footer-bar .widget_nav_menu .current-menu-item a' );278 $css->add_property( 'color', esc_attr( $generate_settings['footer_link_hover_color'] ) );279280 $css->set_selector( 'input[type="text"],input[type="email"],input[type="url"],input[type="password"],input[type="search"],input[type="tel"],input[type="number"],textarea,select' );281 $css->add_property( 'color', esc_attr( $generate_settings['form_text_color'] ) );282 $css->add_property( 'background-color', esc_attr( $generate_settings['form_background_color'] ) );283 $css->add_property( 'border-color', esc_attr( $generate_settings['form_border_color'] ) );284285 $css->set_selector( 'input[type="text"]:focus,input[type="email"]:focus,input[type="url"]:focus,input[type="password"]:focus,input[type="search"]:focus,input[type="tel"]:focus,input[type="number"]:focus,textarea:focus,select:focus' );286 $css->add_property( 'color', esc_attr( $generate_settings['form_text_color_focus'] ) );287 $css->add_property( 'background-color', esc_attr( $generate_settings['form_background_color_focus'] ) );288 $css->add_property( 'border-color', esc_attr( $generate_settings['form_border_color_focus'] ) );289290 $css->set_selector( 'button,html input[type="button"],input[type="reset"],input[type="submit"],a.button,a.button:visited,a.wp-block-button__link:not(.has-background)' );291 $css->add_property( 'color', esc_attr( $generate_settings['form_button_text_color'] ) );292 $css->add_property( 'background-color', esc_attr( $generate_settings['form_button_background_color'] ) );293294 $css->set_selector( 'button:hover,html input[type="button"]:hover,input[type="reset"]:hover,input[type="submit"]:hover,a.button:hover,button:focus,html input[type="button"]:focus,input[type="reset"]:focus,input[type="submit"]:focus,a.button:focus,a.wp-block-button__link:not(.has-background):active,a.wp-block-button__link:not(.has-background):focus,a.wp-block-button__link:not(.has-background):hover' );295 $css->add_property( 'color', esc_attr( $generate_settings['form_button_text_color_hover'] ) );296 $css->add_property( 'background-color', esc_attr( $generate_settings['form_button_background_color_hover'] ) );297298 $css->set_selector( '.generate-back-to-top,.generate-back-to-top:visited' );299 $css->add_property( 'background-color', esc_attr( $generate_settings['back_to_top_background_color'] ) );300 $css->add_property( 'color', esc_attr( $generate_settings['back_to_top_text_color'] ) );301302 $css->set_selector( '.generate-back-to-top:hover,.generate-back-to-top:focus' );303 $css->add_property( 'background-color', esc_attr( $generate_settings['back_to_top_background_color_hover'] ) );304 $css->add_property( 'color', esc_attr( $generate_settings['back_to_top_text_color_hover'] ) );305306 do_action( 'generate_colors_css', $css );307308 return apply_filters( 'generate_colors_css_output', $css->css_output() );309 }310}311312if ( ! function_exists( 'generate_font_css' ) ) {313 /**314 * Generate the CSS in the <head> section using the Theme Customizer.315 *316 * @since 0.1317 */318 function generate_font_css() {319320 $generate_settings = wp_parse_args(321 get_option( 'generate_settings', array() ),322 generate_get_default_fonts()323 );324325 $og_defaults = generate_get_default_fonts( false );326327 $css = new GeneratePress_CSS;328329 $subnav_font_size = $generate_settings['navigation_font_size'] >= 17 ? $generate_settings['navigation_font_size'] - 3 : $generate_settings['navigation_font_size'] - 1;330331 $body_family = generate_get_font_family_css( 'font_body', 'generate_settings', generate_get_default_fonts() );332 $top_bar_family = generate_get_font_family_css( 'font_top_bar', 'generate_settings', generate_get_default_fonts() );333 $site_title_family = generate_get_font_family_css( 'font_site_title', 'generate_settings', generate_get_default_fonts() );334 $site_tagline_family = generate_get_font_family_css( 'font_site_tagline', 'generate_settings', generate_get_default_fonts() );335 $navigation_family = generate_get_font_family_css( 'font_navigation', 'generate_settings', generate_get_default_fonts() );336 $widget_family = generate_get_font_family_css( 'font_widget_title', 'generate_settings', generate_get_default_fonts() );337 $h1_family = generate_get_font_family_css( 'font_heading_1', 'generate_settings', generate_get_default_fonts() );338 $h2_family = generate_get_font_family_css( 'font_heading_2', 'generate_settings', generate_get_default_fonts() );339 $h3_family = generate_get_font_family_css( 'font_heading_3', 'generate_settings', generate_get_default_fonts() );340 $h4_family = generate_get_font_family_css( 'font_heading_4', 'generate_settings', generate_get_default_fonts() );341 $h5_family = generate_get_font_family_css( 'font_heading_5', 'generate_settings', generate_get_default_fonts() );342 $h6_family = generate_get_font_family_css( 'font_heading_6', 'generate_settings', generate_get_default_fonts() );343 $footer_family = generate_get_font_family_css( 'font_footer', 'generate_settings', generate_get_default_fonts() );344 $buttons_family = generate_get_font_family_css( 'font_buttons', 'generate_settings', generate_get_default_fonts() );345346 $css->set_selector( 'body, button, input, select, textarea' );347 $css->add_property( 'font-family', $body_family );348 $css->add_property( 'font-weight', esc_attr( $generate_settings['body_font_weight'] ), $og_defaults['body_font_weight'] );349 $css->add_property( 'text-transform', esc_attr( $generate_settings['body_font_transform'] ), $og_defaults['body_font_transform'] );350 $css->add_property( 'font-size', absint( $generate_settings['body_font_size'] ), $og_defaults['body_font_size'], 'px' );351352 $css->set_selector( 'body' );353 $css->add_property( 'line-height', floatval( $generate_settings['body_line_height'] ), $og_defaults['body_line_height'] );354355 $css->set_selector( 'p' );356 $css->add_property( 'margin-bottom', floatval( $generate_settings['paragraph_margin'] ), $og_defaults['paragraph_margin'], 'em' );357358 $css->set_selector( '.entry-content > [class*="wp-block-"]:not(:last-child)' );359 $css->add_property( 'margin-bottom', floatval( $generate_settings['paragraph_margin'] ), false, 'em' );360361 $css->set_selector( '.top-bar' );362 $css->add_property( 'font-family', $og_defaults['font_top_bar'] !== $generate_settings['font_top_bar'] ? $top_bar_family : null );363 $css->add_property( 'font-weight', esc_attr( $generate_settings['top_bar_font_weight'] ), $og_defaults['top_bar_font_weight'] );364 $css->add_property( 'text-transform', esc_attr( $generate_settings['top_bar_font_transform'] ), $og_defaults['top_bar_font_transform'] );365 $css->add_property( 'font-size', absint( $generate_settings['top_bar_font_size'] ), absint( $og_defaults['top_bar_font_size'] ), 'px' );366367 $css->set_selector( '.main-title' );368 $css->add_property( 'font-family', $og_defaults['font_site_title'] !== $generate_settings['font_site_title'] ? $site_title_family : null );369 $css->add_property( 'font-weight', esc_attr( $generate_settings['site_title_font_weight'] ), $og_defaults['site_title_font_weight'] );370 $css->add_property( 'text-transform', esc_attr( $generate_settings['site_title_font_transform'] ), $og_defaults['site_title_font_transform'] );371 $css->add_property( 'font-size', absint( $generate_settings['site_title_font_size'] ), $og_defaults['site_title_font_size'], 'px' );372373 $css->set_selector( '.site-description' );374 $css->add_property( 'font-family', $og_defaults['font_site_tagline'] !== $generate_settings['font_site_tagline'] ? $site_tagline_family : null );375 $css->add_property( 'font-weight', esc_attr( $generate_settings['site_tagline_font_weight'] ), $og_defaults['site_tagline_font_weight'] );376 $css->add_property( 'text-transform', esc_attr( $generate_settings['site_tagline_font_transform'] ), $og_defaults['site_tagline_font_transform'] );377 $css->add_property( 'font-size', absint( $generate_settings['site_tagline_font_size'] ), $og_defaults['site_tagline_font_size'], 'px' );378379 $css->set_selector( '.main-navigation a, .menu-toggle' );380 $css->add_property( 'font-family', $og_defaults['font_navigation'] !== $generate_settings['font_navigation'] ? $navigation_family : null );381 $css->add_property( 'font-weight', esc_attr( $generate_settings['navigation_font_weight'] ), $og_defaults['navigation_font_weight'] );382 $css->add_property( 'text-transform', esc_attr( $generate_settings['navigation_font_transform'] ), $og_defaults['navigation_font_transform'] );383 $css->add_property( 'font-size', absint( $generate_settings['navigation_font_size'] ), $og_defaults['navigation_font_size'], 'px' );384385 $css->set_selector( '.main-navigation .main-nav ul ul li a' );386 $css->add_property( 'font-size', absint( $subnav_font_size ), false, 'px' );387388 $css->set_selector( '.widget-title' );389 $css->add_property( 'font-family', $og_defaults['font_widget_title'] !== $generate_settings['font_widget_title'] ? $widget_family : null );390 $css->add_property( 'font-weight', esc_attr( $generate_settings['widget_title_font_weight'] ), $og_defaults['widget_title_font_weight'] );391 $css->add_property( 'text-transform', esc_attr( $generate_settings['widget_title_font_transform'] ), $og_defaults['widget_title_font_transform'] );392 $css->add_property( 'font-size', absint( $generate_settings['widget_title_font_size'] ), $og_defaults['widget_title_font_size'], 'px' );393 $css->add_property( 'margin-bottom', absint( $generate_settings['widget_title_separator'] ), absint( $og_defaults['widget_title_separator'] ), 'px' );394395 $css->set_selector( '.sidebar .widget, .footer-widgets .widget' );396 $css->add_property( 'font-size', absint( $generate_settings['widget_content_font_size'] ), $og_defaults['widget_content_font_size'], 'px' );397398 $css->set_selector( 'button:not(.menu-toggle),html input[type="button"],input[type="reset"],input[type="submit"],.button,.button:visited,.wp-block-button .wp-block-button__link' );399 $css->add_property( 'font-family', $og_defaults['font_buttons'] !== $generate_settings['font_buttons'] ? $buttons_family : null );400 $css->add_property( 'font-weight', esc_attr( $generate_settings['buttons_font_weight'] ), $og_defaults['buttons_font_weight'] );401 $css->add_property( 'text-transform', esc_attr( $generate_settings['buttons_font_transform'] ), $og_defaults['buttons_font_transform'] );402403 if ( '' !== $generate_settings['buttons_font_size'] ) {404 $css->add_property( 'font-size', absint( $generate_settings['buttons_font_size'] ), $og_defaults['buttons_font_size'], 'px' );405 }406407 $css->set_selector( 'h1' );408 $css->add_property( 'font-family', $og_defaults['font_heading_1'] !== $generate_settings['font_heading_1'] ? $h1_family : null );409 $css->add_property( 'font-weight', esc_attr( $generate_settings['heading_1_weight'] ), $og_defaults['heading_1_weight'] );410 $css->add_property( 'text-transform', esc_attr( $generate_settings['heading_1_transform'] ), $og_defaults['heading_1_transform'] );411 $css->add_property( 'font-size', absint( $generate_settings['heading_1_font_size'] ), $og_defaults['heading_1_font_size'], 'px' );412 $css->add_property( 'line-height', floatval( $generate_settings['heading_1_line_height'] ), $og_defaults['heading_1_line_height'], 'em' );413 $css->add_property( 'margin-bottom', floatval( $generate_settings['heading_1_margin_bottom'] ), $og_defaults['heading_1_margin_bottom'], 'px' );414415 $css->set_selector( 'h2' );416 $css->add_property( 'font-family', $og_defaults['font_heading_2'] !== $generate_settings['font_heading_2'] ? $h2_family : null );417 $css->add_property( 'font-weight', esc_attr( $generate_settings['heading_2_weight'] ), $og_defaults['heading_2_weight'] );418 $css->add_property( 'text-transform', esc_attr( $generate_settings['heading_2_transform'] ), $og_defaults['heading_2_transform'] );419 $css->add_property( 'font-size', absint( $generate_settings['heading_2_font_size'] ), $og_defaults['heading_2_font_size'], 'px' );420 $css->add_property( 'line-height', floatval( $generate_settings['heading_2_line_height'] ), $og_defaults['heading_2_line_height'], 'em' );421 $css->add_property( 'margin-bottom', floatval( $generate_settings['heading_2_margin_bottom'] ), $og_defaults['heading_2_margin_bottom'], 'px' );422423 $css->set_selector( 'h3' );424 $css->add_property( 'font-family', $og_defaults['font_heading_3'] !== $generate_settings['font_heading_3'] ? $h3_family : null );425 $css->add_property( 'font-weight', esc_attr( $generate_settings['heading_3_weight'] ), $og_defaults['heading_3_weight'] );426 $css->add_property( 'text-transform', esc_attr( $generate_settings['heading_3_transform'] ), $og_defaults['heading_3_transform'] );427 $css->add_property( 'font-size', absint( $generate_settings['heading_3_font_size'] ), $og_defaults['heading_3_font_size'], 'px' );428 $css->add_property( 'line-height', floatval( $generate_settings['heading_3_line_height'] ), $og_defaults['heading_3_line_height'], 'em' );429 $css->add_property( 'margin-bottom', floatval( $generate_settings['heading_3_margin_bottom'] ), $og_defaults['heading_3_margin_bottom'], 'px' );430431 $css->set_selector( 'h4' );432 $css->add_property( 'font-family', $og_defaults['font_heading_4'] !== $generate_settings['font_heading_4'] ? $h4_family : null );433 $css->add_property( 'font-weight', esc_attr( $generate_settings['heading_4_weight'] ), $og_defaults['heading_4_weight'] );434 $css->add_property( 'text-transform', esc_attr( $generate_settings['heading_4_transform'] ), $og_defaults['heading_4_transform'] );435436 if ( '' !== $generate_settings['heading_4_font_size'] ) {437 $css->add_property( 'font-size', absint( $generate_settings['heading_4_font_size'] ), $og_defaults['heading_4_font_size'], 'px' );438 }439440 if ( '' !== $generate_settings['heading_4_line_height'] ) {441 $css->add_property( 'line-height', floatval( $generate_settings['heading_4_line_height'] ), $og_defaults['heading_4_line_height'], 'em' );442 }443444 $css->set_selector( 'h5' );445 $css->add_property( 'font-family', $og_defaults['font_heading_5'] !== $generate_settings['font_heading_5'] ? $h5_family : null );446 $css->add_property( 'font-weight', esc_attr( $generate_settings['heading_5_weight'] ), $og_defaults['heading_5_weight'] );447 $css->add_property( 'text-transform', esc_attr( $generate_settings['heading_5_transform'] ), $og_defaults['heading_5_transform'] );448449 if ( '' !== $generate_settings['heading_5_font_size'] ) {450 $css->add_property( 'font-size', absint( $generate_settings['heading_5_font_size'] ), $og_defaults['heading_5_font_size'], 'px' );451 }452453 if ( '' !== $generate_settings['heading_5_line_height'] ) {454 $css->add_property( 'line-height', floatval( $generate_settings['heading_5_line_height'] ), $og_defaults['heading_5_line_height'], 'em' );455 }456457 $css->set_selector( 'h6' );458 $css->add_property( 'font-family', $og_defaults['font_heading_6'] !== $generate_settings['font_heading_6'] ? $h6_family : null );459 $css->add_property( 'font-weight', esc_attr( $generate_settings['heading_6_weight'] ), $og_defaults['heading_6_weight'] );460 $css->add_property( 'text-transform', esc_attr( $generate_settings['heading_6_transform'] ), $og_defaults['heading_6_transform'] );461462 if ( '' !== $generate_settings['heading_6_font_size'] ) {463 $css->add_property( 'font-size', absint( $generate_settings['heading_6_font_size'] ), $og_defaults['heading_6_font_size'], 'px' );464 }465466 if ( '' !== $generate_settings['heading_6_line_height'] ) {467 $css->add_property( 'line-height', floatval( $generate_settings['heading_6_line_height'] ), $og_defaults['heading_6_line_height'], 'em' );468 }469470 $css->set_selector( '.site-info' );471 $css->add_property( 'font-family', $og_defaults['font_footer'] !== $generate_settings['font_footer'] ? $footer_family : null );472 $css->add_property( 'font-weight', esc_attr( $generate_settings['footer_weight'] ), $og_defaults['footer_weight'] );473 $css->add_property( 'text-transform', esc_attr( $generate_settings['footer_transform'] ), $og_defaults['footer_transform'] );474 $css->add_property( 'font-size', absint( $generate_settings['footer_font_size'] ), $og_defaults['footer_font_size'], 'px' );475476 $css->start_media_query( generate_get_media_query( 'mobile' ) );477 $mobile_site_title = ( isset( $generate_settings['mobile_site_title_font_size'] ) ) ? $generate_settings['mobile_site_title_font_size'] : '30';478 $css->set_selector( '.main-title' );479 $css->add_property( 'font-size', absint( $mobile_site_title ), false, 'px' );480481 $mobile_h1 = ( isset( $generate_settings['mobile_heading_1_font_size'] ) ) ? $generate_settings['mobile_heading_1_font_size'] : '30';482 $css->set_selector( 'h1' );483 $css->add_property( 'font-size', absint( $mobile_h1 ), false, 'px' );484485 $mobile_h2 = ( isset( $generate_settings['mobile_heading_2_font_size'] ) ) ? $generate_settings['mobile_heading_2_font_size'] : '25';486 $css->set_selector( 'h2' );487 $css->add_property( 'font-size', absint( $mobile_h2 ), false, 'px' );488 $css->stop_media_query();489490 do_action( 'generate_typography_css', $css );491492 return apply_filters( 'generate_typography_css_output', $css->css_output() );493 }494}495496if ( ! function_exists( 'generate_spacing_css' ) ) {497 /**498 * Write our dynamic CSS.499 *500 * @since 0.1501 */502 function generate_spacing_css() {503 $spacing_settings = wp_parse_args(504 get_option( 'generate_spacing_settings', array() ),505 generate_spacing_get_defaults()506 );507508 $og_defaults = generate_spacing_get_defaults( false );509 $sidebar_layout = generate_get_layout();510511 $css = new GeneratePress_CSS;512513 $css->set_selector( '.inside-top-bar' );514 $css->add_property( 'padding', generate_padding_css( $spacing_settings['top_bar_top'], $spacing_settings['top_bar_right'], $spacing_settings['top_bar_bottom'], $spacing_settings['top_bar_left'] ), generate_padding_css( $og_defaults['top_bar_top'], $og_defaults['top_bar_right'], $og_defaults['top_bar_bottom'], $og_defaults['top_bar_left'] ) );515516 $css->set_selector( '.inside-header' );517 $css->add_property( 'padding', generate_padding_css( $spacing_settings['header_top'], $spacing_settings['header_right'], $spacing_settings['header_bottom'], $spacing_settings['header_left'] ), generate_padding_css( $og_defaults['header_top'], $og_defaults['header_right'], $og_defaults['header_bottom'], $og_defaults['header_left'] ) );518519 $css->set_selector( '.separate-containers .inside-article, .separate-containers .comments-area, .separate-containers .page-header, .separate-containers .paging-navigation, .one-container .site-content, .inside-page-header, .wp-block-group__inner-container' );520 $css->add_property( 'padding', generate_padding_css( $spacing_settings['content_top'], $spacing_settings['content_right'], $spacing_settings['content_bottom'], $spacing_settings['content_left'] ), generate_padding_css( $og_defaults['content_top'], $og_defaults['content_right'], $og_defaults['content_bottom'], $og_defaults['content_left'] ) );521522 $content_padding = absint( $spacing_settings['content_right'] ) + absint( $spacing_settings['content_left'] );523 $css->set_selector( '.entry-content .alignwide, body:not(.no-sidebar) .entry-content .alignfull' );524 $css->add_property( 'margin-left', '-' . absint( $spacing_settings['content_left'] ) . 'px' );525 $css->add_property( 'width', 'calc(100% + ' . absint( $content_padding ) . 'px)' );526 $css->add_property( 'max-width', 'calc(100% + ' . absint( $content_padding ) . 'px)' );527528 if ( 'text' === generate_get_option( 'container_alignment' ) ) {529 $css->set_selector( '.container.grid-container' );530 $css->add_property( 'max-width', generate_get_option( 'container_width' ) + $content_padding, false, 'px' );531 }532533 $css->set_selector( '.one-container.right-sidebar .site-main,.one-container.both-right .site-main' );534 $css->add_property( 'margin-right', absint( $spacing_settings['content_right'] ), absint( $og_defaults['content_right'] ), 'px' );535536 $css->set_selector( '.one-container.left-sidebar .site-main,.one-container.both-left .site-main' );537 $css->add_property( 'margin-left', absint( $spacing_settings['content_left'] ), absint( $og_defaults['content_left'] ), 'px' );538539 $css->set_selector( '.one-container.both-sidebars .site-main' );540 $css->add_property( 'margin', generate_padding_css( '0', $spacing_settings['content_right'], '0', $spacing_settings['content_left'] ), generate_padding_css( '0', $og_defaults['content_right'], '0', $og_defaults['content_left'] ) );541542 $css->set_selector( '.separate-containers .widget, .separate-containers .site-main > *, .separate-containers .page-header, .widget-area .main-navigation' );543 $css->add_property( 'margin-bottom', absint( $spacing_settings['separator'] ), absint( $og_defaults['separator'] ), 'px' );544545 $css->set_selector( '.separate-containers .site-main' );546 $css->add_property( 'margin', absint( $spacing_settings['separator'] ), $og_defaults['separator'], 'px' );547548 $css->set_selector( '.both-right.separate-containers .inside-left-sidebar' );549 $css->add_property( 'margin-right', absint( $spacing_settings['separator'] / 2 ), absint( $og_defaults['separator'] / 2 ), 'px' );550551 $css->set_selector( '.both-right.separate-containers .inside-right-sidebar' );552 $css->add_property( 'margin-left', absint( $spacing_settings['separator'] / 2 ), absint( $og_defaults['separator'] / 2 ), 'px' );553554 $css->set_selector( '.both-left.separate-containers .inside-left-sidebar' );555 $css->add_property( 'margin-right', absint( $spacing_settings['separator'] / 2 ), absint( $og_defaults['separator'] / 2 ), 'px' );556557 $css->set_selector( '.both-left.separate-containers .inside-right-sidebar' );558 $css->add_property( 'margin-left', absint( $spacing_settings['separator'] / 2 ), absint( $og_defaults['separator'] / 2 ), 'px' );559560 $css->set_selector( '.separate-containers .page-header-image, .separate-containers .page-header-contained, .separate-containers .page-header-image-single, .separate-containers .page-header-content-single' );561 $css->add_property( 'margin-top', absint( $spacing_settings['separator'] ), absint( $og_defaults['separator'] ), 'px' );562563 $css->set_selector( '.separate-containers .inside-right-sidebar, .separate-containers .inside-left-sidebar' );564 $css->add_property( 'margin-top', absint( $spacing_settings['separator'] ), absint( $og_defaults['separator'] ), 'px' );565 $css->add_property( 'margin-bottom', absint( $spacing_settings['separator'] ), absint( $og_defaults['separator'] ), 'px' );566567 $css->set_selector( '.main-navigation .main-nav ul li a,.menu-toggle,.main-navigation .mobile-bar-items a' );568 $css->add_property( 'padding-left', absint( $spacing_settings['menu_item'] ), absint( $og_defaults['menu_item'] ), 'px' );569 $css->add_property( 'padding-right', absint( $spacing_settings['menu_item'] ), absint( $og_defaults['menu_item'] ), 'px' );570 $css->add_property( 'line-height', absint( $spacing_settings['menu_item_height'] ), absint( $og_defaults['menu_item_height'] ), 'px' );571572 $css->set_selector( '.main-navigation .main-nav ul ul li a' );573 $css->add_property( 'padding', generate_padding_css( $spacing_settings['sub_menu_item_height'], $spacing_settings['menu_item'], $spacing_settings['sub_menu_item_height'], $spacing_settings['menu_item'] ), generate_padding_css( $og_defaults['sub_menu_item_height'], $og_defaults['menu_item'], $og_defaults['sub_menu_item_height'], $og_defaults['menu_item'] ) );574575 $css->set_selector( '.main-navigation ul ul' );576 $css->add_property( 'width', absint( $spacing_settings['sub_menu_width'] ), absint( $og_defaults['sub_menu_width'] ), 'px' );577578 $css->set_selector( '.navigation-search input' );579 $css->add_property( 'height', absint( $spacing_settings['menu_item_height'] ), absint( $og_defaults['menu_item_height'] ), 'px' );580581 $css->set_selector( '.rtl .menu-item-has-children .dropdown-menu-toggle' );582 $css->add_property( 'padding-left', absint( $spacing_settings['menu_item'] ), false, 'px' );583584 $css->set_selector( '.menu-item-has-children .dropdown-menu-toggle' );585 $css->add_property( 'padding-right', absint( $spacing_settings['menu_item'] ), absint( $og_defaults['menu_item'] ), 'px' );586587 $css->set_selector( '.menu-item-has-children ul .dropdown-menu-toggle' );588 $css->add_property( 'padding-top', absint( $spacing_settings['sub_menu_item_height'] ), absint( $og_defaults['sub_menu_item_height'] ), 'px' );589 $css->add_property( 'padding-bottom', absint( $spacing_settings['sub_menu_item_height'] ), absint( $og_defaults['sub_menu_item_height'] ), 'px' );590 $css->add_property( 'margin-top', '-' . absint( $spacing_settings['sub_menu_item_height'] ), '-' . absint( $og_defaults['sub_menu_item_height'] ), 'px' );591592 $css->set_selector( '.rtl .main-navigation .main-nav ul li.menu-item-has-children > a' );593 $css->add_property( 'padding-right', absint( $spacing_settings['menu_item'] ), false, 'px' );594595 $css->set_selector( '.widget-area .widget' );596 $css->add_property( 'padding', generate_padding_css( $spacing_settings['widget_top'], $spacing_settings['widget_right'], $spacing_settings['widget_bottom'], $spacing_settings['widget_left'] ), generate_padding_css( $og_defaults['widget_top'], $og_defaults['widget_right'], $og_defaults['widget_bottom'], $og_defaults['widget_left'] ) );597598 $css->set_selector( '.footer-widgets' );599 $css->add_property( 'padding', generate_padding_css( $spacing_settings['footer_widget_container_top'], $spacing_settings['footer_widget_container_right'], $spacing_settings['footer_widget_container_bottom'], $spacing_settings['footer_widget_container_left'] ), generate_padding_css( $og_defaults['footer_widget_container_top'], $og_defaults['footer_widget_container_right'], $og_defaults['footer_widget_container_bottom'], $og_defaults['footer_widget_container_left'] ) );600601 $css->set_selector( '.site-footer .footer-widgets-container .inner-padding' );602 $css->add_property( 'padding', generate_padding_css( '0', '0', '0', $spacing_settings['footer_widget_separator'] ), generate_padding_css( '0', '0', '0', $og_defaults['footer_widget_separator'] ) );603604 $css->set_selector( '.site-footer .footer-widgets-container .inside-footer-widgets' );605 $css->add_property( 'margin-left', '-' . absint( $spacing_settings['footer_widget_separator'] ), '-' . absint( $og_defaults['footer_widget_separator'] ), 'px' );606607 $css->set_selector( '.site-info' );608 $css->add_property( 'padding', generate_padding_css( $spacing_settings['footer_top'], $spacing_settings['footer_right'], $spacing_settings['footer_bottom'], $spacing_settings['footer_left'] ), generate_padding_css( $og_defaults['footer_top'], $og_defaults['footer_right'], $og_defaults['footer_bottom'], $og_defaults['footer_left'] ) );609610 $css->start_media_query( generate_get_media_query( 'mobile' ) );611 $css->set_selector( '.separate-containers .inside-article, .separate-containers .comments-area, .separate-containers .page-header, .separate-containers .paging-navigation, .one-container .site-content, .inside-page-header, .wp-block-group__inner-container' );612 $css->add_property( 'padding', generate_padding_css( $spacing_settings['mobile_content_top'], $spacing_settings['mobile_content_right'], $spacing_settings['mobile_content_bottom'], $spacing_settings['mobile_content_left'] ) );613614 $mobile_content_padding = absint( $spacing_settings['mobile_content_right'] ) + absint( $spacing_settings['mobile_content_left'] );615 $css->set_selector( '.entry-content .alignwide, body:not(.no-sidebar) .entry-content .alignfull' );616 $css->add_property( 'margin-left', '-' . absint( $spacing_settings['mobile_content_left'] ) . 'px' );617 $css->add_property( 'width', 'calc(100% + ' . absint( $mobile_content_padding ) . 'px)' );618 $css->add_property( 'max-width', 'calc(100% + ' . absint( $mobile_content_padding ) . 'px)' );619620 if ( '' !== $spacing_settings['mobile_separator'] ) {621 $css->set_selector( '.separate-containers .widget, .separate-containers .site-main > *, .separate-containers .page-header' );622 $css->add_property( 'margin-bottom', absint( $spacing_settings['mobile_separator'] ), false, 'px' );623624 $css->set_selector( '.separate-containers .site-main' );625 $css->add_property( 'margin', absint( $spacing_settings['mobile_separator'] ), false, 'px' );626627 $css->set_selector( '.separate-containers .page-header-image, .separate-containers .page-header-image-single' );628 $css->add_property( 'margin-top', absint( $spacing_settings['mobile_separator'] ), false, 'px' );629630 $css->set_selector( '.separate-containers .inside-right-sidebar, .separate-containers .inside-left-sidebar' );631 $css->add_property( 'margin-top', absint( $spacing_settings['mobile_separator'] ), false, 'px' );632 $css->add_property( 'margin-bottom', absint( $spacing_settings['mobile_separator'] ), false, 'px' );633 }634 $css->stop_media_query();635636 // Add spacing back where dropdown arrow should be.637 // Old versions of WP don't get nice things.638 if ( version_compare( $GLOBALS['wp_version'], '4.4', '<' ) ) {639 $css->set_selector( '.main-navigation .main-nav ul li.menu-item-has-children>a, .secondary-navigation .main-nav ul li.menu-item-has-children>a' );640 $css->add_property( 'padding-right', absint( $spacing_settings['menu_item'] ), absint( $og_defaults['menu_item'] ), 'px' );641 }642643 $output = '';644645 $generate_settings = wp_parse_args(646 get_option( 'generate_settings', array() ),647 generate_get_color_defaults()648 );649650 // Find out if the content background color and sidebar widget background color is the same.651 $sidebar = strtoupper( $generate_settings['sidebar_widget_background_color'] );652 $content = strtoupper( $generate_settings['content_background_color'] );653 $colors_match = ( ( $sidebar == $content ) || '' == $sidebar ) ? true : false;654655 // If they're all 40 (default), remove the padding when one container is set.656 // This way, the user can still adjust the padding and it will work (unless they want 40px padding).657 // We'll also remove the padding if there's no color difference between the widgets and content background color.658 if ( ( '40' == $spacing_settings['widget_top'] && '40' == $spacing_settings['widget_right'] && '40' == $spacing_settings['widget_bottom'] && '40' == $spacing_settings['widget_left'] ) && $colors_match ) {659 $output .= '.one-container .sidebar .widget{padding:0px;}';660 }661662 do_action( 'generate_spacing_css', $css );663664 return apply_filters( 'generate_spacing_css_output', $css->css_output() . $output );665 }666}667668/**669 * Generates any CSS that can't be cached (can change from page to page).670 *671 * @since 2.0672 */673function generate_no_cache_dynamic_css() {674 $css = new GeneratePress_CSS;675676 if ( ! generate_show_title() ) {677 $css->set_selector( '.page .entry-content' )->add_property( 'margin-top', '0px' );678679 if ( is_single() ) {680 if ( ! apply_filters( 'generate_post_author', true ) && ! apply_filters( 'generate_post_date', true ) ) {681 $css->set_selector( '.single .entry-content' )->add_property( 'margin-top', '0px' );682 }683 }684 }685686 $css->start_media_query( generate_get_media_query( 'mobile-menu' ) );687 $css->set_selector( '.main-navigation .menu-toggle,.main-navigation .mobile-bar-items,.sidebar-nav-mobile:not(#sticky-placeholder)' );688 $css->add_property( 'display', 'block' );689690 $css->set_selector( '.main-navigation ul,.gen-sidebar-nav' );691 $css->add_property( 'display', 'none' );692693 $css->set_selector( '[class*="nav-float-"] .site-header .inside-header > *' );694 $css->add_property( 'float', 'none' );695 $css->add_property( 'clear', 'both' );696 $css->stop_media_query();697698 return $css->css_output();699}700701add_action( 'wp_enqueue_scripts', 'generate_enqueue_dynamic_css', 50 );702/**703 * Enqueue our dynamic CSS.704 *705 * @since 2.0706 */707function generate_enqueue_dynamic_css() {708 if ( ! get_option( 'generate_dynamic_css_output', false ) || is_customize_preview() || apply_filters( 'generate_dynamic_css_skip_cache', false ) ) {709 $css = generate_base_css() . generate_font_css() . generate_advanced_css() . generate_spacing_css();710 } else {711 $css = get_option( 'generate_dynamic_css_output' ) . '/* End cached CSS */';712 }713714 $css = $css . generate_no_cache_dynamic_css() . generate_do_icon_css();715716 wp_add_inline_style( 'generate-style', $css );717}718719add_action( 'init', 'generate_set_dynamic_css_cache' );720/**721 * Sets our dynamic CSS cache if it doesn't exist.722 *723 * If the theme version changed, bust the cache.724 *725 * @since 2.0726 */727function generate_set_dynamic_css_cache() {728 if ( apply_filters( 'generate_dynamic_css_skip_cache', false ) ) {729 return;730 }731732 $cached_css = get_option( 'generate_dynamic_css_output', false );733 $cached_version = get_option( 'generate_dynamic_css_cached_version', '' );734735 if ( ! $cached_css || $cached_version !== GENERATE_VERSION ) {736 $css = generate_base_css() . generate_font_css() . generate_advanced_css() . generate_spacing_css();737738 update_option( 'generate_dynamic_css_output', $css );739 update_option( 'generate_dynamic_css_cached_version', GENERATE_VERSION );740 }741}742743add_action( 'customize_save_after', 'generate_update_dynamic_css_cache' );744/**745 * Update our CSS cache when done saving Customizer options.746 *747 * @since 2.0748 */749function generate_update_dynamic_css_cache() {750 if ( apply_filters( 'generate_dynamic_css_skip_cache', false ) ) {751 return;752 }753754 $css = generate_base_css() . generate_font_css() . generate_advanced_css() . generate_spacing_css();755 update_option( 'generate_dynamic_css_output', $css );756}757758/**759 * Output CSS for the icon fonts.760 *761 * @since 2.3762 */763function generate_do_icon_css() {764 $output = false;765766 if ( 'font' === generate_get_option( 'icons' ) ) {767 $url = trailingslashit( get_template_directory_uri() );768769 $output = '@font-face {770 font-family: "GeneratePress";771 src: url("' . $url . 'fonts/generatepress.eot");772 src: url("' . $url . 'fonts/generatepress.eot#iefix") format("embedded-opentype"),773 url("' . $url . 'fonts/generatepress.woff2") format("woff2"),774 url("' . $url . 'fonts/generatepress.woff") format("woff"),775 url("' . $url . 'fonts/generatepress.ttf") format("truetype"),776 url("' . $url . 'fonts/generatepress.svg#GeneratePress") format("svg");777 font-weight: normal;778 font-style: normal;779 }';780781 if ( defined( 'GENERATE_MENU_PLUS_VERSION' ) ) {782 $output .= '.main-navigation .slideout-toggle a:before,783 .slide-opened .slideout-overlay .slideout-exit:before {784 font-family: GeneratePress;785 }786787 .slideout-navigation .dropdown-menu-toggle:before {788 content: "\f107" !important;789 }790791 .slideout-navigation .sfHover > a .dropdown-menu-toggle:before {792 content: "\f106" !important;793 }';794 }795 }796797 if ( 'svg' === generate_get_option( 'icons' ) ) {798 $output = 'button.menu-toggle:before,799 .search-item a:before,800 .dropdown-menu-toggle:before,801 .cat-links:before,802 .tags-links:before,803 .comments-link:before,804 .nav-previous .prev:before,805 .nav-next .next:before,806 .generate-back-to-top:before {807 display: none;808 }';809 }810811 if ( $output ) {812 return str_replace( array( "\r", "\n", "\t" ), '', $output );813 }814} ...

Full Screen

Full Screen

ProgressBarTest.php

Source:ProgressBarTest.php Github

copy

Full Screen

...20 $bar->start();21 $bar->advance();22 rewind($output->getStream());23 $this->assertEquals(24 $this->generateOutput(' 0 [>---------------------------]').25 $this->generateOutput(' 1 [->--------------------------]'),26 stream_get_contents($output->getStream())27 );28 }29 public function testAdvanceWithStep()30 {31 $bar = new ProgressBar($output = $this->getOutputStream());32 $bar->start();33 $bar->advance(5);34 rewind($output->getStream());35 $this->assertEquals(36 $this->generateOutput(' 0 [>---------------------------]').37 $this->generateOutput(' 5 [----->----------------------]'),38 stream_get_contents($output->getStream())39 );40 }41 public function testAdvanceMultipleTimes()42 {43 $bar = new ProgressBar($output = $this->getOutputStream());44 $bar->start();45 $bar->advance(3);46 $bar->advance(2);47 rewind($output->getStream());48 $this->assertEquals(49 $this->generateOutput(' 0 [>---------------------------]').50 $this->generateOutput(' 3 [--->------------------------]').51 $this->generateOutput(' 5 [----->----------------------]'),52 stream_get_contents($output->getStream())53 );54 }55 public function testCustomizations()56 {57 $bar = new ProgressBar($output = $this->getOutputStream(), 10);58 $bar->setBarWidth(10);59 $bar->setBarCharacter('_');60 $bar->setEmptyBarCharacter(' ');61 $bar->setProgressCharacter('/');62 $bar->setFormat(' %current%/%max% [%bar%] %percent:3s%%');63 $bar->start();64 $bar->advance();65 rewind($output->getStream());66 $this->assertEquals(67 $this->generateOutput(' 0/10 [/ ] 0%').68 $this->generateOutput(' 1/10 [_/ ] 10%'),69 stream_get_contents($output->getStream())70 );71 }72 public function testPercent()73 {74 $bar = new ProgressBar($output = $this->getOutputStream(), 50);75 $bar->start();76 $bar->display();77 $bar->advance();78 $bar->advance();79 rewind($output->getStream());80 $this->assertEquals(81 $this->generateOutput(' 0/50 [>---------------------------] 0%').82 $this->generateOutput(' 0/50 [>---------------------------] 0%').83 $this->generateOutput(' 1/50 [>---------------------------] 2%').84 $this->generateOutput(' 2/50 [=>--------------------------] 4%'),85 stream_get_contents($output->getStream())86 );87 }88 public function testOverwriteWithShorterLine()89 {90 $bar = new ProgressBar($output = $this->getOutputStream(), 50);91 $bar->setFormat(' %current%/%max% [%bar%] %percent:3s%%');92 $bar->start();93 $bar->display();94 $bar->advance();95 // set shorter format96 $bar->setFormat(' %current%/%max% [%bar%]');97 $bar->advance();98 rewind($output->getStream());99 $this->assertEquals(100 $this->generateOutput(' 0/50 [>---------------------------] 0%').101 $this->generateOutput(' 0/50 [>---------------------------] 0%').102 $this->generateOutput(' 1/50 [>---------------------------] 2%').103 $this->generateOutput(' 2/50 [=>--------------------------] '),104 stream_get_contents($output->getStream())105 );106 }107 public function testSetCurrentProgress()108 {109 $bar = new ProgressBar($output = $this->getOutputStream(), 50);110 $bar->start();111 $bar->display();112 $bar->advance();113 $bar->setCurrent(15);114 $bar->setCurrent(25);115 rewind($output->getStream());116 $this->assertEquals(117 $this->generateOutput(' 0/50 [>---------------------------] 0%').118 $this->generateOutput(' 0/50 [>---------------------------] 0%').119 $this->generateOutput(' 1/50 [>---------------------------] 2%').120 $this->generateOutput(' 15/50 [========>-------------------] 30%').121 $this->generateOutput(' 25/50 [==============>-------------] 50%'),122 stream_get_contents($output->getStream())123 );124 }125 /**126 * @expectedException \LogicException127 * @expectedExceptionMessage You must start the progress bar128 */129 public function testSetCurrentBeforeStarting()130 {131 $bar = new ProgressBar($this->getOutputStream());132 $bar->setCurrent(15);133 }134 /**135 * @expectedException \LogicException136 * @expectedExceptionMessage You can't regress the progress bar137 */138 public function testRegressProgress()139 {140 $bar = new ProgressBar($output = $this->getOutputStream(), 50);141 $bar->start();142 $bar->setCurrent(15);143 $bar->setCurrent(10);144 }145 public function testRedrawFrequency()146 {147 $bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($output = $this->getOutputStream(), 6));148 $bar->expects($this->exactly(4))->method('display');149 $bar->setRedrawFrequency(2);150 $bar->start();151 $bar->setCurrent(1);152 $bar->advance(2);153 $bar->advance(2);154 $bar->advance(1);155 }156 public function testMultiByteSupport()157 {158 if (!function_exists('mb_strlen') || (false === $encoding = mb_detect_encoding('■'))) {159 $this->markTestSkipped('The mbstring extension is needed for multi-byte support');160 }161 $bar = new ProgressBar($output = $this->getOutputStream());162 $bar->start();163 $bar->setBarCharacter('■');164 $bar->advance(3);165 rewind($output->getStream());166 $this->assertEquals(167 $this->generateOutput(' 0 [>---------------------------]').168 $this->generateOutput(' 3 [■■■>------------------------]'),169 stream_get_contents($output->getStream())170 );171 }172 public function testClear()173 {174 $bar = new ProgressBar($output = $this->getOutputStream(), 50);175 $bar->start();176 $bar->setCurrent(25);177 $bar->clear();178 rewind($output->getStream());179 $this->assertEquals(180 $this->generateOutput(' 0/50 [>---------------------------] 0%').181 $this->generateOutput(' 25/50 [==============>-------------] 50%').182 $this->generateOutput(' '),183 stream_get_contents($output->getStream())184 );185 }186 public function testPercentNotHundredBeforeComplete()187 {188 $bar = new ProgressBar($output = $this->getOutputStream(), 200);189 $bar->start();190 $bar->display();191 $bar->advance(199);192 $bar->advance();193 rewind($output->getStream());194 $this->assertEquals(195 $this->generateOutput(' 0/200 [>---------------------------] 0%').196 $this->generateOutput(' 0/200 [>---------------------------] 0%').197 $this->generateOutput(' 199/200 [===========================>] 99%').198 $this->generateOutput(' 200/200 [============================] 100%'),199 stream_get_contents($output->getStream())200 );201 }202 public function testNonDecoratedOutput()203 {204 $bar = new ProgressBar($output = $this->getOutputStream(false));205 $bar->start();206 $bar->advance();207 rewind($output->getStream());208 $this->assertEquals('', stream_get_contents($output->getStream()));209 }210 public function testParallelBars()211 {212 $output = $this->getOutputStream();213 $bar1 = new ProgressBar($output, 2);214 $bar2 = new ProgressBar($output, 3);215 $bar2->setProgressCharacter('#');216 $bar3 = new ProgressBar($output);217 $bar1->start();218 $output->write("\n");219 $bar2->start();220 $output->write("\n");221 $bar3->start();222 for ($i = 1; $i <= 3; $i++) {223 // up two lines224 $output->write("\033[2A");225 if ($i <= 2) {226 $bar1->advance();227 }228 $output->write("\n");229 $bar2->advance();230 $output->write("\n");231 $bar3->advance();232 }233 $output->write("\033[2A");234 $output->write("\n");235 $output->write("\n");236 $bar3->finish();237 rewind($output->getStream());238 $this->assertEquals(239 $this->generateOutput(' 0/2 [>---------------------------] 0%')."\n".240 $this->generateOutput(' 0/3 [#---------------------------] 0%')."\n".241 rtrim($this->generateOutput(' 0 [>---------------------------]')).242 "\033[2A".243 $this->generateOutput(' 1/2 [==============>-------------] 50%')."\n".244 $this->generateOutput(' 1/3 [=========#------------------] 33%')."\n".245 rtrim($this->generateOutput(' 1 [->--------------------------]')).246 "\033[2A".247 $this->generateOutput(' 2/2 [============================] 100%')."\n".248 $this->generateOutput(' 2/3 [==================#---------] 66%')."\n".249 rtrim($this->generateOutput(' 2 [-->-------------------------]')).250 "\033[2A".251 "\n".252 $this->generateOutput(' 3/3 [============================] 100%')."\n".253 rtrim($this->generateOutput(' 3 [--->------------------------]')).254 "\033[2A".255 "\n".256 "\n".257 rtrim($this->generateOutput(' 3 [============================]')),258 stream_get_contents($output->getStream())259 );260 }261 public function testAddingPlaceholderFormatter()262 {263 ProgressBar::setPlaceholderFormatterDefinition('remaining_steps', function (ProgressBar $bar) {264 return $bar->getMaxSteps() - $bar->getStep();265 });266 $bar = new ProgressBar($output = $this->getOutputStream(), 3);267 $bar->setFormat(' %remaining_steps% [%bar%]');268 $bar->start();269 $bar->advance();270 $bar->finish();271 rewind($output->getStream());272 $this->assertEquals(273 $this->generateOutput(' 3 [>---------------------------]').274 $this->generateOutput(' 2 [=========>------------------]').275 $this->generateOutput(' 0 [============================]'),276 stream_get_contents($output->getStream())277 );278 }279 public function testMultilineFormat()280 {281 $bar = new ProgressBar($output = $this->getOutputStream(), 3);282 $bar->setFormat("%bar%\nfoobar");283 $bar->start();284 $bar->advance();285 $bar->clear();286 $bar->finish();287 rewind($output->getStream());288 $this->assertEquals(289 $this->generateOutput(">---------------------------\nfoobar").290 $this->generateOutput("=========>------------------\nfoobar ").291 $this->generateOutput(" \n ").292 $this->generateOutput("============================\nfoobar "),293 stream_get_contents($output->getStream())294 );295 }296 public function testAnsiColorsAndEmojis()297 {298 $bar = new ProgressBar($output = $this->getOutputStream(), 15);299 ProgressBar::setPlaceholderFormatterDefinition('memory', function (ProgressBar $bar) {300 static $i = 0;301 $mem = 100000 * $i;302 $colors = $i++ ? '41;37' : '44;37';303 return "\033[".$colors."m ".Helper::formatMemory($mem)." \033[0m";304 });305 $bar->setFormat(" \033[44;37m %title:-37s% \033[0m\n %current%/%max% %bar% %percent:3s%%\n 🏁 %remaining:-10s% %memory:37s%");306 $bar->setBarCharacter($done = "\033[32m●\033[0m");307 $bar->setEmptyBarCharacter($empty = "\033[31m●\033[0m");308 $bar->setProgressCharacter($progress = "\033[32m➤ \033[0m");309 $bar->setMessage('Starting the demo... fingers crossed', 'title');310 $bar->start();311 $bar->setMessage('Looks good to me...', 'title');312 $bar->advance(4);313 $bar->setMessage('Thanks, bye', 'title');314 $bar->finish();315 rewind($output->getStream());316 $this->assertEquals(317 $this->generateOutput(318 " \033[44;37m Starting the demo... fingers crossed \033[0m\n".319 " 0/15 ".$progress.str_repeat($empty, 26)." 0%\n".320 " \xf0\x9f\x8f\x81 1 sec \033[44;37m 0 B \033[0m"321 ).322 $this->generateOutput(323 " \033[44;37m Looks good to me... \033[0m\n".324 " 4/15 ".str_repeat($done, 7).$progress.str_repeat($empty, 19)." 26%\n".325 " \xf0\x9f\x8f\x81 1 sec \033[41;37m 97 KiB \033[0m"326 ).327 $this->generateOutput(328 " \033[44;37m Thanks, bye \033[0m\n".329 " 15/15 ".str_repeat($done, 28)." 100%\n".330 " \xf0\x9f\x8f\x81 1 sec \033[41;37m 195 KiB \033[0m"331 ),332 stream_get_contents($output->getStream())333 );334 }335 public function testSetFormat()336 {337 $bar = new ProgressBar($output = $this->getOutputStream());338 $bar->setFormat('normal');339 $bar->start();340 rewind($output->getStream());341 $this->assertEquals(342 $this->generateOutput(' 0 [>---------------------------]'),343 stream_get_contents($output->getStream())344 );345 $bar = new ProgressBar($output = $this->getOutputStream(), 10);346 $bar->setFormat('normal');347 $bar->start();348 rewind($output->getStream());349 $this->assertEquals(350 $this->generateOutput(' 0/10 [>---------------------------] 0%'),351 stream_get_contents($output->getStream())352 );353 }354 protected function getOutputStream($decorated = true)355 {356 return new StreamOutput(fopen('php://memory', 'r+', false), StreamOutput::VERBOSITY_NORMAL, $decorated);357 }358 protected function generateOutput($expected)359 {360 $count = substr_count($expected, "\n");361 return "\x0D".($count ? sprintf("\033[%dA", $count) : '').$expected;362 }363}...

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1$set = new Set();2$set->add(1);3$set->add(2);4$set->add(3);5$set->add(4);6$set->add(5);7$set->add(6);8$set->add(7);9$set->add(8);10$set->add(9);11$set->add(10);12$set->add(11);13$set->add(12);14$set->add(13);15$set->add(14);16$set->add(15);17$set->add(16);18$set->add(17);19$set->add(18);20$set->add(19);21$set->add(20);22$set->add(21);23$set->add(22);24$set->add(23);25$set->add(24);26$set->add(25);27$set->add(26);28$set->add(27);29$set->add(28);30$set->add(29);31$set->add(30);32$set->add(31);33$set->add(32);34$set->add(33);35$set->add(34);36$set->add(35);37$set->add(36);38$set->add(37);39$set->add(38);40$set->add(39);41$set->add(40);42$set->add(41);43$set->add(42);44$set->add(43);45$set->add(44);46$set->add(45);47$set->add(46);48$set->add(47);49$set->add(48);50$set->add(49);51$set->add(50);52$set->add(51);53$set->add(52);54$set->add(53);55$set->add(54);56$set->add(55);57$set->add(56);58$set->add(57);59$set->add(58);60$set->add(59);61$set->add(60);62$set->add(61);63$set->add(62);64$set->add(63);65$set->add(64);66$set->add(65);67$set->add(66);68$set->add(67);69$set->add(68);70$set->add(69);71$set->add(70);

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1$set = new Set();2$set->generate(1, 100, 10);3$set = new Set();4$set->generate(1, 100, 10);5{6 private static $set = array();7 public function generate($min, $max, $count)8 {9 self::$set = array();10 for ($i = 0; $i < $count; $i++) {11 $number = mt_rand($min, $max);12 self::$set[$number] = $number;13 }14 return self::$set;15 }16}17$set = new Set();18$set->generate(1, 100, 10);19$set = new Set();20$set->generate(1, 100, 10);

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1$set = new set();2$set->generate();3$set = new set();4$set->generate();5class set {6 function generate() {7 echo "Hello World";8 }9}10include_once "set.php";11$set = new set();12$set->generate();

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1$set = new Set();2$set->generate(1, 100, 10);3$set = new Set();4$set->generate(1, 100, 10);5$set = new Set();6$set->generate(1, 100, 10);7$set = new Set();8$set->generate(1, 100, 10);9$set = new Set();10$set->generate(1, 100, 10);11$set = new Set();12$set->generate(1, 100, 10);13$set = new Set();14$set->generate(1, 100, 10);15$set = new Set();16$set->generate(1, 100, 10);17$set = new Set();18$set->generate(1, 100, 10);19$set = new Set();20$set->generate(1, 100, 10);21$set = new Set();22$set->generate(1, 100, 10);23$set = new Set();24$set->generate(1, 100, 10);25$set = new Set();26$set->generate(1, 100, 10);27$set = new Set();28$set->generate(1, 100, 10);

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1$set = new Set();2$set->add('a');3$set->add('b');4$set->add('c');5echo $set->generate();6$set = new Set();7$set->add('a');8$set->add('b');9$set->add('c');10echo $set->generate();11$set = new Set();12$set->add('a');13$set->add('b');14$set->add('c');15echo $set->generate();

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1$set = new Set();2$set->generate(5, 10);3$set = new Set();4$set->generate(5, 10);5$set = new Set();6$set->generate(5, 10);7$set = new Set();8$set->generate(5, 10);9$set = new Set();10$set->generate(5, 10);11$set = new Set();12$set->generate(5, 10);13$set = new Set();14$set->generate(5, 10);15$set = new Set();16$set->generate(5, 10);17$set = new Set();18$set->generate(5, 10);19$set = new Set();20$set->generate(5, 10);21$set = new Set();22$set->generate(5, 10);23$set = new Set();24$set->generate(5, 10);25$set = new Set();26$set->generate(5, 10);27$set = new Set();28$set->generate(5,

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1$set = new Set();2$set->generate(1, 100, 10);3class Set {4 public function generate($min, $max, $count) {5 }6}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger generate code on LambdaTest Cloud Grid

Execute automation tests with generate on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful