Skip to content

Commit f6e9b31

Browse files
committed
apply phps formatting
1 parent 65a894d commit f6e9b31

8 files changed

Lines changed: 368 additions & 274 deletions

src/LicenseHandler.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ private function resolve_license_key_for_addon() {
341341
}
342342

343343
// 3. Legacy: check old per-plugin key from Gravity Forms addon settings.
344-
// This covers customers who entered the key in the old plugin settings
345-
// page and haven't migrated yet. We read it, USE it, AND auto-migrate it
346-
// so the next request uses the new storage directly.
344+
// This covers customers who entered the key in the old plugin settings
345+
// page and haven't migrated yet. We read it, USE it, AND auto-migrate it
346+
// so the next request uses the new storage directly.
347347
$legacy_key = $this->read_legacy_addon_key();
348348
if ( ! empty( $legacy_key ) ) {
349349
$this->auto_migrate_discovered_key( $legacy_key );
@@ -559,7 +559,7 @@ public function plugin_settings_license_fields() {
559559
* @return string HTML output.
560560
*/
561561
private static function render_status_html( $message, $type ) {
562-
$map = array(
562+
$map = array(
563563
'success' => array( '#27ae60', 'dashicons-yes-alt' ),
564564
'warning' => array( '#f39c12', 'dashicons-info' ),
565565
'danger' => array( '#dc3232', 'dashicons-warning' ),

src/pluginUpdater.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -449,17 +449,17 @@ public function check_update( $_transient_data ) {
449449
$hub_plugin_data = \GravityWP\Shared\Hub_Manager::get_plugin_data( $this->slug );
450450

451451
if ( ! empty( $hub_plugin_data ) && ! empty( $hub_plugin_data['new_version'] ) ) {
452-
$version_info = new stdClass();
453-
$version_info->name = $hub_plugin_data['name'] ?? '';
454-
$version_info->slug = $hub_plugin_data['slug'] ?? $this->slug;
455-
$version_info->new_version = $hub_plugin_data['new_version'];
456-
$version_info->url = '';
457-
$version_info->plugin = $this->name;
458-
$version_info->icons = $hub_plugin_data['icons'] ?? [];
459-
$version_info->banners = $hub_plugin_data['banners'] ?? [];
460-
$version_info->sections = $hub_plugin_data['sections'] ?? [];
461-
$version_info->requires = $hub_plugin_data['requires'] ?? '';
462-
$version_info->tested = $hub_plugin_data['tested'] ?? '';
452+
$version_info = new stdClass();
453+
$version_info->name = $hub_plugin_data['name'] ?? '';
454+
$version_info->slug = $hub_plugin_data['slug'] ?? $this->slug;
455+
$version_info->new_version = $hub_plugin_data['new_version'];
456+
$version_info->url = '';
457+
$version_info->plugin = $this->name;
458+
$version_info->icons = $hub_plugin_data['icons'] ?? array();
459+
$version_info->banners = $hub_plugin_data['banners'] ?? array();
460+
$version_info->sections = $hub_plugin_data['sections'] ?? array();
461+
$version_info->requires = $hub_plugin_data['requires'] ?? '';
462+
$version_info->tested = $hub_plugin_data['tested'] ?? '';
463463
$version_info->requires_php = $hub_plugin_data['requires_php'] ?? '';
464464

465465
// Only include download link if license covers this plugin.
@@ -505,7 +505,7 @@ public function check_update( $_transient_data ) {
505505
$no_update = false;
506506
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
507507

508-
$_transient_data->response[ $this->name ] = $version_info;
508+
$_transient_data->response[ $this->name ] = $version_info;
509509
$_transient_data->response[ $this->name ]->plugin = $this->name;
510510
} else {
511511
$no_update = new stdClass();

src/shared/class-api-error-handler.php

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ public static function get_catalog() {
7474

7575
self::$catalog = array(
7676
// ── License-state codes (from PaddlePress) ─────────────────
77-
'unregistered_license_domain' => array(
77+
'unregistered_license_domain' => array(
7878
'severity' => self::SEVERITY_INFO,
7979
'blocking' => false, // Becomes blocking only with can_not_add_new_domain.
8080
'message' => __( 'Activating this site on your license…', 'gravitywp-license-handler' ),
8181
),
82-
'can_not_add_new_domain' => array(
82+
'can_not_add_new_domain' => array(
8383
'severity' => self::SEVERITY_ERROR,
8484
'blocking' => true,
8585
'message' => __( 'Your license is at its site limit. Deactivate another site or upgrade your plan.', 'gravitywp-license-handler' ),
@@ -89,136 +89,136 @@ public static function get_catalog() {
8989
'blocking' => true,
9090
'message' => __( "This license doesn't cover this plugin.", 'gravitywp-license-handler' ),
9191
),
92-
'invalid_license_or_domain' => array(
92+
'invalid_license_or_domain' => array(
9393
'severity' => self::SEVERITY_ERROR,
9494
'blocking' => true,
9595
'message' => __( 'License invalid for this site. Check the key or contact support.', 'gravitywp-license-handler' ),
9696
),
97-
'no_key' => array(
97+
'no_key' => array(
9898
'severity' => self::SEVERITY_INFO,
9999
'blocking' => true,
100100
'message' => __( 'No license key entered.', 'gravitywp-license-handler' ),
101101
),
102102
// PaddlePress emits this when the key isn't in the payments
103103
// table at all (typo, deleted, never existed).
104-
'missing_license_key' => array(
104+
'missing_license_key' => array(
105105
'severity' => self::SEVERITY_ERROR,
106106
'blocking' => true,
107107
'message' => __( "We couldn't find this license key. Double-check that you copied it correctly from your purchase email, or contact support.", 'gravitywp-license-handler' ),
108108
),
109-
'expired_license_key' => array(
109+
'expired_license_key' => array(
110110
'severity' => self::SEVERITY_ERROR,
111111
'blocking' => true,
112112
'message' => __( 'This license key has expired. Renew it to continue receiving updates and use the key on new sites.', 'gravitywp-license-handler' ),
113113
),
114-
'blocked_license_domain' => array(
114+
'blocked_license_domain' => array(
115115
'severity' => self::SEVERITY_ERROR,
116116
'blocking' => true,
117117
'message' => __( 'This site has been blocked for this license. Contact support if you believe this is a mistake.', 'gravitywp-license-handler' ),
118118
),
119-
'invalid_product' => array(
119+
'invalid_product' => array(
120120
'severity' => self::SEVERITY_ERROR,
121121
'blocking' => true,
122122
'message' => __( "This license key isn't valid for this product.", 'gravitywp-license-handler' ),
123123
),
124124

125125
// ── Transport / network codes (raised by Hub_Manager) ──────
126-
'server_error' => array(
126+
'server_error' => array(
127127
'severity' => self::SEVERITY_ERROR,
128128
'blocking' => true,
129129
'message' => __( 'License server unavailable. Try again in a moment.', 'gravitywp-license-handler' ),
130130
),
131-
'cloudflare_blocked' => array(
131+
'cloudflare_blocked' => array(
132132
'severity' => self::SEVERITY_ERROR,
133133
'blocking' => true,
134134
'message' => __( 'Your hosting provider blocked the license check (Cloudflare). Contact your host to allow requests to my.gravitywp.com.', 'gravitywp-license-handler' ),
135135
),
136-
'network_timeout' => array(
136+
'network_timeout' => array(
137137
'severity' => self::SEVERITY_ERROR,
138138
'blocking' => true,
139139
'message' => __( "Couldn't reach the license server. Check your internet connection and try again.", 'gravitywp-license-handler' ),
140140
),
141-
'http_5xx' => array(
141+
'http_5xx' => array(
142142
'severity' => self::SEVERITY_ERROR,
143143
'blocking' => true,
144144
/* translators: %d: HTTP status code */
145145
'message' => __( 'License server returned an error (HTTP %d). Try again shortly.', 'gravitywp-license-handler' ),
146146
),
147-
'http_4xx' => array(
147+
'http_4xx' => array(
148148
'severity' => self::SEVERITY_ERROR,
149149
'blocking' => true,
150150
/* translators: %d: HTTP status code */
151151
'message' => __( 'License request rejected (HTTP %d).', 'gravitywp-license-handler' ),
152152
),
153-
'malformed_response' => array(
153+
'malformed_response' => array(
154154
'severity' => self::SEVERITY_ERROR,
155155
'blocking' => true,
156156
'message' => __( 'Unexpected response from the license server. Contact support if this persists.', 'gravitywp-license-handler' ),
157157
),
158158

159159
// ── REST validator codes (when our request is malformed) ───
160-
'rest_missing_callback_param' => array(
160+
'rest_missing_callback_param' => array(
161161
'severity' => self::SEVERITY_ERROR,
162162
'blocking' => true,
163163
/* translators: %s: parameter name */
164164
'message' => __( 'Missing required field: %s. This is a bug — please report it.', 'gravitywp-license-handler' ),
165165
),
166-
'rest_invalid_param' => array(
166+
'rest_invalid_param' => array(
167167
'severity' => self::SEVERITY_ERROR,
168168
'blocking' => true,
169169
/* translators: %s: parameter name */
170170
'message' => __( 'Invalid request parameter: %s. This is a bug — please report it.', 'gravitywp-license-handler' ),
171171
),
172172

173173
// ── Install / update upgrader codes ────────────────────────
174-
'folder_exists' => array(
174+
'folder_exists' => array(
175175
'severity' => self::SEVERITY_ERROR,
176176
'blocking' => true,
177177
'message' => __( 'A plugin folder with this name already exists. Remove the orphan folder via FTP and retry.', 'gravitywp-license-handler' ),
178178
),
179-
'download_failed' => array(
179+
'download_failed' => array(
180180
'severity' => self::SEVERITY_ERROR,
181181
'blocking' => true,
182182
'message' => __( "Couldn't download the plugin package. Check your license or try again.", 'gravitywp-license-handler' ),
183183
),
184-
'filesystem_requires_ftp' => array(
184+
'filesystem_requires_ftp' => array(
185185
'severity' => self::SEVERITY_ERROR,
186186
'blocking' => true,
187187
'message' => __( 'This site needs FTP credentials to install plugins. Install via Plugins → Add New instead.', 'gravitywp-license-handler' ),
188188
),
189-
'operation_in_progress' => array(
189+
'operation_in_progress' => array(
190190
'severity' => self::SEVERITY_WARN,
191191
'blocking' => true,
192192
'message' => __( 'Another install or update is already running. Wait a few seconds and try again.', 'gravitywp-license-handler' ),
193193
),
194-
'security_check_failed' => array(
194+
'security_check_failed' => array(
195195
'severity' => self::SEVERITY_ERROR,
196196
'blocking' => true,
197197
'message' => __( 'Security check failed. Reload the page and try again.', 'gravitywp-license-handler' ),
198198
),
199199

200200
// ── UI-state codes (raised by interpret_license) ───────────
201-
'wrong_plugin_key' => array(
201+
'wrong_plugin_key' => array(
202202
'severity' => self::SEVERITY_WARN,
203203
'blocking' => false,
204-
'message' => __( "This key is for a different plugin — move it to the matching row.", 'gravitywp-license-handler' ),
204+
'message' => __( 'This key is for a different plugin — move it to the matching row.', 'gravitywp-license-handler' ),
205205
),
206-
'wrong_field_for_plan_type' => array(
206+
'wrong_field_for_plan_type' => array(
207207
'severity' => self::SEVERITY_WARN,
208208
'blocking' => true,
209209
'message' => __( 'This looks like a Single Add-on key. Add it under Individual Plugin Keys instead.', 'gravitywp-license-handler' ),
210210
),
211-
'global_key_in_per_plugin' => array(
211+
'global_key_in_per_plugin' => array(
212212
'severity' => self::SEVERITY_INFO,
213213
'blocking' => false,
214214
'message' => __( 'This is a multi-plugin license (All Access / Agency / List Add-ons). It works here, and it actually unlocks every plugin in your account on its own — you don\'t need to add it to other rows. For clarity, consider moving it to the Global License Key field instead.', 'gravitywp-license-handler' ),
215215
),
216-
'via_global' => array(
216+
'via_global' => array(
217217
'severity' => self::SEVERITY_SUCCESS,
218218
'blocking' => false,
219219
'message' => __( 'Covered by your Global License Key.', 'gravitywp-license-handler' ),
220220
),
221-
'active' => array(
221+
'active' => array(
222222
'severity' => self::SEVERITY_SUCCESS,
223223
'blocking' => false,
224224
'message' => __( 'Active', 'gravitywp-license-handler' ),
@@ -316,7 +316,7 @@ public static function classify_wp_error( $err ) {
316316
// WordPress wraps cURL CURLE_OPERATION_TIMEDOUT (28) and
317317
// CURLE_COULDNT_RESOLVE_HOST (6) all into 'http_request_failed',
318318
// so we have to inspect the message string to differentiate.
319-
$msg = strtolower( (string) $err->get_error_message() );
319+
$msg = strtolower( (string) $err->get_error_message() );
320320
if ( false !== strpos( $msg, 'timed out' ) || false !== strpos( $msg, 'timeout' ) ) {
321321
return 'network_timeout';
322322
}
@@ -419,7 +419,7 @@ public static function interpret_license( $license_data, $plugin_ctx = array() )
419419
// the user the key is a multi-plugin license and that they can
420420
// move it to Global for clarity. The renderer detects the
421421
// non-'active' primary_code and emits the note.
422-
$plan_type = isset( $license_data['plan_type'] ) ? (string) $license_data['plan_type'] : '';
422+
$plan_type = isset( $license_data['plan_type'] ) ? (string) $license_data['plan_type'] : '';
423423
$is_multi_plugin_plan = in_array(
424424
$plan_type,
425425
array( Plan_Types::ALL_ACCESS, Plan_Types::AGENCY, Plan_Types::LIST_ADDONS ),
@@ -442,12 +442,12 @@ public static function interpret_license( $license_data, $plugin_ctx = array() )
442442
// wrong-plugin determination. The hub returns has_access=false
443443
// for two very different conditions:
444444
//
445-
// (a) Wrong product — key activated fine, but its plan doesn't
446-
// grant download permission to this plugin. The user put
447-
// the key in the wrong row.
448-
// (b) Activation failed — site limit reached, insufficient
449-
// membership level, license expired on the server side.
450-
// The key is for the right plugin; it just can't run here.
445+
// (a) Wrong product — key activated fine, but its plan doesn't
446+
// grant download permission to this plugin. The user put
447+
// the key in the wrong row.
448+
// (b) Activation failed — site limit reached, insufficient
449+
// membership level, license expired on the server side.
450+
// The key is for the right plugin; it just can't run here.
451451
//
452452
// PaddlePress only distinguishes these via the embedded `errors`
453453
// map. So we check it FIRST. If we find a blocking error, the
@@ -530,7 +530,7 @@ public static function detect_key_plan_type( $key ) {
530530
* @return array{plan_type:string, slug:?string}
531531
*/
532532
public static function detect_key_destination( $key ) {
533-
$key = (string) $key;
533+
$key = (string) $key;
534534
$default = array(
535535
'plan_type' => Plan_Types::UNKNOWN,
536536
'slug' => null,
@@ -584,12 +584,16 @@ public static function detect_key_destination( $key ) {
584584
*/
585585
public static function remember_key_plan_type( $key, $plan_type, $unlock_slug = null ) {
586586
$key = (string) $key;
587-
if ( '' === $key || ! in_array( $plan_type, array(
588-
Plan_Types::AGENCY,
589-
Plan_Types::ALL_ACCESS,
590-
Plan_Types::LIST_ADDONS,
591-
Plan_Types::SINGLE_ADDON,
592-
), true ) ) {
587+
if ( '' === $key || ! in_array(
588+
$plan_type,
589+
array(
590+
Plan_Types::AGENCY,
591+
Plan_Types::ALL_ACCESS,
592+
Plan_Types::LIST_ADDONS,
593+
Plan_Types::SINGLE_ADDON,
594+
),
595+
true
596+
) ) {
593597
return;
594598
}
595599
$seen = get_option( self::SEEN_KEYS_OPTION, array() );

0 commit comments

Comments
 (0)