PluginProbe
SureMail – SMTP and Email Logs Plugin with Amazon SES, Postmark, and Other Providers / 2.0.0
SureMail – SMTP and Email Logs Plugin with Amazon SES, Postmark, and Other Providers v2.0.0
2.0.2 2.0.1 2.0.0 1.9.5 trunk 0.0.4 0.0.5 0.0.6 1.0.0 1.0.1 1.1.0 1.2.0 1.3.0 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.6.2 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 All 31 releases
suremails / src / api / plugins.js

plugins.js in SureMail – SMTP and Email Logs Plugin with Amazon SES, Postmark, and Other Providers 2.0.0, at src/api/plugins.js

42 lines 930 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // @api/plugins.js
2 import apiFetch from '@wordpress/api-fetch';
3 import { __ } from '@wordpress/i18n';
4
5 /**
6 * Fetches the list of installed and active plugins.
7 *
8 * @return {Promise<Object>} The object containing installed and active plugins.
9 */
10 export const fetchInstalledPluginsData = async () => {
11 try {
12 const response = await apiFetch( {
13 path: '/suremails/v1/installed-plugins',
14 method: 'GET',
15 headers: {
16 'Content-Type': 'application/json',
17 'X-WP-Nonce': suremails.nonce,
18 },
19 } );
20
21 if (
22 response?.success &&
23 response?.plugins?.installed &&
24 response?.plugins?.active
25 ) {
26 return {
27 installed: response.plugins.installed,
28 active: response.plugins.active,
29 };
30 }
31
32 throw new Error(
33 __( 'Invalid data received from server.', 'suremails' )
34 );
35 } catch ( error ) {
36 throw new Error(
37 error.message ||
38 __( 'Failed to fetch installed plugins.', 'suremails' )
39 );
40 }
41 };
42