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 +48 -7 5.5.41 → 5.5.85 View file →
@@ -5,15 +5,22 @@
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 25
19 26 if ( 'on' === WPDA::get_option( WPDA::OPTION_PLUGIN_DEBUG ) ) {
@@ -42,11 +49,14 @@
42 49 }
43 50
44 51 public static function get( $url, $args = array(), $die = false ) {
45 52 $response = wp_remote_get( $url, $args );
46 - // var_dump($response);
47 53
48 - 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 ) ) {
49 59 WPDA::wpda_log_wp_error( json_encode( $response ) );
50 60 if ( $die ) {
51 61 wp_die( 'ERROR: Remote call failed [' . json_encode( $response ) . ']' );
52 62 }
@@ -65,9 +75,40 @@
65 75
66 76 return $response;
67 77 }
68 78
69 - 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() {
70 111 $max = ini_get('post_max_size');
71 112 $unit = $max[ strlen( $max ) - 1 ];
72 113 $max = substr( $max, 0, strlen( $max ) - 1 );
73 114