简体   繁体   中英

Adding a filter to Super Socializer social login

I'm using a plugin called Super Socializer which allows users to sign in using Twitter and Facebook. I would like to replace the social login icons with HTML text. I'm new to working with filters in WordPress and this approach is new to me.

The plugin has code which will allow me to add a filter:

$customInterface = apply_filters('the_champ_login_interface_filter', '', $theChampLoginOptions, $widget);

My approach to change the icons with text would be to do this in functions.php:

`add_filter('the_champ_login_interface_filter', 'changeIconsToText');

function changeIconsToText() {
    // code to change icons to text
}`

This issue is that I don't know where to go from here. How can I grab the variable holding the icons and change it to text? any help would be greatly appreciated, thanks!

The maker(s) of the plugin were quick to response with a solution so I'm posting it here for anyone else who needs it. In functions.php, just create a function and then apply your changes, then add a filter.

function heateor_ss_custom_social_login_icons( $html, $theChampLoginOptions, $widget ) {
    if ( isset( $theChampLoginOptions['providers'] ) && is_array($theChampLoginOptions['providers'] ) && count( $theChampLoginOptions['providers'] ) > 0 ) {
        $html = the_champ_login_notifications( $theChampLoginOptions );
    if ( ! $widget ) {
        $html .= '<div class="the_champ_outer_login_container">';
    if ( isset( $theChampLoginOptions['title'] ) && $theChampLoginOptions['title'] != '' ) {
        $html .= '<div class="the_champ_social_login_title">' . $theChampLoginOptions['title'] . '</div>';
        }
    }
    $html .= '<div class="the_champ_login_container"><ul class="the_champ_login_ul">';
    if ( isset( $theChampLoginOptions['providers'] ) && is_array( $theChampLoginOptions['providers'] ) && count( $theChampLoginOptions['providers'] ) > 0 ) {
        foreach ( $theChampLoginOptions['providers'] as $provider ) {
            $html .= '<li><i ';
    // id
    if( $provider == 'google' ) {
        $html .= 'id="theChamp' . ucfirst( $provider ) . 'Button" ';
    }
    // class
    $html .= 'class="theChampLogin theChamp' . ucfirst( $provider ) . 'Background theChamp' . ucfirst( $provider ) . 'Login" ';
    $html .= 'alt="Login with ';
    $html .= ucfirst( $provider );
    $html .= '" title="Login with ';
    if ( $provider == 'live' ) {
        $html .= 'Windows Live';
    } else {
        $html .= ucfirst( $provider );
    }
    if ( current_filter() == 'comment_form_top' || current_filter() == 'comment_form_must_log_in_after' ) {
        $html .= '" onclick="theChampCommentFormLogin = true; theChampInitiateLogin(this)" >';
    } else {
        $html .= '" onclick="theChampInitiateLogin(this)" >';
    }
    $html .= '<ss style="display:block" class="theChampLoginSvg theChamp' . ucfirst( $provider ) . 'LoginSvg"></ss></i></li>';
    }
    }
    $html .= '</ul></div>';
    if ( ! $widget ) {
        $html .= '</div><div style="clear:both; margin-bottom: 6px"></div>';
    }
    }
    return $html;
}

add_filter( 'the_champ_login_interface_filter', 'heateor_ss_custom_social_login_icons', 10, 3 );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM