updated theme GeneratePress version 3.5.1

This commit is contained in:
2024-10-09 12:47:30 +00:00
committed by Gitium
parent e13bab0b76
commit 7dcace54d3
38 changed files with 374 additions and 70 deletions

View File

@ -264,23 +264,23 @@ function generate_do_inline_block_editor_css( $for = 'block-content' ) {
if ( 'never' !== $underline_links ) {
if ( 'always' === $underline_links ) {
$css->set_selector( '.wp-block a' );
$css->set_selector( ':where(.wp-block a)' );
$css->add_property( 'text-decoration', 'underline' );
}
if ( 'hover' === $underline_links ) {
$css->set_selector( '.wp-block a' );
$css->set_selector( ':where(.wp-block a)' );
$css->add_property( 'text-decoration', 'none' );
$css->set_selector( '.wp-block a:hover, .wp-block a:focus' );
$css->set_selector( ':where(.wp-block a:hover), :where(.wp-block a:focus)' );
$css->add_property( 'text-decoration', 'underline' );
}
if ( 'not-hover' === $underline_links ) {
$css->set_selector( '.wp-block a' );
$css->set_selector( ':where(.wp-block a)' );
$css->add_property( 'text-decoration', 'underline' );
$css->set_selector( '.wp-block a:hover, .wp-block a:focus' );
$css->set_selector( ':where(.wp-block a:hover), :where(.wp-block a:focus)' );
$css->add_property( 'text-decoration', 'none' );
}
@ -501,7 +501,7 @@ function generate_do_inline_block_editor_css( $for = 'block-content' ) {
}
}
$css->set_selector( 'a, a:visited' );
$css->set_selector( 'a' );
if ( $color_settings['content_link_color'] ) {
$css->add_property( 'color', $color_settings['content_link_color'] );

View File

@ -154,11 +154,12 @@ class GeneratePress_Dashboard {
<?php
foreach ( $tabs as $tab ) {
printf(
'<a href="%1$s" class="%2$s"%4$s>%3$s</a>',
'<a href="%1$s" class="%2$s"%4$s%5$s>%3$s</a>',
esc_url( $tab['url'] ),
esc_attr( $tab['class'] ),
esc_html( $tab['name'] ),
! empty( $tab['external'] ) ? 'target="_blank" rel="noreferrer noopener"' : ''
! empty( $tab['external'] ) ? 'target="_blank" rel="noreferrer noopener"' : '',
esc_attr( ! empty( $tab['id'] ) ? 'id=' . $tab['id'] : '' )
);
}
?>

View File

@ -245,6 +245,11 @@ if ( ! function_exists( 'generate_base_css' ) ) {
$css->set_selector( '.dropdown-click .sfHover > a > .dropdown-menu-toggle > .gp-icon svg' );
$css->add_property( 'transform', 'rotate(180deg)' );
if ( 'click' === generate_get_option( 'nav_dropdown_type' ) ) {
$css->set_selector( '.menu-item-has-children .dropdown-menu-toggle[role="presentation"]' );
$css->add_property( 'pointer-events', 'none' );
}
}
$css->set_selector( ':root' );

View File

@ -53,7 +53,7 @@ class GeneratePress_Customize_Field {
$control_args['type'] = 'generate-wrapper-control';
$wp_customize->add_control(
new GeneratePress_Customize_React_Control(
new GeneratePress_Customize_Wrapper_Control(
$wp_customize,
$id,
$control_args

View File

@ -0,0 +1,97 @@
<?php
/**
* Customize API: Wrapper class.
*
* @package GeneratePress
*/
/**
* Customize Wrapper Control class.
*
* @see WP_Customize_Control
*/
class GeneratePress_Customize_Wrapper_Control extends WP_Customize_Control {
/**
* Type.
*
* @access public
* @since 1.0.0
* @var string
*/
public $type = 'generate-wrapper-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() {
$html_attributes = array(
'class' => 'generate-customize-control-wrapper',
'id' => $this->id,
'data-wrapper-type' => $this->choices['type'],
);
if ( ! empty( $this->choices['class'] ) ) {
$html_attributes['class'] .= ' ' . $this->choices['class'];
}
$attributes_string = '';
foreach ( $html_attributes as $attribute => $value ) {
$attributes_string .= $attribute . '="' . esc_attr( $value ) . '" ';
}
$this->toggleIdScript();
?>
<div <?php echo $attributes_string; // phpcs:ignore -- Escaped above. ?>>
<?php
foreach ( $this->choices['items'] as $wrapper ) {
?>
<div id="<?php echo esc_attr( $wrapper . '--wrapper' ); ?>"></div>
<?php
}
?>
</div>
<?php
}
/**
* Add a script to toggle the wrapper.
*/
public function toggleIdScript() {
if ( ! empty( $this->choices['toggleId'] ) ) :
?>
<script>
var liElement = document.getElementById( 'customize-control-<?php echo esc_js( $this->id ); ?>' );
if ( liElement ) {
liElement.setAttribute('data-toggleId', '<?php echo esc_attr( $this->choices['toggleId'] ); ?>');
}
</script>
<?php
endif;
}
}

View File

@ -17,6 +17,7 @@ require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-react-cont
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-wrapper-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';

View File

@ -38,6 +38,11 @@ GeneratePress_Customize_Field::add_wrapper(
$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';
if ( defined( 'GP_PREMIUM_VERSION' ) && version_compare( GP_PREMIUM_VERSION, '2.4.1', '>' ) ) {
$buttons_selector .= ', .wc-block-components-button';
$buttons_hover_selector .= ', .wc-block-components-button:hover';
}
GeneratePress_Customize_Field::add_field(
'generate_settings[form_button_background_color]',
'GeneratePress_Customize_Color_Control',

View File

@ -370,6 +370,12 @@ function generate_do_control_inline_scripts() {
'palette' => $colors,
'showGoogleFonts' => apply_filters( 'generate_font_manager_show_google_fonts', true ),
'colorPickerShouldShift' => function_exists( 'did_filter' ),
'gpFontLibrary' => class_exists( 'GeneratePress_Pro_Font_Library' )
? GeneratePress_Pro_Font_Library::get_fonts()
: array(),
'gpFontLibraryURI' => class_exists( 'GeneratePress_Pro_Font_Library' )
? GeneratePress_Pro_Font_Library::get_font_library_uri()
: '',
)
);

View File

@ -91,6 +91,15 @@ if ( ! function_exists( 'generate_scripts' ) ) {
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 );
wp_localize_script(
'generate-dropdown-click',
'generatepressDropdownClick',
array(
'openSubMenuLabel' => esc_attr__( 'Open Sub-Menu', 'generatepress' ),
'closeSubMenuLabel' => esc_attr__( 'Close Sub-Menu', 'generatepress' ),
)
);
}
if ( apply_filters( 'generate_enable_modal_script', false ) ) {

View File

@ -222,7 +222,7 @@ if ( ! function_exists( 'generate_back_to_top' ) ) {
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">
'<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" role="button">
%5$s
</a>',
esc_attr__( 'Scroll back to top', 'generatepress' ),

View File

@ -365,12 +365,17 @@ if ( ! function_exists( 'generate_dropdown_icon_to_menu_link' ) ) {
* @return string The menu item.
*/
function generate_dropdown_icon_to_menu_link( $title, $item, $args, $depth ) {
$role = 'presentation';
$tabindex = '';
$role = 'presentation';
$tabindex = '';
$aria_label = '';
if ( 'click-arrow' === generate_get_option( 'nav_dropdown_type' ) ) {
$role = 'button';
$tabindex = ' tabindex="0"';
$aria_label = sprintf(
' aria-label="%s"',
esc_attr__( 'Open Sub-Menu', 'generatepress' )
);
}
if ( isset( $args->container_class ) && 'main-nav' === $args->container_class ) {
@ -417,7 +422,7 @@ if ( ! function_exists( 'generate_dropdown_icon_to_menu_link' ) ) {
}
$icon = generate_get_svg_icon( 'arrow' . $arrow_direction );
$title = $title . '<span role="' . $role . '" class="dropdown-menu-toggle"' . $tabindex . '>' . $icon . '</span>';
$title = $title . '<span role="' . $role . '" class="dropdown-menu-toggle"' . $tabindex . $aria_label . '>' . $icon . '</span>';
}
}
}
@ -426,6 +431,37 @@ if ( ! function_exists( 'generate_dropdown_icon_to_menu_link' ) ) {
}
}
add_filter( 'nav_menu_link_attributes', 'generate_set_menu_item_link_attributes', 10, 4 );
/**
* Add attributes to the menu item link when using the Click - Menu Item option.
*
* @since 3.5.0
*
* @param array $atts The menu item attributes.
* @param WP_Post $item The current menu item.
* @param stdClass $args The menu item args.
* @param int $depth The depth of the menu item.
* @return array The menu item attributes.
*/
function generate_set_menu_item_link_attributes( $atts, $item, $args, $depth ) {
if ( ! isset( $args->container_class ) || 'main-nav' !== $args->container_class ) {
return $atts;
}
if ( 'click' !== generate_get_option( 'nav_dropdown_type' ) ) {
return $atts;
}
if ( in_array( 'menu-item-has-children', $item->classes, true ) ) {
$atts['role'] = 'button';
$atts['aria-expanded'] = 'false';
$atts['aria-haspopup'] = 'true';
$atts['aria-label'] = esc_attr__( 'Open Sub-Menu', 'generatepress' );
}
return $atts;
}
if ( ! function_exists( 'generate_navigation_search' ) ) {
add_action( 'generate_inside_navigation', 'generate_navigation_search' );
/**