WordPress 主题/插件/小工具开发教学笔记

这个帖子主要是记录一些我觉得很常用的WordPress 主题/插件/小工具开发教学。

官方教学:

https://developer.wordpress.org/

插件开发教学:

https://www.wpzhiku.com/document/plugins-security/

主题开发教学:

https://www.wpzhiku.com/handbook/theme/

小工具开发教学:

https://www.easywpbook.com/plugin/create-widget.html

文件结构:

https://www.easywpbook.com/theme/struct.html

后台框架:CodeStarFramework(CSF)

https://codestarframework.com/documentation/#/

常用函数查询:

https://www.wpdongli.com/reference/functions/

常用钩子查询:

https://www.wpdongli.com/reference/hooks/

插件说明:

/* 
Plugin Name: 更好用的弹窗
Plugin URI: https://mgcx.top/2001
Description: 更好用更优美的弹窗:美化弹窗一键配置,全程可视化、傻瓜式操作
Version: 0.0.3
Requires at least: 3.1
Requires PHP: 5.6
Author: JuanYi
Author URI: https://mgcx.top
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: better-popup
*/ 

主题说明:

/*
 * @Author        : Qinver
 * @Url           : zibll.com
 * @Date          : 2020-09-29 13:18:36
 * @LastEditTime: 2022-12-07 00:54:33
 * @Email         : 770349780@qq.com
 * @Project       : Zibll子比主题
 * @Description   : 一款极其优雅的Wordpress主题
 * @Read me       : 感谢您使用子比主题,主题源码有详细的注释,支持二次开发。
 * @Remind        : 使用盗版主题会存在各种未知风险。支持正版,从我做起!
 */

每个php头部加这个防止直接访问:

if (!defined('ABSPATH')) exit;

引入路径:

require_once(dirname( __FILE__ ) .'/inc/functions.php');
require_once plugin_dir_path( __FILE__ ) .'classes/setup.class.php';

小工具框架:

<?php 
class juanyi_demo extends WP_Widget {

    public function __construct() {
        $widget_ops = array( 
            'classname' => 'juanyi_demo',
            'description' => '小工具名称',
        );
        parent::__construct( 'juanyi_demo', '小工具名称', $widget_ops );
    }
    public function widget($args,$instance){
        $title = !empty($instance['title']) ? $instance['title'] : "沐光橙香";
    }
    
    public function form( $instance ) {
        $title = !empty($instance['title']) ? $instance['title'] : "沐光橙香";
    
        ?>
        <p>
            <label >沐光橙香</label> 
            <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
        </p>
        <?php 
    }

}

function widgets_init(){
    register_widget("juanyi_demo");
}
add_action('widgets_init','widgets_init');
温馨提示: 本文最后更新于2024-02-05 20:28:19,某些文章具有时效性,若有错误或已失效,请在下方 留言或联系 沐橙论坛
© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容