Use PHP 7.4 featers and PHP 8 polyfills

This commit is contained in:
David Stone
2025-02-08 13:57:32 -07:00
parent 8bea6067cd
commit b41dc2b2eb
550 changed files with 15270 additions and 14627 deletions

View File

@ -7,21 +7,21 @@ class Newsletter {
const SETTING_FIELD_SLUG = 'newsletter_optin';
public function init() {
add_action('wu_settings_login', array($this, 'add_settings'), 20);
add_filter('wu_pre_save_settings', array($this, 'maybe_update_newsletter_subscription'), 10, 3);
public function init(): void {
add_action('wu_settings_login', [$this, 'add_settings'], 20);
add_filter('wu_pre_save_settings', [$this, 'maybe_update_newsletter_subscription'], 10, 3);
}
public function add_settings() {
public function add_settings(): void {
wu_register_settings_field(
'general',
self::SETTING_FIELD_SLUG,
array(
[
'title' => __('Signup for WP Multisite WaaS Newsletter', 'wp-ultimo'),
'desc' => __('Be informed of new releases and all things related to running a WaaS Network.', 'wp-ultimo'),
'type' => 'toggle',
'value' => '1',
),
],
45
);
}
@ -42,40 +42,40 @@ class Newsletter {
if ( isset($settings_to_save[ self::SETTING_FIELD_SLUG ]) && $settings_to_save[ self::SETTING_FIELD_SLUG ] && $settings_to_save[ self::SETTING_FIELD_SLUG ] != $saved_settings[ self::SETTING_FIELD_SLUG ] ) {
$response = wp_remote_post(
'https://wpmultisitewaas.org/wp-json/newsletter/v2/subscribers',
array(
[
'method' => 'PUT',
'body' => wp_json_encode(
array(
[
'email' => $settings['company_email'],
'status' => 'confirmed',
'first_name' => $settings['company_name'],
'country' => $settings['company_country'],
)
]
),
'headers' => array(
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Authorization' => 'Basic ' . base64_encode('30220d7fb4ec49a7410b3a309b9346c18410bd56:0407cd731d6f074cd0b96f2643b7619e89af1ed2'),
),
)
],
]
);
} elseif ( empty($settings_to_save[ self::SETTING_FIELD_SLUG ]) && ! empty($saved_settings[ self::SETTING_FIELD_SLUG ]) ) {
$response = wp_remote_post(
'https://wpmultisitewaas.org/wp-json/newsletter/v2/subscribers',
array(
[
'method' => 'PUT',
'body' => wp_json_encode(
array(
[
'email' => $settings['company_email'],
'status' => 'unsubscribed',
)
]
),
'headers' => array(
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Authorization' => 'Basic ' . base64_encode('30220d7fb4ec49a7410b3a309b9346c18410bd56:0407cd731d6f074cd0b96f2643b7619e89af1ed2'),
),
)
],
]
);
}