简体   繁体   English

为Super Socializer社交登录添加过滤器

[英]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. 我正在使用一个名为Super Socializer的插件,该插件允许用户使用Twitter和Facebook登录。 I would like to replace the social login icons with HTML text. 我想用HTML文本替换社交登录图标。 I'm new to working with filters in WordPress and this approach is new to me. 我是使用WordPress中的过滤器的新手,这种方法对我来说是新的。

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: 我用文本更改图标的方法是在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. 在functions.php中,只需创建一个函数,然后应用您的更改,然后添加一个过滤器。

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 );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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