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

标签 wordpress plugins filter

我正在使用一个名为 Super Socializer 的插件它允许用户使用 Twitter 和 Facebook 登录。我想用 HTML 文本替换社交登录图标。我是 WordPress 中使用过滤器的新手,这种方法对我来说是新的。

该插件包含允许我添加过滤器的代码:

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

我用文本更改图标的方法是在functions.php中执行此操作:

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

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

这个问题是我不知道从这里去哪里。如何获取包含图标的变量并将其更改为文本?任何帮助将不胜感激,谢谢!

最佳答案

该插件的制造商很快就给出了解决方案,因此我将其发布在这里供其他需要它的人使用。在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 );

关于wordpress - 为 Super Socializer 社交登录添加过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41784597/

相关文章:

Tomcat CORS 过滤器 : Why is the default list of headers in "Access-Control-Allow-Headers" so arbitrarily limited?

r - 数据表 DT[i, j, by] 不使用 i 中的条件选择组,试图过滤组内唯一值的数量

php - 需要在文件夹中找到的所有 block (而不是将它们全部写出)

javascript - 如何在子主题中覆盖联系表单7 js文件

php - 按标题和元搜索查询参数

php - 插件在激活期间生成了意外输出的 xxx 个字符

visual-studio-code - 在 Visual Studio Code 之上开发应用程序

ElasticSearch 加入过滤器 : Using subquery results as filter input possible?

rest - 使用 Photoshop 脚本上传图像

Eclipse:如何确保插件中的jar优先于其他地方的其他版本?