';
}
}
return null;
}
}
class-twenty-twenty-one-dark-mode.php 0000644 00000030155 14720672053 0013674 0 ustar 00 in the dashboard.
add_filter( 'admin_body_class', array( $this, 'admin_body_classes' ) );
// Add the switch on the frontend & customizer.
add_action( 'wp_footer', array( $this, 'the_switch' ) );
// Add the privacy policy content.
add_action( 'admin_init', array( $this, 'add_privacy_policy_content' ) );
}
/**
* Enqueues editor custom color variables & scripts.
*
* @since Twenty Twenty-One 1.0
*
* @return void
*/
public function editor_custom_color_variables() {
if ( ! $this->switch_should_render() ) {
return;
}
$background_color = get_theme_mod( 'background_color', 'D1E4DD' );
$should_respect_color_scheme = get_theme_mod( 'respect_user_color_preference', false );
if ( $should_respect_color_scheme && Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( $background_color ) > 127 ) {
// Add Dark Mode variable overrides.
wp_add_inline_style(
'twenty-twenty-one-custom-color-overrides',
'.is-dark-theme.is-dark-theme .editor-styles-wrapper { --global--color-background: var(--global--color-dark-gray); --global--color-primary: var(--global--color-light-gray); --global--color-secondary: var(--global--color-light-gray); --button--color-text: var(--global--color-background); --button--color-text-hover: var(--global--color-secondary); --button--color-text-active: var(--global--color-secondary); --button--color-background: var(--global--color-secondary); --button--color-background-active: var(--global--color-background); --global--color-border: #9ea1a7; --table--stripes-border-color: rgba(240, 240, 240, 0.15); --table--stripes-background-color: rgba(240, 240, 240, 0.15); }'
);
}
wp_enqueue_script(
'twentytwentyone-dark-mode-support-toggle',
get_template_directory_uri() . '/assets/js/dark-mode-toggler.js',
array(),
'1.0.0',
array( 'in_footer' => true )
);
wp_enqueue_script(
'twentytwentyone-editor-dark-mode-support',
get_template_directory_uri() . '/assets/js/editor-dark-mode-support.js',
array( 'twentytwentyone-dark-mode-support-toggle' ),
'1.0.0',
array( 'in_footer' => true )
);
}
/**
* Enqueues scripts and styles.
*
* @since Twenty Twenty-One 1.0
*
* @return void
*/
public function enqueue_scripts() {
if ( ! $this->switch_should_render() ) {
return;
}
$url = get_template_directory_uri() . '/assets/css/style-dark-mode.css';
if ( is_rtl() ) {
$url = get_template_directory_uri() . '/assets/css/style-dark-mode-rtl.css';
}
wp_enqueue_style( 'tt1-dark-mode', $url, array( 'twenty-twenty-one-style' ), wp_get_theme()->get( 'Version' ) ); // @phpstan-ignore-line. Version is always a string.
}
/**
* Enqueues scripts for the customizer.
*
* @since Twenty Twenty-One 1.0
*
* @return void
*/
public function customize_controls_enqueue_scripts() {
if ( ! $this->switch_should_render() ) {
return;
}
wp_enqueue_script(
'twentytwentyone-customize-controls',
get_template_directory_uri() . '/assets/js/customize.js',
array( 'customize-base', 'customize-controls', 'underscore', 'jquery', 'twentytwentyone-customize-helpers' ),
'1.0.0',
array( 'in_footer' => true )
);
}
/**
* Registers customizer options.
*
* @since Twenty Twenty-One 1.0
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
* @return void
*/
public function customizer_controls( $wp_customize ) {
$colors_section = $wp_customize->get_section( 'colors' );
if ( is_object( $colors_section ) ) {
$colors_section->title = __( 'Colors & Dark Mode', 'twentytwentyone' );
}
// Custom notice control.
require_once get_theme_file_path( 'classes/class-twenty-twenty-one-customize-notice-control.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
$wp_customize->add_setting(
'respect_user_color_preference_notice',
array(
'capability' => 'edit_theme_options',
'default' => '',
'sanitize_callback' => '__return_empty_string',
)
);
$wp_customize->add_control(
new Twenty_Twenty_One_Customize_Notice_Control(
$wp_customize,
'respect_user_color_preference_notice',
array(
'section' => 'colors',
'priority' => 100,
'active_callback' => static function () {
return 127 >= Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) );
},
)
)
);
$wp_customize->add_setting(
'respect_user_color_preference',
array(
'capability' => 'edit_theme_options',
'default' => false,
'sanitize_callback' => static function ( $value ) {
return (bool) $value;
},
)
);
$description = '';
$description .= sprintf(
/* translators: %s: Twenty Twenty-One support article URL. */
__( 'Dark Mode is a device setting. If a visitor to your site requests it, your site will be shown with a dark background and light text. Learn more about Dark Mode.', 'twentytwentyone' ),
esc_url( __( 'https://wordpress.org/documentation/article/twenty-twenty-one/#dark-mode-support', 'twentytwentyone' ) )
);
$description .= '
';
$description .= '' . __( 'Dark Mode can also be turned on and off with a button that you can find in the bottom corner of the page.', 'twentytwentyone' ) . '
';
$wp_customize->add_control(
'respect_user_color_preference',
array(
'type' => 'checkbox',
'section' => 'colors',
'label' => esc_html__( 'Dark Mode support', 'twentytwentyone' ),
'priority' => 110,
'description' => $description,
'active_callback' => static function ( $value ) {
return 127 < Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) );
},
)
);
// Add partial for background_color.
$wp_customize->selective_refresh->add_partial(
'background_color',
array(
'selector' => '#dark-mode-toggler',
'container_inclusive' => true,
'render_callback' => function () {
$attrs = ( $this->switch_should_render() ) ? array() : array( 'style' => 'display:none;' );
$this->the_html( $attrs );
},
)
);
}
/**
* Calculates classes for the main element.
*
* @since Twenty Twenty-One 1.0
*
* @param string $classes The classes for element.
* @return string
*/
public function html_classes( $classes ) {
if ( ! $this->switch_should_render() ) {
return $classes;
}
$background_color = get_theme_mod( 'background_color', 'D1E4DD' );
$should_respect_color_scheme = get_theme_mod( 'respect_user_color_preference', false );
if ( $should_respect_color_scheme && 127 <= Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( $background_color ) ) {
return ( $classes ) ? ' respect-color-scheme-preference' : 'respect-color-scheme-preference';
}
return $classes;
}
/**
* Adds a class to the element in the editor to accommodate dark-mode.
*
* @since Twenty Twenty-One 1.0
*
* @global WP_Screen $current_screen WordPress current screen object.
*
* @param string $classes The admin body-classes.
* @return string
*/
public function admin_body_classes( $classes ) {
if ( ! $this->switch_should_render() ) {
return $classes;
}
global $current_screen;
if ( empty( $current_screen ) ) {
set_current_screen();
}
if ( $current_screen->is_block_editor() ) {
$should_respect_color_scheme = get_theme_mod( 'respect_user_color_preference', false );
$background_color = get_theme_mod( 'background_color', 'D1E4DD' );
if ( $should_respect_color_scheme && Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( $background_color ) > 127 ) {
$classes .= ' twentytwentyone-supports-dark-theme';
}
}
return $classes;
}
/**
* Determines if we want to print the dark-mode switch or not.
*
* @since Twenty Twenty-One 1.0
*
* @global bool $is_IE
*
* @return bool
*/
public function switch_should_render() {
global $is_IE;
return (
get_theme_mod( 'respect_user_color_preference', false ) &&
! $is_IE &&
127 <= Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) )
);
}
/**
* Adds night/day switch.
*
* @since Twenty Twenty-One 1.0
*
* @return void
*/
public function the_switch() {
if ( ! $this->switch_should_render() ) {
return;
}
$this->the_html();
$this->the_script();
}
/**
* Prints the dark-mode switch HTML.
*
* Inspired from https://codepen.io/aaroniker/pen/KGpXZo (MIT-licensed)
*
* @since Twenty Twenty-One 1.0
*
* @param array $attrs The attributes to add to our ';
}
?>
get_data( $handle, $strategy ) ) {
wp_script_add_data( $handle, 'strategy', $strategy );
}
}
}
return $to_do;
}
/**
* Adds async/defer attributes to enqueued / registered scripts.
*
* Now that #12009 has landed in WordPress 6.3, this method is only used for older versions of WordPress.
* This method is used on the `script_loader_tag` filter.
*
* @since Twenty Twenty 1.0
*
* @link https://core.trac.wordpress.org/ticket/12009
*
* @param string $tag The script tag.
* @param string $handle The script handle.
* @return string Script HTML string.
*/
public function filter_script_loader_tag( $tag, $handle ) {
$strategies = array(
'async' => (bool) wp_scripts()->get_data( $handle, 'async' ),
'defer' => (bool) wp_scripts()->get_data( $handle, 'defer' ),
);
$strategy = wp_scripts()->get_data( $handle, 'strategy' );
if ( $strategy && isset( $strategies[ $strategy ] ) ) {
$strategies[ $strategy ] = true;
}
foreach ( array_keys( array_filter( $strategies ) ) as $attr ) {
// Prevent adding attribute when already added in #12009.
if ( ! preg_match( ":\s$attr(=|>|\s):", $tag ) ) {
$tag = preg_replace( ':(?=>):', " $attr", $tag, 1 );
}
// Only allow async or defer, not both.
break;
}
return $tag;
}
}
}
class-twentytwenty-separator-control.php 0000644 00000001043 14720676560 0014654 0 ustar 00 ';
}
}
}
}
class-twentytwenty-customize.php 0000644 00000034464 14720676560 0013235 0 ustar 00 get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->selective_refresh->add_partial(
'blogname',
array(
'selector' => '.site-title a',
'render_callback' => 'twentytwenty_customize_partial_blogname',
)
);
$wp_customize->selective_refresh->add_partial(
'blogdescription',
array(
'selector' => '.site-description',
'render_callback' => 'twentytwenty_customize_partial_blogdescription',
)
);
$wp_customize->selective_refresh->add_partial(
'custom_logo',
array(
'selector' => '.header-titles [class*=site-]:not(.site-description)',
'render_callback' => 'twentytwenty_customize_partial_site_logo',
'container_inclusive' => true,
)
);
$wp_customize->selective_refresh->add_partial(
'retina_logo',
array(
'selector' => '.header-titles [class*=site-]:not(.site-description)',
'render_callback' => 'twentytwenty_customize_partial_site_logo',
)
);
/**
* Site Identity
*/
/* 2X Header Logo ---------------- */
$wp_customize->add_setting(
'retina_logo',
array(
'capability' => 'edit_theme_options',
'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ),
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
'retina_logo',
array(
'type' => 'checkbox',
'section' => 'title_tagline',
'priority' => 10,
'label' => __( 'Retina logo', 'twentytwenty' ),
'description' => __( 'Scales the logo to half its uploaded size, making it sharp on high-res screens.', 'twentytwenty' ),
)
);
// Header & Footer Background Color.
$wp_customize->add_setting(
'header_footer_background_color',
array(
'default' => '#ffffff',
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'header_footer_background_color',
array(
'label' => __( 'Header & Footer Background Color', 'twentytwenty' ),
'section' => 'colors',
)
)
);
// Enable picking an accent color.
$wp_customize->add_setting(
'accent_hue_active',
array(
'capability' => 'edit_theme_options',
'sanitize_callback' => array( __CLASS__, 'sanitize_select' ),
'transport' => 'postMessage',
'default' => 'default',
)
);
$wp_customize->add_control(
'accent_hue_active',
array(
'type' => 'radio',
'section' => 'colors',
'label' => __( 'Primary Color', 'twentytwenty' ),
'choices' => array(
'default' => _x( 'Default', 'color', 'twentytwenty' ),
'custom' => _x( 'Custom', 'color', 'twentytwenty' ),
),
)
);
/**
* Implementation for the accent color.
* This is different to all other color options because of the accessibility enhancements.
* The control is a hue-only colorpicker, and there is a separate setting that holds values
* for other colors calculated based on the selected hue and various background-colors on the page.
*
* @since Twenty Twenty 1.0
*/
// Add the setting for the hue colorpicker.
$wp_customize->add_setting(
'accent_hue',
array(
'default' => 344,
'type' => 'theme_mod',
'sanitize_callback' => 'absint',
'transport' => 'postMessage',
)
);
// Add setting to hold colors derived from the accent hue.
$wp_customize->add_setting(
'accent_accessible_colors',
array(
'default' => array(
'content' => array(
'text' => '#000000',
'accent' => '#cd2653',
'secondary' => '#6d6d6d',
'borders' => '#dcd7ca',
),
'header-footer' => array(
'text' => '#000000',
'accent' => '#cd2653',
'secondary' => '#6d6d6d',
'borders' => '#dcd7ca',
),
),
'type' => 'theme_mod',
'transport' => 'postMessage',
'sanitize_callback' => array( __CLASS__, 'sanitize_accent_accessible_colors' ),
)
);
// Add the hue-only colorpicker for the accent color.
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'accent_hue',
array(
'section' => 'colors',
'settings' => 'accent_hue',
'description' => __( 'Apply a custom color for links, buttons, featured images.', 'twentytwenty' ),
'mode' => 'hue',
'active_callback' => static function () use ( $wp_customize ) {
return ( 'custom' === $wp_customize->get_setting( 'accent_hue_active' )->value() );
},
)
)
);
// Update background color with postMessage, so inline CSS output is updated as well.
$wp_customize->get_setting( 'background_color' )->transport = 'postMessage';
/**
* Theme Options
*/
$wp_customize->add_section(
'options',
array(
'title' => __( 'Theme Options', 'twentytwenty' ),
'priority' => 40,
'capability' => 'edit_theme_options',
)
);
/* Enable Header Search ----------------------------------------------- */
$wp_customize->add_setting(
'enable_header_search',
array(
'capability' => 'edit_theme_options',
'default' => true,
'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ),
)
);
$wp_customize->add_control(
'enable_header_search',
array(
'type' => 'checkbox',
'section' => 'options',
'priority' => 10,
'label' => __( 'Show search in header', 'twentytwenty' ),
)
);
/* Show author bio ---------------------------------------------------- */
$wp_customize->add_setting(
'show_author_bio',
array(
'capability' => 'edit_theme_options',
'default' => true,
'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ),
)
);
$wp_customize->add_control(
'show_author_bio',
array(
'type' => 'checkbox',
'section' => 'options',
'priority' => 10,
'label' => __( 'Show author bio', 'twentytwenty' ),
)
);
/* Display full content or excerpts on the blog and archives --------- */
$wp_customize->add_setting(
'blog_content',
array(
'capability' => 'edit_theme_options',
'default' => 'full',
'sanitize_callback' => array( __CLASS__, 'sanitize_select' ),
)
);
$wp_customize->add_control(
'blog_content',
array(
'type' => 'radio',
'section' => 'options',
'priority' => 10,
'label' => __( 'On archive pages, posts show:', 'twentytwenty' ),
'choices' => array(
'full' => __( 'Full text', 'twentytwenty' ),
'summary' => __( 'Summary', 'twentytwenty' ),
),
)
);
/**
* Template: Cover Template.
*/
$wp_customize->add_section(
'cover_template_options',
array(
'title' => __( 'Cover Template', 'twentytwenty' ),
'capability' => 'edit_theme_options',
'description' => __( 'Settings for the "Cover Template" page template. Add a featured image to use as background.', 'twentytwenty' ),
'priority' => 42,
)
);
/* Overlay Fixed Background ------ */
$wp_customize->add_setting(
'cover_template_fixed_background',
array(
'capability' => 'edit_theme_options',
'default' => true,
'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ),
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
'cover_template_fixed_background',
array(
'type' => 'checkbox',
'section' => 'cover_template_options',
'label' => __( 'Fixed Background Image', 'twentytwenty' ),
'description' => __( 'Creates a parallax effect when the visitor scrolls.', 'twentytwenty' ),
)
);
$wp_customize->selective_refresh->add_partial(
'cover_template_fixed_background',
array(
'selector' => '.cover-header',
'type' => 'cover_fixed',
)
);
/* Separator --------------------- */
$wp_customize->add_setting(
'cover_template_separator_1',
array(
'sanitize_callback' => 'wp_filter_nohtml_kses',
)
);
$wp_customize->add_control(
new TwentyTwenty_Separator_Control(
$wp_customize,
'cover_template_separator_1',
array(
'section' => 'cover_template_options',
)
)
);
/* Overlay Background Color ------ */
$wp_customize->add_setting(
'cover_template_overlay_background_color',
array(
'default' => twentytwenty_get_color_for_area( 'content', 'accent' ),
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'cover_template_overlay_background_color',
array(
'label' => __( 'Overlay Background Color', 'twentytwenty' ),
'description' => __( 'The color used for the overlay. Defaults to the accent color.', 'twentytwenty' ),
'section' => 'cover_template_options',
)
)
);
/* Overlay Text Color ------------ */
$wp_customize->add_setting(
'cover_template_overlay_text_color',
array(
'default' => '#ffffff',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'cover_template_overlay_text_color',
array(
'label' => __( 'Overlay Text Color', 'twentytwenty' ),
'description' => __( 'The color used for the text in the overlay.', 'twentytwenty' ),
'section' => 'cover_template_options',
)
)
);
/* Overlay Color Opacity --------- */
$wp_customize->add_setting(
'cover_template_overlay_opacity',
array(
'default' => 80,
'sanitize_callback' => 'absint',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
'cover_template_overlay_opacity',
array(
'label' => __( 'Overlay Opacity', 'twentytwenty' ),
'description' => __( 'Make sure that the contrast is high enough so that the text is readable.', 'twentytwenty' ),
'section' => 'cover_template_options',
'type' => 'range',
'input_attrs' => twentytwenty_customize_opacity_range(),
)
);
$wp_customize->selective_refresh->add_partial(
'cover_template_overlay_opacity',
array(
'selector' => '.cover-color-overlay',
'type' => 'cover_opacity',
)
);
}
/**
* Sanitization callback for the "accent_accessible_colors" setting.
*
* @since Twenty Twenty 1.0
*
* @param array $value The value we want to sanitize.
* @return array Returns sanitized value. Each item in the array gets sanitized separately.
*/
public static function sanitize_accent_accessible_colors( $value ) {
// Make sure the value is an array. Do not typecast, use empty array as fallback.
$value = is_array( $value ) ? $value : array();
// Loop values.
foreach ( $value as $area => $values ) {
foreach ( $values as $context => $color_val ) {
$value[ $area ][ $context ] = sanitize_hex_color( $color_val );
}
}
return $value;
}
/**
* Sanitize select.
*
* @since Twenty Twenty 1.0
*
* @param string $input The input from the setting.
* @param object $setting The selected setting.
* @return string The input from the setting or the default setting.
*/
public static function sanitize_select( $input, $setting ) {
$input = sanitize_key( $input );
$choices = $setting->manager->get_control( $setting->id )->choices;
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
}
/**
* Sanitize boolean for checkbox.
*
* @since Twenty Twenty 1.0
*
* @param bool $checked Whether or not a box is checked.
* @return bool
*/
public static function sanitize_checkbox( $checked ) {
return ( ( isset( $checked ) && true === $checked ) ? true : false );
}
}
// Setup the Theme Customizer settings and controls.
add_action( 'customize_register', array( 'TwentyTwenty_Customize', 'register' ) );
}
/**
* PARTIAL REFRESH FUNCTIONS
* */
if ( ! function_exists( 'twentytwenty_customize_partial_blogname' ) ) {
/**
* Render the site title for the selective refresh partial.
*
* @since Twenty Twenty 1.0
*/
function twentytwenty_customize_partial_blogname() {
bloginfo( 'name' );
}
}
if ( ! function_exists( 'twentytwenty_customize_partial_blogdescription' ) ) {
/**
* Render the site description for the selective refresh partial.
*
* @since Twenty Twenty 1.0
*/
function twentytwenty_customize_partial_blogdescription() {
bloginfo( 'description' );
}
}
if ( ! function_exists( 'twentytwenty_customize_partial_site_logo' ) ) {
/**
* Render the site logo for the selective refresh partial.
*
* Doing it this way so we don't have issues with `render_callback`'s arguments.
*
* @since Twenty Twenty 1.0
*/
function twentytwenty_customize_partial_site_logo() {
twentytwenty_site_logo();
}
}
/**
* Input attributes for cover overlay opacity option.
*
* @since Twenty Twenty 1.0
*
* @return array Array containing attribute names and their values.
*/
function twentytwenty_customize_opacity_range() {
/**
* Filters the input attributes for opacity.
*
* @since Twenty Twenty 1.0
*
* @param array $attrs {
* The attributes.
*
* @type int $min Minimum value.
* @type int $max Maximum value.
* @type int $step Interval between numbers.
* }
*/
return apply_filters(
'twentytwenty_customize_opacity_range',
array(
'min' => 0,
'max' => 90,
'step' => 5,
)
);
}
class-twentytwenty-walker-page.php 0000644 00000013145 14720676560 0013403 0 ustar 00 ID );
if ( isset( $args['pages_with_children'][ $page->ID ] ) ) {
$css_class[] = 'page_item_has_children';
}
if ( ! empty( $current_page_id ) ) {
$_current_page = get_post( $current_page_id );
if ( $_current_page && in_array( $page->ID, $_current_page->ancestors, true ) ) {
$css_class[] = 'current_page_ancestor';
}
if ( $page->ID === $current_page_id ) {
$css_class[] = 'current_page_item';
} elseif ( $_current_page && $page->ID === $_current_page->post_parent ) {
$css_class[] = 'current_page_parent';
}
} elseif ( get_option( 'page_for_posts' ) === $page->ID ) {
$css_class[] = 'current_page_parent';
}
/** This filter is documented in wp-includes/class-walker-page.php */
$css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page_id ) );
$css_classes = $css_classes ? ' class="' . esc_attr( $css_classes ) . '"' : '';
if ( '' === $page->post_title ) {
/* translators: %d: ID of a post. */
$page->post_title = sprintf( __( '#%d (no title)', 'twentytwenty' ), $page->ID );
}
$args['link_before'] = empty( $args['link_before'] ) ? '' : $args['link_before'];
$args['link_after'] = empty( $args['link_after'] ) ? '' : $args['link_after'];
$atts = array();
$atts['href'] = get_permalink( $page->ID );
$atts['aria-current'] = ( $page->ID === $current_page_id ) ? 'page' : '';
/** This filter is documented in wp-includes/class-walker-page.php */
$atts = apply_filters( 'page_menu_link_attributes', $atts, $page, $depth, $args, $current_page_id );
$attributes = '';
foreach ( $atts as $attr => $value ) {
if ( ! empty( $value ) ) {
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
$attributes .= ' ' . $attr . '="' . $value . '"';
}
}
$args['list_item_before'] = '';
$args['list_item_after'] = '';
// Wrap the link in a div and append a sub menu toggle.
if ( isset( $args['show_toggles'] ) && true === $args['show_toggles'] ) {
// Wrap the menu item link contents in a div, used for positioning.
$args['list_item_before'] = '';
$args['list_item_after'] = '';
// Add a toggle to items with children.
if ( isset( $args['pages_with_children'][ $page->ID ] ) ) {
$toggle_target_string = '.menu-modal .page-item-' . $page->ID . ' > ul';
$toggle_duration = twentytwenty_toggle_duration();
// Add the sub menu toggle.
$args['list_item_after'] .= '';
}
// Close the wrapper.
$args['list_item_after'] .= '
';
}
// Add icons to menu items with children.
if ( isset( $args['show_sub_menu_icons'] ) && true === $args['show_sub_menu_icons'] ) {
if ( isset( $args['pages_with_children'][ $page->ID ] ) ) {
$args['list_item_after'] = '