WordPress running on .NET Core.
Перейти к файлу
Jakub Míšek 41eb0863c2 update and cleanup, added response compression 2018-12-10 16:04:04 +01:00
.vscode app uses wpdotnet-sdk 2018-07-03 23:10:43 +02:00
PeachPied.WordPress.MyPlugin bump wp 5.0 2018-12-10 14:27:35 +01:00
app update and cleanup, added response compression 2018-12-10 16:04:04 +01:00
.gitignore Create .gitignore 2017-02-11 16:42:39 +01:00
LICENSE.md Create LICENSE.md 2018-11-27 19:17:11 +01:00
NuGet.Config bump 1.0.0-CI00064 2018-11-25 17:23:06 +01:00
README.MD bump wp 5.0 2018-12-10 14:27:35 +01:00
peachpie-wordpress.sln razor partial view rendered in wordpress dashboard widget 2018-07-20 22:07:05 +02:00

README.MD

This project demonstrates how to start an ASP.NET Core server, integrate WordPress into its pipeline and add additional PHP plugins into it.

WordPress

Even though the project is noticeably small, it contains the entire WordPress CMS. How? This complex PHP web framework was already compiled into the .NET Standard library (see wpdotnet-sdk for more information) and packed into a NuGet package. This demo may just reference it.

To find out more about PeachPie, check out our resources, which includes tutorials, benchmarks and articles on PeachPie.

WordPress PHP Plugin

With this approach it is finally possible to have a project containing only the plugin. WordPress itself is already compiled and the plugin has a dependency on it (like any other C# app you would make).

The build process will do following:

  • compiles .php files within the PeachPied.WordPress.MyPlugin directory. Note that the path wp-content/plugins matters.
  • packs the compiled DLL together with content files (like images, scripts etc.) into a NuGet package.
  • copies the project content into the application output directory, together with WordPress content files extracted from its NuGet.

WordPress C# plugin

The project takes advantage of the WpDotNet SDK which provides a C# abstraction IWpPlugin. Objects of this type can be passed to the WordPress middleware (see UseWordPress) and hook onto filters and actions available in the WordPress API.

Configuration

The configuration itself serves as a demonstration of combining a legacy PHP application with .NET. The demo takes advantage of the ASP.NET Core configuration mechanism, namely the files appsettings.json, appsettings.deployment.json and appsettings.production.json. This allows for having a different configuration for each environment without the need of altering the source code of the project.

Sourceless Distribution

The WordPress package was already configured, so the original PHP source code is not a part of the NuGet nor of the compiled DLL. In case of additional plugins (see PeachPied.WordPress.MyPlugin), it depends what source files are needed in run time. Usually only the main plugin file (containing the WordPress metadata) has to be distributed together with the DLL, so that WordPress can read its content and work properly. The other files can be excluded from the package.

As a result, this project serves as a demonstration of:

  • distributing the WordPress plugin without its source codes
  • build and maintain plugins separately as separate NuGet packages
  • maintaining/providing plugins with a dependency on a certain WordPress version
  • signing the plugin with a private key
  • possibly obfuscating the DLL