Initial commit

This commit is contained in:
2020-04-07 13:03:04 +00:00
committed by Gitium
commit 00f842d9bf
1673 changed files with 471161 additions and 0 deletions

View File

@ -0,0 +1,390 @@
<?php
/**
* Integrate GeneratePress with the WordPress block editor.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Check what sidebar layout we're using.
* We need this function as the post meta in generate_get_layout() only runs
* on is_singular()
*
* @since 2.2
*
* @param bool $meta Check for post meta.
* @return string The saved sidebar layout.
*/
function generate_get_block_editor_sidebar_layout( $meta = true ) {
$layout = generate_get_option( 'layout_setting' );
if ( function_exists( 'get_current_screen' ) ) {
$screen = get_current_screen();
if ( is_object( $screen ) && 'post' === $screen->post_type ) {
$layout = generate_get_option( 'single_layout_setting' );
}
}
// Add in our default filter in case people have adjusted it.
$layout = apply_filters( 'generate_sidebar_layout', $layout );
if ( $meta ) {
$layout_meta = get_post_meta( get_the_ID(), '_generate-sidebar-layout-meta', true );
if ( $layout_meta ) {
$layout = $layout_meta;
}
}
return apply_filters( 'generate_block_editor_sidebar_layout', $layout );
}
/**
* Check whether we're disabling the content title or not.
* We need this function as the post meta in generate_show_title() only runs
* on is_singular()
*
* @since 2.2
*/
function generate_get_block_editor_show_content_title() {
$title = generate_show_title();
$disable_title = get_post_meta( get_the_ID(), '_generate-disable-headline', true );
if ( $disable_title ) {
$title = false;
}
return apply_filters( 'generate_block_editor_show_content_title', $title );
}
/**
* Get the content width for this post.
*
* @since 2.2
*/
function generate_get_block_editor_content_width() {
$container_width = generate_get_option( 'container_width' );
$content_width = $container_width;
$right_sidebar_width = apply_filters( 'generate_right_sidebar_width', '25' );
$left_sidebar_width = apply_filters( 'generate_left_sidebar_width', '25' );
$layout = generate_get_block_editor_sidebar_layout();
if ( 'left-sidebar' == $layout ) {
$content_width = $container_width * ( ( 100 - $left_sidebar_width ) / 100 );
} elseif ( 'right-sidebar' == $layout ) {
$content_width = $container_width * ( ( 100 - $right_sidebar_width ) / 100 );
} elseif ( 'no-sidebar' == $layout ) {
$content_width = $container_width;
} else {
$content_width = $container_width * ( ( 100 - ( $left_sidebar_width + $right_sidebar_width ) ) / 100 );
}
return apply_filters( 'generate_block_editor_content_width', $content_width );
}
add_action( 'enqueue_block_editor_assets', 'generate_enqueue_google_fonts' );
add_action( 'enqueue_block_editor_assets', 'generate_enqueue_backend_block_editor_assets' );
/**
* Add CSS to the admin side of the block editor.
*
* @since 2.2
*/
function generate_enqueue_backend_block_editor_assets() {
wp_enqueue_style( 'generate-block-editor-styles', get_template_directory_uri() . "/css/admin/block-editor.css", false, GENERATE_VERSION, 'all' );
wp_enqueue_script( 'generate-block-editor-tinycolor', get_template_directory_uri() . "/js/admin/tinycolor.js", false, GENERATE_VERSION, true );
wp_enqueue_script( 'generate-block-editor-scripts', get_template_directory_uri() . "/js/admin/block-editor.js", array( 'jquery', 'generate-block-editor-tinycolor' ), GENERATE_VERSION, true );
$show_editor_styles = apply_filters( 'generate_show_block_editor_styles', true );
if ( $show_editor_styles ) {
wp_add_inline_style( 'generate-block-editor-styles', generate_do_inline_block_editor_css() );
}
$color_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_color_defaults()
);
$spacing_settings = wp_parse_args(
get_option( 'generate_spacing_settings', array() ),
generate_spacing_get_defaults()
);
$text_color = generate_get_option( 'text_color' );
if ( $color_settings['content_text_color'] ) {
$text_color = $color_settings['content_text_color'];
}
wp_localize_script( 'generate-block-editor-scripts', 'generate_block_editor', array(
'global_sidebar_layout' => generate_get_block_editor_sidebar_layout( false ),
'container_width' => generate_get_option( 'container_width' ),
'right_sidebar_width' => apply_filters( 'generate_right_sidebar_width', '25' ),
'left_sidebar_width' => apply_filters( 'generate_left_sidebar_width', '25' ),
'content_padding_right' => absint( $spacing_settings['content_right'] ) . 'px',
'content_padding_left' => absint( $spacing_settings['content_left'] ) . 'px',
'content_title' => generate_get_block_editor_show_content_title() ? 'true' : 'false',
'disable_content_title' => esc_html( 'Disable Content Title', 'generatepress' ),
'show_content_title' => esc_html( 'Show Content Title', 'generatepress' ),
'text_color' => $text_color,
'show_editor_styles' => $show_editor_styles,
) );
}
/**
* Write our CSS for the block editor.
*
* @since 2.2
*/
function generate_do_inline_block_editor_css() {
$color_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_color_defaults()
);
$font_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_default_fonts()
);
$css = new GeneratePress_CSS;
$content_width = generate_get_block_editor_content_width();
$spacing_settings = wp_parse_args(
get_option( 'generate_spacing_settings', array() ),
generate_spacing_get_defaults()
);
$content_width_calc = sprintf(
'calc(%1$s - %2$s - %3$s)',
absint( $content_width ) . 'px',
absint( $spacing_settings['content_left'] ) . 'px',
absint( $spacing_settings['content_right'] ) . 'px'
);
$css->set_selector( 'body .wp-block, html body.gutenberg-editor-page .editor-post-title__block, html body.gutenberg-editor-page .editor-default-block-appender, html body.gutenberg-editor-page .editor-block-list__block' );
if ( 'true' === get_post_meta( get_the_ID(), '_generate-full-width-content', true ) ) {
$css->add_property( 'max-width', '100%' );
} else {
$css->add_property( 'max-width', $content_width_calc );
}
$css->set_selector( 'html body.gutenberg-editor-page .block-editor-block-list__block[data-align="full"]' );
$css->add_property( 'max-width', 'none' );
$css->set_selector( '.edit-post-visual-editor .block-editor-block-list__block[data-align=wide]' );
$css->add_property( 'max-width', absint( $content_width ), false, 'px' );
if ( apply_filters( 'generate_do_group_inner_container_style', true ) ) {
$css->set_selector( '.wp-block-group__inner-container' );
$css->add_property( 'max-width', absint( $content_width ), false, 'px' );
$css->add_property( 'margin-left', 'auto' );
$css->add_property( 'margin-right', 'auto' );
$css->add_property( 'padding', generate_padding_css( $spacing_settings['content_top'], $spacing_settings['content_right'], $spacing_settings['content_bottom'], $spacing_settings['content_left'] ) );
}
$css->set_selector( '.wp-block-button__link:not(.has-background)' );
$css->add_property( 'color', esc_attr( $color_settings['form_button_text_color'] ) );
$css->add_property( 'background-color', esc_attr( $color_settings['form_button_background_color'] ) );
$css->set_selector( '.wp-block-button__link:not(.has-background):active, .wp-block-button__link:not(.has-background):focus, .wp-block-button__link:not(.has-background):hover' );
$css->add_property( 'color', esc_attr( $color_settings['form_button_text_color_hover'] ) );
$css->add_property( 'background-color', esc_attr( $color_settings['form_button_background_color_hover'] ) );
$body_family = generate_get_font_family_css( 'font_body', 'generate_settings', generate_get_default_fonts() );
$h1_family = generate_get_font_family_css( 'font_heading_1', 'generate_settings', generate_get_default_fonts() );
$h2_family = generate_get_font_family_css( 'font_heading_2', 'generate_settings', generate_get_default_fonts() );
$h3_family = generate_get_font_family_css( 'font_heading_3', 'generate_settings', generate_get_default_fonts() );
$h4_family = generate_get_font_family_css( 'font_heading_4', 'generate_settings', generate_get_default_fonts() );
$h5_family = generate_get_font_family_css( 'font_heading_5', 'generate_settings', generate_get_default_fonts() );
$h6_family = generate_get_font_family_css( 'font_heading_6', 'generate_settings', generate_get_default_fonts() );
$buttons_family = generate_get_font_family_css( 'font_buttons', 'generate_settings', generate_get_default_fonts() );
$css->set_selector( 'body.gutenberg-editor-page .block-editor-block-list__block, body .editor-styles-wrapper' );
$css->add_property( 'font-family', $body_family );
$css->add_property( 'font-size', absint( $font_settings['body_font_size'] ), false, 'px' );
if ( $color_settings['content_text_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['content_text_color'] ) );
} else {
$css->add_property( 'color', esc_attr( generate_get_option( 'text_color' ) ) );
}
$css->set_selector( '.content-title-visibility' );
if ( $color_settings['content_text_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['content_text_color'] ) );
} else {
$css->add_property( 'color', esc_attr( generate_get_option( 'text_color' ) ) );
}
$css->set_selector( 'body .editor-styles-wrapper, body .editor-styles-wrapper p, body .editor-styles-wrapper .mce-content-body' );
$css->add_property( 'line-height', floatval( $font_settings['body_line_height'] ) );
$css->set_selector( 'body .editor-styles-wrapper h1, .wp-block-heading h1.editor-rich-text__tinymce, .editor-post-title__block .editor-post-title__input' );
$css->add_property( 'font-family', 'inherit' === $h1_family || '' === $h1_family ? $body_family : $h1_family );
$css->add_property( 'font-weight', esc_attr( $font_settings['heading_1_weight'] ) );
$css->add_property( 'text-transform', esc_attr( $font_settings['heading_1_transform'] ) );
$css->add_property( 'font-size', absint( $font_settings['heading_1_font_size'] ), false, 'px' );
$css->add_property( 'line-height', floatval( $font_settings['heading_1_line_height'] ), false, 'em' );
if ( $color_settings['h1_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['h1_color'] ) );
} elseif ( $color_settings['content_text_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['content_text_color'] ) );
} else {
$css->add_property( 'color', esc_attr( generate_get_option( 'text_color' ) ) );
}
if ( $color_settings['content_title_color'] ) {
$css->set_selector( '.editor-post-title__block .editor-post-title__input' );
$css->add_property( 'color', esc_attr( $color_settings['content_title_color'] ) );
}
$css->set_selector( 'body .editor-styles-wrapper h2, .wp-block-heading h2.editor-rich-text__tinymce' );
$css->add_property( 'font-family', $h2_family );
$css->add_property( 'font-weight', esc_attr( $font_settings['heading_2_weight'] ) );
$css->add_property( 'text-transform', esc_attr( $font_settings['heading_2_transform'] ) );
$css->add_property( 'font-size', absint( $font_settings['heading_2_font_size'] ), false, 'px' );
$css->add_property( 'line-height', floatval( $font_settings['heading_2_line_height'] ), false, 'em' );
if ( $color_settings['h2_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['h2_color'] ) );
} elseif ( $color_settings['content_text_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['content_text_color'] ) );
} else {
$css->add_property( 'color', esc_attr( generate_get_option( 'text_color' ) ) );
}
$css->set_selector( 'body .editor-styles-wrapper h3, .wp-block-heading h3.editor-rich-text__tinymce' );
$css->add_property( 'font-family', $h3_family );
$css->add_property( 'font-weight', esc_attr( $font_settings['heading_3_weight'] ) );
$css->add_property( 'text-transform', esc_attr( $font_settings['heading_3_transform'] ) );
$css->add_property( 'font-size', absint( $font_settings['heading_3_font_size'] ), false, 'px' );
$css->add_property( 'line-height', floatval( $font_settings['heading_3_line_height'] ), false, 'em' );
if ( $color_settings['h3_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['h3_color'] ) );
} elseif ( $color_settings['content_text_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['content_text_color'] ) );
} else {
$css->add_property( 'color', esc_attr( generate_get_option( 'text_color' ) ) );
}
$css->set_selector( 'body .editor-styles-wrapper h4, .wp-block-heading h4.editor-rich-text__tinymce' );
$css->add_property( 'font-family', $h4_family );
$css->add_property( 'font-weight', esc_attr( $font_settings['heading_4_weight'] ) );
$css->add_property( 'text-transform', esc_attr( $font_settings['heading_4_transform'] ) );
if ( '' !== $font_settings['heading_4_font_size'] ) {
$css->add_property( 'font-size', absint( $font_settings['heading_4_font_size'] ), false, 'px' );
} else {
$css->add_property( 'font-size', 'inherit' );
}
if ( '' !== $font_settings['heading_4_line_height'] ) {
$css->add_property( 'line-height', floatval( $font_settings['heading_4_line_height'] ), false, 'em' );
}
if ( $color_settings['h4_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['h4_color'] ) );
} elseif ( $color_settings['content_text_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['content_text_color'] ) );
} else {
$css->add_property( 'color', esc_attr( generate_get_option( 'text_color' ) ) );
}
$css->set_selector( 'body .editor-styles-wrapper h5, .wp-block-heading h5.editor-rich-text__tinymce' );
$css->add_property( 'font-family', $h5_family );
$css->add_property( 'font-weight', esc_attr( $font_settings['heading_5_weight'] ) );
$css->add_property( 'text-transform', esc_attr( $font_settings['heading_5_transform'] ) );
if ( '' !== $font_settings['heading_5_font_size'] ) {
$css->add_property( 'font-size', absint( $font_settings['heading_5_font_size'] ), false, 'px' );
} else {
$css->add_property( 'font-size', 'inherit' );
}
if ( '' !== $font_settings['heading_5_line_height'] ) {
$css->add_property( 'line-height', floatval( $font_settings['heading_5_line_height'] ), false, 'em' );
}
if ( $color_settings['h5_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['h5_color'] ) );
} elseif ( $color_settings['content_text_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['content_text_color'] ) );
} else {
$css->add_property( 'color', esc_attr( generate_get_option( 'text_color' ) ) );
}
$css->set_selector( 'body .editor-styles-wrapper h6, .wp-block-heading h6.editor-rich-text__tinymce' );
$css->add_property( 'font-family', $h6_family );
$css->add_property( 'font-weight', esc_attr( $font_settings['heading_6_weight'] ) );
$css->add_property( 'text-transform', esc_attr( $font_settings['heading_6_transform'] ) );
if ( '' !== $font_settings['heading_6_font_size'] ) {
$css->add_property( 'font-size', absint( $font_settings['heading_6_font_size'] ), false, 'px' );
} else {
$css->add_property( 'font-size', 'inherit' );
}
if ( '' !== $font_settings['heading_6_line_height'] ) {
$css->add_property( 'line-height', floatval( $font_settings['heading_6_line_height'] ), false, 'em' );
}
if ( $color_settings['h6_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['h6_color'] ) );
} elseif ( $color_settings['content_text_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['content_text_color'] ) );
} else {
$css->add_property( 'color', esc_attr( generate_get_option( 'text_color' ) ) );
}
$css->set_selector( '.block-editor-block-list__layout .wp-block-button .wp-block-button__link' );
$css->add_property( 'font-family', $buttons_family );
$css->add_property( 'font-weight', esc_attr( $font_settings['buttons_font_weight'] ) );
$css->add_property( 'text-transform', esc_attr( $font_settings['buttons_font_transform'] ) );
if ( '' !== $font_settings['buttons_font_size'] ) {
$css->add_property( 'font-size', absint( $font_settings['buttons_font_size'] ), false, 'px' );
}
$css->set_selector( 'body .editor-styles-wrapper' );
$css->add_property( 'background-color', esc_attr( generate_get_option( 'background_color' ) ) );
if ( $color_settings['content_background_color'] ) {
$body_background = esc_attr( generate_get_option( 'background_color' ) );
$content_background = esc_attr( $color_settings['content_background_color'] );
$css->add_property( 'background', 'linear-gradient(' . $content_background . ',' . $content_background . '), linear-gradient(' . $body_background . ',' . $body_background . ')' );
}
$css->set_selector( '.block-editor-block-list__block a, .block-editor-block-list__block a:visited' );
if ( $color_settings['content_link_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['content_link_color'] ) );
} else {
$css->add_property( 'color', esc_attr( generate_get_option( 'link_color' ) ) );
}
$css->set_selector( '.block-editor-block-list__block a:hover, .block-editor-block-list__block a:focus, .block-editor-block-list__block a:active' );
if ( $color_settings['content_link_hover_color'] ) {
$css->add_property( 'color', esc_attr( $color_settings['content_link_hover_color'] ) );
} else {
$css->add_property( 'color', esc_attr( generate_get_option( 'link_color_hover' ) ) );
}
return $css->css_output();
}

View File

@ -0,0 +1,212 @@
<?php
/**
* Builds our dynamic CSS.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'GeneratePress_CSS' ) ) {
/**
* Creates minified css via PHP.
*
* @author Carlos Rios
* Modified by Tom Usborne for GeneratePress
*/
class GeneratePress_CSS {
/**
* The css selector that you're currently adding rules to
*
* @access protected
* @var string
*/
protected $_selector = '';
/**
* Stores the final css output with all of its rules for the current selector.
*
* @access protected
* @var string
*/
protected $_selector_output = '';
/**
* Stores all of the rules that will be added to the selector
*
* @access protected
* @var string
*/
protected $_css = '';
/**
* The string that holds all of the css to output
*
* @access protected
* @var string
*/
protected $_output = '';
/**
* Stores media queries
*
* @var null
*/
protected $_media_query = null;
/**
* The string that holds all of the css to output inside of the media query
*
* @access protected
* @var string
*/
protected $_media_query_output = '';
/**
* Sets a selector to the object and changes the current selector to a new one
*
* @access public
* @since 1.0
*
* @param string $selector - the css identifier of the html that you wish to target
* @return $this
*/
public function set_selector( $selector = '' ) {
// Render the css in the output string everytime the selector changes.
if ( $this->_selector !== '' ) {
$this->add_selector_rules_to_output();
}
$this->_selector = $selector;
return $this;
}
/**
* Adds a css property with value to the css output
*
* @access public
* @since 1.0
*
* @param string $property - the css property
* @param string $value - the value to be placed with the property
* @param string $og_default - check to see if the value matches the default
* @param string $unit - the unit for the value (px)
* @return $this
*/
public function add_property( $property, $value, $og_default = false, $unit = false ) {
// Add our unit to our value if it exists.
if ( $unit && '' !== $unit ) {
$value = $value . $unit;
if ( '' !== $og_default ) {
$og_default = $og_default . $unit;
}
}
// If we don't have a value or our value is the same as our og default, bail.
if ( empty( $value ) || $og_default == $value ) {
return false;
}
$this->_css .= $property . ':' . $value . ';';
return $this;
}
/**
* Sets a media query in the class
*
* @since 1.1
* @param string $value
* @return $this
*/
public function start_media_query( $value ) {
// Add the current rules to the output.
$this->add_selector_rules_to_output();
// Add any previous media queries to the output.
if ( ! empty( $this->_media_query ) ) {
$this->add_media_query_rules_to_output();
}
// Set the new media query.
$this->_media_query = $value;
return $this;
}
/**
* Stops using a media query.
*
* @see start_media_query()
*
* @since 1.1
* @return $this
*/
public function stop_media_query() {
return $this->start_media_query( null );
}
/**
* Adds the current media query's rules to the class' output variable
*
* @since 1.1
* @return $this
*/
private function add_media_query_rules_to_output() {
if ( ! empty( $this->_media_query_output ) ) {
$this->_output .= sprintf( '@media %1$s{%2$s}', $this->_media_query, $this->_media_query_output );
// Reset the media query output string.
$this->_media_query_output = '';
}
return $this;
}
/**
* Adds the current selector rules to the output variable
*
* @access private
* @since 1.0
*
* @return $this
*/
private function add_selector_rules_to_output() {
if ( ! empty( $this->_css ) ) {
$this->_selector_output = $this->_selector;
$selector_output = sprintf( '%1$s{%2$s}', $this->_selector_output, $this->_css );
// Add our CSS to the output.
if ( ! empty( $this->_media_query ) ) {
$this->_media_query_output .= $selector_output;
$this->_css = '';
} else {
$this->_output .= $selector_output;
}
// Reset the css.
$this->_css = '';
}
return $this;
}
/**
* Returns the minified css in the $_output variable
*
* @access public
* @since 1.0
*
* @return string
*/
public function css_output() {
// Add current selector's rules to output.
$this->add_selector_rules_to_output();
// Output minified css.
return $this->_output;
}
}
}

View File

@ -0,0 +1,814 @@
<?php
/**
* Output all of our dynamic CSS.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! function_exists( 'generate_base_css' ) ) {
/**
* Generate the CSS in the <head> section using the Theme Customizer.
*
* @since 0.1
*/
function generate_base_css() {
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_defaults()
);
$css = new GeneratePress_CSS;
$css->set_selector( 'body' );
$css->add_property( 'background-color', esc_attr( $generate_settings['background_color'] ) );
$css->add_property( 'color', esc_attr( $generate_settings['text_color'] ) );
$css->set_selector( 'a, a:visited' );
$css->add_property( 'color', esc_attr( $generate_settings['link_color'] ) );
$css->set_selector( 'a:visited' )->add_property( 'color', esc_attr( $generate_settings['link_color_visited'] ) );
$css->set_selector( 'a:hover, a:focus, a:active' );
$css->add_property( 'color', esc_attr( $generate_settings['link_color_hover'] ) );
$css->set_selector( 'body .grid-container' )->add_property( 'max-width', absint( $generate_settings['container_width'] ), false, 'px' );
if ( apply_filters( 'generate_do_group_inner_container_style', true ) ) {
$css->set_selector( '.wp-block-group__inner-container' );
$css->add_property( 'max-width', absint( $generate_settings['container_width'] ), false, 'px' );
$css->add_property( 'margin-left', 'auto' );
$css->add_property( 'margin-right', 'auto' );
}
$nav_drop_point = generate_get_option( 'nav_drop_point' );
$nav_location = generate_get_navigation_location();
if ( ( 'nav-float-right' === $nav_location || 'nav-float-left' === $nav_location ) && $nav_drop_point ) {
$media_query = sprintf(
'(max-width: %1$s) and %2$s',
absint( $nav_drop_point ) . 'px',
apply_filters( 'generate_not_mobile_menu_media_query', '(min-width: 769px)' )
);
$css->start_media_query( $media_query );
$css->set_selector( '.inside-header' );
$css->add_property( 'display', '-ms-flexbox' );
$css->add_property( 'display', 'flex' );
$css->add_property( '-ms-flex-direction', 'column' );
$css->add_property( 'flex-direction', 'column' );
$css->add_property( '-ms-flex-align', 'center' );
$css->add_property( 'align-items', 'center' );
$css->set_selector( '.site-logo, .site-branding' );
$css->add_property( 'margin-bottom', '1.5em' );
$css->set_selector( '#site-navigation' );
$css->add_property( 'margin', '0 auto' );
$css->set_selector( '.header-widget' );
$css->add_property( 'margin-top', '1.5em' );
if ( 'nav-float-left' === generate_get_option( 'nav_position_setting' ) ) {
$css->set_selector( '.nav-float-left .site-logo,.nav-float-left .site-branding,.nav-float-left .header-widget' );
$css->add_property( '-webkit-box-ordinal-group', 'initial' );
$css->add_property( '-ms-flex-order', 'initial' );
$css->add_property( 'order', 'initial' );
}
$css->stop_media_query();
}
if ( generate_get_option( 'logo_width' ) ) {
$css->set_selector( '.site-header .header-image' );
$css->add_property( 'width', absint( generate_get_option( 'logo_width' ) ), false, 'px' );
}
do_action( 'generate_base_css', $css );
return apply_filters( 'generate_base_css_output', $css->css_output() );
}
}
if ( ! function_exists( 'generate_advanced_css' ) ) {
/**
* Generate the CSS in the <head> section using the Theme Customizer.
*
* @since 0.1
*/
function generate_advanced_css() {
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_color_defaults()
);
$css = new GeneratePress_CSS;
$css->set_selector( '.top-bar' );
$css->add_property( 'background-color', esc_attr( $generate_settings['top_bar_background_color'] ) );
$css->add_property( 'color', esc_attr( $generate_settings['top_bar_text_color'] ) );
$css->set_selector( '.top-bar a,.top-bar a:visited' );
$css->add_property( 'color', esc_attr( $generate_settings['top_bar_link_color'] ) );
$css->set_selector( '.top-bar a:hover' );
$css->add_property( 'color', esc_attr( $generate_settings['top_bar_link_color_hover'] ) );
$css->set_selector( '.site-header' );
$css->add_property( 'background-color', esc_attr( $generate_settings['header_background_color'] ) );
$css->add_property( 'color', esc_attr( $generate_settings['header_text_color'] ) );
$css->set_selector( '.site-header a,.site-header a:visited' );
$css->add_property( 'color', esc_attr( $generate_settings['header_link_color'] ) );
$css->set_selector( '.site-header a:hover' );
$css->add_property( 'color', esc_attr( $generate_settings['header_link_hover_color'] ) );
$css->set_selector( '.main-title a,.main-title a:hover,.main-title a:visited' );
$css->add_property( 'color', esc_attr( $generate_settings['site_title_color'] ) );
$css->set_selector( '.site-description' );
$css->add_property( 'color', esc_attr( $generate_settings['site_tagline_color'] ) );
$css->set_selector( '.main-navigation,.main-navigation ul ul' );
$css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_color'] ) );
$css->set_selector( '.main-navigation .main-nav ul li a,.menu-toggle' );
$css->add_property( 'color', esc_attr( $generate_settings['navigation_text_color'] ) );
$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' );
$css->add_property( 'color', esc_attr( $generate_settings['navigation_text_hover_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_hover_color'] ) );
$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' );
$css->add_property( 'color', esc_attr( $generate_settings['navigation_text_color'] ) );
$css->set_selector( '.main-navigation .main-nav ul li[class*="current-menu-"] > a' );
$css->add_property( 'color', esc_attr( $generate_settings['navigation_text_current_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_current_color'] ) );
$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' );
$css->add_property( 'color', esc_attr( $generate_settings['navigation_text_current_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_current_color'] ) );
$navigation_search_background = $generate_settings['navigation_background_hover_color'];
$navigation_search_text = $generate_settings['navigation_text_hover_color'];
if ( '' !== $generate_settings['navigation_search_background_color'] ) {
$navigation_search_background = $generate_settings['navigation_search_background_color'];
}
if ( '' !== $generate_settings['navigation_search_text_color'] ) {
$navigation_search_text = $generate_settings['navigation_search_text_color'];
}
$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' );
$css->add_property( 'color', esc_attr( $navigation_search_text ) );
$css->add_property( 'background-color', esc_attr( $navigation_search_background ) );
if ( '' !== $generate_settings['navigation_search_background_color'] ) {
$css->add_property( 'opacity', '1' );
}
$css->set_selector( '.main-navigation ul ul' );
$css->add_property( 'background-color', esc_attr( $generate_settings['subnavigation_background_color'] ) );
$css->set_selector( '.main-navigation .main-nav ul ul li a' );
$css->add_property( 'color', esc_attr( $generate_settings['subnavigation_text_color'] ) );
$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' );
$css->add_property( 'color', esc_attr( $generate_settings['subnavigation_text_hover_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['subnavigation_background_hover_color'] ) );
$css->set_selector( '.main-navigation .main-nav ul ul li[class*="current-menu-"] > a' );
$css->add_property( 'color', esc_attr( $generate_settings['subnavigation_text_current_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['subnavigation_background_current_color'] ) );
$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' );
$css->add_property( 'color', esc_attr( $generate_settings['subnavigation_text_current_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['subnavigation_background_current_color'] ) );
$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' );
$css->add_property( 'color', esc_attr( $generate_settings['content_text_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['content_background_color'] ) );
$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' );
$css->add_property( 'color', esc_attr( $generate_settings['content_link_color'] ) );
$css->set_selector( '.inside-article a:hover,.paging-navigation a:hover,.comments-area a:hover,.page-header a:hover' );
$css->add_property( 'color', esc_attr( $generate_settings['content_link_hover_color'] ) );
$css->set_selector( '.entry-header h1,.page-header h1' );
$css->add_property( 'color', esc_attr( $generate_settings['content_title_color'] ) );
$css->set_selector( '.entry-title a,.entry-title a:visited' );
$css->add_property( 'color', esc_attr( $generate_settings['blog_post_title_color'] ) );
$css->set_selector( '.entry-title a:hover' );
$css->add_property( 'color', esc_attr( $generate_settings['blog_post_title_hover_color'] ) );
$css->set_selector( '.entry-meta' );
$css->add_property( 'color', esc_attr( $generate_settings['entry_meta_text_color'] ) );
$css->set_selector( '.entry-meta a,.entry-meta a:visited' );
$css->add_property( 'color', esc_attr( $generate_settings['entry_meta_link_color'] ) );
$css->set_selector( '.entry-meta a:hover' );
$css->add_property( 'color', esc_attr( $generate_settings['entry_meta_link_color_hover'] ) );
$css->set_selector( 'h1' );
$css->add_property( 'color', esc_attr( $generate_settings['h1_color'] ) );
$css->set_selector( 'h2' );
$css->add_property( 'color', esc_attr( $generate_settings['h2_color'] ) );
$css->set_selector( 'h3' );
$css->add_property( 'color', esc_attr( $generate_settings['h3_color'] ) );
$css->set_selector( 'h4' );
$css->add_property( 'color', esc_attr( $generate_settings['h4_color'] ) );
$css->set_selector( 'h5' );
$css->add_property( 'color', esc_attr( $generate_settings['h5_color'] ) );
$css->set_selector( 'h6' );
$css->add_property( 'color', esc_attr( $generate_settings['h6_color'] ) );
$css->set_selector( '.sidebar .widget' );
$css->add_property( 'color', esc_attr( $generate_settings['sidebar_widget_text_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['sidebar_widget_background_color'] ) );
$css->set_selector( '.sidebar .widget a,.sidebar .widget a:visited' );
$css->add_property( 'color', esc_attr( $generate_settings['sidebar_widget_link_color'] ) );
$css->set_selector( '.sidebar .widget a:hover' );
$css->add_property( 'color', esc_attr( $generate_settings['sidebar_widget_link_hover_color'] ) );
$css->set_selector( '.sidebar .widget .widget-title' );
$css->add_property( 'color', esc_attr( $generate_settings['sidebar_widget_title_color'] ) );
$css->set_selector( '.footer-widgets' );
$css->add_property( 'color', esc_attr( $generate_settings['footer_widget_text_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['footer_widget_background_color'] ) );
$css->set_selector( '.footer-widgets a,.footer-widgets a:visited' );
$css->add_property( 'color', esc_attr( $generate_settings['footer_widget_link_color'] ) );
$css->set_selector( '.footer-widgets a:hover' );
$css->add_property( 'color', esc_attr( $generate_settings['footer_widget_link_hover_color'] ) );
$css->set_selector( '.footer-widgets .widget-title' );
$css->add_property( 'color', esc_attr( $generate_settings['footer_widget_title_color'] ) );
$css->set_selector( '.site-info' );
$css->add_property( 'color', esc_attr( $generate_settings['footer_text_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['footer_background_color'] ) );
$css->set_selector( '.site-info a,.site-info a:visited' );
$css->add_property( 'color', esc_attr( $generate_settings['footer_link_color'] ) );
$css->set_selector( '.site-info a:hover' );
$css->add_property( 'color', esc_attr( $generate_settings['footer_link_hover_color'] ) );
$css->set_selector( '.footer-bar .widget_nav_menu .current-menu-item a' );
$css->add_property( 'color', esc_attr( $generate_settings['footer_link_hover_color'] ) );
$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' );
$css->add_property( 'color', esc_attr( $generate_settings['form_text_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['form_background_color'] ) );
$css->add_property( 'border-color', esc_attr( $generate_settings['form_border_color'] ) );
$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' );
$css->add_property( 'color', esc_attr( $generate_settings['form_text_color_focus'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['form_background_color_focus'] ) );
$css->add_property( 'border-color', esc_attr( $generate_settings['form_border_color_focus'] ) );
$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)' );
$css->add_property( 'color', esc_attr( $generate_settings['form_button_text_color'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['form_button_background_color'] ) );
$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' );
$css->add_property( 'color', esc_attr( $generate_settings['form_button_text_color_hover'] ) );
$css->add_property( 'background-color', esc_attr( $generate_settings['form_button_background_color_hover'] ) );
$css->set_selector( '.generate-back-to-top,.generate-back-to-top:visited' );
$css->add_property( 'background-color', esc_attr( $generate_settings['back_to_top_background_color'] ) );
$css->add_property( 'color', esc_attr( $generate_settings['back_to_top_text_color'] ) );
$css->set_selector( '.generate-back-to-top:hover,.generate-back-to-top:focus' );
$css->add_property( 'background-color', esc_attr( $generate_settings['back_to_top_background_color_hover'] ) );
$css->add_property( 'color', esc_attr( $generate_settings['back_to_top_text_color_hover'] ) );
do_action( 'generate_colors_css', $css );
return apply_filters( 'generate_colors_css_output', $css->css_output() );
}
}
if ( ! function_exists( 'generate_font_css' ) ) {
/**
* Generate the CSS in the <head> section using the Theme Customizer.
*
* @since 0.1
*/
function generate_font_css() {
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_default_fonts()
);
$og_defaults = generate_get_default_fonts( false );
$css = new GeneratePress_CSS;
$subnav_font_size = $generate_settings['navigation_font_size'] >= 17 ? $generate_settings['navigation_font_size'] - 3 : $generate_settings['navigation_font_size'] - 1;
$body_family = generate_get_font_family_css( 'font_body', 'generate_settings', generate_get_default_fonts() );
$top_bar_family = generate_get_font_family_css( 'font_top_bar', 'generate_settings', generate_get_default_fonts() );
$site_title_family = generate_get_font_family_css( 'font_site_title', 'generate_settings', generate_get_default_fonts() );
$site_tagline_family = generate_get_font_family_css( 'font_site_tagline', 'generate_settings', generate_get_default_fonts() );
$navigation_family = generate_get_font_family_css( 'font_navigation', 'generate_settings', generate_get_default_fonts() );
$widget_family = generate_get_font_family_css( 'font_widget_title', 'generate_settings', generate_get_default_fonts() );
$h1_family = generate_get_font_family_css( 'font_heading_1', 'generate_settings', generate_get_default_fonts() );
$h2_family = generate_get_font_family_css( 'font_heading_2', 'generate_settings', generate_get_default_fonts() );
$h3_family = generate_get_font_family_css( 'font_heading_3', 'generate_settings', generate_get_default_fonts() );
$h4_family = generate_get_font_family_css( 'font_heading_4', 'generate_settings', generate_get_default_fonts() );
$h5_family = generate_get_font_family_css( 'font_heading_5', 'generate_settings', generate_get_default_fonts() );
$h6_family = generate_get_font_family_css( 'font_heading_6', 'generate_settings', generate_get_default_fonts() );
$footer_family = generate_get_font_family_css( 'font_footer', 'generate_settings', generate_get_default_fonts() );
$buttons_family = generate_get_font_family_css( 'font_buttons', 'generate_settings', generate_get_default_fonts() );
$css->set_selector( 'body, button, input, select, textarea' );
$css->add_property( 'font-family', $body_family );
$css->add_property( 'font-weight', esc_attr( $generate_settings['body_font_weight'] ), $og_defaults['body_font_weight'] );
$css->add_property( 'text-transform', esc_attr( $generate_settings['body_font_transform'] ), $og_defaults['body_font_transform'] );
$css->add_property( 'font-size', absint( $generate_settings['body_font_size'] ), $og_defaults['body_font_size'], 'px' );
$css->set_selector( 'body' );
$css->add_property( 'line-height', floatval( $generate_settings['body_line_height'] ), $og_defaults['body_line_height'] );
$css->set_selector( 'p' );
$css->add_property( 'margin-bottom', floatval( $generate_settings['paragraph_margin'] ), $og_defaults['paragraph_margin'], 'em' );
$css->set_selector( '.entry-content > [class*="wp-block-"]:not(:last-child)' );
$css->add_property( 'margin-bottom', floatval( $generate_settings['paragraph_margin'] ), false, 'em' );
$css->set_selector( '.top-bar' );
$css->add_property( 'font-family', $og_defaults['font_top_bar'] !== $generate_settings['font_top_bar'] ? $top_bar_family : null );
$css->add_property( 'font-weight', esc_attr( $generate_settings['top_bar_font_weight'] ), $og_defaults['top_bar_font_weight'] );
$css->add_property( 'text-transform', esc_attr( $generate_settings['top_bar_font_transform'] ), $og_defaults['top_bar_font_transform'] );
$css->add_property( 'font-size', absint( $generate_settings['top_bar_font_size'] ), absint( $og_defaults['top_bar_font_size'] ), 'px' );
$css->set_selector( '.main-title' );
$css->add_property( 'font-family', $og_defaults['font_site_title'] !== $generate_settings['font_site_title'] ? $site_title_family : null );
$css->add_property( 'font-weight', esc_attr( $generate_settings['site_title_font_weight'] ), $og_defaults['site_title_font_weight'] );
$css->add_property( 'text-transform', esc_attr( $generate_settings['site_title_font_transform'] ), $og_defaults['site_title_font_transform'] );
$css->add_property( 'font-size', absint( $generate_settings['site_title_font_size'] ), $og_defaults['site_title_font_size'], 'px' );
$css->set_selector( '.site-description' );
$css->add_property( 'font-family', $og_defaults['font_site_tagline'] !== $generate_settings['font_site_tagline'] ? $site_tagline_family : null );
$css->add_property( 'font-weight', esc_attr( $generate_settings['site_tagline_font_weight'] ), $og_defaults['site_tagline_font_weight'] );
$css->add_property( 'text-transform', esc_attr( $generate_settings['site_tagline_font_transform'] ), $og_defaults['site_tagline_font_transform'] );
$css->add_property( 'font-size', absint( $generate_settings['site_tagline_font_size'] ), $og_defaults['site_tagline_font_size'], 'px' );
$css->set_selector( '.main-navigation a, .menu-toggle' );
$css->add_property( 'font-family', $og_defaults['font_navigation'] !== $generate_settings['font_navigation'] ? $navigation_family : null );
$css->add_property( 'font-weight', esc_attr( $generate_settings['navigation_font_weight'] ), $og_defaults['navigation_font_weight'] );
$css->add_property( 'text-transform', esc_attr( $generate_settings['navigation_font_transform'] ), $og_defaults['navigation_font_transform'] );
$css->add_property( 'font-size', absint( $generate_settings['navigation_font_size'] ), $og_defaults['navigation_font_size'], 'px' );
$css->set_selector( '.main-navigation .main-nav ul ul li a' );
$css->add_property( 'font-size', absint( $subnav_font_size ), false, 'px' );
$css->set_selector( '.widget-title' );
$css->add_property( 'font-family', $og_defaults['font_widget_title'] !== $generate_settings['font_widget_title'] ? $widget_family : null );
$css->add_property( 'font-weight', esc_attr( $generate_settings['widget_title_font_weight'] ), $og_defaults['widget_title_font_weight'] );
$css->add_property( 'text-transform', esc_attr( $generate_settings['widget_title_font_transform'] ), $og_defaults['widget_title_font_transform'] );
$css->add_property( 'font-size', absint( $generate_settings['widget_title_font_size'] ), $og_defaults['widget_title_font_size'], 'px' );
$css->add_property( 'margin-bottom', absint( $generate_settings['widget_title_separator'] ), absint( $og_defaults['widget_title_separator'] ), 'px' );
$css->set_selector( '.sidebar .widget, .footer-widgets .widget' );
$css->add_property( 'font-size', absint( $generate_settings['widget_content_font_size'] ), $og_defaults['widget_content_font_size'], 'px' );
$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' );
$css->add_property( 'font-family', $og_defaults['font_buttons'] !== $generate_settings['font_buttons'] ? $buttons_family : null );
$css->add_property( 'font-weight', esc_attr( $generate_settings['buttons_font_weight'] ), $og_defaults['buttons_font_weight'] );
$css->add_property( 'text-transform', esc_attr( $generate_settings['buttons_font_transform'] ), $og_defaults['buttons_font_transform'] );
if ( '' !== $generate_settings['buttons_font_size'] ) {
$css->add_property( 'font-size', absint( $generate_settings['buttons_font_size'] ), $og_defaults['buttons_font_size'], 'px' );
}
$css->set_selector( 'h1' );
$css->add_property( 'font-family', $og_defaults['font_heading_1'] !== $generate_settings['font_heading_1'] ? $h1_family : null );
$css->add_property( 'font-weight', esc_attr( $generate_settings['heading_1_weight'] ), $og_defaults['heading_1_weight'] );
$css->add_property( 'text-transform', esc_attr( $generate_settings['heading_1_transform'] ), $og_defaults['heading_1_transform'] );
$css->add_property( 'font-size', absint( $generate_settings['heading_1_font_size'] ), $og_defaults['heading_1_font_size'], 'px' );
$css->add_property( 'line-height', floatval( $generate_settings['heading_1_line_height'] ), $og_defaults['heading_1_line_height'], 'em' );
$css->add_property( 'margin-bottom', floatval( $generate_settings['heading_1_margin_bottom'] ), $og_defaults['heading_1_margin_bottom'], 'px' );
$css->set_selector( 'h2' );
$css->add_property( 'font-family', $og_defaults['font_heading_2'] !== $generate_settings['font_heading_2'] ? $h2_family : null );
$css->add_property( 'font-weight', esc_attr( $generate_settings['heading_2_weight'] ), $og_defaults['heading_2_weight'] );
$css->add_property( 'text-transform', esc_attr( $generate_settings['heading_2_transform'] ), $og_defaults['heading_2_transform'] );
$css->add_property( 'font-size', absint( $generate_settings['heading_2_font_size'] ), $og_defaults['heading_2_font_size'], 'px' );
$css->add_property( 'line-height', floatval( $generate_settings['heading_2_line_height'] ), $og_defaults['heading_2_line_height'], 'em' );
$css->add_property( 'margin-bottom', floatval( $generate_settings['heading_2_margin_bottom'] ), $og_defaults['heading_2_margin_bottom'], 'px' );
$css->set_selector( 'h3' );
$css->add_property( 'font-family', $og_defaults['font_heading_3'] !== $generate_settings['font_heading_3'] ? $h3_family : null );
$css->add_property( 'font-weight', esc_attr( $generate_settings['heading_3_weight'] ), $og_defaults['heading_3_weight'] );
$css->add_property( 'text-transform', esc_attr( $generate_settings['heading_3_transform'] ), $og_defaults['heading_3_transform'] );
$css->add_property( 'font-size', absint( $generate_settings['heading_3_font_size'] ), $og_defaults['heading_3_font_size'], 'px' );
$css->add_property( 'line-height', floatval( $generate_settings['heading_3_line_height'] ), $og_defaults['heading_3_line_height'], 'em' );
$css->add_property( 'margin-bottom', floatval( $generate_settings['heading_3_margin_bottom'] ), $og_defaults['heading_3_margin_bottom'], 'px' );
$css->set_selector( 'h4' );
$css->add_property( 'font-family', $og_defaults['font_heading_4'] !== $generate_settings['font_heading_4'] ? $h4_family : null );
$css->add_property( 'font-weight', esc_attr( $generate_settings['heading_4_weight'] ), $og_defaults['heading_4_weight'] );
$css->add_property( 'text-transform', esc_attr( $generate_settings['heading_4_transform'] ), $og_defaults['heading_4_transform'] );
if ( '' !== $generate_settings['heading_4_font_size'] ) {
$css->add_property( 'font-size', absint( $generate_settings['heading_4_font_size'] ), $og_defaults['heading_4_font_size'], 'px' );
}
if ( '' !== $generate_settings['heading_4_line_height'] ) {
$css->add_property( 'line-height', floatval( $generate_settings['heading_4_line_height'] ), $og_defaults['heading_4_line_height'], 'em' );
}
$css->set_selector( 'h5' );
$css->add_property( 'font-family', $og_defaults['font_heading_5'] !== $generate_settings['font_heading_5'] ? $h5_family : null );
$css->add_property( 'font-weight', esc_attr( $generate_settings['heading_5_weight'] ), $og_defaults['heading_5_weight'] );
$css->add_property( 'text-transform', esc_attr( $generate_settings['heading_5_transform'] ), $og_defaults['heading_5_transform'] );
if ( '' !== $generate_settings['heading_5_font_size'] ) {
$css->add_property( 'font-size', absint( $generate_settings['heading_5_font_size'] ), $og_defaults['heading_5_font_size'], 'px' );
}
if ( '' !== $generate_settings['heading_5_line_height'] ) {
$css->add_property( 'line-height', floatval( $generate_settings['heading_5_line_height'] ), $og_defaults['heading_5_line_height'], 'em' );
}
$css->set_selector( 'h6' );
$css->add_property( 'font-family', $og_defaults['font_heading_6'] !== $generate_settings['font_heading_6'] ? $h6_family : null );
$css->add_property( 'font-weight', esc_attr( $generate_settings['heading_6_weight'] ), $og_defaults['heading_6_weight'] );
$css->add_property( 'text-transform', esc_attr( $generate_settings['heading_6_transform'] ), $og_defaults['heading_6_transform'] );
if ( '' !== $generate_settings['heading_6_font_size'] ) {
$css->add_property( 'font-size', absint( $generate_settings['heading_6_font_size'] ), $og_defaults['heading_6_font_size'], 'px' );
}
if ( '' !== $generate_settings['heading_6_line_height'] ) {
$css->add_property( 'line-height', floatval( $generate_settings['heading_6_line_height'] ), $og_defaults['heading_6_line_height'], 'em' );
}
$css->set_selector( '.site-info' );
$css->add_property( 'font-family', $og_defaults['font_footer'] !== $generate_settings['font_footer'] ? $footer_family : null );
$css->add_property( 'font-weight', esc_attr( $generate_settings['footer_weight'] ), $og_defaults['footer_weight'] );
$css->add_property( 'text-transform', esc_attr( $generate_settings['footer_transform'] ), $og_defaults['footer_transform'] );
$css->add_property( 'font-size', absint( $generate_settings['footer_font_size'] ), $og_defaults['footer_font_size'], 'px' );
$css->start_media_query( generate_get_media_query( 'mobile' ) );
$mobile_site_title = ( isset( $generate_settings['mobile_site_title_font_size'] ) ) ? $generate_settings['mobile_site_title_font_size'] : '30';
$css->set_selector( '.main-title' );
$css->add_property( 'font-size', absint( $mobile_site_title ), false, 'px' );
$mobile_h1 = ( isset( $generate_settings['mobile_heading_1_font_size'] ) ) ? $generate_settings['mobile_heading_1_font_size'] : '30';
$css->set_selector( 'h1' );
$css->add_property( 'font-size', absint( $mobile_h1 ), false, 'px' );
$mobile_h2 = ( isset( $generate_settings['mobile_heading_2_font_size'] ) ) ? $generate_settings['mobile_heading_2_font_size'] : '25';
$css->set_selector( 'h2' );
$css->add_property( 'font-size', absint( $mobile_h2 ), false, 'px' );
$css->stop_media_query();
do_action( 'generate_typography_css', $css );
return apply_filters( 'generate_typography_css_output', $css->css_output() );
}
}
if ( ! function_exists( 'generate_spacing_css' ) ) {
/**
* Write our dynamic CSS.
*
* @since 0.1
*/
function generate_spacing_css() {
$spacing_settings = wp_parse_args(
get_option( 'generate_spacing_settings', array() ),
generate_spacing_get_defaults()
);
$og_defaults = generate_spacing_get_defaults( false );
$sidebar_layout = generate_get_layout();
$css = new GeneratePress_CSS;
$css->set_selector( '.inside-top-bar' );
$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'] ) );
$css->set_selector( '.inside-header' );
$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'] ) );
$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' );
$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'] ) );
$content_padding = absint( $spacing_settings['content_right'] ) + absint( $spacing_settings['content_left'] );
$css->set_selector( '.entry-content .alignwide, body:not(.no-sidebar) .entry-content .alignfull' );
$css->add_property( 'margin-left', '-' . absint( $spacing_settings['content_left'] ) . 'px' );
$css->add_property( 'width', 'calc(100% + ' . absint( $content_padding ) . 'px)' );
$css->add_property( 'max-width', 'calc(100% + ' . absint( $content_padding ) . 'px)' );
if ( 'text' === generate_get_option( 'container_alignment' ) ) {
$css->set_selector( '.container.grid-container' );
$css->add_property( 'max-width', generate_get_option( 'container_width' ) + $content_padding, false, 'px' );
}
$css->set_selector( '.one-container.right-sidebar .site-main,.one-container.both-right .site-main' );
$css->add_property( 'margin-right', absint( $spacing_settings['content_right'] ), absint( $og_defaults['content_right'] ), 'px' );
$css->set_selector( '.one-container.left-sidebar .site-main,.one-container.both-left .site-main' );
$css->add_property( 'margin-left', absint( $spacing_settings['content_left'] ), absint( $og_defaults['content_left'] ), 'px' );
$css->set_selector( '.one-container.both-sidebars .site-main' );
$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'] ) );
$css->set_selector( '.separate-containers .widget, .separate-containers .site-main > *, .separate-containers .page-header, .widget-area .main-navigation' );
$css->add_property( 'margin-bottom', absint( $spacing_settings['separator'] ), absint( $og_defaults['separator'] ), 'px' );
$css->set_selector( '.separate-containers .site-main' );
$css->add_property( 'margin', absint( $spacing_settings['separator'] ), $og_defaults['separator'], 'px' );
$css->set_selector( '.both-right.separate-containers .inside-left-sidebar' );
$css->add_property( 'margin-right', absint( $spacing_settings['separator'] / 2 ), absint( $og_defaults['separator'] / 2 ), 'px' );
$css->set_selector( '.both-right.separate-containers .inside-right-sidebar' );
$css->add_property( 'margin-left', absint( $spacing_settings['separator'] / 2 ), absint( $og_defaults['separator'] / 2 ), 'px' );
$css->set_selector( '.both-left.separate-containers .inside-left-sidebar' );
$css->add_property( 'margin-right', absint( $spacing_settings['separator'] / 2 ), absint( $og_defaults['separator'] / 2 ), 'px' );
$css->set_selector( '.both-left.separate-containers .inside-right-sidebar' );
$css->add_property( 'margin-left', absint( $spacing_settings['separator'] / 2 ), absint( $og_defaults['separator'] / 2 ), 'px' );
$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' );
$css->add_property( 'margin-top', absint( $spacing_settings['separator'] ), absint( $og_defaults['separator'] ), 'px' );
$css->set_selector( '.separate-containers .inside-right-sidebar, .separate-containers .inside-left-sidebar' );
$css->add_property( 'margin-top', absint( $spacing_settings['separator'] ), absint( $og_defaults['separator'] ), 'px' );
$css->add_property( 'margin-bottom', absint( $spacing_settings['separator'] ), absint( $og_defaults['separator'] ), 'px' );
$css->set_selector( '.main-navigation .main-nav ul li a,.menu-toggle,.main-navigation .mobile-bar-items a' );
$css->add_property( 'padding-left', absint( $spacing_settings['menu_item'] ), absint( $og_defaults['menu_item'] ), 'px' );
$css->add_property( 'padding-right', absint( $spacing_settings['menu_item'] ), absint( $og_defaults['menu_item'] ), 'px' );
$css->add_property( 'line-height', absint( $spacing_settings['menu_item_height'] ), absint( $og_defaults['menu_item_height'] ), 'px' );
$css->set_selector( '.main-navigation .main-nav ul ul li a' );
$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'] ) );
$css->set_selector( '.main-navigation ul ul' );
$css->add_property( 'width', absint( $spacing_settings['sub_menu_width'] ), absint( $og_defaults['sub_menu_width'] ), 'px' );
$css->set_selector( '.navigation-search input' );
$css->add_property( 'height', absint( $spacing_settings['menu_item_height'] ), absint( $og_defaults['menu_item_height'] ), 'px' );
$css->set_selector( '.rtl .menu-item-has-children .dropdown-menu-toggle' );
$css->add_property( 'padding-left', absint( $spacing_settings['menu_item'] ), false, 'px' );
$css->set_selector( '.menu-item-has-children .dropdown-menu-toggle' );
$css->add_property( 'padding-right', absint( $spacing_settings['menu_item'] ), absint( $og_defaults['menu_item'] ), 'px' );
$css->set_selector( '.menu-item-has-children ul .dropdown-menu-toggle' );
$css->add_property( 'padding-top', absint( $spacing_settings['sub_menu_item_height'] ), absint( $og_defaults['sub_menu_item_height'] ), 'px' );
$css->add_property( 'padding-bottom', absint( $spacing_settings['sub_menu_item_height'] ), absint( $og_defaults['sub_menu_item_height'] ), 'px' );
$css->add_property( 'margin-top', '-' . absint( $spacing_settings['sub_menu_item_height'] ), '-' . absint( $og_defaults['sub_menu_item_height'] ), 'px' );
$css->set_selector( '.rtl .main-navigation .main-nav ul li.menu-item-has-children > a' );
$css->add_property( 'padding-right', absint( $spacing_settings['menu_item'] ), false, 'px' );
$css->set_selector( '.widget-area .widget' );
$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'] ) );
$css->set_selector( '.footer-widgets' );
$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'] ) );
$css->set_selector( '.site-footer .footer-widgets-container .inner-padding' );
$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'] ) );
$css->set_selector( '.site-footer .footer-widgets-container .inside-footer-widgets' );
$css->add_property( 'margin-left', '-' . absint( $spacing_settings['footer_widget_separator'] ), '-' . absint( $og_defaults['footer_widget_separator'] ), 'px' );
$css->set_selector( '.site-info' );
$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'] ) );
$css->start_media_query( generate_get_media_query( 'mobile' ) );
$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' );
$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'] ) );
$mobile_content_padding = absint( $spacing_settings['mobile_content_right'] ) + absint( $spacing_settings['mobile_content_left'] );
$css->set_selector( '.entry-content .alignwide, body:not(.no-sidebar) .entry-content .alignfull' );
$css->add_property( 'margin-left', '-' . absint( $spacing_settings['mobile_content_left'] ) . 'px' );
$css->add_property( 'width', 'calc(100% + ' . absint( $mobile_content_padding ) . 'px)' );
$css->add_property( 'max-width', 'calc(100% + ' . absint( $mobile_content_padding ) . 'px)' );
if ( '' !== $spacing_settings['mobile_separator'] ) {
$css->set_selector( '.separate-containers .widget, .separate-containers .site-main > *, .separate-containers .page-header' );
$css->add_property( 'margin-bottom', absint( $spacing_settings['mobile_separator'] ), false, 'px' );
$css->set_selector( '.separate-containers .site-main' );
$css->add_property( 'margin', absint( $spacing_settings['mobile_separator'] ), false, 'px' );
$css->set_selector( '.separate-containers .page-header-image, .separate-containers .page-header-image-single' );
$css->add_property( 'margin-top', absint( $spacing_settings['mobile_separator'] ), false, 'px' );
$css->set_selector( '.separate-containers .inside-right-sidebar, .separate-containers .inside-left-sidebar' );
$css->add_property( 'margin-top', absint( $spacing_settings['mobile_separator'] ), false, 'px' );
$css->add_property( 'margin-bottom', absint( $spacing_settings['mobile_separator'] ), false, 'px' );
}
$css->stop_media_query();
// Add spacing back where dropdown arrow should be.
// Old versions of WP don't get nice things.
if ( version_compare( $GLOBALS['wp_version'], '4.4', '<' ) ) {
$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' );
$css->add_property( 'padding-right', absint( $spacing_settings['menu_item'] ), absint( $og_defaults['menu_item'] ), 'px' );
}
$output = '';
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_color_defaults()
);
// Find out if the content background color and sidebar widget background color is the same.
$sidebar = strtoupper( $generate_settings['sidebar_widget_background_color'] );
$content = strtoupper( $generate_settings['content_background_color'] );
$colors_match = ( ( $sidebar == $content ) || '' == $sidebar ) ? true : false;
// If they're all 40 (default), remove the padding when one container is set.
// This way, the user can still adjust the padding and it will work (unless they want 40px padding).
// We'll also remove the padding if there's no color difference between the widgets and content background color.
if ( ( '40' == $spacing_settings['widget_top'] && '40' == $spacing_settings['widget_right'] && '40' == $spacing_settings['widget_bottom'] && '40' == $spacing_settings['widget_left'] ) && $colors_match ) {
$output .= '.one-container .sidebar .widget{padding:0px;}';
}
do_action( 'generate_spacing_css', $css );
return apply_filters( 'generate_spacing_css_output', $css->css_output() . $output );
}
}
/**
* Generates any CSS that can't be cached (can change from page to page).
*
* @since 2.0
*/
function generate_no_cache_dynamic_css() {
$css = new GeneratePress_CSS;
if ( ! generate_show_title() ) {
$css->set_selector( '.page .entry-content' )->add_property( 'margin-top', '0px' );
if ( is_single() ) {
if ( ! apply_filters( 'generate_post_author', true ) && ! apply_filters( 'generate_post_date', true ) ) {
$css->set_selector( '.single .entry-content' )->add_property( 'margin-top', '0px' );
}
}
}
$css->start_media_query( generate_get_media_query( 'mobile-menu' ) );
$css->set_selector( '.main-navigation .menu-toggle,.main-navigation .mobile-bar-items,.sidebar-nav-mobile:not(#sticky-placeholder)' );
$css->add_property( 'display', 'block' );
$css->set_selector( '.main-navigation ul,.gen-sidebar-nav' );
$css->add_property( 'display', 'none' );
$css->set_selector( '[class*="nav-float-"] .site-header .inside-header > *' );
$css->add_property( 'float', 'none' );
$css->add_property( 'clear', 'both' );
$css->stop_media_query();
return $css->css_output();
}
add_action( 'wp_enqueue_scripts', 'generate_enqueue_dynamic_css', 50 );
/**
* Enqueue our dynamic CSS.
*
* @since 2.0
*/
function generate_enqueue_dynamic_css() {
if ( ! get_option( 'generate_dynamic_css_output', false ) || is_customize_preview() || apply_filters( 'generate_dynamic_css_skip_cache', false ) ) {
$css = generate_base_css() . generate_font_css() . generate_advanced_css() . generate_spacing_css();
} else {
$css = get_option( 'generate_dynamic_css_output' ) . '/* End cached CSS */';
}
$css = $css . generate_no_cache_dynamic_css() . generate_do_icon_css();
wp_add_inline_style( 'generate-style', $css );
}
add_action( 'init', 'generate_set_dynamic_css_cache' );
/**
* Sets our dynamic CSS cache if it doesn't exist.
*
* If the theme version changed, bust the cache.
*
* @since 2.0
*/
function generate_set_dynamic_css_cache() {
if ( apply_filters( 'generate_dynamic_css_skip_cache', false ) ) {
return;
}
$cached_css = get_option( 'generate_dynamic_css_output', false );
$cached_version = get_option( 'generate_dynamic_css_cached_version', '' );
if ( ! $cached_css || $cached_version !== GENERATE_VERSION ) {
$css = generate_base_css() . generate_font_css() . generate_advanced_css() . generate_spacing_css();
update_option( 'generate_dynamic_css_output', $css );
update_option( 'generate_dynamic_css_cached_version', GENERATE_VERSION );
}
}
add_action( 'customize_save_after', 'generate_update_dynamic_css_cache' );
/**
* Update our CSS cache when done saving Customizer options.
*
* @since 2.0
*/
function generate_update_dynamic_css_cache() {
if ( apply_filters( 'generate_dynamic_css_skip_cache', false ) ) {
return;
}
$css = generate_base_css() . generate_font_css() . generate_advanced_css() . generate_spacing_css();
update_option( 'generate_dynamic_css_output', $css );
}
/**
* Output CSS for the icon fonts.
*
* @since 2.3
*/
function generate_do_icon_css() {
$output = false;
if ( 'font' === generate_get_option( 'icons' ) ) {
$url = trailingslashit( get_template_directory_uri() );
$output = '@font-face {
font-family: "GeneratePress";
src: url("' . $url . 'fonts/generatepress.eot");
src: url("' . $url . 'fonts/generatepress.eot#iefix") format("embedded-opentype"),
url("' . $url . 'fonts/generatepress.woff2") format("woff2"),
url("' . $url . 'fonts/generatepress.woff") format("woff"),
url("' . $url . 'fonts/generatepress.ttf") format("truetype"),
url("' . $url . 'fonts/generatepress.svg#GeneratePress") format("svg");
font-weight: normal;
font-style: normal;
}';
if ( defined( 'GENERATE_MENU_PLUS_VERSION' ) ) {
$output .= '.main-navigation .slideout-toggle a:before,
.slide-opened .slideout-overlay .slideout-exit:before {
font-family: GeneratePress;
}
.slideout-navigation .dropdown-menu-toggle:before {
content: "\f107" !important;
}
.slideout-navigation .sfHover > a .dropdown-menu-toggle:before {
content: "\f106" !important;
}';
}
}
if ( 'svg' === generate_get_option( 'icons' ) ) {
$output = 'button.menu-toggle:before,
.search-item a:before,
.dropdown-menu-toggle:before,
.cat-links:before,
.tags-links:before,
.comments-link:before,
.nav-previous .prev:before,
.nav-next .next:before,
.generate-back-to-top:before {
display: none;
}';
}
if ( $output ) {
return str_replace( array( "\r", "\n", "\t" ), '', $output );
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,230 @@
<?php
/**
* Where old Customizer controls retire.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Customize_Width_Slider_Control' ) ) {
/**
* Create our container width slider control
* @deprecated 1.3.47
*/
class Generate_Customize_Width_Slider_Control extends WP_Customize_Control {
public function render_content() {}
}
}
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'GenerateLabelControl' ) ) {
/**
* Heading area
* @since 0.1
* @depreceted 1.3.41
**/
class GenerateLabelControl extends WP_Customize_Control {
public function render_content() {}
}
}
if ( ! class_exists( 'Generate_Google_Font_Dropdown_Custom_Control' ) ) {
/**
* A class to create a dropdown for all google fonts
*/
class Generate_Google_Font_Dropdown_Custom_Control extends WP_Customize_Control {
public $type = 'gp-customizer-fonts';
public function enqueue() {
wp_enqueue_script( 'generatepress-customizer-fonts', trailingslashit( get_template_directory_uri() ) . 'inc/js/typography-controls.js', array( 'customize-controls' ), GENERATE_VERSION, true );
wp_localize_script( 'generatepress-customizer-fonts', 'gp_customize', array( 'nonce' => wp_create_nonce( 'gp_customize_nonce' ) ) );
}
public function to_json() {
parent::to_json();
$number_of_fonts = apply_filters( 'generate_number_of_fonts', 200 );
$this->json['link'] = $this->get_link();
$this->json['value'] = $this->value();
$this->json['default_fonts_title'] = __( 'Default fonts', 'generatepress' );
$this->json['google_fonts_title'] = __( 'Google fonts', 'generatepress' );
$this->json['description'] = __( 'Font family','generatepress' );
$this->json['google_fonts'] = apply_filters( 'generate_typography_customize_list', generate_get_all_google_fonts( $number_of_fonts ) );
$this->json['default_fonts'] = generate_typography_default_fonts();
}
public function content_template() {
?>
<label>
<span class="customize-control-title">{{ data.label }}</span>
<select {{{ data.link }}}>
<optgroup label="{{ data.default_fonts_title }}">
<# for ( var key in data.default_fonts ) { #>
<# var name = data.default_fonts[ key ].split(',')[0]; #>
<option value="{{ data.default_fonts[ key ] }}" <# if ( data.default_fonts[ key ] === data.value ) { #>selected="selected"<# } #>>{{ name }}</option>
<# } #>
</optgroup>
<optgroup label="{{ data.google_fonts_title }}">
<# for ( var key in data.google_fonts ) { #>
<option value="{{ data.google_fonts[ key ].name }}" <# if ( data.google_fonts[ key ].name === data.value ) { #>selected="selected"<# } #>>{{ data.google_fonts[ key ].name }}</option>
<# } #>
</optgroup>
</select>
<p class="description">{{ data.description }}</p>
</label>
<?php
}
}
}
if ( ! class_exists( 'Generate_Select_Control' ) ) {
/**
* A class to create a dropdown for font weight
*/
class Generate_Select_Control extends WP_Customize_Control {
public $type = 'gp-typography-select';
public $choices = array();
public function to_json() {
parent::to_json();
foreach ( $this->choices as $name => $choice ) {
$this->choices[ $name ] = $choice;
}
$this->json['choices'] = $this->choices;
$this->json['link'] = $this->get_link();
$this->json['value'] = $this->value();
}
public function content_template() {
?>
<# if ( ! data.choices )
return;
#>
<label>
<select {{{ data.link }}}>
<# jQuery.each( data.choices, function( label, choice ) { #>
<option value="{{ choice }}" <# if ( choice === data.value ) { #> selected="selected"<# } #>>{{ choice }}</option>
<# } ) #>
</select>
<# if ( data.label ) { #>
<p class="description">{{ data.label }}</p>
<# } #>
</label>
<?php
}
}
}
if ( ! class_exists( 'Generate_Hidden_Input_Control' ) ) {
/**
* Create our hidden input control
*/
class Generate_Hidden_Input_Control extends WP_Customize_Control {
// Setup control type
public $type = 'gp-hidden-input';
public $id = '';
public function to_json() {
parent::to_json();
$this->json['link'] = $this->get_link();
$this->json['value'] = $this->value();
$this->json['id'] = $this->id;
}
public function content_template() {
?>
<input name="{{ data.id }}" type="text" {{{ data.link }}} value="{{{ data.value }}}" class="gp-hidden-input" />
<?php
}
}
}
if ( ! class_exists( 'Generate_Font_Weight_Custom_Control' ) ) {
/**
* A class to create a dropdown for font weight
* @deprecated since 1.3.40
*/
class Generate_Font_Weight_Custom_Control extends WP_Customize_Control {
public function __construct( $manager, $id, $args = array(), $options = array() ) {
parent::__construct( $manager, $id, $args );
}
/**
* Render the content of the category dropdown
*
* @return HTML
*/
public function render_content() {
?>
<label>
<select <?php $this->link(); ?>>
<?php
printf('<option value="%s" %s>%s</option>', 'normal', selected($this->value(), 'normal', false), 'normal');
printf('<option value="%s" %s>%s</option>', 'bold', selected($this->value(), 'bold', false), 'bold');
printf('<option value="%s" %s>%s</option>', '100', selected($this->value(), '100', false), '100');
printf('<option value="%s" %s>%s</option>', '200', selected($this->value(), '200', false), '200');
printf('<option value="%s" %s>%s</option>', '300', selected($this->value(), '300', false), '300');
printf('<option value="%s" %s>%s</option>', '400', selected($this->value(), '400', false), '400');
printf('<option value="%s" %s>%s</option>', '500', selected($this->value(), '500', false), '500');
printf('<option value="%s" %s>%s</option>', '600', selected($this->value(), '600', false), '600');
printf('<option value="%s" %s>%s</option>', '700', selected($this->value(), '700', false), '700');
printf('<option value="%s" %s>%s</option>', '800', selected($this->value(), '800', false), '800');
printf('<option value="%s" %s>%s</option>', '900', selected($this->value(), '900', false), '900');
?>
</select>
<p class="description"><?php echo esc_html( $this->label ); ?></p>
</label>
<?php
}
}
}
if ( ! class_exists( 'Generate_Text_Transform_Custom_Control' ) ) {
/**
* A class to create a dropdown for text-transform
* @deprecated since 1.3.40
*/
class Generate_Text_Transform_Custom_Control extends WP_Customize_Control {
public function __construct( $manager, $id, $args = array(), $options = array() ) {
parent::__construct( $manager, $id, $args );
}
/**
* Render the content of the category dropdown
*
* @return HTML
*/
public function render_content() {
?>
<label>
<select <?php $this->link(); ?>>
<?php
printf('<option value="%s" %s>%s</option>', 'none', selected($this->value(), 'none', false), 'none');
printf('<option value="%s" %s>%s</option>', 'capitalize', selected($this->value(), 'capitalize', false), 'capitalize');
printf('<option value="%s" %s>%s</option>', 'uppercase', selected($this->value(), 'uppercase', false), 'uppercase');
printf('<option value="%s" %s>%s</option>', 'lowercase', selected($this->value(), 'lowercase', false), 'lowercase');
?>
</select>
<p class="description"><?php echo esc_html( $this->label ); ?></p>
</label>
<?php
}
}
}
if ( ! class_exists( 'Generate_Customize_Slider_Control' ) ) {
/**
* Create our container width slider control
* @deprecated 1.3.47
*/
class Generate_Customize_Slider_Control extends WP_Customize_Control {
public function render_content() {}
}
}

View File

@ -0,0 +1,180 @@
<?php
/**
* The range slider Customizer control.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Range_Slider_Control' ) ) {
/**
* Create a range slider control.
* This control allows you to add responsive settings.
*
* @since 1.3.47
*/
class Generate_Range_Slider_Control extends WP_Customize_Control {
/**
* The control type.
*
* @access public
* @var string
*/
public $type = 'generatepress-range-slider';
public $description = '';
public $sub_description = '';
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @see WP_Customize_Control::to_json()
*/
public function to_json() {
parent::to_json();
$devices = array( 'desktop','tablet','mobile' );
foreach ( $devices as $device ) {
$this->json['choices'][ $device ]['min'] = ( isset( $this->choices[ $device ]['min'] ) ) ? $this->choices[ $device ]['min'] : '0';
$this->json['choices'][ $device ]['max'] = ( isset( $this->choices[ $device ]['max'] ) ) ? $this->choices[ $device ]['max'] : '100';
$this->json['choices'][ $device ]['step'] = ( isset( $this->choices[ $device ]['step'] ) ) ? $this->choices[ $device ]['step'] : '1';
$this->json['choices'][ $device ]['edit'] = ( isset( $this->choices[ $device ]['edit'] ) ) ? $this->choices[ $device ]['edit'] : false;
$this->json['choices'][ $device ]['unit'] = ( isset( $this->choices[ $device ]['unit'] ) ) ? $this->choices[ $device ]['unit'] : false;
}
foreach ( $this->settings as $setting_key => $setting_id ) {
$this->json[ $setting_key ] = array(
'link' => $this->get_link( $setting_key ),
'value' => $this->value( $setting_key ),
'default' => isset( $setting_id->default ) ? $setting_id->default : '',
);
}
$this->json['desktop_label'] = __( 'Desktop','generatepress' );
$this->json['tablet_label'] = __( 'Tablet','generatepress' );
$this->json['mobile_label'] = __( 'Mobile','generatepress' );
$this->json['reset_label'] = __( 'Reset','generatepress' );
$this->json['description'] = $this->description;
$this->json['sub_description'] = $this->sub_description;
}
/**
* Enqueue control related scripts/styles.
*
* @access public
*/
public function enqueue() {
wp_enqueue_script( 'generatepress-range-slider', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/slider-control.js', array( 'jquery', 'customize-base', 'jquery-ui-slider' ), false, true );
wp_enqueue_style( 'generatepress-range-slider-css', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/css/slider-customizer.css', null );
}
/**
* An Underscore (JS) template for this control's content (but not its container).
*
* Class variables for this control class are available in the `data` JS object;
* export custom variables by overriding {@see WP_Customize_Control::to_json()}.
*
* @see WP_Customize_Control::print_template()
*
* @access protected
*/
protected function content_template() {
?>
<div class="generatepress-range-slider-control">
<div class="gp-range-title-area">
<# if ( data.label || data.description ) { #>
<div class="gp-range-title-info">
<# if ( data.label ) { #>
<span class="customize-control-title">{{{ data.label }}}</span>
<# } #>
<# if ( data.description ) { #>
<p class="description">{{{ data.description }}}</p>
<# } #>
</div>
<# } #>
<div class="gp-range-slider-controls">
<span class="gp-device-controls">
<# if ( 'undefined' !== typeof ( data.desktop ) ) { #>
<span class="generatepress-device-desktop dashicons dashicons-desktop" data-option="desktop" title="{{ data.desktop_label }}"></span>
<# } #>
<# if ( 'undefined' !== typeof (data.tablet) ) { #>
<span class="generatepress-device-tablet dashicons dashicons-tablet" data-option="tablet" title="{{ data.tablet_label }}"></span>
<# } #>
<# if ( 'undefined' !== typeof (data.mobile) ) { #>
<span class="generatepress-device-mobile dashicons dashicons-smartphone" data-option="mobile" title="{{ data.mobile_label }}"></span>
<# } #>
</span>
<span title="{{ data.reset_label }}" class="generatepress-reset dashicons dashicons-image-rotate"></span>
</div>
</div>
<div class="gp-range-slider-areas">
<# if ( 'undefined' !== typeof ( data.desktop ) ) { #>
<label class="range-option-area" data-option="desktop" style="display: none;">
<div class="wrapper <# if ( '' !== data.choices['desktop']['unit'] ) { #>has-unit<# } #>">
<div class="generatepress-slider" data-step="{{ data.choices['desktop']['step'] }}" data-min="{{ data.choices['desktop']['min'] }}" data-max="{{ data.choices['desktop']['max'] }}"></div>
<div class="gp_range_value <# if ( '' == data.choices['desktop']['unit'] && ! data.choices['desktop']['edit'] ) { #>hide-value<# } #>">
<input <# if ( data.choices['desktop']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> type="number" step="{{ data.choices['desktop']['step'] }}" class="desktop-range value" value="{{ data.desktop.value }}" min="{{ data.choices['desktop']['min'] }}" max="{{ data.choices['desktop']['max'] }}" {{{ data.desktop.link }}} data-reset_value="{{ data.desktop.default }}" />
<span <# if ( ! data.choices['desktop']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> class="value">{{ data.desktop.value }}</span>
<# if ( data.choices['desktop']['unit'] ) { #>
<span class="unit">{{ data.choices['desktop']['unit'] }}</span>
<# } #>
</div>
</div>
</label>
<# } #>
<# if ( 'undefined' !== typeof ( data.tablet ) ) { #>
<label class="range-option-area" data-option="tablet" style="display:none">
<div class="wrapper <# if ( '' !== data.choices['tablet']['unit'] ) { #>has-unit<# } #>">
<div class="generatepress-slider" data-step="{{ data.choices['tablet']['step'] }}" data-min="{{ data.choices['tablet']['min'] }}" data-max="{{ data.choices['tablet']['max'] }}"></div>
<div class="gp_range_value <# if ( '' == data.choices['tablet']['unit'] && ! data.choices['desktop']['edit'] ) { #>hide-value<# } #>">
<input <# if ( data.choices['tablet']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> type="number" step="{{ data.choices['tablet']['step'] }}" class="tablet-range value" value="{{ data.tablet.value }}" min="{{ data.choices['tablet']['min'] }}" max="{{ data.choices['tablet']['max'] }}" {{{ data.tablet.link }}} data-reset_value="{{ data.tablet.default }}" />
<span <# if ( ! data.choices['tablet']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> class="value">{{ data.tablet.value }}</span>
<# if ( data.choices['tablet']['unit'] ) { #>
<span class="unit">{{ data.choices['tablet']['unit'] }}</span>
<# } #>
</div>
</div>
</label>
<# } #>
<# if ( 'undefined' !== typeof ( data.mobile ) ) { #>
<label class="range-option-area" data-option="mobile" style="display:none;">
<div class="wrapper <# if ( '' !== data.choices['mobile']['unit'] ) { #>has-unit<# } #>">
<div class="generatepress-slider" data-step="{{ data.choices['mobile']['step'] }}" data-min="{{ data.choices['mobile']['min'] }}" data-max="{{ data.choices['mobile']['max'] }}"></div>
<div class="gp_range_value <# if ( '' == data.choices['mobile']['unit'] && ! data.choices['desktop']['edit'] ) { #>hide-value<# } #>">
<input <# if ( data.choices['mobile']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> type="number" step="{{ data.choices['mobile']['step'] }}" class="mobile-range value" value="{{ data.mobile.value }}" min="{{ data.choices['mobile']['min'] }}" max="{{ data.choices['mobile']['max'] }}" {{{ data.mobile.link }}} data-reset_value="{{ data.mobile.default }}" />
<span <# if ( ! data.choices['mobile']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> class="value">{{ data.mobile.value }}</span>
<# if ( data.choices['mobile']['unit'] ) { #>
<span class="unit">{{ data.choices['mobile']['unit'] }}</span>
<# } #>
</div>
</div>
</label>
<# } #>
</div>
<# if ( data.sub_description ) { #>
<p class="description sub-description">{{{ data.sub_description }}}</p>
<# } #>
</div>
<?php
}
}
}

View File

@ -0,0 +1,193 @@
<?php
/**
* The typography Customizer control.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Typography_Customize_Control' ) ) {
/**
* Create the typography elements control.
*
* @since 2.0
*/
class Generate_Typography_Customize_Control extends WP_Customize_Control {
public $type = 'gp-customizer-typography';
public function enqueue() {
wp_enqueue_script( 'generatepress-typography-selectWoo', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/selectWoo.min.js', array( 'customize-controls', 'jquery' ), GENERATE_VERSION, true );
wp_enqueue_style( 'generatepress-typography-selectWoo', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/css/selectWoo.min.css', array(), GENERATE_VERSION );
wp_enqueue_script( 'generatepress-typography-customizer', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/typography-customizer.js', array( 'customize-controls', 'generatepress-typography-selectWoo' ), GENERATE_VERSION, true );
wp_enqueue_style( 'generatepress-typography-customizer', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/css/typography-customizer.css', array(), GENERATE_VERSION );
}
public function to_json() {
parent::to_json();
$this->json['default_fonts_title'] = __( 'System fonts', 'generatepress' );
$this->json['google_fonts_title'] = __( 'Google fonts', 'generatepress' );
$this->json['default_fonts'] = generate_typography_default_fonts();
$this->json['family_title'] = esc_html__( 'Font family', 'generatepress' );
$this->json['weight_title'] = esc_html__( 'Font weight', 'generatepress' );
$this->json['transform_title'] = esc_html__( 'Text transform', 'generatepress' );
$this->json['category_title'] = '';
$this->json['variant_title'] = esc_html__( 'Variants', 'generatepress' );
foreach ( $this->settings as $setting_key => $setting_id ) {
$this->json[ $setting_key ] = array(
'link' => $this->get_link( $setting_key ),
'value' => $this->value( $setting_key ),
'default' => isset( $setting_id->default ) ? $setting_id->default : '',
'id' => isset( $setting_id->id ) ? $setting_id->id : ''
);
if ( 'weight' === $setting_key ) {
$this->json[ $setting_key ]['choices'] = $this->get_font_weight_choices();
}
if ( 'transform' === $setting_key ) {
$this->json[ $setting_key ]['choices'] = $this->get_font_transform_choices();
}
}
}
public function content_template() {
?>
<# if ( '' !== data.label ) { #>
<span class="customize-control-title">{{ data.label }}</span>
<# } #>
<# if ( 'undefined' !== typeof ( data.family ) ) { #>
<div class="generatepress-font-family">
<label>
<select {{{ data.family.link }}} data-category="{{{ data.category.id }}}" data-variants="{{{ data.variant.id }}}" style="width:100%;">
<optgroup label="{{ data.default_fonts_title }}">
<# for ( var key in data.default_fonts ) { #>
<# var name = data.default_fonts[ key ].split(',')[0]; #>
<option value="{{ data.default_fonts[ key ] }}" <# if ( data.default_fonts[ key ] === data.family.value ) { #>selected="selected"<# } #>>{{ name }}</option>
<# } #>
</optgroup>
<optgroup label="{{ data.google_fonts_title }}">
<# for ( var key in generatePressTypography.googleFonts ) { #>
<option value="{{ generatePressTypography.googleFonts[ key ].name }}" <# if ( generatePressTypography.googleFonts[ key ].name === data.family.value ) { #>selected="selected"<# } #>>{{ generatePressTypography.googleFonts[ key ].name }}</option>
<# } #>
</optgroup>
</select>
<# if ( '' !== data.family_title ) { #>
<p class="description">{{ data.family_title }}</p>
<# } #>
</label>
</div>
<# } #>
<# if ( 'undefined' !== typeof ( data.variant ) ) { #>
<#
var id = data.family.value.split(' ').join('_').toLowerCase();
var font_data = generatePressTypography.googleFonts[id];
var variants = '';
if ( typeof font_data !== 'undefined' ) {
variants = font_data.variants;
}
if ( null === data.variant.value ) {
data.variant.value = data.variant.default;
}
#>
<div id={{{ data.variant.id }}}" class="generatepress-font-variant" data-saved-value="{{ data.variant.value }}">
<label>
<select name="{{{ data.variant.id }}}" multiple class="typography-multi-select" style="width:100%;" {{{ data.variant.link }}}>
<# _.each( variants, function( label, choice ) { #>
<option value="{{ label }}">{{ label }}</option>
<# } ) #>
</select>
<# if ( '' !== data.variant_title ) { #>
<p class="description">{{ data.variant_title }}</p>
<# } #>
</label>
</div>
<# } #>
<# if ( 'undefined' !== typeof ( data.category ) ) { #>
<div class="generatepress-font-category">
<label>
<input name="{{{ data.category.id }}}" type="hidden" {{{ data.category.link }}} value="{{{ data.category.value }}}" class="gp-hidden-input" />
<# if ( '' !== data.category_title ) { #>
<p class="description">{{ data.category_title }}</p>
<# } #>
</label>
</div>
<# } #>
<div class="generatepress-weight-transform-wrapper">
<# if ( 'undefined' !== typeof ( data.weight ) ) { #>
<div class="generatepress-font-weight">
<label>
<select {{{ data.weight.link }}}>
<# _.each( data.weight.choices, function( label, choice ) { #>
<option value="{{ choice }}" <# if ( choice === data.weight.value ) { #> selected="selected" <# } #>>{{ label }}</option>
<# } ) #>
</select>
<# if ( '' !== data.weight_title ) { #>
<p class="description">{{ data.weight_title }}</p>
<# } #>
</label>
</div>
<# } #>
<# if ( 'undefined' !== typeof ( data.transform ) ) { #>
<div class="generatepress-font-transform">
<label>
<select {{{ data.transform.link }}}>
<# _.each( data.transform.choices, function( label, choice ) { #>
<option value="{{ choice }}" <# if ( choice === data.transform.value ) { #> selected="selected" <# } #>>{{ label }}</option>
<# } ) #>
</select>
<# if ( '' !== data.transform_title ) { #>
<p class="description">{{ data.transform_title }}</p>
<# } #>
</label>
</div>
<# } #>
</div>
<?php
}
public function get_font_weight_choices() {
return array(
'normal' => esc_html( 'normal' ),
'bold' => esc_html( 'bold' ),
'100' => esc_html( '100' ),
'200' => esc_html( '200' ),
'300' => esc_html( '300' ),
'400' => esc_html( '400' ),
'500' => esc_html( '500' ),
'600' => esc_html( '600' ),
'700' => esc_html( '700' ),
'800' => esc_html( '800' ),
'900' => esc_html( '900' ),
);
}
public function get_font_transform_choices() {
return array(
'none' => esc_html( 'none' ),
'capitalize' => esc_html( 'capitalize' ),
'uppercase' => esc_html( 'uppercase' ),
'lowercase' => esc_html( 'lowercase' ),
);
}
}
}

View File

@ -0,0 +1,43 @@
<?php
/**
* The upsell Customizer controll.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Customize_Misc_Control' ) ) {
/**
* Create our in-section upsell controls.
* Escape your URL in the Customizer using esc_url().
*
* @since 0.1
*/
class Generate_Customize_Misc_Control extends WP_Customize_Control {
public $description = '';
public $url = '';
public $type = 'addon';
public $label = '';
public function enqueue() {
wp_enqueue_style( 'generate-customizer-controls-css', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/css/upsell-customizer.css', array(), GENERATE_VERSION );
}
public function to_json() {
parent::to_json();
$this->json['url'] = esc_url( $this->url );
}
public function content_template() {
?>
<p class="description" style="margin-top: 5px;">{{{ data.description }}}</p>
<span class="get-addon">
<a href="{{{ data.url }}}" class="button button-primary" target="_blank">{{ data.label }}</a>
</span>
<?php
}
}
}

View File

@ -0,0 +1,54 @@
<?php
/**
* The upsell Customizer section.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( class_exists( 'WP_Customize_Section' ) && ! class_exists( 'GeneratePress_Upsell_Section' ) ) {
/**
* Create our upsell section.
* Escape your URL in the Customizer using esc_url().
*
* @since unknown
*/
class GeneratePress_Upsell_Section extends WP_Customize_Section {
public $type = 'gp-upsell-section';
public $pro_url = '';
public $pro_text = '';
public $id = '';
public function json() {
$json = parent::json();
$json['pro_text'] = $this->pro_text;
$json['pro_url'] = esc_url( $this->pro_url );
$json['id'] = $this->id;
return $json;
}
protected function render_template() {
?>
<li id="accordion-section-{{ data.id }}" class="generate-upsell-accordion-section control-section-{{ data.type }} cannot-expand accordion-section">
<h3><a href="{{{ data.pro_url }}}" target="_blank">{{ data.pro_text }}</a></h3>
</li>
<?php
}
}
}
if ( ! function_exists( 'generate_customizer_controls_css' ) ) {
add_action( 'customize_controls_enqueue_scripts', 'generate_customizer_controls_css' );
/**
* Add CSS for our controls
*
* @since 1.3.41
*/
function generate_customizer_controls_css() {
wp_enqueue_style( 'generate-customizer-controls-css', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/css/upsell-customizer.css', array(), GENERATE_VERSION );
wp_enqueue_script( 'generatepress-upsell', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/upsell-control.js', array( 'customize-controls' ), false, true );
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,142 @@
.customize-control-generatepress-range-slider .generatepress-slider {
position: relative;
width: calc(100% - 60px);
height: 6px;
background-color: rgba(0,0,0,.10);
cursor: pointer;
-webkit-transition: background .5s;
-moz-transition: background .5s;
transition: background .5s;
}
.customize-control-generatepress-range-slider .has-unit .generatepress-slider {
width: calc(100% - 90px);
}
.customize-control-generatepress-range-slider .gp_range_value.hide-value {
display: none;
}
.customize-control-generatepress-range-slider .gp_range_value.hide-value + .generatepress-slider {
width: 100%;
}
.customize-control-generatepress-range-slider .generatepress-slider .ui-slider-handle {
height: 16px;
width: 16px;
background-color: #3498D9;
display: inline-block;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%) translateX(-4px);
transform: translateY(-50%) translateX(-4px);
border-radius: 50%;
cursor: pointer;
}
.gp-range-title-area {
display: flex;
}
.gp-range-slider-controls {
margin-left: auto;
}
.customize-control-generatepress-range-slider .wrapper {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.customize-control-generatepress-range-slider .gp_range_value {
font-size: 14px;
padding: 0;
font-weight: 400;
width: 50px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.customize-control-generatepress-range-slider .has-unit .gp_range_value {
width: 80px;
}
.customize-control-generatepress-range-slider .gp_range_value span.value {
font-size: 12px;
width: calc(100% - 2px);
text-align: center;
min-height: 30px;
background: #FFF;
line-height: 30px;
border: 1px solid #DDD;
}
.customize-control-generatepress-range-slider .has-unit .gp_range_value span.value {
width: calc(100% - 32px);
display: block;
}
.customize-control-generatepress-range-slider .gp_range_value .unit {
width: 29px;
text-align: center;
font-size: 12px;
line-height: 30px;
background: #fff;
border: 1px solid #ddd;
margin-left: 1px;
}
.customize-control-generatepress-range-slider .generatepress-range-slider-reset span {
font-size: 16px;
line-height: 22px;
}
.customize-control-generatepress-range-slider .gp_range_value input {
font-size: 12px;
padding: 0px;
text-align: center;
min-height: 30px;
height: auto;
border-radius: 0;
border-color: #ddd;
}
.customize-control-generatepress-range-slider .has-unit .gp_range_value input {
width: calc(100% - 30px);
}
.customize-control-generatepress-range-slider .gp-range-title-area .dashicons {
cursor: pointer;
font-size: 11px;
width: 20px;
height: 20px;
line-height: 20px;
color: #222;
text-align: center;
position: relative;
top: 2px;
}
.customize-control-generatepress-range-slider .gp-range-title-area .dashicons:hover {
background: #fafafa;
}
.customize-control-generatepress-range-slider .gp-range-title-area .dashicons.selected {
background: #fff;
color: #222;
}
.customize-control-generatepress-range-slider .gp-device-controls > span:first-child:last-child {
display: none;
}
.customize-control-generatepress-range-slider .sub-description {
margin-top: 10px;
}

View File

@ -0,0 +1,47 @@
.generatepress-font-family {
margin-bottom: 12px;
}
.generatepress-weight-transform-wrapper {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
}
.generatepress-font-weight,
.generatepress-font-transform {
width: calc(50% - 5px);
}
span.select2-container.select2-container--default.select2-container--open li.select2-results__option {
margin:0;
}
span.select2-container.select2-container--default.select2-container--open{
z-index:999999;
}
.select2-selection__rendered li {
margin-bottom: 0;
}
.select2-container--default .select2-selection--single,
.select2-container--default.select2-container .select2-selection--multiple,
.select2-dropdown,
.select2-container--default .select2-selection--multiple .select2-selection__choice {
border-color: #ddd;
border-radius: 0;
}
.select2-container--default .select2-results__option[aria-selected=true] {
color: rgba(0,0,0,0.4);
}
#customize-control-font_heading_1_control,
#customize-control-font_heading_2_control,
#customize-control-font_heading_3_control {
margin-top: 20px;
}

View File

@ -0,0 +1,54 @@
.customize-control-addon:before {
content: "";
height: 1px;
width: 50px;
background: rgba(0,0,0,.10);
display: block;
margin-bottom: 10px;
}
.customize-control-addon {
margin-top: 10px;
}
li#accordion-section-generatepress_upsell_section {
border-top: 1px solid #D54E21;
border-bottom: 1px solid #D54E21;
}
.generate-upsell-accordion-section a {
background: #FFF;
display: block;
padding: 10px 10px 11px 14px;
line-height: 21px;
color: #D54E21;
text-decoration: none;
}
.generate-upsell-accordion-section a:hover {
background:#FAFAFA;
}
.generate-upsell-accordion-section h3 {
margin: 0;
position: relative;
}
.generate-upsell-accordion-section h3 a:after {
content: "\f345";
color: #D54E21;
position: absolute;
top: 11px;
right: 10px;
z-index: 1;
float: right;
border: none;
background: none;
font: normal 20px/1 dashicons;
speak: none;
display: block;
padding: 0;
text-indent: 0;
text-align: center;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

View File

@ -0,0 +1,338 @@
( function( api ) {
'use strict';
// Add callback for when the header_textcolor setting exists.
api( 'generate_settings[nav_position_setting]', function( setting ) {
var isNavFloated, linkSettingValueToControlActiveState;
/**
* Determine whether the navigation is floating.
*
* @returns {boolean} Is floating?
*/
isNavFloated = function() {
if ( 'nav-float-right' === setting.get() || 'nav-float-left' === setting.get() ) {
return true;
}
return false;
};
/**
* Update a control's active state according to the navigation location setting's value.
*
* @param {wp.customize.Control} control
*/
linkSettingValueToControlActiveState = function( control ) {
var setActiveState = function() {
control.active.set( isNavFloated() );
};
// FYI: With the following we can eliminate all of our PHP active_callback code.
control.active.validate = isNavFloated;
// Set initial active state.
setActiveState();
/*
* Update activate state whenever the setting is changed.
* Even when the setting does have a refresh transport where the
* server-side active callback will manage the active state upon
* refresh, having this JS management of the active state will
* ensure that controls will have their visibility toggled
* immediately instead of waiting for the preview to load.
* This is especially important if the setting has a postMessage
* transport where changing the setting wouldn't normally cause
* the preview to refresh and thus the server-side active_callbacks
* would not get invoked.
*/
setting.bind( setActiveState );
};
// Call linkSettingValueToControlActiveState on the navigation dropdown point.
api.control( 'generate_settings[nav_drop_point]', linkSettingValueToControlActiveState );
} );
var setOption = function( headerAlignment, navLocation, navAlignment ) {
if ( headerAlignment ) {
api.control( 'generate_settings[header_alignment_setting]' ).setting.set( headerAlignment );
}
if ( navLocation ) {
api.control( 'generate_settings[nav_position_setting]' ).setting.set( navLocation );
}
if ( navAlignment ) {
api.control( 'generate_settings[nav_alignment_setting]' ).setting.set( navAlignment );
}
};
api( 'generate_header_helper', function( value ) {
var headerAlignment = false,
navLocation = false,
navAlignment = false;
value.bind( function( newval ) {
var headerAlignmentSetting = api.control( 'generate_settings[header_alignment_setting]' ).setting;
var navLocationSetting = api.control( 'generate_settings[nav_position_setting]' ).setting;
var navAlignmentSetting = api.control( 'generate_settings[nav_alignment_setting]' ).setting;
if ( ! headerAlignmentSetting._dirty ) {
headerAlignment = headerAlignmentSetting.get();
}
if ( ! navLocationSetting._dirty ) {
navLocation = navLocationSetting.get();
}
if ( ! navAlignmentSetting._dirty ) {
navAlignment = navAlignmentSetting.get();
}
if ( 'current' === newval ) {
setOption( headerAlignment, navLocation, navAlignment );
}
if ( 'default' === newval ) {
setOption( generatepress_defaults.header_alignment_setting, generatepress_defaults.nav_position_setting, generatepress_defaults.nav_alignment_setting );
}
if ( 'nav-before-centered' === newval ) {
setOption( 'center', 'nav-above-header', 'center' );
}
if ( 'nav-after-centered' === newval ) {
setOption( 'center', 'nav-below-header', 'center' );
}
if ( 'nav-right' === newval ) {
setOption( 'left', 'nav-float-right', 'left' );
}
if ( 'nav-left' === newval ) {
setOption( 'right', 'nav-float-left', 'right' );
}
} );
} );
api( 'nav_color_presets', function( value ) {
var backgroundColor = false,
textColor = false,
backgroundColorHover = false,
textColorHover = false,
currentBackgroundColor = false,
currentTextColor = false,
subMenuBackgroundColor = false,
subMenuTextColor = false,
subMenuBackgroundColorHover = false,
subMenuTextColorHover = false,
subMenuCurrentBackgroundColor = false,
subMenuCurrentTextColor = false;
value.bind( function( newval ) {
var backgroundColorSetting = api.instance( 'generate_settings[navigation_background_color]' ),
textColorSetting = api.instance( 'generate_settings[navigation_text_color]' ),
backgroundColorHoverSetting = api.instance( 'generate_settings[navigation_background_hover_color]' ),
textColorHoverSetting = api.instance( 'generate_settings[navigation_text_hover_color]' ),
currentBackgroundColorSetting = api.instance( 'generate_settings[navigation_background_current_color]' ),
currentTextColorSetting = api.instance( 'generate_settings[navigation_text_current_color]' ),
subMenuBackgroundColorSetting = api.instance( 'generate_settings[subnavigation_background_color]' ),
subMenuTextColorSetting = api.instance( 'generate_settings[subnavigation_text_color]' ),
subMenuBackgroundColorHoverSetting = api.instance( 'generate_settings[subnavigation_background_hover_color]' ),
subMenuTextColorHoverSetting = api.instance( 'generate_settings[subnavigation_text_hover_color]' ),
subMenuCurrentBackgroundColorSetting = api.instance( 'generate_settings[subnavigation_background_current_color]' ),
subMenuCurrentTextColorSetting = api.instance( 'generate_settings[subnavigation_text_current_color]' );
if ( ! backgroundColorSetting._dirty ) {
backgroundColor = backgroundColorSetting.get();
}
if ( ! textColorSetting._dirty ) {
textColor = textColorSetting.get();
}
if ( ! backgroundColorHoverSetting._dirty ) {
backgroundColorHover = backgroundColorHoverSetting.get();
}
if ( ! textColorHoverSetting._dirty ) {
textColorHover = textColorHoverSetting.get();
}
if ( ! currentBackgroundColorSetting._dirty ) {
currentBackgroundColor = currentBackgroundColorSetting.get();
}
if ( ! currentTextColorSetting._dirty ) {
currentTextColor = currentTextColorSetting.get();
}
if ( ! subMenuBackgroundColorSetting._dirty ) {
subMenuBackgroundColor = subMenuBackgroundColorSetting.get();
}
if ( ! subMenuTextColorSetting._dirty ) {
subMenuTextColor = subMenuTextColorSetting.get();
}
if ( ! subMenuBackgroundColorHoverSetting._dirty ) {
subMenuBackgroundColorHover = subMenuBackgroundColorHoverSetting.get();
}
if ( ! subMenuTextColorHoverSetting._dirty ) {
subMenuTextColorHover = subMenuTextColorHoverSetting.get();
}
if ( ! subMenuCurrentBackgroundColorSetting._dirty ) {
subMenuCurrentBackgroundColor = subMenuCurrentBackgroundColorSetting.get();
}
if ( ! subMenuCurrentTextColorSetting._dirty ) {
subMenuCurrentTextColor = subMenuCurrentTextColorSetting.get();
}
if ( 'current' === newval ) {
backgroundColorSetting.set( backgroundColor );
textColorSetting.set( textColor );
backgroundColorHoverSetting.set( backgroundColorHover );
textColorHoverSetting.set( textColorHover );
currentBackgroundColorSetting.set( currentBackgroundColor );
currentTextColorSetting.set( currentTextColorSetting );
subMenuBackgroundColorSetting.set( subMenuBackgroundColor );
subMenuTextColorSetting.set( subMenuTextColor );
subMenuBackgroundColorHoverSetting.set( subMenuBackgroundColorHover );
subMenuTextColorHoverSetting.set( subMenuTextColorHover );
subMenuCurrentBackgroundColorSetting.set( subMenuCurrentBackgroundColor );
subMenuCurrentTextColorSetting.set( subMenuCurrentTextColorSetting );
}
if ( 'default' === newval ) {
backgroundColorSetting.set( generatepress_color_defaults.navigation_background_color );
textColorSetting.set( generatepress_color_defaults.navigation_text_color );
backgroundColorHoverSetting.set( generatepress_color_defaults.navigation_background_hover_color );
textColorHoverSetting.set( generatepress_color_defaults.navigation_text_hover_color );
currentBackgroundColorSetting.set( generatepress_color_defaults.navigation_background_current_color );
currentTextColorSetting.set( generatepress_color_defaults.navigation_text_current_color );
subMenuBackgroundColorSetting.set( generatepress_color_defaults.subnavigation_background_color );
subMenuTextColorSetting.set( generatepress_color_defaults.subnavigation_text_color );
subMenuBackgroundColorHoverSetting.set( generatepress_color_defaults.subnavigation_background_hover_color );
subMenuTextColorHoverSetting.set( generatepress_color_defaults.subnavigation_text_hover_color );
subMenuCurrentBackgroundColorSetting.set( generatepress_color_defaults.subnavigation_background_current_color );
subMenuCurrentTextColorSetting.set( generatepress_color_defaults.subnavigation_text_current_color );
}
if ( 'white' === newval ) {
backgroundColorSetting.set( '#ffffff' );
textColorSetting.set( '#000000' );
backgroundColorHoverSetting.set( '#ffffff' );
textColorHoverSetting.set( '#8f919e' );
currentBackgroundColorSetting.set( '#ffffff' );
currentTextColorSetting.set( '#8f919e' );
subMenuBackgroundColorSetting.set( '#f6f9fc' );
subMenuTextColorSetting.set( '#000000' );
subMenuBackgroundColorHoverSetting.set( '#f6f9fc' );
subMenuTextColorHoverSetting.set( '#8f919e' );
subMenuCurrentBackgroundColorSetting.set( '#f6f9fc' );
subMenuCurrentTextColorSetting.set( '#8f919e' );
}
if ( 'grey' === newval ) {
backgroundColorSetting.set( '#595959' );
textColorSetting.set( '#ffffff' );
backgroundColorHoverSetting.set( '#424242' );
textColorHoverSetting.set( '#ffffff' );
currentBackgroundColorSetting.set( '#424242' );
currentTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorSetting.set( '#424242' );
subMenuTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorHoverSetting.set( '#424242' );
subMenuTextColorHoverSetting.set( '#dbdbdb' );
subMenuCurrentBackgroundColorSetting.set( '#424242' );
subMenuCurrentTextColorSetting.set( '#dbdbdb' );
}
if ( 'blue' === newval ) {
backgroundColorSetting.set( '#1e73be' );
textColorSetting.set( '#ffffff' );
backgroundColorHoverSetting.set( '#035a9e' );
textColorHoverSetting.set( '#ffffff' );
currentBackgroundColorSetting.set( '#035a9e' );
currentTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorSetting.set( '#035a9e' );
subMenuTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorHoverSetting.set( '#035a9e' );
subMenuTextColorHoverSetting.set( '#bbd2e8' );
subMenuCurrentBackgroundColorSetting.set( '#035a9e' );
subMenuCurrentTextColorSetting.set( '#bbd2e8' );
}
if ( 'red' === newval ) {
backgroundColorSetting.set( '#ed4250' );
textColorSetting.set( '#ffffff' );
backgroundColorHoverSetting.set( '#c42f2f' );
textColorHoverSetting.set( '#ffffff' );
currentBackgroundColorSetting.set( '#c42f2f' );
currentTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorSetting.set( '#c42f2f' );
subMenuTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorHoverSetting.set( '#c42f2f' );
subMenuTextColorHoverSetting.set( '#fcd9d6' );
subMenuCurrentBackgroundColorSetting.set( '#c42f2f' );
subMenuCurrentTextColorSetting.set( '#fcd9d6' );
}
if ( 'green' === newval ) {
backgroundColorSetting.set( '#16aa74' );
textColorSetting.set( '#ffffff' );
backgroundColorHoverSetting.set( '#119b6d' );
textColorHoverSetting.set( '#ffffff' );
currentBackgroundColorSetting.set( '#119b6d' );
currentTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorSetting.set( '#119b6d' );
subMenuTextColorSetting.set( '#ffffff' );
subMenuBackgroundColorHoverSetting.set( '#119b6d' );
subMenuTextColorHoverSetting.set( '#c2e8de' );
subMenuCurrentBackgroundColorSetting.set( '#119b6d' );
subMenuCurrentTextColorSetting.set( '#c2e8de' );
}
jQuery('.wp-color-picker').wpColorPicker().change();
} );
} );
}( wp.customize ) );

View File

@ -0,0 +1,609 @@
/**
* Theme Customizer enhancements for a better user experience.
*
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
*/
function generatepress_colors_live_update( id, selector, property, default_value, get_value ) {
default_value = typeof default_value !== 'undefined' ? default_value : 'initial';
get_value = typeof get_value !== 'undefined' ? get_value : '';
wp.customize( 'generate_settings[' + id + ']', function( value ) {
value.bind( function( newval ) {
default_value = ( '' !== get_value ) ? wp.customize.value('generate_settings[' + get_value + ']')() : default_value;
newval = ( '' !== newval ) ? newval : default_value;
if ( jQuery( 'style#' + id ).length ) {
jQuery( 'style#' + id ).html( selector + '{' + property + ':' + newval + ';}' );
} else {
jQuery( 'head' ).append( '<style id="' + id + '">' + selector + '{' + property + ':' + newval + '}</style>' );
setTimeout(function() {
jQuery( 'style#' + id ).not( ':last' ).remove();
}, 1000);
}
} );
} );
}
function generatepress_classes_live_update( id, classes, selector, prefix ) {
classes = typeof classes !== 'undefined' ? classes : '';
prefix = typeof prefix !== 'undefined' ? prefix : '';
wp.customize( 'generate_settings[' + id + ']', function( value ) {
value.bind( function( newval ) {
jQuery.each( classes, function( i, v ) {
jQuery( selector ).removeClass( prefix + v );
});
jQuery( selector ).addClass( prefix + newval );
} );
} );
}
function generatepress_typography_live_update( id, selector, property, unit, media, settings ) {
settings = typeof settings !== 'undefined' ? settings : 'generate_settings';
wp.customize( settings + '[' + id + ']', function( value ) {
value.bind( function( newval ) {
// Get our unit if applicable
unit = typeof unit !== 'undefined' ? unit : '';
var isTablet = ( 'tablet' == id.substring( 0, 6 ) ) ? true : false,
isMobile = ( 'mobile' == id.substring( 0, 6 ) ) ? true : false;
if ( isTablet ) {
if ( '' == wp.customize(settings + '[' + id + ']').get() ) {
var desktopID = id.replace( 'tablet_', '' );
newval = wp.customize(settings + '[' + desktopID + ']').get();
}
}
if ( isMobile ) {
if ( '' == wp.customize(settings + '[' + id + ']').get() ) {
var desktopID = id.replace( 'mobile_', '' );
newval = wp.customize(settings + '[' + desktopID + ']').get();
}
}
if ( 'buttons_font_size' == id && '' == wp.customize('generate_settings[buttons_font_size]').get() ) {
newval = wp.customize('generate_settings[body_font_size]').get();
}
// We're using a desktop value
if ( ! isTablet && ! isMobile ) {
var tabletValue = ( typeof wp.customize(settings + '[tablet_' + id + ']') !== 'undefined' ) ? wp.customize(settings + '[tablet_' + id + ']').get() : '',
mobileValue = ( typeof wp.customize(settings + '[mobile_' + id + ']') !== 'undefined' ) ? wp.customize(settings + '[mobile_' + id + ']').get() : '';
// The tablet setting exists, mobile doesn't
if ( '' !== tabletValue && '' == mobileValue ) {
media = generatepress_live_preview.desktop + ', ' + generatepress_live_preview.mobile;
}
// The tablet setting doesn't exist, mobile does
if ( '' == tabletValue && '' !== mobileValue ) {
media = generatepress_live_preview.desktop + ', ' + generatepress_live_preview.tablet;
}
// The tablet setting doesn't exist, neither does mobile
if ( '' == tabletValue && '' == mobileValue ) {
media = generatepress_live_preview.desktop + ', ' + generatepress_live_preview.tablet + ', ' + generatepress_live_preview.mobile;
}
}
// Check if media query
media_query = typeof media !== 'undefined' ? 'media="' + media + '"' : '';
jQuery( 'head' ).append( '<style id="' + id + '" ' + media_query + '>' + selector + '{' + property + ':' + newval + unit + ';}</style>' );
setTimeout(function() {
jQuery( 'style#' + id ).not( ':last' ).remove();
}, 1000);
setTimeout("jQuery('body').trigger('generate_spacing_updated');", 1000);
} );
} );
}
( function( $ ) {
// Update the site title in real time...
wp.customize( 'blogname', function( value ) {
value.bind( function( newval ) {
$( '.main-title a' ).html( newval );
} );
} );
//Update the site description in real time...
wp.customize( 'blogdescription', function( value ) {
value.bind( function( newval ) {
$( '.site-description' ).html( newval );
} );
} );
wp.customize( 'generate_settings[logo_width]', function( value ) {
value.bind( function( newval ) {
$( '.site-header .header-image' ).css( 'width', newval + 'px' );
if ( '' == newval ) {
$( '.site-header .header-image' ).css( 'width', '' );
}
} );
} );
/**
* Body background color
* Empty: white
*/
generatepress_colors_live_update( 'background_color', 'body', 'background-color', '#FFFFFF' );
/**
* Text color
* Empty: black
*/
generatepress_colors_live_update( 'text_color', 'body', 'color', '#000000' );
/**
* Link color
* Empty: initial
*/
generatepress_colors_live_update( 'link_color', 'a, a:visited', 'color', 'initial' );
/**
* Link color hover
* Empty: initial
*/
generatepress_colors_live_update( 'link_color_hover', 'a:hover', 'color', 'initial' );
/**
* Live update for content & navigation colors thanks to our preset option.
* We only want to run this if GP Premium isn't already doing it.
*/
if ( 'undefined' == typeof generate_colors_live_update ) {
/**
* Blog post title color
* Empty: Body link color
*/
generatepress_colors_live_update( 'blog_post_title_color', '.entry-title a, .entry-title a:visited', 'color', '', 'link_color' );
/**
* Blog post title color on hover
* Empty: Body link color on hover
*/
generatepress_colors_live_update( 'blog_post_title_hover_color', '.entry-title a:hover', 'color', '', 'link_color_hover' );
/**
* Navigation background color
* Empty: Transparent
*/
generatepress_colors_live_update( 'navigation_background_color', '.main-navigation', 'background-color', 'transparent' );
/**
* Primary navigation text color
* Empty: link_color
*/
generatepress_colors_live_update( 'navigation_text_color',
'.main-navigation .main-nav ul li a,\
.menu-toggle,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',
'color',
'',
'link_color'
);
/**
* Primary navigation text color hover
* Empty: link_color_hover
*/
generatepress_colors_live_update( 'navigation_text_hover_color',
'.navigation-search input[type="search"],\
.navigation-search input[type="search"]:active,\
.navigation-search input[type="search"]:focus,\
.main-navigation .main-nav ul li:hover > a,\
.main-navigation .main-nav ul li:focus > a,\
.main-navigation .main-nav ul li.sfHover > a',
'color',
'',
'link_color_hover'
);
/**
* Primary navigation menu item hover
* Empty: transparent
*/
generatepress_colors_live_update( 'navigation_background_hover_color',
'.navigation-search input[type="search"],\
.navigation-search input[type="search"]:focus,\
.main-navigation .main-nav ul li:hover > a,\
.main-navigation .main-nav ul li:focus > a,\
.main-navigation .main-nav ul li.sfHover > a',
'background-color',
'transparent'
);
/**
* Primary sub-navigation color
* Empty: transparent
*/
generatepress_colors_live_update( 'subnavigation_background_color', '.main-navigation ul ul', 'background-color', 'transparent' );
/**
* Primary sub-navigation text color
* Empty: link_color
*/
generatepress_colors_live_update( 'subnavigation_text_color', '.main-navigation .main-nav ul ul li a', 'color', 'link_color' );
/**
* Primary sub-navigation hover
*/
var subnavigation_hover = '.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';
/**
* Primary sub-navigation text hover
* Empty: link_color_hover
*/
generatepress_colors_live_update( 'subnavigation_text_hover_color', subnavigation_hover, 'color', '', 'link_color_hover' );
/**
* Primary sub-navigation background hover
* Empty: transparent
*/
generatepress_colors_live_update( 'subnavigation_background_hover_color', subnavigation_hover, 'background-color', 'transparent' );
/**
* Navigation current selectors
*/
var navigation_current = '.main-navigation .main-nav ul li[class*="current-menu-"] > a, \
.main-navigation .main-nav ul li[class*="current-menu-"]:hover > a, \
.main-navigation .main-nav ul li[class*="current-menu-"].sfHover > a';
/**
* Primary navigation current text
* Empty: link_color
*/
generatepress_colors_live_update( 'navigation_text_current_color', navigation_current, 'color', '', 'link_color' );
/**
* Primary navigation current background
* Empty: transparent
*/
generatepress_colors_live_update( 'navigation_background_current_color', navigation_current, 'background-color', 'transparent' );
/**
* Primary sub-navigation current selectors
*/
var subnavigation_current = '.main-navigation .main-nav ul ul li[class*="current-menu-"] > a,\
.main-navigation .main-nav ul ul li[class*="current-menu-"]:hover > a, \
.main-navigation .main-nav ul ul li[class*="current-menu-"].sfHover > a';
/**
* Primary sub-navigation current text
* Empty: link_color
*/
generatepress_colors_live_update( 'subnavigation_text_current_color', subnavigation_current, 'color', '', 'link_color' );
/**
* Primary navigation current item background
* Empty: transparent
*/
generatepress_colors_live_update( 'subnavigation_background_current_color', subnavigation_current, 'background-color', 'transparent' );
}
/**
* Container width
*/
wp.customize( 'generate_settings[container_width]', function( value ) {
value.bind( function( newval ) {
if ( jQuery( 'style#container_width' ).length ) {
jQuery( 'style#container_width' ).html( 'body .grid-container, .wp-block-group__inner-container{max-width:' + newval + 'px;}' );
} else {
jQuery( 'head' ).append( '<style id="container_width">body .grid-container, .wp-block-group__inner-container{max-width:' + newval + 'px;}</style>' );
setTimeout(function() {
jQuery( 'style#container_width' ).not( ':last' ).remove();
}, 100);
}
jQuery('body').trigger('generate_spacing_updated');
} );
} );
/**
* Live update for typography options.
* We only want to run this if GP Premium isn't already doing it.
*/
if ( 'undefined' == typeof gp_premium_typography_live_update ) {
/**
* Body font size, weight and transform
*/
generatepress_typography_live_update( 'body_font_size', 'body, button, input, select, textarea', 'font-size', 'px' );
generatepress_typography_live_update( 'body_line_height', 'body', 'line-height', '' );
generatepress_typography_live_update( 'paragraph_margin', 'p, .entry-content > [class*="wp-block-"]:not(:last-child)', 'margin-bottom', 'em' );
generatepress_typography_live_update( 'body_font_weight', 'body, button, input, select, textarea', 'font-weight' );
generatepress_typography_live_update( 'body_font_transform', 'body, button, input, select, textarea', 'text-transform' );
/**
* H1 font size, weight and transform
*/
generatepress_typography_live_update( 'heading_1_font_size', 'h1', 'font-size', 'px', generatepress_live_preview.desktop );
generatepress_typography_live_update( 'mobile_heading_1_font_size', 'h1', 'font-size', 'px', generatepress_live_preview.mobile );
generatepress_typography_live_update( 'heading_1_weight', 'h1', 'font-weight' );
generatepress_typography_live_update( 'heading_1_transform', 'h1', 'text-transform' );
generatepress_typography_live_update( 'heading_1_line_height', 'h1', 'line-height', 'em' );
/**
* H2 font size, weight and transform
*/
generatepress_typography_live_update( 'heading_2_font_size', 'h2', 'font-size', 'px', generatepress_live_preview.desktop );
generatepress_typography_live_update( 'mobile_heading_2_font_size', 'h2', 'font-size', 'px', generatepress_live_preview.mobile );
generatepress_typography_live_update( 'heading_2_weight', 'h2', 'font-weight' );
generatepress_typography_live_update( 'heading_2_transform', 'h2', 'text-transform' );
generatepress_typography_live_update( 'heading_2_line_height', 'h2', 'line-height', 'em' );
/**
* H3 font size, weight and transform
*/
generatepress_typography_live_update( 'heading_3_font_size', 'h3', 'font-size', 'px' );
generatepress_typography_live_update( 'heading_3_weight', 'h3', 'font-weight' );
generatepress_typography_live_update( 'heading_3_transform', 'h3', 'text-transform' );
generatepress_typography_live_update( 'heading_3_line_height', 'h3', 'line-height', 'em' );
}
/**
* Content layout
*/
generatepress_classes_live_update( 'content_layout_setting', [ 'one-container', 'separate-containers' ], 'body' );
/**
* Top bar width
*/
wp.customize( 'generate_settings[top_bar_width]', function( value ) {
value.bind( function( newval ) {
if ( 'full' == newval ) {
$( '.top-bar' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
if ( 'contained' == wp.customize.value('generate_settings[top_bar_inner_width]')() ) {
$( '.inside-top-bar' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
}
}
if ( 'contained' == newval ) {
$( '.top-bar' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
$( '.inside-top-bar' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
}
} );
} );
/**
* Inner top bar width
*/
wp.customize( 'generate_settings[top_bar_inner_width]', function( value ) {
value.bind( function( newval ) {
if ( 'full' == newval ) {
$( '.inside-top-bar' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
}
if ( 'contained' == newval ) {
$( '.inside-top-bar' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
}
} );
} );
/**
* Top bar alignment
*/
generatepress_classes_live_update( 'top_bar_alignment', [ 'left', 'center', 'right' ], '.top-bar', 'top-bar-align-' );
/**
* Header layout
*/
wp.customize( 'generate_settings[header_layout_setting]', function( value ) {
value.bind( function( newval ) {
if ( 'fluid-header' == newval ) {
$( '.site-header' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
if ( 'contained' == wp.customize.value('generate_settings[header_inner_width]')() ) {
$( '.inside-header' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
}
}
if ( 'contained-header' == newval ) {
$( '.site-header' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
$( '.inside-header' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
}
} );
} );
/**
* Inner Header layout
*/
wp.customize( 'generate_settings[header_inner_width]', function( value ) {
value.bind( function( newval ) {
if ( 'full-width' == newval ) {
$( '.inside-header' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
}
if ( 'contained' == newval ) {
$( '.inside-header' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
}
} );
} );
/**
* Header alignment
*/
generatepress_classes_live_update( 'header_alignment_setting', [ 'left', 'center', 'right' ], 'body', 'header-aligned-' );
/**
* Navigation width
*/
wp.customize( 'generate_settings[nav_layout_setting]', function( value ) {
value.bind( function( newval ) {
if ( $( 'body' ).hasClass( 'sticky-enabled' ) ) {
wp.customize.preview.send( 'refresh' );
} else {
if ( 'fluid-nav' == newval ) {
$( '.main-navigation' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
if ( 'full-width' !== wp.customize.value('generate_settings[nav_inner_width]')() ) {
$( '.main-navigation .inside-navigation' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
}
}
if ( 'contained-nav' == newval ) {
$( '.main-navigation' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
$( '.main-navigation .inside-navigation' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
}
}
} );
} );
/**
* Inner navigation width
*/
wp.customize( 'generate_settings[nav_inner_width]', function( value ) {
value.bind( function( newval ) {
if ( 'full-width' == newval ) {
$( '.main-navigation .inside-navigation' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
}
if ( 'contained' == newval ) {
$( '.main-navigation .inside-navigation' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
}
} );
} );
/**
* Navigation position
*/
wp.customize( 'generate_settings[nav_position_setting]', function( value ) {
value.bind( function( newval ) {
$( 'body' ).trigger( 'generate_navigation_location_updated' );
// Update navigation alignment settings.
$( 'body' ).removeClass( 'nav-aligned-center' );
$( 'body' ).removeClass( 'nav-aligned-left' );
$( 'body' ).removeClass( 'nav-aligned-right' );
$( 'body' ).addClass( 'nav-aligned-' + wp.customize.value('generate_settings[nav_alignment_setting]')() );
if ( $( '.gen-sidebar-nav' ).length ) {
wp.customize.preview.send( 'refresh' );
return false;
}
if ( 'nav-left-sidebar' == newval ) {
wp.customize.preview.send( 'refresh' );
return false;
}
if ( 'nav-right-sidebar' == newval ) {
wp.customize.preview.send( 'refresh' );
return false;
}
if ( '' !== wp.customize.value('generate_settings[nav_drop_point]')() ) {
wp.customize.preview.send( 'refresh' );
return false;
}
var classes = [ 'nav-below-header', 'nav-above-header', 'nav-float-right', 'nav-float-left', 'nav-left-sidebar', 'nav-right-sidebar' ];
if ( 'nav-left-sidebar' !== newval && 'nav-right-sidebar' !== newval ) {
$.each( classes, function( i, v ) {
$( 'body' ).removeClass( v );
});
}
$( 'body' ).addClass( newval );
if ( 'nav-below-header' == newval ) {
$( '#site-navigation:first' ).insertAfter( '.site-header' ).show();
}
if ( 'nav-above-header' == newval ) {
if ( $( '.top-bar:not(.secondary-navigation .top-bar)' ).length ) {
$( '#site-navigation:first' ).insertAfter( '.top-bar' ).show();
} else {
$( '#site-navigation:first' ).prependTo( 'body' ).show();
}
}
if ( 'nav-float-right' == newval ) {
if ( ! $( 'body' ).hasClass( 'using-floats' ) && $( '.header-widget' ).length ) {
$( '#site-navigation:first' ).insertBefore( '.header-widget' ).show();
} else {
$( '#site-navigation:first' ).appendTo( '.inside-header' ).show();
}
}
if ( 'nav-float-left' == newval ) {
$( '#site-navigation:first' ).appendTo( '.inside-header' ).show();
}
if ( '' == newval ) {
if ( $( '.gen-sidebar-nav' ).length ) {
wp.customize.preview.send( 'refresh' );
} else {
$( '#site-navigation:first' ).hide();
}
}
} );
} );
/**
* Navigation alignment
*/
generatepress_classes_live_update( 'nav_alignment_setting', [ 'left', 'center', 'right' ], 'body', 'nav-aligned-' );
/**
* Footer width
*/
wp.customize( 'generate_settings[footer_layout_setting]', function( value ) {
value.bind( function( newval ) {
if ( 'fluid-footer' == newval ) {
$( '.site-footer' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
}
if ( 'contained-footer' == newval ) {
$( '.site-footer' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
}
} );
} );
/**
* Inner footer width
*/
wp.customize( 'generate_settings[footer_inner_width]', function( value ) {
value.bind( function( newval ) {
if ( 'full-width' == newval ) {
if ( $( '.footer-widgets-container' ).length ) {
$( '.footer-widgets-container' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
} else {
$( '.inside-footer-widgets' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
}
$( '.inside-site-info' ).removeClass( 'grid-container' ).removeClass( 'grid-parent' );
}
if ( 'contained' == newval ) {
if ( $( '.footer-widgets-container' ).length ) {
$( '.footer-widgets-container' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
} else {
$( '.inside-footer-widgets' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
}
$( '.inside-site-info' ).addClass( 'grid-container' ).addClass( 'grid-parent' );
}
} );
} );
/**
* Footer bar alignment
*/
generatepress_classes_live_update( 'footer_bar_alignment', [ 'left', 'center', 'right' ], '.site-footer', 'footer-bar-align-' );
jQuery( 'body' ).on( 'generate_spacing_updated', function() {
var containerAlignment = wp.customize( 'generate_settings[container_alignment]' ).get(),
containerWidth = wp.customize( 'generate_settings[container_width]' ).get(),
contentLeft = generatepress_live_preview.contentLeft,
contentRight = generatepress_live_preview.contentRight;
if ( 'text' === containerAlignment ) {
if ( typeof wp.customize( 'generate_spacing_settings[content_left]' ) !== 'undefined' ) {
contentLeft = wp.customize( 'generate_spacing_settings[content_left]' ).get();
}
if ( typeof wp.customize( 'generate_spacing_settings[content_right]' ) !== 'undefined' ) {
contentRight = wp.customize( 'generate_spacing_settings[content_right]' ).get();
}
var newContainerWidth = Number( containerWidth ) + Number( contentLeft ) + Number( contentRight );
if ( jQuery( 'style#wide_container_width' ).length ) {
jQuery( 'style#wide_container_width' ).html( '#page{max-width:' + newContainerWidth + 'px;}' );
} else {
jQuery( 'head' ).append( '<style id="wide_container_width">#page{max-width:' + newContainerWidth + 'px;}</style>' );
setTimeout(function() {
jQuery( 'style#wide_container_width' ).not( ':last' ).remove();
}, 100);
}
}
} );
} )( jQuery );

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,134 @@
wp.customize.controlConstructor['generatepress-range-slider'] = wp.customize.Control.extend({
ready: function() {
'use strict';
var control = this,
value,
thisInput,
inputDefault,
changeAction,
controlClass = '.customize-control-generatepress-range-slider',
footerActions = jQuery( '#customize-footer-actions' );
// Set up the sliders
jQuery( '.generatepress-slider' ).each( function() {
var _this = jQuery( this );
var _input = _this.closest( 'label' ).find( 'input[type="number"]' );
var _text = _input.next( '.value' );
_this.slider({
value: _input.val(),
min: _this.data( 'min' ),
max: _this.data( 'max' ),
step: _this.data( 'step' ),
slide: function( event, ui ) {
_input.val( ui.value ).change();
_text.text( ui.value );
}
});
});
// Update the range value based on the input value
jQuery( controlClass + ' .gp_range_value input[type=number]' ).on( 'input', function() {
value = jQuery( this ).attr( 'value' );
if ( '' == value ) {
value = -1;
}
jQuery( this ).closest( 'label' ).find( '.generatepress-slider' ).slider( 'value', parseFloat(value)).change();
});
// Handle the reset button
jQuery( controlClass + ' .generatepress-reset' ).on( 'click', function() {
var icon = jQuery( this ),
visible_area = icon.closest( '.gp-range-title-area' ).next( '.gp-range-slider-areas' ).children( 'label:visible' ),
input = visible_area.find( 'input[type=number]' ),
slider_value = visible_area.find( '.generatepress-slider' ),
visual_value = visible_area.find( '.gp_range_value' ),
reset_value = input.attr( 'data-reset_value' );
input.val( reset_value ).change();
visual_value.find( 'input' ).val( reset_value );
visual_value.find( '.value' ).text( reset_value );
if ( '' == reset_value ) {
reset_value = -1;
}
slider_value.slider( 'value', parseFloat( reset_value ) );
});
// Figure out which device icon to make active on load
jQuery( controlClass + ' .generatepress-range-slider-control' ).each( function() {
var _this = jQuery( this );
_this.find( '.gp-device-controls' ).children( 'span:first-child' ).addClass( 'selected' );
_this.find( '.range-option-area:first-child' ).show();
});
// Do stuff when device icons are clicked
jQuery( controlClass + ' .gp-device-controls > span' ).on( 'click', function( event ) {
var device = jQuery( this ).data( 'option' );
jQuery( controlClass + ' .gp-device-controls span' ).each( function() {
var _this = jQuery( this );
if ( device == _this.attr( 'data-option' ) ) {
_this.addClass( 'selected' );
_this.siblings().removeClass( 'selected' );
}
});
jQuery( controlClass + ' .gp-range-slider-areas label' ).each( function() {
var _this = jQuery( this );
if ( device == _this.attr( 'data-option' ) ) {
_this.show();
_this.siblings().hide();
}
});
// Set the device we're currently viewing
wp.customize.previewedDevice.set( jQuery( event.currentTarget ).data( 'option' ) );
} );
// Set the selected devices in our control when the Customizer devices are clicked
footerActions.find( '.devices button' ).on( 'click', function() {
var device = jQuery( this ).data( 'device' );
jQuery( controlClass + ' .gp-device-controls span' ).each( function() {
var _this = jQuery( this );
if ( device == _this.attr( 'data-option' ) ) {
_this.addClass( 'selected' );
_this.siblings().removeClass( 'selected' );
}
});
jQuery( controlClass + ' .gp-range-slider-areas label' ).each( function() {
var _this = jQuery( this );
if ( device == _this.attr( 'data-option' ) ) {
_this.show();
_this.siblings().hide();
}
});
});
// Apply changes when desktop slider is changed
control.container.on( 'input change', '.desktop-range',
function() {
control.settings['desktop'].set( jQuery( this ).val() );
}
);
// Apply changes when tablet slider is changed
control.container.on( 'input change', '.tablet-range',
function() {
control.settings['tablet'].set( jQuery( this ).val() );
}
);
// Apply changes when mobile slider is changed
control.container.on( 'input change', '.mobile-range',
function() {
control.settings['mobile'].set( jQuery( this ).val() );
}
);
}
});

View File

@ -0,0 +1,154 @@
( function( api ) {
api.controlConstructor['gp-customizer-typography'] = api.Control.extend( {
ready: function() {
var control = this;
control.container.on( 'change', '.generatepress-font-family select',
function() {
var _this = jQuery( this ),
_value = _this.val(),
_categoryID = _this.attr( 'data-category' ),
_variantsID = _this.attr( 'data-variants' );
// Set our font family
control.settings['family'].set( _this.val() );
// Bail if our controls don't exist
if ( 'undefined' == typeof control.settings['category'] || 'undefined' == typeof control.settings['variant'] ) {
return;
}
setTimeout( function() {
// Send our request to the generate_get_all_google_fonts_ajax function
var response = jQuery.getJSON({
type: 'POST',
url: ajaxurl,
data: {
action: 'generate_get_all_google_fonts_ajax',
gp_customize_nonce: gp_customize.nonce
},
async: false,
dataType: 'json',
});
// Get our response
var fonts = response.responseJSON;
// Create an ID from our selected font
var id = _value.split(' ').join('_').toLowerCase();
// Set our values if we have them
if ( id in fonts ) {
// Get existing variants if this font is already selected
var got_variants = false;
jQuery( '.generatepress-font-family select' ).not( _this ).each( function( key, select ) {
var parent = jQuery( this ).closest( '.generatepress-font-family' );
if ( _value == jQuery( select ).val() && _this.data( 'category' ) !== jQuery( select ).data( 'category' ) ) {
if ( ! got_variants ) {
updated_variants = jQuery( parent.next( '.generatepress-font-variant' ).find( 'select' ) ).val();
got_variants = true;
}
}
} );
// We're using a Google font, so show the variants field
_this.closest( '.generatepress-font-family' ).next( 'div' ).show();
// Remove existing variants
jQuery( 'select[name="' + _variantsID + '"]' ).find( 'option' ).remove();
// Populate our select input with available variants
jQuery.each( fonts[ id ].variants, function( key, value ) {
jQuery( 'select[name="' + _variantsID + '"]' ).append( jQuery( '<option></option>' ).attr( 'value', value ).text( value ) );
} );
// Set our variants
if ( ! got_variants ) {
control.settings[ 'variant' ].set( fonts[ id ].variants );
} else {
control.settings[ 'variant' ].set( updated_variants );
}
// Set our font category
control.settings[ 'category' ].set( fonts[ id ].category );
jQuery( 'input[name="' + _categoryID + '"' ).val( fonts[ id ].category );
} else {
_this.closest( '.generatepress-font-family' ).next( 'div' ).hide();
control.settings[ 'category' ].set( '' )
control.settings[ 'variant' ].set( '' )
jQuery( 'input[name="' + _categoryID + '"' ).val( '' );
jQuery( 'select[name="' + _variantsID + '"]' ).find( 'option' ).remove();
}
}, 25 );
}
);
control.container.on( 'change', '.generatepress-font-variant select',
function() {
var _this = jQuery( this );
var variants = _this.val();
control.settings['variant'].set( variants );
jQuery( '.generatepress-font-variant select' ).each( function( key, value ) {
var this_control = jQuery( this ).closest( 'li' ).attr( 'id' ).replace( 'customize-control-', '' );
var parent = jQuery( this ).closest( '.generatepress-font-variant' );
var font_val = api.control( this_control ).settings['family'].get();
if ( font_val == control.settings['family'].get() && _this.attr( 'name' ) !== jQuery( value ).attr( 'name' ) ) {
jQuery( parent.find( 'select' ) ).not( _this ).val( variants ).triggerHandler( 'change' );
api.control( this_control ).settings['variant'].set( variants );
}
} );
}
);
control.container.on( 'change', '.generatepress-font-category input',
function() {
control.settings['category'].set( jQuery( this ).val() );
}
);
control.container.on( 'change', '.generatepress-font-weight select',
function() {
control.settings['weight'].set( jQuery( this ).val() );
}
);
control.container.on( 'change', '.generatepress-font-transform select',
function() {
control.settings['transform'].set( jQuery( this ).val() );
}
);
}
} );
} )( wp.customize );
jQuery( document ).ready( function( $ ) {
$( '.generatepress-font-family select' ).select2();
$( '.generatepress-font-variant' ).each( function( key, value ) {
var _this = $( this );
var value = _this.data( 'saved-value' );
if ( value ) {
value = value.toString().split( ',' );
}
_this.find( 'select' ).select2().val( value ).trigger( 'change.select2' );
} );
$( ".generatepress-font-family" ).each( function( key, value ) {
var _this = $( this );
if ( $.inArray( _this.find( 'select' ).val(), typography_defaults ) !== -1 ) {
_this.next( '.generatepress-font-variant' ).hide();
}
} );
} );

View File

@ -0,0 +1,12 @@
( function( $, api ) {
api.sectionConstructor['gp-upsell-section'] = api.Section.extend( {
// No events for this type of section.
attachEvents: function () {},
// Always make the section active.
isContextuallyActive: function () {
return true;
}
} );
} )( jQuery, wp.customize );

View File

@ -0,0 +1,23 @@
<?php
/**
* Load necessary Customizer controls and functions.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// Controls
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-range-control.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-typography-control.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-upsell-section.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-upsell-control.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-deprecated.php';
// Helper functions
require_once trailingslashit( dirname( __FILE__ ) ) . 'helpers.php';
// Deprecated
require_once trailingslashit( dirname( __FILE__ ) ) . 'deprecated.php';

View File

@ -0,0 +1,111 @@
<?php
/**
* Where old Customizer functions retire.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! function_exists( 'generate_sanitize_typography' ) ) {
/**
* Sanitize typography dropdown.
*
* @since 1.1.10
* @deprecated 1.3.45
*/
function generate_sanitize_typography( $input ) {
// Grab all of our fonts
$fonts = generate_get_all_google_fonts();
// Loop through all of them and grab their names
$font_names = array();
foreach ( $fonts as $k => $fam ) {
$font_names[] = $fam['name'];
}
// Get all non-Google font names
$not_google = generate_typography_default_fonts();
// Merge them both into one array
$valid = array_merge( $font_names, $not_google );
// Sanitize
if ( in_array( $input, $valid ) ) {
return $input;
} else {
return 'Open Sans';
}
}
}
if ( ! function_exists( 'generate_sanitize_font_weight' ) ) {
/**
* Sanitize font weight.
*
* @since 1.1.10
* @deprecated 1.3.40
*/
function generate_sanitize_font_weight( $input ) {
$valid = array(
'normal',
'bold',
'100',
'200',
'300',
'400',
'500',
'600',
'700',
'800',
'900',
);
if ( in_array( $input, $valid ) ) {
return $input;
} else {
return 'normal';
}
}
}
if ( ! function_exists( 'generate_sanitize_text_transform' ) ) {
/**
* Sanitize text transform.
*
* @since 1.1.10
* @deprecated 1.3.40
*/
function generate_sanitize_text_transform( $input ) {
$valid = array(
'none',
'capitalize',
'uppercase',
'lowercase',
);
if ( in_array( $input, $valid ) ) {
return $input;
} else {
return 'none';
}
}
}
if ( ! function_exists( 'generate_typography_customize_preview_css' ) ) {
/**
* Hide the hidden input control
* @since 1.3.40
*/
function generate_typography_customize_preview_css() {
?>
<style>
.customize-control-gp-hidden-input {display:none !important;}
</style>
<?php
}
}

View File

@ -0,0 +1,330 @@
<?php
/**
* Helper functions for the Customizer.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! function_exists( 'generate_is_posts_page' ) ) {
/**
* Check to see if we're on a posts page
*
* @since 1.3.39
*/
function generate_is_posts_page() {
return ( is_home() || is_archive() || is_tax() ) ? true : false;
}
}
if ( ! function_exists( 'generate_is_footer_bar_active' ) ) {
/**
* Check to see if we're using our footer bar widget
*
* @since 1.3.42
*/
function generate_is_footer_bar_active() {
return ( is_active_sidebar( 'footer-bar' ) ) ? true : false;
}
}
if ( ! function_exists( 'generate_is_top_bar_active' ) ) {
/**
* Check to see if the top bar is active
*
* @since 1.3.45
*/
function generate_is_top_bar_active() {
$top_bar = is_active_sidebar( 'top-bar' ) ? true : false;
return apply_filters( 'generate_is_top_bar_active', $top_bar );
}
}
if ( ! function_exists( 'generate_hidden_navigation' ) && function_exists( 'is_customize_preview' ) ) {
add_action( 'wp_footer', 'generate_hidden_navigation' );
/**
* Adds a hidden navigation if no navigation is set
* This allows us to use postMessage to position the navigation when it doesn't exist
*
* @since 1.3.40
*/
function generate_hidden_navigation() {
if ( is_customize_preview() && function_exists( 'generate_navigation_position' ) ) {
?>
<div style="display:none;">
<?php generate_navigation_position(); ?>
</div>
<?php
}
}
}
if ( ! function_exists( 'generate_customize_partial_blogname' ) ) {
/**
* Render the site title for the selective refresh partial.
*
* @since 1.3.41
*/
function generate_customize_partial_blogname() {
bloginfo( 'name' );
}
}
if ( ! function_exists( 'generate_customize_partial_blogdescription' ) ) {
/**
* Render the site tagline for the selective refresh partial.
*
* @since 1.3.41
*/
function generate_customize_partial_blogdescription() {
bloginfo( 'description' );
}
}
if ( ! function_exists( 'generate_enqueue_color_palettes' ) ) {
add_action( 'customize_controls_enqueue_scripts', 'generate_enqueue_color_palettes' );
/**
* Add our custom color palettes to the color pickers in the Customizer.
*
* @since 1.3.42
*/
function generate_enqueue_color_palettes() {
// Old versions of WP don't get nice things
if ( ! function_exists( 'wp_add_inline_script' ) ) {
return;
}
// Grab our palette array and turn it into JS
$palettes = json_encode( generate_get_default_color_palettes() );
// Add our custom palettes
// json_encode takes care of escaping
wp_add_inline_script( 'wp-color-picker', 'jQuery.wp.wpColorPicker.prototype.options.palettes = ' . $palettes . ';' );
}
}
if ( ! function_exists( 'generate_sanitize_integer' ) ) {
/**
* Sanitize integers.
*
* @since 1.0.8
*/
function generate_sanitize_integer( $input ) {
return absint( $input );
}
}
if ( ! function_exists( 'generate_sanitize_decimal_integer' ) ) {
/**
* Sanitize integers that can use decimals.
*
* @since 1.3.41
*/
function generate_sanitize_decimal_integer( $input ) {
return abs( floatval( $input ) );
}
}
/**
* Sanitize a positive number, but allow an empty value.
*
* @since 2.2
*/
function generate_sanitize_empty_absint( $input ) {
if ( '' == $input ) {
return '';
}
return absint( $input );
}
if ( ! function_exists( 'generate_sanitize_checkbox' ) ) {
/**
* Sanitize checkbox values.
*
* @since 1.0.8
*/
function generate_sanitize_checkbox( $checked ) {
return ( ( isset( $checked ) && true == $checked ) ? true : false );
}
}
if ( ! function_exists( 'generate_sanitize_blog_excerpt' ) ) {
/**
* Sanitize blog excerpt.
* Needed because GP Premium calls the control ID which is different from the settings ID.
*
* @since 1.0.8
*/
function generate_sanitize_blog_excerpt( $input ) {
$valid = array(
'full',
'excerpt'
);
if ( in_array( $input, $valid ) ) {
return $input;
} else {
return 'full';
}
}
}
if ( ! function_exists( 'generate_sanitize_hex_color' ) ) {
/**
* Sanitize colors.
* Allow blank value.
*
* @since 1.2.9.6
*/
function generate_sanitize_hex_color( $color ) {
if ( '' === $color ) {
return '';
}
// 3 or 6 hex digits, or the empty string.
if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
return $color;
}
return '';
}
}
/**
* Sanitize RGBA colors.
*
* @since 2.2
*/
function generate_sanitize_rgba_color( $color ) {
if ( '' === $color ) {
return '';
}
if ( false === strpos( $color, 'rgba' ) ) {
return generate_sanitize_hex_color( $color );
}
$color = str_replace( ' ', '', $color );
sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
return 'rgba('.$red.','.$green.','.$blue.','.$alpha.')';
}
if ( ! function_exists( 'generate_sanitize_choices' ) ) {
/**
* Sanitize choices.
*
* @since 1.3.24
*/
function generate_sanitize_choices( $input, $setting ) {
// Ensure input is a slug
$input = sanitize_key( $input );
// Get list of choices from the control
// associated with the setting
$choices = $setting->manager->get_control( $setting->id )->choices;
// If the input is a valid key, return it;
// otherwise, return the default
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
}
}
/**
* Sanitize our Google Font variants
*
* @since 2.0
*/
function generate_sanitize_variants( $input ) {
if ( is_array( $input ) ) {
$input = implode( ',', $input );
}
return sanitize_text_field( $input );
}
add_action( 'customize_controls_enqueue_scripts', 'generate_do_control_inline_scripts', 100 );
/**
* Add misc inline scripts to our controls.
*
* We don't want to add these to the controls themselves, as they will be repeated
* each time the control is initialized.
*
* @since 2.0
*/
function generate_do_control_inline_scripts() {
wp_localize_script( 'generatepress-typography-customizer', 'gp_customize',
array(
'nonce' => wp_create_nonce( 'gp_customize_nonce' )
)
);
$number_of_fonts = apply_filters( 'generate_number_of_fonts', 200 );
wp_localize_script(
'generatepress-typography-customizer',
'generatePressTypography',
array(
'googleFonts' => apply_filters( 'generate_typography_customize_list', generate_get_all_google_fonts( $number_of_fonts ) )
)
);
wp_localize_script( 'generatepress-typography-customizer', 'typography_defaults', generate_typography_default_fonts() );
wp_enqueue_script( 'generatepress-customizer-controls', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/customizer-controls.js', array( 'customize-controls', 'jquery' ), GENERATE_VERSION, true );
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_defaults', generate_get_defaults() );
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_color_defaults', generate_get_color_defaults() );
}
if ( ! function_exists( 'generate_customizer_live_preview' ) ) {
add_action( 'customize_preview_init', 'generate_customizer_live_preview', 100 );
/**
* Add our live preview scripts
*
* @since 0.1
*/
function generate_customizer_live_preview() {
$spacing_settings = wp_parse_args(
get_option( 'generate_spacing_settings', array() ),
generate_spacing_get_defaults()
);
wp_enqueue_script( 'generate-themecustomizer', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/customizer-live-preview.js', array( 'customize-preview' ), GENERATE_VERSION, true );
wp_localize_script( 'generate-themecustomizer', 'generatepress_live_preview', array(
'mobile' => generate_get_media_query( 'mobile' ),
'tablet' => generate_get_media_query( 'tablet' ),
'desktop' => generate_get_media_query( 'desktop' ),
'contentLeft' => absint( $spacing_settings['content_left'] ),
'contentRight' => absint( $spacing_settings['content_right'] ),
) );
}
}
/**
* Check to see if we have a logo or not.
*
* Used as an active callback. Calling has_custom_logo creates a PHP notice for
* multisite users.
*
* @since 2.0.1
*/
function generate_has_custom_logo_callback() {
if ( get_theme_mod( 'custom_logo' ) ) {
return true;
}
return false;
}
/**
* Save our preset layout controls. These should always save to be "current".
*
* @since 2.2
*/
function generate_sanitize_preset_layout( $input ) {
return 'current';
}

View File

@ -0,0 +1,367 @@
<?php
/**
* Builds our admin page.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! function_exists( 'generate_create_menu' ) ) {
add_action( 'admin_menu', 'generate_create_menu' );
/**
* Adds our "GeneratePress" dashboard menu item
*
* @since 0.1
*/
function generate_create_menu() {
$generate_page = add_theme_page( 'GeneratePress', 'GeneratePress', apply_filters( 'generate_dashboard_page_capability', 'edit_theme_options' ), 'generate-options', 'generate_settings_page' );
add_action( "admin_print_styles-$generate_page", 'generate_options_styles' );
}
}
if ( ! function_exists( 'generate_options_styles' ) ) {
/**
* Adds any necessary scripts to the GP dashboard page
*
* @since 0.1
*/
function generate_options_styles() {
wp_enqueue_style( 'generate-options', get_template_directory_uri() . '/css/admin/style.css', array(), GENERATE_VERSION );
}
}
if ( ! function_exists( 'generate_settings_page' ) ) {
/**
* Builds the content of our GP dashboard page
*
* @since 0.1
*/
function generate_settings_page() {
?>
<div class="wrap">
<div class="metabox-holder">
<div class="gp-masthead clearfix">
<div class="gp-container">
<div class="gp-title">
<a href="<?php echo generate_get_premium_url( 'https://generatepress.com' ); // WPCS: XSS ok, sanitization ok. ?>" target="_blank">GeneratePress</a> <span class="gp-version"><?php echo GENERATE_VERSION; // WPCS: XSS ok ?></span>
</div>
<div class="gp-masthead-links">
<?php if ( ! defined( 'GP_PREMIUM_VERSION' ) ) : ?>
<a style="font-weight: bold;" href="<?php echo generate_get_premium_url( 'https://generatepress.com/premium/' ); // WPCS: XSS ok, sanitization ok. ?>" target="_blank"><?php esc_html_e( 'Premium', 'generatepress' );?></a>
<?php endif; ?>
<a href="<?php echo esc_url( 'https://generatepress.com/support' ); ?>" target="_blank"><?php esc_html_e( 'Support', 'generatepress' ); ?></a>
<a href="<?php echo esc_url( 'https://docs.generatepress.com' ); ?>" target="_blank"><?php esc_html_e( 'Documentation', 'generatepress' );?></a>
</div>
</div>
</div>
<?php
/**
* generate_dashboard_after_header hook.
*
* @since 2.0
*/
do_action( 'generate_dashboard_after_header' );
?>
<div class="gp-container">
<div class="postbox-container clearfix" style="float: none;">
<div class="grid-container grid-parent">
<?php
/**
* generate_dashboard_inside_container hook.
*
* @since 2.0
*/
do_action( 'generate_dashboard_inside_container' );
?>
<div class="form-metabox grid-70" style="padding-left: 0;">
<h2 style="height:0;margin:0;"><!-- admin notices below this element --></h2>
<form method="post" action="options.php">
<?php settings_fields( 'generate-settings-group' ); ?>
<?php do_settings_sections( 'generate-settings-group' ); ?>
<div class="customize-button hide-on-desktop">
<?php
printf( '<a id="generate_customize_button" class="button button-primary" href="%1$s">%2$s</a>',
esc_url( admin_url( 'customize.php' ) ),
esc_html__( 'Customize', 'generatepress' )
);
?>
</div>
<?php
/**
* generate_inside_options_form hook.
*
* @since 0.1
*/
do_action( 'generate_inside_options_form' );
?>
</form>
<?php
$modules = array(
'Backgrounds' => array(
'url' => generate_get_premium_url( 'https://generatepress.com/premium/#backgrounds', false ),
),
'Blog' => array(
'url' => generate_get_premium_url( 'https://generatepress.com/premium/#blog', false ),
),
'Colors' => array(
'url' => generate_get_premium_url( 'https://generatepress.com/premium/#colors', false ),
),
'Copyright' => array(
'url' => generate_get_premium_url( 'https://generatepress.com/premium/#copyright', false ),
),
'Disable Elements' => array(
'url' => generate_get_premium_url( 'https://generatepress.com/premium/#disable-elements', false ),
),
'Elements' => array(
'url' => generate_get_premium_url( 'https://generatepress.com/premium/#elements', false ),
),
'Import / Export' => array(
'url' => generate_get_premium_url( 'https://generatepress.com/premium/#import-export', false ),
),
'Menu Plus' => array(
'url' => generate_get_premium_url( 'https://generatepress.com/premium/#menu-plus', false ),
),
'Secondary Nav' => array(
'url' => generate_get_premium_url( 'https://generatepress.com/premium/#secondary-nav', false ),
),
'Sections' => array(
'url' => generate_get_premium_url( 'https://generatepress.com/premium/#sections', false ),
),
'Site Library' => array(
'url' => generate_get_premium_url( 'https://generatepress.com/site-library', false ),
),
'Spacing' => array(
'url' => generate_get_premium_url( 'https://generatepress.com/premium/#spacing', false ),
),
'Typography' => array(
'url' => generate_get_premium_url( 'https://generatepress.com/premium/#typography', false ),
),
'WooCommerce' => array(
'url' => generate_get_premium_url( 'https://generatepress.com/premium/#woocommerce', false ),
),
);
if ( ! defined( 'GP_PREMIUM_VERSION' ) ) : ?>
<div class="postbox generate-metabox">
<h3 class="hndle"><?php esc_html_e( 'Premium Modules', 'generatepress' ); ?></h3>
<div class="inside" style="margin:0;padding:0;">
<div class="premium-addons">
<?php foreach( $modules as $module => $info ) { ?>
<div class="add-on activated gp-clear addon-container grid-parent">
<div class="addon-name column-addon-name" style="">
<a href="<?php echo esc_url( $info['url'] ); ?>" target="_blank"><?php echo esc_html( $module ); ?></a>
</div>
<div class="addon-action addon-addon-action" style="text-align:right;">
<a href="<?php echo esc_url( $info['url'] ); ?>" target="_blank"><?php esc_html_e( 'Learn more', 'generatepress' ); ?></a>
</div>
</div>
<div class="gp-clear"></div>
<?php } ?>
</div>
</div>
</div>
<?php
endif;
/**
* generate_options_items hook.
*
* @since 0.1
*/
do_action( 'generate_options_items' );
$typography_section = 'customize.php?autofocus[section]=font_section';
$colors_section = 'customize.php?autofocus[section]=body_section';
if ( function_exists( 'generatepress_is_module_active' ) ) {
if ( generatepress_is_module_active( 'generate_package_typography', 'GENERATE_TYPOGRAPHY' ) ) {
$typography_section = 'customize.php?autofocus[panel]=generate_typography_panel';
}
if ( generatepress_is_module_active( 'generate_package_colors', 'GENERATE_COLORS' ) ) {
$colors_section = 'customize.php?autofocus[panel]=generate_colors_panel';
}
}
$quick_settings = array(
'logo' => array(
'title' => __( 'Upload Logo', 'generatepress' ),
'icon' => 'dashicons-format-image',
'url' => admin_url( 'customize.php?autofocus[control]=custom_logo' ),
),
'typography' => array(
'title' => __( 'Customize Fonts', 'generatepress' ),
'icon' => 'dashicons-editor-textcolor',
'url' => admin_url( $typography_section ),
),
'colors' => array(
'title' => __( 'Customize Colors', 'generatepress' ),
'icon' => 'dashicons-admin-customizer',
'url' => admin_url( $colors_section ),
),
'layout' => array(
'title' => __( 'Layout Options', 'generatepress' ),
'icon' => 'dashicons-layout',
'url' => admin_url( 'customize.php?autofocus[panel]=generate_layout_panel' ),
),
'all' => array(
'title' => __( 'All Options', 'generatepress' ),
'icon' => 'dashicons-admin-generic',
'url' => admin_url( 'customize.php' ),
),
);
?>
</div>
<div class="generate-right-sidebar grid-30" style="padding-right: 0;">
<div class="postbox generate-metabox start-customizing">
<h3 class="hndle"><?php esc_html_e( 'Start Customizing', 'generatepress' ); ?></h3>
<div class="inside">
<ul>
<?php
foreach ( $quick_settings as $key => $data ) {
printf(
'<li><span class="dashicons %1$s"></span> <a href="%2$s">%3$s</a></li>',
esc_attr( $data['icon'] ),
esc_url( $data['url'] ),
esc_html( $data['title'] )
);
}
?>
</ul>
<p><?php esc_html_e( 'Want to learn more about the theme? Check out our extensive documentation.', 'generatepress' ); ?></p>
<a href="https://docs.generatepress.com"><?php esc_html_e( 'Visit documentation &rarr;', 'generatepress' ); ?></a>
</div>
</div>
<?php
/**
* generate_admin_right_panel hook.
*
* @since 0.1
*/
do_action( 'generate_admin_right_panel' );
?>
<div class="postbox generate-metabox" id="gen-delete">
<h3 class="hndle"><?php esc_html_e( 'Reset Settings', 'generatepress' );?></h3>
<div class="inside">
<p><?php esc_html_e( 'Deleting your settings can not be undone.', 'generatepress' ); ?></p>
<form method="post">
<p><input type="hidden" name="generate_reset_customizer" value="generate_reset_customizer_settings" /></p>
<p>
<?php
$warning = 'return confirm("' . esc_html__( 'Warning: This will delete your settings.', 'generatepress' ) . '")';
wp_nonce_field( 'generate_reset_customizer_nonce', 'generate_reset_customizer_nonce' );
submit_button( esc_attr__( 'Reset', 'generatepress' ), 'button-primary', 'submit', false,
array(
'onclick' => esc_js( $warning )
)
);
?>
</p>
</form>
<?php
/**
* generate_delete_settings_form hook.
*
* @since 0.1
*/
do_action( 'generate_delete_settings_form' );
?>
</div>
</div>
</div>
</div>
</div>
<div class="gp-options-footer">
<span>
<?php
printf( // WPCS: XSS ok
/* translators: %s: Heart icon */
_x( 'Made with %s by Tom Usborne', 'made with love', 'generatepress' ),
'<span style="color:#D04848" class="dashicons dashicons-heart"></span>'
);
?>
</span>
</div>
</div>
</div>
</div>
<?php
}
}
if ( ! function_exists( 'generate_reset_customizer_settings' ) ) {
add_action( 'admin_init', 'generate_reset_customizer_settings' );
/**
* Reset customizer settings
*
* @since 0.1
*/
function generate_reset_customizer_settings() {
if ( empty( $_POST['generate_reset_customizer'] ) || 'generate_reset_customizer_settings' !== $_POST['generate_reset_customizer'] ) {
return;
}
$nonce = isset( $_POST['generate_reset_customizer_nonce'] ) ? sanitize_key( $_POST['generate_reset_customizer_nonce'] ) : '';
if ( ! wp_verify_nonce( $nonce, 'generate_reset_customizer_nonce' ) ) {
return;
}
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
delete_option( 'generate_settings' );
delete_option( 'generate_dynamic_css_output' );
delete_option( 'generate_dynamic_css_cached_version' );
remove_theme_mod( 'font_body_variants' );
remove_theme_mod( 'font_body_category' );
wp_safe_redirect( admin_url( 'themes.php?page=generate-options&status=reset' ) );
exit;
}
}
if ( ! function_exists( 'generate_admin_errors' ) ) {
add_action( 'admin_notices', 'generate_admin_errors' );
/**
* Add our admin notices
*
* @since 0.1
*/
function generate_admin_errors() {
$screen = get_current_screen();
if ( 'appearance_page_generate-options' !== $screen->base ) {
return;
}
if ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] ) {
add_settings_error( 'generate-notices', 'true', esc_html__( 'Settings saved.', 'generatepress' ), 'updated' );
}
if ( isset( $_GET['status'] ) && 'imported' == $_GET['status'] ) {
add_settings_error( 'generate-notices', 'imported', esc_html__( 'Import successful.', 'generatepress' ), 'updated' );
}
if ( isset( $_GET['status'] ) && 'reset' == $_GET['status'] ) {
add_settings_error( 'generate-notices', 'reset', esc_html__( 'Settings removed.', 'generatepress' ), 'updated' );
}
settings_errors( 'generate-notices' );
}
}

View File

@ -0,0 +1,354 @@
<?php
/**
* Sets all of our theme defaults.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! function_exists( 'generate_get_defaults' ) ) {
/**
* Set default options
*
* @since 0.1
*/
function generate_get_defaults() {
return apply_filters( 'generate_option_defaults',
array(
'hide_title' => '',
'hide_tagline' => '',
'logo' => '',
'inline_logo_site_branding' => false,
'retina_logo' => '',
'logo_width' => '',
'top_bar_width' => 'full',
'top_bar_inner_width' => 'contained',
'top_bar_alignment' => 'right',
'container_width' => '1100',
'container_alignment' => 'boxes',
'header_layout_setting' => 'fluid-header',
'header_inner_width' => 'contained',
'nav_alignment_setting' => ( is_rtl() ) ? 'right' : 'left',
'header_alignment_setting' => ( is_rtl() ) ? 'right' : 'left',
'nav_layout_setting' => 'fluid-nav',
'nav_inner_width' => 'contained',
'nav_position_setting' => 'nav-below-header',
'nav_drop_point' => '',
'nav_dropdown_type' => 'hover',
'nav_dropdown_direction' => 'right',
'nav_search' => 'disable',
'content_layout_setting' => 'separate-containers',
'layout_setting' => 'right-sidebar',
'blog_layout_setting' => 'right-sidebar',
'single_layout_setting' => 'right-sidebar',
'post_content' => 'excerpt',
'footer_layout_setting' => 'fluid-footer',
'footer_inner_width' => 'contained',
'footer_widget_setting' => '3',
'footer_bar_alignment' => 'right',
'back_to_top' => '',
'background_color' => '#efefef',
'text_color' => '#3a3a3a',
'link_color' => '#1e73be',
'link_color_hover' => '#000000',
'link_color_visited' => '',
'font_awesome_essentials' => true,
'icons' => 'font',
'combine_css' => true,
'dynamic_css_cache' => true,
)
);
}
}
if ( ! function_exists( 'generate_get_color_defaults' ) ) {
/**
* Set default options
*/
function generate_get_color_defaults() {
return apply_filters( 'generate_color_option_defaults',
array(
'top_bar_background_color' => '#636363',
'top_bar_text_color' => '#ffffff',
'top_bar_link_color' => '#ffffff',
'top_bar_link_color_hover' => '#303030',
'header_background_color' => '#ffffff',
'header_text_color' => '#3a3a3a',
'header_link_color' => '#3a3a3a',
'header_link_hover_color' => '',
'site_title_color' => '#222222',
'site_tagline_color' => '#757575',
'navigation_background_color' => '#222222',
'navigation_text_color' => '#ffffff',
'navigation_background_hover_color' => '#3f3f3f',
'navigation_text_hover_color' => '#ffffff',
'navigation_background_current_color' => '#3f3f3f',
'navigation_text_current_color' => '#ffffff',
'subnavigation_background_color' => '#3f3f3f',
'subnavigation_text_color' => '#ffffff',
'subnavigation_background_hover_color' => '#4f4f4f',
'subnavigation_text_hover_color' => '#ffffff',
'subnavigation_background_current_color' => '#4f4f4f',
'subnavigation_text_current_color' => '#ffffff',
'navigation_search_background_color' => '',
'navigation_search_text_color' => '',
'content_background_color' => '#ffffff',
'content_text_color' => '',
'content_link_color' => '',
'content_link_hover_color' => '',
'content_title_color' => '',
'blog_post_title_color' => '',
'blog_post_title_hover_color' => '',
'entry_meta_text_color' => '#595959',
'entry_meta_link_color' => '#595959',
'entry_meta_link_color_hover' => '#1e73be',
'h1_color' => '',
'h2_color' => '',
'h3_color' => '',
'h4_color' => '',
'h5_color' => '',
'h6_color' => '',
'sidebar_widget_background_color' => '#ffffff',
'sidebar_widget_text_color' => '',
'sidebar_widget_link_color' => '',
'sidebar_widget_link_hover_color' => '',
'sidebar_widget_title_color' => '#000000',
'footer_widget_background_color' => '#ffffff',
'footer_widget_text_color' => '',
'footer_widget_link_color' => '',
'footer_widget_link_hover_color' => '',
'footer_widget_title_color' => '#000000',
'footer_background_color' => '#222222',
'footer_text_color' => '#ffffff',
'footer_link_color' => '#ffffff',
'footer_link_hover_color' => '#606060',
'form_background_color' => '#fafafa',
'form_text_color' => '#666666',
'form_background_color_focus' => '#ffffff',
'form_text_color_focus' => '#666666',
'form_border_color' => '#cccccc',
'form_border_color_focus' => '#bfbfbf',
'form_button_background_color' => '#666666',
'form_button_background_color_hover' => '#3f3f3f',
'form_button_text_color' => '#ffffff',
'form_button_text_color_hover' => '#ffffff',
'back_to_top_background_color' => 'rgba( 0,0,0,0.4 )',
'back_to_top_background_color_hover' => 'rgba( 0,0,0,0.6 )',
'back_to_top_text_color' => '#ffffff',
'back_to_top_text_color_hover' => '#ffffff',
)
);
}
}
if ( ! function_exists( 'generate_get_default_fonts' ) ) {
/**
* Set default options.
*
* @since 0.1
*
* @param bool $filter Whether to return the filtered values or original values.
* @return array Option defaults.
*/
function generate_get_default_fonts( $filter = true ) {
$defaults = array(
'font_body' => 'System Stack',
'font_body_category' => '',
'font_body_variants' => '',
'body_font_weight' => 'normal',
'body_font_transform' => 'none',
'body_font_size' => '17',
'body_line_height' => '1.5', // no unit
'paragraph_margin' => '1.5', // em
'font_top_bar' => 'inherit',
'font_top_bar_category' => '',
'font_top_bar_variants' => '',
'top_bar_font_weight' => 'normal',
'top_bar_font_transform' => 'none',
'top_bar_font_size' => '13',
'font_site_title' => 'inherit',
'font_site_title_category' => '',
'font_site_title_variants' => '',
'site_title_font_weight' => 'bold',
'site_title_font_transform' => 'none',
'site_title_font_size' => '45',
'mobile_site_title_font_size' => '30',
'font_site_tagline' => 'inherit',
'font_site_tagline_category' => '',
'font_site_tagline_variants' => '',
'site_tagline_font_weight' => 'normal',
'site_tagline_font_transform' => 'none',
'site_tagline_font_size' => '15',
'font_navigation' => 'inherit',
'font_navigation_category' => '',
'font_navigation_variants' => '',
'navigation_font_weight' => 'normal',
'navigation_font_transform' => 'none',
'navigation_font_size' => '15',
'font_widget_title' => 'inherit',
'font_widget_title_category' => '',
'font_widget_title_variants' => '',
'widget_title_font_weight' => 'normal',
'widget_title_font_transform' => 'none',
'widget_title_font_size' => '20',
'widget_title_separator' => '30',
'widget_content_font_size' => '17',
'font_buttons' => 'inherit',
'font_buttons_category' => '',
'font_buttons_variants' => '',
'buttons_font_weight' => 'normal',
'buttons_font_transform' => 'none',
'buttons_font_size' => '',
'font_heading_1' => 'inherit',
'font_heading_1_category' => '',
'font_heading_1_variants' => '',
'heading_1_weight' => '300',
'heading_1_transform' => 'none',
'heading_1_font_size' => '40',
'heading_1_line_height' => '1.2', // em
'heading_1_margin_bottom' => '20',
'mobile_heading_1_font_size' => '30',
'font_heading_2' => 'inherit',
'font_heading_2_category' => '',
'font_heading_2_variants' => '',
'heading_2_weight' => '300',
'heading_2_transform' => 'none',
'heading_2_font_size' => '30',
'heading_2_line_height' => '1.2', // em
'heading_2_margin_bottom' => '20',
'mobile_heading_2_font_size' => '25',
'font_heading_3' => 'inherit',
'font_heading_3_category' => '',
'font_heading_3_variants' => '',
'heading_3_weight' => 'normal',
'heading_3_transform' => 'none',
'heading_3_font_size' => '20',
'heading_3_line_height' => '1.2', // em
'heading_3_margin_bottom' => '20',
'font_heading_4' => 'inherit',
'font_heading_4_category' => '',
'font_heading_4_variants' => '',
'heading_4_weight' => 'normal',
'heading_4_transform' => 'none',
'heading_4_font_size' => '',
'heading_4_line_height' => '', // em
'font_heading_5' => 'inherit',
'font_heading_5_category' => '',
'font_heading_5_variants' => '',
'heading_5_weight' => 'normal',
'heading_5_transform' => 'none',
'heading_5_font_size' => '',
'heading_5_line_height' => '', // em
'font_heading_6' => 'inherit',
'font_heading_6_category' => '',
'font_heading_6_variants' => '',
'heading_6_weight' => 'normal',
'heading_6_transform' => 'none',
'heading_6_font_size' => '',
'heading_6_line_height' => '', // em
'font_footer' => 'inherit',
'font_footer_category' => '',
'font_footer_variants' => '',
'footer_weight' => 'normal',
'footer_transform' => 'none',
'footer_font_size' => '15',
);
if ( $filter ) {
return apply_filters( 'generate_font_option_defaults', $defaults );
}
return $defaults;
}
}
if ( ! function_exists( 'generate_spacing_get_defaults' ) ) {
/**
* Set the default options.
*
* @since 0.1
*
* @param bool $filter Whether to return the filtered values or original values.
* @return array Option defaults.
*/
function generate_spacing_get_defaults( $filter = true ) {
$defaults = array(
'top_bar_top' => '10',
'top_bar_right' => '10',
'top_bar_bottom' => '10',
'top_bar_left' => '10',
'header_top' => '40',
'header_right' => '40',
'header_bottom' => '40',
'header_left' => '40',
'menu_item' => '20',
'menu_item_height' => '60',
'sub_menu_item_height' => '10',
'sub_menu_width' => '200',
'content_top' => '40',
'content_right' => '40',
'content_bottom' => '40',
'content_left' => '40',
'mobile_content_top' => '30',
'mobile_content_right' => '30',
'mobile_content_bottom' => '30',
'mobile_content_left' => '30',
'separator' => '20',
'mobile_separator' => '',
'left_sidebar_width' => '25',
'right_sidebar_width' => '25',
'widget_top' => '40',
'widget_right' => '40',
'widget_bottom' => '40',
'widget_left' => '40',
'footer_widget_container_top' => '40',
'footer_widget_container_right' => '40',
'footer_widget_container_bottom' => '40',
'footer_widget_container_left' => '40',
'footer_widget_separator' => '40',
'footer_top' => '20',
'footer_right' => '20',
'footer_bottom' => '20',
'footer_left' => '20',
);
if ( $filter ) {
return apply_filters( 'generate_spacing_option_defaults', $defaults );
}
return $defaults;
}
}
if ( ! function_exists( 'generate_typography_default_fonts' ) ) {
/**
* Set the default system fonts.
*
* @since 1.3.40
*/
function generate_typography_default_fonts() {
$fonts = array(
'inherit',
'System Stack',
'Arial, Helvetica, sans-serif',
'Century Gothic',
'Comic Sans MS',
'Courier New',
'Georgia, Times New Roman, Times, serif',
'Helvetica',
'Impact',
'Lucida Console',
'Lucida Sans Unicode',
'Palatino Linotype',
'Segoe UI, Helvetica Neue, Helvetica, sans-serif',
'Tahoma, Geneva, sans-serif',
'Trebuchet MS, Helvetica, sans-serif',
'Verdana, Geneva, sans-serif',
);
return apply_filters( 'generate_typography_default_fonts', $fonts );
}
}

View File

@ -0,0 +1,712 @@
<?php
/**
* Where old functions retire.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// Deprecated constants
define( 'GENERATE_URI', get_template_directory_uri() );
define( 'GENERATE_DIR', get_template_directory() );
if ( ! function_exists( 'generate_paging_nav' ) ) {
/**
* Build the pagination links
* @since 1.3.35
* @deprecated 1.3.45
*/
function generate_paging_nav() {
_deprecated_function( __FUNCTION__, '1.3.45', 'the_posts_navigation()' );
if ( function_exists( 'the_posts_pagination' ) ) {
the_posts_pagination( array(
'mid_size' => apply_filters( 'generate_pagination_mid_size', 1 ),
'prev_text' => __( '&larr; Previous', 'generatepress' ),
'next_text' => __( 'Next &rarr;', 'generatepress' )
) );
}
}
}
if ( ! function_exists( 'generate_additional_spacing' ) ) {
/**
* Add fallback CSS for our mobile search icon color
* @deprecated 1.3.47
*/
function generate_additional_spacing() {
// No longer needed
}
}
if ( ! function_exists( 'generate_mobile_search_spacing_fallback_css' ) ) {
/**
* Enqueue our mobile search icon color fallback CSS
* @deprecated 1.3.47
*/
function generate_mobile_search_spacing_fallback_css() {
// No longer needed
}
}
if ( ! function_exists( 'generate_addons_available' ) ) {
/**
* Check to see if there's any addons not already activated
* @since 1.0.9
* @deprecated 1.3.47
*/
function generate_addons_available() {
if ( defined( 'GP_PREMIUM_VERSION' ) ) {
return false;
}
}
}
if ( ! function_exists( 'generate_no_addons' ) ) {
/**
* Check to see if no addons are activated
* @since 1.0.9
* @deprecated 1.3.47
*/
function generate_no_addons() {
if ( defined( 'GP_PREMIUM_VERSION' ) ) {
return false;
}
}
}
if ( ! function_exists( 'generate_get_min_suffix' ) ) {
/**
* Figure out if we should use minified scripts or not
* @since 1.3.29
* @deprecated 2.0
*/
function generate_get_min_suffix() {
return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
}
}
if ( ! function_exists( 'generate_add_layout_meta_box' ) ) {
function generate_add_layout_meta_box() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_register_layout_meta_box()' );
}
}
if ( ! function_exists( 'generate_show_layout_meta_box' ) ) {
function generate_show_layout_meta_box() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_do_layout_meta_box()' );
}
}
if ( ! function_exists( 'generate_save_layout_meta' ) ) {
function generate_save_layout_meta() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_save_layout_meta_data()' );
}
}
if ( ! function_exists( 'generate_add_footer_widget_meta_box' ) ) {
function generate_add_footer_widget_meta_box() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_register_layout_meta_box()' );
}
}
if ( ! function_exists( 'generate_show_footer_widget_meta_box' ) ) {
function generate_show_footer_widget_meta_box() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_do_layout_meta_box()' );
}
}
if ( ! function_exists( 'generate_save_footer_widget_meta' ) ) {
function generate_save_footer_widget_meta() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_save_layout_meta_data()' );
}
}
if ( ! function_exists( 'generate_add_page_builder_meta_box' ) ) {
function generate_add_page_builder_meta_box() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_register_layout_meta_box()' );
}
}
if ( ! function_exists( 'generate_show_page_builder_meta_box' ) ) {
function generate_show_page_builder_meta_box() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_do_layout_meta_box()' );
}
}
if ( ! function_exists( 'generate_save_page_builder_meta' ) ) {
function generate_save_page_builder_meta() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_save_layout_meta_data()' );
}
}
if ( ! function_exists( 'generate_add_de_meta_box' ) ) {
function generate_add_de_meta_box() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_register_layout_meta_box()' );
}
}
if ( ! function_exists( 'generate_show_de_meta_box' ) ) {
function generate_show_de_meta_box() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_do_layout_meta_box()' );
}
}
if ( ! function_exists( 'generate_save_de_meta' ) ) {
function generate_save_de_meta() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_save_layout_meta_data()' );
}
}
if ( ! function_exists( 'generate_add_base_inline_css' ) ) {
function generate_add_base_inline_css() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_enqueue_dynamic_css()' );
}
}
if ( ! function_exists( 'generate_color_scripts' ) ) {
function generate_color_scripts() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_enqueue_dynamic_css()' );
}
}
if ( ! function_exists( 'generate_typography_scripts' ) ) {
function generate_typography_scripts() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_enqueue_dynamic_css()' );
}
}
if ( ! function_exists( 'generate_spacing_scripts' ) ) {
function generate_spacing_scripts() {
_deprecated_function( __FUNCTION__, '2.0', 'generate_enqueue_dynamic_css()' );
}
}
if ( ! function_exists( 'generate_get_setting' ) ) {
/**
* A wrapper function to get our settings.
*
* @since 1.3.40
*
* @param string $option The option name to look up.
* @return string The option value.
* @todo Ability to specify different option name and defaults.
*/
function generate_get_setting( $setting ) {
return generate_get_option( $setting );
}
}
if ( ! function_exists( 'generate_right_sidebar_class' ) ) {
/**
* Display the classes for the sidebar.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
*/
function generate_right_sidebar_class( $class = '' ) {
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join( ' ', generate_get_right_sidebar_class( $class ) ) . '"'; // WPCS: XSS ok, sanitization ok.
}
}
if ( ! function_exists( 'generate_get_right_sidebar_class' ) ) {
/**
* Retrieve the classes for the sidebar.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
* @return array Array of classes.
*/
function generate_get_right_sidebar_class( $class = '' ) {
$classes = array();
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
}
$classes = array_map( 'esc_attr', $classes );
return apply_filters( 'generate_right_sidebar_class', $classes, $class );
}
}
if ( ! function_exists( 'generate_left_sidebar_class' ) ) {
/**
* Display the classes for the sidebar.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
*/
function generate_left_sidebar_class( $class = '' ) {
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join( ' ', generate_get_left_sidebar_class( $class ) ) . '"'; // WPCS: XSS ok, sanitization ok.
}
}
if ( ! function_exists( 'generate_get_left_sidebar_class' ) ) {
/**
* Retrieve the classes for the sidebar.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
* @return array Array of classes.
*/
function generate_get_left_sidebar_class( $class = '' ) {
$classes = array();
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
}
$classes = array_map( 'esc_attr', $classes );
return apply_filters( 'generate_left_sidebar_class', $classes, $class );
}
}
if ( ! function_exists( 'generate_content_class' ) ) {
/**
* Display the classes for the content.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
*/
function generate_content_class( $class = '' ) {
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join( ' ', generate_get_content_class( $class ) ) . '"'; // WPCS: XSS ok, sanitization ok.
}
}
if ( ! function_exists( 'generate_get_content_class' ) ) {
/**
* Retrieve the classes for the content.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
* @return array Array of classes.
*/
function generate_get_content_class( $class = '' ) {
$classes = array();
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
}
$classes = array_map( 'esc_attr', $classes );
return apply_filters( 'generate_content_class', $classes, $class );
}
}
if ( ! function_exists( 'generate_header_class' ) ) {
/**
* Display the classes for the header.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
*/
function generate_header_class( $class = '' ) {
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join( ' ', generate_get_header_class( $class ) ) . '"'; // WPCS: XSS ok, sanitization ok.
}
}
if ( ! function_exists( 'generate_get_header_class' ) ) {
/**
* Retrieve the classes for the content.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
* @return array Array of classes.
*/
function generate_get_header_class( $class = '' ) {
$classes = array();
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
}
$classes = array_map( 'esc_attr', $classes );
return apply_filters( 'generate_header_class', $classes, $class );
}
}
if ( ! function_exists( 'generate_inside_header_class' ) ) {
/**
* Display the classes for inside the header.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
*/
function generate_inside_header_class( $class = '' ) {
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join( ' ', generate_get_inside_header_class( $class ) ) . '"'; // WPCS: XSS ok, sanitization ok.
}
}
if ( ! function_exists( 'generate_get_inside_header_class' ) ) {
/**
* Retrieve the classes for inside the header.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
* @return array Array of classes.
*/
function generate_get_inside_header_class( $class = '' ) {
$classes = array();
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
}
$classes = array_map( 'esc_attr', $classes );
return apply_filters( 'generate_inside_header_class', $classes, $class );
}
}
if ( ! function_exists( 'generate_container_class' ) ) {
/**
* Display the classes for the container.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
*/
function generate_container_class( $class = '' ) {
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join( ' ', generate_get_container_class( $class ) ) . '"'; // WPCS: XSS ok, sanitization ok.
}
}
if ( ! function_exists( 'generate_get_container_class' ) ) {
/**
* Retrieve the classes for the content.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
* @return array Array of classes.
*/
function generate_get_container_class( $class = '' ) {
$classes = array();
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
}
$classes = array_map( 'esc_attr', $classes );
return apply_filters( 'generate_container_class', $classes, $class );
}
}
if ( ! function_exists( 'generate_navigation_class' ) ) {
/**
* Display the classes for the navigation.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
*/
function generate_navigation_class( $class = '' ) {
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join( ' ', generate_get_navigation_class( $class ) ) . '"'; // WPCS: XSS ok, sanitization ok.
}
}
if ( ! function_exists( 'generate_get_navigation_class' ) ) {
/**
* Retrieve the classes for the navigation.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
* @return array Array of classes.
*/
function generate_get_navigation_class( $class = '' ) {
$classes = array();
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
}
$classes = array_map( 'esc_attr', $classes );
return apply_filters( 'generate_navigation_class', $classes, $class );
}
}
if ( ! function_exists( 'generate_inside_navigation_class' ) ) {
/**
* Display the classes for the inner navigation.
*
* @since 1.3.41
* @param string|array $class One or more classes to add to the class list.
*/
function generate_inside_navigation_class( $class = '' ) {
$classes = array();
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
}
$classes = array_map( 'esc_attr', $classes );
$return = apply_filters( 'generate_inside_navigation_class', $classes, $class );
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join( ' ', $return ) . '"'; // WPCS: XSS ok, sanitization ok.
}
}
if ( ! function_exists( 'generate_menu_class' ) ) {
/**
* Display the classes for the navigation.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
*/
function generate_menu_class( $class = '' ) {
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join( ' ', generate_get_menu_class( $class ) ) . '"'; // WPCS: XSS ok, sanitization ok.
}
}
if ( ! function_exists( 'generate_get_menu_class' ) ) {
/**
* Retrieve the classes for the navigation.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
* @return array Array of classes.
*/
function generate_get_menu_class( $class = '' ) {
$classes = array();
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
}
$classes = array_map( 'esc_attr', $classes );
return apply_filters( 'generate_menu_class', $classes, $class );
}
}
if ( ! function_exists( 'generate_main_class' ) ) {
/**
* Display the classes for the <main> container.
*
* @since 1.1.0
* @param string|array $class One or more classes to add to the class list.
*/
function generate_main_class( $class = '' ) {
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join( ' ', generate_get_main_class( $class ) ) . '"'; // WPCS: XSS ok, sanitization ok.
}
}
if ( ! function_exists( 'generate_get_main_class' ) ) {
/**
* Retrieve the classes for the footer.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
* @return array Array of classes.
*/
function generate_get_main_class( $class = '' ) {
$classes = array();
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
}
$classes = array_map( 'esc_attr', $classes );
return apply_filters( 'generate_main_class', $classes, $class );
}
}
if ( ! function_exists( 'generate_footer_class' ) ) {
/**
* Display the classes for the footer.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
*/
function generate_footer_class( $class = '' ) {
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join( ' ', generate_get_footer_class( $class ) ) . '"'; // WPCS: XSS ok, sanitization ok.
}
}
if ( ! function_exists( 'generate_get_footer_class' ) ) {
/**
* Retrieve the classes for the footer.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
* @return array Array of classes.
*/
function generate_get_footer_class( $class = '' ) {
$classes = array();
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
}
$classes = array_map( 'esc_attr', $classes );
return apply_filters( 'generate_footer_class', $classes, $class );
}
}
if ( ! function_exists( 'generate_inside_footer_class' ) ) {
/**
* Display the classes for the footer.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
*/
function generate_inside_footer_class( $class = '' ) {
$classes = array();
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
}
$classes = array_map( 'esc_attr', $classes );
$return = apply_filters( 'generate_inside_footer_class', $classes, $class );
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join( ' ', $return ) . '"'; // WPCS: XSS ok, sanitization ok.
}
}
if ( ! function_exists( 'generate_top_bar_class' ) ) {
/**
* Display the classes for the top bar.
*
* @since 1.3.45
* @param string|array $class One or more classes to add to the class list.
*/
function generate_top_bar_class( $class = '' ) {
$classes = array();
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
}
$classes = array_map( 'esc_attr', $classes );
$return = apply_filters( 'generate_top_bar_class', $classes, $class );
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join( ' ', $return ) . '"'; // WPCS: XSS ok, sanitization ok.
}
}
if ( ! function_exists( 'generate_body_schema' ) ) {
/**
* Figure out which schema tags to apply to the <body> element.
*
* @since 1.3.15
*/
function generate_body_schema() {
// Set up blog variable
$blog = ( is_home() || is_archive() || is_attachment() || is_tax() || is_single() ) ? true : false;
// Set up default itemtype
$itemtype = 'WebPage';
// Get itemtype for the blog
$itemtype = ( $blog ) ? 'Blog' : $itemtype;
// Get itemtype for search results
$itemtype = ( is_search() ) ? 'SearchResultsPage' : $itemtype;
// Get the result
$result = esc_html( apply_filters( 'generate_body_itemtype', $itemtype ) );
// Return our HTML
echo "itemtype='https://schema.org/$result' itemscope='itemscope'"; // WPCS: XSS ok, sanitization ok.
}
}
if ( ! function_exists( 'generate_article_schema' ) ) {
/**
* Figure out which schema tags to apply to the <article> element
* The function determines the itemtype: generate_article_schema( 'BlogPosting' )
* @since 1.3.15
*/
function generate_article_schema( $type = 'CreativeWork' ) {
// Get the itemtype
$itemtype = esc_html( apply_filters( 'generate_article_itemtype', $type ) );
// Print the results
echo "itemtype='https://schema.org/$itemtype' itemscope='itemscope'"; // WPCS: XSS ok, sanitization ok.
}
}

View File

@ -0,0 +1,350 @@
<?php
/**
* General functions.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! function_exists( 'generate_scripts' ) ) {
add_action( 'wp_enqueue_scripts', 'generate_scripts' );
/**
* Enqueue scripts and styles
*/
function generate_scripts() {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
$dir_uri = get_template_directory_uri();
if ( generate_get_option( 'combine_css' ) && $suffix ) {
wp_enqueue_style( 'generate-style', $dir_uri . "/css/all.min.css", array(), GENERATE_VERSION, 'all' );
} else {
$lite = '';
if ( apply_filters( 'generate_unsemantic_grid_lite', false ) ) {
$lite = '-lite';
}
wp_enqueue_style( 'generate-style-grid', $dir_uri . "/css/unsemantic-grid{$lite}{$suffix}.css", false, GENERATE_VERSION, 'all' );
wp_enqueue_style( 'generate-style', $dir_uri . "/style{$suffix}.css", array(), GENERATE_VERSION, 'all' );
wp_enqueue_style( 'generate-mobile-style', $dir_uri . "/css/mobile{$suffix}.css", array( 'generate-style' ), GENERATE_VERSION, 'all' );
}
if ( is_child_theme() ) {
wp_enqueue_style( 'generate-child', get_stylesheet_uri(), array( 'generate-style' ), filemtime( get_stylesheet_directory() . '/style.css' ), 'all' );
}
if ( ! apply_filters( 'generate_fontawesome_essentials', false ) ) {
wp_enqueue_style( 'font-awesome', $dir_uri . "/css/font-awesome{$suffix}.css", false, '4.7', 'all' );
}
if ( function_exists( 'wp_script_add_data' ) ) {
wp_enqueue_script( 'generate-classlist', $dir_uri . "/js/classList{$suffix}.js", array(), GENERATE_VERSION, true );
wp_script_add_data( 'generate-classlist', 'conditional', 'lte IE 11' );
}
wp_enqueue_script( 'generate-menu', $dir_uri . "/js/menu{$suffix}.js", array(), GENERATE_VERSION, true );
wp_enqueue_script( 'generate-a11y', $dir_uri . "/js/a11y{$suffix}.js", array(), GENERATE_VERSION, true );
if ( 'click' === generate_get_option( 'nav_dropdown_type' ) || 'click-arrow' === generate_get_option( 'nav_dropdown_type' ) ) {
wp_enqueue_script( 'generate-dropdown-click', $dir_uri . "/js/dropdown-click{$suffix}.js", array( 'generate-menu' ), GENERATE_VERSION, true );
}
if ( 'enable' === generate_get_option( 'nav_search' ) ) {
wp_enqueue_script( 'generate-navigation-search', $dir_uri . "/js/navigation-search{$suffix}.js", array( 'generate-menu' ), GENERATE_VERSION, true );
wp_localize_script(
'generate-navigation-search',
'generatepressNavSearch',
array(
'open' => esc_attr__( 'Open Search Bar', 'generatepress' ),
'close' => esc_attr__( 'Close Search Bar', 'generatepress' ),
)
);
}
if ( 'enable' === generate_get_option( 'back_to_top' ) ) {
wp_enqueue_script( 'generate-back-to-top', $dir_uri . "/js/back-to-top{$suffix}.js", array(), GENERATE_VERSION, true );
}
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
}
if ( ! function_exists( 'generate_widgets_init' ) ) {
add_action( 'widgets_init', 'generate_widgets_init' );
/**
* Register widgetized area and update sidebar with default widgets
*/
function generate_widgets_init() {
$widgets = array(
'sidebar-1' => __( 'Right Sidebar', 'generatepress' ),
'sidebar-2' => __( 'Left Sidebar', 'generatepress' ),
'header' => __( 'Header', 'generatepress' ),
'footer-1' => __( 'Footer Widget 1', 'generatepress' ),
'footer-2' => __( 'Footer Widget 2', 'generatepress' ),
'footer-3' => __( 'Footer Widget 3', 'generatepress' ),
'footer-4' => __( 'Footer Widget 4', 'generatepress' ),
'footer-5' => __( 'Footer Widget 5', 'generatepress' ),
'footer-bar' => __( 'Footer Bar','generatepress' ),
'top-bar' => __( 'Top Bar','generatepress' ),
);
foreach ( $widgets as $id => $name ) {
register_sidebar( array(
'name' => $name,
'id' => $id,
'before_widget' => '<aside id="%1$s" class="widget inner-padding %2$s">',
'after_widget' => '</aside>',
'before_title' => apply_filters( 'generate_start_widget_title', '<h2 class="widget-title">' ),
'after_title' => apply_filters( 'generate_end_widget_title', '</h2>' ),
) );
}
}
}
if ( ! function_exists( 'generate_smart_content_width' ) ) {
add_action( 'wp', 'generate_smart_content_width' );
/**
* Set the $content_width depending on layout of current page
* Hook into "wp" so we have the correct layout setting from generate_get_layout()
* Hooking into "after_setup_theme" doesn't get the correct layout setting
*/
function generate_smart_content_width() {
global $content_width;
$container_width = generate_get_option( 'container_width' );
$right_sidebar_width = apply_filters( 'generate_right_sidebar_width', '25' );
$left_sidebar_width = apply_filters( 'generate_left_sidebar_width', '25' );
$layout = generate_get_layout();
if ( 'left-sidebar' == $layout ) {
$content_width = $container_width * ( ( 100 - $left_sidebar_width ) / 100 );
} elseif ( 'right-sidebar' == $layout ) {
$content_width = $container_width * ( ( 100 - $right_sidebar_width ) / 100 );
} elseif ( 'no-sidebar' == $layout ) {
$content_width = $container_width;
} else {
$content_width = $container_width * ( ( 100 - ( $left_sidebar_width + $right_sidebar_width ) ) / 100 );
}
}
}
if ( ! function_exists( 'generate_page_menu_args' ) ) {
add_filter( 'wp_page_menu_args', 'generate_page_menu_args' );
/**
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
*
* @since 0.1
*
* @param array $args The existing menu args.
* @return array Menu args.
*/
function generate_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
}
if ( ! function_exists( 'generate_disable_title' ) ) {
add_filter( 'generate_show_title', 'generate_disable_title' );
/**
* Remove our title if set.
*
* @since 1.3.18
*
* @param bool $title Whether the title is displayed or not.
* @return bool Whether to display the content title.
*/
function generate_disable_title( $title ) {
if ( is_singular() ) {
$disable_title = get_post_meta( get_the_ID(), '_generate-disable-headline', true );
if ( $disable_title ) {
$title = false;
}
}
return $title;
}
}
if ( ! function_exists( 'generate_resource_hints' ) ) {
add_filter( 'wp_resource_hints', 'generate_resource_hints', 10, 2 );
/**
* Add resource hints to our Google fonts call.
*
* @since 1.3.42
*
* @param array $urls URLs to print for resource hints.
* @param string $relation_type The relation type the URLs are printed.
* @return array $urls URLs to print for resource hints.
*/
function generate_resource_hints( $urls, $relation_type ) {
if ( wp_style_is( 'generate-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) {
$urls[] = array(
'href' => 'https://fonts.gstatic.com',
'crossorigin',
);
} else {
$urls[] = 'https://fonts.gstatic.com';
}
}
return $urls;
}
}
if ( ! function_exists( 'generate_remove_caption_padding' ) ) {
add_filter( 'img_caption_shortcode_width', 'generate_remove_caption_padding' );
/**
* Remove WordPress's default padding on images with captions
*
* @param int $width Default WP .wp-caption width (image width + 10px)
* @return int Updated width to remove 10px padding
*/
function generate_remove_caption_padding( $width ) {
return $width - 10;
}
}
if ( ! function_exists( 'generate_enhanced_image_navigation' ) ) {
add_filter( 'attachment_link', 'generate_enhanced_image_navigation', 10, 2 );
/**
* Filter in a link to a content ID attribute for the next/previous image links on image attachment pages
*/
function generate_enhanced_image_navigation( $url, $id ) {
if ( ! is_attachment() && ! wp_attachment_is_image( $id ) ) {
return $url;
}
$image = get_post( $id );
if ( ! empty( $image->post_parent ) && $image->post_parent != $id ) {
$url .= '#main';
}
return $url;
}
}
if ( ! function_exists( 'generate_categorized_blog' ) ) {
/**
* Determine whether blog/site has more than one category.
*
* @since 1.2.5
*
* @return bool True of there is more than one category, false otherwise.
*/
function generate_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'generate_categories' ) ) ) {
// Create an array of all the categories that are attached to posts.
$all_the_cool_cats = get_categories( array(
'fields' => 'ids',
'hide_empty' => 1,
// We only need to know if there is more than one category.
'number' => 2,
) );
// Count the number of categories that are attached to the posts.
$all_the_cool_cats = count( $all_the_cool_cats );
set_transient( 'generate_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so twentyfifteen_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so twentyfifteen_categorized_blog should return false.
return false;
}
}
}
if ( ! function_exists( 'generate_category_transient_flusher' ) ) {
add_action( 'edit_category', 'generate_category_transient_flusher' );
add_action( 'save_post', 'generate_category_transient_flusher' );
/**
* Flush out the transients used in {@see generate_categorized_blog()}.
*
* @since 1.2.5
*/
function generate_category_transient_flusher() {
// Like, beat it. Dig?
delete_transient( 'generate_categories' );
}
}
if ( ! function_exists( 'generate_get_default_color_palettes' ) ) {
/**
* Set up our colors for the color picker palettes and filter them so you can change them.
*
* @since 1.3.42
*/
function generate_get_default_color_palettes() {
$palettes = array(
'#000000',
'#FFFFFF',
'#F1C40F',
'#E74C3C',
'#1ABC9C',
'#1e72bd',
'#8E44AD',
'#00CC77',
);
return apply_filters( 'generate_default_color_palettes', $palettes );
}
}
add_filter( 'generate_fontawesome_essentials', 'generate_set_font_awesome_essentials' );
/**
* Check to see if we should include the full Font Awesome library or not.
*
* @since 2.0
*
* @param bool $essentials
* @return bool
*/
function generate_set_font_awesome_essentials( $essentials ) {
if ( generate_get_option( 'font_awesome_essentials' ) ) {
return true;
}
return $essentials;
}
add_filter( 'generate_dynamic_css_skip_cache', 'generate_skip_dynamic_css_cache' );
/**
* Skips caching of the dynamic CSS if set to false.
*
* @since 2.0
*
* @param bool $cache
* @return bool
*/
function generate_skip_dynamic_css_cache( $cache ) {
if ( ! generate_get_option( 'dynamic_css_cache' ) ) {
return true;
}
return $cache;
}
add_filter( 'wp_headers', 'generate_set_wp_headers' );
/**
* Set any necessary headers.
*
* @since 2.3
*/
function generate_set_wp_headers( $headers ) {
$headers['X-UA-Compatible'] = 'IE=edge';
return $headers;
}

View File

@ -0,0 +1,565 @@
<?php
/**
* Adds HTML markup.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Display HTML classes for an element.
*
* @since 2.2
*
* @param string $context The element we're targeting.
* @param string|array $class One or more classes to add to the class list.
*/
function generate_do_element_classes( $context, $class = '' ) {
echo 'class="' . join( ' ', generate_get_element_classes( $context, $class ) ) . '"'; // WPCS: XSS ok, sanitization ok.
}
/**
* Retrieve HTML classes for an element.
*
* @since 2.2
*
* @param string $context The element we're targeting.
* @param string|array $class One or more classes to add to the class list.
* @return array Array of classes.
*/
function generate_get_element_classes( $context, $class = '' ) {
$classes = array();
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
}
$classes = array_map( 'esc_attr', $classes );
return apply_filters( "generate_{$context}_class", $classes, $class );
}
/**
* Get any necessary microdata.
*
* @since 2.2
*
* @param string $context The element to target.
* @return string Our final attribute to add to the element.
*/
function generate_get_microdata( $context ) {
$data = false;
if ( 'microdata' !== apply_filters( 'generate_schema_type', 'microdata' ) ) {
return false;
}
if ( 'body' === $context ) {
$type = 'WebPage';
if ( is_home() || is_archive() || is_attachment() || is_tax() || is_single() ) {
$type = 'Blog';
}
if ( is_search() ) {
$type = 'SearchResultsPage';
}
$type = apply_filters( 'generate_body_itemtype', $type );
$data = sprintf(
'itemtype="https://schema.org/%s" itemscope',
esc_html( $type )
);
}
if ( 'header' === $context ) {
$data = 'itemtype="https://schema.org/WPHeader" itemscope';
}
if ( 'navigation' === $context ) {
$data = 'itemtype="https://schema.org/SiteNavigationElement" itemscope';
}
if ( 'article' === $context ) {
$type = apply_filters( 'generate_article_itemtype', 'CreativeWork' );
$data = sprintf(
'itemtype="https://schema.org/%s" itemscope',
esc_html( $type )
);
}
if ( 'post-author' === $context ) {
$data = 'itemprop="author" itemtype="https://schema.org/Person" itemscope';
}
if ( 'comment-body' === $context ) {
$data = 'itemtype="https://schema.org/Comment" itemscope';
}
if ( 'comment-author' === $context ) {
$data = 'itemprop="author" itemtype="https://schema.org/Person" itemscope';
}
if ( 'sidebar' === $context ) {
$data = 'itemtype="https://schema.org/WPSideBar" itemscope';
}
if ( 'footer' === $context ) {
$data = 'itemtype="https://schema.org/WPFooter" itemscope';
}
if ( $data ) {
return apply_filters( "generate_{$context}_microdata", $data );
}
}
/**
* Output our microdata for an element.
*
* @since 2.2
*
* @param $context The element to target.
* @return string The microdata.
*/
function generate_do_microdata( $context ) {
echo generate_get_microdata( $context ); // WPCS: XSS ok, sanitization ok.
}
if ( ! function_exists( 'generate_body_classes' ) ) {
add_filter( 'body_class', 'generate_body_classes' );
/**
* Adds custom classes to the array of body classes.
* @since 0.1
*/
function generate_body_classes( $classes ) {
$sidebar_layout = generate_get_layout();
$navigation_location = generate_get_navigation_location();
$navigation_alignment = generate_get_option( 'nav_alignment_setting' );
$navigation_dropdown = generate_get_option( 'nav_dropdown_type' );
$header_layout = generate_get_option( 'header_layout_setting' );
$header_alignment = generate_get_option( 'header_alignment_setting' );
$content_layout = generate_get_option( 'content_layout_setting' );
$footer_widgets = generate_get_footer_widgets();
// These values all have defaults, but we like to be extra careful.
$classes[] = ( $sidebar_layout ) ? $sidebar_layout : 'right-sidebar';
$classes[] = ( $navigation_location ) ? $navigation_location : 'nav-below-header';
$classes[] = ( $header_layout ) ? $header_layout : 'fluid-header';
$classes[] = ( $content_layout ) ? $content_layout : 'separate-containers';
$classes[] = ( '' !== $footer_widgets ) ? 'active-footer-widgets-' . absint( $footer_widgets ) : 'active-footer-widgets-3';
if ( 'enable' === generate_get_option( 'nav_search' ) ) {
$classes[] = 'nav-search-enabled';
}
// Only necessary for nav before or after header.
if ( 'nav-below-header' === $navigation_location || 'nav-above-header' === $navigation_location ) {
if ( 'center' === $navigation_alignment ) {
$classes[] = 'nav-aligned-center';
} elseif ( 'right' === $navigation_alignment ) {
$classes[] = 'nav-aligned-right';
} elseif ( 'left' === $navigation_alignment ) {
$classes[] = 'nav-aligned-left';
}
}
if ( 'center' === $header_alignment ) {
$classes[] = 'header-aligned-center';
} elseif ( 'right' === $header_alignment ) {
$classes[] = 'header-aligned-right';
} elseif ( 'left' === $header_alignment ) {
$classes[] = 'header-aligned-left';
}
if ( 'click' === $navigation_dropdown ) {
$classes[] = 'dropdown-click';
$classes[] = 'dropdown-click-menu-item';
} elseif ( 'click-arrow' === $navigation_dropdown ) {
$classes[] = 'dropdown-click-arrow';
$classes[] = 'dropdown-click';
} else {
$classes[] = 'dropdown-hover';
}
if ( is_singular() ) {
// Page builder container metabox option.
// Used to be a single checkbox, hence the name/true value. Now it's a radio choice between full width and contained.
$content_container = get_post_meta( get_the_ID(), '_generate-full-width-content', true );
if ( $content_container ) {
if ( 'true' === $content_container ) {
$classes[] = 'full-width-content';
}
if ( 'contained' === $content_container ) {
$classes[] = 'contained-content';
}
}
if ( has_post_thumbnail() ) {
$classes[] = 'featured-image-active';
}
}
return $classes;
}
}
if ( ! function_exists( 'generate_top_bar_classes' ) ) {
add_filter( 'generate_top_bar_class', 'generate_top_bar_classes' );
/**
* Adds custom classes to the header.
*
* @since 0.1
*/
function generate_top_bar_classes( $classes ) {
$classes[] = 'top-bar';
if ( 'contained' === generate_get_option( 'top_bar_width' ) ) {
$classes[] = 'grid-container';
$classes[] = 'grid-parent';
}
$classes[] = 'top-bar-align-' . esc_attr( generate_get_option( 'top_bar_alignment' ) );
return $classes;
}
}
if ( ! function_exists( 'generate_right_sidebar_classes' ) ) {
add_filter( 'generate_right_sidebar_class', 'generate_right_sidebar_classes' );
/**
* Adds custom classes to the right sidebar.
*
* @since 0.1
*/
function generate_right_sidebar_classes( $classes ) {
$right_sidebar_width = apply_filters( 'generate_right_sidebar_width', '25' );
$left_sidebar_width = apply_filters( 'generate_left_sidebar_width', '25' );
$right_sidebar_tablet_width = apply_filters( 'generate_right_sidebar_tablet_width', $right_sidebar_width );
$left_sidebar_tablet_width = apply_filters( 'generate_left_sidebar_tablet_width', $left_sidebar_width );
$classes[] = 'widget-area';
$classes[] = 'grid-' . $right_sidebar_width;
$classes[] = 'tablet-grid-' . $right_sidebar_tablet_width;
$classes[] = 'grid-parent';
$classes[] = 'sidebar';
// Get the layout
$layout = generate_get_layout();
if ( '' !== $layout ) {
switch ( $layout ) {
case 'both-left' :
$total_sidebar_width = $left_sidebar_width + $right_sidebar_width;
$classes[] = 'pull-' . ( 100 - $total_sidebar_width );
$total_sidebar_tablet_width = $left_sidebar_tablet_width + $right_sidebar_tablet_width;
$classes[] = 'tablet-pull-' . ( 100 - $total_sidebar_tablet_width );
break;
}
}
return $classes;
}
}
if ( ! function_exists( 'generate_left_sidebar_classes' ) ) {
add_filter( 'generate_left_sidebar_class', 'generate_left_sidebar_classes' );
/**
* Adds custom classes to the left sidebar.
*
* @since 0.1
*/
function generate_left_sidebar_classes( $classes ) {
$right_sidebar_width = apply_filters( 'generate_right_sidebar_width', '25' );
$left_sidebar_width = apply_filters( 'generate_left_sidebar_width', '25' );
$total_sidebar_width = $left_sidebar_width + $right_sidebar_width;
$right_sidebar_tablet_width = apply_filters( 'generate_right_sidebar_tablet_width', $right_sidebar_width );
$left_sidebar_tablet_width = apply_filters( 'generate_left_sidebar_tablet_width', $left_sidebar_width );
$total_sidebar_tablet_width = $left_sidebar_tablet_width + $right_sidebar_tablet_width;
$classes[] = 'widget-area';
$classes[] = 'grid-' . $left_sidebar_width;
$classes[] = 'tablet-grid-' . $left_sidebar_tablet_width;
$classes[] = 'mobile-grid-100';
$classes[] = 'grid-parent';
$classes[] = 'sidebar';
// Get the layout
$layout = generate_get_layout();
if ( '' !== $layout ) {
switch ( $layout ) {
case 'left-sidebar' :
$classes[] = 'pull-' . ( 100 - $left_sidebar_width );
$classes[] = 'tablet-pull-' . ( 100 - $left_sidebar_tablet_width );
break;
case 'both-sidebars' :
case 'both-left' :
$classes[] = 'pull-' . ( 100 - $total_sidebar_width );
$classes[] = 'tablet-pull-' . ( 100 - $total_sidebar_tablet_width );
break;
}
}
return $classes;
}
}
if ( ! function_exists( 'generate_content_classes' ) ) {
add_filter( 'generate_content_class', 'generate_content_classes' );
/**
* Adds custom classes to the content container.
*
* @since 0.1
*/
function generate_content_classes( $classes ) {
$right_sidebar_width = apply_filters( 'generate_right_sidebar_width', '25' );
$left_sidebar_width = apply_filters( 'generate_left_sidebar_width', '25' );
$total_sidebar_width = $left_sidebar_width + $right_sidebar_width;
$right_sidebar_tablet_width = apply_filters( 'generate_right_sidebar_tablet_width', $right_sidebar_width );
$left_sidebar_tablet_width = apply_filters( 'generate_left_sidebar_tablet_width', $left_sidebar_width );
$total_sidebar_tablet_width = $left_sidebar_tablet_width + $right_sidebar_tablet_width;
$classes[] = 'content-area';
$classes[] = 'grid-parent';
$classes[] = 'mobile-grid-100';
// Get the layout
$layout = generate_get_layout();
if ( '' !== $layout ) {
switch ( $layout ) {
case 'right-sidebar' :
$classes[] = 'grid-' . ( 100 - $right_sidebar_width );
$classes[] = 'tablet-grid-' . ( 100 - $right_sidebar_tablet_width );
break;
case 'left-sidebar' :
$classes[] = 'push-' . $left_sidebar_width;
$classes[] = 'grid-' . ( 100 - $left_sidebar_width );
$classes[] = 'tablet-push-' . $left_sidebar_tablet_width;
$classes[] = 'tablet-grid-' . ( 100 - $left_sidebar_tablet_width );
break;
case 'no-sidebar' :
$classes[] = 'grid-100';
$classes[] = 'tablet-grid-100';
break;
case 'both-sidebars' :
$classes[] = 'push-' . $left_sidebar_width;
$classes[] = 'grid-' . ( 100 - $total_sidebar_width );
$classes[] = 'tablet-push-' . $left_sidebar_tablet_width;
$classes[] = 'tablet-grid-' . ( 100 - $total_sidebar_tablet_width );
break;
case 'both-right' :
$classes[] = 'grid-' . ( 100 - $total_sidebar_width );
$classes[] = 'tablet-grid-' . ( 100 - $total_sidebar_tablet_width );
break;
case 'both-left' :
$classes[] = 'push-' . $total_sidebar_width;
$classes[] = 'grid-' . ( 100 - $total_sidebar_width );
$classes[] = 'tablet-push-' . $total_sidebar_tablet_width;
$classes[] = 'tablet-grid-' . ( 100 - $total_sidebar_tablet_width );
break;
}
}
return $classes;
}
}
if ( ! function_exists( 'generate_header_classes' ) ) {
add_filter( 'generate_header_class', 'generate_header_classes' );
/**
* Adds custom classes to the header.
*
* @since 0.1
*/
function generate_header_classes( $classes ) {
$classes[] = 'site-header';
if ( 'contained-header' === generate_get_option( 'header_layout_setting' ) ) {
$classes[] = 'grid-container';
$classes[] = 'grid-parent';
}
return $classes;
}
}
if ( ! function_exists( 'generate_inside_header_classes' ) ) {
add_filter( 'generate_inside_header_class', 'generate_inside_header_classes' );
/**
* Adds custom classes to inside the header.
*
* @since 0.1
*/
function generate_inside_header_classes( $classes ) {
$classes[] = 'inside-header';
if ( 'full-width' !== generate_get_option( 'header_inner_width' ) ) {
$classes[] = 'grid-container';
$classes[] = 'grid-parent';
}
return $classes;
}
}
if ( ! function_exists( 'generate_navigation_classes' ) ) {
add_filter( 'generate_navigation_class', 'generate_navigation_classes' );
/**
* Adds custom classes to the navigation.
*
* @since 0.1
*/
function generate_navigation_classes( $classes ) {
$classes[] = 'main-navigation';
if ( 'contained-nav' === generate_get_option( 'nav_layout_setting' ) ) {
$classes[] = 'grid-container';
$classes[] = 'grid-parent';
}
if ( 'left' === generate_get_option( 'nav_dropdown_direction' ) ) {
$nav_layout = generate_get_option( 'nav_position_setting' );
switch ( $nav_layout ) {
case 'nav-below-header':
case 'nav-above-header':
case 'nav-float-right':
case 'nav-float-left':
$classes[] = 'sub-menu-left';
break;
}
}
return $classes;
}
}
if ( ! function_exists( 'generate_inside_navigation_classes' ) ) {
add_filter( 'generate_inside_navigation_class', 'generate_inside_navigation_classes' );
/**
* Adds custom classes to the inner navigation.
*
* @since 1.3.41
*/
function generate_inside_navigation_classes( $classes ) {
$classes[] = 'inside-navigation';
if ( 'full-width' !== generate_get_option( 'nav_inner_width' ) ) {
$classes[] = 'grid-container';
$classes[] = 'grid-parent';
}
return $classes;
}
}
if ( ! function_exists( 'generate_menu_classes' ) ) {
add_filter( 'generate_menu_class', 'generate_menu_classes' );
/**
* Adds custom classes to the menu.
*
* @since 0.1
*/
function generate_menu_classes( $classes ) {
$classes[] = 'menu';
$classes[] = 'sf-menu';
return $classes;
}
}
if ( ! function_exists( 'generate_footer_classes' ) ) {
add_filter( 'generate_footer_class', 'generate_footer_classes' );
/**
* Adds custom classes to the footer.
*
* @since 0.1
*/
function generate_footer_classes( $classes ) {
$classes[] = 'site-footer';
if ( 'contained-footer' === generate_get_option( 'footer_layout_setting' ) ) {
$classes[] = 'grid-container';
$classes[] = 'grid-parent';
}
if ( is_active_sidebar( 'footer-bar' ) ) {
$classes[] = 'footer-bar-active';
$classes[] = 'footer-bar-align-' . esc_attr( generate_get_option( 'footer_bar_alignment' ) );
}
return $classes;
}
}
if ( ! function_exists( 'generate_inside_footer_classes' ) ) {
add_filter( 'generate_inside_footer_class', 'generate_inside_footer_classes' );
/**
* Adds custom classes to the footer.
*
* @since 0.1
*/
function generate_inside_footer_classes( $classes ) {
$classes[] = 'footer-widgets-container';
if ( 'full-width' !== generate_get_option( 'footer_inner_width' ) ) {
$classes[] = 'grid-container';
$classes[] = 'grid-parent';
}
return $classes;
}
}
if ( ! function_exists( 'generate_main_classes' ) ) {
add_filter( 'generate_main_class', 'generate_main_classes' );
/**
* Adds custom classes to the <main> element
* @since 1.1.0
*/
function generate_main_classes( $classes ) {
$classes[] = 'site-main';
return $classes;
}
}
if ( ! function_exists( 'generate_post_classes' ) ) {
add_filter( 'post_class', 'generate_post_classes' );
/**
* Adds custom classes to the <article> element.
* Remove .hentry class from pages to comply with structural data guidelines.
*
* @since 1.3.39
*/
function generate_post_classes( $classes ) {
if ( 'page' == get_post_type() ) {
$classes = array_diff( $classes, array( 'hentry' ) );
}
return $classes;
}
}

View File

@ -0,0 +1,315 @@
<?php
/**
* Builds our main Layout meta box.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
add_action( 'admin_enqueue_scripts', 'generate_enqueue_meta_box_scripts' );
/**
* Adds any scripts for this meta box.
*
* @since 2.0
*
* @param string $hook The current admin page.
*/
function generate_enqueue_meta_box_scripts( $hook ) {
if ( in_array( $hook, array( 'post.php', 'post-new.php' ) ) ) {
$post_types = get_post_types( array( 'public' => true ) );
$screen = get_current_screen();
$post_type = $screen->id;
if ( in_array( $post_type, ( array ) $post_types ) ) {
wp_enqueue_style( 'generate-layout-metabox', get_template_directory_uri() . '/css/admin/meta-box.css', array(), GENERATE_VERSION );
}
}
}
add_action( 'add_meta_boxes', 'generate_register_layout_meta_box' );
/**
* Generate the layout metabox
*
* @since 2.0
*/
function generate_register_layout_meta_box() {
if ( ! current_user_can( apply_filters( 'generate_metabox_capability', 'edit_theme_options' ) ) ) {
return;
}
if ( ! defined( 'GENERATE_LAYOUT_META_BOX' ) ) {
define( 'GENERATE_LAYOUT_META_BOX', true );
}
$post_types = get_post_types( array( 'public' => true ) );
foreach ( $post_types as $type ) {
if ( 'attachment' !== $type ) {
add_meta_box(
'generate_layout_options_meta_box',
esc_html__( 'Layout', 'generatepress' ),
'generate_do_layout_meta_box',
$type,
'side'
);
}
}
}
/**
* Build our meta box.
*
* @since 2.0
*
* @param object $post All post information.
*/
function generate_do_layout_meta_box( $post ) {
wp_nonce_field( basename( __FILE__ ), 'generate_layout_nonce' );
$stored_meta = (array) get_post_meta( $post->ID );
$stored_meta['_generate-sidebar-layout-meta'][0] = ( isset( $stored_meta['_generate-sidebar-layout-meta'][0] ) ) ? $stored_meta['_generate-sidebar-layout-meta'][0] : '';
$stored_meta['_generate-footer-widget-meta'][0] = ( isset( $stored_meta['_generate-footer-widget-meta'][0] ) ) ? $stored_meta['_generate-footer-widget-meta'][0] : '';
$stored_meta['_generate-full-width-content'][0] = ( isset( $stored_meta['_generate-full-width-content'][0] ) ) ? $stored_meta['_generate-full-width-content'][0] : '';
$stored_meta['_generate-disable-headline'][0] = ( isset( $stored_meta['_generate-disable-headline'][0] ) ) ? $stored_meta['_generate-disable-headline'][0] : '';
$tabs = apply_filters( 'generate_metabox_tabs',
array(
'sidebars' => array(
'title' => esc_html__( 'Sidebars', 'generatepress' ),
'target' => '#generate-layout-sidebars',
'class' => 'current',
),
'footer_widgets' => array(
'title' => esc_html__( 'Footer Widgets', 'generatepress' ),
'target' => '#generate-layout-footer-widgets',
'class' => '',
),
'disable_elements' => array(
'title' => esc_html__( 'Disable Elements', 'generatepress' ),
'target' => '#generate-layout-disable-elements',
'class' => '',
),
'container' => array(
'title' => esc_html__( 'Page Builder Container', 'generatepress' ),
'target' => '#generate-layout-page-builder-container',
'class' => '',
),
)
);
?>
<script>
jQuery(document).ready(function($) {
$( '.generate-meta-box-menu li a' ).on( 'click', function( event ) {
event.preventDefault();
$( this ).parent().addClass( 'current' );
$( this ).parent().siblings().removeClass( 'current' );
var tab = $( this ).attr( 'data-target' );
// Page header module still using href.
if ( ! tab ) {
tab = $( this ).attr( 'href' );
}
$( '.generate-meta-box-content' ).children( 'div' ).not( tab ).css( 'display', 'none' );
$( tab ).fadeIn( 100 );
});
});
</script>
<div id="generate-meta-box-container">
<ul class="generate-meta-box-menu">
<?php
foreach ( ( array ) $tabs as $tab => $data ) {
echo '<li class="' . esc_attr( $data['class'] ) . '"><a data-target="' . esc_attr( $data['target'] ) . '" href="#">' . esc_html( $data['title'] ) . '</a></li>';
}
do_action( 'generate_layout_meta_box_menu_item' );
?>
</ul>
<div class="generate-meta-box-content">
<div id="generate-layout-sidebars">
<div class="generate_layouts">
<label for="meta-generate-layout-global" style="display:block;margin-bottom:10px;">
<input type="radio" name="_generate-sidebar-layout-meta" id="meta-generate-layout-global" value="" <?php checked( $stored_meta['_generate-sidebar-layout-meta'][0], '' ); ?>>
<?php esc_html_e( 'Default', 'generatepress' );?>
</label>
<label for="meta-generate-layout-one" style="display:block;margin-bottom:3px;" title="<?php esc_attr_e( 'Right Sidebar', 'generatepress' );?>">
<input type="radio" name="_generate-sidebar-layout-meta" id="meta-generate-layout-one" value="right-sidebar" <?php checked( $stored_meta['_generate-sidebar-layout-meta'][0], 'right-sidebar' ); ?>>
<?php esc_html_e( 'Content', 'generatepress' );?> / <strong><?php echo esc_html_x( 'Sidebar', 'Short name for meta box', 'generatepress' ); ?></strong>
</label>
<label for="meta-generate-layout-two" style="display:block;margin-bottom:3px;" title="<?php esc_attr_e( 'Left Sidebar', 'generatepress' );?>">
<input type="radio" name="_generate-sidebar-layout-meta" id="meta-generate-layout-two" value="left-sidebar" <?php checked( $stored_meta['_generate-sidebar-layout-meta'][0], 'left-sidebar' ); ?>>
<strong><?php echo esc_html_x( 'Sidebar', 'Short name for meta box', 'generatepress' ); ?></strong> / <?php esc_html_e( 'Content', 'generatepress' );?>
</label>
<label for="meta-generate-layout-three" style="display:block;margin-bottom:3px;" title="<?php esc_attr_e( 'No Sidebars', 'generatepress' );?>">
<input type="radio" name="_generate-sidebar-layout-meta" id="meta-generate-layout-three" value="no-sidebar" <?php checked( $stored_meta['_generate-sidebar-layout-meta'][0], 'no-sidebar' ); ?>>
<?php esc_html_e( 'Content (no sidebars)', 'generatepress' );?>
</label>
<label for="meta-generate-layout-four" style="display:block;margin-bottom:3px;" title="<?php esc_attr_e( 'Both Sidebars', 'generatepress' );?>">
<input type="radio" name="_generate-sidebar-layout-meta" id="meta-generate-layout-four" value="both-sidebars" <?php checked( $stored_meta['_generate-sidebar-layout-meta'][0], 'both-sidebars' ); ?>>
<strong><?php echo esc_html_x( 'Sidebar', 'Short name for meta box', 'generatepress' ); ?></strong> / <?php esc_html_e( 'Content', 'generatepress' );?> / <strong><?php echo esc_html_x( 'Sidebar', 'Short name for meta box', 'generatepress' ); ?></strong>
</label>
<label for="meta-generate-layout-five" style="display:block;margin-bottom:3px;" title="<?php esc_attr_e( 'Both Sidebars on Left', 'generatepress' );?>">
<input type="radio" name="_generate-sidebar-layout-meta" id="meta-generate-layout-five" value="both-left" <?php checked( $stored_meta['_generate-sidebar-layout-meta'][0], 'both-left' ); ?>>
<strong><?php echo esc_html_x( 'Sidebar', 'Short name for meta box', 'generatepress' ); ?></strong> / <strong><?php echo esc_html_x( 'Sidebar', 'Short name for meta box', 'generatepress' ); ?></strong> / <?php esc_html_e( 'Content', 'generatepress' );?>
</label>
<label for="meta-generate-layout-six" style="display:block;margin-bottom:3px;" title="<?php esc_attr_e( 'Both Sidebars on Right', 'generatepress' );?>">
<input type="radio" name="_generate-sidebar-layout-meta" id="meta-generate-layout-six" value="both-right" <?php checked( $stored_meta['_generate-sidebar-layout-meta'][0], 'both-right' ); ?>>
<?php esc_html_e( 'Content', 'generatepress' );?> / <strong><?php echo esc_html_x( 'Sidebar', 'Short name for meta box', 'generatepress' ); ?></strong> / <strong><?php echo esc_html_x( 'Sidebar', 'Short name for meta box', 'generatepress' ); ?></strong>
</label>
</div>
</div>
<div id="generate-layout-footer-widgets" style="display: none;">
<div class="generate_footer_widget">
<label for="meta-generate-footer-widget-global" style="display:block;margin-bottom:10px;">
<input type="radio" name="_generate-footer-widget-meta" id="meta-generate-footer-widget-global" value="" <?php checked( $stored_meta['_generate-footer-widget-meta'][0], '' ); ?>>
<?php esc_html_e( 'Default', 'generatepress' );?>
</label>
<label for="meta-generate-footer-widget-zero" style="display:block;margin-bottom:3px;" title="<?php esc_attr_e( '0 Widgets', 'generatepress' );?>">
<input type="radio" name="_generate-footer-widget-meta" id="meta-generate-footer-widget-zero" value="0" <?php checked( $stored_meta['_generate-footer-widget-meta'][0], '0' ); ?>>
<?php esc_html_e( '0 Widgets', 'generatepress' );?>
</label>
<label for="meta-generate-footer-widget-one" style="display:block;margin-bottom:3px;" title="<?php esc_attr_e( '1 Widget', 'generatepress' );?>">
<input type="radio" name="_generate-footer-widget-meta" id="meta-generate-footer-widget-one" value="1" <?php checked( $stored_meta['_generate-footer-widget-meta'][0], '1' ); ?>>
<?php esc_html_e( '1 Widget', 'generatepress' );?>
</label>
<label for="meta-generate-footer-widget-two" style="display:block;margin-bottom:3px;" title="<?php esc_attr_e( '2 Widgets', 'generatepress' );?>">
<input type="radio" name="_generate-footer-widget-meta" id="meta-generate-footer-widget-two" value="2" <?php checked( $stored_meta['_generate-footer-widget-meta'][0], '2' ); ?>>
<?php esc_html_e( '2 Widgets', 'generatepress' );?>
</label>
<label for="meta-generate-footer-widget-three" style="display:block;margin-bottom:3px;" title="<?php esc_attr_e( '3 Widgets', 'generatepress' );?>">
<input type="radio" name="_generate-footer-widget-meta" id="meta-generate-footer-widget-three" value="3" <?php checked( $stored_meta['_generate-footer-widget-meta'][0], '3' ); ?>>
<?php esc_html_e( '3 Widgets', 'generatepress' );?>
</label>
<label for="meta-generate-footer-widget-four" style="display:block;margin-bottom:3px;" title="<?php esc_attr_e( '4 Widgets', 'generatepress' );?>">
<input type="radio" name="_generate-footer-widget-meta" id="meta-generate-footer-widget-four" value="4" <?php checked( $stored_meta['_generate-footer-widget-meta'][0], '4' ); ?>>
<?php esc_html_e( '4 Widgets', 'generatepress' );?>
</label>
<label for="meta-generate-footer-widget-five" style="display:block;margin-bottom:3px;" title="<?php esc_attr_e( '5 Widgets', 'generatepress' );?>">
<input type="radio" name="_generate-footer-widget-meta" id="meta-generate-footer-widget-five" value="5" <?php checked( $stored_meta['_generate-footer-widget-meta'][0], '5' ); ?>>
<?php esc_html_e( '5 Widgets', 'generatepress' );?>
</label>
</div>
</div>
<div id="generate-layout-page-builder-container" style="display: none;">
<p class="page-builder-content" style="color:#666;font-size:13px;margin-top:0;">
<?php esc_html_e( 'Choose your page builder content container type. Both options remove the content padding for you.', 'generatepress' ) ;?>
</p>
<p class="generate_full_width_template">
<label for="default-content" style="display:block;margin-bottom:10px;">
<input type="radio" name="_generate-full-width-content" id="default-content" value="" <?php checked( $stored_meta['_generate-full-width-content'][0], '' ); ?>>
<?php esc_html_e( 'Default', 'generatepress' );?>
</label>
<label id="full-width-content" for="_generate-full-width-content" style="display:block;margin-bottom:10px;">
<input type="radio" name="_generate-full-width-content" id="_generate-full-width-content" value="true" <?php checked( $stored_meta['_generate-full-width-content'][0], 'true' ); ?>>
<?php esc_html_e( 'Full Width', 'generatepress' );?>
</label>
<label id="generate-remove-padding" for="_generate-remove-content-padding" style="display:block;margin-bottom:10px;">
<input type="radio" name="_generate-full-width-content" id="_generate-remove-content-padding" value="contained" <?php checked( $stored_meta['_generate-full-width-content'][0], 'contained' ); ?>>
<?php esc_html_e( 'Contained', 'generatepress' );?>
</label>
</p>
</div>
<div id="generate-layout-disable-elements" style="display: none;">
<?php if ( ! defined( 'GENERATE_DE_VERSION' ) ) : ?>
<div class="generate_disable_elements">
<label for="meta-generate-disable-headline" style="display:block;margin: 0 0 1em;" title="<?php esc_attr_e( 'Content Title', 'generatepress' );?>">
<input type="checkbox" name="_generate-disable-headline" id="meta-generate-disable-headline" value="true" <?php checked( $stored_meta['_generate-disable-headline'][0], 'true' ); ?>>
<?php esc_html_e( 'Content Title', 'generatepress' );?>
</label>
<?php if ( ! defined( 'GP_PREMIUM_VERSION' ) ) : ?>
<span style="display:block;padding-top:1em;border-top:1px solid #EFEFEF;">
<a href="<?php echo generate_get_premium_url( 'https://generatepress.com/downloads/generate-disable-elements' ); // WPCS: XSS ok, sanitization ok. ?>" target="_blank"><?php esc_html_e( 'Premium module available', 'generatepress' ); ?></a>
</span>
<?php endif; ?>
</div>
<?php endif; ?>
<?php do_action( 'generate_layout_disable_elements_section', $stored_meta ); ?>
</div>
<?php do_action( 'generate_layout_meta_box_content', $stored_meta ); ?>
</div>
</div>
<?php
}
add_action( 'save_post', 'generate_save_layout_meta_data' );
/**
* Saves the sidebar layout meta data.
*
* @since 2.0
*
* @param int Post ID.
*/
function generate_save_layout_meta_data( $post_id ) {
$is_autosave = wp_is_post_autosave( $post_id );
$is_revision = wp_is_post_revision( $post_id );
$is_valid_nonce = ( isset( $_POST['generate_layout_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['generate_layout_nonce'] ), basename( __FILE__ ) ) ) ? true : false;
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
return;
}
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return $post_id;
}
$sidebar_layout_key = '_generate-sidebar-layout-meta';
$sidebar_layout_value = filter_input( INPUT_POST, $sidebar_layout_key, FILTER_SANITIZE_STRING );
if ( $sidebar_layout_value ) {
update_post_meta( $post_id, $sidebar_layout_key, $sidebar_layout_value );
} else {
delete_post_meta( $post_id, $sidebar_layout_key );
}
$footer_widget_key = '_generate-footer-widget-meta';
$footer_widget_value = filter_input( INPUT_POST, $footer_widget_key, FILTER_SANITIZE_STRING );
// Check for empty string to allow 0 as a value.
if ( '' !== $footer_widget_value ) {
update_post_meta( $post_id, $footer_widget_key, $footer_widget_value );
} else {
delete_post_meta( $post_id, $footer_widget_key );
}
$page_builder_container_key = '_generate-full-width-content';
$page_builder_container_value = filter_input( INPUT_POST, $page_builder_container_key, FILTER_SANITIZE_STRING );
if ( $page_builder_container_value ) {
update_post_meta( $post_id, $page_builder_container_key, $page_builder_container_value );
} else {
delete_post_meta( $post_id, $page_builder_container_key );
}
// We only need this if the Disable Elements module doesn't exist
if ( ! defined( 'GENERATE_DE_VERSION' ) ) {
$disable_content_title_key = '_generate-disable-headline';
$disable_content_title_value = filter_input( INPUT_POST, $disable_content_title_key, FILTER_SANITIZE_STRING );
if ( $disable_content_title_value ) {
update_post_meta( $post_id, $disable_content_title_key, $disable_content_title_value );
} else {
delete_post_meta( $post_id, $disable_content_title_key );
}
}
do_action( 'generate_layout_meta_box_save', $post_id );
}

View File

@ -0,0 +1,341 @@
<?php
/**
* Migrates old options on update.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
add_action( 'admin_init', 'generate_do_admin_db_updates' );
/**
* Process database updates if necessary.
* There's nothing in here yet, but we're setting the version to use later.
*
* @since 2.1
*/
function generate_do_admin_db_updates() {
// Get the current version.
$current_version = get_option( 'generate_db_version', false );
// Process future database updates here.
// Set the new database version.
if ( version_compare( $current_version, GENERATE_VERSION, '<' ) ) {
update_option( 'generate_db_version', GENERATE_VERSION, false );
}
}
add_action( 'init', 'generate_do_db_updates', 5 );
/**
* Process important database updates when someone visits the front or backend.
*
* @since 2.3
*/
function generate_do_db_updates() {
$flags = get_option( 'generate_migration_settings', array() );
if ( ! isset( $flags['combine_css'] ) || 'done' !== $flags['combine_css'] ) {
if ( ! get_option( 'fresh_site' ) ) {
$settings = get_option( 'generate_settings', array() );
$settings['combine_css'] = false;
update_option( 'generate_settings', $settings );
}
$flags['combine_css'] = 'done';
update_option( 'generate_migration_settings', $flags );
}
}
if ( ! function_exists( 'generate_update_logo_setting' ) ) {
add_action( 'admin_init', 'generate_update_logo_setting' );
/**
* Migrate the old logo database entry to the new custom_logo theme mod (WordPress 4.5)
*
* @since 1.3.29
*/
function generate_update_logo_setting() {
// If we're not running WordPress 4.5, bail.
if ( ! function_exists( 'the_custom_logo' ) ) {
return;
}
// If we already have a custom logo, bail.
if ( get_theme_mod( 'custom_logo' ) ) {
return;
}
// Get our settings.
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_defaults()
);
// Get the old logo value.
$old_value = $generate_settings['logo'];
// If there's no old value, bail.
if ( empty( $old_value ) ) {
return;
}
// We made it this far, that means we have an old logo, and no new logo.
// Let's get the ID from our old value.
$logo = attachment_url_to_postid( $old_value );
// Now let's update the new logo setting with our ID.
if ( is_int( $logo ) ) {
set_theme_mod( 'custom_logo', $logo );
}
// Got our custom logo? Time to delete the old value
if ( get_theme_mod( 'custom_logo' ) ) {
$new_settings['logo'] = '';
$update_settings = wp_parse_args( $new_settings, $generate_settings );
update_option( 'generate_settings', $update_settings );
}
}
}
if ( ! function_exists( 'generate_typography_convert_values' ) ) {
add_action( 'admin_init', 'generate_typography_convert_values' );
/**
* Take the old body font value and strip it of variants
* This should only run once
* @since 1.3.0
*/
function generate_typography_convert_values() {
// Don't run this if Typography add-on is activated
if ( function_exists( 'generate_fonts_customize_register' ) ) {
return;
}
// If we've done this before, bail
if ( 'true' == get_option( 'generate_update_core_typography' ) || 'true' == get_option( 'generate_update_premium_typography' ) ) {
return;
}
// Get all settings
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_default_fonts()
);
// Get our body font family setting
$value = $generate_settings['font_body'];
// Create a new, empty array
$new_settings = array();
// If our value has : in it, and isn't empty
if ( strpos( $value, ':' ) !== false && ! empty( $value ) ) {
// Remove the : and anything past it
$value = current( explode( ':', $value ) );
// Populate our new array with our new, clean value
$new_settings['font_body'] = $value;
}
// Update our options if our new array isn't empty
if ( ! empty( $new_settings ) ) {
$generate_new_typography_settings = wp_parse_args( $new_settings, $generate_settings );
update_option( 'generate_settings', $generate_new_typography_settings );
}
// All done, set an option so we don't go through this again
update_option( 'generate_update_core_typography','true' );
}
}
if ( ! function_exists( 'generate_typography_set_font_data' ) ) {
add_action( 'admin_init', 'generate_typography_set_font_data' );
/**
* This function will check to see if your category and variants are saved
* If not, it will set them for you
* Generally, set_theme_mod isn't best practice, but this is here for migration purposes for a set amount of time only
* Any time a user saves a font in the Customizer from now on, the category and variants are saved as theme_mods, so this function won't be necessary.
*
* @since 1.3.40
*/
function generate_typography_set_font_data() {
// Get our defaults
$defaults = generate_get_default_fonts();
// Get our settings
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
$defaults
);
// We don't need to do this if we're using the default font, as these values have defaults already
if ( $defaults['font_body'] == $generate_settings['font_body'] ) {
return;
}
// Don't need to continue if we're using a system font or our default font
if ( in_array( $generate_settings['font_body'], generate_typography_default_fonts() ) ) {
return;
}
// Don't continue if our category and variants are already set
if ( get_theme_mod( 'font_body_category' ) && get_theme_mod( 'font_body_variants' ) ) {
return;
}
// Get all of our fonts
$fonts = generate_get_all_google_fonts();
// Get the ID from our font
$id = strtolower( str_replace( ' ', '_', $generate_settings['font_body'] ) );
// If the ID doesn't exist within our fonts, we can bail
if ( ! array_key_exists( $id, $fonts ) ) {
return;
}
// Let's grab our category to go with our font
$category = ! empty( $fonts[$id]['category'] ) ? $fonts[$id]['category'] : '';
// Grab all of the variants associated with our font
$variants = $fonts[$id]['variants'];
// Loop through our variants and put them into an array, then turn them into a comma separated list
$output = array();
if ( $variants ) {
foreach ( $variants as $variant ) {
$output[] = $variant;
}
$variants = implode(',', $output);
}
// Set our theme mods with our new settings
if ( '' !== $category ) {
set_theme_mod( 'font_body_category', $category );
}
if ( '' !== $variants ) {
set_theme_mod( 'font_body_variants', $variants );
}
}
}
add_action( 'admin_init', 'generate_migrate_existing_settings', 1 );
/**
* Execute functions after existing sites update.
*
* We check to see if options already exist. If they do, we can assume the user has
* updated the theme, and not installed it from scratch.
*
* We run this right away in the Dashboard to avoid other migration functions from
* setting options and causing these functions to run on fresh installs.
*
* @since 2.0
*/
function generate_migrate_existing_settings() {
// Existing settings with no defaults.
$existing_settings = get_option( 'generate_settings' );
if ( get_theme_mod( 'font_body_variants', '' ) ) {
$existing_settings['font_body_variants'] = get_theme_mod( 'font_body_variants' );
}
if ( get_theme_mod( 'font_body_category', '' ) ) {
$existing_settings['font_body_category'] = get_theme_mod( 'font_body_category' );
}
// Existing settings with defaults.
$settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_defaults()
);
// Empty arrays to add data to.
$migrated_flags = array();
$new_settings = array();
// An option to see what we've migrated.
$migration_settings = get_option( 'generate_migration_settings', array() );
// We have settings, so this isn't a fresh install.
if ( ! empty( $existing_settings ) ) {
// Turn on the full Font Awesome library for existing websites.
if ( ! isset( $migration_settings['font_awesome_essentials_updated'] ) || 'true' !== $migration_settings['font_awesome_essentials_updated'] ) {
$new_settings['font_awesome_essentials'] = false;
}
// Turn off dynamic CSS caching for existing websites.
if ( ! isset( $migration_settings['skip_dynamic_css_cache'] ) || 'true' !== $migration_settings['skip_dynamic_css_cache'] ) {
$new_settings['dynamic_css_cache'] = false;
}
// Set our font family to Open Sans if we never saved a different font.
if ( ! isset( $migration_settings['default_font_updated'] ) || 'true' !== $migration_settings['default_font_updated'] ) {
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
array(
'font_body' => 'Open Sans',
)
);
$category = get_theme_mod( 'font_body_category', 'sans-serif' );
$variants = get_theme_mod( 'font_body_variants', '300,300italic,regular,italic,600,600italic,700,700italic,800,800italic' );
if ( 'Open Sans' == $generate_settings['font_body'] ) {
$new_settings['font_body'] = 'Open Sans';
set_theme_mod( 'font_body_category', $category );
set_theme_mod( 'font_body_variants', $variants );
}
}
// Set blog post content to full content if it hasn't been set otherwise.
if ( ! isset( $migration_settings['blog_post_content_preview'] ) || 'true' !== $migration_settings['blog_post_content_preview'] ) {
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
array(
'post_content' => 'full',
)
);
if ( 'full' === $generate_settings['post_content'] ) {
$new_settings['post_content'] = 'full';
}
}
}
// Set our flags.
if ( ! isset( $migration_settings['font_awesome_essentials_updated'] ) || 'true' !== $migration_settings['font_awesome_essentials_updated'] ) {
$migrated_flags['font_awesome_essentials_updated'] = 'true';
}
if ( ! isset( $migration_settings['skip_dynamic_css_cache'] ) || 'true' !== $migration_settings['skip_dynamic_css_cache'] ) {
$migrated_flags['skip_dynamic_css_cache'] = 'true';
}
if ( ! isset( $migration_settings['default_font_updated'] ) || 'true' !== $migration_settings['default_font_updated'] ) {
$migrated_flags['default_font_updated'] = 'true';
}
if ( ! isset( $migration_settings['blog_post_content_preview'] ) || 'true' !== $migration_settings['blog_post_content_preview'] ) {
$migrated_flags['blog_post_content_preview'] = 'true';
}
// Merge our new settings with our existing settings.
if ( ! empty( $new_settings ) ) {
$update_settings = wp_parse_args( $new_settings, $settings );
update_option( 'generate_settings', $update_settings );
}
// Set our migrated setting flags.
if ( ! empty( $migrated_flags ) ) {
$update_migration_flags = wp_parse_args( $migrated_flags, $migration_settings );
update_option( 'generate_migration_settings', $update_migration_flags );
}
}

View File

@ -0,0 +1,268 @@
<?php
/**
* Add compatibility for some popular third party plugins.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
add_action( 'after_setup_theme', 'generate_setup_woocommerce' );
/**
* Set up WooCommerce
*
* @since 1.3.47
*/
function generate_setup_woocommerce() {
if ( ! class_exists( 'WooCommerce' ) ) {
return;
}
// Add support for WC features.
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
// Remove default WooCommerce wrappers.
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
add_action( 'woocommerce_sidebar', 'generate_construct_sidebars' );
}
if ( ! function_exists( 'generate_woocommerce_start' ) ) {
add_action( 'woocommerce_before_main_content', 'generate_woocommerce_start', 10 );
/**
* Add WooCommerce starting wrappers
*
* @since 1.3.22
*/
function generate_woocommerce_start() {
?>
<div id="primary" <?php generate_do_element_classes( 'content' );?>>
<main id="main" <?php generate_do_element_classes( 'main' ); ?>>
<?php
/**
* generate_before_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_before_main_content' );
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata( 'article' ); ?>>
<div class="inside-article">
<?php
/**
* generate_before_content hook.
*
* @since 0.1
*
* @hooked generate_featured_page_header_inside_single - 10
*/
do_action( 'generate_before_content' );
?>
<div class="entry-content" itemprop="text">
<?php
}
}
if ( ! function_exists( 'generate_woocommerce_end' ) ) {
add_action( 'woocommerce_after_main_content', 'generate_woocommerce_end', 10 );
/**
* Add WooCommerce ending wrappers
*
* @since 1.3.22
*/
function generate_woocommerce_end() {
?>
</div><!-- .entry-content -->
<?php
/**
* generate_after_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_content' );
?>
</div><!-- .inside-article -->
</article><!-- #post-## -->
<?php
/**
* generate_after_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_main_content' );
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
}
}
if ( ! function_exists( 'generate_woocommerce_css' ) ) {
add_action( 'wp_enqueue_scripts', 'generate_woocommerce_css', 100 );
/**
* Add WooCommerce CSS
*
* @since 1.3.45
*/
function generate_woocommerce_css() {
if ( ! class_exists( 'WooCommerce' ) ) {
return;
}
$mobile = generate_get_media_query( 'mobile' );
$css = '.woocommerce .page-header-image-single {
display: none;
}
.woocommerce .entry-content,
.woocommerce .product .entry-summary {
margin-top: 0;
}
.related.products {
clear: both;
}
.checkout-subscribe-prompt.clear {
visibility: visible;
height: initial;
width: initial;
}
@media ' . esc_attr( $mobile ) . ' {
.woocommerce .woocommerce-ordering,
.woocommerce-page .woocommerce-ordering {
float: none;
}
.woocommerce .woocommerce-ordering select {
max-width: 100%;
}
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product,
.woocommerce-page[class*=columns-] ul.products li.product,
.woocommerce[class*=columns-] ul.products li.product {
width: 100%;
float: none;
}
}';
$css = str_replace( array( "\r", "\n", "\t" ), '', $css );
wp_add_inline_style( 'woocommerce-general', $css );
}
}
if ( ! function_exists( 'generate_bbpress_css' ) ) {
add_action( 'wp_enqueue_scripts', 'generate_bbpress_css', 100 );
/**
* Add bbPress CSS
*
* @since 1.3.45
*/
function generate_bbpress_css() {
if ( ! class_exists( 'bbPress' ) ) {
return;
}
$css = '#bbpress-forums ul.bbp-lead-topic,
#bbpress-forums ul.bbp-topics,
#bbpress-forums ul.bbp-forums,
#bbpress-forums ul.bbp-replies,
#bbpress-forums ul.bbp-search-results,
#bbpress-forums,
div.bbp-breadcrumb,
div.bbp-topic-tags {
font-size: inherit;
}
.single-forum #subscription-toggle {
display: block;
margin: 1em 0;
clear: left;
}
#bbpress-forums .bbp-search-form {
margin-bottom: 10px;
}
.bbp-login-form fieldset {
border: 0;
padding: 0;
}';
$css = str_replace( array( "\r", "\n", "\t" ), '', $css );
wp_add_inline_style( 'bbp-default', $css );
}
}
if ( ! function_exists( 'generate_buddypress_css' ) ) {
add_action( 'wp_enqueue_scripts', 'generate_buddypress_css', 100 );
/**
* Add BuddyPress CSS
*
* @since 1.3.45
*/
function generate_buddypress_css() {
if ( ! class_exists( 'BuddyPress' ) ) {
return;
}
$css = '#buddypress form#whats-new-form #whats-new-options[style] {
min-height: 6rem;
overflow: visible;
}';
$css = str_replace( array( "\r", "\n", "\t" ), '', $css );
wp_add_inline_style( 'bp-legacy-css', $css );
}
}
if ( ! function_exists( 'generate_beaver_builder_css' ) ) {
add_action( 'wp_enqueue_scripts', 'generate_beaver_builder_css', 100 );
/**
* Add Beaver Builder CSS
*
* Beaver Builder pages set to no sidebar used to automatically be full width, however
* now that we have the Page Builder Container meta box, we want to give the user
* the option to set the page to full width or contained.
*
* We can't remove this CSS as people who are depending on it will lose their full
* width layout when they update.
*
* So instead, we only apply this CSS to posts older than the date of this update.
*
* @since 1.3.45
*/
function generate_beaver_builder_css() {
// Check is Beaver Builder is active
// If we have the full-width-content class, we don't need to do anything else
if ( in_array( 'fl-builder', get_body_class() ) && ! in_array( 'full-width-content', get_body_class() ) && ! in_array( 'contained-content', get_body_class() ) ) {
global $post;
if ( ! isset( $post ) ) {
return;
}
$compare_date = strtotime( '2017-03-14' );
$post_date = strtotime( $post->post_date );
if ( $post_date < $compare_date ) {
$css = '.fl-builder.no-sidebar .container.grid-container {
max-width: 100%;
}
.fl-builder.one-container.no-sidebar .site-content {
padding:0;
}';
$css = str_replace( array( "\r", "\n", "\t" ), '', $css );
wp_add_inline_style( 'generate-style', $css );
}
}
}
}

View File

@ -0,0 +1,116 @@
<?php
/**
* Archive elements.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! function_exists( 'generate_archive_title' ) ) {
add_action( 'generate_archive_title', 'generate_archive_title' );
/**
* Build the archive title
*
* @since 1.3.24
*/
function generate_archive_title() {
if ( ! function_exists( 'the_archive_title' ) ) {
return;
}
$clearfix = is_author() ? ' clearfix' : '';
?>
<header class="page-header<?php echo $clearfix; // WPCS: XSS ok, sanitization ok. ?>">
<?php
/**
* generate_before_archive_title hook.
*
* @since 0.1
*/
do_action( 'generate_before_archive_title' );
?>
<h1 class="page-title">
<?php the_archive_title(); ?>
</h1>
<?php
/**
* generate_after_archive_title hook.
*
* @since 0.1
*
* @hooked generate_do_archive_description - 10
*/
do_action( 'generate_after_archive_title' );
?>
</header><!-- .page-header -->
<?php
}
}
if ( ! function_exists( 'generate_filter_the_archive_title' ) ) {
add_filter( 'get_the_archive_title', 'generate_filter_the_archive_title' );
/**
* Alter the_archive_title() function to match our original archive title function
*
* @since 1.3.45
*
* @param string $title The archive title
* @return string The altered archive title
*/
function generate_filter_the_archive_title( $title ) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
/*
* Queue the first post, that way we know
* what author we're dealing with (if that is the case).
*/
the_post();
$title = sprintf( '%1$s<span class="vcard">%2$s</span>',
get_avatar( get_the_author_meta( 'ID' ), 75 ),
get_the_author()
);
/*
* Since we called the_post() above, we need to
* rewind the loop back to the beginning that way
* we can run the loop properly, in full.
*/
rewind_posts();
}
return $title;
}
}
add_action( 'generate_after_archive_title', 'generate_do_archive_description' );
/**
* Output the archive description.
*
* @since 2.3
*/
function generate_do_archive_description() {
$term_description = term_description();
if ( ! empty( $term_description ) ) {
printf( '<div class="taxonomy-description">%s</div>', $term_description ); // WPCS: XSS ok, sanitization ok.
}
if ( get_the_author_meta( 'description' ) && is_author() ) {
echo '<div class="author-info">' . get_the_author_meta( 'description' ) . '</div>'; // WPCS: XSS ok, sanitization ok.
}
/**
* generate_after_archive_description hook.
*
* @since 0.1
*/
do_action( 'generate_after_archive_description' );
}

View File

@ -0,0 +1,161 @@
<?php
/**
* Comment structure.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! function_exists( 'generate_comment' ) ) {
/**
* Template for comments and pingbacks.
*
* Used as a callback by wp_list_comments() for displaying the comments.
*/
function generate_comment( $comment, $args, $depth ) {
$args['avatar_size'] = apply_filters( 'generate_comment_avatar_size', 50 );
if ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) : ?>
<li id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
<div class="comment-body">
<?php _e( 'Pingback:', 'generatepress' ); // WPCS: XSS OK. ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( 'Edit', 'generatepress' ), '<span class="edit-link">', '</span>' ); ?>
</div>
<?php else : ?>
<li id="comment-<?php comment_ID(); ?>" <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?>>
<article id="div-comment-<?php comment_ID(); ?>" class="comment-body" <?php generate_do_microdata( 'comment-body' ); ?>>
<footer class="comment-meta">
<?php
if ( 0 != $args['avatar_size'] ) {
echo get_avatar( $comment, $args['avatar_size'] );
}
?>
<div class="comment-author-info">
<div class="comment-author vcard" <?php generate_do_microdata( 'comment-author' ); ?>>
<?php printf( '<cite itemprop="name" class="fn">%s</cite>', get_comment_author_link() ); ?>
</div><!-- .comment-author -->
<div class="entry-meta comment-metadata">
<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
<time datetime="<?php comment_time( 'c' ); ?>" itemprop="datePublished">
<?php printf( // WPCS: XSS OK.
/* translators: 1: date, 2: time */
_x( '%1$s at %2$s', '1: date, 2: time', 'generatepress' ),
get_comment_date(),
get_comment_time()
); ?>
</time>
</a>
<?php edit_comment_link( __( 'Edit', 'generatepress' ), '<span class="edit-link">| ', '</span>' ); ?>
</div><!-- .comment-metadata -->
</div><!-- .comment-author-info -->
<?php if ( '0' == $comment->comment_approved ) : ?>
<p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'generatepress' ); // WPCS: XSS OK. ?></p>
<?php endif; ?>
</footer><!-- .comment-meta -->
<div class="comment-content" itemprop="text">
<?php
/**
* generate_before_comment_content hook.
*
* @since 2.4
*
*/
do_action( 'generate_before_comment_text', $comment, $args, $depth );
comment_text();
/**
* generate_after_comment_content hook.
*
* @since 2.4
*
*/
do_action( 'generate_after_comment_text', $comment, $args, $depth );
?>
</div><!-- .comment-content -->
</article><!-- .comment-body -->
<?php
endif;
}
}
add_action( 'generate_after_comment_text', 'generate_do_comment_reply_link', 10, 3 );
/**
* Add our comment reply link after the comment text.
*
* @since 2.4
*/
function generate_do_comment_reply_link( $comment, $args, $depth ) {
comment_reply_link( array_merge( $args, array(
'add_below' => 'div-comment',
'depth' => $depth,
'max_depth' => $args['max_depth'],
'before' => '<span class="reply">',
'after' => '</span>',
) ) );
}
add_filter( 'comment_form_defaults', 'generate_set_comment_form_defaults' );
/**
* Set the default settings for our comments.
*
* @since 2.3
*
* @param array $defaults
* @return array
*/
function generate_set_comment_form_defaults( $defaults ) {
$defaults['comment_field'] = sprintf(
'<p class="comment-form-comment"><label for="comment" class="screen-reader-text">%1$s</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',
esc_html__( 'Comment', 'generatepress' )
);
$defaults['comment_notes_before'] = null;
$defaults['comment_notes_after'] = null;
$defaults['id_form'] = 'commentform';
$defaults['id_submit'] = 'submit';
$defaults['title_reply'] = apply_filters( 'generate_leave_comment', __( 'Leave a Comment', 'generatepress' ) );
$defaults['label_submit'] = apply_filters( 'generate_post_comment', __( 'Post Comment', 'generatepress' ) );
return $defaults;
}
add_filter( 'comment_form_default_fields', 'generate_filter_comment_fields' );
/**
* Customizes the existing comment fields.
*
* @since 2.1.2
* @param array $fields
* @return array
*/
function generate_filter_comment_fields( $fields ) {
$commenter = wp_get_current_commenter();
$fields['author'] = sprintf(
'<label for="author" class="screen-reader-text">%1$s</label><input placeholder="%1$s *" id="author" name="author" type="text" value="%2$s" size="30" />',
esc_html__( 'Name', 'generatepress' ),
esc_attr( $commenter['comment_author'] )
);
$fields['email'] = sprintf(
'<label for="email" class="screen-reader-text">%1$s</label><input placeholder="%1$s *" id="email" name="email" type="email" value="%2$s" size="30" />',
esc_html__( 'Email', 'generatepress' ),
esc_attr( $commenter['comment_author_email'] )
);
$fields['url'] = sprintf(
'<label for="url" class="screen-reader-text">%1$s</label><input placeholder="%1$s" id="url" name="url" type="url" value="%2$s" size="30" />',
esc_html__( 'Website', 'generatepress' ),
esc_attr( $commenter['comment_author_url'] )
);
return $fields;
}

View File

@ -0,0 +1,112 @@
<?php
/**
* Featured image elements.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! function_exists( 'generate_post_image' ) ) {
add_action( 'generate_after_entry_header', 'generate_post_image' );
/**
* Prints the Post Image to post excerpts
*/
function generate_post_image() {
// If there's no featured image, return.
if ( ! has_post_thumbnail() ) {
return;
}
// If we're not on any single post/page or the 404 template, we must be showing excerpts.
if ( ! is_singular() && ! is_404() ) {
echo apply_filters( 'generate_featured_image_output', sprintf( // WPCS: XSS ok.
'<div class="post-image">
%3$s
<a href="%1$s">
%2$s
</a>
</div>',
esc_url( get_permalink() ),
get_the_post_thumbnail(
get_the_ID(),
apply_filters( 'generate_page_header_default_size', 'full' ),
array(
'itemprop' => 'image',
)
),
apply_filters( 'generate_inside_featured_image_output', '' )
) );
}
}
}
if ( ! function_exists( 'generate_featured_page_header_area' ) ) {
/**
* Build the page header.
*
* @since 1.0.7
*
* @param string The featured image container class
*/
function generate_featured_page_header_area( $class ) {
// Don't run the function unless we're on a page it applies to.
if ( ! is_singular() ) {
return;
}
// Don't run the function unless we have a post thumbnail.
if ( ! has_post_thumbnail() ) {
return;
}
?>
<div class="<?php echo esc_attr( $class ); ?> grid-container grid-parent">
<?php the_post_thumbnail(
apply_filters( 'generate_page_header_default_size', 'full' ),
array(
'itemprop' => 'image',
)
); ?>
</div>
<?php
}
}
if ( ! function_exists( 'generate_featured_page_header' ) ) {
add_action( 'generate_after_header', 'generate_featured_page_header', 10 );
/**
* Add page header above content.
*
* @since 1.0.2
*/
function generate_featured_page_header() {
if ( function_exists( 'generate_page_header' ) ) {
return;
}
if ( is_page() ) {
generate_featured_page_header_area( 'page-header-image' );
}
}
}
if ( ! function_exists( 'generate_featured_page_header_inside_single' ) ) {
add_action( 'generate_before_content', 'generate_featured_page_header_inside_single', 10 );
/**
* Add post header inside content.
* Only add to single post.
*
* @since 1.0.7
*/
function generate_featured_page_header_inside_single() {
if ( function_exists( 'generate_page_header' ) ) {
return;
}
if ( is_single() ) {
generate_featured_page_header_area( 'page-header-image-single' );
}
}
}

View File

@ -0,0 +1,224 @@
<?php
/**
* Footer elements.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! function_exists( 'generate_construct_footer' ) ) {
add_action( 'generate_footer', 'generate_construct_footer' );
/**
* Build our footer.
*
* @since 1.3.42
*/
function generate_construct_footer() {
?>
<footer class="site-info" <?php generate_do_microdata( 'footer' ); ?>>
<div class="inside-site-info <?php if ( 'full-width' !== generate_get_option( 'footer_inner_width' ) ) : ?>grid-container grid-parent<?php endif; ?>">
<?php
/**
* generate_before_copyright hook.
*
* @since 0.1
*
* @hooked generate_footer_bar - 15
*/
do_action( 'generate_before_copyright' );
?>
<div class="copyright-bar">
<?php
/**
* generate_credits hook.
*
* @since 0.1
*
* @hooked generate_add_footer_info - 10
*/
do_action( 'generate_credits' );
?>
</div>
</div>
</footer><!-- .site-info -->
<?php
}
}
if ( ! function_exists( 'generate_footer_bar' ) ) {
add_action( 'generate_before_copyright', 'generate_footer_bar', 15 );
/**
* Build our footer bar
*
* @since 1.3.42
*/
function generate_footer_bar() {
if ( ! is_active_sidebar( 'footer-bar' ) ) {
return;
}
?>
<div class="footer-bar">
<?php dynamic_sidebar( 'footer-bar' ); ?>
</div>
<?php
}
}
if ( ! function_exists( 'generate_add_footer_info' ) ) {
add_action( 'generate_credits', 'generate_add_footer_info' );
/**
* Add the copyright to the footer
*
* @since 0.1
*/
function generate_add_footer_info() {
$copyright = sprintf( '<span class="copyright">&copy; %1$s %2$s</span> &bull; %4$s <a href="%3$s" itemprop="url">%5$s</a>',
date( 'Y' ),
get_bloginfo( 'name' ),
esc_url( 'https://generatepress.com' ),
_x( 'Powered by', 'GeneratePress', 'generatepress' ),
__( 'GeneratePress', 'generatepress' )
);
echo apply_filters( 'generate_copyright', $copyright ); // WPCS: XSS ok.
}
}
/**
* Build our individual footer widgets.
* Displays a sample widget if no widget is found in the area.
*
* @since 2.0
*
* @param int $widget_width The width class of our widget.
* @param int $widget The ID of our widget.
*/
function generate_do_footer_widget( $widget_width, $widget ) {
$widget_width = apply_filters( "generate_footer_widget_{$widget}_width", $widget_width );
$tablet_widget_width = apply_filters( "generate_footer_widget_{$widget}_tablet_width", '50' );
?>
<div class="footer-widget-<?php echo absint( $widget ); ?> grid-parent grid-<?php echo absint( $widget_width ); ?> tablet-grid-<?php echo absint( $tablet_widget_width ); ?> mobile-grid-100">
<?php dynamic_sidebar( 'footer-' . absint( $widget ) ); ?>
</div>
<?php
}
if ( ! function_exists( 'generate_construct_footer_widgets' ) ) {
add_action( 'generate_footer', 'generate_construct_footer_widgets', 5 );
/**
* Build our footer widgets.
*
* @since 1.3.42
*/
function generate_construct_footer_widgets() {
// Get how many widgets to show.
$widgets = generate_get_footer_widgets();
if ( ! empty( $widgets ) && 0 !== $widgets ) :
// If no footer widgets exist, we don't need to continue.
if (
! is_active_sidebar( 'footer-1' ) &&
! is_active_sidebar( 'footer-2' ) &&
! is_active_sidebar( 'footer-3' ) &&
! is_active_sidebar( 'footer-4' ) &&
! is_active_sidebar( 'footer-5' ) )
{
return;
}
// Set up the widget width.
$widget_width = '';
if ( $widgets == 1 ) {
$widget_width = '100';
}
if ( $widgets == 2 ) {
$widget_width = '50';
}
if ( $widgets == 3 ) {
$widget_width = '33';
}
if ( $widgets == 4 ) {
$widget_width = '25';
}
if ( $widgets == 5 ) {
$widget_width = '20';
}
?>
<div id="footer-widgets" class="site footer-widgets">
<div <?php generate_do_element_classes( 'inside_footer' ); ?>>
<div class="inside-footer-widgets">
<?php
if ( $widgets >= 1 ) {
generate_do_footer_widget( $widget_width, 1 );
}
if ( $widgets >= 2 ) {
generate_do_footer_widget( $widget_width, 2 );
}
if ( $widgets >= 3 ) {
generate_do_footer_widget( $widget_width, 3 );
}
if ( $widgets >= 4 ) {
generate_do_footer_widget( $widget_width, 4 );
}
if ( $widgets >= 5 ) {
generate_do_footer_widget( $widget_width, 5 );
}
?>
</div>
</div>
</div>
<?php
endif;
/**
* generate_after_footer_widgets hook.
*
* @since 0.1
*/
do_action( 'generate_after_footer_widgets' );
}
}
if ( ! function_exists( 'generate_back_to_top' ) ) {
add_action( 'generate_after_footer', 'generate_back_to_top' );
/**
* Build the back to top button
*
* @since 1.3.24
*/
function generate_back_to_top() {
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_defaults()
);
if ( 'enable' !== $generate_settings['back_to_top'] ) {
return;
}
echo apply_filters( 'generate_back_to_top_output', sprintf( // WPCS: XSS ok.
'<a title="%1$s" rel="nofollow" href="#" class="generate-back-to-top" style="opacity:0;visibility:hidden;" data-scroll-speed="%2$s" data-start-scroll="%3$s">
<span class="screen-reader-text">%5$s</span>
%6$s
</a>',
esc_attr__( 'Scroll back to top', 'generatepress' ),
absint( apply_filters( 'generate_back_to_top_scroll_speed', 400 ) ),
absint( apply_filters( 'generate_back_to_top_start_scroll', 300 ) ),
esc_attr( apply_filters( 'generate_back_to_top_icon', 'fa-angle-up' ) ),
esc_html__( 'Scroll back to top', 'generatepress' ),
generate_get_svg_icon( 'arrow' )
) );
}
}

View File

@ -0,0 +1,310 @@
<?php
/**
* Header elements.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! function_exists( 'generate_construct_header' ) ) {
add_action( 'generate_header', 'generate_construct_header' );
/**
* Build the header.
*
* @since 1.3.42
*/
function generate_construct_header() {
?>
<header id="masthead" <?php generate_do_element_classes( 'header' ); ?> <?php generate_do_microdata( 'header' ); ?>>
<div <?php generate_do_element_classes( 'inside_header' ); ?>>
<?php
/**
* generate_before_header_content hook.
*
* @since 0.1
*/
do_action( 'generate_before_header_content' );
// Add our main header items.
generate_header_items();
/**
* generate_after_header_content hook.
*
* @since 0.1
*
* @hooked generate_add_navigation_float_right - 5
*/
do_action( 'generate_after_header_content' );
?>
</div><!-- .inside-header -->
</header><!-- #masthead -->
<?php
}
}
if ( ! function_exists( 'generate_header_items' ) ) {
/**
* Build the header contents.
* Wrapping this into a function allows us to customize the order.
*
* @since 1.2.9.7
*/
function generate_header_items() {
$order = apply_filters( 'generate_header_items_order',
array(
'header-widget',
'site-branding',
'logo',
)
);
foreach ( $order as $item ) {
if ( 'header-widget' === $item ) {
generate_construct_header_widget();
}
if ( 'site-branding' === $item ) {
generate_construct_site_title();
}
if ( 'logo' === $item ) {
generate_construct_logo();
}
}
}
}
if ( ! function_exists( 'generate_construct_logo' ) ) {
/**
* Build the logo
*
* @since 1.3.28
*/
function generate_construct_logo() {
$logo_url = ( function_exists( 'the_custom_logo' ) && get_theme_mod( 'custom_logo' ) ) ? wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' ) : false;
$logo_url = ( $logo_url ) ? $logo_url[0] : generate_get_option( 'logo' );
$logo_url = esc_url( apply_filters( 'generate_logo', $logo_url ) );
$retina_logo_url = esc_url( apply_filters( 'generate_retina_logo', generate_get_option( 'retina_logo' ) ) );
// If we don't have a logo, bail.
if ( empty( $logo_url ) ) {
return;
}
/**
* generate_before_logo hook.
*
* @since 0.1
*/
do_action( 'generate_before_logo' );
$attr = apply_filters( 'generate_logo_attributes', array(
'class' => 'header-image',
'alt' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
'src' => $logo_url,
'title' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
) );
if ( '' !== $retina_logo_url ) {
$attr['srcset'] = $logo_url . ' 1x, ' . $retina_logo_url . ' 2x';
// Add dimensions to image if retina is set. This fixes a container width bug in Firefox.
if ( function_exists( 'the_custom_logo' ) && get_theme_mod( 'custom_logo' ) ) {
$data = wp_get_attachment_metadata( get_theme_mod( 'custom_logo' ) );
if ( ! empty( $data ) ) {
$attr['width'] = $data['width'];
$attr['height'] = $data['height'];
}
}
}
$attr = array_map( 'esc_attr', $attr );
$html_attr = '';
foreach ( $attr as $name => $value ) {
$html_attr .= " $name=" . '"' . $value . '"';
}
// Print our HTML.
echo apply_filters( 'generate_logo_output', sprintf( // WPCS: XSS ok, sanitization ok.
'<div class="site-logo">
<a href="%1$s" title="%2$s" rel="home">
<img %3$s />
</a>
</div>',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
$html_attr
), $logo_url, $html_attr );
/**
* generate_after_logo hook.
*
* @since 0.1
*/
do_action( 'generate_after_logo' );
}
}
if ( ! function_exists( 'generate_construct_site_title' ) ) {
/**
* Build the site title and tagline.
*
* @since 1.3.28
*/
function generate_construct_site_title() {
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_defaults()
);
// Get the title and tagline.
$title = get_bloginfo( 'title' );
$tagline = get_bloginfo( 'description' );
// If the disable title checkbox is checked, or the title field is empty, return true.
$disable_title = ( '1' == $generate_settings['hide_title'] || '' == $title ) ? true : false;
// If the disable tagline checkbox is checked, or the tagline field is empty, return true.
$disable_tagline = ( '1' == $generate_settings['hide_tagline'] || '' == $tagline ) ? true : false;
// Build our site title.
$site_title = apply_filters( 'generate_site_title_output', sprintf(
'<%1$s class="main-title" itemprop="headline">
<a href="%2$s" rel="home">
%3$s
</a>
</%1$s>',
( is_front_page() && is_home() ) ? 'h1' : 'p',
esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
get_bloginfo( 'name' )
) );
// Build our tagline.
$site_tagline = apply_filters( 'generate_site_description_output', sprintf(
'<p class="site-description" itemprop="description">
%1$s
</p>',
html_entity_decode( get_bloginfo( 'description', 'display' ) )
) );
// Site title and tagline.
if ( false == $disable_title || false == $disable_tagline ) {
if ( generate_get_option( 'inline_logo_site_branding' ) && generate_has_logo_site_branding() ) {
echo '<div class="site-branding-container">';
generate_construct_logo();
}
echo apply_filters( 'generate_site_branding_output', sprintf( // WPCS: XSS ok, sanitization ok.
'<div class="site-branding">
%1$s
%2$s
</div>',
( ! $disable_title ) ? $site_title : '',
( ! $disable_tagline ) ? $site_tagline : ''
) );
if ( generate_get_option( 'inline_logo_site_branding' ) && generate_has_logo_site_branding() ) {
echo '</div><!-- .site-branding-container -->';
}
}
}
}
add_filter( 'generate_header_items_order', 'generate_reorder_inline_site_branding' );
/**
* Remove the logo from it's usual position.
*
* @since 2.3
*/
function generate_reorder_inline_site_branding( $order ) {
if ( ! generate_get_option( 'inline_logo_site_branding' ) || ! generate_has_logo_site_branding() ) {
return $order;
}
return array(
'header-widget',
'site-branding',
);
}
if ( ! function_exists( 'generate_construct_header_widget' ) ) {
/**
* Build the header widget.
*
* @since 1.3.28
*/
function generate_construct_header_widget() {
if ( is_active_sidebar( 'header' ) ) : ?>
<div class="header-widget">
<?php dynamic_sidebar( 'header' ); ?>
</div>
<?php endif;
}
}
if ( ! function_exists( 'generate_top_bar' ) ) {
add_action( 'generate_before_header', 'generate_top_bar', 5 );
/**
* Build our top bar.
*
* @since 1.3.45
*/
function generate_top_bar() {
if ( ! is_active_sidebar( 'top-bar' ) ) {
return;
}
?>
<div <?php generate_do_element_classes( 'top_bar' ); ?>>
<div class="inside-top-bar<?php if ( 'contained' == generate_get_option( 'top_bar_inner_width' ) ) echo ' grid-container grid-parent'; ?>">
<?php dynamic_sidebar( 'top-bar' ); ?>
</div>
</div>
<?php
}
}
if ( ! function_exists( 'generate_pingback_header' ) ) {
add_action( 'wp_head', 'generate_pingback_header' );
/**
* Add a pingback url auto-discovery header for singularly identifiable articles.
*
* @since 1.3.42
*/
function generate_pingback_header() {
if ( is_singular() && pings_open() ) {
printf( '<link rel="pingback" href="%s">' . "\n", esc_url( get_bloginfo( 'pingback_url' ) ) );
}
}
}
if ( ! function_exists( 'generate_add_viewport' ) ) {
add_action( 'wp_head', 'generate_add_viewport' );
/**
* Add viewport to wp_head.
*
* @since 1.1.0
*/
function generate_add_viewport() {
echo apply_filters( 'generate_meta_viewport', '<meta name="viewport" content="width=device-width, initial-scale=1">' ); // WPCS: XSS ok.
}
}
add_action( 'generate_before_header', 'generate_do_skip_to_content_link', 2 );
/**
* Add skip to content link before the header.
*
* @since 2.0
*/
function generate_do_skip_to_content_link() {
printf( '<a class="screen-reader-text skip-link" href="#content" title="%1$s">%2$s</a>',
esc_attr__( 'Skip to content', 'generatepress' ),
esc_html__( 'Skip to content', 'generatepress' )
);
}

View File

@ -0,0 +1,397 @@
<?php
/**
* Navigation elements.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! function_exists( 'generate_navigation_position' ) ) {
/**
* Build the navigation.
*
* @since 0.1
*/
function generate_navigation_position() {
?>
<nav id="site-navigation" <?php generate_do_element_classes( 'navigation' ); ?> <?php generate_do_microdata( 'navigation' ); ?>>
<div <?php generate_do_element_classes( 'inside_navigation' ); ?>>
<?php
/**
* generate_inside_navigation hook.
*
* @since 0.1
*
* @hooked generate_navigation_search - 10
* @hooked generate_mobile_menu_search_icon - 10
*/
do_action( 'generate_inside_navigation' );
?>
<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
<?php
/**
* generate_inside_mobile_menu hook.
*
* @since 0.1
*/
do_action( 'generate_inside_mobile_menu' );
generate_do_svg_icon( 'menu-bars', true );
$mobile_menu_label = apply_filters( 'generate_mobile_menu_label', __( 'Menu', 'generatepress' ) );
if ( $mobile_menu_label ) {
printf(
'<span class="mobile-menu">%s</span>',
$mobile_menu_label
);
} else {
printf(
'<span class="screen-reader-text">%s</span>',
__( 'Menu', 'generatepress' )
);
}
?>
</button>
<?php
wp_nav_menu(
array(
'theme_location' => 'primary',
'container' => 'div',
'container_class' => 'main-nav',
'container_id' => 'primary-menu',
'menu_class' => '',
'fallback_cb' => 'generate_menu_fallback',
'items_wrap' => '<ul id="%1$s" class="%2$s ' . join( ' ', generate_get_element_classes( 'menu' ) ) . '">%3$s</ul>',
)
);
/**
* generate_after_primary_menu hook.
*
* @since 2.3
*/
do_action( 'generate_after_primary_menu' );
?>
</div><!-- .inside-navigation -->
</nav><!-- #site-navigation -->
<?php
}
}
if ( ! function_exists( 'generate_menu_fallback' ) ) {
/**
* Menu fallback.
*
* @since 1.1.4
*
* @param array $args
* @return string
*/
function generate_menu_fallback( $args ) {
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_defaults()
);
?>
<div id="primary-menu" class="main-nav">
<ul <?php generate_do_element_classes( 'menu' ); ?>>
<?php
$args = array(
'sort_column' => 'menu_order',
'title_li' => '',
'walker' => new Generate_Page_Walker(),
);
wp_list_pages( $args );
if ( 'enable' === $generate_settings['nav_search'] ) {
printf(
'<li class="search-item"><a aria-label="%1$s" href="#">%2$s</a></li>',
esc_attr__( 'Open Search Bar', 'generatepress' ),
generate_get_svg_icon( 'search', true )
);
}
?>
</ul>
</div><!-- .main-nav -->
<?php
}
}
/**
* Generate the navigation based on settings
*
* It would be better to have all of these inside one action, but these
* are kept this way to maintain backward compatibility for people
* un-hooking and moving the navigation/changing the priority.
*
* @since 0.1
*/
if ( ! function_exists( 'generate_add_navigation_after_header' ) ) {
add_action( 'generate_after_header', 'generate_add_navigation_after_header', 5 );
function generate_add_navigation_after_header() {
if ( 'nav-below-header' == generate_get_navigation_location() ) {
generate_navigation_position();
}
}
}
if ( ! function_exists( 'generate_add_navigation_before_header' ) ) {
add_action( 'generate_before_header', 'generate_add_navigation_before_header', 5 );
function generate_add_navigation_before_header() {
if ( 'nav-above-header' == generate_get_navigation_location() ) {
generate_navigation_position();
}
}
}
if ( ! function_exists( 'generate_add_navigation_float_right' ) ) {
add_action( 'generate_after_header_content', 'generate_add_navigation_float_right', 5 );
function generate_add_navigation_float_right() {
if ( 'nav-float-right' == generate_get_navigation_location() || 'nav-float-left' == generate_get_navigation_location() ) {
generate_navigation_position();
}
}
}
if ( ! function_exists( 'generate_add_navigation_before_right_sidebar' ) ) {
add_action( 'generate_before_right_sidebar_content', 'generate_add_navigation_before_right_sidebar', 5 );
function generate_add_navigation_before_right_sidebar() {
if ( 'nav-right-sidebar' == generate_get_navigation_location() ) {
echo '<div class="gen-sidebar-nav">';
generate_navigation_position();
echo '</div>';
}
}
}
if ( ! function_exists( 'generate_add_navigation_before_left_sidebar' ) ) {
add_action( 'generate_before_left_sidebar_content', 'generate_add_navigation_before_left_sidebar', 5 );
function generate_add_navigation_before_left_sidebar() {
if ( 'nav-left-sidebar' == generate_get_navigation_location() ) {
echo '<div class="gen-sidebar-nav">';
generate_navigation_position();
echo '</div>';
}
}
}
if ( ! class_exists( 'Generate_Page_Walker' ) && class_exists( 'Walker_Page' ) ) {
/**
* Add current-menu-item to the current item if no theme location is set
* This means we don't have to duplicate CSS properties for current_page_item and current-menu-item
*
* @since 1.3.21
*/
class Generate_Page_Walker extends Walker_Page {
function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
$css_class = array( 'page_item', 'page-item-' . $page->ID );
$button = '';
if ( isset( $args['pages_with_children'][ $page->ID ] ) ) {
$css_class[] = 'menu-item-has-children';
$icon = generate_get_svg_icon( 'arrow' );
$button = '<span role="presentation" class="dropdown-menu-toggle">' . $icon . '</span>';
}
if ( ! empty( $current_page ) ) {
$_current_page = get_post( $current_page );
if ( $_current_page && in_array( $page->ID, $_current_page->ancestors ) ) {
$css_class[] = 'current-menu-ancestor';
}
if ( $page->ID == $current_page ) {
$css_class[] = 'current-menu-item';
} elseif ( $_current_page && $page->ID == $_current_page->post_parent ) {
$css_class[] = 'current-menu-parent';
}
} elseif ( $page->ID == get_option( 'page_for_posts' ) ) {
$css_class[] = 'current-menu-parent';
}
$css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
$args['link_before'] = empty( $args['link_before'] ) ? '' : $args['link_before'];
$args['link_after'] = empty( $args['link_after'] ) ? '' : $args['link_after'];
$output .= sprintf(
'<li class="%s"><a href="%s">%s%s%s%s</a>',
$css_classes,
get_permalink( $page->ID ),
$args['link_before'],
apply_filters( 'the_title', $page->post_title, $page->ID ),
$args['link_after'],
$button
);
}
}
}
if ( ! function_exists( 'generate_dropdown_icon_to_menu_link' ) ) {
add_filter( 'nav_menu_item_title', 'generate_dropdown_icon_to_menu_link', 10, 4 );
/**
* Add dropdown icon if menu item has children.
*
* @since 1.3.42
*
* @param string $title The menu item title.
* @param WP_Post $item All of our menu item data.
* @param stdClass $args All of our menu item args.
* @param int $dept Depth of menu item.
* @return string The menu item.
*/
function generate_dropdown_icon_to_menu_link( $title, $item, $args, $depth ) {
$role = 'presentation';
$tabindex = '';
if ( 'click-arrow' === generate_get_option( 'nav_dropdown_type' ) ) {
$role = 'button';
$tabindex = ' tabindex="0"';
}
if ( isset( $args->container_class ) && 'main-nav' === $args->container_class ) {
foreach ( $item->classes as $value ) {
if ( 'menu-item-has-children' === $value ) {
$icon = generate_get_svg_icon( 'arrow' );
$title = $title . '<span role="' . $role . '" class="dropdown-menu-toggle"' . $tabindex . '>' . $icon . '</span>';
}
}
}
return $title;
}
}
if ( ! function_exists( 'generate_navigation_search' ) ) {
add_action( 'generate_inside_navigation', 'generate_navigation_search' );
/**
* Add the search bar to the navigation.
*
* @since 1.1.4
*/
function generate_navigation_search() {
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_defaults()
);
if ( 'enable' !== $generate_settings['nav_search'] ) {
return;
}
echo apply_filters( 'generate_navigation_search_output', sprintf( // WPCS: XSS ok, sanitization ok.
'<form method="get" class="search-form navigation-search" action="%1$s">
<input type="search" class="search-field" value="%2$s" name="s" title="%3$s" />
</form>',
esc_url( home_url( '/' ) ),
esc_attr( get_search_query() ),
esc_attr_x( 'Search', 'label', 'generatepress' )
));
}
}
if ( ! function_exists( 'generate_menu_search_icon' ) ) {
add_filter( 'wp_nav_menu_items', 'generate_menu_search_icon', 10, 2 );
/**
* Add search icon to primary menu if set
*
* @since 1.2.9.7
*
* @param string $nav The HTML list content for the menu items.
* @param stdClass $args An object containing wp_nav_menu() arguments.
* @return string The search icon menu item.
*/
function generate_menu_search_icon( $nav, $args ) {
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_defaults()
);
// If the search icon isn't enabled, return the regular nav.
if ( 'enable' !== $generate_settings['nav_search'] ) {
return $nav;
}
// If our primary menu is set, add the search icon.
if ( isset( $args->theme_location ) && 'primary' === $args->theme_location ) {
return sprintf(
'%1$s<li class="search-item"><a aria-label="%2$s" href="#">%3$s</a></li>',
$nav,
esc_attr__( 'Open Search Bar', 'generatepress' ),
generate_get_svg_icon( 'search', true )
);
}
// Our primary menu isn't set, return the regular nav.
// In this case, the search icon is added to the generate_menu_fallback() function in navigation.php.
return $nav;
}
}
if ( ! function_exists( 'generate_mobile_menu_search_icon' ) ) {
add_action( 'generate_inside_navigation', 'generate_mobile_menu_search_icon' );
/**
* Add search icon to mobile menu bar
*
* @since 1.3.12
*/
function generate_mobile_menu_search_icon() {
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_defaults()
);
// If the search icon isn't enabled, return the regular nav.
if ( 'enable' !== $generate_settings['nav_search'] ) {
return;
}
?>
<div class="mobile-bar-items">
<?php do_action( 'generate_inside_mobile_menu_bar' ); ?>
<span class="search-item">
<a aria-label="<?php _e( 'Open Search Bar', 'generatepress' ); ?>" href="#">
<?php generate_do_svg_icon( 'search', true ); ?>
</a>
</span>
</div><!-- .mobile-bar-items -->
<?php
}
}
add_action( 'wp_footer', 'generate_clone_sidebar_navigation' );
/**
* Clone our sidebar navigation and place it below the header.
* This places our mobile menu in a more user-friendly location.
*
* We're not using wp_add_inline_script() as this needs to happens
* before menu.js is enqueued.
*
* @since 2.0
*/
function generate_clone_sidebar_navigation() {
if ( 'nav-left-sidebar' !== generate_get_navigation_location() && 'nav-right-sidebar' !== generate_get_navigation_location() ) {
return;
}
?>
<script>
var target, nav, clone;
nav = document.getElementById( 'site-navigation' );
if ( nav ) {
clone = nav.cloneNode( true );
clone.className += ' sidebar-nav-mobile';
clone.setAttribute( 'aria-label', '<?php esc_attr_e( 'Mobile Menu', 'generatepress' ); ?>' );
target = document.getElementById( 'masthead' );
if ( target ) {
target.insertAdjacentHTML( 'afterend', clone.outerHTML );
} else {
document.body.insertAdjacentHTML( 'afterbegin', clone.outerHTML )
}
}
</script>
<?php
}

