从零开始,开发WORDPRESS插件

开发教程

官方详细信息:查看

参考:Wordpress大学-插件开发教程

我要开发的是一款能在文本编辑器中添加按钮的插件,取名为:Magic Button

我谷歌了一下并在Wordpress后台查找次名字,没有重名。

我在桌面新建文件夹,取名Magic Button,

目录结构:

  • /Magic Button — 唯一的插件名称,不要包含空格或者特殊字符
  • Magic Button.php — 唯一的插件名称,插件主文件
  • uninstall.php — 插件的卸载文件
  • /js — JavaScript 文件
  • /css — css 样式表
  • /images — 图片
  • /includes — 存放要包含的 PHP 文件

在Magic Button.php里面写入:标准插件信息

<?php
/*
Plugin Name: 插件名称
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
Description: 插件的简单描述
Version: 插件版本号, 例如: 1.0
Author: 插件作者
Author URI: http://URI_Of_The_Plugin_Author作者地址
*/
?>

标准信息头至少要包括插件名称,这样WordPress才能识别你的插件。其他信息将显示在控制面板插件管理页面中。标准插件信息对各行顺序没有要求。

版权信息 :写入GPL版权信息

<?php
/*  Copyright 年份  作者名  (email : 你的邮箱)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
?>

GPL许可具有“传染性”,我非常喜欢。

此时,插件已经可以使用了,将Magic Button.php文件放入wp-content/plugin目录,即可使用。

WordPress代码编辑标准:查看

WordPress 技巧:如何在后台显示日志 ID

2019-10-1 0:00:32

投稿

Wordpress优化

2018-10-18 22:28:22

⚠️
Npcink上的部份代码及教程来源于互联网,仅供网友学习交流,若您喜欢本文可附上原文链接随意转载。
无意侵害您的权益,请发送邮件至 1355471563#qq.com 或点击右侧 私信:Muze 反馈,我们将尽快处理。
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索