WordPress GitHub Sync 项目教程

WordPress GitHub Sync 项目教程

wordpress-github-syncA WordPress plugin to sync content with a GitHub repository (or Jekyll site)项目地址:https://gitcode.com/gh_mirrors/wo/wordpress-github-sync

1. 项目的目录结构及介绍

WordPress GitHub Sync 项目的目录结构如下:

wordpress-github-sync/
├── admin/
│   ├── css/
│   ├── js/
│   └── views/
├── includes/
│   ├── api/
│   ├── classes/
│   ├── compatibility/
│   └── functions/
├── languages/
├── vendor/
├── wp-github-sync.php
└── readme.txt

目录介绍:

  • admin/: 包含插件的后台管理界面所需的CSS、JavaScript和视图文件。
  • includes/: 包含插件的核心功能,如API接口、类定义、兼容性处理和功能函数。
  • languages/: 包含插件的本地化语言文件。
  • vendor/: 包含第三方依赖库。
  • wp-github-sync.php: 插件的主文件,包含插件的基本信息和初始化代码。
  • readme.txt: 插件的说明文档。

2. 项目的启动文件介绍

项目的启动文件是 wp-github-sync.php。这个文件包含了插件的基本信息和初始化代码。以下是文件的部分内容:

<?php
/*
Plugin Name: WordPress GitHub Sync
Plugin URI: https://github.com/mAAdhaTTah/wordpress-github-sync
Description: A WordPress plugin to sync content with a GitHub repository (or Jekyll site).
Version: 2.0.1
Author: James DiGioia, Ben Balter
Author URI: https://github.com/mAAdhaTTah
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/

// 引入必要的文件
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/includes/functions/core.php';

// 初始化插件
add_action('plugins_loaded', function () {
    WordPress_GitHub_Sync::instance();
});

启动文件功能:

  • 定义插件的基本信息,如名称、版本、作者等。
  • 引入必要的依赖文件和核心功能文件。
  • 通过 plugins_loaded 钩子初始化插件。

3. 项目的配置文件介绍

项目的配置文件主要涉及插件的后台设置页面和GitHub的Webhook设置。

后台设置页面:

在 WordPress 后台,进入 设置 -> GitHub Sync 页面,可以进行以下配置:

  • GitHub Repository: 输入要同步的GitHub仓库地址。
  • GitHub Token: 输入GitHub的个人访问令牌,用于授权插件访问GitHub仓库。
  • Webhook URL: 显示用于GitHub的Webhook URL,用于触发内容同步。

GitHub Webhook 设置:

在GitHub仓库的 Settings -> Webhooks 页面,添加一个新的Webhook,配置如下:

  • Payload URL: 使用插件提供的Webhook URL。
  • Content Type: 选择 application/json
  • Secret: 留空或根据需要设置。
  • Events: 选择 Just the push event

通过这些配置,插件可以实现WordPress内容与GitHub仓库的双向同步。

wordpress-github-syncA WordPress plugin to sync content with a GitHub repository (or Jekyll site)项目地址:https://gitcode.com/gh_mirrors/wo/wordpress-github-sync

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

樊慈宜Diane

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值