doumengyin0491 2018-12-14 16:37
浏览 49

需要帮助编辑WordPress插件以动态显示用户社交媒体图标

I'm editing a WordPress plugin named UsersWP. It's a plugin for users to create profiles and post content on the website. The plugin has some input form fields that I can drag and drop so that users can insert information and upload files.

The only problem is that it does not have input fields for users to enter their social media profile account links. The only way I can do that is by using a URL input field and give it a Font Awesome icon specific to that field from the Admin panel. But this method also returns the url string next to the icon on the front end. I don't want it to do that.

What I want is for the user to enter a link to their social media profile, insert that link into an anchor tag and return that as a clickable icon on the front end. The problem now is that I don't know how to return icon.

The script is below is from a different file named class-profile.php:

// URL
    if ($field->field_type == 'url' && !empty($value)) {
        $link_text = $value;
        // if deafult_value is not url then it will be used as link text. 
        if ($field->default_value && !empty($field->default_value) ) {
            if (substr( $field->default_value, 0, 4 ) === "http") {
                $link_text = $value;
            } else {
                $link_text = $field->default_value;
            }
        }
        if (substr( $link_text, 0, 4 ) === "http") {
            $link_text = esc_url($link_text);
        }

        $value = '<a href="'.$value.'">' . '<i class="uwp_field_icon ' . uwp_get_field_icon( $value ) . '"></i>' . '</a>';
    }

This one is from a file named fields.php:

function uwp_get_field_icon( $icon_value ) {
$field_icon = $icon_value;

if ( ! empty( $icon_value ) ) {
    if ( strpos( $icon_value, 'http' ) === 0 ) {
        $field_icon = ' '. $icon_value .' <span class="uwp_field_icon" style="background: url(' . $icon_value . ') no-repeat left center;padding-left:14px;background-size:100% auto;margin-right:5px"></span>';
    } else if ( strpos($icon_value, ' fa-') !== false ) {
        $field_icon = '<i class="uwp_field_icon ' . $icon_value . '"></i>';
    }
}

return apply_filters( 'uwp_get_field_icon', $field_icon, $icon_value );

}

And this is how it comes out in HTML form. 1

This should return an icon. How can I insert the Font Awesome icon class inside the i tag?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 目详情-五一模拟赛详情页
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line