PluginProbe ʕ •ᴥ•ʔ
Flex Import / 2.9
Flex Import v2.9
2.9 trunk 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8
flex-import / includes / flex-get-api.php
flex-import / includes Last commit date
class-template-importer.php 3 weeks ago flex-dashboard-post-api.php 3 weeks ago flex-get-api.php 3 weeks ago flex-get-templates-api.php 3 weeks ago fleximp-license-functions.php 3 weeks ago
flex-get-api.php
60 lines
1 <?php
2 // fetch-plugins-api.php
3
4 require_once '../../../../wp-load.php';
5
6 header('Content-Type: application/json');
7
8 if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
9 echo json_encode(['error' => 'Invalid request method']);
10 exit;
11 }
12
13 $postData = json_decode(file_get_contents('php://input'), true);
14
15 $action = $postData['action'] ?? 'getPlugins'; // Default action is to get plugins
16 $url = '';
17
18 switch ($action) {
19 case 'getPlugins':
20 $url = FLEXIMP_JSON_DATA_URL . 'flex_theme_get_plugins_list_to_download';
21 $data = [];
22 break;
23
24 default:
25 echo json_encode(['error' => 'Invalid action']);
26 exit;
27 }
28
29 $args = [
30 'method' => 'GET',
31 'headers' => [
32 'Content-Type' => 'application/json',
33 ]
34 ];
35
36 $response = wp_remote_get($url, $args);
37
38 if (is_wp_error($response)) {
39 echo json_encode(['error' => 'Request failed: ' . $response->get_error_message()]);
40 exit;
41 }
42
43 $http_code = wp_remote_retrieve_response_code($response);
44 if ($http_code !== 200) {
45 echo json_encode(['error' => 'HTTP error: ' . $http_code]);
46 exit;
47 }
48
49 $response_body = wp_remote_retrieve_body($response);
50 $data = json_decode($response_body, true);
51
52
53
54 if (json_last_error() !== JSON_ERROR_NONE) {
55 echo json_encode(['error' => 'Invalid JSON format received from the external API']);
56 exit;
57 }
58
59 echo json_encode($data);
60 ?>