• I would like to use the WordPress API to submit a plugin or theme. I will send the ZIP file and WordPress should give me the option to activate it after installation or not. All this through wp-JSON and programmatically.

    How could I do this?

    • This topic was modified 4 years, 4 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter remiCs

    (@emersong20)

    PS: I can’t use wp-cli because I can’t require my customers has SSH access to install in your web hosting provider.

    Dion

    (@diondesigns)

    The WordPress REST API reference may be of some help:

    https://developer.wordpress.org/rest-api/reference/plugins/

    Thread Starter remiCs

    (@emersong20)

    I didn’t find any endpoint available that allows me send a zip archive to upload a plugin

    Dion

    (@diondesigns)

    Are you aware that using the REST API for administrative tasks requires an authorization header containing the site owner’s WP username/password? Asking customers to provide these credentials to you is not in their best interest.

    Also keep in mind that you have no idea whether a customer site has filesystem restrictions that prohibit non-media HTTP file uploads. WordPress has some built-in ways to get around the restrictions, but they are interactive and therefore not available in the REST API.

    If the code you desire is meant to run on the customer’s site, give some thought to writing a custom plugin that handles these tasks. A number of (mainly older) themes in the repository here contain code that is fairly close to what you would need in such a custom plugin.

    Thread Starter remiCs

    (@emersong20)

    Are you aware that using the REST API for administrative tasks requires an authorization header containing the site owner’s WP username/password? Asking customers to provide these credentials to you is not in their best interest.

    As far as I know, you can create an “application secret” that does not require the customer to share your user and password.

    If the code you desire is meant to run on the customer’s site, give some thought to writing a custom plugin that handles these tasks.

    Sorry, I can’t develop a WordPress plugin because at the end of the day I need to have an API to integrate with an external system. Maybe I could develop a plugin that creates a new wp-json endpoint in WP REST API:

    POST /wp/v2/plugins/upload

    Do you have any idea how could I start?

    Dion

    (@diondesigns)

    This should be of some assistance for creating a custom endpoint:

    https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘How could I install a plugin or theme programatically?’ is closed to new replies.