wordpress 天气插件开发

<?php
/*
 * author by:wordpress教程网(http://www.wpnoob.cn)
 * url:
 *
 */
class weatherWidget extends WP_Widget {
    /*
     * 参数:
     * $widget_ops -- 用来保存类名和描述,以便在主题控制面板正确显示小工具信息
     * $control_ops -- 是可选参数,用来定义小工具在控制面板显示的宽度和高度
     * 最后是关键的一步,调用WP_Widget来初始化我们的小工具
     **/
    function weatherWidget(){
        $widget_ops = array('classname'=>'site_weather','description'=>'天气');
        $control_ops = array('width'=>250,'height'=>300);
        $this->WP_Widget(false, '天气', $widget_ops, $control_ops);
    }
    
    
    function form($instance){
        //title:标题,text:内容
        $text = "<div class='widget '><iframe name='weather_inc' src='http://i.tianqi.com/index.php?c=code&id=55'  width='255' height='294' frameborder='0' marginwidth='0' marginheight='0' scrolling='no'></iframe></div>";
        echo '<p style="text-align:left;"><label for="'.$this->get_field_name('text').'"><div style="width:200px;" id="'.$this->get_field_id('text').'" name="'.$this->get_field_name('text').'" type="text"  /> ' . $text . '</div></label></p>';
    }
    
    
    
    function widget($args, $instance){
        $text = "<div class='widget '><iframe name='weather_inc' src='http://i.tianqi.com/index.php?c=code&id=55'  width='255' height='294' frameborder='0' marginwidth='0' marginheight='0' scrolling='no'></iframe></div>";
        if( $text )  echo $text;        
    }
    
    
}

?>

 

转载于:https://www.cnblogs.com/hellowzd/p/5593161.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值