View File

@ -0,0 +1,388 @@
<?php
/**
* Post meta elements.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! function_exists( 'generate_content_nav' ) ) {
/**
* Display navigation to next/previous pages when applicable.
*
* @since 0.1
*
* @param string $nav_id The id of our navigation.
*/
function generate_content_nav( $nav_id ) {
if ( ! apply_filters( 'generate_show_post_navigation', true ) ) {
return;
}
global $wp_query, $post;
// Don't print empty markup on single pages if there's nowhere to navigate.
if ( is_single() ) {
$previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( ! $next && ! $previous ) {
return;
}
}
// Don't print empty markup in archives if there's only one page.
if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) ) {
return;
}
$nav_class = ( is_single() ) ? 'post-navigation' : 'paging-navigation';
?>
<nav id="<?php echo esc_attr( $nav_id ); ?>" class="<?php echo esc_attr( $nav_class ); ?>">
<span class="screen-reader-text"><?php esc_html_e( 'Post navigation', 'generatepress' ); ?></span>
<?php if ( is_single() ) : // navigation links for single posts.
$post_navigation_args = apply_filters( 'generate_post_navigation_args', array(
'previous_format' => '<div class="nav-previous">' . generate_get_svg_icon( 'arrow' ) . '<span class="prev" title="' . esc_attr__( 'Previous', 'generatepress' ) . '">%link</span></div>',
'next_format' => '<div class="nav-next">' . generate_get_svg_icon( 'arrow' ) . '<span class="next" title="' . esc_attr__( 'Next', 'generatepress' ) . '">%link</span></div>',
'link' => '%title',
'in_same_term' => apply_filters( 'generate_category_post_navigation', false ),
'excluded_terms' => '',
'taxonomy' => 'category',
) );
previous_post_link(
$post_navigation_args['previous_format'],
$post_navigation_args['link'],
$post_navigation_args['in_same_term'],
$post_navigation_args['excluded_terms'],
$post_navigation_args['taxonomy']
);
next_post_link(
$post_navigation_args['next_format'],
$post_navigation_args['link'],
$post_navigation_args['in_same_term'],
$post_navigation_args['excluded_terms'],
$post_navigation_args['taxonomy']
);
elseif ( is_home() || is_archive() || is_search() ) : // navigation links for home, archive, and search pages.
if ( get_next_posts_link() ) : ?>
<div class="nav-previous">
<?php generate_do_svg_icon( 'arrow' ); ?>
<span class="prev" title="<?php esc_attr_e( 'Previous', 'generatepress' );?>"><?php next_posts_link( __( 'Older posts', 'generatepress' ) ); ?></span>
</div>
<?php endif;
if ( get_previous_posts_link() ) : ?>
<div class="nav-next">
<?php generate_do_svg_icon( 'arrow' ); ?>
<span class="next" title="<?php esc_attr_e( 'Next', 'generatepress' );?>"><?php previous_posts_link( __( 'Newer posts', 'generatepress' ) ); ?></span>
</div>
<?php endif;
if ( function_exists( 'the_posts_pagination' ) ) {
the_posts_pagination( array(
'mid_size' => apply_filters( 'generate_pagination_mid_size', 1 ),
'prev_text' => apply_filters( 'generate_previous_link_text', __( '&larr; Previous', 'generatepress' ) ),
'next_text' => apply_filters( 'generate_next_link_text', __( 'Next &rarr;', 'generatepress' ) ),
) );
}
/**
* generate_paging_navigation hook.
*
* @since 0.1
*/
do_action( 'generate_paging_navigation' );
endif; ?>
</nav><!-- #<?php echo esc_html( $nav_id ); ?> -->
<?php
}
}
if ( ! function_exists( 'generate_modify_posts_pagination_template' ) ) {
add_filter( 'navigation_markup_template', 'generate_modify_posts_pagination_template', 10, 2 );
/**
* Remove the container and screen reader text from the_posts_pagination()
* We add this in ourselves in generate_content_nav()
*
* @since 1.3.45
*
* @param string $template The default template.
* @param string $class The class passed by the calling function.
* @return string The HTML for the post navigation.
*/
function generate_modify_posts_pagination_template( $template, $class ) {
if ( ! empty( $class ) && false !== strpos( $class, 'pagination' ) ) {
$template = '<div class="nav-links">%3$s</div>';
}
return $template;
}
}
/**
* Output requested post meta.
*
* @since 2.3
*
* @param string $item The post meta item we're requesting
* @return The requested HTML.
*/
function generate_do_post_meta_item( $item ) {
if ( 'date' === $item ) {
$date = apply_filters( 'generate_post_date', true );
$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time>' . $time_string;
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
// If our date is enabled, show it.
if ( $date ) {
echo apply_filters( 'generate_post_date_output',
sprintf( // WPCS: XSS ok, sanitization ok.
'<span class="posted-on">%1$s<a href="%2$s" title="%3$s" rel="bookmark">%4$s</a></span> ',
apply_filters( 'generate_inside_post_meta_item_output', '', 'date' ),
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
$time_string
),
$time_string );
}
}
if ( 'author' === $item ) {
$author = apply_filters( 'generate_post_author', true );
if ( $author ) {
echo apply_filters( 'generate_post_author_output',
sprintf( '<span class="byline">%1$s<span class="author vcard" %5$s><a class="url fn n" href="%2$s" title="%3$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%4$s</span></a></span></span> ',
apply_filters( 'generate_inside_post_meta_item_output', '', 'author' ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
/* translators: 1: Author name */
esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
esc_html( get_the_author() ),
generate_get_microdata( 'post-author' )
)
);
}
}
if ( 'categories' === $item ) {
$categories = apply_filters( 'generate_show_categories', true );
$term_separator = apply_filters( 'generate_term_separator', _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ), 'categories' );
$categories_list = get_the_category_list( $term_separator );
if ( $categories_list && $categories ) {
echo apply_filters( 'generate_category_list_output',
sprintf( '<span class="cat-links">%3$s<span class="screen-reader-text">%1$s </span>%2$s</span> ', // WPCS: XSS ok, sanitization ok.
esc_html_x( 'Categories', 'Used before category names.', 'generatepress' ),
$categories_list,
apply_filters( 'generate_inside_post_meta_item_output', '', 'categories' )
)
);
}
}
if ( 'tags' === $item ) {
$tags = apply_filters( 'generate_show_tags', true );
$term_separator = apply_filters( 'generate_term_separator', _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ), 'tags' );
$tags_list = get_the_tag_list( '', $term_separator );
if ( $tags_list && $tags ) {
echo apply_filters( 'generate_tag_list_output',
sprintf( '<span class="tags-links">%3$s<span class="screen-reader-text">%1$s </span>%2$s</span> ', // WPCS: XSS ok, sanitization ok.
esc_html_x( 'Tags', 'Used before tag names.', 'generatepress' ),
$tags_list,
apply_filters( 'generate_inside_post_meta_item_output', '', 'tags' )
)
);
}
}
if ( 'comments-link' === $item ) {
$comments = apply_filters( 'generate_show_comments', true );
if ( $comments && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '<span class="comments-link">';
echo apply_filters( 'generate_inside_post_meta_item_output', '', 'comments-link' );
comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
echo '</span> ';
}
}
/**
* generate_post_meta_items hook.
*
* @since 2.4
*/
do_action( 'generate_post_meta_items', $item );
}
add_filter( 'generate_inside_post_meta_item_output', 'generate_do_post_meta_prefix', 10, 2 );
/**
* Add svg icons or text to our post meta output.
*
* @since 2.4
*/
function generate_do_post_meta_prefix( $output, $item ) {
if ( 'author' === $item ) {
$output = __( 'by', 'generatepress' ) . ' ';
}
if ( 'categories' === $item ) {
$output = generate_get_svg_icon( 'categories' );
}
if ( 'tags' === $item ) {
$output = generate_get_svg_icon( 'tags' );
}
if ( 'comments-link' === $item ) {
$output = generate_get_svg_icon( 'comments' );
}
return $output;
}
if ( ! function_exists( 'generate_posted_on' ) ) {
/**
* Prints HTML with meta information for the current post-date/time and author.
*
* @since 0.1
*/
function generate_posted_on() {
$items = apply_filters( 'generate_header_entry_meta_items', array(
'date',
'author',
) );
foreach ( $items as $item ) {
generate_do_post_meta_item( $item );
}
}
}
if ( ! function_exists( 'generate_entry_meta' ) ) {
/**
* Prints HTML with meta information for the categories, tags.
*
* @since 1.2.5
*/
function generate_entry_meta() {
$items = apply_filters( 'generate_footer_entry_meta_items', array(
'categories',
'tags',
'comments-link',
) );
foreach ( $items as $item ) {
generate_do_post_meta_item( $item );
}
}
}
if ( ! function_exists( 'generate_excerpt_more' ) ) {
add_filter( 'excerpt_more', 'generate_excerpt_more' );
/**
* Prints the read more HTML to post excerpts.
*
* @since 0.1
*
* @param string $more The string shown within the more link.
* @return string The HTML for the more link.
*/
function generate_excerpt_more( $more ) {
return apply_filters( 'generate_excerpt_more_output', sprintf( ' ... <a title="%1$s" class="read-more" href="%2$s">%3$s %4$s</a>',
the_title_attribute( 'echo=0' ),
esc_url( get_permalink( get_the_ID() ) ),
__( 'Read more', 'generatepress' ),
'<span class="screen-reader-text">' . get_the_title() . '</span>'
) );
}
}
if ( ! function_exists( 'generate_content_more' ) ) {
add_filter( 'the_content_more_link', 'generate_content_more' );
/**
* Prints the read more HTML to post content using the more tag.
*
* @since 0.1
*
* @param string $more The string shown within the more link.
* @return string The HTML for the more link
*/
function generate_content_more( $more ) {
return apply_filters( 'generate_content_more_link_output', sprintf( '<p class="read-more-container"><a title="%1$s" class="read-more content-read-more" href="%2$s">%3$s%4$s</a></p>',
the_title_attribute( 'echo=0' ),
esc_url( get_permalink( get_the_ID() ) . apply_filters( 'generate_more_jump','#more-' . get_the_ID() ) ),
__( 'Read more', 'generatepress' ),
'<span class="screen-reader-text">' . get_the_title() . '</span>'
) );
}
}
if ( ! function_exists( 'generate_post_meta' ) ) {
add_action( 'generate_after_entry_title', 'generate_post_meta' );
/**
* Build the post meta.
*
* @since 1.3.29
*/
function generate_post_meta() {
$post_types = apply_filters( 'generate_entry_meta_post_types', array(
'post',
) );
if ( in_array( get_post_type(), $post_types ) ) : ?>
<div class="entry-meta">
<?php generate_posted_on(); ?>
</div><!-- .entry-meta -->
<?php endif;
}
}
if ( ! function_exists( 'generate_footer_meta' ) ) {
add_action( 'generate_after_entry_content', 'generate_footer_meta' );
/**
* Build the footer post meta.
*
* @since 1.3.30
*/
function generate_footer_meta() {
$post_types = apply_filters( 'generate_footer_meta_post_types', array(
'post',
) );
if ( in_array( get_post_type(), $post_types ) ) : ?>
<footer class="entry-meta">
<?php
generate_entry_meta();
if ( is_single() ) {
generate_content_nav( 'nav-below' );
}
?>
</footer><!-- .entry-meta -->
<?php endif;
}
}

