PluginProbe ʕ •ᴥ•ʔ
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress / 4.10.0
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress v4.10.0
4.12.0 4.10.0 4.9.0 4.8.1 trunk 1.0 1.1 1.12.1 1.2.3 1.2.4 1.2.5 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.5 1.5.1 1.5.2 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.5.1 1.6.6 1.6.6.1 1.6.6.2 1.6.6.3 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.9.0 1.9.1 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.8.1 1.9.9 1.9.9.1 1.9.9.2 1.9.9.3 2.0 2.0.1 2.1 2.1.1 2.1.2 2.1.3 2.10 2.11 2.11.1 2.12 2.12.1 2.12.2 2.12.3 2.12.4 2.13 2.14 2.14.1 2.15 2.15.1 2.16 2.16.1 2.17 2.17.1 2.18 2.18.1 2.18.2 2.18.3 2.19 2.19.1 2.19.2 2.19.3 2.2 2.2.1 2.3 2.3.1 2.3.10 2.3.2 2.3.3 2.3.4 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.1.1 2.4.1.2 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5 2.5.1 2.5.2 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.7 2.7.1 2.7.2 2.8 2.9 2.9.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.1 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.7.5 4.7.6 4.7.7
custom-facebook-feed / inc / UsageTracking / Core / Sender.php
custom-facebook-feed / inc / UsageTracking / Core Last commit date
PayloadBuilder.php 3 weeks ago RegisterSite.php 3 weeks ago Scheduler.php 3 weeks ago Sender.php 3 weeks ago
Sender.php
68 lines
1 <?php
2 /**
3 * Sends the usage report payload to the API.
4 *
5 * @package CustomFacebookFeed\UsageTracking\Core
6 * @since 4.0
7 */
8
9 namespace CustomFacebookFeed\UsageTracking\Core;
10
11 use CustomFacebookFeed\UsageTracking\Config;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 class Sender {
18
19 /**
20 * Send the usage report payload to the API.
21 * Skips send if payload exceeds max size to avoid timeouts; uses longer timeout for large bodies.
22 *
23 * @param array $payload Full JSON-serializable payload.
24 * @return bool True if request was sent successfully (2xx), false otherwise.
25 */
26 public function send( array $payload ) {
27 $url = Config::get_usage_report_url();
28 $body = wp_json_encode( $payload );
29 if ( false === $body ) {
30 return false;
31 }
32
33 $max_bytes = (int) apply_filters( 'cff_smash_usage_tracking_max_payload_bytes', Config::MAX_PAYLOAD_BYTES );
34 if ( $max_bytes > 0 && strlen( $body ) > $max_bytes ) {
35 if ( defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG && function_exists( 'error_log' ) ) {
36 error_log( '[CFF Usage Tracking] Payload size ' . strlen( $body ) . ' exceeds max ' . $max_bytes . ', send skipped.' );
37 }
38 return false;
39 }
40
41 $timeout = (int) apply_filters( 'cff_smash_usage_tracking_request_timeout', Config::REQUEST_TIMEOUT );
42 $timeout = max( 15, min( 120, $timeout ) );
43
44 $response = wp_remote_post(
45 $url,
46 array(
47 'method' => 'POST',
48 'timeout' => $timeout,
49 'redirection' => 5,
50 'httpversion' => '1.1',
51 'blocking' => true,
52 'headers' => array(
53 'Content-Type' => 'application/json',
54 ),
55 'body' => $body,
56 'user-agent' => 'CFF/' . (defined( 'CFFVER' ) ? CFFVER : '') . '; ' . get_bloginfo( 'url' ),
57 )
58 );
59
60 if ( is_wp_error( $response ) ) {
61 return false;
62 }
63
64 $code = wp_remote_retrieve_response_code( $response );
65 return $code >= 200 && $code < 300;
66 }
67 }
68