updated theme GeneratePress
version 3.0.2
This commit is contained in:
@ -18,41 +18,87 @@ if ( ! function_exists( 'generate_scripts' ) ) {
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
$dir_uri = get_template_directory_uri();
|
||||
|
||||
if ( generate_get_option( 'combine_css' ) && $suffix ) {
|
||||
wp_enqueue_style( 'generate-style', $dir_uri . "/css/all.min.css", array(), GENERATE_VERSION, 'all' );
|
||||
} else {
|
||||
$lite = '';
|
||||
if ( apply_filters( 'generate_unsemantic_grid_lite', false ) ) {
|
||||
$lite = '-lite';
|
||||
if ( generate_is_using_flexbox() ) {
|
||||
if ( is_singular() && comments_open() ) {
|
||||
wp_enqueue_style( 'generate-comments', $dir_uri . "/assets/css/components/comments{$suffix}.css", array(), GENERATE_VERSION, 'all' );
|
||||
}
|
||||
|
||||
wp_enqueue_style( 'generate-style-grid', $dir_uri . "/css/unsemantic-grid{$lite}{$suffix}.css", false, GENERATE_VERSION, 'all' );
|
||||
wp_enqueue_style( 'generate-style', $dir_uri . "/style{$suffix}.css", array(), GENERATE_VERSION, 'all' );
|
||||
wp_enqueue_style( 'generate-mobile-style', $dir_uri . "/css/mobile{$suffix}.css", array( 'generate-style' ), GENERATE_VERSION, 'all' );
|
||||
if (
|
||||
is_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 ( is_child_theme() ) {
|
||||
wp_enqueue_style( 'generate-child', get_stylesheet_uri(), array( 'generate-style' ), filemtime( get_stylesheet_directory() . '/style.css' ), '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 . "/css/font-awesome{$suffix}.css", false, '4.7', 'all' );
|
||||
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 . "/js/classList{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
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' );
|
||||
}
|
||||
|
||||
wp_enqueue_script( 'generate-menu', $dir_uri . "/js/menu{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
wp_enqueue_script( 'generate-a11y', $dir_uri . "/js/a11y{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
if ( apply_filters( 'generate_combine_js', true ) && $suffix ) {
|
||||
wp_enqueue_script( 'generate-main', $dir_uri . "/assets/js/main{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
$script_handle = 'generate-main';
|
||||
} else {
|
||||
wp_enqueue_script( 'generate-menu', $dir_uri . "/assets/js/menu{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
wp_enqueue_script( 'generate-a11y', $dir_uri . "/assets/js/a11y{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
$script_handle = 'generate-menu';
|
||||
}
|
||||
|
||||
wp_localize_script(
|
||||
$script_handle,
|
||||
'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 . "/js/dropdown-click{$suffix}.js", array( 'generate-menu' ), GENERATE_VERSION, true );
|
||||
wp_enqueue_script( 'generate-dropdown-click', $dir_uri . "/assets/js/dropdown-click{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
}
|
||||
|
||||
if ( 'enable' === generate_get_option( 'nav_search' ) ) {
|
||||
wp_enqueue_script( 'generate-navigation-search', $dir_uri . "/js/navigation-search{$suffix}.js", array( 'generate-menu' ), GENERATE_VERSION, true );
|
||||
wp_enqueue_script( 'generate-navigation-search', $dir_uri . "/assets/js/navigation-search{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
|
||||
wp_localize_script(
|
||||
'generate-navigation-search',
|
||||
@ -65,7 +111,7 @@ if ( ! function_exists( 'generate_scripts' ) ) {
|
||||
}
|
||||
|
||||
if ( 'enable' === generate_get_option( 'back_to_top' ) ) {
|
||||
wp_enqueue_script( 'generate-back-to-top', $dir_uri . "/js/back-to-top{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
wp_enqueue_script( 'generate-back-to-top', $dir_uri . "/assets/js/back-to-top{$suffix}.js", array(), GENERATE_VERSION, true );
|
||||
}
|
||||
|
||||
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
|
||||
@ -89,19 +135,21 @@ if ( ! function_exists( 'generate_widgets_init' ) ) {
|
||||
'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' ),
|
||||
'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>' ),
|
||||
) );
|
||||
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>' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -121,11 +169,11 @@ if ( ! function_exists( 'generate_smart_content_width' ) ) {
|
||||
$left_sidebar_width = apply_filters( 'generate_left_sidebar_width', '25' );
|
||||
$layout = generate_get_layout();
|
||||
|
||||
if ( 'left-sidebar' == $layout ) {
|
||||
if ( 'left-sidebar' === $layout ) {
|
||||
$content_width = $container_width * ( ( 100 - $left_sidebar_width ) / 100 );
|
||||
} elseif ( 'right-sidebar' == $layout ) {
|
||||
} elseif ( 'right-sidebar' === $layout ) {
|
||||
$content_width = $container_width * ( ( 100 - $right_sidebar_width ) / 100 );
|
||||
} elseif ( 'no-sidebar' == $layout ) {
|
||||
} elseif ( 'no-sidebar' === $layout ) {
|
||||
$content_width = $container_width;
|
||||
} else {
|
||||
$content_width = $container_width * ( ( 100 - ( $left_sidebar_width + $right_sidebar_width ) ) / 100 );
|
||||
@ -205,8 +253,8 @@ if ( ! function_exists( '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
|
||||
* @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;
|
||||
@ -216,7 +264,10 @@ if ( ! function_exists( 'generate_remove_caption_padding' ) ) {
|
||||
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
|
||||
* 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 ) ) {
|
||||
@ -224,6 +275,7 @@ if ( ! function_exists( 'generate_enhanced_image_navigation' ) ) {
|
||||
}
|
||||
|
||||
$image = get_post( $id );
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentially loose.
|
||||
if ( ! empty( $image->post_parent ) && $image->post_parent != $id ) {
|
||||
$url .= '#main';
|
||||
}
|
||||
@ -241,15 +293,17 @@ if ( ! function_exists( 'generate_categorized_blog' ) ) {
|
||||
* @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' ) ) ) {
|
||||
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,
|
||||
$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,
|
||||
) );
|
||||
// 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 );
|
||||
@ -269,7 +323,7 @@ if ( ! function_exists( 'generate_categorized_blog' ) ) {
|
||||
|
||||
if ( ! function_exists( 'generate_category_transient_flusher' ) ) {
|
||||
add_action( 'edit_category', 'generate_category_transient_flusher' );
|
||||
add_action( 'save_post', 'generate_category_transient_flusher' );
|
||||
add_action( 'save_post', 'generate_category_transient_flusher' );
|
||||
/**
|
||||
* Flush out the transients used in {@see generate_categorized_blog()}.
|
||||
*
|
||||
@ -309,7 +363,7 @@ add_filter( 'generate_fontawesome_essentials', 'generate_set_font_awesome_essent
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
* @param bool $essentials
|
||||
* @param bool $essentials The existing value.
|
||||
* @return bool
|
||||
*/
|
||||
function generate_set_font_awesome_essentials( $essentials ) {
|
||||
@ -326,7 +380,7 @@ add_filter( 'generate_dynamic_css_skip_cache', 'generate_skip_dynamic_css_cache'
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
* @param bool $cache
|
||||
* @param bool $cache The existing value.
|
||||
* @return bool
|
||||
*/
|
||||
function generate_skip_dynamic_css_cache( $cache ) {
|
||||
@ -341,6 +395,8 @@ 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 ) {
|
||||
@ -348,3 +404,33 @@ function generate_set_wp_headers( $headers ) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user