View File

@ -0,0 +1,83 @@
<?php
/**
* Build the sidebars.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! function_exists( 'generate_construct_sidebars' ) ) {
/**
* Construct the sidebars.
*
* @since 0.1
*/
function generate_construct_sidebars() {
$layout = generate_get_layout();
// When to show the right sidebar.
$rs = array( 'right-sidebar', 'both-sidebars', 'both-right', 'both-left' );
// When to show the left sidebar.
$ls = array( 'left-sidebar', 'both-sidebars', 'both-right', 'both-left' );
// If left sidebar, show it.
if ( in_array( $layout, $ls ) ) {
get_sidebar( 'left' );
}
// If right sidebar, show it.
if ( in_array( $layout, $rs ) ) {
get_sidebar();
}
}
/**
* The below hook was removed in 2.0, but we'll keep the call here so child themes
* don't lose their sidebar when they update the theme.
*/
add_action( 'generate_sidebars', 'generate_construct_sidebars' );
}
/**
* Show sidebar widgets if no widgets are added to the sidebar area.
*
* @since 2.2
*
* @param string $area Left or right sidebar.
*/
function generate_do_default_sidebar_widgets( $area ) {
if ( 'nav-' . $area === generate_get_navigation_location() ) {
return;
}
if ( function_exists( 'generate_secondary_nav_get_defaults' ) ) {
$secondary_nav = wp_parse_args(
get_option( 'generate_secondary_nav_settings', array() ),
generate_secondary_nav_get_defaults()
);
if ( 'secondary-nav-' . $area === $secondary_nav['secondary_nav_position_setting'] ) {
return;
}
}
if ( ! apply_filters( 'generate_show_default_sidebar_widgets', true ) ) {
return;
}
?>
<aside id="search" class="widget widget_search">
<?php get_search_form(); ?>
</aside>
<aside id="archives" class="widget">
<h2 class="widget-title"><?php esc_html_e( 'Archives', 'generatepress' ); ?></h2>
<ul>
<?php wp_get_archives( array( 'type' => 'monthly' ) ); ?>
</ul>
</aside>
<?php
}

