duanlu8613 2019-05-30 09:18
浏览 155

如何在twitter小部件中输入嵌入式Twitter帖子?

I'm creating a Twitter widget where you can enter HTML code from an embedded Twitter post. The problem is, when I enter the HTML code, the textfield in the widget at widget options changes the HTML code to normal text.

With the code below, it looks like this:

image of twitter post

class Twitter_Widget extends WP_Widget {
    // Class constructor
    public function __construct() {
        $widget_ops = array( 
            'classname' => 'twitter-plugin',
            'description' => 'This plugin will provide twitter widget',
        );
        parent::__construct( 'twitter', 'Twitter Widget', $widget_ops );
    }

    // Output the widget content on the front-end
    public function widget( $args, $instance ) {
        echo $args['before_widget'];
        if ( ! empty( $instance['title'] ) ) {
            echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
        }

        echo $instance['link'];

        echo $args['after_widget'];
    }

    // Output the option form field in admin Widgets screen
    public function form( $instance ) {
        ?>
            <label >Enter Link:</label>
            <input type="text" name="<?php echo $this->get_field_name('link'); ?>" value="<?php echo $instance["link"] ?>">

        <?php
    }

    // Save options
    public function update( $new_instance, $old_instance ) {
        $instance = array();
        $instance['link'] = strip_tags($new_instance['link']);

        return $instance;
    }

}

I expect it to be, for example, like this:

enter image description here

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 matlab图像高斯低通滤波
    • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
    • ¥15 钢筋实图交点识别,机器视觉代码
    • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
    • ¥50 400g qsfp 光模块iphy方案
    • ¥15 两块ADC0804用proteus仿真时,出现异常
    • ¥15 关于风控系统,如何去选择
    • ¥15 这款软件是什么?需要能满足我的需求
    • ¥15 SpringSecurityOauth2登陆前后request不一致
    • ¥15 禅道二次开发编辑版本,上传不了发行包