Use PHP 7.4 featers and PHP 8 polyfills
This commit is contained in:
@ -43,7 +43,7 @@ trait Singleton {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
$this->has_parents() && method_exists(get_parent_class($this), 'init') && parent::init();
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ trait WP_Ultimo_Deprecated {
|
||||
* @param string $term Returns a string based on the term and this plugin slug.
|
||||
* @return void
|
||||
*/
|
||||
public function slugfy($term) {
|
||||
public function slugfy($term): void {
|
||||
|
||||
_deprecated_function(__METHOD__, '2.0.0', 'wu_slugify($term)');
|
||||
|
||||
@ -34,7 +34,7 @@ trait WP_Ultimo_Deprecated {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_page_to_branding() {
|
||||
public function add_page_to_branding(): void {
|
||||
|
||||
_deprecated_function(__METHOD__, '2.0.0');
|
||||
}
|
||||
@ -49,7 +49,7 @@ trait WP_Ultimo_Deprecated {
|
||||
* @param boolean $vars Key => Value pairs to be made available as local variables inside the view scope.
|
||||
* @return void
|
||||
*/
|
||||
public function render($view, $vars = false) {
|
||||
public function render($view, $vars = false): void {
|
||||
|
||||
_deprecated_function(__METHOD__, '2.0.0', 'wu_get_template()');
|
||||
|
||||
@ -82,7 +82,7 @@ trait WP_Ultimo_Deprecated {
|
||||
* @param boolean $network Where to display, network admin or normal admin.
|
||||
* @return void
|
||||
*/
|
||||
public function add_message($message, $type = 'success', $network = false) {
|
||||
public function add_message($message, $type = 'success', $network = false): void {
|
||||
|
||||
_deprecated_function(__METHOD__, '2.0.0', 'WP_Ultimo()->notices->add()');
|
||||
|
||||
@ -117,12 +117,12 @@ trait WP_Ultimo_Deprecated {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_select2() {
|
||||
public function enqueue_select2(): void {
|
||||
|
||||
_deprecated_function(__METHOD__, '2.0.0');
|
||||
|
||||
wp_enqueue_style('wu-select2css', 'https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.css', false, '1.0', 'all');
|
||||
|
||||
wp_enqueue_script('wu-select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.js', array('jquery'), '1.0', true);
|
||||
wp_enqueue_script('wu-select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.js', ['jquery'], '1.0', true);
|
||||
}
|
||||
}
|
||||
|
@ -58,17 +58,17 @@ trait WP_Ultimo_Plan_Deprecated {
|
||||
$value = $this->get_feature_list();
|
||||
break;
|
||||
case 'quotas':
|
||||
$value = array(
|
||||
$value = [
|
||||
// 'sites' => 300,
|
||||
'upload' => 1024 * 1024 * 1024,
|
||||
'visits' => 300,
|
||||
);
|
||||
];
|
||||
break;
|
||||
case 'post':
|
||||
$value = (object) array(
|
||||
$value = (object) [
|
||||
'ID' => $this->get_id(),
|
||||
'post_title' => $this->get_name(),
|
||||
);
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$value = $this->get_meta('wpu_' . $key, false, true);
|
||||
@ -107,7 +107,7 @@ trait WP_Ultimo_Plan_Deprecated {
|
||||
* @param array $featured_plan Feature list for pricing tables.
|
||||
* @return void
|
||||
*/
|
||||
public function set_featured_plan($featured_plan) {
|
||||
public function set_featured_plan($featured_plan): void {
|
||||
|
||||
$this->meta['featured_plan'] = $featured_plan;
|
||||
}
|
||||
@ -134,7 +134,7 @@ trait WP_Ultimo_Plan_Deprecated {
|
||||
*/
|
||||
public function get_pricing_table_lines() {
|
||||
|
||||
$pricing_table_lines = array();
|
||||
$pricing_table_lines = [];
|
||||
|
||||
/*
|
||||
* Setup Fee
|
||||
@ -155,7 +155,7 @@ trait WP_Ultimo_Plan_Deprecated {
|
||||
* Post Type Lines
|
||||
* Gets the post type lines to be displayed on the pricing table options
|
||||
*/
|
||||
$post_types = get_post_types(array('public' => true), 'objects');
|
||||
$post_types = get_post_types(['public' => true], 'objects');
|
||||
$post_types = apply_filters('wu_get_post_types', $post_types);
|
||||
|
||||
foreach ($post_types as $pt_slug => $post_type) {
|
||||
@ -233,7 +233,7 @@ trait WP_Ultimo_Plan_Deprecated {
|
||||
$trial_days_plan = $this->get_trial_duration();
|
||||
|
||||
if ($trial_days > 0 || $trial_days_plan) {
|
||||
$trial_days = $trial_days_plan ? $trial_days_plan : $trial_days;
|
||||
$trial_days = $trial_days_plan ?: $trial_days;
|
||||
|
||||
$pricing_table_lines['wu_product_trial'] = ! $this->is_free() ? sprintf(__('%s day <strong>Free Trial</strong>', 'wp-ultimo'), $trial_days) : '-';
|
||||
}
|
||||
@ -297,7 +297,7 @@ trait WP_Ultimo_Plan_Deprecated {
|
||||
/*
|
||||
* @since 1.3.3 Only Show elements allowed on the plan settings
|
||||
*/
|
||||
$elements = array();
|
||||
$elements = [];
|
||||
|
||||
if ( ! $elements) {
|
||||
return true;
|
||||
@ -347,13 +347,13 @@ trait WP_Ultimo_Plan_Deprecated {
|
||||
$quotas,
|
||||
fn($quota_name) => ! in_array(
|
||||
$quota_name,
|
||||
array(
|
||||
[
|
||||
'sites',
|
||||
'attachment',
|
||||
'upload',
|
||||
'users',
|
||||
'visits',
|
||||
),
|
||||
],
|
||||
true
|
||||
),
|
||||
ARRAY_FILTER_USE_KEY
|
||||
|
@ -20,7 +20,7 @@ trait WP_Ultimo_Settings_Deprecated {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_legacy_scripts() {
|
||||
public function handle_legacy_scripts(): void {
|
||||
/*
|
||||
* Mailchimp: Backwards compatibility.
|
||||
*/
|
||||
@ -35,14 +35,14 @@ trait WP_Ultimo_Settings_Deprecated {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_legacy_filters() {
|
||||
public function handle_legacy_filters(): void {
|
||||
|
||||
$legacy_settings = array();
|
||||
$legacy_settings = [];
|
||||
|
||||
/*
|
||||
* Fetch Extra Sections
|
||||
*/
|
||||
$sections = apply_filters_deprecated('wu_settings_sections', array(array()), '2.0.0', 'wu_register_settings_section()');
|
||||
$sections = apply_filters_deprecated('wu_settings_sections', [[]], '2.0.0', 'wu_register_settings_section()');
|
||||
|
||||
foreach ($sections as $section_key => $section) {
|
||||
if ($section_key === 'activation') {
|
||||
@ -53,7 +53,7 @@ trait WP_Ultimo_Settings_Deprecated {
|
||||
$legacy_settings = array_merge($legacy_settings, $section['fields']);
|
||||
}
|
||||
|
||||
$filters = array(
|
||||
$filters = [
|
||||
'wu_settings_section_general',
|
||||
'wu_settings_section_network',
|
||||
'wu_settings_section_domain_mapping',
|
||||
@ -62,25 +62,25 @@ trait WP_Ultimo_Settings_Deprecated {
|
||||
'wu_settings_section_styling',
|
||||
'wu_settings_section_tools',
|
||||
'wu_settings_section_advanced',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($filters as $filter) {
|
||||
$message = __('Adding setting sections directly via filters is no longer supported.');
|
||||
|
||||
$legacy_settings = apply_filters_deprecated($filter, array($legacy_settings), '2.0.0', 'wu_register_settings_field()', $message);
|
||||
$legacy_settings = apply_filters_deprecated($filter, [$legacy_settings], '2.0.0', 'wu_register_settings_field()', $message);
|
||||
}
|
||||
|
||||
if ($legacy_settings) {
|
||||
$this->add_section(
|
||||
'other',
|
||||
array(
|
||||
[
|
||||
'title' => __('Other', 'wp-ultimo'),
|
||||
'desc' => __('Other', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($legacy_settings as $setting_key => $setting) {
|
||||
if (strpos((string) $setting_key, 'license_key_') !== false) {
|
||||
if (str_contains((string) $setting_key, 'license_key_')) {
|
||||
continue; // Remove old license key fields
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ trait WP_Ultimo_Site_Deprecated {
|
||||
*/
|
||||
public function get_subscription() {
|
||||
|
||||
_deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Models\Site::get_membership()');
|
||||
_deprecated_function(self::class, '2.0.0', '\WP_Ultimo\Models\Site::get_membership()');
|
||||
|
||||
return $this->get_membership();
|
||||
}
|
||||
|
Reference in New Issue
Block a user