rest api – how to update a plugin from external website?

Question

I’m using the rest API from wordpress, And I want to trigger a plugin update, is this possible?

This is my code for listings the plugins, I can retrieve the custom version, but I can’t find the latest version.

const config = {
  headers: {
    "Content-Type": "application/json",
    Authorization: `Basic ${token}`,
  },
};

async function getPluginList() {
  const response = await axios.get(pluginsUrl, config);
  return response.data;
}

getPluginList()
  .then((data) => {
    data.forEach((element) => {
      console.log("Plugin name: ", element.name);
      console.log("status: ", element.status);
      console.log("current Version: ", element.version);
      console.log("Textdomain: ", element.textdomain);
      console.log("Links: ", element._links);
    });
  })
  .catch((error) => {
    console.error(error);
  });

0
Fede 1 year 2023-02-25T21:11:44-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse