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 / Config.php
custom-facebook-feed / inc / UsageTracking Last commit date
Core 3 weeks ago Facebook 3 weeks ago Config.php 3 weeks ago EventRecorder.php 3 weeks ago ReporterInterface.php 3 weeks ago SmashUsageTracking.php 3 weeks ago
Config.php
118 lines
1 <?php
2 /**
3 * Smash Usage Tracking configuration.
4 *
5 * API URL and option names. Reusable across plugins.
6 *
7 * @package CustomFacebookFeed\UsageTracking
8 * @since 4.0
9 */
10
11 namespace CustomFacebookFeed\UsageTracking;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 class Config {
18
19 /**
20 * Option key: enabled flag and last_send timestamp.
21 * Reuses the legacy usage-tracking option so existing consent carries over.
22 */
23 const OPTION_TRACKING = 'cff_usage_tracking';
24
25 /**
26 * Default enabled state when the option has never been saved.
27 * Matches the legacy default: opt-in required for the free plugin.
28 */
29 const DEFAULT_ENABLED = false;
30
31 /**
32 * Option key: site token returned by the API.
33 */
34 const OPTION_SITE_TOKEN = 'cff_smash_usage_tracking_site_token';
35
36 /**
37 * Option key: schedule metadata (optional).
38 */
39 const OPTION_SCHEDULE = 'cff_smash_usage_tracking_schedule';
40
41 /**
42 * Option key: dates when plugin was active (Y-m-d), for days_active metric.
43 */
44 const OPTION_ACTIVE_DATES = 'cff_smash_usage_active_dates';
45
46 /**
47 * Option key: last N session durations in seconds, for session_duration metric.
48 */
49 const OPTION_SESSION_DURATIONS = 'cff_smash_usage_session_durations';
50
51 /**
52 * Cron hook name. Different from the Pro plugin to avoid duplicate sends
53 * on sites where both free and pro are installed simultaneously.
54 */
55 const CRON_HOOK = 'cff_free_smash_usage_tracking_cron';
56
57 /**
58 * Max request timeout in seconds for usage report (large payloads).
59 */
60 const REQUEST_TIMEOUT = 30;
61
62 /**
63 * Max payload size in bytes before send is skipped (default 2MB).
64 */
65 const MAX_PAYLOAD_BYTES = 2097152;
66
67 /**
68 * Register-site endpoint path (relative to API base).
69 */
70 const REGISTER_SITE_PATH = '/v1/register-site';
71
72 /**
73 * Usage report endpoint path (relative to API base).
74 */
75 const USAGE_REPORT_PATH = '/v1/usage-report';
76
77 /**
78 * Get the API base URL (filterable).
79 *
80 * @return string
81 */
82 public static function get_api_url() {
83 $url = defined( 'CFF_SMASH_USAGE_TRACKING_API_URL' ) ? CFF_SMASH_USAGE_TRACKING_API_URL : '';
84 return (string) apply_filters( 'cff_smash_usage_tracking_api_url', $url );
85 }
86
87 /**
88 * Get full URL for register-site endpoint.
89 *
90 * @return string
91 */
92 public static function get_register_site_url() {
93 return rtrim( self::get_api_url(), '/' ) . self::REGISTER_SITE_PATH;
94 }
95
96 /**
97 * Get full URL for usage-report endpoint.
98 *
99 * @return string
100 */
101 public static function get_usage_report_url() {
102 return rtrim( self::get_api_url(), '/' ) . self::USAGE_REPORT_PATH;
103 }
104
105 /**
106 * Check if tracking is enabled.
107 *
108 * @return bool
109 */
110 public static function is_enabled() {
111 $opt = get_option( self::OPTION_TRACKING, false );
112 if ( ! is_array( $opt ) || ! array_key_exists( 'enabled', $opt ) ) {
113 return self::DEFAULT_ENABLED;
114 }
115 return ! empty( $opt['enabled'] );
116 }
117 }
118