Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How is the Wordpress API exposed and how can I leverage it to extend my site? #141

Open
DeanLaw14 opened this issue Sep 19, 2023 · 1 comment

Comments

@DeanLaw14
Copy link

Hello Hello,

I've recently configured a wp app, so I'm still figuring a lot of this out but I'm looking to intercept requests from WP (perhaps via NETCore middleware), with the intention of applying some logic to the request payload before further sending it to a downstream API. Is something like this possible? If so is there a sample app or documentation you can point me to?

Apologies if this question isn't as focused as it could be, but any help/ideas would be much appreciated

@jakubmisek
Copy link
Collaborator

Hi,

I'm glad you're trying wp on .net!

To intercept (any) request on .NET, just add a request handler (middleware) before the WordPress middleware (i.e. before app.UseWordPress();) https://docs.peachpie.io/scenarios/wordpress/overview/#quick-start

To add WordPress hooks in C#, you can take advantage of the plugin API, like this one: https://github.com/iolevel/peachpie-wordpress/blob/master/app/Plugins/ShortcodePlugin.cs .

Then register it in app.UseWordPress(); (https://github.com/iolevel/peachpie-wordpress/blob/20e1c00f94d93467c1987ed48223b98a9e794a20/app/Program.cs#L40)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants