Wordpress小部件开发 - 打开时宽度增加

时间:2011-12-25 14:18:17

标签: widget width wordpress-plugin wordpress

在Wordpress小部件页面上,您可以看到当您在侧边栏中单击/切换它们时,某些小部件的宽度会增加。我怎么能用我自己的小部件做到这一点?我正在使用WP_Widget类。

谢谢!

1 个答案:

答案 0 :(得分:1)

注册窗口小部件时,您可以设置窗口小部件控件选项,以便控制宽度。

检查以下示例代码:

<?php
class WP_Widget_Text_Link extends WP_Widget {

    function WP_Widget_Text_Link() {
        $widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML with Title linked'));
        $control_ops = array('width' => 600, 'height' => 350);
        $this->WP_Widget('textlink', __('Text with Link'), $widget_ops, $control_ops);
    }

    // stripped down remaining code for the widget, which are not needed for the answer.
}