• Resolved webdbapps

    (@webdbapps)


    I’m developing a theme using Angular that has modules for registration, moderation, sponsors and administration. I’m startimg to pencil out the server side plugin and need to create custom endpoints that will get and post data emitted by the theme.

    Should the custom endpoint functions be placed in my server side plugin and installed before installing and testing the theme?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    That would work, but may not be ideal. Are the endpoints used by the theme or the plugin, or both? Is the plugin required by the theme? If not, will endpoints fail if the other is not in place? To which module do the endpoints actually relate to?

    Themes generally should not be creating content, only styling the output. If data becomes unusable with a different theme, you have a poor schema that should be reevaluated. (unless this data is used solely for theme styling and is meaningless without the theme)

    Depending on the answers to these questions, how you go about structuring your code might change. I’m not looking for actual answers to my questions, they are meant to evoke thoughts towards formulating the best approach. Considering the answers, do what makes the most sense.

    Thread Starter webdbapps

    (@webdbapps)

    Thanks for your reply. Conceptually, my plan is to create an Angular theme that replaces the UI completely. In doing so, it can be styled the way we want it, and use the API endpoints to send data back to the database, in cases of updating static pages, adding registrants or updating registrant payment status. This would mean that a server side plugin is driving the custom endpoints to ensure the registrant data from the UI is stored in the database meta table.

    All that being said, it sounds like I need a server side plugin that creates the custom endpoints and allows the extended API to receive authenticated POST requests from the Angular theme in situations where a registrant is paying their membership, uploading their docuemts etc. The theme would be solely focused on serving the static content (pages), allowing users and admin to login, and providing the user experience based on the authentication permissions of the logged in user.

    Just want to make sure I’m going about this with best practices in mind, especially in this cross platform world where users will be browsing the site on tablets and phones more so than on desktop browsers.

    Moderator bcworkz

    (@bcworkz)

    Based on that added information, I’d say the answer to

    Should the custom endpoint functions be placed in my server side plugin and installed before installing and testing the theme?

    would be YES! ?? In reality though, you’ll probably be going back and forth, tuning the interaction on both ends.

    Sounds like an interesting, ambitious project. I wish you well with it.

    Thread Starter webdbapps

    (@webdbapps)

    I appreciate the advice and feedback. I’ve been a developer for over 2 decades but am fairly new to WordPress. Based on your suggestions, I’ve moved away from housing my Angular logic in a theme and instead leveraging Angular inside the plugin I’m creating.

    I’m surprised that Angular is not a full partner yet in the WordPress ecosystem. I’ve used it for years when developing custom content management platforms but it does not appear to be embraced yet in this use case.

    Thanks again for your help and guidance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Where to Add Custom REST API Endpoint Logic?’ is closed to new replies.