View File

@ -0,0 +1,343 @@
<?php
/**
* Main theme functions.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* A wrapper function to get our options.
*
* @since 2.2
*
* @param string $option The option name to look up.
* @return string The option value.
*/
function generate_get_option( $option ) {
$defaults = generate_get_defaults();
if ( ! isset( $defaults[ $option ] ) ) {
return;
}
$options = wp_parse_args(
get_option( 'generate_settings', array() ),
$defaults
);
return $options[ $option ];
}
if ( ! function_exists( 'generate_get_layout' ) ) {
/**
* Get the layout for the current page.
*
* @since 0.1
*
* @return string The sidebar layout location.
*/
function generate_get_layout() {
$layout = generate_get_option( 'layout_setting' );
if ( is_single() ) {
$layout = generate_get_option( 'single_layout_setting' );
}
if ( is_singular() ) {
$layout_meta = get_post_meta( get_the_ID(), '_generate-sidebar-layout-meta', true );
if ( $layout_meta ) {
$layout = $layout_meta;
}
}
if ( is_home() || is_archive() || is_search() || is_tax() ) {
$layout = generate_get_option( 'blog_layout_setting' );
}
return apply_filters( 'generate_sidebar_layout', $layout );
}
}
if ( ! function_exists( 'generate_get_footer_widgets' ) ) {
/**
* Get the footer widgets for the current page
*
* @since 0.1
*
* @return int The number of footer widgets.
*/
function generate_get_footer_widgets() {
$widgets = generate_get_option( 'footer_widget_setting' );
if ( is_singular() ) {
$widgets_meta = get_post_meta( get_the_ID(), '_generate-footer-widget-meta', true );
if ( $widgets_meta || '0' === $widgets_meta ) {
$widgets = $widgets_meta;
}
}
return apply_filters( 'generate_footer_widgets', $widgets );
}
}
if ( ! function_exists( 'generate_show_excerpt' ) ) {
/**
* Figure out if we should show the blog excerpts or full posts
* @since 1.3.15
*/
function generate_show_excerpt() {
global $post;
// Check to see if the more tag is being used.
$more_tag = apply_filters( 'generate_more_tag', strpos( $post->post_content, '<!--more-->' ) );
$format = ( false !== get_post_format() ) ? get_post_format() : 'standard';
$show_excerpt = ( 'excerpt' === generate_get_option( 'post_content' ) ) ? true : false;
$show_excerpt = ( 'standard' !== $format ) ? false : $show_excerpt;
$show_excerpt = ( $more_tag ) ? false : $show_excerpt;
$show_excerpt = ( is_search() ) ? true : $show_excerpt;
return apply_filters( 'generate_show_excerpt', $show_excerpt );
}
}
if ( ! function_exists( 'generate_show_title' ) ) {
/**
* Check to see if we should show our page/post title or not.
*
* @since 1.3.18
*
* @return bool Whether to show the content title.
*/
function generate_show_title() {
return apply_filters( 'generate_show_title', true );
}
}
if ( ! function_exists( 'generate_get_premium_url' ) ) {
/**
* Generate a URL to our premium add-ons.
* Allows the use of a referral ID and campaign.
*
* @since 1.3.42
*
* @param string $url URL to premium page.
* @param bool $trailing_slash Whether we want to include a trailing slash.
* @return string The URL to generatepress.com.
*/
function generate_get_premium_url( $url = 'https://generatepress.com/premium', $trailing_slash = true ) {
if ( $trailing_slash ) {
$url = trailingslashit( $url );
}
$args = apply_filters( 'generate_premium_url_args', array(
'ref' => null,
'campaign' => null,
) );
if ( isset( $args['ref'] ) ) {
$url = add_query_arg( 'ref', absint( $args['ref'] ), $url );
}
if ( isset( $args['campaign'] ) ) {
$url = add_query_arg( 'campaign', sanitize_text_field( $args['campaign'] ), $url );
}
return esc_url( $url );
}
}
if ( ! function_exists( 'generate_padding_css' ) ) {
/**
* Shorten our padding/margin values into shorthand form.
*
* @since 0.1
*
* @param int $top Top spacing.
* @param int $right Right spacing.
* @param int $bottom Bottom spacing.
* @param int $left Left spacing.
* @return string Element spacing values.
*/
function generate_padding_css( $top, $right, $bottom, $left ) {
$padding_top = ( isset( $top ) && '' !== $top ) ? absint( $top ) . 'px ' : '0px ';
$padding_right = ( isset( $right ) && '' !== $right ) ? absint( $right ) . 'px ' : '0px ';
$padding_bottom = ( isset( $bottom ) && '' !== $bottom ) ? absint( $bottom ) . 'px ' : '0px ';
$padding_left = ( isset( $left ) && '' !== $left ) ? absint( $left ) . 'px' : '0px';
if ( ( absint( $padding_top ) === absint( $padding_right ) ) && ( absint( $padding_right ) === absint( $padding_bottom ) ) && ( absint( $padding_bottom ) === absint( $padding_left ) ) ) {
return $padding_left;
}
return $padding_top . $padding_right . $padding_bottom . $padding_left;
}
}
if ( ! function_exists( 'generate_get_link_url' ) ) {
/**
* Return the post URL.
*
* Falls back to the post permalink if no URL is found in the post.
*
* @since 1.2.5
*
* @see get_url_in_content()
* @return string The Link format URL.
*/
function generate_get_link_url() {
$has_url = get_url_in_content( get_the_content() );
return $has_url ? $has_url : apply_filters( 'the_permalink', get_permalink() );
}
}
if ( ! function_exists( 'generate_get_navigation_location' ) ) {
/**
* Get the location of the navigation and filter it.
*
* @since 1.3.41
*
* @return string The primary menu location.
*/
function generate_get_navigation_location() {
return apply_filters( 'generate_navigation_location', generate_get_option( 'nav_position_setting' ) );
}
}
/**
* Check if the logo and site branding are active.
*
* @since 2.3
*/
function generate_has_logo_site_branding() {
if ( get_theme_mod( 'custom_logo' ) && ( ! generate_get_option( 'hide_title' ) || ! generate_get_option( 'hide_tagline' ) ) ) {
return true;
}
return false;
}
/**
* Create SVG icons.
*
* @since 2.3
*/
function generate_get_svg_icon( $icon, $replace = false ) {
if ( 'svg' !== generate_get_option( 'icons' ) ) {
return;
}
$output = '';
if ( 'menu-bars' === $icon ) {
$output = '<svg viewBox="0 0 512 512" aria-hidden="true" role="img" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em">
<path d="M0 96c0-13.255 10.745-24 24-24h464c13.255 0 24 10.745 24 24s-10.745 24-24 24H24c-13.255 0-24-10.745-24-24zm0 160c0-13.255 10.745-24 24-24h464c13.255 0 24 10.745 24 24s-10.745 24-24 24H24c-13.255 0-24-10.745-24-24zm0 160c0-13.255 10.745-24 24-24h464c13.255 0 24 10.745 24 24s-10.745 24-24 24H24c-13.255 0-24-10.745-24-24z" />
</svg>';
}
if ( 'close' === $icon ) {
$output = '<svg viewBox="0 0 512 512" aria-hidden="true" role="img" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em">
<path d="M71.029 71.029c9.373-9.372 24.569-9.372 33.942 0L256 222.059l151.029-151.03c9.373-9.372 24.569-9.372 33.942 0 9.372 9.373 9.372 24.569 0 33.942L289.941 256l151.03 151.029c9.372 9.373 9.372 24.569 0 33.942-9.373 9.372-24.569 9.372-33.942 0L256 289.941l-151.029 151.03c-9.373 9.372-24.569 9.372-33.942 0-9.372-9.373-9.372-24.569 0-33.942L222.059 256 71.029 104.971c-9.372-9.373-9.372-24.569 0-33.942z" />
</svg>';
}
if ( 'search' === $icon ) {
$output = '<svg viewBox="0 0 512 512" aria-hidden="true" role="img" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em">
<path fill-rule="evenodd" clip-rule="evenodd" d="M208 48c-88.366 0-160 71.634-160 160s71.634 160 160 160 160-71.634 160-160S296.366 48 208 48zM0 208C0 93.125 93.125 0 208 0s208 93.125 208 208c0 48.741-16.765 93.566-44.843 129.024l133.826 134.018c9.366 9.379 9.355 24.575-.025 33.941-9.379 9.366-24.575 9.355-33.941-.025L337.238 370.987C301.747 399.167 256.839 416 208 416 93.125 416 0 322.875 0 208z"/>
</svg>';
}
if ( 'categories' === $icon ) {
$output = '<svg viewBox="0 0 512 512" aria-hidden="true" role="img" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em">
<path d="M0 112c0-26.51 21.49-48 48-48h110.014a48 48 0 0 1 43.592 27.907l12.349 26.791A16 16 0 0 0 228.486 128H464c26.51 0 48 21.49 48 48v224c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112z" fill-rule="nonzero"/>
</svg>';
}
if ( 'tags' === $icon ) {
$output = '<svg viewBox="0 0 512 512" aria-hidden="true" role="img" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em">
<path d="M20 39.5c-8.836 0-16 7.163-16 16v176c0 4.243 1.686 8.313 4.687 11.314l224 224c6.248 6.248 16.378 6.248 22.626 0l176-176c6.244-6.244 6.25-16.364.013-22.615l-223.5-224A15.999 15.999 0 0 0 196.5 39.5H20zm56 96c0-13.255 10.745-24 24-24s24 10.745 24 24-10.745 24-24 24-24-10.745-24-24z"/>
<path d="M259.515 43.015c4.686-4.687 12.284-4.687 16.97 0l228 228c4.686 4.686 4.686 12.284 0 16.97l-180 180c-4.686 4.687-12.284 4.687-16.97 0-4.686-4.686-4.686-12.284 0-16.97L479.029 279.5 259.515 59.985c-4.686-4.686-4.686-12.284 0-16.97z" fill-rule="nonzero"/>
</svg>';
}
if ( 'comments' === $icon ) {
$output = '<svg viewBox="0 0 512 512" aria-hidden="true" role="img" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em">
<path d="M132.838 329.973a435.298 435.298 0 0 0 16.769-9.004c13.363-7.574 26.587-16.142 37.419-25.507 7.544.597 15.27.925 23.098.925 54.905 0 105.634-15.311 143.285-41.28 23.728-16.365 43.115-37.692 54.155-62.645 54.739 22.205 91.498 63.272 91.498 110.286 0 42.186-29.558 79.498-75.09 102.828 23.46 49.216 75.09 101.709 75.09 101.709s-115.837-38.35-154.424-78.46c-9.956 1.12-20.297 1.758-30.793 1.758-88.727 0-162.927-43.071-181.007-100.61z" fill-rule="nonzero"/>
<path d="M383.371 132.502c0 70.603-82.961 127.787-185.216 127.787-10.496 0-20.837-.639-30.793-1.757-38.587 40.093-154.424 78.429-154.424 78.429s51.63-52.472 75.09-101.67c-45.532-23.321-75.09-60.619-75.09-102.79C12.938 61.9 95.9 4.716 198.155 4.716 300.41 4.715 383.37 61.9 383.37 132.502z" fill-rule="nonzero" />
</svg>';
}
if ( 'arrow' === $icon ) {
$output = '<svg viewBox="0 0 330 512" aria-hidden="true" role="img" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em">
<path d="M305.913 197.085c0 2.266-1.133 4.815-2.833 6.514L171.087 335.593c-1.7 1.7-4.249 2.832-6.515 2.832s-4.815-1.133-6.515-2.832L26.064 203.599c-1.7-1.7-2.832-4.248-2.832-6.514s1.132-4.816 2.832-6.515l14.162-14.163c1.7-1.699 3.966-2.832 6.515-2.832 2.266 0 4.815 1.133 6.515 2.832l111.316 111.317 111.316-111.317c1.7-1.699 4.249-2.832 6.515-2.832s4.815 1.133 6.515 2.832l14.162 14.163c1.7 1.7 2.833 4.249 2.833 6.515z" fill-rule="nonzero"/>
</svg>';
}
if ( $replace ) {
$output .= '<svg viewBox="0 0 512 512" aria-hidden="true" role="img" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em">
<path d="M71.029 71.029c9.373-9.372 24.569-9.372 33.942 0L256 222.059l151.029-151.03c9.373-9.372 24.569-9.372 33.942 0 9.372 9.373 9.372 24.569 0 33.942L289.941 256l151.03 151.029c9.372 9.373 9.372 24.569 0 33.942-9.373 9.372-24.569 9.372-33.942 0L256 289.941l-151.029 151.03c-9.373 9.372-24.569 9.372-33.942 0-9.372-9.373-9.372-24.569 0-33.942L222.059 256 71.029 104.971c-9.372-9.373-9.372-24.569 0-33.942z" />
</svg>';
}
$output = apply_filters( 'generate_svg_icon_element', $output, $icon );
$classes = array(
'gp-icon',
'icon-' . $icon,
);
$output = sprintf(
'<span class="%1$s">%2$s</span>',
implode( ' ', $classes ),
$output
);
return apply_filters( 'generate_svg_icon', $output, $icon );
}
/**
* Out our icon HTML.
*
* @since 2.3
*
* @param string $icon
* @param bool $replace Whether to include the close icon to be shown using JS.
* @return string
*/
function generate_do_svg_icon( $icon, $replace = false ) {
echo generate_get_svg_icon( $icon, $replace );
}
/**
* Get our media queries.
*
* @since 2.4
*
* @param string $name
* @return string The full media query.
*/
function generate_get_media_query( $name ) {
$desktop = apply_filters( 'generate_desktop_media_query', '(min-width:1025px)' );
$tablet = apply_filters( 'generate_tablet_media_query', '(min-width: 769px) and (max-width: 1024px)' );
$mobile = apply_filters( 'generate_mobile_media_query', '(max-width:768px)' );
$mobile_menu = apply_filters( 'generate_mobile_menu_media_query', $mobile );
$queries = apply_filters( 'generate_media_queries', array(
'desktop' => $desktop,
'tablet' => $tablet,
'mobile' => $mobile,
'mobile-menu' => $mobile_menu,
) );
return $queries[ $name ];
}

File diff suppressed because one or more lines are too long