Use PHP 7.4 featers and PHP 8 polyfills
This commit is contained in:
@ -29,9 +29,9 @@ class Discount_Code_Compat {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_filter('update_post_metadata', array($this, 'check_update_coupon'), 10, 5);
|
||||
add_filter('update_post_metadata', [$this, 'check_update_coupon'], 10, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,13 +29,13 @@ class Elementor_Compat {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_action('wu_duplicate_site', array($this, 'regenerate_css'));
|
||||
add_action('wu_duplicate_site', [$this, 'regenerate_css']);
|
||||
|
||||
add_filter('wu_should_redirect_to_primary_domain', array($this, 'maybe_prevent_redirection'));
|
||||
add_filter('wu_should_redirect_to_primary_domain', [$this, 'maybe_prevent_redirection']);
|
||||
|
||||
add_action('elementor/widget/shortcode/skins_init', array($this, 'maybe_setup_preview'));
|
||||
add_action('elementor/widget/shortcode/skins_init', [$this, 'maybe_setup_preview']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,7 +45,7 @@ class Elementor_Compat {
|
||||
* @param array $site Info about the duplicated site.
|
||||
* @return void
|
||||
*/
|
||||
public function regenerate_css($site) {
|
||||
public function regenerate_css($site): void {
|
||||
|
||||
if ( ! class_exists('\Elementor\Plugin')) {
|
||||
return;
|
||||
@ -85,12 +85,12 @@ class Elementor_Compat {
|
||||
* @since 2.0.5
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_setup_preview() {
|
||||
public function maybe_setup_preview(): void {
|
||||
|
||||
$elementor_actions = array(
|
||||
$elementor_actions = [
|
||||
'elementor',
|
||||
'elementor_ajax',
|
||||
);
|
||||
];
|
||||
|
||||
if (in_array(wu_request('action'), $elementor_actions, true)) {
|
||||
wu_element_setup_preview();
|
||||
|
@ -29,7 +29,7 @@ class General_Compat {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
/**
|
||||
* Woocommerce
|
||||
@ -38,46 +38,46 @@ class General_Compat {
|
||||
*
|
||||
* @see https://wordpress.org/plugins/woocommerce/
|
||||
*/
|
||||
add_action('woocommerce_loaded', array($this, 'replace_wc_wpdb_table_fix'));
|
||||
add_action('woocommerce_loaded', [$this, 'replace_wc_wpdb_table_fix']);
|
||||
|
||||
/**
|
||||
* WP Typography.
|
||||
*
|
||||
* @see https://de.wordpress.org/plugins/wp-typography/
|
||||
*/
|
||||
add_action('load-settings_page_wp-typography', array($this, 'add_wp_typography_warning_message'));
|
||||
add_action('load-settings_page_wp-typography', [$this, 'add_wp_typography_warning_message']);
|
||||
|
||||
add_filter('typo_settings', array($this, 'fix_wp_typography'));
|
||||
add_filter('typo_settings', [$this, 'fix_wp_typography']);
|
||||
|
||||
/**
|
||||
* Brizy Page Builder.
|
||||
*
|
||||
* @see https://wordpress.org/plugins/brizy/
|
||||
*/
|
||||
add_filter('wu_append_preview_parameter', array($this, 'fix_brizy_preview_url'));
|
||||
add_filter('wu_append_preview_parameter', [$this, 'fix_brizy_preview_url']);
|
||||
|
||||
add_filter('wu_should_redirect_to_primary_domain', array($this, 'fix_brizy_editor_screen'));
|
||||
add_filter('wu_should_redirect_to_primary_domain', [$this, 'fix_brizy_editor_screen']);
|
||||
|
||||
/**
|
||||
* Divi Page Builder.
|
||||
*
|
||||
* @see https://www.elegantthemes.com/
|
||||
*/
|
||||
add_filter('wu_should_redirect_to_primary_domain', array($this, 'fix_divi_editor_screen'));
|
||||
add_filter('wu_should_redirect_to_primary_domain', [$this, 'fix_divi_editor_screen']);
|
||||
|
||||
/**
|
||||
* WP Hide Pro
|
||||
*
|
||||
* @see https://wp-hide.com/
|
||||
*/
|
||||
add_filter('wu_append_preview_parameter', array($this, 'fix_wp_hide_preview_url'));
|
||||
add_filter('wu_append_preview_parameter', [$this, 'fix_wp_hide_preview_url']);
|
||||
|
||||
/**
|
||||
* Frontend Admin.
|
||||
*
|
||||
* @see https://wpfrontendadmin.com/
|
||||
*/
|
||||
add_filter('wp_frontend_admin/shortcode/admin_page_final_url', array($this, 'fix_frontend_admin_loading_url'), 10, 3);
|
||||
add_filter('wp_frontend_admin/shortcode/admin_page_final_url', [$this, 'fix_frontend_admin_loading_url'], 10, 3);
|
||||
|
||||
/**
|
||||
* Oxygen Builder.
|
||||
@ -87,16 +87,16 @@ class General_Compat {
|
||||
*
|
||||
* @see https://oxygenbuilder.com/
|
||||
*/
|
||||
add_filter('wu_element_should_enqueue_scripts', array($this, 'maybe_parse_oxygen_content'), 10, 3);
|
||||
add_filter('wu_element_should_enqueue_scripts', [$this, 'maybe_parse_oxygen_content'], 10, 3);
|
||||
|
||||
add_action('wu_template_previewer', array($this, 'prevent_oxygen_cleanup_on_template_previewer'));
|
||||
add_action('wu_template_previewer', [$this, 'prevent_oxygen_cleanup_on_template_previewer']);
|
||||
|
||||
/**
|
||||
* WP Maintenance Mode. Adds SSO to WPMM, if enabled.
|
||||
*
|
||||
* @see https://wordpress.org/plugins/wp-maintenance-mode/
|
||||
*/
|
||||
add_filter('wu_sso_loaded_on_init', array($this, 'add_sso_to_maintenance_mode'));
|
||||
add_filter('wu_sso_loaded_on_init', [$this, 'add_sso_to_maintenance_mode']);
|
||||
|
||||
/**
|
||||
* Avada Theme.
|
||||
@ -106,8 +106,8 @@ class General_Compat {
|
||||
*
|
||||
* @see https://themeforest.net/item/avada-responsive-multipurpose-theme/
|
||||
*/
|
||||
add_filter('wu_template_previewer_before', array($this, 'run_wp_on_template_previewer'));
|
||||
add_filter('wu_domain_post_save', array($this, 'clear_avada_cache'));
|
||||
add_filter('wu_template_previewer_before', [$this, 'run_wp_on_template_previewer']);
|
||||
add_filter('wu_domain_post_save', [$this, 'clear_avada_cache']);
|
||||
|
||||
/**
|
||||
* FluentCRM Pro
|
||||
@ -116,7 +116,7 @@ class General_Compat {
|
||||
*
|
||||
* @see https://fluentcrm.com/
|
||||
*/
|
||||
add_action('wp_insert_site', array($this, 'fix_fluent_pro_site_duplication'));
|
||||
add_action('wp_insert_site', [$this, 'fix_fluent_pro_site_duplication']);
|
||||
|
||||
/**
|
||||
* Rank Math (Free and Pro)
|
||||
@ -125,7 +125,7 @@ class General_Compat {
|
||||
*
|
||||
* @see https://rankmath.com/
|
||||
*/
|
||||
add_action('wp_initialize_site', array($this, 'fix_rank_math_site_creation'), 1);
|
||||
add_action('wp_initialize_site', [$this, 'fix_rank_math_site_creation'], 1);
|
||||
|
||||
/**
|
||||
* WP E-Signature and WP E-Signature Business add-ons
|
||||
@ -134,7 +134,7 @@ class General_Compat {
|
||||
*
|
||||
* @see https://www.approveme.com/
|
||||
*/
|
||||
add_action('wp_initialize_site', array($this, 'fix_wp_e_signature_site_creation'), 1);
|
||||
add_action('wp_initialize_site', [$this, 'fix_wp_e_signature_site_creation'], 1);
|
||||
|
||||
/**
|
||||
* KeyPress DSN Manager backwards compatibility.
|
||||
@ -161,7 +161,7 @@ class General_Compat {
|
||||
* @since 2.1.1
|
||||
* @see https://perfmatters.io/
|
||||
*/
|
||||
add_filter('wp_print_scripts', array($this, 'remove_perfmatters_checkout_dep'), 99);
|
||||
add_filter('wp_print_scripts', [$this, 'remove_perfmatters_checkout_dep'], 99);
|
||||
|
||||
/**
|
||||
* Adds the setup preview for elements on DIVI.
|
||||
@ -189,20 +189,20 @@ class General_Compat {
|
||||
* @see https://wordpress.org/plugins/woocommerce/
|
||||
* @since 2.0.14
|
||||
*/
|
||||
public function replace_wc_wpdb_table_fix() {
|
||||
public function replace_wc_wpdb_table_fix(): void {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
remove_action('switch_blog', array(WC(), 'wpdb_table_fix'), 0);
|
||||
remove_action('switch_blog', [WC(), 'wpdb_table_fix'], 0);
|
||||
|
||||
// List of tables without prefixes.
|
||||
$tables = array(
|
||||
$tables = [
|
||||
'payment_tokenmeta' => 'woocommerce_payment_tokenmeta',
|
||||
'order_itemmeta' => 'woocommerce_order_itemmeta',
|
||||
'wc_product_meta_lookup' => 'wc_product_meta_lookup',
|
||||
'wc_tax_rate_classes' => 'wc_tax_rate_classes',
|
||||
'wc_reserved_stock' => 'wc_reserved_stock',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ( $tables as $name => $table ) {
|
||||
$wpdb->tables[] = $table;
|
||||
@ -250,7 +250,7 @@ class General_Compat {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function add_wp_typography_warning_message() {
|
||||
public function add_wp_typography_warning_message(): void {
|
||||
|
||||
WP_Ultimo()->notices->add(__('WP Typography "Smart Quotes" replacement is not compatible with WP Multisite WaaS and will be automatically disabled.', 'wp-ultimo'), 'warning');
|
||||
}
|
||||
@ -381,7 +381,7 @@ class General_Compat {
|
||||
* @since 2.0.4
|
||||
* @return void
|
||||
*/
|
||||
public function prevent_oxygen_cleanup_on_template_previewer() {
|
||||
public function prevent_oxygen_cleanup_on_template_previewer(): void {
|
||||
|
||||
add_action(
|
||||
'wp_head',
|
||||
@ -401,9 +401,9 @@ class General_Compat {
|
||||
* @param \WP_Ultimo\Domain_Mapping\SSO $sso The SSO class instance.
|
||||
* @return void
|
||||
*/
|
||||
public function add_sso_to_maintenance_mode($sso) {
|
||||
public function add_sso_to_maintenance_mode($sso): void {
|
||||
|
||||
add_action('wpmm_head', array($sso, 'enqueue_script'));
|
||||
add_action('wpmm_head', [$sso, 'enqueue_script']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -412,7 +412,7 @@ class General_Compat {
|
||||
*
|
||||
* @since 2.0.11
|
||||
*/
|
||||
public function run_wp_on_template_previewer() {
|
||||
public function run_wp_on_template_previewer(): void {
|
||||
|
||||
if (class_exists('Avada')) {
|
||||
do_action('wp'); //phpcs:disable
|
||||
@ -427,7 +427,7 @@ class General_Compat {
|
||||
*
|
||||
* @since 2.0.11
|
||||
*/
|
||||
public function clear_avada_cache($data) {
|
||||
public function clear_avada_cache($data): void {
|
||||
|
||||
switch_to_blog($data['blog_id']);
|
||||
|
||||
@ -462,14 +462,14 @@ class General_Compat {
|
||||
*
|
||||
* @since 2.0.11
|
||||
*/
|
||||
public function fix_fluent_pro_site_duplication() {
|
||||
public function fix_fluent_pro_site_duplication(): void {
|
||||
|
||||
$class_name = 'FluentCampaign\App\Hooks\Handlers\IntegrationHandler';
|
||||
|
||||
if (class_exists($class_name)) {
|
||||
|
||||
// Here we use this function due FluentCrm($class_name) returns an instance not working with remove_action
|
||||
$this->hard_remove_action('set_user_role', array($class_name, 'maybeAutoAlterTags'), 11);
|
||||
$this->hard_remove_action('set_user_role', [$class_name, 'maybeAutoAlterTags'], 11);
|
||||
|
||||
}
|
||||
|
||||
@ -482,20 +482,20 @@ class General_Compat {
|
||||
*
|
||||
* @since 2.0.20
|
||||
*/
|
||||
public function fix_rank_math_site_creation() {
|
||||
public function fix_rank_math_site_creation(): void {
|
||||
|
||||
$class_names = array(
|
||||
$class_names = [
|
||||
'RankMath\Installer',
|
||||
'RankMathPro\Installer',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($class_names as $class_name) {
|
||||
|
||||
if (class_exists($class_name)) {
|
||||
|
||||
// HankMath does not provide a instance of the activation class
|
||||
$this->hard_remove_action('wpmu_new_blog', array($class_name, 'activate_blog'), 10);
|
||||
$this->hard_remove_action('wp_initialize_site', array($class_name, 'initialize_site'), 10);
|
||||
$this->hard_remove_action('wpmu_new_blog', [$class_name, 'activate_blog'], 10);
|
||||
$this->hard_remove_action('wp_initialize_site', [$class_name, 'initialize_site'], 10);
|
||||
|
||||
}
|
||||
|
||||
@ -511,19 +511,19 @@ class General_Compat {
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public function fix_wp_e_signature_site_creation() {
|
||||
public function fix_wp_e_signature_site_creation(): void {
|
||||
|
||||
$class_names = array(
|
||||
$class_names = [
|
||||
'ESIG_SAD',
|
||||
'ESIG_SIF',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($class_names as $class_name) {
|
||||
|
||||
if (class_exists($class_name)) {
|
||||
|
||||
// WP E-Signature does not provide a instance of the activation class
|
||||
$this->hard_remove_action('wpmu_new_blog', array($class_name, 'activate_new_site'), 10);
|
||||
$this->hard_remove_action('wpmu_new_blog', [$class_name, 'activate_new_site'], 10);
|
||||
|
||||
}
|
||||
|
||||
@ -541,7 +541,7 @@ class General_Compat {
|
||||
* @param int $priority The The action priority.
|
||||
* @return void
|
||||
*/
|
||||
public function hard_remove_action($tag, $handler, $priority) {
|
||||
public function hard_remove_action($tag, $handler, $priority): void {
|
||||
|
||||
global $wp_filter;
|
||||
|
||||
@ -555,7 +555,7 @@ class General_Compat {
|
||||
|
||||
foreach($wp_filter[$tag][$priority] as $handler_key => $filter_handler) {
|
||||
|
||||
if(strpos((string) $handler_key, (string) $handler[1]) !== false && is_array($filter_handler['function']) && is_a($filter_handler['function'][0], $handler[0]) && $filter_handler['function'][1] === $handler[1]) {
|
||||
if(str_contains((string) $handler_key, (string) $handler[1]) && is_array($filter_handler['function']) && is_a($filter_handler['function'][0], $handler[0]) && $filter_handler['function'][1] === $handler[1]) {
|
||||
|
||||
$handler_id = $handler_key;
|
||||
|
||||
@ -579,7 +579,7 @@ class General_Compat {
|
||||
* @since 2.1.1
|
||||
* @return void
|
||||
*/
|
||||
public function remove_perfmatters_checkout_dep() {
|
||||
public function remove_perfmatters_checkout_dep(): void {
|
||||
|
||||
if (is_main_site() || is_admin()) {
|
||||
|
||||
|
@ -47,10 +47,10 @@ class Gutenberg_Support {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
if ($this->should_load()) {
|
||||
add_action('admin_enqueue_scripts', array($this, 'add_scripts'));
|
||||
add_action('admin_enqueue_scripts', [$this, 'add_scripts']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,9 +60,9 @@ class Gutenberg_Support {
|
||||
* @since 1.9.14
|
||||
* @return void
|
||||
*/
|
||||
public function add_scripts() {
|
||||
public function add_scripts(): void {
|
||||
|
||||
wp_register_script('wu-gutenberg-support', wu_get_asset('gutenberg-support.js', 'js'), array('jquery'), wu_get_version(), true);
|
||||
wp_register_script('wu-gutenberg-support', wu_get_asset('gutenberg-support.js', 'js'), ['jquery'], wu_get_version(), true);
|
||||
|
||||
// translators: the placeholder is replaced with the network name.
|
||||
$preview_message = apply_filters('wu_gutenberg_support_preview_message', sprintf(__('<strong>%s</strong> is generating the preview...', 'wp-ultimo'), get_network_option(null, 'site_name')));
|
||||
@ -70,10 +70,10 @@ class Gutenberg_Support {
|
||||
wp_localize_script(
|
||||
'wu-gutenberg-support',
|
||||
'wu_gutenberg',
|
||||
array(
|
||||
[
|
||||
'logo' => esc_url(wu_get_network_logo()),
|
||||
'replacement_message' => $preview_message,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-gutenberg-support');
|
||||
|
@ -44,19 +44,19 @@ class Legacy_Shortcodes {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_shortcode('wu_paying_users', array($this, 'paying_users'));
|
||||
add_shortcode('wu_paying_users', [$this, 'paying_users']);
|
||||
|
||||
add_shortcode('wu_user_meta', array($this, 'user_meta'));
|
||||
add_shortcode('wu_user_meta', [$this, 'user_meta']);
|
||||
|
||||
add_shortcode('wu_plan_link', array($this, 'plan_link'));
|
||||
add_shortcode('wu_plan_link', [$this, 'plan_link']);
|
||||
|
||||
add_shortcode('wu_restricted_content', array($this, 'restricted_content'));
|
||||
add_shortcode('wu_restricted_content', [$this, 'restricted_content']);
|
||||
|
||||
add_shortcode('wu_pricing_table', array($this, 'pricing_table'));
|
||||
add_shortcode('wu_pricing_table', [$this, 'pricing_table']);
|
||||
|
||||
add_shortcode('wu_templates_list', array($this, 'templates_list'));
|
||||
add_shortcode('wu_templates_list', [$this, 'templates_list']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,12 +86,12 @@ class Legacy_Shortcodes {
|
||||
}
|
||||
|
||||
$atts = shortcode_atts(
|
||||
array(
|
||||
[
|
||||
'user_id' => $user_id,
|
||||
'meta_name' => 'first_name',
|
||||
'default' => false,
|
||||
'unique' => true,
|
||||
),
|
||||
],
|
||||
$atts,
|
||||
'wu_user_meta'
|
||||
);
|
||||
@ -106,7 +106,7 @@ class Legacy_Shortcodes {
|
||||
$value = implode(', ', $value);
|
||||
}
|
||||
|
||||
return $value ? $value : '--';
|
||||
return $value ?: '--';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -121,12 +121,12 @@ class Legacy_Shortcodes {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$atts = shortcode_atts(array(), $atts, 'wu_paying_users');
|
||||
$atts = shortcode_atts([], $atts, 'wu_paying_users');
|
||||
|
||||
$paying_customers = wu_get_customers(
|
||||
array(
|
||||
[
|
||||
'count' => true,
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
return $paying_customers;
|
||||
@ -143,11 +143,11 @@ class Legacy_Shortcodes {
|
||||
public function plan_link($atts) {
|
||||
|
||||
$atts = shortcode_atts(
|
||||
array(
|
||||
[
|
||||
'plan_id' => 0,
|
||||
'plan_freq' => 1,
|
||||
'skip_plan' => 1,
|
||||
),
|
||||
],
|
||||
$atts,
|
||||
'wu_plan_link'
|
||||
);
|
||||
@ -157,7 +157,7 @@ class Legacy_Shortcodes {
|
||||
*
|
||||
* @since 1.5.1
|
||||
*/
|
||||
foreach (array('plan_id', 'plan_freq') as $att) {
|
||||
foreach (['plan_id', 'plan_freq'] as $att) {
|
||||
$atts[ $att ] = wu_extract_number($atts[ $att ]);
|
||||
}
|
||||
|
||||
@ -200,14 +200,14 @@ class Legacy_Shortcodes {
|
||||
public function restricted_content($atts, $content) {
|
||||
|
||||
$atts = shortcode_atts(
|
||||
array(
|
||||
[
|
||||
'plan_id' => false,
|
||||
'product_id' => false,
|
||||
'only_active' => true,
|
||||
'only_logged' => false,
|
||||
'exclude_trials' => false,
|
||||
'from_request' => false,
|
||||
),
|
||||
],
|
||||
$atts,
|
||||
'wu_restricted_content'
|
||||
);
|
||||
@ -218,9 +218,9 @@ class Legacy_Shortcodes {
|
||||
return __('You need to pass a valid plan ID.', 'wp-ultimo');
|
||||
}
|
||||
|
||||
$query_products = get_query_var('products', array());
|
||||
$query_products = get_query_var('products', []);
|
||||
|
||||
$request_products = array();
|
||||
$request_products = [];
|
||||
|
||||
foreach ($query_products as $product) {
|
||||
$product = wu_get_product($product);
|
||||
@ -238,8 +238,8 @@ class Legacy_Shortcodes {
|
||||
|
||||
$else = '[wu_default_content]';
|
||||
|
||||
if (strpos($content, $else) !== false) {
|
||||
list($if, $else) = explode($else, $content, 2);
|
||||
if (str_contains($content, $else)) {
|
||||
[$if, $else] = explode($else, $content, 2);
|
||||
} else {
|
||||
$if = $content;
|
||||
|
||||
@ -258,7 +258,7 @@ class Legacy_Shortcodes {
|
||||
|
||||
if ($membership && $should_check && ! $from_request) {
|
||||
$membership_products = array_merge(
|
||||
array($membership->get_plan_id()),
|
||||
[$membership->get_plan_id()],
|
||||
$membership->get_addon_ids()
|
||||
);
|
||||
|
||||
@ -297,7 +297,7 @@ class Legacy_Shortcodes {
|
||||
global $post;
|
||||
|
||||
$atts = shortcode_atts(
|
||||
array(
|
||||
[
|
||||
'primary_color' => wu_get_setting('primary_color', '#00a1ff'),
|
||||
'accent_color' => wu_get_setting('accent_color', '#78b336'),
|
||||
'default_pricing_option' => wu_get_setting('default_pricing_option', 1),
|
||||
@ -306,7 +306,7 @@ class Legacy_Shortcodes {
|
||||
// New Options
|
||||
'layout' => 'legacy',
|
||||
'period_selector_layout' => 'legacy',
|
||||
),
|
||||
],
|
||||
$atts,
|
||||
'wu_pricing_table'
|
||||
);
|
||||
@ -328,46 +328,46 @@ class Legacy_Shortcodes {
|
||||
|
||||
$checkout_form = new \WP_Ultimo\Models\Checkout_Form();
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$search_arguments = array(
|
||||
$search_arguments = [
|
||||
'fields' => 'ids',
|
||||
);
|
||||
];
|
||||
|
||||
if ($atts['plan_id']) {
|
||||
$search_arguments['id__in'] = $atts['plan_id'];
|
||||
}
|
||||
|
||||
if ($atts['show_selector']) {
|
||||
$fields[] = array(
|
||||
$fields[] = [
|
||||
'step' => 'checkout',
|
||||
'name' => '',
|
||||
'type' => 'period_selection',
|
||||
'id' => 'period_selection',
|
||||
'period_selection_template' => $atts['period_selector_layout'],
|
||||
'period_options' => array(
|
||||
array(
|
||||
'period_options' => [
|
||||
[
|
||||
'duration' => 1,
|
||||
'duration_unit' => 'month',
|
||||
'label' => __('Monthly', 'wp-ultimo'),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'duration' => 3,
|
||||
'duration_unit' => 'month',
|
||||
'label' => __('Quarterly', 'wp-ultimo'),
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'duration' => 1,
|
||||
'duration_unit' => 'year',
|
||||
'label' => __('Yearly', 'wp-ultimo'),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$layout = $atts['layout'];
|
||||
|
||||
$fields[] = array(
|
||||
$fields[] = [
|
||||
'step' => 'checkout',
|
||||
'name' => __('Plans', 'wp-ultimo'),
|
||||
'type' => 'pricing_table',
|
||||
@ -376,29 +376,29 @@ class Legacy_Shortcodes {
|
||||
'pricing_table_products' => implode(',', wu_get_plans($search_arguments)),
|
||||
'pricing_table_template' => $layout,
|
||||
'element_classes' => $layout === 'legacy' ? 'wu-content-plan' : '',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* If not using the legacy checkout,
|
||||
* we'll need a submit field.
|
||||
*/
|
||||
if ($layout !== 'legacy') {
|
||||
$fields[] = array(
|
||||
$fields[] = [
|
||||
'step' => 'checkout',
|
||||
'name' => __('Get Started →', 'wp-ultimo'),
|
||||
'type' => 'submit_button',
|
||||
'id' => 'checkout',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$steps = array(
|
||||
array(
|
||||
$steps = [
|
||||
[
|
||||
'id' => 'checkout',
|
||||
'name' => __('Checkout', 'wp-ultimo'),
|
||||
'desc' => '',
|
||||
'fields' => $fields,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$checkout = \WP_Ultimo\Checkout\Checkout::get_instance();
|
||||
|
||||
@ -433,30 +433,30 @@ class Legacy_Shortcodes {
|
||||
/*
|
||||
* Adds the product fields to keep them.
|
||||
*/
|
||||
$final_fields['products[]'] = array(
|
||||
$final_fields['products[]'] = [
|
||||
'type' => 'hidden',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-for' => '(product, index) in unique_products',
|
||||
'v-model' => 'products[index]',
|
||||
'v-bind:id' => '"products-" + index',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$final_fields['pre-flight'] = array(
|
||||
$final_fields['pre-flight'] = [
|
||||
'type' => 'hidden',
|
||||
'value' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
return wu_get_template_contents(
|
||||
'checkout/form',
|
||||
array(
|
||||
[
|
||||
'step' => $checkout_form->get_step('checkout', true),
|
||||
'step_name' => 'checkout',
|
||||
'checkout_form_name' => 'wu_pricing_table',
|
||||
'checkout_form_action' => add_query_arg('pre-flight', 1, wu_get_registration_url()),
|
||||
'display_title' => '',
|
||||
'final_fields' => $final_fields,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -477,14 +477,14 @@ class Legacy_Shortcodes {
|
||||
global $post;
|
||||
|
||||
$atts = shortcode_atts(
|
||||
array(
|
||||
[
|
||||
'show_filters' => true,
|
||||
'show_title' => true,
|
||||
'templates' => false,
|
||||
'cols' => 3,
|
||||
'layout' => 'legacy',
|
||||
'checkout_page' => wu_guess_registration_page(),
|
||||
),
|
||||
],
|
||||
$atts,
|
||||
'wu_templates_list'
|
||||
);
|
||||
@ -512,33 +512,33 @@ class Legacy_Shortcodes {
|
||||
|
||||
$checkout_form = new \WP_Ultimo\Models\Checkout_Form();
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$search_arguments = array(
|
||||
$search_arguments = [
|
||||
'fields' => 'ids',
|
||||
);
|
||||
];
|
||||
|
||||
$layout = $atts['layout'];
|
||||
|
||||
$fields[] = array(
|
||||
$fields[] = [
|
||||
'step' => 'checkout',
|
||||
'name' => __('Templates', 'wp-ultimo'),
|
||||
'type' => 'template_selection',
|
||||
'id' => 'template_selection',
|
||||
'template_selection_sites' => implode(',', $templates ? $templates : wu_get_site_templates($search_arguments)),
|
||||
'template_selection_sites' => implode(',', $templates ?: wu_get_site_templates($search_arguments)),
|
||||
'template_selection_template' => $layout,
|
||||
'cols' => $atts['cols'],
|
||||
'element_classes' => $layout === 'legacy' ? 'wu-content-templates' : '',
|
||||
);
|
||||
];
|
||||
|
||||
$steps = array(
|
||||
array(
|
||||
$steps = [
|
||||
[
|
||||
'id' => 'checkout',
|
||||
'name' => __('Checkout', 'wp-ultimo'),
|
||||
'desc' => '',
|
||||
'fields' => $fields,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$checkout = \WP_Ultimo\Checkout\Checkout::get_instance();
|
||||
|
||||
@ -570,23 +570,23 @@ class Legacy_Shortcodes {
|
||||
'after'
|
||||
);
|
||||
|
||||
$final_fields['pre-flight'] = array(
|
||||
$final_fields['pre-flight'] = [
|
||||
'type' => 'hidden',
|
||||
'value' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
$page_url = wu_switch_blog_and_run(fn() => get_permalink($atts['checkout_page']));
|
||||
|
||||
return wu_get_template_contents(
|
||||
'checkout/form',
|
||||
array(
|
||||
[
|
||||
'step' => $checkout_form->get_step('checkout', true),
|
||||
'step_name' => 'checkout',
|
||||
'checkout_form_name' => 'wu_templates_list',
|
||||
'checkout_form_action' => add_query_arg('pre-flight', 1, $page_url),
|
||||
'display_title' => '',
|
||||
'final_fields' => $final_fields,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
/**
|
||||
|
@ -49,10 +49,10 @@ class Multiple_Accounts_Compat {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
// Add the settings to enable or disable this feature.
|
||||
add_action('wu_settings_login', array($this, 'add_settings'), 10);
|
||||
add_action('wu_settings_login', [$this, 'add_settings'], 10);
|
||||
|
||||
if ($this->should_load()) {
|
||||
|
||||
@ -60,28 +60,28 @@ class Multiple_Accounts_Compat {
|
||||
$this->fix_object_cache_on_multiple_accounts();
|
||||
|
||||
// Unset user, if the current one is not part of the site.
|
||||
add_action('plugins_loaded', array($this, 'maybe_unset_current_user'), -10);
|
||||
add_action('plugins_loaded', [$this, 'maybe_unset_current_user'], -10);
|
||||
|
||||
// prevents woocommerce from adding customers to sites without our knowledge
|
||||
add_action('woocommerce_process_login_errors', array($this, 'prevent_woo_from_adding_to_blog'), -10);
|
||||
add_action('woocommerce_process_login_errors', [$this, 'prevent_woo_from_adding_to_blog'], -10);
|
||||
|
||||
// Add the filter to prevent email blocking
|
||||
add_filter('email_exists', array($this, 'allow_duplicate_emails'), 10, 2);
|
||||
add_filter('email_exists', [$this, 'allow_duplicate_emails'], 10, 2);
|
||||
|
||||
// Add the filter to prevent email blocking
|
||||
add_filter('query', array($this, 'fix_user_query'), -999);
|
||||
add_filter('query', [$this, 'fix_user_query'], -999);
|
||||
|
||||
// Action in the login to debug the login info
|
||||
add_filter('authenticate', array($this, 'fix_login'), 50000, 3);
|
||||
add_filter('authenticate', [$this, 'fix_login'], 50000, 3);
|
||||
|
||||
// Now we handle the password thing
|
||||
add_action('init', array($this, 'handle_reset_password'), 2000);
|
||||
add_action('init', [$this, 'handle_reset_password'], 2000);
|
||||
|
||||
// Now we add a custom column in that table to allow the admin to control them
|
||||
add_filter('wpmu_users_columns', array($this, 'add_multiple_account_column'));
|
||||
add_filter('wpmu_users_columns', [$this, 'add_multiple_account_column']);
|
||||
|
||||
// Adds the number of additional accounts.
|
||||
add_filter('manage_users_custom_column', array($this, 'add_column_content'), 10, 3);
|
||||
add_filter('manage_users_custom_column', [$this, 'add_column_content'], 10, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,9 +95,9 @@ class Multiple_Accounts_Compat {
|
||||
*/
|
||||
public function fix_object_cache_on_multiple_accounts(): void {
|
||||
|
||||
$to_remove = array(
|
||||
$to_remove = [
|
||||
'useremail',
|
||||
);
|
||||
];
|
||||
|
||||
if (function_exists('wp_cache_add_non_persistent_groups')) {
|
||||
wp_cache_add_non_persistent_groups($to_remove);
|
||||
@ -118,7 +118,7 @@ class Multiple_Accounts_Compat {
|
||||
|
||||
$search = "\$db->get_row(\"SELECT * FROM $wpdb->users WHERE user_email";
|
||||
|
||||
if ( strpos($wpdb->func_call, $search) === 0) {
|
||||
if ( str_starts_with($wpdb->func_call, $search)) {
|
||||
$prefix = "SELECT * FROM $wpdb->users WHERE user_email";
|
||||
|
||||
$last = substr($query, strlen($prefix));
|
||||
@ -187,7 +187,7 @@ class Multiple_Accounts_Compat {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_unset_current_user() {
|
||||
public function maybe_unset_current_user(): void {
|
||||
|
||||
global $current_user;
|
||||
|
||||
@ -254,27 +254,27 @@ class Multiple_Accounts_Compat {
|
||||
*
|
||||
* @return void.
|
||||
*/
|
||||
public function add_settings() {
|
||||
public function add_settings(): void {
|
||||
|
||||
wu_register_settings_field(
|
||||
'login-and-registration',
|
||||
'multiple_accounts_header',
|
||||
array(
|
||||
[
|
||||
'title' => __('Multiple Accounts', 'wp-ultimo'),
|
||||
'desc' => __('Options related to the Multiple Accounts feature.', 'wp-ultimo'),
|
||||
'type' => 'header',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
wu_register_settings_field(
|
||||
'login-and-registration',
|
||||
'enable_multiple_accounts',
|
||||
array(
|
||||
[
|
||||
'title' => __('Enable Multiple Accounts', 'wp-ultimo'),
|
||||
'desc' => __('Allow users to have accounts in different sites with the same email address. This is useful when running stores with WooCommerce and other plugins, for example.', 'wp-ultimo') . ' ' . sprintf('<a href="%s" target="_blank">%s</a>', wu_get_documentation_url('multiple-accounts'), __('Read More', 'wp-ultimo')),
|
||||
'type' => 'toggle',
|
||||
'default' => 0,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -303,7 +303,7 @@ class Multiple_Accounts_Compat {
|
||||
* @param int $user_id The ID of the user.
|
||||
* @return void
|
||||
*/
|
||||
public function add_column_content($null, $column, $user_id) {
|
||||
public function add_column_content($null, $column, $user_id): void {
|
||||
|
||||
if ($column === 'multiple_accounts') {
|
||||
|
||||
@ -312,11 +312,11 @@ class Multiple_Accounts_Compat {
|
||||
|
||||
// Get all the accounts with the same email
|
||||
$users = new \WP_User_Query(
|
||||
array(
|
||||
[
|
||||
'blog_id' => 0,
|
||||
'search' => $user->user_email,
|
||||
'fields' => array('ID', 'user_login'),
|
||||
)
|
||||
'fields' => ['ID', 'user_login'],
|
||||
]
|
||||
);
|
||||
|
||||
// translators: the %d is the account count for that email address.
|
||||
@ -334,7 +334,7 @@ class Multiple_Accounts_Compat {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_reset_password() {
|
||||
public function handle_reset_password(): void {
|
||||
|
||||
// Only run in the right case
|
||||
if (wu_request('action') === 'retrievepassword' || wu_request('wc_reset_password')) {
|
||||
@ -364,9 +364,9 @@ class Multiple_Accounts_Compat {
|
||||
// Sets the right user to be returned;
|
||||
$has_user = false;
|
||||
|
||||
$query = array(
|
||||
$query = [
|
||||
'search' => $email,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* When the user id is present, we use it
|
||||
@ -377,9 +377,9 @@ class Multiple_Accounts_Compat {
|
||||
* @since 2.0.11
|
||||
*/
|
||||
if ($user_id) {
|
||||
$query['include'] = array(
|
||||
$query['include'] = [
|
||||
absint($user_id),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// Now we search for the correct user based on the password and the blog information
|
||||
@ -418,7 +418,7 @@ class Multiple_Accounts_Compat {
|
||||
// Sets the right user to be returned;
|
||||
$user = $this->get_right_user($username, $password);
|
||||
|
||||
return $user ? $user : null;
|
||||
return $user ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -447,9 +447,9 @@ class Multiple_Accounts_Compat {
|
||||
|
||||
$args = array_slice(func_get_args(), 2);
|
||||
|
||||
$args = array_merge(array($capability), $args);
|
||||
$args = array_merge([$capability], $args);
|
||||
|
||||
$can = call_user_func_array(\Closure::fromCallable(array($current_user, 'has_cap')), $args);
|
||||
$can = call_user_func_array(\Closure::fromCallable([$current_user, 'has_cap']), $args);
|
||||
|
||||
if ($switched) {
|
||||
restore_current_blog();
|
||||
@ -473,7 +473,7 @@ class Multiple_Accounts_Compat {
|
||||
|
||||
// $hash = wp_hash_password($password);
|
||||
// Now we search for the correct user based on the password and the blog information
|
||||
$users = new \WP_User_Query(array('search' => $email));
|
||||
$users = new \WP_User_Query(['search' => $email]);
|
||||
|
||||
// Loop the results and check which one is in this group
|
||||
foreach ($users->results as $user_with_email) {
|
||||
|
@ -29,11 +29,11 @@ class Product_Compat {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
add_filter('wu_product_options_sections', array($this, 'add_legacy_section'), 100, 2);
|
||||
add_filter('wu_product_options_sections', [$this, 'add_legacy_section'], 100, 2);
|
||||
|
||||
add_filter('update_post_metadata', array($this, 'check_update_plan'), 10, 5);
|
||||
add_filter('update_post_metadata', [$this, 'check_update_plan'], 10, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,47 +93,47 @@ class Product_Compat {
|
||||
*/
|
||||
public function add_legacy_section($sections, $object) {
|
||||
|
||||
$sections['legacy_options_core'] = array(
|
||||
$sections['legacy_options_core'] = [
|
||||
'title' => __('Legacy Options', 'wp-ultimo'),
|
||||
'desc' => __('Options used by old 1.X versions. ', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-spreadsheet',
|
||||
'state' => array(
|
||||
'state' => [
|
||||
'legacy_options' => $object->get_legacy_options(),
|
||||
),
|
||||
'fields' => array(
|
||||
'legacy_options' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'legacy_options' => [
|
||||
'type' => 'toggle',
|
||||
'value' => $object->get_legacy_options(),
|
||||
'title' => __('Toggle Legacy Options', 'wp-ultimo'),
|
||||
'desc' => __('Toggle this option to edit legacy options.', 'wp-ultimo'),
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'legacy_options',
|
||||
),
|
||||
),
|
||||
'featured_plan' => array(
|
||||
],
|
||||
],
|
||||
'featured_plan' => [
|
||||
'type' => 'toggle',
|
||||
'value' => $object->is_featured_plan(),
|
||||
'title' => __('Featured Plan', 'wp-ultimo'),
|
||||
'desc' => __('Toggle this option to mark this product as featured on the legacy pricing tables.', 'wp-ultimo'),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'legacy_options',
|
||||
),
|
||||
),
|
||||
'feature_list' => array(
|
||||
],
|
||||
],
|
||||
'feature_list' => [
|
||||
'type' => 'textarea',
|
||||
'title' => __('Features List', 'wp-ultimo'),
|
||||
'placeholder' => __('E.g. Feature 1', 'wp-ultimo') . PHP_EOL . __('Feature 2', 'wp-ultimo'),
|
||||
'desc' => __('Add a feature per line. These will be shown on the pricing tables.', 'wp-ultimo'),
|
||||
'value' => $object->get_feature_list(),
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'legacy_options',
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'rows' => 6,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
Reference in New Issue
Block a user