zoukankan      html  css  js  c++  java
  • Typecho 插件开发基础

    <?php
    
    /**
     * 标题 插件说明
     *
     * @package 添加标题
     * @author Fan
     * @version 1.0.0
     * @link http://cnblogs.com/fan-bk
     */
     
    class FanWorld_Plugin implements Typecho_Plugin_Interface{
        
        /* 激活插件方法 */
        public static function activate(){
            Typecho_Plugin::factory('admin/menu.php')->navBar = array('FanWorld_Plugin', 'render');  //先找到接口 详细情况看最后链接
        }
    
        /* 禁用插件方法 */
        public static function deactivate(){}
    
        /* 插件配置方法 */
        public static function config(Typecho_Widget_Helper_Form $form){
            /** 配置 */
            $name = new Typecho_Widget_Helper_Form_Element_Text('word', NULL, 'fan', _t('设置标题'));
            $href = new Typecho_Widget_Helper_Form_Element_Text('href', NULL, 'http://lindn.cn', _t('设置链接'));
            $form->addInput($name);
            $form->addInput($href);
        }
    
        /* 个人用户的配置方法 */
        public static function personalConfig(Typecho_Widget_Helper_Form $form){}
    
        /* 插件实现方法 */
        public static function render(){
          /*
    调用插件配置项的方式是:Options + 插件名(不带_Plugin) + 配置项名
          Typecho_Widget::widget('Widget_Options')->plugin('HelloWorld')->word
          当然,你也可以通过 Helper 助手来获取
          Helper::options()->plugin('HelloWorld')->word
          */
     
    echo '<a href="'.Typecho_Widget::widget('Widget_Options')->plugin('FanWorld')->href.'" class="author">' . Typecho_Widget::widget('Widget_Options')->plugin('FanWorld')->word . '</a>'; } }

    细节注意:

    插件  文件夹名 需要与类名相同  插件文件名必须是Plugin

    文件夹名:FanWorld

    文件名:Plugin.php

    类名: FanWorld_Plugin

    插件说明:

    • activate: 插件的激活接口,主要填写一些插件的初始化程序。
    • deactivate: 这个是插件的禁用接口,主要就是插件在禁用时对一些资源的释放。
    • config: 插件的配置面板,用于制作插件的标准配置菜单。
    • personalConfig: 个人用户的配置面板,基本用不到。
    • render: 自己定义的方法,用来实现插件要完成的功能。

    官方说明:https://www.typechodev.com/docs/zh_CN/typecho-extend/plugin/#-hello-world

  • 相关阅读:
    ReLu(Rectified Linear Units)激活函数
    转载 deep learning:八(SparseCoding稀疏编码)
    转载 Deep learning:一(基础知识_1)
    转载 Deep learning:二(linear regression练习)
    转载 Deep learning:三(Multivariance Linear Regression练习)
    转载 Deep learning:四(logistic regression练习)
    转载 Deep learning:五(regularized线性回归练习)
    转载 Deep learning:七(基础知识_2)
    转载 Deep learning:六(regularized logistic回归练习)
    Java环境的配置
  • 原文地址:https://www.cnblogs.com/fan-bk/p/8275927.html
Copyright © 2011-2022 走看看