PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.85
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.85
5.5.85 5.5.84 5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 All 161 releases
← All changes | WPDataAccess/Utilities/WPDA_Remote_Call.php +52 -8 5.5.36 → 5.5.85 View file →
@@ -5,19 +5,29 @@
5 5 use WPDataAccess\WPDA;
6 6
7 7 class WPDA_Remote_Call {
8 8
9 - public static function post( $url, $body, $die = false, $headers = array() ) {
9 + public static function post(
10 + $url,
11 + $body,
12 + $die = false,
13 + $headers = array(),
14 + $sslverify = true
15 + ) {
10 16 $response = wp_remote_post(
11 17 $url,
12 18 array(
13 - 'headers' => $headers,
14 - 'body' => $body,
15 - 'timeout' => 60,
19 + 'headers' => $headers,
20 + 'body' => $body,
21 + 'timeout' => 60,
22 + 'sslverify' => $sslverify,
16 23 )
17 24 );
18 - // var_dump($response);
19 25
26 + if ( 'on' === WPDA::get_option( WPDA::OPTION_PLUGIN_DEBUG ) ) {
27 + // WPDA::wpda_log_wp_error( $response );
28 + }
29 +
20 30 if ( is_wp_error( $response ) ) {
21 31 WPDA::wpda_log_wp_error( json_encode( $response ) );
22 32 if ( $die ) {
23 33 wp_die( 'ERROR: Remote call failed [' . json_encode( $response ) . ']' );
@@ -39,11 +49,14 @@
39 49 }
40 50
41 51 public static function get( $url, $args = array(), $die = false ) {
42 52 $response = wp_remote_get( $url, $args );
43 - // var_dump($response);
44 53
45 - if ( is_wp_error( $response ) ) {
54 + if ( 'on' === WPDA::get_option( WPDA::OPTION_PLUGIN_DEBUG ) ) {
55 + // WPDA::wpda_log_wp_error( $response );
56 + }
57 +
58 + if ( is_wp_error( $response ) ) {
46 59 WPDA::wpda_log_wp_error( json_encode( $response ) );
47 60 if ( $die ) {
48 61 wp_die( 'ERROR: Remote call failed [' . json_encode( $response ) . ']' );
49 62 }
@@ -62,9 +75,40 @@
62 75
63 76 return $response;
64 77 }
65 78
66 - public static function max_size() {
79 + public static function delete( $url, $args = array(), $headers = array(), $die = false ) {
80 + $response = wp_remote_request(
81 + $url,
82 + array(
83 + 'method' => 'DELETE',
84 + 'headers' => $headers,
85 + )
86 + );
87 +
88 + if ( 'on' === WPDA::get_option( WPDA::OPTION_PLUGIN_DEBUG ) ) {
89 + // WPDA::wpda_log_wp_error( $response );
90 + }
91 +
92 + if ( is_wp_error( $response ) ) {
93 + WPDA::wpda_log_wp_error( json_encode( $response ) );
94 + if ( $die ) {
95 + wp_die( 'ERROR: Remote DELETE failed [' . json_encode( $response ) . ']' );
96 + }
97 +
98 + return false;
99 + }
100 +
101 + $status_code = wp_remote_retrieve_response_code( $response );
102 + if ( $status_code === 204 ) {
103 + return true;
104 + }
105 +
106 + WPDA::wpda_log_wp_error("ERROR: Delete failed: HTTP $status_code");
107 + return false;
108 + }
109 +
110 + public static function max_size() {
67 111 $max = ini_get('post_max_size');
68 112 $unit = $max[ strlen( $max ) - 1 ];
69 113 $max = substr( $max, 0, strlen( $max ) - 1 );
70 114