承接 gregrickaby/nextjs-wordpress-plugin 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gregrickaby/nextjs-wordpress-plugin

最新稳定版本:1.0.6

Composer 安装命令:

composer require gregrickaby/nextjs-wordpress-plugin

包简介

A plugin to help turn WordPress into a headless CMS.

README 文档

README

A plugin to help configure WordPress for use as a headless CMS.

This plugin is a companion to the Next.js WordPress Theme and is intended to be used within the Next.js WordPress project.

Download

There are a few ways to aquire this plugin:

1) Composer

This is the preferred method of installation.

composer require gregrickaby/nextjs-wordpress-plugin

2) WP CLI

wp plugin install https://github.com/gregrickaby/nextjs-wordpress-plugin/archive/refs/heads/main.zip --activate

3) Download

Download the latest release (.zip) and upload it like any other WordPress plugin.

Activate

Once installed, activate the plugin.

Configuration

There's no configuration necessary. For additional project configuration, please see the instructions in the Next.js WordPress repository.

Revalidation

If your Custom Post Types and front-end routes differ from this plugin, you'll need to edit src/classes/Revalidation.php to match your project.

⚠️ Editing a plugin directly means you'll need to re-apply your changes after a plugin update occurs. If you do need to customize, consider forking this plugin and making your changes there.

// src/classes/Revalidation.php

/**
 * Configure the $slug based on your post types and front-end routing.
 */
switch ( $post_type ) {
 case 'post': // post type
  $slug = "/blog/{$post_name}"; // front-end route
  break;
 case 'book': // book post type
  $slug = "/books/{$post_name}"; // front-end route
  break;
 default:
  $slug = $post_name;
  break;
}

Preview Link

To change the preview links, edit src/classes/Links.php.

// src/classes/Links.php

 public function set_headless_preview_link( string $link, WP_Post $post ): string {

  // Return the original link if the frontend URL or preview secret are not defined.
  if ( ! $this->frontend_url || ! $this->preview_secret ) {
   return $link;
  }

  // Update the preview link to point to the front-end.
  return add_query_arg(
   [ 'secret' => $this->preview_secret ],
   esc_url_raw( "{$this->frontend_url}/preview/{$post->ID}" ) // <-- edit this to match your front-end routing!
  );
 }

Support

If you find something wrong, please open an issue. I will do my best to respond in a timely manner.

License

This plugin is licensed under the MIT License.

统计信息

  • 总下载量: 1.88k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固