Okay
  Public Ticket #2883268
social media icons
Closed

Comments

  •  34
    Dave started the conversation

    Hi Tahir,

    I notice all social media icons in header and footer open use target="_blank" but I'd prefer these to open in the same window.

    I know new windows for eternal links has been pretty standard for years but from a usability perspective they are no longer the best option. New windows on mobile devices leave users struggling to get back to the original site and so should be avoided.

    Hope you can help out.

    Thanks,

    Dave


  •  1,878
    Judith replied

    Hey Dave,

    I am afraid Salient does not have any such Feature available at the moment.

    Thanks

  •  34
    Dave replied

    Hi there,

    Do you accept this is a bit of a usability issue and maybe something that should be addressed in a future release?

    If you're able to point me in the right direction of the PHP file(s) that I need to amend I'm happy to try and sort this myself.

    Many thanks,

    Dave



  •  8,844
    Tahir replied

    Hey Again,

    You can add this function to the Child Theme to override it: 

    Salient: header.php (nectar/helpers/header.php
    /**
     * Outputs social icons in the header navigation.
     *
     * @since 6.0
     */
    if ( ! function_exists( 'nectar_header_social_icons' ) ) {
        function nectar_header_social_icons( $location ) {
            global $nectar_options;
            $social_networks = nectar_get_social_media_list();
            if ( $location === 'secondary-nav' ) {
                echo '<ul id="social">';
            }
            foreach ( $social_networks as $network_name => $icon_arr ) {
                $leading_fa = ('font-awesome' === $icon_arr['icon_type']) ? 'fa ': '';
                if ( $network_name === 'rss' ) {
                    if ( ! empty( $nectar_options[ 'use-' . $network_name . '-icon-header' ] ) && $nectar_options[ 'use-' . $network_name . '-icon-header' ] === '1' ) {
                        $nectar_rss_url_link = ( ! empty( $nectar_options['rss-url'] ) ) ? $nectar_options['rss-url'] : get_bloginfo( 'rss_url' );
                        if( $location !== 'main-nav' ) { echo '<li>'; }
                        echo '<a target="_blank" href="' . esc_url( $nectar_rss_url_link ) . '"><span class="screen-reader-text">RSS</span><i class="' . esc_attr($leading_fa) . esc_attr($icon_arr['icon_class']) . '" aria-hidden="true"></i> </a>';
                        if( $location !== 'main-nav' ) { echo '</li>'; }
                    }
                }
                else {
                    $target_attr = ($network_name != 'email' && $network_name != 'phone') ? 'target="_blank"' : '';
                    if ( ! empty( $nectar_options[ 'use-' . $network_name . '-icon-header' ] ) && $nectar_options[ 'use-' . $network_name . '-icon-header' ] === '1' ) {
                        if( $location !== 'main-nav' ) { echo '<li>'; }
                        if( isset($nectar_options[ $network_name . '-url' ]) ) {
                            echo '<a '.$target_attr.'="" href="' . esc_url( $nectar_options[ $network_name . '-url' ] ) . '"><span class="screen-reader-text">'.esc_attr($network_name).'</span><i class="' . esc_attr($leading_fa) . esc_attr($icon_arr['icon_class']) . '" aria-hidden="true"></i> </a>';
                        } else {
                            echo '<a '.$target_attr.'="" href="#"><span class="screen-reader-text">'.esc_attr($network_name).'</span><i class="' . esc_attr($leading_fa) . esc_attr($icon_arr['icon_class']) . '" aria-hidden="true"></i> </a>';
                        }
                        if( $location !== 'main-nav' ) { echo '</li>'; }
                    }
                }
            } // end loop.
            if ( $location === 'secondary-nav' ) {
                echo '</ul>';
            }
        }
    }

    Thanks 


    ThemeNectar Support Team 

  •  34
    Dave replied

    Thanks, Tahir. Just what I was after!

    Dave