最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【未解决】如何用PHP编写一个wordpress的插件

WordPress crifan 1143浏览 0评论
折腾:
【记录】写同步有道云笔记中帖子的Wordpress插件
期间,需要去:
搞清楚,如何编写wordpress的插件
搞懂基本逻辑。
貌似是用php语言编写的。
wordpress 插件 编写
WordPress 插件教程:自己动手写 WordPress 插件
zh-cn:开发一个插件 « WordPress Codex
https://codex.wordpress.org/zh-cn:开发一个插件
起个名字:
ynote sync
有道云笔记同步到wordpress
如何开发一个WordPress插件 | WordPress大学
插件开发 · wordpress二次开发快速入门 · 看云
决定改名为:
youdaonote-sync
【整理】Wordpress插件中的readme.txt
Header Requirements | Plugin Developer Handbook | WordPress Developer Resources
Introduction to Plugin Development | Plugin Developer Handbook | WordPress Developer Resources
Determining Plugin and Content Directories « WordPress Codex
等后续插件写好了,再去参考:
Developer Information — WordPress Plugins
提交给wordpress官网。
官网插件示例:
Hello Dolly — WordPress Plugins
现在先不管:Text Domain和Domain Path
等后续有了多国语言再说。
再去参考:
Header Requirements | Plugin Developer Handbook | WordPress Developer Resources
PHPDoc – Wikipedia
在写了基本的代码后:
youdaonote-sync.php
<?php
/*
Plugin Name: Youdaonote Sync
Description: The youdao note synchronization to wordpress.
Version: 0.0.1
Author: Crifan Li
Text Domain: youdaonotesync
*/
/*
1. 该插件适用于同步有道云笔记;
2. 由于有道云笔记帖子中没有合适的分类和标签,所以目前是把“作者”作为“分类”,“来源”作为“标签”;
3. 大约每 30 分钟同步一次;
4. 同步内容包括分类、标签、标题、内容及其包含的图片;
*/
/*
Features:
1. The plugin applies for youdao note;
2. take “author” as “category”, “source” as “tag” due to youdao note post not contain category and tag;
3. About synchronization every 30 minutes;
4. Synchronous including categorie, tag, title, content and pictures contained;
*/
// require_once ‘src/autoload.php’;
// require_once ‘YoudaonoteSync.php’;
// require_once(ABSPATH . ‘wp-admin/includes/image.php’);
defined( ‘ABSPATH’ ) or die( ‘Can not direct run youdaonote-sync php code!’ );
// /**
// * Doesn’t work if PHP version is not 5.3.0 or higher
// */
// if (version_compare(phpversion(), ‘5.3.0’, ‘<‘)) {
// return;
// }
/**
* Loader class for the Youdaonote plugin
*/
class YoudaonoteSyncLoader
{
}
去wordpress后台插件中,就可以看到对应的插件了:
然后继续去写真正的代码。
几个hook:
register_activation_hook
TODO:
继续看:
https://developer.wordpress.org/plugins/the-basics/
和:
zh-cn:开发一个插件 « WordPress Codex
https://codex.wordpress.org/zh-cn:开发一个插件
在此期间,需要去尽量实现:
【已解决】Mac中如何实现实时调试wordpress中插件的php代码

转载请注明:在路上 » 【未解决】如何用PHP编写一个wordpress的插件

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.183 seconds, using 22.15MB memory