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

[Feature] Simple walk throughs for building a theme and a plugin in C# #84

Open
by-theo opened this issue Sep 17, 2020 · 6 comments
Open
Labels
enhancement New feature or request

Comments

@by-theo
Copy link

by-theo commented Sep 17, 2020

Description
Just looking for a simple guide to start building in C#, willing to assist with putting together the walk through but will need your assistance.

@by-theo by-theo added the enhancement New feature or request label Sep 17, 2020
@jakubmisek
Copy link
Collaborator

Thats a good idea, we should definitely provide documentation on C# plugins.

For now, we have a sample plugin at https://github.com/iolevel/peachpie-wordpress/tree/master/app/Plugins or at

sealed class Provider : IWpPluginProvider

@by-theo
Copy link
Author

by-theo commented Sep 18, 2020

Awesome.

I tested the sample yesterday and was able to get the ShortcodePlugin to work, however I could not get it to be displayed in the list of installed plugins.

In PHP we usually set some info

/*
Plugin Name: My Plugin
Plugin URI:
Description:
Version: 0.0.1
Author: Theo Taylor | TAYLOR'D Technologies
Author URI: http://taylord.tech/
License:
*/

Not so sure how to get that done in C#, I am working through the examples tho so whatever I figure out I can post.

Another good set of snippets would be simple filters and actions

@by-theo
Copy link
Author

by-theo commented Sep 18, 2020

Here is an example of a plugin that changes all of the post titles

using PeachPied.WordPress.Standard;

namespace WPTest.Plugins
{
    class CustomTitlePlugin : IWpPlugin
    {
        public void Configure(WpApp app)
        {
            app.AddFilter("the_title", new CustomTitle(() => "This is a custom title"));
        }
        private delegate string CustomTitle();
    }
}

@jakubmisek
Copy link
Collaborator

jakubmisek commented Sep 22, 2020

@Theo-Taylor nice! we'll be working on a C# plugin doc soon.

btw there is predefined FilterTitle helper method, so you can write:

public void Configure(WpApp app) {
        app.FilterTitle((title, postid) => "This is a custom title"));
}

We're aware that the plugin is not listed in WP dashboard. It is because the plugin is loaded statically, as a must-use plugin.

@by-theo
Copy link
Author

by-theo commented Sep 22, 2020

@jakubmisek awesome! Really looking forward to it

To the plugin not being listing - Ah gotcha, at first I was confused cause I didn't know if the plugin was working since it isn't listed but I understand

Keep us posted on the docs! I'm thinking about doing a tutorial series on wpdotnet development, completely in C# and including things like the WP REST API. Since .NET Core has React and Angular support I think this will be a new and fantastic way to build and deploy websites

@XeonG
Copy link

XeonG commented May 1, 2021

"Keep us posted on the docs! I'm thinking about doing a tutorial series on wpdotnet development, completely in C# and including things like the WP REST API. Since .NET Core has React and Angular support I think this will be a new and fantastic way to build and deploy websites"

Did you ever do that?.. would be super interested in using .Net Core with WP with a frontend in React,

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

No branches or pull requests

3 participants