first
This commit is contained in:
554
wp-content/themes/generatepress/inc/block-editor.php
Normal file
554
wp-content/themes/generatepress/inc/block-editor.php
Normal file
@ -0,0 +1,554 @@
|
||||
<?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_filter( 'block_editor_settings_all', 'generate_add_inline_block_editor_styles' );
|
||||
/**
|
||||
* Add dynamic inline styles to the block editor content.
|
||||
*
|
||||
* @param array $editor_settings The existing editor settings.
|
||||
*/
|
||||
function generate_add_inline_block_editor_styles( $editor_settings ) {
|
||||
$show_editor_styles = apply_filters( 'generate_show_block_editor_styles', true );
|
||||
|
||||
if ( $show_editor_styles ) {
|
||||
if ( generate_is_using_dynamic_typography() ) {
|
||||
$google_fonts_uri = GeneratePress_Typography::get_google_fonts_uri();
|
||||
|
||||
if ( $google_fonts_uri ) {
|
||||
// Need to use @import for now until this is ready: https://github.com/WordPress/gutenberg/pull/35950.
|
||||
$google_fonts_import = sprintf(
|
||||
'@import "%s";',
|
||||
$google_fonts_uri
|
||||
);
|
||||
|
||||
$editor_settings['styles'][] = array( 'css' => $google_fonts_import );
|
||||
}
|
||||
}
|
||||
|
||||
$editor_settings['styles'][] = array( 'css' => wp_strip_all_tags( generate_do_inline_block_editor_css() ) );
|
||||
|
||||
if ( generate_is_using_dynamic_typography() ) {
|
||||
$editor_settings['styles'][] = array( 'css' => wp_strip_all_tags( GeneratePress_Typography::get_css( 'core' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $editor_settings;
|
||||
}
|
||||
|
||||
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_script(
|
||||
'generate-block-editor',
|
||||
trailingslashit( get_template_directory_uri() ) . 'assets/dist/block-editor.js',
|
||||
array( 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-plugins', 'wp-polyfill' ),
|
||||
GENERATE_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
$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',
|
||||
'generatepressBlockEditor',
|
||||
array(
|
||||
'globalSidebarLayout' => generate_get_block_editor_sidebar_layout( false ),
|
||||
'containerWidth' => generate_get_option( 'container_width' ),
|
||||
'contentPaddingRight' => absint( $spacing_settings['content_right'] ) . 'px',
|
||||
'contentPaddingLeft' => absint( $spacing_settings['content_left'] ) . 'px',
|
||||
'rightSidebarWidth' => apply_filters( 'generate_right_sidebar_width', '25' ),
|
||||
'leftSidebarWidth' => apply_filters( 'generate_left_sidebar_width', '25' ),
|
||||
'text_color' => $text_color,
|
||||
'show_editor_styles' => apply_filters( 'generate_show_block_editor_styles', true ),
|
||||
'contentAreaType' => apply_filters( 'generate_block_editor_content_area_type', '' ),
|
||||
'customContentWidth' => apply_filters( 'generate_block_editor_container_width', '' ),
|
||||
)
|
||||
);
|
||||
|
||||
wp_register_style( 'generate-block-editor', false, array(), true, true );
|
||||
wp_add_inline_style( 'generate-block-editor', generate_do_inline_block_editor_css( 'block-editor' ) );
|
||||
wp_enqueue_style( 'generate-block-editor' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Write our CSS for the block editor.
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $for Define whether this CSS for the block content or the block editor.
|
||||
*/
|
||||
function generate_do_inline_block_editor_css( $for = 'block-content' ) {
|
||||
$css = new GeneratePress_CSS();
|
||||
|
||||
$css->set_selector( ':root' );
|
||||
|
||||
$global_colors = generate_get_global_colors();
|
||||
|
||||
if ( ! empty( $global_colors ) ) {
|
||||
foreach ( (array) $global_colors as $key => $data ) {
|
||||
if ( ! empty( $data['slug'] ) && ! empty( $data['color'] ) ) {
|
||||
$css->add_property( '--' . $data['slug'], $data['color'] );
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( (array) $global_colors as $key => $data ) {
|
||||
if ( ! empty( $data['slug'] ) && ! empty( $data['color'] ) ) {
|
||||
$css->set_selector( '.has-' . $data['slug'] . '-color' );
|
||||
$css->add_property( 'color', 'var(--' . $data['slug'] . ')' );
|
||||
|
||||
$css->set_selector( '.has-' . $data['slug'] . '-background-color' );
|
||||
$css->add_property( 'background-color', 'var(--' . $data['slug'] . ')' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this CSS is for the editor only (not the block content), we can return here.
|
||||
if ( 'block-editor' === $for ) {
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
$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()
|
||||
);
|
||||
|
||||
$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' );
|
||||
$css->add_property(
|
||||
'--content-width',
|
||||
'true' === get_post_meta( get_the_ID(), '_generate-full-width-content', true )
|
||||
? '100%'
|
||||
: $content_width_calc
|
||||
);
|
||||
|
||||
$css->set_selector( 'body .wp-block' );
|
||||
$css->add_property( 'max-width', 'var(--content-width)' );
|
||||
|
||||
$css->set_selector( '.wp-block[data-align="full"]' );
|
||||
$css->add_property( 'max-width', 'none' );
|
||||
|
||||
$css->set_selector( '.wp-block[data-align="wide"]' );
|
||||
$css->add_property( 'max-width', absint( $content_width ), false, 'px' );
|
||||
|
||||
$underline_links = generate_get_option( 'underline_links' );
|
||||
|
||||
if ( 'never' !== $underline_links ) {
|
||||
if ( 'always' === $underline_links ) {
|
||||
$css->set_selector( '.wp-block a' );
|
||||
$css->add_property( 'text-decoration', 'underline' );
|
||||
}
|
||||
|
||||
if ( 'hover' === $underline_links ) {
|
||||
$css->set_selector( '.wp-block a' );
|
||||
$css->add_property( 'text-decoration', 'none' );
|
||||
|
||||
$css->set_selector( '.wp-block a:hover, .wp-block a:focus' );
|
||||
$css->add_property( 'text-decoration', 'underline' );
|
||||
}
|
||||
|
||||
if ( 'not-hover' === $underline_links ) {
|
||||
$css->set_selector( '.wp-block a' );
|
||||
$css->add_property( 'text-decoration', 'underline' );
|
||||
|
||||
$css->set_selector( '.wp-block a:hover, .wp-block a:focus' );
|
||||
$css->add_property( 'text-decoration', 'none' );
|
||||
}
|
||||
|
||||
$css->set_selector( 'a.button, .wp-block-button__link' );
|
||||
$css->add_property( 'text-decoration', 'none' );
|
||||
} else {
|
||||
$css->set_selector( '.wp-block a' );
|
||||
$css->add_property( 'text-decoration', 'none' );
|
||||
}
|
||||
|
||||
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( 'a.button, a.button:visited, .wp-block-button__link:not(.has-background)' );
|
||||
$css->add_property( 'color', $color_settings['form_button_text_color'] );
|
||||
$css->add_property( 'background-color', $color_settings['form_button_background_color'] );
|
||||
$css->add_property( 'padding', '10px 20px' );
|
||||
$css->add_property( 'border', '0' );
|
||||
$css->add_property( 'border-radius', '0' );
|
||||
|
||||
$css->set_selector( 'a.button:hover, a.button:active, a.button:focus, .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', $color_settings['form_button_text_color_hover'] );
|
||||
$css->add_property( 'background-color', $color_settings['form_button_background_color_hover'] );
|
||||
|
||||
if ( ! generate_is_using_dynamic_typography() ) {
|
||||
$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' );
|
||||
|
||||
if ( ! generate_is_using_dynamic_typography() ) {
|
||||
$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', $color_settings['content_text_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'text_color' ) );
|
||||
}
|
||||
|
||||
$css->set_selector( '.content-title-visibility' );
|
||||
|
||||
if ( $color_settings['content_text_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['content_text_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'text_color' ) );
|
||||
}
|
||||
|
||||
if ( ! generate_is_using_dynamic_typography() ) {
|
||||
$css->set_selector( 'body, p' );
|
||||
$css->add_property( 'line-height', floatval( $font_settings['body_line_height'] ) );
|
||||
|
||||
$css->set_selector( 'p' );
|
||||
$css->add_property( 'margin-top', '0px' );
|
||||
$css->add_property( 'margin-bottom', $font_settings['paragraph_margin'], false, 'em' );
|
||||
}
|
||||
|
||||
$css->set_selector( 'h1' );
|
||||
|
||||
if ( ! generate_is_using_dynamic_typography() ) {
|
||||
$css->add_property( 'font-family', 'inherit' === $h1_family || '' === $h1_family ? $body_family : $h1_family );
|
||||
$css->add_property( 'font-weight', $font_settings['heading_1_weight'] );
|
||||
$css->add_property( 'text-transform', $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' );
|
||||
$css->add_property( 'margin-bottom', floatval( $font_settings['heading_1_margin_bottom'] ), false, 'px' );
|
||||
$css->add_property( 'margin-top', '0' );
|
||||
}
|
||||
|
||||
if ( $color_settings['h1_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['h1_color'] );
|
||||
} elseif ( $color_settings['content_text_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['content_text_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'text_color' ) );
|
||||
}
|
||||
|
||||
if ( $color_settings['content_title_color'] ) {
|
||||
$css->set_selector( '.editor-styles-wrapper .editor-post-title__input' );
|
||||
$css->add_property( 'color', $color_settings['content_title_color'] );
|
||||
}
|
||||
|
||||
$css->set_selector( 'h2' );
|
||||
|
||||
if ( ! generate_is_using_dynamic_typography() ) {
|
||||
$css->add_property( 'font-family', $h2_family );
|
||||
$css->add_property( 'font-weight', $font_settings['heading_2_weight'] );
|
||||
$css->add_property( 'text-transform', $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' );
|
||||
$css->add_property( 'margin-bottom', floatval( $font_settings['heading_2_margin_bottom'] ), false, 'px' );
|
||||
$css->add_property( 'margin-top', '0' );
|
||||
}
|
||||
|
||||
if ( $color_settings['h2_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['h2_color'] );
|
||||
} elseif ( $color_settings['content_text_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['content_text_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'text_color' ) );
|
||||
}
|
||||
|
||||
$css->set_selector( 'h3' );
|
||||
|
||||
if ( ! generate_is_using_dynamic_typography() ) {
|
||||
$css->add_property( 'font-family', $h3_family );
|
||||
$css->add_property( 'font-weight', $font_settings['heading_3_weight'] );
|
||||
$css->add_property( 'text-transform', $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' );
|
||||
$css->add_property( 'margin-bottom', floatval( $font_settings['heading_3_margin_bottom'] ), false, 'px' );
|
||||
$css->add_property( 'margin-top', '0' );
|
||||
}
|
||||
|
||||
if ( $color_settings['h3_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['h3_color'] );
|
||||
} elseif ( $color_settings['content_text_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['content_text_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'text_color' ) );
|
||||
}
|
||||
|
||||
$css->set_selector( 'h4' );
|
||||
|
||||
if ( ! generate_is_using_dynamic_typography() ) {
|
||||
$css->add_property( 'font-family', $h4_family );
|
||||
$css->add_property( 'font-weight', $font_settings['heading_4_weight'] );
|
||||
$css->add_property( 'text-transform', $font_settings['heading_4_transform'] );
|
||||
$css->add_property( 'margin-bottom', '20px' );
|
||||
$css->add_property( 'margin-top', '0' );
|
||||
|
||||
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', $color_settings['h4_color'] );
|
||||
} elseif ( $color_settings['content_text_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['content_text_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'text_color' ) );
|
||||
}
|
||||
|
||||
$css->set_selector( 'h5' );
|
||||
|
||||
if ( ! generate_is_using_dynamic_typography() ) {
|
||||
$css->add_property( 'font-family', $h5_family );
|
||||
$css->add_property( 'font-weight', $font_settings['heading_5_weight'] );
|
||||
$css->add_property( 'text-transform', $font_settings['heading_5_transform'] );
|
||||
$css->add_property( 'margin-bottom', '20px' );
|
||||
$css->add_property( 'margin-top', '0' );
|
||||
|
||||
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', $color_settings['h5_color'] );
|
||||
} elseif ( $color_settings['content_text_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['content_text_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'text_color' ) );
|
||||
}
|
||||
|
||||
$css->set_selector( 'h6' );
|
||||
|
||||
if ( ! generate_is_using_dynamic_typography() ) {
|
||||
$css->add_property( 'font-family', $h6_family );
|
||||
$css->add_property( 'font-weight', $font_settings['heading_6_weight'] );
|
||||
$css->add_property( 'text-transform', $font_settings['heading_6_transform'] );
|
||||
$css->add_property( 'margin-bottom', '20px' );
|
||||
$css->add_property( 'margin-top', '0' );
|
||||
|
||||
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', $color_settings['h6_color'] );
|
||||
} elseif ( $color_settings['content_text_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['content_text_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'text_color' ) );
|
||||
}
|
||||
|
||||
$css->set_selector( 'a.button, .block-editor-block-list__layout .wp-block-button .wp-block-button__link' );
|
||||
|
||||
if ( ! generate_is_using_dynamic_typography() ) {
|
||||
$css->add_property( 'font-family', $buttons_family );
|
||||
$css->add_property( 'font-weight', $font_settings['buttons_font_weight'] );
|
||||
$css->add_property( 'text-transform', $font_settings['buttons_font_transform'] );
|
||||
|
||||
if ( '' !== $font_settings['buttons_font_size'] ) {
|
||||
$css->add_property( 'font-size', absint( $font_settings['buttons_font_size'] ), false, 'px' );
|
||||
} else {
|
||||
$css->add_property( 'font-size', 'inherit' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( version_compare( $GLOBALS['wp_version'], '5.7-alpha.1', '>' ) ) {
|
||||
$css->set_selector( '.block-editor__container .edit-post-visual-editor' );
|
||||
$css->add_property( 'background-color', generate_get_option( 'background_color' ) );
|
||||
|
||||
$css->set_selector( 'body' );
|
||||
|
||||
if ( $color_settings['content_background_color'] ) {
|
||||
$css->add_property( 'background-color', $color_settings['content_background_color'] );
|
||||
} else {
|
||||
$css->add_property( 'background-color', generate_get_option( 'background_color' ) );
|
||||
}
|
||||
} else {
|
||||
$css->set_selector( 'body' );
|
||||
$css->add_property( 'background-color', generate_get_option( 'background_color' ) );
|
||||
|
||||
if ( $color_settings['content_background_color'] ) {
|
||||
$body_background = generate_get_option( 'background_color' );
|
||||
$content_background = $color_settings['content_background_color'];
|
||||
|
||||
$css->add_property( 'background', 'linear-gradient(' . $content_background . ',' . $content_background . '), linear-gradient(' . $body_background . ',' . $body_background . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
$css->set_selector( 'a, a:visited' );
|
||||
|
||||
if ( $color_settings['content_link_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['content_link_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'link_color' ) );
|
||||
}
|
||||
|
||||
$css->set_selector( 'a:hover, a:focus, a:active' );
|
||||
|
||||
if ( $color_settings['content_link_hover_color'] ) {
|
||||
$css->add_property( 'color', $color_settings['content_link_hover_color'] );
|
||||
} else {
|
||||
$css->add_property( 'color', generate_get_option( 'link_color_hover' ) );
|
||||
}
|
||||
|
||||
return $css->css_output();
|
||||
}
|
217
wp-content/themes/generatepress/inc/class-css.php
Normal file
217
wp-content/themes/generatepress/inc/class-css.php
Normal file
@ -0,0 +1,217 @@
|
||||
<?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 = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
|
||||
|
||||
/**
|
||||
* Stores the final css output with all of its rules for the current selector.
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $_selector_output = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
|
||||
|
||||
/**
|
||||
* Stores all of the rules that will be added to the selector
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $_css = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
|
||||
|
||||
/**
|
||||
* The string that holds all of the css to output
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $_output = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
|
||||
|
||||
/**
|
||||
* Stores media queries
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
protected $_media_query = null; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
|
||||
|
||||
/**
|
||||
* The string that holds all of the css to output inside of the media query
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $_media_query_output = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
|
||||
|
||||
/**
|
||||
* 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 ) {
|
||||
// Setting font-size to 0 is rarely ever a good thing.
|
||||
if ( 'font-size' === $property && 0 === $value ) {
|
||||
return 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 ) && ! is_numeric( $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 The media query.
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
266
wp-content/themes/generatepress/inc/class-dashboard.php
Normal file
266
wp-content/themes/generatepress/inc/class-dashboard.php
Normal file
@ -0,0 +1,266 @@
|
||||
<?php
|
||||
/**
|
||||
* Build our admin dashboard.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* This class adds HTML attributes to various theme elements.
|
||||
*/
|
||||
class GeneratePress_Dashboard {
|
||||
/**
|
||||
* Class instance.
|
||||
*
|
||||
* @access private
|
||||
* @var $instance Class instance.
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get started.
|
||||
*/
|
||||
public function __construct() {
|
||||
// Load our old dashboard if we're using an old version of GP Premium.
|
||||
if ( defined( 'GP_PREMIUM_VERSION' ) && version_compare( GP_PREMIUM_VERSION, '2.1.0-alpha.1', '<' ) ) {
|
||||
require_once get_template_directory() . '/inc/dashboard.php';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
add_action( 'admin_menu', array( $this, 'add_menu_item' ) );
|
||||
add_filter( 'admin_body_class', array( $this, 'set_admin_body_class' ) );
|
||||
add_action( 'in_admin_header', array( $this, 'add_header' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
||||
add_action( 'generate_admin_dashboard', array( $this, 'start_customizing' ) );
|
||||
add_action( 'generate_admin_dashboard', array( $this, 'go_pro' ), 15 );
|
||||
add_action( 'generate_admin_dashboard', array( $this, 'reset' ), 100 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our dashboard menu item.
|
||||
*/
|
||||
public function add_menu_item() {
|
||||
add_theme_page(
|
||||
esc_html__( 'GeneratePress', 'generatepress' ),
|
||||
esc_html__( 'GeneratePress', 'generatepress' ),
|
||||
apply_filters( 'generate_dashboard_page_capability', 'edit_theme_options' ),
|
||||
'generate-options',
|
||||
array( $this, 'page' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our dashboard pages so we can style them.
|
||||
*/
|
||||
public static function get_pages() {
|
||||
return apply_filters(
|
||||
'generate_dashboard_screens',
|
||||
array(
|
||||
'appearance_page_generate-options',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a body class on GP dashboard pages.
|
||||
*
|
||||
* @param string $classes The existing classes.
|
||||
*/
|
||||
public function set_admin_body_class( $classes ) {
|
||||
$dashboard_pages = self::get_pages();
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( in_array( $current_screen->id, $dashboard_pages ) ) {
|
||||
$classes .= ' generate-dashboard-page';
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build our Dashboard header.
|
||||
*/
|
||||
public static function header() {
|
||||
?>
|
||||
<div class="generatepress-dashboard-header">
|
||||
<div class="generatepress-dashboard-header__title">
|
||||
<h1>
|
||||
<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600"><path d="M485.2 427.8l-99.1-46.2 15.8-34c5.6-11.9 8.8-24.3 10-36.7 3.3-33.7-9-67.3-33.2-91.1-8.9-8.7-19.3-16.1-31.3-21.7-11.9-5.6-24.3-8.8-36.7-10-33.7-3.3-67.4 9-91.1 33.2-8.7 8.9-16.1 19.3-21.7 31.3l-15.8 34-30.4 65.2c-.7 1.5-.1 3.3 1.5 4l65.2 30.4 34 15.8 34 15.8 68 31.7 74.7 34.8c-65 45.4-152.1 55.2-228.7 17.4C90.2 447.4 44.1 313.3 97.3 202.6c53.3-110.8 186-158.5 297.8-106.3 88.1 41.1 137.1 131.9 129.1 223.4-.1 1.3.6 2.4 1.7 3l65.6 30.6c1.8.8 3.9-.3 4.2-2.2 22.6-130.7-44-265.4-170.5-323.5-150.3-69-327-4.1-396.9 145.8-70 150.1-5.1 328.5 145.1 398.5 114.1 53.2 244.5 28.4 331.3-52.3 17.9-16.6 33.9-35.6 47.5-56.8 1-1.5.4-3.6-1.3-4.3l-65.7-30.7zm-235-109.6l15.8-34c8.8-18.8 31.1-26.9 49.8-18.1s26.9 31 18.1 49.8l-15.8 34-34-15.8-33.9-15.9z" fill="currentColor" /></svg>
|
||||
<?php echo esc_html( get_admin_page_title() ); ?>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<?php self::navigation(); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Build our Dashboard menu.
|
||||
*/
|
||||
public static function navigation() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
$tabs = apply_filters(
|
||||
'generate_dashboard_tabs',
|
||||
array(
|
||||
'dashboard' => array(
|
||||
'name' => __( 'Dashboard', 'generatepress' ),
|
||||
'url' => admin_url( 'themes.php?page=generate-options' ),
|
||||
'class' => 'appearance_page_generate-options' === $screen->id ? 'active' : '',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! defined( 'GP_PREMIUM_VERSION' ) ) {
|
||||
$tabs['premium'] = array(
|
||||
'name' => __( 'Premium', 'generatepress' ),
|
||||
'url' => 'https://generatepress.com/premium',
|
||||
'class' => '',
|
||||
'external' => true,
|
||||
);
|
||||
}
|
||||
|
||||
$tabs['support'] = array(
|
||||
'name' => __( 'Support', 'generatepress' ),
|
||||
'url' => 'https://generatepress.com/support',
|
||||
'class' => '',
|
||||
'external' => true,
|
||||
);
|
||||
|
||||
$tabs['documentation'] = array(
|
||||
'name' => __( 'Documentation', 'generatepress' ),
|
||||
'url' => 'https://docs.generatepress.com',
|
||||
'class' => '',
|
||||
'external' => true,
|
||||
);
|
||||
?>
|
||||
<div class="generatepress-dashboard-header__navigation">
|
||||
<?php
|
||||
foreach ( $tabs as $tab ) {
|
||||
printf(
|
||||
'<a href="%1$s" class="%2$s"%4$s>%3$s</a>',
|
||||
esc_url( $tab['url'] ),
|
||||
esc_attr( $tab['class'] ),
|
||||
esc_html( $tab['name'] ),
|
||||
! empty( $tab['external'] ) ? 'target="_blank" rel="noreferrer noopener"' : ''
|
||||
);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our Dashboard headers.
|
||||
*/
|
||||
public function add_header() {
|
||||
$dashboard_pages = self::get_pages();
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( in_array( $current_screen->id, $dashboard_pages ) ) {
|
||||
self::header();
|
||||
|
||||
/**
|
||||
* generate_dashboard_after_header hook.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
do_action( 'generate_dashboard_after_header' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our scripts to the page.
|
||||
*/
|
||||
public function enqueue_scripts() {
|
||||
$dashboard_pages = self::get_pages();
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( in_array( $current_screen->id, $dashboard_pages ) ) {
|
||||
wp_enqueue_style(
|
||||
'generate-dashboard',
|
||||
get_template_directory_uri() . '/assets/dist/style-dashboard.css',
|
||||
array( 'wp-components' ),
|
||||
GENERATE_VERSION
|
||||
);
|
||||
|
||||
if ( 'appearance_page_generate-options' === $current_screen->id ) {
|
||||
wp_enqueue_script(
|
||||
'generate-dashboard',
|
||||
get_template_directory_uri() . '/assets/dist/dashboard.js',
|
||||
array( 'wp-api', 'wp-i18n', 'wp-components', 'wp-element', 'wp-api-fetch', 'wp-hooks', 'wp-polyfill' ),
|
||||
GENERATE_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
wp_set_script_translations( 'generate-dashboard', 'generatepress' );
|
||||
|
||||
wp_localize_script(
|
||||
'generate-dashboard',
|
||||
'generateDashboard',
|
||||
array(
|
||||
'hasPremium' => defined( 'GP_PREMIUM_VERSION' ),
|
||||
'customizeSectionUrls' => array(
|
||||
'siteIdentitySection' => add_query_arg( rawurlencode( 'autofocus[section]' ), 'title_tagline', wp_customize_url() ),
|
||||
'colorsSection' => add_query_arg( rawurlencode( 'autofocus[section]' ), 'generate_colors_section', wp_customize_url() ),
|
||||
'typographySection' => add_query_arg( rawurlencode( 'autofocus[section]' ), 'generate_typography_section', wp_customize_url() ),
|
||||
'layoutSection' => add_query_arg( rawurlencode( 'autofocus[panel]' ), 'generate_layout_panel', wp_customize_url() ),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the HTML for our page.
|
||||
*/
|
||||
public function page() {
|
||||
?>
|
||||
<div class="wrap">
|
||||
<div class="generatepress-dashboard">
|
||||
<?php do_action( 'generate_admin_dashboard' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the container for our start customizing app.
|
||||
*/
|
||||
public function start_customizing() {
|
||||
echo '<div id="generatepress-dashboard-app"></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the container for our start customizing app.
|
||||
*/
|
||||
public function go_pro() {
|
||||
echo '<div id="generatepress-dashboard-go-pro"></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the container for our reset app.
|
||||
*/
|
||||
public function reset() {
|
||||
echo '<div id="generatepress-reset"></div>';
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Dashboard::get_instance();
|
496
wp-content/themes/generatepress/inc/class-html-attributes.php
Normal file
496
wp-content/themes/generatepress/inc/class-html-attributes.php
Normal file
@ -0,0 +1,496 @@
|
||||
<?php
|
||||
/**
|
||||
* Add HTML attributes to our theme elements.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* This class adds HTML attributes to various theme elements.
|
||||
*/
|
||||
class GeneratePress_HTML_Attributes {
|
||||
/**
|
||||
* Class instance.
|
||||
*
|
||||
* @access private
|
||||
* @var $instance Class instance.
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
add_filter( 'generate_parse_attr', array( $this, 'parse_attributes' ), 10, 3 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the attributes.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The current attributes.
|
||||
* @param string $context The context in which attributes are applied.
|
||||
* @param array $settings Custom settings passed to the filter.
|
||||
*/
|
||||
public function parse_attributes( $attributes, $context, $settings ) {
|
||||
switch ( $context ) {
|
||||
case 'top-bar':
|
||||
return $this->top_bar( $attributes );
|
||||
|
||||
case 'inside-top-bar':
|
||||
return $this->inside_top_bar( $attributes );
|
||||
|
||||
case 'header':
|
||||
return $this->site_header( $attributes );
|
||||
|
||||
case 'inside-header':
|
||||
return $this->inside_site_header( $attributes );
|
||||
|
||||
case 'menu-toggle':
|
||||
return $this->menu_toggle( $attributes );
|
||||
|
||||
case 'navigation':
|
||||
return $this->primary_navigation( $attributes );
|
||||
|
||||
case 'inside-navigation':
|
||||
return $this->primary_inner_navigation( $attributes );
|
||||
|
||||
case 'mobile-menu-control-wrapper':
|
||||
return $this->mobile_menu_control_wrapper( $attributes );
|
||||
|
||||
case 'site-info':
|
||||
return $this->site_info( $attributes );
|
||||
|
||||
case 'inside-site-info':
|
||||
return $this->inside_site_info( $attributes );
|
||||
|
||||
case 'entry-header':
|
||||
return $this->entry_header( $attributes );
|
||||
|
||||
case 'page-header':
|
||||
return $this->page_header( $attributes );
|
||||
|
||||
case 'site-content':
|
||||
return $this->site_content( $attributes );
|
||||
|
||||
case 'page':
|
||||
return $this->page( $attributes );
|
||||
|
||||
case 'content':
|
||||
return $this->content( $attributes );
|
||||
|
||||
case 'main':
|
||||
return $this->main( $attributes );
|
||||
|
||||
case 'post-navigation':
|
||||
return $this->post_navigation( $attributes );
|
||||
|
||||
case 'left-sidebar':
|
||||
return $this->left_sidebar( $attributes );
|
||||
|
||||
case 'right-sidebar':
|
||||
return $this->right_sidebar( $attributes );
|
||||
|
||||
case 'footer-widgets-container':
|
||||
return $this->footer_widgets_container( $attributes );
|
||||
|
||||
case 'comment-body':
|
||||
return $this->comment_body( $attributes, $settings );
|
||||
|
||||
case 'comment-meta':
|
||||
return $this->comment_meta( $attributes );
|
||||
|
||||
case 'footer-entry-meta':
|
||||
return $this->footer_entry_meta( $attributes );
|
||||
|
||||
case 'woocommerce-content':
|
||||
return $this->woocommerce_content( $attributes );
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our top bar.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function top_bar( $attributes ) {
|
||||
$classes = generate_get_element_classes( 'top_bar' );
|
||||
|
||||
if ( $classes ) {
|
||||
$attributes['class'] .= ' ' . join( ' ', $classes );
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our inside top bar container.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function inside_top_bar( $attributes ) {
|
||||
$attributes['class'] .= ' inside-top-bar';
|
||||
|
||||
if ( 'contained' === generate_get_option( 'top_bar_inner_width' ) ) {
|
||||
$attributes['class'] .= ' grid-container';
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
$attributes['class'] .= ' grid-parent';
|
||||
}
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our site header.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function site_header( $attributes ) {
|
||||
$attributes['id'] = 'masthead';
|
||||
$attributes['aria-label'] = esc_attr__( 'Site', 'generatepress' );
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our inside site header container.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function inside_site_header( $attributes ) {
|
||||
$classes = generate_get_element_classes( 'inside_header' );
|
||||
|
||||
if ( $classes ) {
|
||||
$attributes['class'] .= ' ' . join( ' ', $classes );
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our menu toggle.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function menu_toggle( $attributes ) {
|
||||
$attributes['class'] .= ' menu-toggle';
|
||||
$attributes['aria-controls'] = 'primary-menu';
|
||||
$attributes['aria-expanded'] = 'false';
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our main navigation.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function primary_navigation( $attributes ) {
|
||||
$attributes['id'] = 'site-navigation';
|
||||
$attributes['aria-label'] = esc_attr__( 'Primary', 'generatepress' );
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our main navigation.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function primary_inner_navigation( $attributes ) {
|
||||
$classes = generate_get_element_classes( 'inside_navigation' );
|
||||
|
||||
if ( $classes ) {
|
||||
$attributes['class'] .= ' ' . join( ' ', $classes );
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our main navigation.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function mobile_menu_control_wrapper( $attributes ) {
|
||||
$attributes['id'] = 'mobile-menu-control-wrapper';
|
||||
$attributes['class'] .= ' main-navigation mobile-menu-control-wrapper';
|
||||
$attributes['aria-label'] = esc_attr__( 'Mobile Toggle', 'generatepress' );
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our footer element.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function site_info( $attributes ) {
|
||||
$attributes['class'] .= ' site-info';
|
||||
$attributes['aria-label'] = esc_attr__( 'Site', 'generatepress' );
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our inside site info container.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function inside_site_info( $attributes ) {
|
||||
$attributes['class'] .= ' inside-site-info';
|
||||
|
||||
if ( 'full-width' !== generate_get_option( 'footer_inner_width' ) ) {
|
||||
$attributes['class'] .= ' grid-container';
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
$attributes['class'] .= ' grid-parent';
|
||||
}
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our entry headers.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function entry_header( $attributes ) {
|
||||
$attributes['class'] .= ' entry-header';
|
||||
$attributes['aria-label'] = esc_attr__( 'Content', 'generatepress' );
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our page headers.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function page_header( $attributes ) {
|
||||
$attributes['class'] .= ' page-header';
|
||||
$attributes['aria-label'] = esc_attr__( 'Page', 'generatepress' );
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our entry headers.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function post_navigation( $attributes ) {
|
||||
if ( is_single() ) {
|
||||
$attributes['class'] .= ' post-navigation';
|
||||
$attributes['aria-label'] = esc_attr__( 'Posts', 'generatepress' );
|
||||
} else {
|
||||
$attributes['class'] .= ' paging-navigation';
|
||||
$attributes['aria-label'] = esc_attr__( 'Archive Page', 'generatepress' );
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our page container.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function page( $attributes ) {
|
||||
$attributes['id'] = 'page';
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our site content container.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function site_content( $attributes ) {
|
||||
$attributes['id'] = 'content';
|
||||
$attributes['class'] .= ' site-content';
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our primary content container.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function content( $attributes ) {
|
||||
$attributes['id'] = 'primary';
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our primary content container.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function main( $attributes ) {
|
||||
$attributes['id'] = 'main';
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our left sidebar.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function left_sidebar( $attributes ) {
|
||||
$classes = generate_get_element_classes( 'left_sidebar' );
|
||||
|
||||
if ( $classes ) {
|
||||
$attributes['class'] .= ' ' . join( ' ', $classes );
|
||||
}
|
||||
|
||||
$attributes['id'] = 'left-sidebar';
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our right sidebar.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function right_sidebar( $attributes ) {
|
||||
$classes = generate_get_element_classes( 'right_sidebar' );
|
||||
|
||||
if ( $classes ) {
|
||||
$attributes['class'] .= ' ' . join( ' ', $classes );
|
||||
}
|
||||
|
||||
$attributes['id'] = 'right-sidebar';
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our footer widget inner container.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function footer_widgets_container( $attributes ) {
|
||||
$classes = generate_get_element_classes( 'inside_footer' );
|
||||
|
||||
if ( $classes ) {
|
||||
$attributes['class'] .= ' ' . join( ' ', $classes );
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our footer widget inner container.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
* @param array $settings Settings passed through the function.
|
||||
*/
|
||||
public function comment_body( $attributes, $settings ) {
|
||||
$attributes['class'] .= ' comment-body';
|
||||
$attributes['id'] = 'div-comment-' . $settings['comment-id'];
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our comment meta.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function comment_meta( $attributes ) {
|
||||
$attributes['class'] .= ' comment-meta';
|
||||
$attributes['aria-label'] = esc_attr__( 'Comment meta', 'generatepress' );
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our footer entry meta.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function footer_entry_meta( $attributes ) {
|
||||
$attributes['class'] .= ' entry-meta';
|
||||
$attributes['aria-label'] = esc_attr__( 'Entry meta', 'generatepress' );
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to our WooCommerce content container.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @param array $attributes The existing attributes.
|
||||
*/
|
||||
public function woocommerce_content( $attributes ) {
|
||||
if ( is_singular() ) {
|
||||
$attributes['id'] = 'post-' . get_the_ID();
|
||||
$attributes['class'] = esc_attr( implode( ' ', get_post_class( '', get_the_ID() ) ) );
|
||||
|
||||
if ( 'microdata' === generate_get_schema_type() ) {
|
||||
$type = apply_filters( 'generate_article_itemtype', 'CreativeWork' );
|
||||
|
||||
$attributes['itemtype'] = sprintf(
|
||||
'https://schema.org/%s',
|
||||
$type
|
||||
);
|
||||
|
||||
$attributes['itemscope'] = true;
|
||||
}
|
||||
} else {
|
||||
$attributes['class'] = 'woocommerce-archive-wrapper';
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_HTML_Attributes::get_instance();
|
151
wp-content/themes/generatepress/inc/class-rest.php
Normal file
151
wp-content/themes/generatepress/inc/class-rest.php
Normal file
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
/**
|
||||
* Rest API functions
|
||||
*
|
||||
* @package GenerateBlocks
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class GenerateBlocks_Rest
|
||||
*/
|
||||
class GeneratePress_Rest extends WP_REST_Controller {
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @access private
|
||||
* @var object Instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'generatepress/v';
|
||||
|
||||
/**
|
||||
* Version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $version = '1';
|
||||
|
||||
/**
|
||||
* Initiator.
|
||||
*
|
||||
* @return object initialized object of class.
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* GeneratePress_Rest constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register rest routes.
|
||||
*/
|
||||
public function register_routes() {
|
||||
$namespace = $this->namespace . $this->version;
|
||||
|
||||
register_rest_route(
|
||||
$namespace,
|
||||
'/reset/',
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'reset' ),
|
||||
'permission_callback' => array( $this, 'update_settings_permission' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edit options permissions.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update_settings_permission() {
|
||||
return current_user_can( 'manage_options' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset settings.
|
||||
*
|
||||
* @param WP_REST_Request $request request object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function reset( WP_REST_Request $request ) {
|
||||
delete_option( 'generate_settings' );
|
||||
delete_option( 'generate_dynamic_css_output' );
|
||||
delete_option( 'generate_dynamic_css_cached_version' );
|
||||
|
||||
return $this->success( __( 'Settings reset.', 'generatepress' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Success rest.
|
||||
*
|
||||
* @param mixed $response response data.
|
||||
* @return mixed
|
||||
*/
|
||||
public function success( $response ) {
|
||||
return new WP_REST_Response(
|
||||
array(
|
||||
'success' => true,
|
||||
'response' => $response,
|
||||
),
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Failed rest.
|
||||
*
|
||||
* @param mixed $response response data.
|
||||
* @return mixed
|
||||
*/
|
||||
public function failed( $response ) {
|
||||
return new WP_REST_Response(
|
||||
array(
|
||||
'success' => false,
|
||||
'response' => $response,
|
||||
),
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Error rest.
|
||||
*
|
||||
* @param mixed $code error code.
|
||||
* @param mixed $response response data.
|
||||
* @return mixed
|
||||
*/
|
||||
public function error( $code, $response ) {
|
||||
return new WP_REST_Response(
|
||||
array(
|
||||
'error' => true,
|
||||
'success' => false,
|
||||
'error_code' => $code,
|
||||
'response' => $response,
|
||||
),
|
||||
401
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Rest::get_instance();
|
408
wp-content/themes/generatepress/inc/class-theme-update.php
Normal file
408
wp-content/themes/generatepress/inc/class-theme-update.php
Normal file
@ -0,0 +1,408 @@
|
||||
<?php
|
||||
/**
|
||||
* Migrates old options on update.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Process option updates if necessary.
|
||||
*/
|
||||
class GeneratePress_Theme_Update {
|
||||
/**
|
||||
* Class instance.
|
||||
*
|
||||
* @access private
|
||||
* @var $instance Class instance.
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
if ( is_admin() ) {
|
||||
add_action( 'admin_init', __CLASS__ . '::init', 5 );
|
||||
} else {
|
||||
add_action( 'wp', __CLASS__ . '::init', 5 );
|
||||
}
|
||||
|
||||
add_action( 'admin_init', __CLASS__ . '::admin_updates', 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement theme update logic. Only run updates on existing sites.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public static function init() {
|
||||
if ( is_customize_preview() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$saved_version = get_option( 'generate_db_version', false );
|
||||
|
||||
if ( false === $saved_version ) {
|
||||
// Typically this would mean this is a new install, but we haven't always had the version saved, so we need to check for existing settings.
|
||||
|
||||
$existing_settings = get_option( 'generate_settings', array() );
|
||||
|
||||
// Can't count this as a user-set option since a previous migration script set it.
|
||||
if ( isset( $existing_settings['combine_css'] ) ) {
|
||||
unset( $existing_settings['combine_css'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $existing_settings ) ) {
|
||||
// We have settings, which means this is an old install with no version number.
|
||||
$saved_version = '2.0';
|
||||
} else {
|
||||
// No settings and no saved version, must be a new install.
|
||||
|
||||
if ( 'admin_init' === current_action() ) {
|
||||
// If we're in the admin, add our version to the database.
|
||||
update_option( 'generate_db_version', GENERATE_VERSION );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( version_compare( $saved_version, GENERATE_VERSION, '=' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( version_compare( $saved_version, '2.3.0', '<' ) ) {
|
||||
self::v_2_3_0();
|
||||
}
|
||||
|
||||
if ( version_compare( $saved_version, '3.0.0-alpha.1', '<' ) ) {
|
||||
self::v_3_0_0();
|
||||
}
|
||||
|
||||
if ( version_compare( $saved_version, '3.1.0-alpha.1', '<' ) ) {
|
||||
self::v_3_1_0();
|
||||
}
|
||||
|
||||
// Delete our CSS cache.
|
||||
delete_option( 'generate_dynamic_css_output' );
|
||||
delete_option( 'generate_dynamic_css_cached_version' );
|
||||
|
||||
// Reset our dynamic CSS file updated time so it regenerates.
|
||||
$dynamic_css_data = get_option( 'generatepress_dynamic_css_data', array() );
|
||||
|
||||
if ( ! empty( $dynamic_css_data ) ) {
|
||||
if ( isset( $dynamic_css_data['updated_time'] ) ) {
|
||||
unset( $dynamic_css_data['updated_time'] );
|
||||
}
|
||||
|
||||
update_option( 'generatepress_dynamic_css_data', $dynamic_css_data );
|
||||
}
|
||||
|
||||
// Last thing to do is update our version.
|
||||
update_option( 'generate_db_version', GENERATE_VERSION );
|
||||
}
|
||||
|
||||
/**
|
||||
* Less important updates that should only happen in the Dashboard.
|
||||
* These use a database flag instead of our version number for legacy reasons.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public static function admin_updates() {
|
||||
self::v_1_3_0();
|
||||
self::v_1_3_29();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove variants from font family values.
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public static function v_1_3_0() {
|
||||
// Don't run this if Typography add-on is activated.
|
||||
if ( function_exists( 'generate_fonts_customize_register' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$settings = get_option( 'generate_settings', array() );
|
||||
|
||||
if ( ! isset( $settings['font_body'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$value = $settings['font_body'];
|
||||
$needs_update = false;
|
||||
|
||||
// If our value has : in it.
|
||||
if ( ! empty( $value ) && strpos( $value, ':' ) !== false ) {
|
||||
// Remove the : and anything past it.
|
||||
$value = current( explode( ':', $value ) );
|
||||
|
||||
$settings['font_body'] = $value;
|
||||
$needs_update = true;
|
||||
}
|
||||
|
||||
if ( $needs_update ) {
|
||||
update_option( 'generate_settings', $settings );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move logo to custom_logo option as required by WP.org.
|
||||
*
|
||||
* @since 1.3.29
|
||||
*/
|
||||
public static function v_1_3_29() {
|
||||
if ( ! function_exists( 'the_custom_logo' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( get_theme_mod( 'custom_logo' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$settings = get_option( 'generate_settings', array() );
|
||||
|
||||
if ( ! isset( $settings['logo'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$old_value = $settings['logo'];
|
||||
|
||||
if ( empty( $old_value ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$logo = attachment_url_to_postid( $old_value );
|
||||
|
||||
if ( is_int( $logo ) ) {
|
||||
set_theme_mod( 'custom_logo', $logo );
|
||||
}
|
||||
|
||||
if ( get_theme_mod( 'custom_logo' ) ) {
|
||||
$settings['logo'] = '';
|
||||
update_option( 'generate_settings', $settings );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn off the combine CSS option for existing sites.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public static function v_2_3_0() {
|
||||
$settings = get_option( 'generate_settings', array() );
|
||||
$update_options = false;
|
||||
|
||||
if ( ! isset( $settings['combine_css'] ) ) {
|
||||
$settings['combine_css'] = false;
|
||||
$update_options = true;
|
||||
}
|
||||
|
||||
if ( $update_options ) {
|
||||
update_option( 'generate_settings', $settings );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update sites using old defaults.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public static function v_3_0_0() {
|
||||
$settings = get_option( 'generate_settings', array() );
|
||||
$update_options = false;
|
||||
|
||||
$old_defaults = array(
|
||||
'icons' => 'font',
|
||||
'structure' => 'floats',
|
||||
'hide_tagline' => '',
|
||||
'container_width' => '1100',
|
||||
'nav_position_setting' => 'nav-below-header',
|
||||
'container_alignment' => 'boxes',
|
||||
'background_color' => '#efefef',
|
||||
'text_color' => '#3a3a3a',
|
||||
'header_text_color' => '#3a3a3a',
|
||||
'header_link_color' => '#3a3a3a',
|
||||
'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',
|
||||
'sidebar_widget_title_color' => '#000000',
|
||||
'site_title_font_size' => '45',
|
||||
'mobile_site_title_font_size' => '30',
|
||||
'form_button_background_color' => '#666666',
|
||||
'form_button_background_color_hover' => '#3f3f3f',
|
||||
'footer_background_color' => '#222222',
|
||||
'footer_link_hover_color' => '#606060',
|
||||
'entry_meta_link_color' => '#595959',
|
||||
'entry_meta_link_color_hover' => '#1e73be',
|
||||
'blog_post_title_color' => '',
|
||||
'blog_post_title_hover_color' => '',
|
||||
'heading_1_font_size' => '40',
|
||||
'mobile_heading_1_font_size' => '30',
|
||||
'heading_1_weight' => '300',
|
||||
'heading_2_font_size' => '30',
|
||||
'mobile_heading_2_font_size' => '25',
|
||||
'heading_2_weight' => '300',
|
||||
'heading_3_font_size' => '20',
|
||||
'mobile_heading_3_font_size' => '',
|
||||
'heading_4_font_size' => '',
|
||||
'mobile_heading_4_font_size' => '',
|
||||
'heading_5_font_size' => '',
|
||||
'mobile_heading_5_font_size' => '',
|
||||
);
|
||||
|
||||
foreach ( $old_defaults as $key => $value ) {
|
||||
if ( ! isset( $settings[ $key ] ) ) {
|
||||
$settings[ $key ] = $value;
|
||||
$update_options = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $update_options ) {
|
||||
update_option( 'generate_settings', $settings );
|
||||
}
|
||||
|
||||
$spacing_settings = get_option( 'generate_spacing_settings', array() );
|
||||
$update_spacing_options = false;
|
||||
|
||||
$old_spacing_defaults = array(
|
||||
'left_sidebar_width' => '25',
|
||||
'right_sidebar_width' => '25',
|
||||
'top_bar_right' => '10',
|
||||
'top_bar_left' => '10',
|
||||
'mobile_top_bar_right' => '',
|
||||
'mobile_top_bar_left' => '',
|
||||
'header_top' => '40',
|
||||
'header_bottom' => '40',
|
||||
'mobile_header_right' => '',
|
||||
'mobile_header_left' => '',
|
||||
'mobile_widget_top' => '',
|
||||
'mobile_widget_right' => '',
|
||||
'mobile_widget_bottom' => '',
|
||||
'mobile_widget_left' => '',
|
||||
'mobile_footer_widget_container_top' => '',
|
||||
'mobile_footer_widget_container_right' => '',
|
||||
'mobile_footer_widget_container_bottom' => '',
|
||||
'mobile_footer_widget_container_left' => '',
|
||||
'footer_right' => '20',
|
||||
'footer_left' => '20',
|
||||
'mobile_footer_right' => '10',
|
||||
'mobile_footer_left' => '10',
|
||||
);
|
||||
|
||||
foreach ( $old_spacing_defaults as $key => $value ) {
|
||||
if ( ! isset( $spacing_settings[ $key ] ) ) {
|
||||
$spacing_settings[ $key ] = $value;
|
||||
$update_spacing_options = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $update_spacing_options ) {
|
||||
update_option( 'generate_spacing_settings', $spacing_settings );
|
||||
}
|
||||
|
||||
if ( $update_options || $update_spacing_options ) {
|
||||
delete_option( 'generate_dynamic_css_output' );
|
||||
delete_option( 'generate_dynamic_css_cached_version' );
|
||||
|
||||
// Reset our dynamic CSS file updated time so it regenerates.
|
||||
$dynamic_css_data = get_option( 'generatepress_dynamic_css_data', array() );
|
||||
|
||||
if ( ! empty( $dynamic_css_data ) ) {
|
||||
if ( isset( $dynamic_css_data['updated_time'] ) ) {
|
||||
unset( $dynamic_css_data['updated_time'] );
|
||||
}
|
||||
|
||||
update_option( 'generatepress_dynamic_css_data', $dynamic_css_data );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update sites using old defaults.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
public static function v_3_1_0() {
|
||||
$settings = get_option( 'generate_settings', array() );
|
||||
$update_options = false;
|
||||
|
||||
$old_defaults = array(
|
||||
'underline_links' => 'never',
|
||||
'use_dynamic_typography' => false,
|
||||
'background_color' => '#f7f8f9',
|
||||
'text_color' => '#222222',
|
||||
'link_color' => '#1e73be',
|
||||
'link_color_hover' => '#000000',
|
||||
'header_background_color' => '#ffffff',
|
||||
'site_title_color' => '#222222',
|
||||
'site_tagline_color' => '#757575',
|
||||
'navigation_background_color' => '#ffffff',
|
||||
'navigation_background_hover_color' => '#ffffff',
|
||||
'navigation_background_current_color' => '#ffffff',
|
||||
'navigation_text_color' => '#515151',
|
||||
'navigation_text_hover_color' => '#7a8896',
|
||||
'navigation_text_current_color' => '#7a8896',
|
||||
'subnavigation_background_color' => '#eaeaea',
|
||||
'subnavigation_background_hover_color' => '#eaeaea',
|
||||
'subnavigation_background_current_color' => '#eaeaea',
|
||||
'subnavigation_text_color' => '#515151',
|
||||
'subnavigation_text_hover_color' => '#7a8896',
|
||||
'subnavigation_text_current_color' => '#7a8896',
|
||||
'content_background_color' => '#ffffff',
|
||||
'blog_post_title_color' => '#222222',
|
||||
'blog_post_title_hover_color' => '#55555e',
|
||||
'entry_meta_text_color' => '#595959',
|
||||
'sidebar_widget_background_color' => '#ffffff',
|
||||
'footer_widget_background_color' => '#ffffff',
|
||||
'footer_widget_title_color' => '#000000',
|
||||
'footer_background_color' => '#55555e',
|
||||
'footer_text_color' => '#ffffff',
|
||||
'footer_link_color' => '#ffffff',
|
||||
'footer_link_hover_color' => '#d3d3d3',
|
||||
'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',
|
||||
);
|
||||
|
||||
foreach ( $old_defaults as $key => $value ) {
|
||||
if ( ! isset( $settings[ $key ] ) ) {
|
||||
$settings[ $key ] = $value;
|
||||
$update_options = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $update_options ) {
|
||||
update_option( 'generate_settings', $settings );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Theme_Update::get_instance();
|
@ -0,0 +1,306 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles typography migration.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles all of our typography migration.
|
||||
*/
|
||||
class GeneratePress_Typography_Migration {
|
||||
/**
|
||||
* Class instance.
|
||||
*
|
||||
* @access private
|
||||
* @var $instance Class instance.
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map our new typography keys to the old prefixes.
|
||||
*/
|
||||
public static function get_option_prefixes() {
|
||||
$data = array(
|
||||
array(
|
||||
'selector' => 'body',
|
||||
'legacy_prefix' => 'body',
|
||||
'group' => 'base',
|
||||
'module' => 'core',
|
||||
),
|
||||
array(
|
||||
'selector' => 'top-bar',
|
||||
'legacy_prefix' => 'top_bar',
|
||||
'group' => 'widgets',
|
||||
'module' => 'core',
|
||||
),
|
||||
array(
|
||||
'selector' => 'main-title',
|
||||
'legacy_prefix' => 'site_title',
|
||||
'group' => 'header',
|
||||
'module' => 'core',
|
||||
),
|
||||
array(
|
||||
'selector' => 'site-description',
|
||||
'legacy_prefix' => 'site_tagline',
|
||||
'group' => 'header',
|
||||
'module' => 'core',
|
||||
),
|
||||
array(
|
||||
'selector' => 'primary-menu-items',
|
||||
'legacy_prefix' => 'navigation',
|
||||
'group' => 'primaryNavigation',
|
||||
'module' => 'core',
|
||||
),
|
||||
array(
|
||||
'selector' => 'widget-titles',
|
||||
'legacy_prefix' => 'widget_title',
|
||||
'group' => 'widgets',
|
||||
'module' => 'core',
|
||||
),
|
||||
array(
|
||||
'selector' => 'buttons',
|
||||
'legacy_prefix' => 'buttons',
|
||||
'group' => 'content',
|
||||
'module' => 'core',
|
||||
),
|
||||
array(
|
||||
'selector' => 'single-content-title',
|
||||
'legacy_prefix' => 'single_post_title',
|
||||
'group' => 'content',
|
||||
'module' => 'core',
|
||||
),
|
||||
array(
|
||||
'selector' => 'archive-content-title',
|
||||
'legacy_prefix' => 'archive_post_title',
|
||||
'group' => 'content',
|
||||
'module' => 'core',
|
||||
),
|
||||
array(
|
||||
'selector' => 'footer',
|
||||
'legacy_prefix' => 'footer',
|
||||
'group' => 'footer',
|
||||
'module' => 'core',
|
||||
),
|
||||
);
|
||||
|
||||
$headings = array(
|
||||
'h1' => 'heading_1',
|
||||
'h2' => 'heading_2',
|
||||
'h3' => 'heading_3',
|
||||
'h4' => 'heading_4',
|
||||
'h5' => 'heading_5',
|
||||
'h6' => 'heading_6',
|
||||
);
|
||||
|
||||
foreach ( $headings as $selector => $legacy_prefix ) {
|
||||
$data[] = array(
|
||||
'selector' => $selector,
|
||||
'legacy_prefix' => $legacy_prefix,
|
||||
'group' => 'content',
|
||||
'module' => 'core',
|
||||
);
|
||||
}
|
||||
|
||||
if ( function_exists( 'generate_secondary_nav_typography_selectors' ) ) {
|
||||
$data[] = array(
|
||||
'selector' => 'secondary-nav-menu-items',
|
||||
'legacy_prefix' => 'secondary_navigation',
|
||||
'group' => 'secondaryNavigation',
|
||||
'module' => 'secondary-nav',
|
||||
);
|
||||
}
|
||||
|
||||
if ( function_exists( 'generate_menu_plus_typography_selectors' ) ) {
|
||||
$data[] = array(
|
||||
'selector' => 'off-canvas-panel-menu-items',
|
||||
'legacy_prefix' => 'slideout',
|
||||
'group' => 'offCanvasPanel',
|
||||
'module' => 'off-canvas-panel',
|
||||
);
|
||||
}
|
||||
|
||||
if ( function_exists( 'generate_woocommerce_typography_selectors' ) ) {
|
||||
$data[] = array(
|
||||
'selector' => 'woocommerce-catalog-product-titles',
|
||||
'legacy_prefix' => 'wc_product_title',
|
||||
'group' => 'wooCommerce',
|
||||
'module' => 'woocommerce',
|
||||
);
|
||||
|
||||
$data[] = array(
|
||||
'selector' => 'woocommerce-related-product-titles',
|
||||
'legacy_prefix' => 'wc_related_product_title',
|
||||
'group' => 'wooCommerce',
|
||||
'module' => 'woocommerce',
|
||||
);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we have a saved value.
|
||||
*
|
||||
* @param string $id The option ID.
|
||||
* @param array $settings The saved settings.
|
||||
* @param array $defaults The defaults.
|
||||
*/
|
||||
public static function has_saved_value( $id, $settings, $defaults ) {
|
||||
return isset( $settings[ $id ] )
|
||||
&& isset( $defaults[ $id ] )
|
||||
&& $defaults[ $id ] !== $settings[ $id ] // Need this because the Customizer treats defaults as saved values.
|
||||
&& (
|
||||
! empty( $settings[ $id ] )
|
||||
|| 0 === $settings[ $id ]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of our mapped typography data.
|
||||
*/
|
||||
public static function get_mapped_typography_data() {
|
||||
$settings = get_option( 'generate_settings', array() );
|
||||
$defaults = generate_get_default_fonts();
|
||||
$typography_mapping = array();
|
||||
|
||||
// These options don't have "font" in their IDs.
|
||||
$no_font_in_ids = array(
|
||||
'single_post_title',
|
||||
'archive_post_title',
|
||||
);
|
||||
|
||||
for ( $headings = 1; $headings < 7; $headings++ ) {
|
||||
$no_font_in_ids[] = 'heading_' . $headings;
|
||||
}
|
||||
|
||||
foreach ( self::get_option_prefixes() as $key => $data ) {
|
||||
$legacy_setting_ids = array(
|
||||
'fontFamily' => 'font_' . $data['legacy_prefix'],
|
||||
'fontWeight' => $data['legacy_prefix'] . '_font_weight',
|
||||
'textTransform' => $data['legacy_prefix'] . '_font_transform',
|
||||
'fontSize' => $data['legacy_prefix'] . '_font_size',
|
||||
'fontSizeMobile' => 'mobile_' . $data['legacy_prefix'] . 'font_size',
|
||||
'lineHeight' => $data['legacy_prefix'] . '_line_height',
|
||||
);
|
||||
|
||||
if ( 'slideout' === $data['legacy_prefix'] ) {
|
||||
$legacy_setting_ids['fontSizeMobile'] = $data['legacy_prefix'] . '_mobile_font_size';
|
||||
}
|
||||
|
||||
if ( in_array( $data['legacy_prefix'], $no_font_in_ids ) ) {
|
||||
$legacy_setting_ids['fontWeight'] = $data['legacy_prefix'] . '_weight';
|
||||
$legacy_setting_ids['textTransform'] = $data['legacy_prefix'] . '_transform';
|
||||
}
|
||||
|
||||
foreach ( $legacy_setting_ids as $name => $id ) {
|
||||
if ( self::has_saved_value( $id, $settings, $defaults ) ) {
|
||||
$typography_mapping[ $key ][ $name ] = $settings[ $id ];
|
||||
}
|
||||
|
||||
if ( 'secondary_navigation' === $data['legacy_prefix'] && function_exists( 'generate_secondary_nav_get_defaults' ) ) {
|
||||
$secondary_nav_settings = get_option( 'generate_secondary_nav_settings', array() );
|
||||
$secondary_nav_defaults = generate_secondary_nav_get_defaults();
|
||||
|
||||
if ( self::has_saved_value( $id, $secondary_nav_settings, $secondary_nav_defaults ) ) {
|
||||
$typography_mapping[ $key ][ $name ] = $secondary_nav_settings[ $id ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'body' === $key ) {
|
||||
if ( self::has_saved_value( 'body_line_height', $settings, $defaults ) ) {
|
||||
$typography_mapping[ $key ]['lineHeightUnit'] = '';
|
||||
}
|
||||
|
||||
if ( self::has_saved_value( 'paragraph_margin', $settings, $defaults ) ) {
|
||||
$typography_mapping[ $key ]['marginBottom'] = $settings['paragraph_margin'];
|
||||
$typography_mapping[ $key ]['marginBottomUnit'] = 'em';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'widget-titles' === $key && self::has_saved_value( 'widget_title_separator', $settings, $defaults ) ) {
|
||||
$typography_mapping[ $key ]['marginBottom'] = $settings['widget_title_separator'];
|
||||
$typography_mapping[ $key ]['marginBottomUnit'] = 'px';
|
||||
}
|
||||
|
||||
if ( 'h1' === $key || 'h2' === $key || 'h3' === $key ) {
|
||||
if ( self::has_saved_value( $data['legacy_prefix'] . '_margin_bottom', $settings, $defaults ) ) {
|
||||
$typography_mapping[ $key ]['marginBottom'] = $settings[ $data['legacy_prefix'] . '_margin_bottom' ];
|
||||
$typography_mapping[ $key ]['marginBottomUnit'] = 'px';
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $typography_mapping[ $key ]['fontSize'] ) ) {
|
||||
$typography_mapping[ $key ]['fontSizeUnit'] = 'px';
|
||||
}
|
||||
|
||||
if ( isset( $typography_mapping[ $key ] ) ) {
|
||||
$typography_mapping[ $key ]['selector'] = $data['selector'];
|
||||
$typography_mapping[ $key ]['module'] = $data['module'];
|
||||
$typography_mapping[ $key ]['group'] = $data['group'];
|
||||
}
|
||||
}
|
||||
|
||||
// Reset array keys starting at 0.
|
||||
$typography_mapping = array_values( $typography_mapping );
|
||||
|
||||
return $typography_mapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of our mapped font data.
|
||||
*/
|
||||
public static function get_mapped_font_data() {
|
||||
$font_mapping = array();
|
||||
|
||||
foreach ( self::get_option_prefixes() as $key => $data ) {
|
||||
$settings = get_option( 'generate_settings', array() );
|
||||
$defaults = generate_get_default_fonts();
|
||||
|
||||
if ( 'secondary_navigation' === $data['legacy_prefix'] && function_exists( 'generate_secondary_nav_get_defaults' ) ) {
|
||||
$settings = get_option( 'generate_secondary_nav_settings', array() );
|
||||
$defaults = generate_secondary_nav_get_defaults();
|
||||
}
|
||||
|
||||
if ( self::has_saved_value( 'font_' . $data['legacy_prefix'], $settings, $defaults ) ) {
|
||||
$has_font = array_search( $settings[ 'font_' . $data['legacy_prefix'] ], array_column( $font_mapping, 'fontFamily' ) );
|
||||
|
||||
if ( false !== $has_font ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$font_mapping[ $key ]['fontFamily'] = $settings[ 'font_' . $data['legacy_prefix'] ];
|
||||
|
||||
$local_fonts = generate_typography_default_fonts();
|
||||
|
||||
if ( ! in_array( $settings[ 'font_' . $data['legacy_prefix'] ], $local_fonts ) ) {
|
||||
$font_mapping[ $key ]['googleFont'] = true;
|
||||
$font_mapping[ $key ]['googleFontCategory'] = get_theme_mod( 'font_' . $data['legacy_prefix'] . '_category' );
|
||||
$font_mapping[ $key ]['googleFontVariants'] = get_theme_mod( 'font_' . $data['legacy_prefix'] . '_variants' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reset array keys starting at 0.
|
||||
$font_mapping = array_values( $font_mapping );
|
||||
|
||||
return $font_mapping;
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Typography_Migration::get_instance();
|
362
wp-content/themes/generatepress/inc/class-typography.php
Normal file
362
wp-content/themes/generatepress/inc/class-typography.php
Normal file
@ -0,0 +1,362 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles typography on the front-end.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles all of our typography option output.
|
||||
*/
|
||||
class GeneratePress_Typography {
|
||||
/**
|
||||
* Class instance.
|
||||
*
|
||||
* @access private
|
||||
* @var $instance Class instance.
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_google_fonts' ) );
|
||||
add_filter( 'generate_editor_styles', array( $this, 'add_editor_styles' ) );
|
||||
|
||||
// Load fonts the old way in versions before 5.8 as block_editor_settings_all didn't exist.
|
||||
if ( version_compare( $GLOBALS['wp_version'], '5.8', '<' ) ) {
|
||||
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_google_fonts' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate our Google Fonts URI.
|
||||
*/
|
||||
public static function get_google_fonts_uri() {
|
||||
$fonts = generate_get_option( 'font_manager' );
|
||||
|
||||
if ( empty( $fonts ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$google_fonts_uri = '';
|
||||
$data = array();
|
||||
|
||||
foreach ( $fonts as $font ) {
|
||||
if ( empty( $font['googleFont'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$variants = array();
|
||||
|
||||
if ( ! empty( $font['googleFontVariants'] ) ) {
|
||||
// Remove spaces from string.
|
||||
$variants = str_replace( ' ', '', $font['googleFontVariants'] );
|
||||
|
||||
// Turn string into array.
|
||||
$variants = explode( ',', $variants );
|
||||
}
|
||||
|
||||
$variants = apply_filters( 'generate_google_font_variants', $variants, $font['fontFamily'] );
|
||||
|
||||
$name = str_replace( ' ', '+', $font['fontFamily'] );
|
||||
$name = str_replace( '"', '', $name );
|
||||
|
||||
if ( $variants ) {
|
||||
$data[] = $name . ':' . implode( ',', $variants );
|
||||
} else {
|
||||
$data[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $data ) ) {
|
||||
$font_args = apply_filters(
|
||||
'generate_google_font_args',
|
||||
array(
|
||||
'family' => implode( '|', $data ),
|
||||
'subset' => null,
|
||||
'display' => generate_get_option( 'google_font_display' ),
|
||||
)
|
||||
);
|
||||
|
||||
$google_fonts_uri = add_query_arg( $font_args, 'https://fonts.googleapis.com/css' );
|
||||
}
|
||||
|
||||
return $google_fonts_uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Google Fonts if they're set.
|
||||
*/
|
||||
public function enqueue_google_fonts() {
|
||||
if ( ! generate_is_using_dynamic_typography() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$google_fonts_uri = self::get_google_fonts_uri();
|
||||
|
||||
if ( $google_fonts_uri ) {
|
||||
wp_enqueue_style( 'generate-google-fonts', $google_fonts_uri, array(), GENERATE_VERSION );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build our typography CSS.
|
||||
*
|
||||
* @param string $module The name of the module we're generating CSS for.
|
||||
*/
|
||||
public static function get_css( $module = 'core' ) {
|
||||
$typography = generate_get_option( 'typography' );
|
||||
|
||||
// Get data for a specific module so CSS can be compiled separately.
|
||||
$typography = array_filter(
|
||||
(array) $typography,
|
||||
function( $data ) use ( $module ) {
|
||||
return ( isset( $data['module'] ) && $data['module'] === $module );
|
||||
}
|
||||
);
|
||||
|
||||
if ( empty( $typography ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$css = new GeneratePress_CSS();
|
||||
|
||||
$body_selector = 'body';
|
||||
$paragraph_selector = 'p';
|
||||
|
||||
foreach ( $typography as $key => $data ) {
|
||||
$options = wp_parse_args(
|
||||
$data,
|
||||
self::get_defaults()
|
||||
);
|
||||
|
||||
$selector = self::get_css_selector( $options['selector'] );
|
||||
|
||||
if ( 'custom' === $selector ) {
|
||||
$selector = $options['customSelector'];
|
||||
}
|
||||
|
||||
$font_family = self::get_font_family( $options['fontFamily'] );
|
||||
|
||||
$css->set_selector( $selector );
|
||||
$css->add_property( 'font-family', $font_family );
|
||||
$css->add_property( 'font-weight', $options['fontWeight'] );
|
||||
$css->add_property( 'text-transform', $options['textTransform'] );
|
||||
$css->add_property( 'font-style', $options['fontStyle'] );
|
||||
$css->add_property( 'text-decoration', $options['textDecoration'] );
|
||||
$css->add_property( 'font-size', $options['fontSize'], false, $options['fontSizeUnit'] );
|
||||
$css->add_property( 'letter-spacing', $options['letterSpacing'], false, $options['letterSpacingUnit'] );
|
||||
|
||||
if ( 'body' !== $options['selector'] ) {
|
||||
$css->add_property( 'line-height', $options['lineHeight'], false, $options['lineHeightUnit'] );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottom'], false, $options['marginBottomUnit'] );
|
||||
} else {
|
||||
$css->set_selector( $body_selector );
|
||||
$css->add_property( 'line-height', $options['lineHeight'], false, $options['lineHeightUnit'] );
|
||||
|
||||
$css->set_selector( $paragraph_selector );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottom'], false, $options['marginBottomUnit'] );
|
||||
}
|
||||
|
||||
$css->start_media_query( generate_get_media_query( 'tablet' ) );
|
||||
|
||||
$css->set_selector( $selector );
|
||||
$css->add_property( 'font-size', $options['fontSizeTablet'], false, $options['fontSizeUnit'] );
|
||||
$css->add_property( 'letter-spacing', $options['letterSpacingTablet'], false, $options['letterSpacingUnit'] );
|
||||
|
||||
if ( 'body' !== $options['selector'] ) {
|
||||
$css->add_property( 'line-height', $options['lineHeightTablet'], false, $options['lineHeightUnit'] );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottomTablet'], false, $options['marginBottomUnit'] );
|
||||
} else {
|
||||
$css->set_selector( $body_selector );
|
||||
$css->add_property( 'line-height', $options['lineHeightTablet'], false, $options['lineHeightUnit'] );
|
||||
|
||||
$css->set_selector( $paragraph_selector );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottomTablet'], false, $options['marginBottomUnit'] );
|
||||
}
|
||||
|
||||
$css->stop_media_query();
|
||||
|
||||
$css->start_media_query( generate_get_media_query( 'mobile' ) );
|
||||
|
||||
$css->set_selector( $selector );
|
||||
$css->add_property( 'font-size', $options['fontSizeMobile'], false, $options['fontSizeUnit'] );
|
||||
$css->add_property( 'letter-spacing', $options['letterSpacingMobile'], false, $options['letterSpacingUnit'] );
|
||||
|
||||
if ( 'body' !== $options['selector'] ) {
|
||||
$css->add_property( 'line-height', $options['lineHeightMobile'], false, $options['lineHeightUnit'] );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottomMobile'], false, $options['marginBottomUnit'] );
|
||||
} else {
|
||||
$css->set_selector( $body_selector );
|
||||
$css->add_property( 'line-height', $options['lineHeightMobile'], false, $options['lineHeightUnit'] );
|
||||
|
||||
$css->set_selector( $paragraph_selector );
|
||||
$css->add_property( 'margin-bottom', $options['marginBottomMobile'], false, $options['marginBottomUnit'] );
|
||||
}
|
||||
|
||||
$css->stop_media_query();
|
||||
}
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CSS selector.
|
||||
*
|
||||
* @param string $selector The saved selector to look up.
|
||||
*/
|
||||
public static function get_css_selector( $selector ) {
|
||||
switch ( $selector ) {
|
||||
case 'body':
|
||||
$selector = 'body, button, input, select, textarea';
|
||||
break;
|
||||
|
||||
case 'main-title':
|
||||
$selector = '.main-title';
|
||||
break;
|
||||
|
||||
case 'site-description':
|
||||
$selector = '.site-description';
|
||||
break;
|
||||
|
||||
case 'primary-menu-items':
|
||||
$selector = '.main-navigation a, .main-navigation .menu-toggle, .main-navigation .menu-bar-items';
|
||||
break;
|
||||
|
||||
case 'primary-sub-menu-items':
|
||||
$selector = '.main-navigation .main-nav ul ul li a';
|
||||
break;
|
||||
|
||||
case 'primary-menu-toggle':
|
||||
$selector = '.main-navigation .menu-toggle';
|
||||
break;
|
||||
|
||||
case 'buttons':
|
||||
$selector = 'button:not(.menu-toggle),html input[type="button"],input[type="reset"],input[type="submit"],.button,.wp-block-button .wp-block-button__link';
|
||||
break;
|
||||
|
||||
case 'all-headings':
|
||||
$selector = 'h1, h2, h3, h4, h5, h6';
|
||||
break;
|
||||
|
||||
case 'single-content-title':
|
||||
$selector = 'h1.entry-title';
|
||||
break;
|
||||
|
||||
case 'archive-content-title':
|
||||
$selector = 'h2.entry-title';
|
||||
break;
|
||||
|
||||
case 'top-bar':
|
||||
$selector = '.top-bar';
|
||||
break;
|
||||
|
||||
case 'widget-titles':
|
||||
$selector = '.widget-title';
|
||||
break;
|
||||
|
||||
case 'footer':
|
||||
$selector = '.site-info';
|
||||
break;
|
||||
}
|
||||
|
||||
return apply_filters( 'generate_typography_css_selector', $selector );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our full font family value.
|
||||
*
|
||||
* @param string $font_family The font family name.
|
||||
*/
|
||||
public static function get_font_family( $font_family ) {
|
||||
if ( ! $font_family ) {
|
||||
return $font_family;
|
||||
}
|
||||
|
||||
$font_manager = generate_get_option( 'font_manager' );
|
||||
|
||||
$font_families = array();
|
||||
foreach ( (array) $font_manager as $key => $data ) {
|
||||
$font_families[ $data['fontFamily'] ] = $data;
|
||||
}
|
||||
|
||||
$font_family_args = array();
|
||||
if ( ! empty( $font_families[ $font_family ] ) ) {
|
||||
$font_family_args = $font_families[ $font_family ];
|
||||
}
|
||||
|
||||
if ( ! empty( $font_family_args['googleFont'] ) && ! empty( $font_family_args['googleFontCategory'] ) ) {
|
||||
// Add quotations around font names with standalone numbers.
|
||||
if ( preg_match( '/(?<!\S)\d+(?!\S)/', $font_family ) ) {
|
||||
$font_family = '"' . $font_family . '"';
|
||||
}
|
||||
|
||||
$font_family = $font_family . ', ' . $font_family_args['googleFontCategory'];
|
||||
} elseif ( 'System Default' === $font_family ) {
|
||||
$font_family = generate_get_system_default_font();
|
||||
}
|
||||
|
||||
return $font_family;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the defaults for our CSS options.
|
||||
*/
|
||||
public static function get_defaults() {
|
||||
return array(
|
||||
'selector' => '',
|
||||
'fontFamily' => '',
|
||||
'fontWeight' => '',
|
||||
'textTransform' => '',
|
||||
'textDecoration' => '',
|
||||
'fontStyle' => '',
|
||||
'fontSize' => '',
|
||||
'fontSizeTablet' => '',
|
||||
'fontSizeMobile' => '',
|
||||
'fontSizeUnit' => 'px',
|
||||
'lineHeight' => '',
|
||||
'lineHeightTablet' => '',
|
||||
'lineHeightMobile' => '',
|
||||
'lineHeightUnit' => '',
|
||||
'letterSpacing' => '',
|
||||
'letterSpacingTablet' => '',
|
||||
'letterSpacingMobile' => '',
|
||||
'letterSpacingUnit' => 'px',
|
||||
'marginBottom' => '',
|
||||
'marginBottomTablet' => '',
|
||||
'marginBottomMobile' => '',
|
||||
'marginBottomUnit' => 'px',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add editor styles to the block editor.
|
||||
*
|
||||
* @param array $editor_styles Existing styles.
|
||||
*/
|
||||
public function add_editor_styles( $editor_styles ) {
|
||||
if ( generate_is_using_dynamic_typography() ) {
|
||||
$editor_styles[] = 'assets/css/admin/editor-typography.css';
|
||||
}
|
||||
|
||||
return $editor_styles;
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Typography::get_instance();
|
1335
wp-content/themes/generatepress/inc/css-output.php
Normal file
1335
wp-content/themes/generatepress/inc/css-output.php
Normal file
File diff suppressed because it is too large
Load Diff
1573
wp-content/themes/generatepress/inc/customizer.php
Normal file
1573
wp-content/themes/generatepress/inc/customizer.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,217 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles adding Customizer controls.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper functions to add Customizer fields.
|
||||
*/
|
||||
class GeneratePress_Customize_Field {
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @access private
|
||||
* @var object Instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator.
|
||||
*
|
||||
* @since 1.2.0
|
||||
* @return object initialized object of class.
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a wrapper for defined controls.
|
||||
*
|
||||
* @param string $id The settings ID for this field.
|
||||
* @param array $control_args The args for add_control().
|
||||
*/
|
||||
public static function add_wrapper( $id, $control_args = array() ) {
|
||||
global $wp_customize;
|
||||
|
||||
if ( ! $id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$control_args['settings'] = isset( $wp_customize->selective_refresh ) ? array() : 'blogname';
|
||||
$control_args['choices']['id'] = str_replace( '_', '-', $id );
|
||||
$control_args['type'] = 'generate-wrapper-control';
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Customize_React_Control(
|
||||
$wp_customize,
|
||||
$id,
|
||||
$control_args
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a title.
|
||||
*
|
||||
* @param string $id The settings ID for this field.
|
||||
* @param array $control_args The args for add_control().
|
||||
*/
|
||||
public static function add_title( $id, $control_args = array() ) {
|
||||
global $wp_customize;
|
||||
|
||||
if ( ! $id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$control_args['settings'] = isset( $wp_customize->selective_refresh ) ? array() : 'blogname';
|
||||
$control_args['type'] = 'generate-title-control';
|
||||
$control_args['choices']['title'] = $control_args['title'];
|
||||
unset( $control_args['title'] );
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Customize_React_Control(
|
||||
$wp_customize,
|
||||
$id,
|
||||
$control_args
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Customizer field.
|
||||
*
|
||||
* @param string $id The settings ID for this field.
|
||||
* @param object $control_class A custom control classes if we want one.
|
||||
* @param array $setting_args The args for add_setting().
|
||||
* @param array $control_args The args for add_control().
|
||||
*/
|
||||
public static function add_field( $id, $control_class, $setting_args = array(), $control_args = array() ) {
|
||||
global $wp_customize;
|
||||
|
||||
if ( ! $id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$settings = wp_parse_args(
|
||||
$setting_args,
|
||||
array(
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'default' => '',
|
||||
'transport' => 'refresh',
|
||||
'validate_callback' => '',
|
||||
'sanitize_callback' => '',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
$id,
|
||||
array(
|
||||
'type' => $settings['type'],
|
||||
'capability' => $settings['capability'],
|
||||
'default' => $settings['default'],
|
||||
'transport' => $settings['transport'],
|
||||
'validate_callback' => $settings['validate_callback'],
|
||||
'sanitize_callback' => $settings['sanitize_callback'],
|
||||
)
|
||||
);
|
||||
|
||||
$control_args['settings'] = $id;
|
||||
|
||||
if ( ! isset( $control_args['type'] ) ) {
|
||||
unset( $control_args['type'] );
|
||||
}
|
||||
|
||||
if ( ! isset( $control_args['defaultValue'] ) && isset( $setting_args['default'] ) ) {
|
||||
$control_args['defaultValue'] = $setting_args['default'];
|
||||
}
|
||||
|
||||
if ( isset( $control_args['output'] ) ) {
|
||||
global $generate_customize_fields;
|
||||
|
||||
$generate_customize_fields[] = array(
|
||||
'js_vars' => $control_args['output'],
|
||||
'settings' => $id,
|
||||
);
|
||||
}
|
||||
|
||||
if ( $control_class ) {
|
||||
$wp_customize->add_control(
|
||||
new $control_class(
|
||||
$wp_customize,
|
||||
$id,
|
||||
$control_args
|
||||
)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$wp_customize->add_control(
|
||||
$id,
|
||||
$control_args
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add color field group.
|
||||
*
|
||||
* @param string $id The ID for the group wrapper.
|
||||
* @param string $section_id The section ID.
|
||||
* @param string $toggle_id The Toggle ID.
|
||||
* @param array $fields The color fields.
|
||||
*/
|
||||
public static function add_color_field_group( $id, $section_id, $toggle_id, $fields ) {
|
||||
self::add_wrapper(
|
||||
"generate_{$id}_wrapper",
|
||||
array(
|
||||
'section' => $section_id,
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => $toggle_id,
|
||||
'items' => array_keys( $fields ),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $fields as $key => $field ) {
|
||||
self::add_field(
|
||||
$key,
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $field['default_value'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => $field['label'],
|
||||
'section' => $section_id,
|
||||
'choices' => array(
|
||||
'alpha' => isset( $field['alpha'] ) ? $field['alpha'] : true,
|
||||
'toggleId' => $toggle_id,
|
||||
'wrapper' => $key,
|
||||
'tooltip' => $field['tooltip'],
|
||||
'hideLabel' => isset( $field['hide_label'] ) ? $field['hide_label'] : false,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $field['element'],
|
||||
'property' => $field['property'],
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Customize API: ColorAlpha class
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
/**
|
||||
* Customize Color Control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @see WP_Customize_Control
|
||||
*/
|
||||
class GeneratePress_Customize_Color_Control extends WP_Customize_Color_Control {
|
||||
/**
|
||||
* Type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'generate-color-control';
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @since 3.4.0
|
||||
* @uses WP_Customize_Control::to_json()
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['choices'] = $this->choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty JS template.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function content_template() {}
|
||||
}
|
@ -0,0 +1,303 @@
|
||||
<?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 {
|
||||
/**
|
||||
* Render content.
|
||||
*/
|
||||
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 { // phpcs:ignore
|
||||
/**
|
||||
* Render content.
|
||||
*/
|
||||
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 { // phpcs:ignore
|
||||
/**
|
||||
* Set type.
|
||||
*
|
||||
* @var $type
|
||||
*/
|
||||
public $type = 'gp-customizer-fonts';
|
||||
|
||||
/**
|
||||
* Enqueue scripts.
|
||||
*/
|
||||
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' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Send variables to json.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render content.
|
||||
*/
|
||||
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 { // phpcs:ignore
|
||||
/**
|
||||
* Set type.
|
||||
*
|
||||
* @var $type
|
||||
*/
|
||||
public $type = 'gp-typography-select';
|
||||
|
||||
/**
|
||||
* Set choices.
|
||||
*
|
||||
* @var $choices
|
||||
*/
|
||||
public $choices = array();
|
||||
|
||||
/**
|
||||
* Send variables to json.
|
||||
*/
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Render content.
|
||||
*/
|
||||
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 { // phpcs:ignore
|
||||
/**
|
||||
* Set type.
|
||||
*
|
||||
* @var $type
|
||||
*/
|
||||
public $type = 'gp-hidden-input';
|
||||
|
||||
/**
|
||||
* Set ID
|
||||
*
|
||||
* @var $id
|
||||
*/
|
||||
public $id = '';
|
||||
|
||||
/**
|
||||
* Send variables to json.
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['link'] = $this->get_link();
|
||||
$this->json['value'] = $this->value();
|
||||
$this->json['id'] = $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render content.
|
||||
*/
|
||||
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 { // phpcs:ignore
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param object $manager The manager.
|
||||
* @param int $id The ID.
|
||||
* @param array $args The args.
|
||||
* @param array $options The options.
|
||||
*/
|
||||
public function __construct( $manager, $id, $args = array(), $options = array() ) {
|
||||
parent::__construct( $manager, $id, $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the content of the category dropdown
|
||||
*/
|
||||
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 { // phpcs:ignore
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param object $manager The manager.
|
||||
* @param int $id The ID.
|
||||
* @param array $args The args.
|
||||
* @param array $options The options.
|
||||
*/
|
||||
public function __construct( $manager, $id, $args = array(), $options = array() ) {
|
||||
parent::__construct( $manager, $id, $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the content of the category dropdown
|
||||
*/
|
||||
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 { // phpcs:ignore
|
||||
/**
|
||||
* Render content.
|
||||
*/
|
||||
public function render_content() {}
|
||||
}
|
||||
}
|
@ -0,0 +1,209 @@
|
||||
<?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';
|
||||
|
||||
/**
|
||||
* The control description.
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $description = '';
|
||||
|
||||
/**
|
||||
* The control sub-description.
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
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',
|
||||
),
|
||||
GENERATE_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'generatepress-range-slider-css',
|
||||
trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/css/slider-customizer.css',
|
||||
array(),
|
||||
GENERATE_VERSION
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Customize API: ColorAlpha class
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
/**
|
||||
* Customize Color Control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @see WP_Customize_Control
|
||||
*/
|
||||
class GeneratePress_Customize_React_Control extends WP_Customize_Control {
|
||||
/**
|
||||
* Type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'generate-react-control';
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @since 3.4.0
|
||||
* @uses WP_Customize_Control::to_json()
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['choices'] = $this->choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty JS template.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function content_template() {}
|
||||
|
||||
/**
|
||||
* Empty PHP template.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_content() {}
|
||||
}
|
@ -0,0 +1,243 @@
|
||||
<?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 {
|
||||
/**
|
||||
* Set the type.
|
||||
*
|
||||
* @var string $type
|
||||
*/
|
||||
public $type = 'gp-customizer-typography';
|
||||
|
||||
/**
|
||||
* Enqueue scripts.
|
||||
*/
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send variables to json.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render content.
|
||||
*/
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
* Build font weight choices.
|
||||
*/
|
||||
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' ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build text transform choices.
|
||||
*/
|
||||
public function get_font_transform_choices() {
|
||||
return array(
|
||||
'none' => esc_html( 'none' ),
|
||||
'capitalize' => esc_html( 'capitalize' ),
|
||||
'uppercase' => esc_html( 'uppercase' ),
|
||||
'lowercase' => esc_html( 'lowercase' ),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
<?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 {
|
||||
/**
|
||||
* Set description.
|
||||
*
|
||||
* @var public $description
|
||||
*/
|
||||
public $description = '';
|
||||
|
||||
/**
|
||||
* Set URL.
|
||||
*
|
||||
* @var public $url
|
||||
*/
|
||||
public $url = '';
|
||||
|
||||
/**
|
||||
* Set type.
|
||||
*
|
||||
* @var public $type
|
||||
*/
|
||||
public $type = 'addon';
|
||||
|
||||
/**
|
||||
* Set label.
|
||||
*
|
||||
* @var public $label
|
||||
*/
|
||||
public $label = '';
|
||||
|
||||
/**
|
||||
* Enqueue scripts.
|
||||
*/
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send variables to json.
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['url'] = esc_url( $this->url );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render content.
|
||||
*/
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
<?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 {
|
||||
/**
|
||||
* Set type.
|
||||
*
|
||||
* @var public $type
|
||||
*/
|
||||
public $type = 'gp-upsell-section';
|
||||
|
||||
/**
|
||||
* Set pro URL.
|
||||
*
|
||||
* @var public $pro_url
|
||||
*/
|
||||
public $pro_url = '';
|
||||
|
||||
/**
|
||||
* Set pro text.
|
||||
*
|
||||
* @var public $pro_text
|
||||
*/
|
||||
public $pro_text = '';
|
||||
|
||||
/**
|
||||
* Set ID.
|
||||
*
|
||||
* @var public $id
|
||||
*/
|
||||
public $id = '';
|
||||
|
||||
/**
|
||||
* Send variables to json.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render content.
|
||||
*/
|
||||
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' ),
|
||||
GENERATE_VERSION,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
1
wp-content/themes/generatepress/inc/customizer/controls/css/selectWoo.min.css
vendored
Normal file
1
wp-content/themes/generatepress/inc/customizer/controls/css/selectWoo.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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: never;
|
||||
display: block;
|
||||
padding: 0;
|
||||
text-indent: 0;
|
||||
text-align: center;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
@ -0,0 +1,297 @@
|
||||
( function( api ) {
|
||||
'use strict';
|
||||
|
||||
// Add callback for when the header_textcolor setting exists.
|
||||
api( 'generate_settings[nav_position_setting]', function( setting ) {
|
||||
var isNavFloated, isNavAlignable, setNavDropPointActiveState, setNavAlignmentsActiveState;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine whether the navigation is align-able.
|
||||
*
|
||||
* @returns {boolean} Is floating?
|
||||
*/
|
||||
isNavAlignable = function() {
|
||||
if ( 'nav-float-right' === setting.get() || 'nav-float-left' === setting.get() ) {
|
||||
var navAsHeader = api.instance( 'generate_menu_plus_settings[navigation_as_header]' );
|
||||
|
||||
if ( navAsHeader && navAsHeader.get() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update a control's active state according to the navigation location setting's value.
|
||||
*
|
||||
* @param {wp.customize.Control} control
|
||||
*/
|
||||
setNavDropPointActiveState = 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 );
|
||||
};
|
||||
|
||||
/**
|
||||
* Update a control's active state according to the navigation location setting's value.
|
||||
*
|
||||
* @param {wp.customize.Control} control
|
||||
*/
|
||||
setNavAlignmentsActiveState = function( control ) {
|
||||
var setActiveState = function() {
|
||||
control.active.set( isNavAlignable() );
|
||||
};
|
||||
|
||||
// FYI: With the following we can eliminate all of our PHP active_callback code.
|
||||
control.active.validate = isNavAlignable;
|
||||
|
||||
// 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 );
|
||||
};
|
||||
|
||||
api.control( 'generate_settings[nav_drop_point]', setNavDropPointActiveState );
|
||||
api.control( 'generate_settings[nav_layout_setting]', setNavAlignmentsActiveState );
|
||||
api.control( 'generate_settings[nav_inner_width]', setNavAlignmentsActiveState );
|
||||
api.control( 'generate_settings[nav_alignment_setting]', setNavAlignmentsActiveState );
|
||||
} );
|
||||
|
||||
var setOption = function( options ) {
|
||||
if ( options.headerAlignment ) {
|
||||
api.instance( 'generate_settings[header_alignment_setting]' ).set( options.headerAlignment );
|
||||
}
|
||||
|
||||
if ( options.navLocation ) {
|
||||
api.instance( 'generate_settings[nav_position_setting]' ).set( options.navLocation );
|
||||
}
|
||||
|
||||
if ( options.navAlignment ) {
|
||||
api.instance( 'generate_settings[nav_alignment_setting]' ).set( options.navAlignment );
|
||||
}
|
||||
|
||||
if ( options.boxAlignment ) {
|
||||
api.instance( 'generate_settings[container_alignment]' ).set( options.boxAlignment );
|
||||
}
|
||||
|
||||
if ( options.siteTitleFontSize ) {
|
||||
api.instance( 'generate_settings[site_title_font_size]' ).set( options.siteTitleFontSize );
|
||||
}
|
||||
|
||||
if ( 'undefined' !== typeof options.hideSiteTagline ) {
|
||||
api.instance( 'generate_settings[hide_tagline]' ).set( options.hideSiteTagline );
|
||||
}
|
||||
|
||||
if ( options.headerPaddingTop ) {
|
||||
api.instance( 'generate_spacing_settings[header_top]' ).set( options.headerPaddingTop );
|
||||
}
|
||||
|
||||
if ( options.headerPaddingBottom ) {
|
||||
api.instance( 'generate_spacing_settings[header_bottom]' ).set( options.headerPaddingBottom );
|
||||
}
|
||||
};
|
||||
|
||||
api( 'generate_header_helper', function( value ) {
|
||||
var headerAlignment = false,
|
||||
navLocation = false,
|
||||
navAlignment = false,
|
||||
boxAlignment = false,
|
||||
siteTitleFontSize = false,
|
||||
hideSiteTagline = false,
|
||||
headerPaddingTop = false,
|
||||
headerPaddingBottom = false;
|
||||
|
||||
value.bind( function( newval ) {
|
||||
var headerAlignmentSetting = api.instance( 'generate_settings[header_alignment_setting]' );
|
||||
var navLocationSetting = api.instance( 'generate_settings[nav_position_setting]' );
|
||||
var navAlignmentSetting = api.instance( 'generate_settings[nav_alignment_setting]' );
|
||||
var boxAlignmentSetting = api.instance( 'generate_settings[container_alignment]' );
|
||||
var siteTitleFontSizeSetting = api.instance( 'generate_settings[site_title_font_size]' );
|
||||
var hideSiteTaglineSetting = api.instance( 'generate_settings[hide_tagline]' );
|
||||
var headerPaddingTopSetting = api.instance( 'generate_spacing_settings[header_top]' );
|
||||
var headerPaddingBottomSetting = api.instance( 'generate_spacing_settings[header_bottom]' );
|
||||
|
||||
if ( ! headerAlignmentSetting._dirty ) {
|
||||
headerAlignment = headerAlignmentSetting.get();
|
||||
}
|
||||
|
||||
if ( ! navLocationSetting._dirty ) {
|
||||
navLocation = navLocationSetting.get();
|
||||
}
|
||||
|
||||
if ( ! navAlignmentSetting._dirty ) {
|
||||
navAlignment = navAlignmentSetting.get();
|
||||
}
|
||||
|
||||
if ( ! boxAlignmentSetting._dirty ) {
|
||||
boxAlignment = boxAlignmentSetting.get();
|
||||
}
|
||||
|
||||
if ( ! siteTitleFontSizeSetting._dirty ) {
|
||||
siteTitleFontSize = siteTitleFontSizeSetting.get();
|
||||
}
|
||||
|
||||
if ( ! hideSiteTaglineSetting._dirty ) {
|
||||
hideSiteTagline = hideSiteTaglineSetting.get();
|
||||
}
|
||||
|
||||
if ( ! headerPaddingTopSetting._dirty ) {
|
||||
headerPaddingTop = headerPaddingTopSetting.get();
|
||||
}
|
||||
|
||||
if ( ! headerPaddingBottomSetting._dirty ) {
|
||||
headerPaddingBottom = headerPaddingBottomSetting.get();
|
||||
}
|
||||
|
||||
var options = {
|
||||
headerAlignment: generatepress_defaults.header_alignment_setting,
|
||||
navLocation: generatepress_defaults.nav_position_setting,
|
||||
navAlignment: generatepress_defaults.nav_alignment_setting,
|
||||
boxAlignment: generatepress_defaults.container_alignment,
|
||||
siteTitleFontSize: generatepress_typography_defaults.site_title_font_size,
|
||||
hideSiteTagline: generatepress_defaults.hide_tagline,
|
||||
headerPaddingTop: generatepress_spacing_defaults.header_top,
|
||||
headerPaddingBottom: generatepress_spacing_defaults.header_bottom,
|
||||
};
|
||||
|
||||
if ( 'current' === newval ) {
|
||||
options = {
|
||||
headerAlignment: headerAlignment,
|
||||
navLocation: navLocation,
|
||||
navAlignment: navAlignment,
|
||||
boxAlignment: boxAlignment,
|
||||
siteTitleFontSize: siteTitleFontSize,
|
||||
hideSiteTagline: hideSiteTagline,
|
||||
headerPaddingTop: headerPaddingTop,
|
||||
headerPaddingBottom: headerPaddingBottom,
|
||||
};
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'default' === newval ) {
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'classic' === newval ) {
|
||||
var options = {
|
||||
headerAlignment: 'left',
|
||||
navLocation: 'nav-below-header',
|
||||
navAlignment: 'left',
|
||||
boxAlignment: 'boxes',
|
||||
siteTitleFontSize: '45',
|
||||
hideSiteTagline: '',
|
||||
headerPaddingTop: '40',
|
||||
headerPaddingBottom: '40',
|
||||
};
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'nav-before' === newval ) {
|
||||
options['headerAlignment'] = 'left';
|
||||
options['navLocation'] = 'nav-above-header';
|
||||
options['navAlignment'] = 'left';
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'nav-after' === newval ) {
|
||||
options['headerAlignment'] = 'left';
|
||||
options['navLocation'] = 'nav-below-header';
|
||||
options['navAlignment'] = 'left';
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'nav-before-centered' === newval ) {
|
||||
options['headerAlignment'] = 'center';
|
||||
options['navLocation'] = 'nav-above-header';
|
||||
options['navAlignment'] = 'center';
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'nav-after-centered' === newval ) {
|
||||
options['headerAlignment'] = 'center';
|
||||
options['navLocation'] = 'nav-below-header';
|
||||
options['navAlignment'] = 'center';
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'nav-left' === newval ) {
|
||||
options['headerAlignment'] = 'left';
|
||||
options['navLocation'] = 'nav-float-left';
|
||||
options['navAlignment'] = 'right';
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
api( 'generate_settings[use_dynamic_typography]', function( value ) {
|
||||
var fontManager = api.control( 'generate_settings[font_manager]' );
|
||||
var typographyManager = api.control( 'generate_settings[typography]' );
|
||||
|
||||
value.bind( function( newval ) {
|
||||
if ( newval ) {
|
||||
if ( fontManager.setting.get().length === 0 ) {
|
||||
fontManager.setting.set( generatepressCustomizeControls.mappedTypographyData.fonts );
|
||||
}
|
||||
|
||||
if ( typographyManager.setting.get().length === 0 ) {
|
||||
typographyManager.setting.set( generatepressCustomizeControls.mappedTypographyData.typography );
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}( wp.customize ) );
|
@ -0,0 +1,522 @@
|
||||
/**
|
||||
* Theme Customizer enhancements for a better user experience.
|
||||
*
|
||||
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
|
||||
*
|
||||
* @param id
|
||||
* @param selector
|
||||
* @param property
|
||||
* @param default_value
|
||||
* @param get_value
|
||||
*/
|
||||
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', '' );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* 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' );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ) {
|
||||
var navLocation = wp.customize.value( 'generate_settings[nav_position_setting]' )();
|
||||
|
||||
if ( $( 'body' ).hasClass( 'sticky-enabled' ) ) {
|
||||
wp.customize.preview.send( 'refresh' );
|
||||
} else {
|
||||
var mainNavigation = $( '.main-navigation' );
|
||||
|
||||
if ( 'fluid-nav' == newval ) {
|
||||
mainNavigation.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 ) {
|
||||
if ( ! mainNavigation.hasClass( 'has-branding' ) && generatepress_live_preview.isFlex && ( 'nav-float-right' === navLocation || 'nav-float-left' === navLocation ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainNavigation.addClass( 'grid-container' ).addClass( '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 alignment
|
||||
*/
|
||||
wp.customize( 'generate_settings[nav_alignment_setting]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
var classes = [ 'left', 'center', 'right' ];
|
||||
var selector = 'body';
|
||||
var prefix = 'nav-aligned-';
|
||||
|
||||
if ( generatepress_live_preview.isFlex ) {
|
||||
selector = '.main-navigation:not(.slideout-navigation)';
|
||||
prefix = 'nav-align-';
|
||||
}
|
||||
|
||||
jQuery.each( classes, function( i, v ) {
|
||||
jQuery( selector ).removeClass( prefix + v );
|
||||
} );
|
||||
|
||||
if ( generatepress_live_preview.isFlex && generatepress_live_preview.isRTL ) {
|
||||
jQuery( selector ).addClass( prefix + newval );
|
||||
} else if ( 'nav-align-left' !== prefix + newval ) {
|
||||
jQuery( selector ).addClass( prefix + newval );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* 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(),
|
||||
containerLayout = wp.customize( 'generate_settings[content_layout_setting]' ).get(),
|
||||
contentLeft = generatepress_live_preview.contentLeft,
|
||||
contentRight = generatepress_live_preview.contentRight;
|
||||
|
||||
if ( ! generatepress_live_preview.isFlex && '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( 'body:not(.full-width-content) #page{max-width:' + newContainerWidth + 'px;}' );
|
||||
} else {
|
||||
jQuery( 'head' ).append( '<style id="wide_container_width">body:not(.full-width-content) #page{max-width:' + newContainerWidth + 'px;}</style>' );
|
||||
setTimeout( function() {
|
||||
jQuery( 'style#wide_container_width' ).not( ':last' ).remove();
|
||||
}, 100 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( generatepress_live_preview.isFlex && 'boxes' === containerAlignment ) {
|
||||
var topBarPaddingLeft = jQuery( '.inside-top-bar' ).css( 'padding-left' ),
|
||||
topBarPaddingRight = jQuery( '.inside-top-bar' ).css( 'padding-right' ),
|
||||
headerPaddingLeft = jQuery( '.inside-header' ).css( 'padding-left' ),
|
||||
headerPaddingRight = jQuery( '.inside-header' ).css( 'padding-right' ),
|
||||
footerWidgetPaddingLeft = jQuery( '.footer-widgets-container' ).css( 'padding-left' ),
|
||||
footerWidgetPaddingRight = jQuery( '.footer-widgets-container' ).css( 'padding-right' ),
|
||||
footerBarPaddingLeft = jQuery( '.inside-footer-bar' ).css( 'padding-left' ),
|
||||
footerBarPaddingRight = jQuery( '.inside-footer-bar' ).css( 'padding-right' );
|
||||
|
||||
if ( typeof wp.customize( 'generate_spacing_settings[top_bar_left]' ) !== 'undefined' ) {
|
||||
topBarPaddingLeft = wp.customize( 'generate_spacing_settings[top_bar_left]' ).get() + 'px';
|
||||
}
|
||||
|
||||
if ( typeof wp.customize( 'generate_spacing_settings[top_bar_right]' ) !== 'undefined' ) {
|
||||
topBarPaddingRight = wp.customize( 'generate_spacing_settings[top_bar_right]' ).get() + 'px';
|
||||
}
|
||||
|
||||
if ( typeof wp.customize( 'generate_spacing_settings[header_left]' ) !== 'undefined' ) {
|
||||
headerPaddingLeft = wp.customize( 'generate_spacing_settings[header_left]' ).get() + 'px';
|
||||
}
|
||||
|
||||
if ( typeof wp.customize( 'generate_spacing_settings[header_right]' ) !== 'undefined' ) {
|
||||
headerPaddingRight = wp.customize( 'generate_spacing_settings[header_right]' ).get() + 'px';
|
||||
}
|
||||
|
||||
if ( typeof wp.customize( 'generate_spacing_settings[footer_widget_container_left]' ) !== 'undefined' ) {
|
||||
footerWidgetPaddingLeft = wp.customize( 'generate_spacing_settings[footer_widget_container_left]' ).get() + 'px';
|
||||
}
|
||||
|
||||
if ( typeof wp.customize( 'generate_spacing_settings[footer_widget_container_right]' ) !== 'undefined' ) {
|
||||
footerWidgetPaddingRight = wp.customize( 'generate_spacing_settings[footer_widget_container_right]' ).get() + 'px';
|
||||
}
|
||||
|
||||
if ( typeof wp.customize( 'generate_spacing_settings[footer_left]' ) !== 'undefined' ) {
|
||||
footerBarPaddingLeft = wp.customize( 'generate_spacing_settings[footer_left]' ).get() + 'px';
|
||||
}
|
||||
|
||||
if ( typeof wp.customize( 'generate_spacing_settings[footer_right]' ) !== 'undefined' ) {
|
||||
footerBarPaddingRight = wp.customize( 'generate_spacing_settings[footer_right]' ).get() + 'px';
|
||||
}
|
||||
|
||||
var newTopBarWidth = parseFloat( containerWidth ) + parseFloat( topBarPaddingLeft ) + parseFloat( topBarPaddingRight ),
|
||||
newHeaderWidth = parseFloat( containerWidth ) + parseFloat( headerPaddingLeft ) + parseFloat( headerPaddingRight ),
|
||||
newFooterWidgetWidth = parseFloat( containerWidth ) + parseFloat( footerWidgetPaddingLeft ) + parseFloat( footerWidgetPaddingRight ),
|
||||
newFooterBarWidth = parseFloat( containerWidth ) + parseFloat( footerBarPaddingLeft ) + parseFloat( footerBarPaddingRight );
|
||||
|
||||
if ( jQuery( 'style#box_sizing_widths' ).length ) {
|
||||
jQuery( 'style#box_sizing_widths' ).html( '.inside-top-bar.grid-container{max-width:' + newTopBarWidth + 'px;}.inside-header.grid-container{max-width:' + newHeaderWidth + 'px;}.footer-widgets-container.grid-container{max-width:' + newFooterWidgetWidth + 'px;}.inside-site-info.grid-container{max-width:' + newFooterBarWidth + 'px;}' );
|
||||
} else {
|
||||
jQuery( 'head' ).append( '<style id="box_sizing_widths">.inside-top-bar.grid-container{max-width:' + newTopBarWidth + 'px;}.inside-header.grid-container{max-width:' + newHeaderWidth + 'px;}.footer-widgets-container.grid-container{max-width:' + newFooterWidgetWidth + 'px;}.inside-site-info.grid-container{max-width:' + newFooterBarWidth + 'px;}</style>' );
|
||||
setTimeout( function() {
|
||||
jQuery( 'style#box_sizing_widths' ).not( ':last' ).remove();
|
||||
}, 100 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( generatepress_live_preview.isFlex && 'text' === containerAlignment ) {
|
||||
var headerPaddingLeft = jQuery( '.inside-header' ).css( 'padding-left' ),
|
||||
headerPaddingRight = jQuery( '.inside-header' ).css( 'padding-right' ),
|
||||
menuItemPadding = jQuery( '.main-navigation .main-nav ul li a' ).css( 'padding-left' ),
|
||||
secondaryMenuItemPadding = jQuery( '.secondary-navigation .main-nav ul li a' ).css( 'padding-left' );
|
||||
|
||||
if ( typeof wp.customize( 'generate_spacing_settings[header_left]' ) !== 'undefined' ) {
|
||||
headerPaddingLeft = wp.customize( 'generate_spacing_settings[header_left]' ).get() + 'px';
|
||||
}
|
||||
|
||||
if ( typeof wp.customize( 'generate_spacing_settings[header_right]' ) !== 'undefined' ) {
|
||||
headerPaddingRight = wp.customize( 'generate_spacing_settings[header_right]' ).get() + 'px';
|
||||
}
|
||||
|
||||
if ( typeof wp.customize( 'generate_spacing_settings[menu_item]' ) !== 'undefined' ) {
|
||||
menuItemPadding = wp.customize( 'generate_spacing_settings[menu_item]' ).get() + 'px';
|
||||
}
|
||||
|
||||
if ( typeof wp.customize( 'generate_spacing_settings[secondary_menu_item]' ) !== 'undefined' ) {
|
||||
secondaryMenuItemPadding = wp.customize( 'generate_spacing_settings[secondary_menu_item]' ).get() + 'px';
|
||||
}
|
||||
|
||||
var newNavPaddingLeft = parseFloat( headerPaddingLeft ) - parseFloat( menuItemPadding ),
|
||||
newNavPaddingRight = parseFloat( headerPaddingRight ) - parseFloat( menuItemPadding ),
|
||||
newSecondaryNavPaddingLeft = parseFloat( headerPaddingLeft ) - parseFloat( secondaryMenuItemPadding ),
|
||||
newSecondaryNavPaddingRight = parseFloat( headerPaddingRight ) - parseFloat( secondaryMenuItemPadding );
|
||||
|
||||
if ( jQuery( 'style#navigation_padding' ).length ) {
|
||||
jQuery( 'style#navigation_padding' ).html( '.nav-below-header .main-navigation .inside-navigation.grid-container, .nav-above-header .main-navigation .inside-navigation.grid-container{padding: 0 ' + newNavPaddingRight + 'px 0 ' + newNavPaddingLeft + 'px;}' );
|
||||
jQuery( 'style#secondary_navigation_padding' ).html( '.secondary-nav-below-header .secondary-navigation .inside-navigation.grid-container, .secondary-nav-above-header .secondary-navigation .inside-navigation.grid-container{padding: 0 ' + newSecondaryNavPaddingRight + 'px 0 ' + newSecondaryNavPaddingLeft + 'px;}' );
|
||||
} else {
|
||||
jQuery( 'head' ).append( '<style id="navigation_padding">.nav-below-header .main-navigation .inside-navigation.grid-container, .nav-above-header .main-navigation .inside-navigation.grid-container{padding: 0 ' + newNavPaddingRight + 'px 0 ' + newNavPaddingLeft + 'px;}</style>' );
|
||||
jQuery( 'head' ).append( '<style id="secondary_navigation_padding">.secondary-nav-below-header .secondary-navigation .inside-navigation.grid-container, .secondary-nav-above-header .secondary-navigation .inside-navigation.grid-container{padding: 0 ' + newSecondaryNavPaddingRight + 'px 0 ' + newSecondaryNavPaddingLeft + 'px;}</style>' );
|
||||
setTimeout( function() {
|
||||
jQuery( 'style#navigation_padding' ).not( ':last' ).remove();
|
||||
jQuery( 'style#secondary_navigation_padding' ).not( ':last' ).remove();
|
||||
}, 100 );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
wp.customize( 'generate_settings[global_colors]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
var globalColors = '';
|
||||
|
||||
newval.forEach( function( item ) {
|
||||
globalColors += '--' + item.slug + ':' + item.color + ';';
|
||||
} );
|
||||
|
||||
if ( $( 'style#global_colors' ).length ) {
|
||||
$( 'style#global_colors' ).html( ':root{' + globalColors + '}' );
|
||||
} else {
|
||||
$( 'head' ).append( '<style id="global_colors">:root{' + globalColors + '}</style>' );
|
||||
|
||||
setTimeout( function() {
|
||||
$( 'style#global_colors' ).not( ':last' ).remove();
|
||||
}, 100 );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}( jQuery ) );
|
@ -0,0 +1,341 @@
|
||||
/* global gpPostMessageFields */
|
||||
/* eslint max-depth: off */
|
||||
var gpPostMessage = {
|
||||
|
||||
/**
|
||||
* The fields.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
fields: {},
|
||||
|
||||
/**
|
||||
* A collection of methods for the <style> tags.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
styleTag: {
|
||||
|
||||
/**
|
||||
* Add a <style> tag in <head> if it doesn't already exist.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param {string} id - The field-ID.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
add( id ) {
|
||||
id = id.replace( /[^\w\s]/gi, '-' );
|
||||
if ( null === document.getElementById( 'gp-postmessage-' + id ) || 'undefined' === typeof document.getElementById( 'gp-postmessage-' + id ) ) {
|
||||
jQuery( 'head' ).append( '<style id="gp-postmessage-' + id + '"></style>' );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a <style> tag in <head> if it doesn't already exist,
|
||||
* by calling the this.add method, and then add styles inside it.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param {string} id - The field-ID.
|
||||
* @param {string} styles - The styles to add.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
addData( id, styles ) {
|
||||
id = id.replace( '[', '-' ).replace( ']', '' );
|
||||
gpPostMessage.styleTag.add( id );
|
||||
jQuery( '#gp-postmessage-' + id ).text( styles );
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Common utilities.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
util: {
|
||||
|
||||
/**
|
||||
* Processes the value and applies any replacements and/or additions.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param {Object} output - The output (js_vars) argument.
|
||||
* @param {mixed} value - The value.
|
||||
* @param {string} controlType - The control-type.
|
||||
*
|
||||
* @return {string|false} - Returns false if value is excluded, otherwise a string.
|
||||
*/
|
||||
processValue( output, value ) {
|
||||
var self = this,
|
||||
settings = window.parent.wp.customize.get(),
|
||||
excluded = false;
|
||||
|
||||
if ( 'object' === typeof value ) {
|
||||
_.each( value, function( subValue, key ) {
|
||||
value[ key ] = self.processValue( output, subValue );
|
||||
} );
|
||||
return value;
|
||||
}
|
||||
output = _.defaults( output, {
|
||||
prefix: '',
|
||||
units: '',
|
||||
suffix: '',
|
||||
value_pattern: '$',
|
||||
pattern_replace: {},
|
||||
exclude: [],
|
||||
} );
|
||||
|
||||
if ( 1 <= output.exclude.length ) {
|
||||
_.each( output.exclude, function( exclusion ) {
|
||||
if ( value == exclusion ) {
|
||||
excluded = true;
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
if ( excluded ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
value = output.value_pattern.replace( new RegExp( '\\$', 'g' ), value );
|
||||
_.each( output.pattern_replace, function( id, placeholder ) {
|
||||
if ( ! _.isUndefined( settings[ id ] ) ) {
|
||||
value = value.replace( placeholder, settings[ id ] );
|
||||
}
|
||||
} );
|
||||
return output.prefix + value + output.units + output.suffix;
|
||||
},
|
||||
|
||||
/**
|
||||
* Make sure urls are properly formatted for background-image properties.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param {string} url - The URL.
|
||||
*
|
||||
* @return {string} - Returns the URL.
|
||||
*/
|
||||
backgroundImageValue( url ) {
|
||||
return ( -1 === url.indexOf( 'url(' ) ) ? 'url(' + url + ')' : url;
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* A collection of utilities for CSS generation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
css: {
|
||||
|
||||
/**
|
||||
* Generates the CSS from the output (js_vars) parameter.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param {Object} output - The output (js_vars) argument.
|
||||
* @param {mixed} value - The value.
|
||||
* @param {string} controlType - The control-type.
|
||||
*
|
||||
* @return {string} - Returns CSS as a string.
|
||||
*/
|
||||
fromOutput( output, value, controlType ) {
|
||||
var styles = '',
|
||||
mediaQuery = false,
|
||||
processedValue;
|
||||
|
||||
try {
|
||||
value = JSON.parse( value );
|
||||
} catch ( e ) {} // eslint-disable-line no-empty
|
||||
|
||||
if ( output.js_callback && 'function' === typeof window[ output.js_callback ] ) {
|
||||
value = window[ output.js_callback[ 0 ] ]( value, output.js_callback[ 1 ] );
|
||||
}
|
||||
|
||||
// Apply the gpPostMessageStylesOutput filter.
|
||||
styles = wp.hooks.applyFilters( 'gpPostMessageStylesOutput', styles, value, output, controlType );
|
||||
|
||||
if ( '' === styles ) {
|
||||
switch ( controlType ) {
|
||||
case 'kirki-multicolor':
|
||||
case 'kirki-sortable':
|
||||
styles += output.element + '{';
|
||||
_.each( value, function( val, key ) {
|
||||
if ( output.choice && key !== output.choice ) {
|
||||
return;
|
||||
}
|
||||
processedValue = gpPostMessage.util.processValue( output, val );
|
||||
|
||||
if ( '' === processedValue ) {
|
||||
if ( 'background-color' === output.property ) {
|
||||
processedValue = 'unset';
|
||||
} else if ( 'background-image' === output.property ) {
|
||||
processedValue = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
if ( false !== processedValue ) {
|
||||
styles += output.property ? output.property + '-' + key + ':' + processedValue + ';' : key + ':' + processedValue + ';';
|
||||
}
|
||||
} );
|
||||
styles += '}';
|
||||
break;
|
||||
default:
|
||||
if ( 'kirki-image' === controlType ) {
|
||||
value = ( ! _.isUndefined( value.url ) ) ? gpPostMessage.util.backgroundImageValue( value.url ) : gpPostMessage.util.backgroundImageValue( value );
|
||||
}
|
||||
if ( _.isObject( value ) ) {
|
||||
styles += output.element + '{';
|
||||
_.each( value, function( val, key ) {
|
||||
var property;
|
||||
if ( output.choice && key !== output.choice ) {
|
||||
return;
|
||||
}
|
||||
processedValue = gpPostMessage.util.processValue( output, val );
|
||||
property = output.property ? output.property : key;
|
||||
|
||||
if ( '' === processedValue ) {
|
||||
if ( 'background-color' === property ) {
|
||||
processedValue = 'unset';
|
||||
} else if ( 'background-image' === property ) {
|
||||
processedValue = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
if ( false !== processedValue ) {
|
||||
styles += property + ':' + processedValue + ';';
|
||||
}
|
||||
} );
|
||||
styles += '}';
|
||||
} else {
|
||||
processedValue = gpPostMessage.util.processValue( output, value );
|
||||
if ( '' === processedValue ) {
|
||||
if ( 'background-color' === output.property ) {
|
||||
processedValue = 'unset';
|
||||
} else if ( 'background-image' === output.property ) {
|
||||
processedValue = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
if ( false !== processedValue ) {
|
||||
styles += output.element + '{' + output.property + ':' + processedValue + ';}';
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the media-query.
|
||||
if ( output.media_query && 'string' === typeof output.media_query && ! _.isEmpty( output.media_query ) ) {
|
||||
mediaQuery = output.media_query;
|
||||
if ( -1 === mediaQuery.indexOf( '@media' ) ) {
|
||||
mediaQuery = '@media ' + mediaQuery;
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a media-query, add it and return.
|
||||
if ( mediaQuery ) {
|
||||
return mediaQuery + '{' + styles + '}';
|
||||
}
|
||||
|
||||
// Return the styles.
|
||||
return styles;
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* A collection of utilities to change the HTML in the document.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
html: {
|
||||
|
||||
/**
|
||||
* Modifies the HTML from the output (js_vars) parameter.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param {Object} output - The output (js_vars) argument.
|
||||
* @param {mixed} value - The value.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
fromOutput( output, value ) {
|
||||
if ( output.js_callback && 'function' === typeof window[ output.js_callback ] ) {
|
||||
value = window[ output.js_callback[ 0 ] ]( value, output.js_callback[ 1 ] );
|
||||
}
|
||||
|
||||
if ( _.isObject( value ) || _.isArray( value ) ) {
|
||||
if ( ! output.choice ) {
|
||||
return;
|
||||
}
|
||||
_.each( value, function( val, key ) {
|
||||
if ( output.choice && key !== output.choice ) {
|
||||
return;
|
||||
}
|
||||
value = val;
|
||||
} );
|
||||
}
|
||||
value = gpPostMessage.util.processValue( output, value );
|
||||
|
||||
if ( output.attr ) {
|
||||
jQuery( output.element ).attr( output.attr, value );
|
||||
} else {
|
||||
jQuery( output.element ).html( value );
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* A collection of utilities to allow toggling a CSS class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
toggleClass: {
|
||||
|
||||
/**
|
||||
* Toggles a CSS class from the output (js_vars) parameter.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param {Object} output - The output (js_vars) argument.
|
||||
* @param {mixed} value - The value.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
fromOutput( output, value ) {
|
||||
if ( 'undefined' === typeof output.class || 'undefined' === typeof output.value ) {
|
||||
return;
|
||||
}
|
||||
if ( value === output.value && ! jQuery( output.element ).hasClass( output.class ) ) {
|
||||
jQuery( output.element ).addClass( output.class );
|
||||
} else {
|
||||
jQuery( output.element ).removeClass( output.class );
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
jQuery( document ).ready( function() {
|
||||
var styles;
|
||||
_.each( gpPostMessageFields, function( field ) {
|
||||
wp.customize( field.settings, function( value ) {
|
||||
value.bind( function( newVal ) {
|
||||
styles = '';
|
||||
_.each( field.js_vars, function( output ) {
|
||||
output.function = ( ! output.function || 'undefined' === typeof gpPostMessage[ output.function ] ) ? 'css' : output.function;
|
||||
field.type = ( field.choices && field.choices.parent_type ) ? field.choices.parent_type : field.type;
|
||||
|
||||
if ( 'css' === output.function ) {
|
||||
styles += gpPostMessage.css.fromOutput( output, newVal, field.type );
|
||||
} else {
|
||||
gpPostMessage[ output.function ].fromOutput( output, newVal, field.type );
|
||||
}
|
||||
} );
|
||||
gpPostMessage.styleTag.addData( field.settings, styles );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
} );
|
1
wp-content/themes/generatepress/inc/customizer/controls/js/selectWoo.min.js
vendored
Normal file
1
wp-content/themes/generatepress/inc/customizer/controls/js/selectWoo.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -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() );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
});
|
@ -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();
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
@ -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 );
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Load necessary Customizer controls and functions.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
// Add fields.
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'class-customize-field.php';
|
||||
|
||||
// Controls.
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-react-control.php';
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-color-control.php';
|
||||
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';
|
133
wp-content/themes/generatepress/inc/customizer/deprecated.php
Normal file
133
wp-content/themes/generatepress/inc/customizer/deprecated.php
Normal file
@ -0,0 +1,133 @@
|
||||
<?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
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
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
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
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
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_hidden_navigation' ) && function_exists( 'is_customize_preview' ) ) {
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the back to top button.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_back_to_top_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Back to Top', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'back-to-top-colors',
|
||||
),
|
||||
'active_callback' => function() {
|
||||
if ( generate_get_option( 'back_to_top' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_back_to_top_background_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'back-to-top-colors',
|
||||
'items' => array(
|
||||
'back_to_top_background_color',
|
||||
'back_to_top_background_color_hover',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[back_to_top_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['back_to_top_background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'back-to-top-colors',
|
||||
'wrapper' => 'back_to_top_background_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'a.generate-back-to-top',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[back_to_top_background_color_hover]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['back_to_top_background_color_hover'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'back-to-top-colors',
|
||||
'wrapper' => 'back_to_top_background_color_hover',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'a.generate-back-to-top:hover, a.generate-back-to-top:focus',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_back_to_top_text_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'back-to-top-colors',
|
||||
'items' => array(
|
||||
'back_to_top_text_color',
|
||||
'back_to_top_text_color_hover',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[back_to_top_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['back_to_top_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'button-colors',
|
||||
'wrapper' => 'back_to_top_text_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'a.generate-back-to-top',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[back_to_top_text_color_hover]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['back_to_top_text_color_hover'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'back-to-top-colors',
|
||||
'wrapper' => 'back_to_top_text_color_hover',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'a.generate-back-to-top:hover, a.generate-back-to-top:focus',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
156
wp-content/themes/generatepress/inc/customizer/fields/body.php
Normal file
156
wp-content/themes/generatepress/inc/customizer/fields/body.php
Normal file
@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the Body.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_body_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Body', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'base-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $defaults['background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'base-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'body',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $defaults['text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'base-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'body',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_body_link_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'base-colors',
|
||||
'items' => array(
|
||||
'link_color',
|
||||
'link_color_hover',
|
||||
'link_color_visited',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $defaults['link_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'toggleId' => 'base-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'a, a:visited',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[link_color_hover]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $defaults['link_color_hover'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'link_color_hover',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'toggleId' => 'base-colors',
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
if ( '' !== generate_get_option( 'link_color_visited' ) ) {
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[link_color_visited]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $defaults['link_color_visited'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'refresh',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Color Visited', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'link_color_visited',
|
||||
'tooltip' => __( 'Choose Visited Color', 'generatepress' ),
|
||||
'toggleId' => 'base-colors',
|
||||
'hideLabel' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the Body.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_buttons_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Buttons', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'button-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_buttons_background_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'button-colors',
|
||||
'items' => array(
|
||||
'form_button_background_color',
|
||||
'form_button_background_color_hover',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$buttons_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)';
|
||||
$buttons_hover_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';
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_button_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_button_background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'button-colors',
|
||||
'wrapper' => 'form_button_background_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $buttons_selector,
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_button_background_color_hover]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_button_background_color_hover'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'button-colors',
|
||||
'wrapper' => 'form_button_background_color_hover',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $buttons_hover_selector,
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_buttons_text_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'button-colors',
|
||||
'items' => array(
|
||||
'form_button_text_color',
|
||||
'form_button_text_color_hover',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_button_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_button_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'button-colors',
|
||||
'wrapper' => 'form_button_text_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $buttons_selector,
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_button_text_color_hover]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_button_text_color_hover'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'button-colors',
|
||||
'wrapper' => 'form_button_text_color_hover',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $buttons_hover_selector,
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
@ -0,0 +1,372 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the content.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_content_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Content', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$content_colors = '.separate-containers .inside-article, .separate-containers .comments-area, .separate-containers .page-header, .one-container .container, .separate-containers .paging-navigation, .inside-page-header';
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[content_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['content_background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $content_colors,
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[content_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['content_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $content_colors,
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_content_link_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'content-colors',
|
||||
'items' => array(
|
||||
'content_link_color',
|
||||
'content_link_hover_color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[content_link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['content_link_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'content_link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.inside-article a:not(.button):not(.wp-block-button__link), .inside-article a:not(.button):not(.wp-block-button__link):visited, .paging-navigation a, .paging-navigation a:visited, .comments-area a, .comments-area a:visited, .page-header a, .page-header a:visited',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[content_link_hover_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['content_link_hover_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'content_link_hover_color',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'toggleId' => 'content-colors',
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.inside-article a:not(.button):not(.wp-block-button__link):hover, .paging-navigation a:hover, .comments-area a:hover, .page-header a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[content_title_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['content_title_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Content Title', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.entry-header h1,.page-header h1',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_archive_content_title_link_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'content-colors',
|
||||
'items' => array(
|
||||
'blog_post_title_color',
|
||||
'blog_post_title_hover_color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[blog_post_title_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['blog_post_title_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Archive Content Title', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'blog_post_title_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.entry-title a,.entry-title a:visited',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[blog_post_title_hover_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['blog_post_title_hover_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Archive Content Title Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'blog_post_title_hover_color',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'toggleId' => 'content-colors',
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.entry-title a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[entry_meta_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['entry_meta_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Entry Meta Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.entry-meta',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_entry_meta_link_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'content-colors',
|
||||
'items' => array(
|
||||
'entry_meta_link_color',
|
||||
'entry_meta_link_color_hover',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[entry_meta_link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['entry_meta_link_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Entry Meta Links', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'entry_meta_link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.entry-meta a',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[entry_meta_link_color_hover]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['entry_meta_link_color_hover'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Entry Meta Links Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'entry_meta_link_color_hover',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'toggleId' => 'content-colors',
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.entry-meta a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$headings = array(
|
||||
array(
|
||||
'slug' => 'h1_color',
|
||||
'label' => __( 'Heading 1 (H1) Color', 'generatepress' ),
|
||||
'selector' => 'h1',
|
||||
),
|
||||
array(
|
||||
'slug' => 'h2_color',
|
||||
'label' => __( 'Heading 2 (H2) Color', 'generatepress' ),
|
||||
'selector' => 'h2',
|
||||
),
|
||||
array(
|
||||
'slug' => 'h3_color',
|
||||
'label' => __( 'Heading 3 (H3) Color', 'generatepress' ),
|
||||
'selector' => 'h3',
|
||||
),
|
||||
array(
|
||||
'slug' => 'h4_color',
|
||||
'label' => __( 'Heading 4 (H4) Color', 'generatepress' ),
|
||||
'selector' => 'h4',
|
||||
),
|
||||
array(
|
||||
'slug' => 'h5_color',
|
||||
'label' => __( 'Heading 5 (H5) Color', 'generatepress' ),
|
||||
'selector' => 'h5',
|
||||
),
|
||||
array(
|
||||
'slug' => 'h6_color',
|
||||
'label' => __( 'Heading 6 (H6) Color', 'generatepress' ),
|
||||
'selector' => 'h6',
|
||||
),
|
||||
);
|
||||
|
||||
foreach ( $headings as $heading ) {
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[' . $heading['slug'] . ']',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults[ $heading['slug'] ],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => $heading['label'],
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $heading['selector'],
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the footer bar.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_footer_bar_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Footer Bar', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-bar-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'footer-bar-colors',
|
||||
'wrapper' => 'footer_background_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-info',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-bar-colors',
|
||||
'wrapper' => 'footer_text_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-info',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_footer_bar_colors_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'footer-bar-colors',
|
||||
'items' => array(
|
||||
'footer_link_color',
|
||||
'footer_link_hover_color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_link_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-bar-colors',
|
||||
'wrapper' => 'footer_link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-info a',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_link_hover_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_link_hover_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-bar-colors',
|
||||
'wrapper' => 'footer_link_hover_color',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-info a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the footer widgets.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_footer_widgets_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Footer Widgets', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-widget-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_widget_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_widget_background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'footer-widget-colors',
|
||||
'wrapper' => 'footer_widget_background_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.footer-widgets',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_widget_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_widget_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-widget-colors',
|
||||
'wrapper' => 'footer_widget_text_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.footer-widgets',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_footer_widget_colors_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'footer-widget-colors',
|
||||
'items' => array(
|
||||
'footer_widget_link_color',
|
||||
'footer_widget_link_hover_color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_widget_link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_widget_link_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-widget-colors',
|
||||
'wrapper' => 'footer_widget_link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.footer-widgets a',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_widget_link_hover_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_widget_link_hover_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-widget-colors',
|
||||
'wrapper' => 'footer_widget_link_hover_color',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.footer-widgets a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_widget_title_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_widget_title_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Widget Title', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-widget-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.footer-widgets .widget-title',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
226
wp-content/themes/generatepress/inc/customizer/fields/forms.php
Normal file
226
wp-content/themes/generatepress/inc/customizer/fields/forms.php
Normal file
@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the Body.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_forms_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Forms', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'form-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_forms_background_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'form-colors',
|
||||
'items' => array(
|
||||
'form_background_color',
|
||||
'form_background_color_focus',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$forms_selector = 'input[type="text"], input[type="email"], input[type="url"], input[type="password"], input[type="search"], input[type="number"], input[type="tel"], textarea, select';
|
||||
$forms_focus_selector = 'input[type="text"]:focus, input[type="email"]:focus, input[type="url"]:focus, input[type="password"]:focus, input[type="search"]:focus, input[type="number"]:focus, input[type="tel"]:focus, textarea:focus, select:focus';
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'form-colors',
|
||||
'wrapper' => 'form_background_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $forms_selector,
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_background_color_focus]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_background_color_focus'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background Focus', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'form-colors',
|
||||
'wrapper' => 'form_background_color_focus',
|
||||
'tooltip' => __( 'Choose Focus Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $forms_focus_selector,
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_forms_text_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'form-colors',
|
||||
'items' => array(
|
||||
'form_text_color',
|
||||
'form_text_color_focus',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'form-colors',
|
||||
'wrapper' => 'form_text_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $forms_selector,
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_text_color_focus]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_text_color_focus'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text Focus', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'form-colors',
|
||||
'wrapper' => 'form_text_color_focus',
|
||||
'tooltip' => __( 'Choose Focus Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $forms_focus_selector,
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_forms_border_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'form-colors',
|
||||
'items' => array(
|
||||
'form_border_color',
|
||||
'form_border_color_focus',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_border_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_border_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Border', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'form-colors',
|
||||
'wrapper' => 'form_border_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $forms_selector,
|
||||
'property' => 'border-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_border_color_focus]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_border_color_focus'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Border Focus', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'form-colors',
|
||||
'wrapper' => 'form_border_color_focus',
|
||||
'tooltip' => __( 'Choose Focus Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $forms_focus_selector,
|
||||
'property' => 'border-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
180
wp-content/themes/generatepress/inc/customizer/fields/header.php
Normal file
180
wp-content/themes/generatepress/inc/customizer/fields/header.php
Normal file
@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the header.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_header_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Header', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'header-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[header_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['header_background_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'header-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-header',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[header_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['header_text_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'header-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-header',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_header_link_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'header-colors',
|
||||
'items' => array(
|
||||
'header_link_color',
|
||||
'header_link_hover_color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[header_link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['header_link_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'header-colors',
|
||||
'wrapper' => 'header_link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-header a:not([rel="home"])',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[header_link_hover_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['header_link_hover_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'header-colors',
|
||||
'wrapper' => 'header_link_hover_color',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-header a:not([rel="home"]):hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[site_title_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['site_title_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Site Title', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'header-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.main-title a, .main-title a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[site_tagline_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['site_tagline_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Tagline', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'header-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-description',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
@ -0,0 +1,214 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the primary navigation.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*
|
||||
* @var array $color_defaults
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
$menu_hover_selectors = '.navigation-search input[type="search"], .navigation-search input[type="search"]:active, .navigation-search input[type="search"]:focus, .main-navigation .main-nav ul li:not([class*="current-menu-"]):hover > a, .main-navigation .main-nav ul li:not([class*="current-menu-"]):focus > a, .main-navigation .main-nav ul li.sfHover:not([class*="current-menu-"]) > a, .main-navigation .menu-bar-item:hover > a, .main-navigation .menu-bar-item.sfHover > a';
|
||||
$menu_current_selectors = '.main-navigation .main-nav ul li[class*="current-menu-"] > a';
|
||||
$submenu_hover_selectors = '.main-navigation .main-nav ul ul li:not([class*="current-menu-"]):hover > a,.main-navigation .main-nav ul ul li:not([class*="current-menu-"]):focus > a,.main-navigation .main-nav ul ul li.sfHover:not([class*="current-menu-"]) > a';
|
||||
$submenu_current_selectors = '.main-navigation .main-nav ul ul li[class*="current-menu-"] > a';
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_primary_navigation_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Primary Navigation', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'primary-navigation-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// Navigation background group.
|
||||
GeneratePress_Customize_Field::add_color_field_group(
|
||||
'primary_navigation_background',
|
||||
'generate_colors_section',
|
||||
'primary-navigation-colors',
|
||||
array(
|
||||
'generate_settings[navigation_background_color]' => array(
|
||||
'default_value' => $color_defaults['navigation_background_color'],
|
||||
'label' => __( 'Navigation Background', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'element' => '.main-navigation',
|
||||
'property' => 'background-color',
|
||||
'hide_label' => false,
|
||||
),
|
||||
'generate_settings[navigation_background_hover_color]' => array(
|
||||
'default_value' => $color_defaults['navigation_background_hover_color'],
|
||||
'label' => __( 'Navigation Background Hover', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'element' => $menu_hover_selectors,
|
||||
'property' => 'background-color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
'generate_settings[navigation_background_current_color]' => array(
|
||||
'default_value' => $color_defaults['navigation_background_current_color'],
|
||||
'label' => __( 'Navigation Background Current', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Current Color', 'generatepress' ),
|
||||
'element' => $menu_current_selectors,
|
||||
'property' => 'background-color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// Navigation text group.
|
||||
GeneratePress_Customize_Field::add_color_field_group(
|
||||
'primary_navigation_text',
|
||||
'generate_colors_section',
|
||||
'primary-navigation-colors',
|
||||
array(
|
||||
'generate_settings[navigation_text_color]' => array(
|
||||
'default_value' => $color_defaults['navigation_text_color'],
|
||||
'label' => __( 'Navigation Text', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'element' => '.main-navigation .main-nav ul li a, .main-navigation .menu-toggle, .main-navigation button.menu-toggle:hover, .main-navigation button.menu-toggle:focus, .main-navigation .mobile-bar-items a, .main-navigation .mobile-bar-items a:hover, .main-navigation .mobile-bar-items a:focus, .main-navigation .menu-bar-items',
|
||||
'property' => 'color',
|
||||
'hide_label' => false,
|
||||
),
|
||||
'generate_settings[navigation_text_hover_color]' => array(
|
||||
'default_value' => $color_defaults['navigation_text_hover_color'],
|
||||
'label' => __( 'Navigation Text Hover', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'element' => $menu_hover_selectors,
|
||||
'property' => 'color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
'generate_settings[navigation_text_current_color]' => array(
|
||||
'default_value' => $color_defaults['navigation_text_current_color'],
|
||||
'label' => __( 'Navigation Text Current', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Current Color', 'generatepress' ),
|
||||
'element' => $menu_current_selectors,
|
||||
'property' => 'color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// Sub-Menu background group.
|
||||
GeneratePress_Customize_Field::add_color_field_group(
|
||||
'primary_navigation_submenu_background',
|
||||
'generate_colors_section',
|
||||
'primary-navigation-colors',
|
||||
array(
|
||||
'generate_settings[subnavigation_background_color]' => array(
|
||||
'default_value' => $color_defaults['subnavigation_background_color'],
|
||||
'label' => __( 'Sub-Menu Background', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'element' => '.main-navigation ul ul',
|
||||
'property' => 'background-color',
|
||||
'hide_label' => false,
|
||||
),
|
||||
'generate_settings[subnavigation_background_hover_color]' => array(
|
||||
'default_value' => $color_defaults['subnavigation_background_hover_color'],
|
||||
'label' => __( 'Sub-Menu Background Hover', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'element' => $submenu_hover_selectors,
|
||||
'property' => 'background-color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
'generate_settings[subnavigation_background_current_color]' => array(
|
||||
'default_value' => $color_defaults['subnavigation_background_current_color'],
|
||||
'label' => __( 'Sub-Menu Background Current', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Current Color', 'generatepress' ),
|
||||
'element' => $submenu_current_selectors,
|
||||
'property' => 'background-color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// Sub-Menu text group.
|
||||
GeneratePress_Customize_Field::add_color_field_group(
|
||||
'primary_navigation_submenu_text',
|
||||
'generate_colors_section',
|
||||
'primary-navigation-colors',
|
||||
array(
|
||||
'generate_settings[subnavigation_text_color]' => array(
|
||||
'default_value' => $color_defaults['subnavigation_text_color'],
|
||||
'label' => __( 'Sub-Menu Text', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'element' => '.main-navigation .main-nav ul ul li a',
|
||||
'property' => 'color',
|
||||
'hide_label' => false,
|
||||
),
|
||||
'generate_settings[subnavigation_text_hover_color]' => array(
|
||||
'default_value' => $color_defaults['subnavigation_text_hover_color'],
|
||||
'label' => __( 'Sub-Menu Text Hover', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'element' => $submenu_hover_selectors,
|
||||
'property' => 'color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
'generate_settings[subnavigation_text_current_color]' => array(
|
||||
'default_value' => $color_defaults['subnavigation_text_current_color'],
|
||||
'label' => __( 'Sub-Menu Text Current', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Current Color', 'generatepress' ),
|
||||
'element' => $submenu_current_selectors,
|
||||
'property' => 'color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_navigation_search_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Navigation Search', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'primary-navigation-search-colors',
|
||||
),
|
||||
'active_callback' => function() {
|
||||
if ( 'enable' === generate_get_option( 'nav_search' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[navigation_search_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['navigation_search_background_color'],
|
||||
'transport' => 'refresh',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'primary-navigation-search-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[navigation_search_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['navigation_search_text_color'],
|
||||
'transport' => 'refresh',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'primary-navigation-search-colors',
|
||||
),
|
||||
)
|
||||
);
|
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the Search Modal.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_search_modal_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Search Modal', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'search-modal-colors',
|
||||
),
|
||||
'active_callback' => function() {
|
||||
if ( generate_get_option( 'nav_search_modal' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[search_modal_bg_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['search_modal_bg_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Field Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'search-modal-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => ':root',
|
||||
'property' => '--gp-search-modal-bg-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[search_modal_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['search_modal_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Field Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'search-modal-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => ':root',
|
||||
'property' => '--gp-search-modal-text-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[search_modal_overlay_bg_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['search_modal_overlay_bg_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Overlay Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'search-modal-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => ':root',
|
||||
'property' => '--gp-search-modal-overlay-bg-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the sidebar widgets.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_sidebar_widgets_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Sidebar Widgets', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'sidebar-widget-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[sidebar_widget_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['sidebar_widget_background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'sidebar-widget-colors',
|
||||
'wrapper' => 'sidebar_widget_background_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.sidebar .widget',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[sidebar_widget_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['sidebar_widget_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'sidebar-widget-colors',
|
||||
'wrapper' => 'sidebar_widget_text_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.sidebar .widget',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_sidebar_widget_colors_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'sidebar-widget-colors',
|
||||
'items' => array(
|
||||
'sidebar_widget_link_color',
|
||||
'sidebar_widget_link_hover_color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[sidebar_widget_link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['sidebar_widget_link_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'sidebar-widget-colors',
|
||||
'wrapper' => 'sidebar_widget_link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.sidebar .widget a',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[sidebar_widget_link_hover_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['sidebar_widget_link_hover_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'sidebar-widget-colors',
|
||||
'wrapper' => 'sidebar_widget_link_hover_color',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.sidebar .widget a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[sidebar_widget_title_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['sidebar_widget_title_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Widget Title', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'sidebar-widget-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.sidebar .widget .widget-title',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the top bar.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_top_bar_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Top Bar', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'top-bar-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[top_bar_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['top_bar_background_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'settings' => 'generate_settings[top_bar_background_color]',
|
||||
'active_callback' => 'generate_is_top_bar_active',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'top-bar-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.top-bar',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[top_bar_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['top_bar_text_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'active_callback' => 'generate_is_top_bar_active',
|
||||
'choices' => array(
|
||||
'toggleId' => 'top-bar-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.top-bar',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_top_bar_link_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'top-bar-colors',
|
||||
'items' => array(
|
||||
'top_bar_link_color',
|
||||
'top_bar_link_color_hover',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[top_bar_link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['top_bar_link_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'active_callback' => 'generate_is_top_bar_active',
|
||||
'choices' => array(
|
||||
'wrapper' => 'top_bar_link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'toggleId' => 'top-bar-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.top-bar a',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[top_bar_link_color_hover]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['top_bar_link_color_hover'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'active_callback' => 'generate_is_top_bar_active',
|
||||
'choices' => array(
|
||||
'wrapper' => 'top_bar_link_color_hover',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'toggleId' => 'top-bar-colors',
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.top-bar a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
476
wp-content/themes/generatepress/inc/customizer/helpers.php
Normal file
476
wp-content/themes/generatepress/inc/customizer/helpers.php
Normal file
@ -0,0 +1,476 @@
|
||||
<?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_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 = wp_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
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
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
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_decimal_integer( $input ) {
|
||||
return abs( floatval( $input ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize integers that can use decimals.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_empty_decimal_integer( $input ) {
|
||||
if ( '' === $input ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return abs( floatval( $input ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize integers that can use negative decimals.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_empty_negative_decimal_integer( $input ) {
|
||||
if ( '' === $input ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return floatval( $input );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize a positive number, but allow an empty value.
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_empty_absint( $input ) {
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentially loose.
|
||||
if ( '' == $input ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return absint( $input );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sanitize_checkbox' ) ) {
|
||||
/**
|
||||
* Sanitize checkbox values.
|
||||
*
|
||||
* @since 1.0.8
|
||||
* @param string $checked The value to check.
|
||||
*/
|
||||
function generate_sanitize_checkbox( $checked ) {
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentially loose.
|
||||
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
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
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
|
||||
* @param string $color The color to check.
|
||||
*/
|
||||
function generate_sanitize_hex_color( $color ) {
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentially loose.
|
||||
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;
|
||||
}
|
||||
|
||||
// Sanitize CSS variables.
|
||||
if ( strpos( $color, 'var(' ) !== false ) {
|
||||
return sanitize_text_field( $color );
|
||||
}
|
||||
|
||||
// Sanitize rgb() values.
|
||||
if ( strpos( $color, 'rgb(' ) !== false ) {
|
||||
$color = str_replace( ' ', '', $color );
|
||||
|
||||
sscanf( $color, 'rgb(%d,%d,%d)', $red, $green, $blue );
|
||||
return 'rgb(' . $red . ',' . $green . ',' . $blue . ')';
|
||||
}
|
||||
|
||||
// Sanitize rgba() values.
|
||||
if ( strpos( $color, 'rgba' ) !== false ) {
|
||||
$color = str_replace( ' ', '', $color );
|
||||
sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
|
||||
|
||||
return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize RGBA colors.
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $color The color to check.
|
||||
*/
|
||||
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
|
||||
* @param string $input The value to check.
|
||||
* @param object $setting The setting object.
|
||||
*/
|
||||
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
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
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() );
|
||||
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_typography_defaults', generate_get_default_fonts() );
|
||||
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_spacing_defaults', generate_spacing_get_defaults() );
|
||||
|
||||
wp_localize_script(
|
||||
'generatepress-customizer-controls',
|
||||
'generatepressCustomizeControls',
|
||||
array(
|
||||
'mappedTypographyData' => array(
|
||||
'typography' => GeneratePress_Typography_Migration::get_mapped_typography_data(),
|
||||
'fonts' => GeneratePress_Typography_Migration::get_mapped_font_data(),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'generate-customizer-controls',
|
||||
trailingslashit( get_template_directory_uri() ) . 'assets/dist/customizer.js',
|
||||
// We're including wp-color-picker for localized strings, nothing more.
|
||||
array( 'lodash', 'react', 'react-dom', 'wp-components', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-polyfill', 'jquery', 'customize-base', 'customize-controls', 'wp-color-picker' ),
|
||||
GENERATE_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
if ( function_exists( 'wp_set_script_translations' ) ) {
|
||||
wp_set_script_translations( 'generate-customizer-controls', 'generatepress' );
|
||||
}
|
||||
|
||||
$color_palette = get_theme_support( 'editor-color-palette' );
|
||||
$colors = array();
|
||||
|
||||
if ( is_array( $color_palette ) ) {
|
||||
foreach ( $color_palette as $key => $value ) {
|
||||
foreach ( $value as $color ) {
|
||||
$colors[] = array(
|
||||
'name' => $color['name'],
|
||||
'color' => $color['color'],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wp_localize_script(
|
||||
'generate-customizer-controls',
|
||||
'generateCustomizerControls',
|
||||
array(
|
||||
'palette' => $colors,
|
||||
'showGoogleFonts' => apply_filters( 'generate_font_manager_show_google_fonts', true ),
|
||||
'colorPickerShouldShift' => function_exists( 'did_filter' ),
|
||||
)
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'generate-customizer-controls',
|
||||
trailingslashit( get_template_directory_uri() ) . 'assets/dist/style-customizer.css',
|
||||
array( 'wp-components' ),
|
||||
GENERATE_VERSION
|
||||
);
|
||||
|
||||
$global_colors = generate_get_global_colors();
|
||||
$global_colors_css = ':root {';
|
||||
|
||||
if ( ! empty( $global_colors ) ) {
|
||||
foreach ( (array) $global_colors as $key => $data ) {
|
||||
$global_colors_css .= '--' . $data['slug'] . ':' . $data['color'] . ';';
|
||||
}
|
||||
}
|
||||
|
||||
$global_colors_css .= '}';
|
||||
|
||||
wp_add_inline_style( 'generate-customizer-controls', $global_colors_css );
|
||||
}
|
||||
|
||||
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_only' ),
|
||||
'desktop' => generate_get_media_query( 'desktop' ),
|
||||
'contentLeft' => absint( $spacing_settings['content_left'] ),
|
||||
'contentRight' => absint( $spacing_settings['content_right'] ),
|
||||
'isFlex' => generate_is_using_flexbox(),
|
||||
'isRTL' => is_rtl(),
|
||||
)
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'generate-postMessage',
|
||||
trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/postMessage.js',
|
||||
array( 'jquery', 'customize-preview', 'wp-hooks' ),
|
||||
GENERATE_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
global $generate_customize_fields;
|
||||
wp_localize_script( 'generate-postMessage', 'gpPostMessageFields', $generate_customize_fields );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
return 'current';
|
||||
}
|
||||
|
||||
/**
|
||||
* Display options if we're using the Floats structure.
|
||||
*/
|
||||
function generate_is_using_floats_callback() {
|
||||
return 'floats' === generate_get_option( 'structure' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine whether to show the inline logo option.
|
||||
*/
|
||||
function generate_show_inline_logo_callback() {
|
||||
return 'floats' === generate_get_option( 'structure' ) && generate_has_logo_site_branding();
|
||||
}
|
378
wp-content/themes/generatepress/inc/dashboard.php
Normal file
378
wp-content/themes/generatepress/inc/dashboard.php
Normal file
@ -0,0 +1,378 @@
|
||||
<?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( esc_html__( 'GeneratePress', 'generatepress' ), esc_html__( '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() . '/assets/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' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function. ?>" target="_blank">GeneratePress</a> <span class="gp-version"><?php echo esc_html( GENERATE_VERSION ); ?></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/' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function. ?>" 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 →', '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(
|
||||
/* 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'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only checking. False positive.
|
||||
add_settings_error( 'generate-notices', 'true', esc_html__( 'Settings saved.', 'generatepress' ), 'updated' );
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only checking. False positive.
|
||||
if ( isset( $_GET['status'] ) && 'imported' === $_GET['status'] ) {
|
||||
add_settings_error( 'generate-notices', 'imported', esc_html__( 'Import successful.', 'generatepress' ), 'updated' );
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only checking. False positive.
|
||||
if ( isset( $_GET['status'] ) && 'reset' === $_GET['status'] ) {
|
||||
add_settings_error( 'generate-notices', 'reset', esc_html__( 'Settings removed.', 'generatepress' ), 'updated' );
|
||||
}
|
||||
|
||||
settings_errors( 'generate-notices' );
|
||||
}
|
||||
}
|
418
wp-content/themes/generatepress/inc/defaults.php
Normal file
418
wp-content/themes/generatepress/inc/defaults.php
Normal file
@ -0,0 +1,418 @@
|
||||
<?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' => true,
|
||||
'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' => '1200',
|
||||
'container_alignment' => 'text',
|
||||
'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-float-right',
|
||||
'nav_drop_point' => '',
|
||||
'nav_dropdown_type' => 'hover',
|
||||
'nav_dropdown_direction' => is_rtl() ? 'left' : 'right',
|
||||
'nav_search' => 'disable',
|
||||
'nav_search_modal' => false,
|
||||
'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' => 'var(--base-2)',
|
||||
'text_color' => 'var(--contrast)',
|
||||
'link_color' => 'var(--accent)',
|
||||
'link_color_hover' => 'var(--contrast)',
|
||||
'link_color_visited' => '',
|
||||
'font_awesome_essentials' => true,
|
||||
'icons' => 'svg',
|
||||
'combine_css' => true,
|
||||
'dynamic_css_cache' => true,
|
||||
'structure' => 'flexbox',
|
||||
'underline_links' => 'always',
|
||||
'font_manager' => array(),
|
||||
'typography' => array(),
|
||||
'google_font_display' => 'auto',
|
||||
'use_dynamic_typography' => true,
|
||||
'global_colors' => array(
|
||||
array(
|
||||
'name' => __( 'Contrast', 'generatepress' ),
|
||||
'slug' => 'contrast',
|
||||
'color' => '#222222',
|
||||
),
|
||||
array(
|
||||
/* translators: Contrast number */
|
||||
'name' => sprintf( __( 'Contrast %s', 'generatepress' ), '2' ),
|
||||
'slug' => 'contrast-2',
|
||||
'color' => '#575760',
|
||||
),
|
||||
array(
|
||||
/* translators: Contrast number */
|
||||
'name' => sprintf( __( 'Contrast %s', 'generatepress' ), '3' ),
|
||||
'slug' => 'contrast-3',
|
||||
'color' => '#b2b2be',
|
||||
),
|
||||
array(
|
||||
'name' => __( 'Base', 'generatepress' ),
|
||||
'slug' => 'base',
|
||||
'color' => '#f0f0f0',
|
||||
),
|
||||
array(
|
||||
/* translators: Base number */
|
||||
'name' => sprintf( __( 'Base %s', 'generatepress' ), '2' ),
|
||||
'slug' => 'base-2',
|
||||
'color' => '#f7f8f9',
|
||||
),
|
||||
array(
|
||||
/* translators: Base number */
|
||||
'name' => sprintf( __( 'Base %s', 'generatepress' ), '3' ),
|
||||
'slug' => 'base-3',
|
||||
'color' => '#ffffff',
|
||||
),
|
||||
array(
|
||||
'name' => __( 'Accent', 'generatepress' ),
|
||||
'slug' => 'accent',
|
||||
'color' => '#1e73be',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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' => 'var(--base-3)',
|
||||
'header_text_color' => '',
|
||||
'header_link_color' => '',
|
||||
'header_link_hover_color' => '',
|
||||
'site_title_color' => 'var(--contrast)',
|
||||
'site_tagline_color' => 'var(--contrast-2)',
|
||||
'navigation_background_color' => 'var(--base-3)',
|
||||
'navigation_text_color' => 'var(--contrast)',
|
||||
'navigation_background_hover_color' => '',
|
||||
'navigation_text_hover_color' => 'var(--accent)',
|
||||
'navigation_background_current_color' => '',
|
||||
'navigation_text_current_color' => 'var(--accent)',
|
||||
'subnavigation_background_color' => 'var(--base)',
|
||||
'subnavigation_text_color' => '',
|
||||
'subnavigation_background_hover_color' => '',
|
||||
'subnavigation_text_hover_color' => '',
|
||||
'subnavigation_background_current_color' => '',
|
||||
'subnavigation_text_current_color' => '',
|
||||
'navigation_search_background_color' => '',
|
||||
'navigation_search_text_color' => '',
|
||||
'content_background_color' => 'var(--base-3)',
|
||||
'content_text_color' => '',
|
||||
'content_link_color' => '',
|
||||
'content_link_hover_color' => '',
|
||||
'content_title_color' => '',
|
||||
'blog_post_title_color' => 'var(--contrast)',
|
||||
'blog_post_title_hover_color' => 'var(--contrast-2)',
|
||||
'entry_meta_text_color' => 'var(--contrast-2)',
|
||||
'entry_meta_link_color' => '',
|
||||
'entry_meta_link_color_hover' => '',
|
||||
'h1_color' => '',
|
||||
'h2_color' => '',
|
||||
'h3_color' => '',
|
||||
'h4_color' => '',
|
||||
'h5_color' => '',
|
||||
'h6_color' => '',
|
||||
'sidebar_widget_background_color' => 'var(--base-3)',
|
||||
'sidebar_widget_text_color' => '',
|
||||
'sidebar_widget_link_color' => '',
|
||||
'sidebar_widget_link_hover_color' => '',
|
||||
'sidebar_widget_title_color' => '',
|
||||
'footer_widget_background_color' => 'var(--base-3)',
|
||||
'footer_widget_text_color' => '',
|
||||
'footer_widget_link_color' => '',
|
||||
'footer_widget_link_hover_color' => '',
|
||||
'footer_widget_title_color' => '',
|
||||
'footer_background_color' => 'var(--base-3)',
|
||||
'footer_text_color' => '',
|
||||
'footer_link_color' => '',
|
||||
'footer_link_hover_color' => '',
|
||||
'form_background_color' => 'var(--base-2)',
|
||||
'form_text_color' => 'var(--contrast)',
|
||||
'form_background_color_focus' => 'var(--base-2)',
|
||||
'form_text_color_focus' => 'var(--contrast)',
|
||||
'form_border_color' => 'var(--base)',
|
||||
'form_border_color_focus' => 'var(--contrast-3)',
|
||||
'form_button_background_color' => '#55555e',
|
||||
'form_button_background_color_hover' => '#3f4047',
|
||||
'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',
|
||||
'search_modal_bg_color' => 'var(--base-3)',
|
||||
'search_modal_text_color' => 'var(--contrast)',
|
||||
'search_modal_overlay_bg_color' => 'rgba(0,0,0,0.2)',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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' => '25',
|
||||
'mobile_site_title_font_size' => '',
|
||||
'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' => 'normal',
|
||||
'heading_1_transform' => 'none',
|
||||
'heading_1_font_size' => '42',
|
||||
'heading_1_line_height' => '1.2', // em.
|
||||
'heading_1_margin_bottom' => '20',
|
||||
'mobile_heading_1_font_size' => '31',
|
||||
'font_heading_2' => 'inherit',
|
||||
'font_heading_2_category' => '',
|
||||
'font_heading_2_variants' => '',
|
||||
'heading_2_weight' => 'normal',
|
||||
'heading_2_transform' => 'none',
|
||||
'heading_2_font_size' => '35',
|
||||
'heading_2_line_height' => '1.2', // em.
|
||||
'heading_2_margin_bottom' => '20',
|
||||
'mobile_heading_2_font_size' => '27',
|
||||
'font_heading_3' => 'inherit',
|
||||
'font_heading_3_category' => '',
|
||||
'font_heading_3_variants' => '',
|
||||
'heading_3_weight' => 'normal',
|
||||
'heading_3_transform' => 'none',
|
||||
'heading_3_font_size' => '29',
|
||||
'heading_3_line_height' => '1.2', // em.
|
||||
'heading_3_margin_bottom' => '20',
|
||||
'mobile_heading_3_font_size' => '24',
|
||||
'font_heading_4' => 'inherit',
|
||||
'font_heading_4_category' => '',
|
||||
'font_heading_4_variants' => '',
|
||||
'heading_4_weight' => 'normal',
|
||||
'heading_4_transform' => 'none',
|
||||
'heading_4_font_size' => '24',
|
||||
'heading_4_line_height' => '', // em.
|
||||
'mobile_heading_4_font_size' => '22',
|
||||
'font_heading_5' => 'inherit',
|
||||
'font_heading_5_category' => '',
|
||||
'font_heading_5_variants' => '',
|
||||
'heading_5_weight' => 'normal',
|
||||
'heading_5_transform' => 'none',
|
||||
'heading_5_font_size' => '20',
|
||||
'heading_5_line_height' => '', // em.
|
||||
'mobile_heading_5_font_size' => '19',
|
||||
'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' => '40',
|
||||
'top_bar_bottom' => '10',
|
||||
'top_bar_left' => '40',
|
||||
'mobile_top_bar_top' => '',
|
||||
'mobile_top_bar_right' => '30',
|
||||
'mobile_top_bar_bottom' => '',
|
||||
'mobile_top_bar_left' => '30',
|
||||
'header_top' => '20',
|
||||
'header_right' => '40',
|
||||
'header_bottom' => '20',
|
||||
'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' => '30',
|
||||
'right_sidebar_width' => '30',
|
||||
'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' => '40',
|
||||
'footer_bottom' => '20',
|
||||
'footer_left' => '40',
|
||||
'mobile_footer_top' => '',
|
||||
'mobile_footer_right' => '30',
|
||||
'mobile_footer_bottom' => '',
|
||||
'mobile_footer_left' => '30',
|
||||
);
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
914
wp-content/themes/generatepress/inc/deprecated.php
Normal file
914
wp-content/themes/generatepress/inc/deprecated.php
Normal file
@ -0,0 +1,914 @@
|
||||
<?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' => __( '← Previous', 'generatepress' ),
|
||||
'next_text' => __( 'Next →', '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' ) ) {
|
||||
/**
|
||||
* Add layout metabox.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
function generate_add_layout_meta_box() {
|
||||
_deprecated_function( __FUNCTION__, '2.0', 'generate_register_layout_meta_box()' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_show_layout_meta_box' ) ) {
|
||||
/**
|
||||
* Show layout metabox.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
function generate_show_layout_meta_box() {
|
||||
_deprecated_function( __FUNCTION__, '2.0', 'generate_do_layout_meta_box()' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_save_layout_meta' ) ) {
|
||||
/**
|
||||
* Save layout metabox.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
function generate_save_layout_meta() {
|
||||
_deprecated_function( __FUNCTION__, '2.0', 'generate_save_layout_meta_data()' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_add_footer_widget_meta_box' ) ) {
|
||||
/**
|
||||
* Add footer widget metabox.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
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' ) ) {
|
||||
/**
|
||||
* Show footer widget metabox.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
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' ) ) {
|
||||
/**
|
||||
* Save footer widget metabox.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
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' ) ) {
|
||||
/**
|
||||
* Add page builder metabox.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
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' ) ) {
|
||||
/**
|
||||
* Show page builder metabox.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
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' ) ) {
|
||||
/**
|
||||
* Save page builder metabox.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
function generate_save_page_builder_meta() {
|
||||
_deprecated_function( __FUNCTION__, '2.0', 'generate_save_layout_meta_data()' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_add_de_meta_box' ) ) {
|
||||
/**
|
||||
* Add disable elements metabox.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
function generate_add_de_meta_box() {
|
||||
_deprecated_function( __FUNCTION__, '2.0', 'generate_register_layout_meta_box()' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_show_de_meta_box' ) ) {
|
||||
/**
|
||||
* Show disable elements metabox.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
function generate_show_de_meta_box() {
|
||||
_deprecated_function( __FUNCTION__, '2.0', 'generate_do_layout_meta_box()' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_save_de_meta' ) ) {
|
||||
/**
|
||||
* Save disable elements metabox.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
function generate_save_de_meta() {
|
||||
_deprecated_function( __FUNCTION__, '2.0', 'generate_save_layout_meta_data()' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_add_base_inline_css' ) ) {
|
||||
/**
|
||||
* Add base inline CSS.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
function generate_add_base_inline_css() {
|
||||
_deprecated_function( __FUNCTION__, '2.0', 'generate_enqueue_dynamic_css()' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_color_scripts' ) ) {
|
||||
/**
|
||||
* Enqueue base colors inline CSS.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
function generate_color_scripts() {
|
||||
_deprecated_function( __FUNCTION__, '2.0', 'generate_enqueue_dynamic_css()' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_typography_scripts' ) ) {
|
||||
/**
|
||||
* Enqueue typography CSS.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
function generate_typography_scripts() {
|
||||
_deprecated_function( __FUNCTION__, '2.0', 'generate_enqueue_dynamic_css()' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_spacing_scripts' ) ) {
|
||||
/**
|
||||
* Enqueue spacing CSS.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated 2.0
|
||||
*/
|
||||
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 $setting 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 ) ) . '"'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
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 ) ) . '"'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
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 ) ) . '"'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
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 ) ) . '"'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
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 ) ) . '"'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
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 ) ) . '"'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
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 ) ) . '"'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
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 ) . '"'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
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 ) ) . '"'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
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 ) ) . '"'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
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 ) ) . '"'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
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 ) . '"'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
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 ) . '"'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
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'"; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
* @param string $type The type of schema.
|
||||
*/
|
||||
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'"; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process database updates if necessary.
|
||||
* There's nothing in here yet, but we're setting the version to use later.
|
||||
*
|
||||
* @since 2.1
|
||||
* @deprecated 3.0.0
|
||||
*/
|
||||
function generate_do_admin_db_updates() {
|
||||
// Replaced by Generate_Theme_Update().
|
||||
}
|
||||
|
||||
/**
|
||||
* Process important database updates when someone visits the front or backend.
|
||||
*
|
||||
* @since 2.3
|
||||
* @deprecated 3.0.0
|
||||
*/
|
||||
function generate_do_db_updates() {
|
||||
// Replaced by Generate_Theme_Update().
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_update_logo_setting' ) ) {
|
||||
/**
|
||||
* Migrate the old logo database entry to the new custom_logo theme mod (WordPress 4.5)
|
||||
*
|
||||
* @since 1.3.29
|
||||
* @deprecated 3.0.0
|
||||
*/
|
||||
function generate_update_logo_setting() {
|
||||
// Replaced by Generate_Theme_Update().
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_typography_convert_values' ) ) {
|
||||
/**
|
||||
* Take the old body font value and strip it of variants
|
||||
* This should only run once
|
||||
*
|
||||
* @since 1.3.0
|
||||
* @deprecated 3.0.0
|
||||
*/
|
||||
function generate_typography_convert_values() {
|
||||
// Replaced by Generate_Theme_Update().
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @deprecated 3.0.0
|
||||
*/
|
||||
function generate_migrate_existing_settings() {
|
||||
// Replaced by Generate_Theme_Update().
|
||||
}
|
||||
|
||||
/**
|
||||
* Output CSS for the icon fonts.
|
||||
*
|
||||
* @since 2.3
|
||||
* @deprecated 3.0.0
|
||||
*/
|
||||
function generate_do_icon_css() {
|
||||
$output = false;
|
||||
|
||||
if ( 'font' === generate_get_option( 'icons' ) ) {
|
||||
$url = trailingslashit( get_template_directory_uri() );
|
||||
|
||||
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 ( $output ) {
|
||||
return str_replace( array( "\r", "\n", "\t" ), '', $output );
|
||||
}
|
||||
}
|
483
wp-content/themes/generatepress/inc/general.php
Normal file
483
wp-content/themes/generatepress/inc/general.php
Normal file
@ -0,0 +1,483 @@
|
||||
<?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_is_using_flexbox() ) {
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentionally loose.
|
||||
if ( is_singular() && ( comments_open() || '0' != get_comments_number() ) ) {
|
||||
wp_enqueue_style( 'generate-comments', $dir_uri . "/assets/css/components/comments{$suffix}.css", array(), GENERATE_VERSION, 'all' );
|
||||
}
|
||||
|
||||
if (
|
||||
is_active_sidebar( 'top-bar' ) ||
|
||||
is_active_sidebar( 'footer-bar' ) ||
|
||||
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' )
|
||||
) {
|
||||
wp_enqueue_style( 'generate-widget-areas', $dir_uri . "/assets/css/components/widget-areas{$suffix}.css", array(), GENERATE_VERSION, 'all' );
|
||||
}
|
||||
|
||||
wp_enqueue_style( 'generate-style', $dir_uri . "/assets/css/main{$suffix}.css", array(), GENERATE_VERSION, 'all' );
|
||||
} else {
|
||||
if ( generate_get_option( 'combine_css' ) && $suffix ) {
|
||||
wp_enqueue_style( 'generate-style', $dir_uri . "/assets/css/all{$suffix}.css", array(), GENERATE_VERSION, 'all' );
|
||||
} else {
|
||||
wp_enqueue_style( 'generate-style-grid', $dir_uri . "/assets/css/unsemantic-grid{$suffix}.css", false, GENERATE_VERSION, 'all' );
|
||||
wp_enqueue_style( 'generate-style', $dir_uri . "/assets/css/style{$suffix}.css", array(), GENERATE_VERSION, 'all' );
|
||||
wp_enqueue_style( 'generate-mobile-style', $dir_uri . "/assets/css/mobile{$suffix}.css", array(), GENERATE_VERSION, 'all' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'font' === generate_get_option( 'icons' ) ) {
|
||||
wp_enqueue_style( 'generate-font-icons', $dir_uri . "/assets/css/components/font-icons{$suffix}.css", array(), GENERATE_VERSION, 'all' );
|
||||
}
|
||||
|
||||
if ( ! apply_filters( 'generate_fontawesome_essentials', false ) ) {
|
||||
wp_enqueue_style( 'font-awesome', $dir_uri . "/assets/css/components/font-awesome{$suffix}.css", false, '4.7', 'all' );
|
||||
}
|
||||
|
||||
if ( is_rtl() ) {
|
||||
if ( generate_is_using_flexbox() ) {
|
||||
wp_enqueue_style( 'generate-rtl', $dir_uri . "/assets/css/main-rtl{$suffix}.css", array(), GENERATE_VERSION, 'all' );
|
||||
} else {
|
||||
wp_enqueue_style( 'generate-rtl', $dir_uri . "/assets/css/style-rtl{$suffix}.css", array(), GENERATE_VERSION, 'all' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_child_theme() && apply_filters( 'generate_load_child_theme_stylesheet', true ) ) {
|
||||
wp_enqueue_style( 'generate-child', get_stylesheet_uri(), array( 'generate-style' ), filemtime( get_stylesheet_directory() . '/style.css' ), 'all' );
|
||||
}
|
||||
|
||||
if ( function_exists( 'wp_script_add_data' ) ) {
|
||||
wp_enqueue_script( 'generate-classlist', $dir_uri . "/assets/js/classList{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
wp_script_add_data( 'generate-classlist', 'conditional', 'lte IE 11' );
|
||||
}
|
||||
|
||||
if ( generate_has_active_menu() ) {
|
||||
wp_enqueue_script( 'generate-menu', $dir_uri . "/assets/js/menu{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
}
|
||||
|
||||
wp_localize_script(
|
||||
'generate-menu',
|
||||
'generatepressMenu',
|
||||
apply_filters(
|
||||
'generate_localize_js_args',
|
||||
array(
|
||||
'toggleOpenedSubMenus' => true,
|
||||
'openSubMenuLabel' => esc_attr__( 'Open Sub-Menu', 'generatepress' ),
|
||||
'closeSubMenuLabel' => esc_attr__( 'Close Sub-Menu', 'generatepress' ),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ( 'click' === generate_get_option( 'nav_dropdown_type' ) || 'click-arrow' === generate_get_option( 'nav_dropdown_type' ) ) {
|
||||
wp_enqueue_script( 'generate-dropdown-click', $dir_uri . "/assets/js/dropdown-click{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
}
|
||||
|
||||
if ( apply_filters( 'generate_enable_modal_script', false ) ) {
|
||||
wp_enqueue_script( 'generate-modal', $dir_uri . '/assets/dist/modal.js', array(), GENERATE_VERSION, true );
|
||||
}
|
||||
|
||||
if ( 'enable' === generate_get_option( 'nav_search' ) ) {
|
||||
wp_enqueue_script( 'generate-navigation-search', $dir_uri . "/assets/js/navigation-search{$suffix}.js", array(), 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 . "/assets/js/back-to-top{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
|
||||
wp_localize_script(
|
||||
'generate-back-to-top',
|
||||
'generatepressBackToTop',
|
||||
apply_filters(
|
||||
'generate_back_to_top_js_args',
|
||||
array(
|
||||
'smooth' => 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 ) {
|
||||
$handle = generate_is_using_dynamic_typography() ? 'generate-google-fonts' : 'generate-fonts';
|
||||
$hint_type = apply_filters( 'generate_google_font_resource_hint_type', 'preconnect' );
|
||||
$has_crossorigin_support = version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' );
|
||||
|
||||
if ( wp_style_is( $handle, 'queue' ) ) {
|
||||
if ( $relation_type === $hint_type ) {
|
||||
if ( $has_crossorigin_support && 'preconnect' === $hint_type ) {
|
||||
$urls[] = array(
|
||||
'href' => 'https://fonts.gstatic.com',
|
||||
'crossorigin',
|
||||
);
|
||||
|
||||
$urls[] = array(
|
||||
'href' => 'https://fonts.googleapis.com',
|
||||
'crossorigin',
|
||||
);
|
||||
} else {
|
||||
$urls[] = 'https://fonts.gstatic.com';
|
||||
$urls[] = 'https://fonts.googleapis.com';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'dns-prefetch' !== $hint_type ) {
|
||||
$googleapis_index = array_search( 'fonts.googleapis.com', $urls );
|
||||
|
||||
if ( false !== $googleapis_index ) {
|
||||
unset( $urls[ $googleapis_index ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* @param string $url The input URL.
|
||||
* @param int $id The ID of the post.
|
||||
*/
|
||||
function generate_enhanced_image_navigation( $url, $id ) {
|
||||
if ( ! is_attachment() && ! wp_attachment_is_image( $id ) ) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
$image = get_post( $id );
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentially loose.
|
||||
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' ) ) ) { // phpcs:ignore
|
||||
// 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 The existing value.
|
||||
* @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 The existing value.
|
||||
* @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.
|
||||
*
|
||||
* @param array $headers The existing headers.
|
||||
*
|
||||
* @since 2.3
|
||||
*/
|
||||
function generate_set_wp_headers( $headers ) {
|
||||
$headers['X-UA-Compatible'] = 'IE=edge';
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
add_filter( 'generate_after_element_class_attribute', 'generate_set_microdata_markup', 10, 2 );
|
||||
/**
|
||||
* Adds microdata to elements.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $output The existing output after the class attribute.
|
||||
* @param string $context What element we're targeting.
|
||||
*/
|
||||
function generate_set_microdata_markup( $output, $context ) {
|
||||
if ( 'left_sidebar' === $context || 'right_sidebar' === $context ) {
|
||||
$context = 'sidebar';
|
||||
}
|
||||
|
||||
if ( 'footer' === $context ) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
if ( 'site-info' === $context ) {
|
||||
$context = 'footer';
|
||||
}
|
||||
|
||||
$microdata = generate_get_microdata( $context );
|
||||
|
||||
if ( $microdata ) {
|
||||
return $microdata;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
add_action( 'wp_footer', 'generate_do_a11y_scripts' );
|
||||
/**
|
||||
* Enqueue scripts in the footer.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function generate_do_a11y_scripts() {
|
||||
if ( apply_filters( 'generate_print_a11y_script', true ) ) {
|
||||
// Add our small a11y script inline.
|
||||
printf(
|
||||
'<script id="generate-a11y">%s</script>',
|
||||
'!function(){"use strict";if("querySelector"in document&&"addEventListener"in window){var e=document.body;e.addEventListener("mousedown",function(){e.classList.add("using-mouse")}),e.addEventListener("keydown",function(){e.classList.remove("using-mouse")})}}();'
|
||||
);
|
||||
}
|
||||
}
|
568
wp-content/themes/generatepress/inc/markup.php
Normal file
568
wp-content/themes/generatepress/inc/markup.php
Normal file
@ -0,0 +1,568 @@
|
||||
<?php
|
||||
/**
|
||||
* Adds HTML markup.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_body_classes' ) ) {
|
||||
add_filter( 'body_class', 'generate_body_classes' );
|
||||
/**
|
||||
* Adds custom classes to the array of body classes.
|
||||
*
|
||||
* @param array $classes The existing 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_alignment = generate_get_option( 'header_alignment_setting' );
|
||||
$content_layout = generate_get_option( 'content_layout_setting' );
|
||||
|
||||
// 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[] = ( $content_layout ) ? $content_layout : 'separate-containers';
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
$footer_widgets = generate_get_footer_widgets();
|
||||
$header_layout = generate_get_option( 'header_layout_setting' );
|
||||
|
||||
$classes[] = ( $header_layout ) ? $header_layout : 'fluid-header';
|
||||
$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 ( ! generate_is_using_flexbox() && '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.
|
||||
*
|
||||
* @param array $classes The existing classes.
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_top_bar_classes( $classes ) {
|
||||
$classes[] = 'top-bar';
|
||||
|
||||
if ( 'contained' === generate_get_option( 'top_bar_width' ) ) {
|
||||
$classes[] = 'grid-container';
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
$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.
|
||||
*
|
||||
* @param array $classes The existing classes.
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_right_sidebar_classes( $classes ) {
|
||||
$classes[] = 'widget-area';
|
||||
$classes[] = 'sidebar';
|
||||
$classes[] = 'is-right-sidebar';
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
$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[] = 'grid-' . $right_sidebar_width;
|
||||
$classes[] = 'tablet-grid-' . $right_sidebar_tablet_width;
|
||||
$classes[] = 'grid-parent';
|
||||
|
||||
// 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.
|
||||
*
|
||||
* @param array $classes The existing classes.
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_left_sidebar_classes( $classes ) {
|
||||
$classes[] = 'widget-area';
|
||||
$classes[] = 'sidebar';
|
||||
$classes[] = 'is-left-sidebar';
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
$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[] = 'grid-' . $left_sidebar_width;
|
||||
$classes[] = 'tablet-grid-' . $left_sidebar_tablet_width;
|
||||
$classes[] = 'mobile-grid-100';
|
||||
$classes[] = 'grid-parent';
|
||||
|
||||
// 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.
|
||||
*
|
||||
* @param array $classes The existing classes.
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_content_classes( $classes ) {
|
||||
$classes[] = 'content-area';
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
$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[] = '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.
|
||||
*
|
||||
* @param array $classes The existing classes.
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_header_classes( $classes ) {
|
||||
$classes[] = 'site-header';
|
||||
|
||||
if ( 'contained-header' === generate_get_option( 'header_layout_setting' ) ) {
|
||||
$classes[] = 'grid-container';
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
$classes[] = 'grid-parent';
|
||||
}
|
||||
}
|
||||
|
||||
if ( generate_has_inline_mobile_toggle() ) {
|
||||
$classes[] = 'has-inline-mobile-toggle';
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* @param array $classes The existing classes.
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_inside_header_classes( $classes ) {
|
||||
$classes[] = 'inside-header';
|
||||
|
||||
if ( 'full-width' !== generate_get_option( 'header_inner_width' ) ) {
|
||||
$classes[] = 'grid-container';
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
$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.
|
||||
*
|
||||
* @param array $classes The existing classes.
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_navigation_classes( $classes ) {
|
||||
$classes[] = 'main-navigation';
|
||||
|
||||
if ( 'contained-nav' === generate_get_option( 'nav_layout_setting' ) ) {
|
||||
if ( generate_is_using_flexbox() ) {
|
||||
$navigation_location = generate_get_navigation_location();
|
||||
|
||||
if ( 'nav-float-right' !== $navigation_location && 'nav-float-left' !== $navigation_location ) {
|
||||
$classes[] = 'grid-container';
|
||||
}
|
||||
} else {
|
||||
$classes[] = 'grid-container';
|
||||
$classes[] = 'grid-parent';
|
||||
}
|
||||
}
|
||||
|
||||
if ( generate_is_using_flexbox() ) {
|
||||
$nav_alignment = generate_get_option( 'nav_alignment_setting' );
|
||||
|
||||
if ( 'center' === $nav_alignment ) {
|
||||
$classes[] = 'nav-align-center';
|
||||
} elseif ( 'right' === $nav_alignment ) {
|
||||
$classes[] = 'nav-align-right';
|
||||
} elseif ( is_rtl() && 'left' === $nav_alignment ) {
|
||||
$classes[] = 'nav-align-left';
|
||||
}
|
||||
|
||||
if ( generate_has_menu_bar_items() ) {
|
||||
$classes[] = 'has-menu-bar-items';
|
||||
}
|
||||
}
|
||||
|
||||
$submenu_direction = 'right';
|
||||
|
||||
if ( 'left' === generate_get_option( 'nav_dropdown_direction' ) ) {
|
||||
$submenu_direction = 'left';
|
||||
}
|
||||
|
||||
if ( 'nav-left-sidebar' === generate_get_navigation_location() ) {
|
||||
$submenu_direction = 'right';
|
||||
|
||||
if ( 'both-right' === generate_get_layout() ) {
|
||||
$submenu_direction = 'left';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'nav-right-sidebar' === generate_get_navigation_location() ) {
|
||||
$submenu_direction = 'left';
|
||||
|
||||
if ( 'both-left' === generate_get_layout() ) {
|
||||
$submenu_direction = 'right';
|
||||
}
|
||||
}
|
||||
|
||||
$classes[] = 'sub-menu-' . $submenu_direction;
|
||||
|
||||
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.
|
||||
*
|
||||
* @param array $classes The existing classes.
|
||||
* @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';
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
$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.
|
||||
*
|
||||
* @param array $classes The existing classes.
|
||||
* @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.
|
||||
*
|
||||
* @param array $classes The existing classes.
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_footer_classes( $classes ) {
|
||||
$classes[] = 'site-footer';
|
||||
|
||||
if ( 'contained-footer' === generate_get_option( 'footer_layout_setting' ) ) {
|
||||
$classes[] = 'grid-container';
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
$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.
|
||||
*
|
||||
* @param array $classes The existing classes.
|
||||
* @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';
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
$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
|
||||
*
|
||||
* @param array $classes The existing classes.
|
||||
* @since 1.1.0
|
||||
*/
|
||||
function generate_main_classes( $classes ) {
|
||||
$classes[] = 'site-main';
|
||||
|
||||
return $classes;
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'generate_page_class', 'generate_do_page_container_classes' );
|
||||
/**
|
||||
* Adds custom classes to the #page element
|
||||
*
|
||||
* @param array $classes The existing classes.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_do_page_container_classes( $classes ) {
|
||||
$classes[] = 'site';
|
||||
$classes[] = 'grid-container';
|
||||
$classes[] = 'container';
|
||||
|
||||
if ( generate_is_using_hatom() ) {
|
||||
$classes[] = 'hfeed';
|
||||
}
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
$classes[] = 'grid-parent';
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
add_filter( 'generate_comment-author_class', 'generate_do_comment_author_classes' );
|
||||
/**
|
||||
* Adds custom classes to the comment author element
|
||||
*
|
||||
* @param array $classes The existing classes.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_do_comment_author_classes( $classes ) {
|
||||
$classes[] = 'comment-author';
|
||||
|
||||
if ( generate_is_using_hatom() ) {
|
||||
$classes[] = 'vcard';
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* @param array $classes The existing classes.
|
||||
* @since 1.3.39
|
||||
*/
|
||||
function generate_post_classes( $classes ) {
|
||||
if ( 'page' === get_post_type() || ! generate_is_using_hatom() ) {
|
||||
$classes = array_diff( $classes, array( 'hentry' ) );
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
}
|
279
wp-content/themes/generatepress/inc/meta-box.php
Normal file
279
wp-content/themes/generatepress/inc/meta-box.php
Normal file
@ -0,0 +1,279 @@
|
||||
<?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() . '/assets/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 );
|
||||
}
|
||||
|
||||
global $post;
|
||||
|
||||
$blog_id = get_option( 'page_for_posts' );
|
||||
|
||||
// No need for the Layout metabox on the blog page.
|
||||
if ( isset( $post->ID ) && $blog_id && (int) $blog_id === (int) $post->ID ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$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__( 'Content 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="generate-sidebar-layout" class="generate-layout-metabox-section-title"><?php esc_html_e( 'Sidebar Layout', 'generatepress' ); ?></label>
|
||||
|
||||
<select name="_generate-sidebar-layout-meta" id="generate-sidebar-layout">
|
||||
<option value="" <?php selected( $stored_meta['_generate-sidebar-layout-meta'][0], '' ); ?>><?php esc_html_e( 'Default', 'generatepress' ); ?></option>
|
||||
<option value="right-sidebar" <?php selected( $stored_meta['_generate-sidebar-layout-meta'][0], 'right-sidebar' ); ?>><?php esc_html_e( 'Right Sidebar', 'generatepress' ); ?></option>
|
||||
<option value="left-sidebar" <?php selected( $stored_meta['_generate-sidebar-layout-meta'][0], 'left-sidebar' ); ?>><?php esc_html_e( 'Left Sidebar', 'generatepress' ); ?></option>
|
||||
<option value="no-sidebar" <?php selected( $stored_meta['_generate-sidebar-layout-meta'][0], 'no-sidebar' ); ?>><?php esc_html_e( 'No Sidebars', 'generatepress' ); ?></option>
|
||||
<option value="both-sidebars" <?php selected( $stored_meta['_generate-sidebar-layout-meta'][0], 'both-sidebars' ); ?>><?php esc_html_e( 'Both Sidebars', 'generatepress' ); ?></option>
|
||||
<option value="both-left" <?php selected( $stored_meta['_generate-sidebar-layout-meta'][0], 'both-left' ); ?>><?php esc_html_e( 'Both Sidebars on Left', 'generatepress' ); ?></option>
|
||||
<option value="both-right" <?php selected( $stored_meta['_generate-sidebar-layout-meta'][0], 'both-right' ); ?>><?php esc_html_e( 'Both Sidebars on Right', 'generatepress' ); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="generate-layout-footer-widgets" style="display: none;">
|
||||
<div class="generate_footer_widget">
|
||||
<label for="generate-footer-widget" class="generate-layout-metabox-section-title"><?php esc_html_e( 'Footer Widgets', 'generatepress' ); ?></label>
|
||||
|
||||
<select name="_generate-footer-widget-meta" id="generate-footer-widget">
|
||||
<option value="" <?php selected( $stored_meta['_generate-footer-widget-meta'][0], '' ); ?>><?php esc_html_e( 'Default', 'generatepress' ); ?></option>
|
||||
<option value="0" <?php selected( $stored_meta['_generate-footer-widget-meta'][0], '0' ); ?>><?php esc_html_e( '0 Widgets', 'generatepress' ); ?></option>
|
||||
<option value="1" <?php selected( $stored_meta['_generate-footer-widget-meta'][0], '1' ); ?>><?php esc_html_e( '1 Widgets', 'generatepress' ); ?></option>
|
||||
<option value="2" <?php selected( $stored_meta['_generate-footer-widget-meta'][0], '2' ); ?>><?php esc_html_e( '2 Widgets', 'generatepress' ); ?></option>
|
||||
<option value="3" <?php selected( $stored_meta['_generate-footer-widget-meta'][0], '3' ); ?>><?php esc_html_e( '3 Widgets', 'generatepress' ); ?></option>
|
||||
<option value="4" <?php selected( $stored_meta['_generate-footer-widget-meta'][0], '4' ); ?>><?php esc_html_e( '4 Widgets', 'generatepress' ); ?></option>
|
||||
<option value="5" <?php selected( $stored_meta['_generate-footer-widget-meta'][0], '5' ); ?>><?php esc_html_e( '5 Widgets', 'generatepress' ); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div id="generate-layout-page-builder-container" style="display: none;">
|
||||
<label for="_generate-full-width-content" class="generate-layout-metabox-section-title"><?php esc_html_e( 'Content Container', 'generatepress' ); ?></label>
|
||||
|
||||
<p class="page-builder-content" style="color:#666;font-size:13px;margin-top:0;">
|
||||
<?php esc_html_e( 'Choose your content container type.', 'generatepress' ); ?>
|
||||
</p>
|
||||
|
||||
<select name="_generate-full-width-content" id="_generate-full-width-content">
|
||||
<option value="" <?php selected( $stored_meta['_generate-full-width-content'][0], '' ); ?>><?php esc_html_e( 'Default', 'generatepress' ); ?></option>
|
||||
<option value="true" <?php selected( $stored_meta['_generate-full-width-content'][0], 'true' ); ?>><?php esc_html_e( 'Full Width', 'generatepress' ); ?></option>
|
||||
<option value="contained" <?php selected( $stored_meta['_generate-full-width-content'][0], 'contained' ); ?>><?php esc_html_e( 'Contained', 'generatepress' ); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="generate-layout-disable-elements" style="display: none;">
|
||||
<label class="generate-layout-metabox-section-title"><?php esc_html_e( 'Disable Elements', 'generatepress' ); ?></label>
|
||||
<?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' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function. ?>" 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 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 = isset( $_POST[ $sidebar_layout_key ] )
|
||||
? sanitize_text_field( wp_unslash( $_POST[ $sidebar_layout_key ] ) )
|
||||
: '';
|
||||
|
||||
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 = isset( $_POST[ $footer_widget_key ] )
|
||||
? sanitize_text_field( wp_unslash( $_POST[ $footer_widget_key ] ) )
|
||||
: '';
|
||||
|
||||
// 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 = isset( $_POST[ $page_builder_container_key ] )
|
||||
? sanitize_text_field( wp_unslash( $_POST[ $page_builder_container_key ] ) )
|
||||
: '';
|
||||
|
||||
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 = isset( $_POST[ $disable_content_title_key ] )
|
||||
? sanitize_text_field( wp_unslash( $_POST[ $disable_content_title_key ] ) )
|
||||
: '';
|
||||
|
||||
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 );
|
||||
}
|
910
wp-content/themes/generatepress/inc/plugin-compat.php
Normal file
910
wp-content/themes/generatepress/inc/plugin-compat.php
Normal file
@ -0,0 +1,910 @@
|
||||
<?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' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag name for our WooCommerce wrappers.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
function generate_get_woocommerce_wrapper_tagname() {
|
||||
echo is_singular()
|
||||
? 'article'
|
||||
: 'div';
|
||||
}
|
||||
|
||||
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 <?php generate_do_attr( 'content' ); ?>>
|
||||
<main <?php generate_do_attr( 'main' ); ?>>
|
||||
<?php
|
||||
/**
|
||||
* generate_before_main_content hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_before_main_content' );
|
||||
?>
|
||||
<<?php generate_get_woocommerce_wrapper_tagname(); ?> <?php generate_do_attr( 'woocommerce-content' ); ?>>
|
||||
<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' );
|
||||
|
||||
$itemprop = '';
|
||||
|
||||
if ( 'microdata' === generate_get_schema_type() ) {
|
||||
$itemprop = ' itemprop="text"';
|
||||
}
|
||||
?>
|
||||
<div class="entry-content"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
|
||||
<?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>
|
||||
<?php
|
||||
/**
|
||||
* generate_after_content hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_after_content' );
|
||||
?>
|
||||
</div>
|
||||
</<?php generate_get_woocommerce_wrapper_tagname(); ?>>
|
||||
<?php
|
||||
/**
|
||||
* generate_after_main_content hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_after_main_content' );
|
||||
?>
|
||||
</main>
|
||||
</div>
|
||||
<?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() {
|
||||
if ( generate_is_using_flexbox() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$body_classes = get_body_class();
|
||||
|
||||
// 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', $body_classes ) && ! in_array( 'full-width-content', $body_classes ) && ! in_array( 'contained-content', $body_classes ) ) {
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'generate_do_third_party_plugin_css', 50 );
|
||||
/**
|
||||
* Add CSS for third-party plugins.
|
||||
*
|
||||
* @since 3.0.1
|
||||
*/
|
||||
function generate_do_third_party_plugin_css() {
|
||||
$css = new GeneratePress_CSS();
|
||||
|
||||
if ( generate_is_using_flexbox() && class_exists( 'Elementor\Plugin' ) ) {
|
||||
$css->set_selector( '.elementor-template-full-width .site-content' );
|
||||
$css->add_property( 'display', 'block' );
|
||||
}
|
||||
|
||||
if ( $css->css_output() ) {
|
||||
wp_add_inline_style( 'generate-style', $css->css_output() );
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'generate_do_pro_compatibility', 50 );
|
||||
/**
|
||||
* Add CSS to ensure compatibility with GP Premium.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_do_pro_compatibility() {
|
||||
if ( ! defined( 'GP_PREMIUM_VERSION' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$css = new GeneratePress_CSS();
|
||||
|
||||
if ( version_compare( GP_PREMIUM_VERSION, '1.11.0-alpha.1', '<' ) ) {
|
||||
if ( generate_is_using_flexbox() && defined( 'GENERATE_SECONDARY_NAV_VERSION' ) ) {
|
||||
$css->set_selector( '.secondary-navigation .inside-navigation:before, .secondary-navigation .inside-navigation:after' );
|
||||
$css->add_property( 'content', '"."' );
|
||||
$css->add_property( 'display', 'block' );
|
||||
$css->add_property( 'overflow', 'hidden' );
|
||||
$css->add_property( 'visibility', 'hidden' );
|
||||
$css->add_property( 'font-size', '0px' );
|
||||
$css->add_property( 'line-height', '0px' );
|
||||
$css->add_property( 'width', '0px' );
|
||||
$css->add_property( 'height', '0px' );
|
||||
|
||||
$css->set_selector( '.secondary-navigation .inside-navigation:after' );
|
||||
$css->add_property( 'clear', 'both' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( version_compare( GP_PREMIUM_VERSION, '1.12.0-alpha.1', '<' ) ) {
|
||||
if ( defined( 'GENERATE_MENU_PLUS_VERSION' ) && function_exists( 'generate_menu_plus_get_defaults' ) ) {
|
||||
$menu_plus_settings = wp_parse_args(
|
||||
get_option( 'generate_menu_plus_settings', array() ),
|
||||
generate_menu_plus_get_defaults()
|
||||
);
|
||||
|
||||
if ( generate_is_using_flexbox() && ( 'true' === $menu_plus_settings['sticky_menu'] || 'desktop' === $menu_plus_settings['sticky_menu'] || 'mobile' === $menu_plus_settings['sticky_menu'] || 'enable' === $menu_plus_settings['mobile_header_sticky'] ) ) {
|
||||
if ( generate_has_inline_mobile_toggle() ) {
|
||||
$css->start_media_query( generate_get_media_query( 'mobile-menu' ) );
|
||||
|
||||
$css->set_selector( '#sticky-placeholder' );
|
||||
$css->add_property( 'height', '0' );
|
||||
$css->add_property( 'overflow', 'hidden' );
|
||||
|
||||
$css->set_selector( '.has-inline-mobile-toggle #site-navigation.toggled' );
|
||||
$css->add_property( 'margin-top', '0' );
|
||||
|
||||
$css->set_selector( '.has-inline-mobile-menu #site-navigation.toggled .main-nav > ul' );
|
||||
$css->add_property( 'top', '1.5em' );
|
||||
|
||||
$css->stop_media_query();
|
||||
}
|
||||
|
||||
if ( 'desktop' === $menu_plus_settings['sticky_menu'] ) {
|
||||
$css->set_selector( '.sticky-enabled .gen-sidebar-nav.is_stuck .main-navigation' );
|
||||
$css->add_property( 'margin-bottom', '0' );
|
||||
|
||||
$css->set_selector( '.sticky-enabled .gen-sidebar-nav.is_stuck' );
|
||||
$css->add_property( 'z-index', '500' );
|
||||
|
||||
$css->set_selector( '.sticky-enabled .main-navigation.is_stuck' );
|
||||
$css->add_property( 'box-shadow', '0 2px 2px -2px rgba(0, 0, 0, .2)' );
|
||||
|
||||
$css->set_selector( '.navigation-stick:not(.gen-sidebar-nav)' );
|
||||
$css->add_property( 'left', '0' );
|
||||
$css->add_property( 'right', '0' );
|
||||
$css->add_property( 'width', '100% !important' );
|
||||
|
||||
$css->set_selector( '.both-sticky-menu .main-navigation:not(#mobile-header).toggled .main-nav > ul,.mobile-sticky-menu .main-navigation:not(#mobile-header).toggled .main-nav > ul,.mobile-header-sticky #mobile-header.toggled .main-nav > ul' );
|
||||
$css->add_property( 'position', 'absolute' );
|
||||
$css->add_property( 'left', '0' );
|
||||
$css->add_property( 'right', '0' );
|
||||
$css->add_property( 'z-index', '999' );
|
||||
}
|
||||
|
||||
$css->set_selector( '.nav-float-right .navigation-stick' );
|
||||
$css->add_property( 'width', '100% !important' );
|
||||
$css->add_property( 'left', '0' );
|
||||
|
||||
$css->set_selector( '.nav-float-right .navigation-stick .navigation-branding' );
|
||||
$css->add_property( 'margin-right', 'auto' );
|
||||
|
||||
if ( ! $menu_plus_settings['navigation_as_header'] ) {
|
||||
$header_left = 40;
|
||||
$header_right = 40;
|
||||
$mobile_header_left = 30;
|
||||
$mobile_header_right = 30;
|
||||
|
||||
if ( function_exists( 'generate_spacing_get_defaults' ) ) {
|
||||
$spacing_settings = wp_parse_args(
|
||||
get_option( 'generate_spacing_settings', array() ),
|
||||
generate_spacing_get_defaults()
|
||||
);
|
||||
|
||||
$header_left = $spacing_settings['header_left'];
|
||||
$header_right = $spacing_settings['header_right'];
|
||||
$mobile_header_left = $spacing_settings['mobile_header_left'];
|
||||
$mobile_header_right = $spacing_settings['mobile_header_right'];
|
||||
}
|
||||
|
||||
if ( function_exists( 'generate_is_using_flexbox' ) && generate_is_using_flexbox() ) {
|
||||
if ( function_exists( 'generate_get_option' ) && 'text' === generate_get_option( 'container_alignment' ) ) {
|
||||
$css->set_selector( '.main-navigation.navigation-stick .inside-navigation.grid-container' );
|
||||
$css->add_property( 'padding-left', $header_left, false, 'px' );
|
||||
$css->add_property( 'padding-right', $header_right, false, 'px' );
|
||||
|
||||
$css->start_media_query( generate_get_media_query( 'mobile-menu' ) );
|
||||
$css->set_selector( '.main-navigation.navigation-stick .inside-navigation.grid-container' );
|
||||
$css->add_property( 'padding-left', $mobile_header_left, false, 'px' );
|
||||
$css->add_property( 'padding-right', $mobile_header_right, false, 'px' );
|
||||
$css->stop_media_query();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$css->set_selector( '.nav-float-right .main-navigation.has-branding:not([class*="nav-align-"]):not(.mobile-header-navigation) .menu-bar-items,.nav-float-right .main-navigation.has-sticky-branding.navigation-stick:not([class*="nav-align-"]):not(.mobile-header-navigation) .menu-bar-items' );
|
||||
$css->add_property( 'margin-left', '0' );
|
||||
}
|
||||
|
||||
if ( generate_has_inline_mobile_toggle() && 'false' !== $menu_plus_settings['slideout_menu'] ) {
|
||||
$css->set_selector( '.slideout-mobile .has-inline-mobile-toggle #site-navigation.toggled,.slideout-both .has-inline-mobile-toggle #site-navigation.toggled' );
|
||||
$css->add_property( 'margin-top', '0' );
|
||||
}
|
||||
|
||||
if ( 'font' === generate_get_option( 'icons' ) ) {
|
||||
$css->set_selector( '.main-navigation .slideout-toggle a:before,.slide-opened .slideout-overlay .slideout-exit:before' );
|
||||
$css->add_property( 'font-family', 'GeneratePress' );
|
||||
|
||||
$css->set_selector( '.slideout-navigation .dropdown-menu-toggle:before' );
|
||||
$css->add_property( 'content', '"\f107" !important' );
|
||||
|
||||
$css->set_selector( '.slideout-navigation .sfHover > a .dropdown-menu-toggle:before' );
|
||||
$css->add_property( 'content', '"\f106" !important' );
|
||||
}
|
||||
|
||||
if ( generate_is_using_flexbox() && $menu_plus_settings['navigation_as_header'] ) {
|
||||
$content_left = 40;
|
||||
$content_right = 40;
|
||||
|
||||
if ( function_exists( 'generate_spacing_get_defaults' ) ) {
|
||||
$spacing_settings = wp_parse_args(
|
||||
get_option( 'generate_spacing_settings', array() ),
|
||||
generate_spacing_get_defaults()
|
||||
);
|
||||
|
||||
$content_left = $spacing_settings['content_left'];
|
||||
$content_right = $spacing_settings['content_right'];
|
||||
}
|
||||
|
||||
if ( 'text' === generate_get_option( 'container_alignment' ) ) {
|
||||
$css->set_selector( '.main-navigation.has-branding .inside-navigation.grid-container, .main-navigation.has-branding .inside-navigation.grid-container' );
|
||||
$css->add_property( 'padding', generate_padding_css( 0, $content_right, 0, $content_left ) );
|
||||
}
|
||||
|
||||
$css->set_selector( '.navigation-branding' );
|
||||
$css->add_property( 'margin-left', '10px' );
|
||||
|
||||
$css->set_selector( '.navigation-branding .main-title, .mobile-header-navigation .site-logo' );
|
||||
$css->add_property( 'margin-left', '10px' );
|
||||
|
||||
if ( is_rtl() ) {
|
||||
$css->set_selector( '.navigation-branding' );
|
||||
$css->add_property( 'margin-left', 'auto' );
|
||||
$css->add_property( 'margin-right', '10px' );
|
||||
|
||||
$css->set_selector( '.navigation-branding .main-title, .mobile-header-navigation .site-logo' );
|
||||
$css->add_property( 'margin-right', '10px' );
|
||||
$css->add_property( 'margin-left', '0' );
|
||||
}
|
||||
|
||||
$css->set_selector( '.navigation-branding > div + .main-title' );
|
||||
$css->add_property( 'margin-left', '10px' );
|
||||
|
||||
if ( is_rtl() ) {
|
||||
$css->set_selector( '.navigation-branding > div + .main-title' );
|
||||
$css->add_property( 'margin-right', '10px' );
|
||||
}
|
||||
|
||||
$css->set_selector( '.has-branding .navigation-branding img' );
|
||||
$css->add_property( 'margin', '0' );
|
||||
|
||||
$css->start_media_query( generate_get_media_query( 'mobile-menu' ) );
|
||||
if ( 'text' === generate_get_option( 'container_alignment' ) ) {
|
||||
$css->set_selector( '.main-navigation.has-branding .inside-navigation.grid-container' );
|
||||
$css->add_property( 'padding', '0' );
|
||||
}
|
||||
$css->stop_media_query();
|
||||
}
|
||||
}
|
||||
|
||||
if ( defined( 'GENERATE_SPACING_VERSION' ) ) {
|
||||
if ( generate_is_using_flexbox() ) {
|
||||
$css->set_selector( '#footer-widgets, .site-info' );
|
||||
$css->add_property( 'padding', '0' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( defined( 'GENERATE_SECONDARY_NAV_VERSION' ) ) {
|
||||
if ( generate_is_using_flexbox() && has_nav_menu( 'secondary' ) ) {
|
||||
if ( 'text' === generate_get_option( 'container_alignment' ) && function_exists( 'generate_secondary_nav_get_defaults' ) ) {
|
||||
$secondary_nav_settings = wp_parse_args(
|
||||
get_option( 'generate_secondary_nav_settings', array() ),
|
||||
generate_secondary_nav_get_defaults()
|
||||
);
|
||||
|
||||
$spacing_settings = wp_parse_args(
|
||||
get_option( 'generate_spacing_settings', array() ),
|
||||
generate_spacing_get_defaults()
|
||||
);
|
||||
|
||||
$navigation_left_padding = absint( $spacing_settings['header_left'] ) - absint( $secondary_nav_settings['secondary_menu_item'] );
|
||||
$navigation_right_padding = absint( $spacing_settings['header_right'] ) - absint( $secondary_nav_settings['secondary_menu_item'] );
|
||||
|
||||
$css->set_selector( '.secondary-nav-below-header .secondary-navigation .inside-navigation.grid-container, .secondary-nav-above-header .secondary-navigation .inside-navigation.grid-container' );
|
||||
$css->add_property( 'padding', generate_padding_css( 0, $navigation_right_padding, 0, $navigation_left_padding ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( generate_is_using_flexbox() && defined( 'GENERATE_FONT_VERSION' ) && function_exists( 'generate_get_default_fonts' ) ) {
|
||||
$font_settings = wp_parse_args(
|
||||
get_option( 'generate_settings', array() ),
|
||||
generate_get_default_fonts()
|
||||
);
|
||||
|
||||
if ( isset( $font_settings['tablet_navigation_font_size'] ) && '' !== $font_settings['tablet_navigation_font_size'] ) {
|
||||
$css->start_media_query( generate_get_media_query( 'tablet' ) );
|
||||
$css->set_selector( '.main-navigation .menu-toggle' );
|
||||
$css->add_property( 'font-size', absint( $font_settings['tablet_navigation_font_size'] ), false, 'px' );
|
||||
$css->stop_media_query();
|
||||
}
|
||||
|
||||
if ( isset( $font_settings['mobile_navigation_font_size'] ) && '' !== $font_settings['mobile_navigation_font_size'] ) {
|
||||
$css->start_media_query( generate_get_media_query( 'mobile-menu' ) );
|
||||
$css->set_selector( '.main-navigation .menu-toggle' );
|
||||
$css->add_property( 'font-size', absint( $font_settings['mobile_navigation_font_size'] ), false, 'px' );
|
||||
$css->stop_media_query();
|
||||
}
|
||||
}
|
||||
|
||||
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', '0' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $css->css_output() ) {
|
||||
wp_add_inline_style( 'generate-style', $css->css_output() );
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'generate_menu_item_dropdown_arrow_direction', 'generate_set_pro_menu_item_arrow_directions', 10, 3 );
|
||||
/**
|
||||
* Set the menu item arrow directions for Secondary and Slideout navs.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $arrow_direction The current direction.
|
||||
* @param object $args The args for the current menu.
|
||||
* @param int $depth The current depth of the menu item.
|
||||
*/
|
||||
function generate_set_pro_menu_item_arrow_directions( $arrow_direction, $args, $depth ) {
|
||||
if ( function_exists( 'generate_secondary_nav_get_defaults' ) && 'secondary' === $args->theme_location ) {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_secondary_nav_settings', array() ),
|
||||
generate_secondary_nav_get_defaults()
|
||||
);
|
||||
|
||||
if ( 0 !== $depth ) {
|
||||
$arrow_direction = 'right';
|
||||
|
||||
if ( 'left' === $settings['secondary_nav_dropdown_direction'] ) {
|
||||
$arrow_direction = 'left';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'secondary-nav-left-sidebar' === $settings['secondary_nav_position_setting'] ) {
|
||||
$arrow_direction = 'right';
|
||||
|
||||
if ( 'both-right' === generate_get_layout() ) {
|
||||
$arrow_direction = 'left';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'secondary-nav-right-sidebar' === $settings['secondary_nav_position_setting'] ) {
|
||||
$arrow_direction = 'left';
|
||||
|
||||
if ( 'both-left' === generate_get_layout() ) {
|
||||
$arrow_direction = 'right';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'hover' !== generate_get_option( 'nav_dropdown_type' ) ) {
|
||||
$arrow_direction = 'down';
|
||||
}
|
||||
}
|
||||
|
||||
return $arrow_direction;
|
||||
}
|
||||
|
||||
add_filter( 'generate_menu_plus_option_defaults', 'generate_set_menu_plus_compat_defaults' );
|
||||
/**
|
||||
* Set defaults in our pro Menu Plus module.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param array $defaults The existing defaults.
|
||||
*/
|
||||
function generate_set_menu_plus_compat_defaults( $defaults ) {
|
||||
if ( generate_has_inline_mobile_toggle() ) {
|
||||
$defaults['mobile_menu_label'] = '';
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
add_filter( 'generate_spacing_option_defaults', 'generate_set_spacing_compat_defaults', 20 );
|
||||
/**
|
||||
* Set defaults in our pro Spacing module.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param array $defaults The existing defaults.
|
||||
*/
|
||||
function generate_set_spacing_compat_defaults( $defaults ) {
|
||||
$defaults['mobile_header_top'] = '';
|
||||
$defaults['mobile_header_bottom'] = '';
|
||||
$defaults['mobile_header_right'] = '30';
|
||||
$defaults['mobile_header_left'] = '30';
|
||||
|
||||
$defaults['mobile_widget_top'] = '30';
|
||||
$defaults['mobile_widget_right'] = '30';
|
||||
$defaults['mobile_widget_bottom'] = '30';
|
||||
$defaults['mobile_widget_left'] = '30';
|
||||
|
||||
$defaults['mobile_footer_widget_container_top'] = '30';
|
||||
$defaults['mobile_footer_widget_container_right'] = '30';
|
||||
$defaults['mobile_footer_widget_container_bottom'] = '30';
|
||||
$defaults['mobile_footer_widget_container_left'] = '30';
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
add_filter( 'generate_page_hero_css_output', 'generate_do_pro_page_hero_css', 10, 2 );
|
||||
/**
|
||||
* Add CSS to our premium Page Heroes.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $css_output Existing CSS.
|
||||
* @param array $options The Header Element options.
|
||||
*/
|
||||
function generate_do_pro_page_hero_css( $css_output, $options ) {
|
||||
if ( ! defined( 'GP_PREMIUM_VERSION' ) ) {
|
||||
return $css_output;
|
||||
}
|
||||
|
||||
$new_css = '';
|
||||
|
||||
if ( version_compare( GP_PREMIUM_VERSION, '1.12.0-alpha.1', '<' ) ) {
|
||||
$css = new GeneratePress_CSS();
|
||||
|
||||
$padding_inside = false;
|
||||
|
||||
if ( generate_is_using_flexbox() && 'text' === generate_get_option( 'container_alignment' ) ) {
|
||||
$padding_inside = true;
|
||||
}
|
||||
|
||||
if ( $padding_inside ) {
|
||||
$container_width = generate_get_option( 'container_width' );
|
||||
$padding_right = '0px';
|
||||
$padding_left = '0px';
|
||||
|
||||
if ( $options['padding_right'] ) {
|
||||
$padding_right = absint( $options['padding_right'] ) . $options['padding_right_unit'];
|
||||
}
|
||||
|
||||
if ( $options['padding_left'] ) {
|
||||
$padding_left = absint( $options['padding_left'] ) . $options['padding_left_unit'];
|
||||
}
|
||||
|
||||
$css->set_selector( '.page-hero .inside-page-hero.grid-container' );
|
||||
|
||||
$css->add_property(
|
||||
'max-width',
|
||||
sprintf(
|
||||
'calc(%1$s - %2$s - %3$s)',
|
||||
$container_width . 'px',
|
||||
$padding_right,
|
||||
$padding_left
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( generate_is_using_flexbox() && '' !== $options['site_header_merge'] ) {
|
||||
if ( 'merge-desktop' === $options['site_header_merge'] ) {
|
||||
$css->start_media_query( apply_filters( 'generate_not_mobile_media_query', '(min-width: 769px)' ) );
|
||||
}
|
||||
|
||||
if ( $options['navigation_colors'] ) {
|
||||
$navigation_background = $options['navigation_background_color'] ? $options['navigation_background_color'] : 'transparent';
|
||||
$navigation_background_hover = $options['navigation_background_color_hover'] ? $options['navigation_background_color_hover'] : 'transparent';
|
||||
|
||||
$css->set_selector( '.header-wrap #site-navigation:not(.toggled), .header-wrap #mobile-header:not(.toggled):not(.navigation-stick), .has-inline-mobile-toggle .mobile-menu-control-wrapper' );
|
||||
$css->add_property( 'background', $navigation_background );
|
||||
|
||||
$css->set_selector( '.main-navigation:not(.toggled):not(.navigation-stick) .menu-bar-item:not(.close-search) > a' );
|
||||
$css->add_property( 'color', esc_attr( $options['navigation_text_color'] ) );
|
||||
|
||||
$css->set_selector( '.header-wrap #site-navigation:not(.toggled) .menu-bar-item:not(.close-search):hover > a, .header-wrap #mobile-header:not(.toggled) .menu-bar-item:not(.close-search):hover > a, .header-wrap #site-navigation:not(.toggled) .menu-bar-item:not(.close-search).sfHover > a, .header-wrap #mobile-header:not(.toggled) .menu-bar-item:not(.close-search).sfHover > a' );
|
||||
$css->add_property( 'background', $navigation_background_hover );
|
||||
|
||||
if ( '' !== $options['navigation_text_color_hover'] ) {
|
||||
$css->add_property( 'color', esc_attr( $options['navigation_text_color_hover'] ) );
|
||||
} else {
|
||||
$css->add_property( 'color', esc_attr( $options['navigation_text_color'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'merge-desktop' === $options['site_header_merge'] ) {
|
||||
$css->stop_media_query();
|
||||
}
|
||||
}
|
||||
|
||||
if ( $css->css_output() ) {
|
||||
$new_css = $css->css_output();
|
||||
}
|
||||
}
|
||||
|
||||
return $css_output . $new_css;
|
||||
}
|
||||
|
||||
add_action( 'customize_register', 'generate_pro_compat_customize_register', 100 );
|
||||
/**
|
||||
* Alter some Customizer options in the pro version.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param object $wp_customize The Customizer object.
|
||||
*/
|
||||
function generate_pro_compat_customize_register( $wp_customize ) {
|
||||
if ( ! defined( 'GP_PREMIUM_VERSION' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( version_compare( GP_PREMIUM_VERSION, '1.12.0-alpha.1', '<' ) ) {
|
||||
if ( $wp_customize->get_setting( 'generate_spacing_settings[separator]' ) ) {
|
||||
$wp_customize->get_setting( 'generate_spacing_settings[separator]' )->transport = 'refresh';
|
||||
}
|
||||
|
||||
if ( $wp_customize->get_setting( 'generate_spacing_settings[right_sidebar_width]' ) ) {
|
||||
$wp_customize->get_setting( 'generate_spacing_settings[right_sidebar_width]' )->transport = 'refresh';
|
||||
}
|
||||
|
||||
if ( $wp_customize->get_setting( 'generate_spacing_settings[left_sidebar_width]' ) ) {
|
||||
$wp_customize->get_setting( 'generate_spacing_settings[left_sidebar_width]' )->transport = 'refresh';
|
||||
}
|
||||
|
||||
if ( $wp_customize->get_setting( 'generate_spacing_settings[footer_widget_container_top]' ) ) {
|
||||
$wp_customize->get_setting( 'generate_spacing_settings[footer_widget_container_top]' )->transport = 'refresh';
|
||||
}
|
||||
|
||||
if ( $wp_customize->get_setting( 'generate_spacing_settings[footer_widget_container_right]' ) ) {
|
||||
$wp_customize->get_setting( 'generate_spacing_settings[footer_widget_container_right]' )->transport = 'refresh';
|
||||
}
|
||||
|
||||
if ( $wp_customize->get_setting( 'generate_spacing_settings[footer_widget_container_bottom]' ) ) {
|
||||
$wp_customize->get_setting( 'generate_spacing_settings[footer_widget_container_bottom]' )->transport = 'refresh';
|
||||
}
|
||||
|
||||
if ( $wp_customize->get_setting( 'generate_spacing_settings[footer_widget_container_left]' ) ) {
|
||||
$wp_customize->get_setting( 'generate_spacing_settings[footer_widget_container_left]' )->transport = 'refresh';
|
||||
}
|
||||
|
||||
if ( $wp_customize->get_setting( 'generate_spacing_settings[mobile_footer_widget_container_top]' ) ) {
|
||||
$wp_customize->get_setting( 'generate_spacing_settings[mobile_footer_widget_container_top]' )->transport = 'refresh';
|
||||
}
|
||||
|
||||
if ( $wp_customize->get_setting( 'generate_spacing_settings[mobile_footer_widget_container_right]' ) ) {
|
||||
$wp_customize->get_setting( 'generate_spacing_settings[mobile_footer_widget_container_right]' )->transport = 'refresh';
|
||||
}
|
||||
|
||||
if ( $wp_customize->get_setting( 'generate_spacing_settings[mobile_footer_widget_container_bottom]' ) ) {
|
||||
$wp_customize->get_setting( 'generate_spacing_settings[mobile_footer_widget_container_bottom]' )->transport = 'refresh';
|
||||
}
|
||||
|
||||
if ( $wp_customize->get_setting( 'generate_spacing_settings[mobile_footer_widget_container_left]' ) ) {
|
||||
$wp_customize->get_setting( 'generate_spacing_settings[mobile_footer_widget_container_left]' )->transport = 'refresh';
|
||||
}
|
||||
|
||||
if ( $wp_customize->get_setting( 'generate_spacing_settings[footer_top]' ) ) {
|
||||
$wp_customize->get_setting( 'generate_spacing_settings[footer_top]' )->transport = 'refresh';
|
||||
}
|
||||
|
||||
if ( $wp_customize->get_setting( 'generate_spacing_settings[footer_right]' ) ) {
|
||||
$wp_customize->get_setting( 'generate_spacing_settings[footer_right]' )->transport = 'refresh';
|
||||
}
|
||||
|
||||
if ( $wp_customize->get_setting( 'generate_spacing_settings[footer_bottom]' ) ) {
|
||||
$wp_customize->get_setting( 'generate_spacing_settings[footer_bottom]' )->transport = 'refresh';
|
||||
}
|
||||
|
||||
if ( $wp_customize->get_setting( 'generate_spacing_settings[footer_left]' ) ) {
|
||||
$wp_customize->get_setting( 'generate_spacing_settings[footer_left]' )->transport = 'refresh';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $wp_customize->get_panel( 'generate_typography_panel' ) ) {
|
||||
$wp_customize->get_panel( 'generate_typography_panel' )->active_callback = function() {
|
||||
if ( generate_is_using_dynamic_typography() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'wp', 'generate_do_pro_compatibility_setup' );
|
||||
/**
|
||||
* Do basic compatibility with GP Premium versions.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_do_pro_compatibility_setup() {
|
||||
if ( ! defined( 'GP_PREMIUM_VERSION' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( version_compare( GP_PREMIUM_VERSION, '1.12.0-alpha.1', '<' ) ) {
|
||||
// Fix Elements removing archive post titles.
|
||||
if ( function_exists( 'generate_premium_do_elements' ) && ! is_singular() ) {
|
||||
add_filter( 'generate_show_title', '__return_true', 20 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( generate_is_using_dynamic_typography() ) {
|
||||
remove_action( 'wp_enqueue_scripts', 'generate_enqueue_google_fonts', 0 );
|
||||
remove_action( 'wp_enqueue_scripts', 'generate_typography_premium_css', 100 );
|
||||
remove_filter( 'generate_external_dynamic_css_output', 'generate_typography_add_to_external_stylesheet' );
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'generate_has_active_menu', 'generate_do_pro_active_menus' );
|
||||
/**
|
||||
* Tell GP about our active pro menus.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param boolean $has_active_menu Whether we have an active menu.
|
||||
*/
|
||||
function generate_do_pro_active_menus( $has_active_menu ) {
|
||||
if ( ! defined( 'GP_PREMIUM_VERSION' ) ) {
|
||||
return $has_active_menu;
|
||||
}
|
||||
|
||||
if ( version_compare( GP_PREMIUM_VERSION, '2.1.0-alpha.1', '<' ) ) {
|
||||
if ( function_exists( 'generate_menu_plus_get_defaults' ) ) {
|
||||
$menu_plus_settings = wp_parse_args(
|
||||
get_option( 'generate_menu_plus_settings', array() ),
|
||||
generate_menu_plus_get_defaults()
|
||||
);
|
||||
|
||||
if ( 'disable' !== $menu_plus_settings['mobile_header'] || 'false' !== $menu_plus_settings['slideout_menu'] ) {
|
||||
$has_active_menu = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( function_exists( 'generate_secondary_nav_get_defaults' ) && has_nav_menu( 'secondary' ) ) {
|
||||
$has_active_menu = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $has_active_menu;
|
||||
}
|
||||
|
||||
add_action( 'init', 'generate_do_customizer_compatibility_setup' );
|
||||
/**
|
||||
* Make changes to the Customizer in the Pro version.
|
||||
*/
|
||||
function generate_do_customizer_compatibility_setup() {
|
||||
if ( ! defined( 'GP_PREMIUM_VERSION' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( version_compare( GP_PREMIUM_VERSION, '2.1.0-alpha.1', '<' ) ) {
|
||||
if ( generate_is_using_dynamic_typography() ) {
|
||||
remove_action( 'customize_register', 'generate_fonts_customize_register' );
|
||||
remove_action( 'customize_preview_init', 'generate_typography_customizer_live_preview' );
|
||||
}
|
||||
|
||||
remove_action( 'customize_register', 'generate_colors_customize_register' );
|
||||
remove_action( 'customize_preview_init', 'generate_colors_customizer_live_preview' );
|
||||
remove_action( 'customize_controls_enqueue_scripts', 'generate_enqueue_color_palettes', 1001 );
|
||||
remove_action( 'customize_register', 'generate_colors_secondary_nav_customizer', 1000 );
|
||||
remove_action( 'customize_register', 'generate_slideout_navigation_color_controls', 150 );
|
||||
remove_action( 'customize_register', 'generate_colors_wc_customizer', 100 );
|
||||
}
|
||||
}
|
142
wp-content/themes/generatepress/inc/structure/archives.php
Normal file
142
wp-content/themes/generatepress/inc/structure/archives.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?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;
|
||||
}
|
||||
?>
|
||||
<header <?php generate_do_attr( 'page-header' ); ?>>
|
||||
<?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>
|
||||
<?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' ), 50 ),
|
||||
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 = get_the_archive_description();
|
||||
|
||||
if ( ! empty( $term_description ) ) {
|
||||
if ( is_author() ) {
|
||||
printf( '<div class="author-info">%s</div>', $term_description ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
} else {
|
||||
printf( '<div class="taxonomy-description">%s</div>', $term_description ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* generate_after_archive_description hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_after_archive_description' );
|
||||
}
|
||||
|
||||
add_action( 'generate_before_loop', 'generate_do_search_results_title' );
|
||||
/**
|
||||
* Add the search results title to the search results page.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param string $template The template we're targeting.
|
||||
*/
|
||||
function generate_do_search_results_title( $template ) {
|
||||
if ( 'search' === $template ) {
|
||||
// phpcs:ignore -- No escaping needed.
|
||||
echo apply_filters(
|
||||
'generate_search_title_output',
|
||||
sprintf(
|
||||
'<header %s><h1 class="page-title">%s</h1></header>',
|
||||
generate_get_attr( 'page-header' ),
|
||||
sprintf(
|
||||
/* translators: 1: Search query name */
|
||||
__( 'Search Results for: %s', 'generatepress' ),
|
||||
'<span>' . get_search_query() . '</span>'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
233
wp-content/themes/generatepress/inc/structure/comments.php
Normal file
233
wp-content/themes/generatepress/inc/structure/comments.php
Normal file
@ -0,0 +1,233 @@
|
||||
<?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.
|
||||
*
|
||||
* @param object $comment The comment object.
|
||||
* @param array $args The existing args.
|
||||
* @param int $depth The thread depth.
|
||||
*/
|
||||
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 esc_html_e( 'Pingback:', 'generatepress' ); ?> <?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 <?php generate_do_attr( 'comment-body', array(), array( 'comment-id' => get_comment_ID() ) ); ?>>
|
||||
<footer <?php generate_do_attr( 'comment-meta' ); ?>>
|
||||
<?php
|
||||
if ( 0 != $args['avatar_size'] ) { // phpcs:ignore
|
||||
echo get_avatar( $comment, $args['avatar_size'] );
|
||||
}
|
||||
?>
|
||||
<div class="comment-author-info">
|
||||
<div <?php generate_do_element_classes( 'comment-author' ); ?>>
|
||||
<?php printf( '<cite itemprop="name" class="fn">%s</cite>', get_comment_author_link() ); ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* generate_after_comment_author_name hook.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
do_action( 'generate_after_comment_author_name' );
|
||||
|
||||
if ( apply_filters( 'generate_show_comment_entry_meta', true ) ) :
|
||||
$has_comment_date_link = apply_filters( 'generate_add_comment_date_link', true );
|
||||
|
||||
?>
|
||||
<div class="entry-meta comment-metadata">
|
||||
<?php
|
||||
if ( $has_comment_date_link ) {
|
||||
printf(
|
||||
'<a href="%s">',
|
||||
esc_url( get_comment_link( $comment->comment_ID ) )
|
||||
);
|
||||
}
|
||||
?>
|
||||
<time datetime="<?php comment_time( 'c' ); ?>" itemprop="datePublished">
|
||||
<?php
|
||||
printf(
|
||||
/* translators: 1: date, 2: time */
|
||||
_x( '%1$s at %2$s', '1: date, 2: time', 'generatepress' ), // phpcs:ignore
|
||||
get_comment_date(), // phpcs:ignore
|
||||
get_comment_time() // phpcs:ignore
|
||||
);
|
||||
?>
|
||||
</time>
|
||||
<?php
|
||||
if ( $has_comment_date_link ) {
|
||||
echo '</a>';
|
||||
}
|
||||
|
||||
edit_comment_link( __( 'Edit', 'generatepress' ), '<span class="edit-link">| ', '</span>' );
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php if ( '0' == $comment->comment_approved ) : // phpcs:ignore ?>
|
||||
<p class="comment-awaiting-moderation"><?php esc_html_e( 'Your comment is awaiting moderation.', 'generatepress' ); ?></p>
|
||||
<?php endif; ?>
|
||||
</footer>
|
||||
|
||||
<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>
|
||||
</article>
|
||||
<?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
|
||||
* @param object $comment The comment object.
|
||||
* @param array $args The existing args.
|
||||
* @param int $depth The thread depth.
|
||||
*/
|
||||
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 The existing 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" required></textarea></p>',
|
||||
esc_html__( 'Comment', 'generatepress' )
|
||||
);
|
||||
|
||||
$defaults['comment_notes_before'] = '';
|
||||
$defaults['comment_notes_after'] = '';
|
||||
$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 The existing fields.
|
||||
* @return array
|
||||
*/
|
||||
function generate_filter_comment_fields( $fields ) {
|
||||
$commenter = wp_get_current_commenter();
|
||||
$required = get_option( 'require_name_email' );
|
||||
|
||||
$fields['author'] = sprintf(
|
||||
'<label for="author" class="screen-reader-text">%1$s</label><input placeholder="%1$s%3$s" id="author" name="author" type="text" value="%2$s" size="30"%4$s />',
|
||||
esc_html__( 'Name', 'generatepress' ),
|
||||
esc_attr( $commenter['comment_author'] ),
|
||||
$required ? ' *' : '',
|
||||
$required ? ' required' : ''
|
||||
);
|
||||
|
||||
$fields['email'] = sprintf(
|
||||
'<label for="email" class="screen-reader-text">%1$s</label><input placeholder="%1$s%3$s" id="email" name="email" type="email" value="%2$s" size="30"%4$s />',
|
||||
esc_html__( 'Email', 'generatepress' ),
|
||||
esc_attr( $commenter['comment_author_email'] ),
|
||||
$required ? ' *' : '',
|
||||
$required ? ' required' : ''
|
||||
);
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
add_action( 'generate_after_do_template_part', 'generate_do_comments_template', 15 );
|
||||
/**
|
||||
* Add the comments template to pages and single posts.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $template The template we're targeting.
|
||||
*/
|
||||
function generate_do_comments_template( $template ) {
|
||||
if ( 'single' === $template || 'page' === $template ) {
|
||||
// If comments are open or we have at least one comment, load up the comment template.
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentionally loose.
|
||||
if ( comments_open() || '0' != get_comments_number() ) :
|
||||
/**
|
||||
* generate_before_comments_container hook.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
do_action( 'generate_before_comments_container' );
|
||||
?>
|
||||
|
||||
<div class="comments-area">
|
||||
<?php comments_template(); ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
<?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() ) {
|
||||
|
||||
$attrs = array();
|
||||
|
||||
if ( 'microdata' === generate_get_schema_type() ) {
|
||||
$attrs = array(
|
||||
'itemprop' => 'image',
|
||||
);
|
||||
}
|
||||
|
||||
echo apply_filters( // phpcs:ignore
|
||||
'generate_featured_image_output',
|
||||
sprintf(
|
||||
'<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' ),
|
||||
$attrs
|
||||
),
|
||||
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 $class 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;
|
||||
}
|
||||
|
||||
$attrs = array();
|
||||
|
||||
if ( 'microdata' === generate_get_schema_type() ) {
|
||||
$attrs = array(
|
||||
'itemprop' => 'image',
|
||||
);
|
||||
}
|
||||
?>
|
||||
<div class="featured-image <?php echo esc_attr( $class ); ?> grid-container grid-parent">
|
||||
<?php
|
||||
the_post_thumbnail(
|
||||
apply_filters( 'generate_page_header_default_size', 'full' ),
|
||||
$attrs
|
||||
);
|
||||
?>
|
||||
</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' );
|
||||
}
|
||||
}
|
||||
}
|
236
wp-content/themes/generatepress/inc/structure/footer.php
Normal file
236
wp-content/themes/generatepress/inc/structure/footer.php
Normal file
@ -0,0 +1,236 @@
|
||||
<?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 <?php generate_do_attr( 'site-info' ); ?>>
|
||||
<div <?php generate_do_attr( 'inside-site-info' ); ?>>
|
||||
<?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>
|
||||
<?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">© %1$s %2$s</span> • %4$s <a href="%3$s"%6$s>%5$s</a>',
|
||||
date( 'Y' ), // phpcs:ignore
|
||||
get_bloginfo( 'name' ),
|
||||
esc_url( 'https://generatepress.com' ),
|
||||
_x( 'Built with', 'GeneratePress', 'generatepress' ),
|
||||
__( 'GeneratePress', 'generatepress' ),
|
||||
'microdata' === generate_get_schema_type() ? ' itemprop="url"' : ''
|
||||
);
|
||||
|
||||
echo apply_filters( 'generate_copyright', $copyright ); // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_classes = sprintf(
|
||||
'footer-widget-%s',
|
||||
absint( $widget )
|
||||
);
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
$widget_width = apply_filters( "generate_footer_widget_{$widget}_width", $widget_width );
|
||||
$tablet_widget_width = apply_filters( "generate_footer_widget_{$widget}_tablet_width", '50' );
|
||||
|
||||
$widget_classes = sprintf(
|
||||
'footer-widget-%1$s grid-parent grid-%2$s tablet-grid-%3$s mobile-grid-100',
|
||||
absint( $widget ),
|
||||
absint( $widget_width ),
|
||||
absint( $tablet_widget_width )
|
||||
);
|
||||
}
|
||||
?>
|
||||
<div class="<?php echo $widget_classes; // phpcs:ignore ?>">
|
||||
<?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 ( 1 === (int) $widgets ) {
|
||||
$widget_width = '100';
|
||||
}
|
||||
|
||||
if ( 2 === (int) $widgets ) {
|
||||
$widget_width = '50';
|
||||
}
|
||||
|
||||
if ( 3 === (int) $widgets ) {
|
||||
$widget_width = '33';
|
||||
}
|
||||
|
||||
if ( 4 === (int) $widgets ) {
|
||||
$widget_width = '25';
|
||||
}
|
||||
|
||||
if ( 5 === (int) $widgets ) {
|
||||
$widget_width = '20';
|
||||
}
|
||||
?>
|
||||
<div id="footer-widgets" class="site footer-widgets">
|
||||
<div <?php generate_do_attr( 'footer-widgets-container' ); ?>>
|
||||
<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( // phpcs:ignore
|
||||
'generate_back_to_top_output',
|
||||
sprintf(
|
||||
'<a title="%1$s" aria-label="%1$s" rel="nofollow" href="#" class="generate-back-to-top" data-scroll-speed="%2$s" data-start-scroll="%3$s">
|
||||
%5$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' ) ),
|
||||
generate_get_svg_icon( 'arrow-up' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
386
wp-content/themes/generatepress/inc/structure/header.php
Normal file
386
wp-content/themes/generatepress/inc/structure/header.php
Normal file
@ -0,0 +1,386 @@
|
||||
<?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 <?php generate_do_attr( 'header' ); ?>>
|
||||
<div <?php generate_do_attr( 'inside-header' ); ?>>
|
||||
<?php
|
||||
/**
|
||||
* generate_before_header_content hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_before_header_content' );
|
||||
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
// 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>
|
||||
</header>
|
||||
<?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 is-logo-image',
|
||||
'alt' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
|
||||
'src' => $logo_url,
|
||||
)
|
||||
);
|
||||
|
||||
$data = get_theme_mod( 'custom_logo' ) && ( '' !== $retina_logo_url || generate_is_using_flexbox() )
|
||||
? wp_get_attachment_metadata( get_theme_mod( 'custom_logo' ) )
|
||||
: false;
|
||||
|
||||
if ( '' !== $retina_logo_url ) {
|
||||
$attr['srcset'] = $logo_url . ' 1x, ' . $retina_logo_url . ' 2x';
|
||||
}
|
||||
|
||||
if ( $data ) {
|
||||
if ( isset( $data['width'] ) ) {
|
||||
$attr['width'] = $data['width'];
|
||||
}
|
||||
|
||||
if ( isset( $data['height'] ) ) {
|
||||
$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( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'generate_logo_output',
|
||||
sprintf(
|
||||
'<div class="site-logo">
|
||||
<a href="%1$s" rel="home">
|
||||
<img %2$s />
|
||||
</a>
|
||||
</div>',
|
||||
esc_url( apply_filters( 'generate_logo_href', home_url( '/' ) ) ),
|
||||
$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; // phpcs:ignore
|
||||
|
||||
// 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; // phpcs:ignore
|
||||
|
||||
$schema_type = generate_get_schema_type();
|
||||
|
||||
// Build our site title.
|
||||
$site_title = apply_filters(
|
||||
'generate_site_title_output',
|
||||
sprintf(
|
||||
'<%1$s class="main-title"%4$s>
|
||||
<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' ),
|
||||
'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : ''
|
||||
)
|
||||
);
|
||||
|
||||
// Build our tagline.
|
||||
$site_tagline = apply_filters(
|
||||
'generate_site_description_output',
|
||||
sprintf(
|
||||
'<p class="site-description"%2$s>
|
||||
%1$s
|
||||
</p>',
|
||||
html_entity_decode( get_bloginfo( 'description', 'display' ) ), // phpcs:ignore
|
||||
'microdata' === generate_get_schema_type() ? ' itemprop="description"' : ''
|
||||
)
|
||||
);
|
||||
|
||||
// Site title and tagline.
|
||||
if ( false === $disable_title || false === $disable_tagline ) {
|
||||
if ( generate_needs_site_branding_container() ) {
|
||||
echo '<div class="site-branding-container">';
|
||||
generate_construct_logo();
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- outputting site title and tagline. False positive.
|
||||
echo apply_filters(
|
||||
'generate_site_branding_output',
|
||||
sprintf(
|
||||
'<div class="site-branding">
|
||||
%1$s
|
||||
%2$s
|
||||
</div>',
|
||||
( ! $disable_title ) ? $site_title : '',
|
||||
( ! $disable_tagline ) ? $site_tagline : ''
|
||||
)
|
||||
);
|
||||
|
||||
if ( generate_needs_site_branding_container() ) {
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'generate_header_items_order', 'generate_reorder_inline_site_branding' );
|
||||
/**
|
||||
* Remove the logo from it's usual position.
|
||||
*
|
||||
* @since 2.3
|
||||
* @param array $order Order of the header items.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'generate_before_header_content', 'generate_do_site_logo', 5 );
|
||||
/**
|
||||
* Add the site logo to our header.
|
||||
* Only added if we aren't using floats to preserve backwards compatibility.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_do_site_logo() {
|
||||
if ( ! generate_is_using_flexbox() || generate_needs_site_branding_container() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
generate_construct_logo();
|
||||
}
|
||||
|
||||
add_action( 'generate_before_header_content', 'generate_do_site_branding' );
|
||||
/**
|
||||
* Add the site branding to our header.
|
||||
* Only added if we aren't using floats to preserve backwards compatibility.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_do_site_branding() {
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
generate_construct_site_title();
|
||||
}
|
||||
|
||||
add_action( 'generate_after_header_content', 'generate_do_header_widget' );
|
||||
/**
|
||||
* Add the header widget to our header.
|
||||
* Only used when grid isn't using floats to preserve backwards compatibility.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_do_header_widget() {
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
generate_construct_header_widget();
|
||||
}
|
||||
|
||||
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_attr( 'top-bar' ); ?>>
|
||||
<div <?php generate_do_attr( 'inside-top-bar' ); ?>>
|
||||
<?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', 1 );
|
||||
/**
|
||||
* 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">' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
}
|
||||
|
||||
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' )
|
||||
);
|
||||
}
|
635
wp-content/themes/generatepress/inc/structure/navigation.php
Normal file
635
wp-content/themes/generatepress/inc/structure/navigation.php
Normal file
@ -0,0 +1,635 @@
|
||||
<?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() {
|
||||
/**
|
||||
* generate_before_navigation hook.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
do_action( 'generate_before_navigation' );
|
||||
?>
|
||||
<nav <?php generate_do_attr( 'navigation' ); ?>>
|
||||
<div <?php generate_do_attr( '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 <?php generate_do_attr( 'menu-toggle' ); ?>>
|
||||
<?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 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML allowed in filter.
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
'<span class="screen-reader-text">%s</span>',
|
||||
esc_html__( 'Menu', 'generatepress' )
|
||||
);
|
||||
}
|
||||
?>
|
||||
</button>
|
||||
<?php
|
||||
/**
|
||||
* generate_after_mobile_menu_button hook
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
do_action( 'generate_after_mobile_menu_button' );
|
||||
|
||||
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>
|
||||
</nav>
|
||||
<?php
|
||||
/**
|
||||
* generate_after_navigation hook.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
do_action( 'generate_after_navigation' );
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'generate_before_navigation', 'generate_do_header_mobile_menu_toggle' );
|
||||
/**
|
||||
* Build the mobile menu toggle in the header.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_do_header_mobile_menu_toggle() {
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! generate_has_inline_mobile_toggle() ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<nav <?php generate_do_attr( 'mobile-menu-control-wrapper' ); ?>>
|
||||
<?php
|
||||
/**
|
||||
* generate_inside_mobile_menu_control_wrapper hook.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
do_action( 'generate_inside_mobile_menu_control_wrapper' );
|
||||
?>
|
||||
<button <?php generate_do_attr( 'menu-toggle', array( 'data-nav' => 'site-navigation' ) ); ?>>
|
||||
<?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 = __( 'Menu', 'generatepress' );
|
||||
|
||||
if ( 'nav-float-right' === generate_get_navigation_location() || 'nav-float-left' === generate_get_navigation_location() ) {
|
||||
$mobile_menu_label = '';
|
||||
}
|
||||
|
||||
$mobile_menu_label = apply_filters( 'generate_mobile_menu_label', $mobile_menu_label );
|
||||
|
||||
if ( $mobile_menu_label ) {
|
||||
printf(
|
||||
'<span class="mobile-menu">%s</span>',
|
||||
$mobile_menu_label // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML allowed in filter.
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
'<span class="screen-reader-text">%s</span>',
|
||||
esc_html__( 'Menu', 'generatepress' )
|
||||
);
|
||||
}
|
||||
?>
|
||||
</button>
|
||||
</nav>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_menu_fallback' ) ) {
|
||||
/**
|
||||
* Menu fallback.
|
||||
*
|
||||
* @since 1.1.4
|
||||
*
|
||||
* @param array $args Existing menu args.
|
||||
*/
|
||||
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 ( ! generate_is_using_flexbox() && 'enable' === $generate_settings['nav_search'] ) {
|
||||
$search_item = apply_filters(
|
||||
'generate_navigation_search_menu_item_output',
|
||||
sprintf(
|
||||
'<li class="search-item menu-item-align-right"><a aria-label="%1$s" href="#">%2$s</a></li>',
|
||||
esc_attr__( 'Open Search Bar', 'generatepress' ),
|
||||
generate_get_svg_icon( 'search', true ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function.
|
||||
)
|
||||
);
|
||||
|
||||
echo $search_item; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Safe output.
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_add_navigation_after_header' ) ) {
|
||||
add_action( 'generate_after_header', 'generate_add_navigation_after_header', 5 );
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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 );
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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 );
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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 );
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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 );
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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 ) { // phpcs:ignore
|
||||
$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 ) { // phpcs:ignore
|
||||
$css_class[] = 'current-menu-item';
|
||||
} elseif ( $_current_page && $page->ID == $_current_page->post_parent ) { // phpcs:ignore
|
||||
$css_class[] = 'current-menu-parent';
|
||||
}
|
||||
} elseif ( $page->ID == get_option( 'page_for_posts' ) ) { // phpcs:ignore
|
||||
$css_class[] = 'current-menu-parent';
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Core filter name.
|
||||
$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 ), // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Core filter name.
|
||||
$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 $depth 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 ) {
|
||||
$arrow_direction = 'down';
|
||||
|
||||
if ( 'primary' === $args->theme_location ) {
|
||||
if ( 0 !== $depth ) {
|
||||
$arrow_direction = 'right';
|
||||
|
||||
if ( 'left' === generate_get_option( 'nav_dropdown_direction' ) ) {
|
||||
$arrow_direction = 'left';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'nav-left-sidebar' === generate_get_navigation_location() ) {
|
||||
$arrow_direction = 'right';
|
||||
|
||||
if ( 'both-right' === generate_get_layout() ) {
|
||||
$arrow_direction = 'left';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'nav-right-sidebar' === generate_get_navigation_location() ) {
|
||||
$arrow_direction = 'left';
|
||||
|
||||
if ( 'both-left' === generate_get_layout() ) {
|
||||
$arrow_direction = 'right';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'hover' !== generate_get_option( 'nav_dropdown_type' ) ) {
|
||||
$arrow_direction = 'down';
|
||||
}
|
||||
}
|
||||
|
||||
$arrow_direction = apply_filters( 'generate_menu_item_dropdown_arrow_direction', $arrow_direction, $args, $depth );
|
||||
|
||||
if ( 'down' === $arrow_direction ) {
|
||||
$arrow_direction = '';
|
||||
} else {
|
||||
$arrow_direction = '-' . $arrow_direction;
|
||||
}
|
||||
|
||||
$icon = generate_get_svg_icon( 'arrow' . $arrow_direction );
|
||||
$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( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'generate_navigation_search_output',
|
||||
sprintf(
|
||||
'<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' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'generate_after_primary_menu', 'generate_do_menu_bar_item_container' );
|
||||
add_action( 'generate_inside_mobile_menu_control_wrapper', 'generate_do_menu_bar_item_container' );
|
||||
/**
|
||||
* Add a container for menu bar items.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_do_menu_bar_item_container() {
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( generate_has_menu_bar_items() ) {
|
||||
echo '<div class="menu-bar-items">';
|
||||
do_action( 'generate_menu_bar_items' );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'wp', 'generate_add_menu_bar_items' );
|
||||
/**
|
||||
* Add menu bar items to the primary navigation.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_add_menu_bar_items() {
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'enable' === generate_get_option( 'nav_search' ) ) {
|
||||
add_action( 'generate_menu_bar_items', 'generate_do_navigation_search_button' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the navigation search button.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_do_navigation_search_button() {
|
||||
if ( ! generate_is_using_flexbox() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'enable' !== generate_get_option( 'nav_search' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$search_item = apply_filters(
|
||||
'generate_navigation_search_menu_item_output',
|
||||
sprintf(
|
||||
'<span class="menu-bar-item search-item"><a aria-label="%1$s" href="#">%2$s</a></span>',
|
||||
esc_attr__( 'Open Search Bar', 'generatepress' ),
|
||||
generate_get_svg_icon( 'search', true ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function.
|
||||
)
|
||||
);
|
||||
|
||||
echo $search_item; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- No escaping needed.
|
||||
}
|
||||
|
||||
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.
|
||||
* Only used if using old float system.
|
||||
*
|
||||
* @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 ( generate_is_using_flexbox() ) {
|
||||
return $nav;
|
||||
}
|
||||
|
||||
// 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 ) {
|
||||
$search_item = apply_filters(
|
||||
'generate_navigation_search_menu_item_output',
|
||||
sprintf(
|
||||
'<li class="search-item menu-item-align-right"><a aria-label="%1$s" href="#">%2$s</a></li>',
|
||||
esc_attr__( 'Open Search Bar', 'generatepress' ),
|
||||
generate_get_svg_icon( 'search', true ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function.
|
||||
)
|
||||
);
|
||||
|
||||
return $nav . $search_item;
|
||||
}
|
||||
|
||||
// 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.
|
||||
* Only used if using old float system.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
if ( generate_is_using_flexbox() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="mobile-bar-items">
|
||||
<?php do_action( 'generate_inside_mobile_menu_bar' ); ?>
|
||||
<span class="search-item">
|
||||
<a aria-label="<?php esc_attr_e( 'Open Search Bar', 'generatepress' ); ?>" href="#">
|
||||
<?php generate_do_svg_icon( 'search', true ); ?>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<?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
|
||||
}
|
579
wp-content/themes/generatepress/inc/structure/post-meta.php
Normal file
579
wp-content/themes/generatepress/inc/structure/post-meta.php
Normal file
@ -0,0 +1,579 @@
|
||||
<?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 ) {
|
||||
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 <?php generate_do_attr( 'post-navigation', array( 'id' => esc_attr( $nav_id ) ) ); ?>>
|
||||
<?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-left' ) . '<span class="prev">%link</span></div>',
|
||||
'next_format' => '<div class="nav-next">' . generate_get_svg_icon( 'arrow-right' ) . '<span class="next">%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',
|
||||
sprintf(
|
||||
/* translators: left arrow */
|
||||
__( '%s Previous', 'generatepress' ),
|
||||
'<span aria-hidden="true">←</span>'
|
||||
)
|
||||
),
|
||||
'next_text' => apply_filters(
|
||||
'generate_next_link_text',
|
||||
sprintf(
|
||||
/* translators: right arrow */
|
||||
__( 'Next %s', 'generatepress' ),
|
||||
'<span aria-hidden="true">→</span>'
|
||||
)
|
||||
),
|
||||
'before_page_number' => sprintf(
|
||||
'<span class="screen-reader-text">%s</span>',
|
||||
_x( 'Page', 'prepends the pagination page number for screen readers', 'generatepress' )
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* generate_paging_navigation hook.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
do_action( 'generate_paging_navigation' );
|
||||
|
||||
endif;
|
||||
?>
|
||||
</nav>
|
||||
<?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.
|
||||
*/
|
||||
function generate_do_post_meta_item( $item ) {
|
||||
if ( 'date' === $item ) {
|
||||
$time_string = '<time class="entry-date published" datetime="%1$s"%5$s>%2$s</time>';
|
||||
|
||||
$updated_time = get_the_modified_time( 'U' );
|
||||
$published_time = get_the_time( 'U' ) + 1800;
|
||||
$schema_type = generate_get_schema_type();
|
||||
|
||||
if ( $updated_time > $published_time ) {
|
||||
if ( apply_filters( 'generate_post_date_show_updated_only', false ) ) {
|
||||
$time_string = '<time class="entry-date updated-date" datetime="%3$s"%6$s>%4$s</time>';
|
||||
} else {
|
||||
$time_string = '<time class="updated" datetime="%3$s"%6$s>%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() ),
|
||||
'microdata' === $schema_type ? ' itemprop="datePublished"' : '',
|
||||
'microdata' === $schema_type ? ' itemprop="dateModified"' : ''
|
||||
);
|
||||
|
||||
$posted_on = '<span class="posted-on">%1$s%4$s</span> ';
|
||||
|
||||
if ( apply_filters( 'generate_post_date_link', false ) ) {
|
||||
$posted_on = '<span class="posted-on">%1$s<a href="%2$s" title="%3$s" rel="bookmark">%4$s</a></span> ';
|
||||
}
|
||||
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'generate_post_date_output',
|
||||
sprintf(
|
||||
$posted_on,
|
||||
apply_filters( 'generate_inside_post_meta_item_output', '', 'date' ),
|
||||
esc_url( get_permalink() ),
|
||||
esc_attr( get_the_time() ),
|
||||
$time_string
|
||||
),
|
||||
$time_string,
|
||||
$posted_on
|
||||
);
|
||||
}
|
||||
|
||||
if ( 'author' === $item ) {
|
||||
$schema_type = generate_get_schema_type();
|
||||
|
||||
$byline = '<span class="byline">%1$s<span class="author%8$s" %5$s><a class="url fn n" href="%2$s" title="%3$s" rel="author"%6$s><span class="author-name"%7$s>%4$s</span></a></span></span> ';
|
||||
|
||||
if ( ! apply_filters( 'generate_post_author_link', true ) ) {
|
||||
$byline = '<span class="byline">%1$s<span class="author%8$s" %5$s><span class="author-name"%7$s>%4$s</span></span></span> ';
|
||||
}
|
||||
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'generate_post_author_output',
|
||||
sprintf(
|
||||
$byline,
|
||||
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' ),
|
||||
'microdata' === $schema_type ? ' itemprop="url"' : '',
|
||||
'microdata' === $schema_type ? ' itemprop="name"' : '',
|
||||
generate_is_using_hatom() ? ' vcard' : ''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( 'categories' === $item ) {
|
||||
$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 ) {
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'generate_category_list_output',
|
||||
sprintf(
|
||||
'<span class="cat-links">%3$s<span class="screen-reader-text">%1$s </span>%2$s</span> ',
|
||||
esc_html_x( 'Categories', 'Used before category names.', 'generatepress' ),
|
||||
$categories_list,
|
||||
apply_filters( 'generate_inside_post_meta_item_output', '', 'categories' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'tags' === $item ) {
|
||||
$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 ) {
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'generate_tag_list_output',
|
||||
sprintf(
|
||||
'<span class="tags-links">%3$s<span class="screen-reader-text">%1$s </span>%2$s</span> ',
|
||||
esc_html_x( 'Tags', 'Used before tag names.', 'generatepress' ),
|
||||
$tags_list,
|
||||
apply_filters( 'generate_inside_post_meta_item_output', '', 'tags' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'comments-link' === $item ) {
|
||||
if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
|
||||
echo '<span class="comments-link">';
|
||||
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
'generate_inside_post_meta_item_output',
|
||||
'',
|
||||
'comments-link'
|
||||
);
|
||||
comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
|
||||
echo '</span> ';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'post-navigation' === $item && is_single() ) {
|
||||
generate_content_nav( 'nav-below' );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param string $output The existing output.
|
||||
* @param string $item The item to target.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove post meta items from display if their individual filters are set.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param array $items The post meta items.
|
||||
*/
|
||||
function generate_disable_post_meta_items( $items ) {
|
||||
$disable_filter_names = apply_filters(
|
||||
'generate_disable_post_meta_filter_names',
|
||||
array(
|
||||
'date' => 'generate_post_date',
|
||||
'author' => 'generate_post_author',
|
||||
'categories' => 'generate_show_categories',
|
||||
'tags' => 'generate_show_tags',
|
||||
'comments-link' => 'generate_show_comments',
|
||||
'post-navigation' => 'generate_show_post_navigation',
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $items as $item ) {
|
||||
$default_display = true;
|
||||
|
||||
if ( 'comments-link' === $item && is_singular() ) {
|
||||
$default_display = false;
|
||||
}
|
||||
|
||||
// phpcs:ignore -- Hook name is coming from a variable.
|
||||
if ( isset( $disable_filter_names[ $item ] ) && ! apply_filters( $disable_filter_names[ $item ], $default_display ) ) {
|
||||
$items = array_diff( $items, array( $item ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the post meta items in the header entry meta.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_get_header_entry_meta_items() {
|
||||
$items = apply_filters(
|
||||
'generate_header_entry_meta_items',
|
||||
array(
|
||||
'date',
|
||||
'author',
|
||||
)
|
||||
);
|
||||
|
||||
// Disable post meta items based on their individual filters.
|
||||
$items = generate_disable_post_meta_items( $items );
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the post meta items in the footer entry meta.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_get_footer_entry_meta_items() {
|
||||
$items = apply_filters(
|
||||
'generate_footer_entry_meta_items',
|
||||
array(
|
||||
'categories',
|
||||
'tags',
|
||||
'comments-link',
|
||||
'post-navigation',
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* This wasn't a "meta item" prior to 3.0.0 and some users may be using the filter above
|
||||
* without specifying that they want to include post-navigation. The below forces it to display
|
||||
* for users using the old float system to prevent it from disappearing on update.
|
||||
*/
|
||||
if ( ! generate_is_using_flexbox() && ! in_array( 'post-navigation', (array) $items ) ) {
|
||||
$items[] = 'post-navigation';
|
||||
}
|
||||
|
||||
if ( ! is_singular() ) {
|
||||
$items = array_diff( (array) $items, array( 'post-navigation' ) );
|
||||
}
|
||||
|
||||
// Disable post meta items based on their individual filters.
|
||||
$items = generate_disable_post_meta_items( $items );
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
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 = generate_get_header_entry_meta_items();
|
||||
|
||||
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 = generate_get_footer_entry_meta_items();
|
||||
|
||||
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" aria-label="%4$s">%3$s</a>',
|
||||
the_title_attribute( 'echo=0' ),
|
||||
esc_url( get_permalink( get_the_ID() ) ),
|
||||
__( 'Read more', 'generatepress' ),
|
||||
sprintf(
|
||||
/* translators: Aria-label describing the read more button */
|
||||
_x( 'More on %s', 'more on post title', 'generatepress' ),
|
||||
the_title_attribute( 'echo=0' )
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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" aria-label="%4$s">%3$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' ),
|
||||
sprintf(
|
||||
/* translators: Aria-label describing the read more button */
|
||||
_x( 'More on %s', 'more on post title', 'generatepress' ),
|
||||
the_title_attribute( 'echo=0' )
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'wp', 'generate_add_post_meta', 5 );
|
||||
/**
|
||||
* Add our post meta items to the page.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_add_post_meta() {
|
||||
$header_items = generate_get_header_entry_meta_items();
|
||||
|
||||
$header_post_types = apply_filters(
|
||||
'generate_entry_meta_post_types',
|
||||
array(
|
||||
'post',
|
||||
)
|
||||
);
|
||||
|
||||
if ( in_array( get_post_type(), $header_post_types ) && ! empty( $header_items ) ) {
|
||||
add_action( 'generate_after_entry_title', 'generate_post_meta' );
|
||||
}
|
||||
|
||||
$footer_items = generate_get_footer_entry_meta_items();
|
||||
|
||||
$footer_post_types = apply_filters(
|
||||
'generate_footer_meta_post_types',
|
||||
array(
|
||||
'post',
|
||||
)
|
||||
);
|
||||
|
||||
if ( in_array( get_post_type(), $footer_post_types ) && ! empty( $footer_items ) ) {
|
||||
add_action( 'generate_after_entry_content', 'generate_footer_meta' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_post_meta' ) ) {
|
||||
/**
|
||||
* Build the post meta.
|
||||
*
|
||||
* @since 1.3.29
|
||||
*/
|
||||
function generate_post_meta() {
|
||||
?>
|
||||
<div class="entry-meta">
|
||||
<?php generate_posted_on(); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_footer_meta' ) ) {
|
||||
/**
|
||||
* Build the footer post meta.
|
||||
*
|
||||
* @since 1.3.30
|
||||
*/
|
||||
function generate_footer_meta() {
|
||||
?>
|
||||
<footer <?php generate_do_attr( 'footer-entry-meta' ); ?>>
|
||||
<?php generate_entry_meta(); ?>
|
||||
</footer>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'generate_after_loop', 'generate_do_post_navigation' );
|
||||
/**
|
||||
* Add our post navigation after post loops.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $template The template of the current action.
|
||||
*/
|
||||
function generate_do_post_navigation( $template ) {
|
||||
$templates = apply_filters(
|
||||
'generate_post_navigation_templates',
|
||||
array(
|
||||
'index',
|
||||
'archive',
|
||||
'search',
|
||||
)
|
||||
);
|
||||
|
||||
if ( in_array( $template, $templates ) && apply_filters( 'generate_show_post_navigation', true ) ) {
|
||||
generate_content_nav( 'nav-below' );
|
||||
}
|
||||
}
|
111
wp-content/themes/generatepress/inc/structure/search-modal.php
Normal file
111
wp-content/themes/generatepress/inc/structure/search-modal.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* Post meta elements.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
add_action( 'wp_footer', 'generate_do_search_modal' );
|
||||
/**
|
||||
* Create the search modal HTML.
|
||||
*/
|
||||
function generate_do_search_modal() {
|
||||
if ( ! generate_get_option( 'nav_search_modal' ) ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="gp-modal gp-search-modal" id="gp-search">
|
||||
<div class="gp-modal__overlay" tabindex="-1" data-gpmodal-close>
|
||||
<div class="gp-modal__container">
|
||||
<?php do_action( 'generate_inside_search_modal' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action( 'generate_menu_bar_items', 'generate_do_search_modal_trigger' );
|
||||
/**
|
||||
* Create the search modal trigger.
|
||||
*/
|
||||
function generate_do_search_modal_trigger() {
|
||||
if ( ! generate_get_option( 'nav_search_modal' ) ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<span class="menu-bar-item">
|
||||
<a href="#" role="button" aria-label="<?php _e( 'Open search', 'generatepress' ); ?>" data-gpmodal-trigger="gp-search"><?php echo generate_get_svg_icon( 'search', true ); // phpcs:ignore -- Escaped in function. ?></a>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
|
||||
add_filter( 'generate_enable_modal_script', 'generate_enable_search_modal' );
|
||||
/**
|
||||
* Enable the search modal.
|
||||
*/
|
||||
function generate_enable_search_modal() {
|
||||
return generate_get_option( 'nav_search_modal' );
|
||||
}
|
||||
|
||||
add_action( 'generate_base_css', 'generate_do_search_modal_css' );
|
||||
/**
|
||||
* Do the modal CSS.
|
||||
*
|
||||
* @param Object $css The existing CSS object.
|
||||
*/
|
||||
function generate_do_search_modal_css( $css ) {
|
||||
if ( ! generate_get_option( 'nav_search_modal' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$css->set_selector( '.search-modal-fields' );
|
||||
$css->add_property( 'display', 'flex' );
|
||||
|
||||
$css->set_selector( '.gp-search-modal .gp-modal__overlay' );
|
||||
$css->add_property( 'align-items', 'flex-start' );
|
||||
$css->add_property( 'padding-top', '25vh' );
|
||||
$css->add_property( 'background', 'var(--gp-search-modal-overlay-bg-color)' );
|
||||
|
||||
$css->set_selector( '.search-modal-form' );
|
||||
$css->add_property( 'width', '500px' );
|
||||
$css->add_property( 'max-width', '100%' );
|
||||
$css->add_property( 'background-color', 'var(--gp-search-modal-bg-color)' );
|
||||
$css->add_property( 'color', 'var(--gp-search-modal-text-color)' );
|
||||
|
||||
$css->set_selector( '.search-modal-form .search-field, .search-modal-form .search-field:focus' );
|
||||
$css->add_property( 'width', '100%' );
|
||||
$css->add_property( 'height', '60px' );
|
||||
$css->add_property( 'background-color', 'transparent' );
|
||||
$css->add_property( 'border', 0 );
|
||||
$css->add_property( 'appearance', 'none' );
|
||||
$css->add_property( 'color', 'currentColor' );
|
||||
|
||||
$css->set_selector( '.search-modal-fields button, .search-modal-fields button:active, .search-modal-fields button:focus, .search-modal-fields button:hover' );
|
||||
$css->add_property( 'background-color', 'transparent' );
|
||||
$css->add_property( 'border', 0 );
|
||||
$css->add_property( 'color', 'currentColor' );
|
||||
$css->add_property( 'width', '60px' );
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
||||
add_action( 'generate_inside_search_modal', 'generate_do_search_fields' );
|
||||
/**
|
||||
* Add our search fields to the modal.
|
||||
*/
|
||||
function generate_do_search_fields() {
|
||||
?>
|
||||
<form role="search" method="get" class="search-modal-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
|
||||
<label class="screen-reader-text"><?php echo apply_filters( 'generate_search_label', _x( 'Search for:', 'label', 'generatepress' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></label>
|
||||
<div class="search-modal-fields">
|
||||
<input type="search" class="search-field" placeholder="<?php echo esc_attr( apply_filters( 'generate_search_placeholder', _x( 'Search …', 'placeholder', 'generatepress' ) ) ); ?>" value="<?php echo get_search_query(); ?>" name="s" />
|
||||
<button aria-label="<?php echo esc_attr( apply_filters( 'generate_search_button', _x( 'Search', 'submit button', 'generatepress' ) ) ); ?>"><?php echo generate_get_svg_icon( 'search' ); // phpcs:ignore -- Escaped in function. ?></button>
|
||||
</div>
|
||||
<?php do_action( 'generate_inside_search_modal_form' ); ?>
|
||||
</form>
|
||||
<?php
|
||||
}
|
83
wp-content/themes/generatepress/inc/structure/sidebars.php
Normal file
83
wp-content/themes/generatepress/inc/structure/sidebars.php
Normal 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() ) { // phpcs:ignore -- False positive.
|
||||
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 ) || generate_is_using_flexbox() ) {
|
||||
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
|
||||
}
|
828
wp-content/themes/generatepress/inc/theme-functions.php
Normal file
828
wp-content/themes/generatepress/inc/theme-functions.php
Normal file
@ -0,0 +1,828 @@
|
||||
<?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 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether we should display the entry header or not.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_show_entry_header() {
|
||||
$show_entry_header = true;
|
||||
$show_title = generate_show_title();
|
||||
$has_before_entry_title = has_action( 'generate_before_entry_title' );
|
||||
$has_after_entry_title = has_action( 'generate_after_entry_title' );
|
||||
|
||||
if ( is_page() ) {
|
||||
$has_before_entry_title = has_action( 'generate_before_page_title' );
|
||||
$has_after_entry_title = has_action( 'generate_after_page_title' );
|
||||
}
|
||||
|
||||
if ( ! $show_title && ! $has_before_entry_title && ! $has_after_entry_title ) {
|
||||
$show_entry_header = false;
|
||||
}
|
||||
|
||||
return apply_filters( 'generate_show_entry_header', $show_entry_header );
|
||||
}
|
||||
|
||||
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() );
|
||||
|
||||
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Core filter name.
|
||||
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() {
|
||||
$has_site_title = ! generate_get_option( 'hide_title' ) && get_bloginfo( 'title' );
|
||||
$has_site_tagline = ! generate_get_option( 'hide_tagline' ) && get_bloginfo( 'description' );
|
||||
|
||||
if ( get_theme_mod( 'custom_logo' ) && ( $has_site_title || $has_site_tagline ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create SVG icons.
|
||||
*
|
||||
* @since 2.3
|
||||
*
|
||||
* @param string $icon The icon to get.
|
||||
* @param bool $replace Whether we're replacing an icon on action (click).
|
||||
*/
|
||||
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" xmlns="http://www.w3.org/2000/svg" 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" xmlns="http://www.w3.org/2000/svg" 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" xmlns="http://www.w3.org/2000/svg" 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" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em"><path d="M0 112c0-26.51 21.49-48 48-48h110.014a48 48 0 0143.592 27.907l12.349 26.791A16 16 0 00228.486 128H464c26.51 0 48 21.49 48 48v224c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112z" /></svg>';
|
||||
}
|
||||
|
||||
if ( 'tags' === $icon ) {
|
||||
$output = '<svg viewBox="0 0 512 512" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" 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 00196.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" /></svg>';
|
||||
}
|
||||
|
||||
if ( 'comments' === $icon ) {
|
||||
$output = '<svg viewBox="0 0 512 512" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em"><path d="M132.838 329.973a435.298 435.298 0 0016.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"/><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" /></svg>';
|
||||
}
|
||||
|
||||
if ( 'arrow' === $icon ) {
|
||||
$output = '<svg viewBox="0 0 330 512" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" 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" /></svg>';
|
||||
}
|
||||
|
||||
if ( 'arrow-right' === $icon ) {
|
||||
$output = '<svg viewBox="0 0 192 512" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path d="M178.425 256.001c0 2.266-1.133 4.815-2.832 6.515L43.599 394.509c-1.7 1.7-4.248 2.833-6.514 2.833s-4.816-1.133-6.515-2.833l-14.163-14.162c-1.699-1.7-2.832-3.966-2.832-6.515 0-2.266 1.133-4.815 2.832-6.515l111.317-111.316L16.407 144.685c-1.699-1.7-2.832-4.249-2.832-6.515s1.133-4.815 2.832-6.515l14.163-14.162c1.7-1.7 4.249-2.833 6.515-2.833s4.815 1.133 6.514 2.833l131.994 131.993c1.7 1.7 2.832 4.249 2.832 6.515z" fill-rule="nonzero" /></svg>';
|
||||
}
|
||||
|
||||
if ( 'arrow-left' === $icon ) {
|
||||
$output = '<svg viewBox="0 0 192 512" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path d="M178.425 138.212c0 2.265-1.133 4.813-2.832 6.512L64.276 256.001l111.317 111.277c1.7 1.7 2.832 4.247 2.832 6.513 0 2.265-1.133 4.813-2.832 6.512L161.43 394.46c-1.7 1.7-4.249 2.832-6.514 2.832-2.266 0-4.816-1.133-6.515-2.832L16.407 262.514c-1.699-1.7-2.832-4.248-2.832-6.513 0-2.265 1.133-4.813 2.832-6.512l131.994-131.947c1.7-1.699 4.249-2.831 6.515-2.831 2.265 0 4.815 1.132 6.514 2.831l14.163 14.157c1.7 1.7 2.832 3.965 2.832 6.513z" fill-rule="nonzero" /></svg>';
|
||||
}
|
||||
|
||||
if ( 'arrow-up' === $icon ) {
|
||||
$output = '<svg viewBox="0 0 330 512" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path d="M305.863 314.916c0 2.266-1.133 4.815-2.832 6.514l-14.157 14.163c-1.699 1.7-3.964 2.832-6.513 2.832-2.265 0-4.813-1.133-6.512-2.832L164.572 224.276 53.295 335.593c-1.699 1.7-4.247 2.832-6.512 2.832-2.265 0-4.814-1.133-6.513-2.832L26.113 321.43c-1.699-1.7-2.831-4.248-2.831-6.514s1.132-4.816 2.831-6.515L158.06 176.408c1.699-1.7 4.247-2.833 6.512-2.833 2.265 0 4.814 1.133 6.513 2.833L303.03 308.4c1.7 1.7 2.832 4.249 2.832 6.515z" fill-rule="nonzero" /></svg>';
|
||||
}
|
||||
|
||||
$output = apply_filters( 'generate_svg_icon_element', $output, $icon );
|
||||
|
||||
if ( $replace ) {
|
||||
$output .= '<svg viewBox="0 0 512 512" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" 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>';
|
||||
}
|
||||
|
||||
$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 The icon to print.
|
||||
* @param bool $replace Whether to include the close icon to be shown using JS.
|
||||
*/
|
||||
function generate_do_svg_icon( $icon, $replace = false ) {
|
||||
echo generate_get_svg_icon( $icon, $replace ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function.
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our media queries.
|
||||
*
|
||||
* @since 2.4
|
||||
*
|
||||
* @param string $name Name of the media query.
|
||||
* @return string The full media query.
|
||||
*/
|
||||
function generate_get_media_query( $name ) {
|
||||
$desktop = apply_filters( 'generate_desktop_media_query', '(min-width:1025px)' );
|
||||
$tablet_only = 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_only' => $tablet_only,
|
||||
'tablet' => '(max-width: 1024px)',
|
||||
'mobile' => $mobile,
|
||||
'mobile-menu' => $mobile_menu,
|
||||
)
|
||||
);
|
||||
|
||||
return $queries[ $name ];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = '' ) {
|
||||
$after = apply_filters( 'generate_after_element_class_attribute', '', $context );
|
||||
|
||||
if ( $after ) {
|
||||
$after = ' ' . $after;
|
||||
}
|
||||
|
||||
echo 'class="' . join( ' ', generate_get_element_classes( $context, $class ) ) . '"' . $after; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function.
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 the kind of schema we're using.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_get_schema_type() {
|
||||
return apply_filters( 'generate_schema_type', 'microdata' );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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' !== generate_get_schema_type() ) {
|
||||
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 string $context The element to target.
|
||||
*/
|
||||
function generate_do_microdata( $context ) {
|
||||
echo generate_get_microdata( $context ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in function.
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to print hAtom output or not.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_is_using_hatom() {
|
||||
return apply_filters( 'generate_is_using_hatom', true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether we're using the Flexbox structure.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_is_using_flexbox() {
|
||||
// No flexbox for old versions of GPP.
|
||||
if ( defined( 'GP_PREMIUM_VERSION' ) && version_compare( GP_PREMIUM_VERSION, '1.11.0-alpha.1', '<' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return 'flexbox' === generate_get_option( 'structure' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we have any menu bar items.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_has_menu_bar_items() {
|
||||
return has_action( 'generate_menu_bar_items' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we should include the default template part.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $template The template to get.
|
||||
*/
|
||||
function generate_do_template_part( $template ) {
|
||||
/**
|
||||
* generate_before_do_template_part hook.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $template The template.
|
||||
*/
|
||||
do_action( 'generate_before_do_template_part', $template );
|
||||
|
||||
if ( apply_filters( 'generate_do_template_part', true, $template ) ) {
|
||||
if ( 'archive' === $template || 'index' === $template ) {
|
||||
get_template_part( 'content', get_post_format() );
|
||||
} elseif ( 'none' === $template ) {
|
||||
get_template_part( 'no-results' );
|
||||
} else {
|
||||
get_template_part( 'content', $template );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* generate_after_do_template_parts hook.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param string $template The template.
|
||||
*/
|
||||
do_action( 'generate_after_do_template_part', $template );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we should use inline mobile navigation.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_has_inline_mobile_toggle() {
|
||||
$has_inline_mobile_toggle = generate_is_using_flexbox() && ( 'nav-float-right' === generate_get_navigation_location() || 'nav-float-left' === generate_get_navigation_location() );
|
||||
|
||||
return apply_filters( 'generate_has_inline_mobile_toggle', $has_inline_mobile_toggle );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build our the_title() parameters.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_get_the_title_parameters() {
|
||||
$params = array(
|
||||
'before' => sprintf(
|
||||
'<h1 class="entry-title"%s>',
|
||||
'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : ''
|
||||
),
|
||||
'after' => '</h1>',
|
||||
);
|
||||
|
||||
if ( ! is_singular() ) {
|
||||
$params = array(
|
||||
'before' => sprintf(
|
||||
'<h2 class="entry-title"%2$s><a href="%1$s" rel="bookmark">',
|
||||
esc_url( get_permalink() ),
|
||||
'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : ''
|
||||
),
|
||||
'after' => '</a></h2>',
|
||||
);
|
||||
}
|
||||
|
||||
if ( 'link' === get_post_format() ) {
|
||||
$params = array(
|
||||
'before' => sprintf(
|
||||
'<h2 class="entry-title"%2$s><a href="%1$s" rel="bookmark">',
|
||||
esc_url( generate_get_link_url() ),
|
||||
'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : ''
|
||||
),
|
||||
'after' => '</a></h2>',
|
||||
);
|
||||
}
|
||||
|
||||
return apply_filters( 'generate_get_the_title_parameters', $params );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether we should display the default loop or not.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_has_default_loop() {
|
||||
return apply_filters( 'generate_has_default_loop', true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Detemine whether to output site branding container.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function generate_needs_site_branding_container() {
|
||||
$container = false;
|
||||
|
||||
if ( generate_has_logo_site_branding() ) {
|
||||
if ( generate_is_using_flexbox() || generate_get_option( 'inline_logo_site_branding' ) ) {
|
||||
$container = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge array of attributes with defaults, and apply contextual filter on array.
|
||||
*
|
||||
* The contextual filter is of the form `generate_attr_{context}`.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param string $context The context, to build filter name.
|
||||
* @param array $attributes Optional. Extra attributes to merge with defaults.
|
||||
* @param array $settings Optional. Custom data to pass to filter.
|
||||
* @return array Merged and filtered attributes.
|
||||
*/
|
||||
function generate_parse_attr( $context, $attributes = array(), $settings = array() ) {
|
||||
// Initialize an empty class attribute so it's easier to append to in filters.
|
||||
if ( ! isset( $attributes['class'] ) ) {
|
||||
$attributes['class'] = '';
|
||||
}
|
||||
|
||||
// We used to have a class-only system. If it's in use, add the classes.
|
||||
$classes = generate_get_element_classes( $context );
|
||||
|
||||
if ( $classes ) {
|
||||
$attributes['class'] .= join( ' ', $classes );
|
||||
}
|
||||
|
||||
// Contextual filter.
|
||||
return apply_filters( 'generate_parse_attr', $attributes, $context, $settings );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build list of attributes into a string and apply contextual filter on string.
|
||||
*
|
||||
* The contextual filter is of the form `generate_attr_{context}_output`.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param string $context The context, to build filter name.
|
||||
* @param array $attributes Optional. Extra attributes to merge with defaults.
|
||||
* @param array $settings Optional. Custom data to pass to filter.
|
||||
* @return string String of HTML attributes and values.
|
||||
*/
|
||||
function generate_get_attr( $context, $attributes = array(), $settings = array() ) {
|
||||
$attributes = generate_parse_attr( $context, $attributes, $settings );
|
||||
|
||||
$output = '';
|
||||
|
||||
// Cycle through attributes, build tag attribute string.
|
||||
foreach ( $attributes as $key => $value ) {
|
||||
if ( ! $value ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove any whitespace at the start or end of our classes.
|
||||
if ( 'class' === $key ) {
|
||||
$value = trim( $value );
|
||||
}
|
||||
|
||||
if ( true === $value ) {
|
||||
$output .= esc_html( $key ) . ' ';
|
||||
} else {
|
||||
$output .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Before this function existed we had the below to add attributes after the class attribute.
|
||||
$after = apply_filters( 'generate_after_element_class_attribute', '', $context );
|
||||
|
||||
if ( $after ) {
|
||||
$after = ' ' . $after;
|
||||
}
|
||||
|
||||
$output .= $after;
|
||||
|
||||
$output = apply_filters( 'generate_get_attr_output', $output, $attributes, $context, $settings );
|
||||
|
||||
return trim( $output );
|
||||
}
|
||||
|
||||
/**
|
||||
* Output our string of HTML attributes.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param string $context The context, to build filter name.
|
||||
* @param array $attributes Optional. Extra attributes to merge with defaults.
|
||||
* @param array $settings Optional. Custom data to pass to filter.
|
||||
*/
|
||||
function generate_do_attr( $context, $attributes = array(), $settings = array() ) {
|
||||
echo generate_get_attr( $context, $attributes, $settings ); // phpcs:ignore -- Escaping done in function.
|
||||
}
|
||||
|
||||
/**
|
||||
* Build our editor color palette based on our global colors.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function generate_get_editor_color_palette() {
|
||||
$global_colors = generate_get_option( 'global_colors' );
|
||||
$editor_palette = array();
|
||||
$static_colors = false;
|
||||
|
||||
if ( apply_filters( 'generate_color_palette_use_static_colors', false ) ) {
|
||||
$static_colors = true;
|
||||
}
|
||||
|
||||
if ( ! empty( $global_colors ) ) {
|
||||
foreach ( (array) $global_colors as $key => $data ) {
|
||||
$editor_palette[] = array(
|
||||
'name' => $data['name'],
|
||||
'slug' => $data['slug'],
|
||||
'color' => $static_colors ? $data['color'] : 'var(--' . $data['slug'] . ')',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $editor_palette;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our global colors.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function generate_get_global_colors() {
|
||||
$global_colors = generate_get_option( 'global_colors' );
|
||||
$colors = array();
|
||||
|
||||
if ( ! empty( $global_colors ) ) {
|
||||
foreach ( (array) $global_colors as $key => $data ) {
|
||||
$colors[] = array(
|
||||
'slug' => $data['slug'],
|
||||
'color' => $data['color'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our system default font.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function generate_get_system_default_font() {
|
||||
return apply_filters( 'generate_typography_system_stack', '-apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if we have a GP menu active.
|
||||
* This is primarily used to know whether we need to enqueue menu.js or not.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function generate_has_active_menu() {
|
||||
$has_active_menu = true;
|
||||
|
||||
if ( ! generate_get_navigation_location() ) {
|
||||
$has_active_menu = false;
|
||||
}
|
||||
|
||||
return apply_filters( 'generate_has_active_menu', $has_active_menu );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if we're using dynamic typography.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function generate_is_using_dynamic_typography() {
|
||||
return generate_get_option( 'use_dynamic_typography' );
|
||||
}
|
1144
wp-content/themes/generatepress/inc/typography.php
Normal file
1144
wp-content/themes/generatepress/inc/typography.php
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user