| 1 |
type ContentEmbedInfoResponse = { |
| 2 |
success: boolean; |
| 3 |
data?: { |
| 4 |
// Empty if user doesn't have permissions or plugin already activated |
| 5 |
activateAjaxUrl?: string; |
| 6 |
message: string; |
| 7 |
}; |
| 8 |
}; |
| 9 |
|
| 10 |
export function startInstall(nonce: string) { |
| 11 |
const formData = new FormData(); |
| 12 |
const ajaxUrl = (window as any).ajaxurl; |
| 13 |
formData.append('_wpnonce', nonce); |
| 14 |
formData.append('action', 'content_embed_install'); |
| 15 |
return fetch(ajaxUrl, { |
| 16 |
method: 'POST', |
| 17 |
body: formData, |
| 18 |
keepalive: true, |
| 19 |
}).then<ContentEmbedInfoResponse>(res => res.json()); |
| 20 |
} |
| 21 |
|
| 22 |
export function startActivation(requestUrl: string) { |
| 23 |
return fetch(requestUrl, { |
| 24 |
method: 'POST', |
| 25 |
keepalive: true, |
| 26 |
}).then<ContentEmbedInfoResponse>(res => res.json()); |
| 27 |
} |
| 28 |
|