Use new code style
This commit is contained in:
@ -27,6 +27,5 @@ class AS_Admin_View {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function init() {} // end init;
|
||||
|
||||
} // end class AS_Admin_View;
|
||||
public function init() {}
|
||||
}
|
||||
|
@ -32,8 +32,7 @@ class Discount_Code_Compat {
|
||||
public function init() {
|
||||
|
||||
add_filter('update_post_metadata', array($this, 'check_update_coupon'), 10, 5);
|
||||
|
||||
} // end init;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves meta data from old plugins on the new plugin.
|
||||
@ -51,22 +50,18 @@ class Discount_Code_Compat {
|
||||
/*
|
||||
* Check if we are in the main site of the network.
|
||||
*/
|
||||
if (!is_main_site()) {
|
||||
|
||||
if ( ! is_main_site()) {
|
||||
return;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if we have a new entity with this ID.
|
||||
*/
|
||||
$migrated_discount_code = wu_get_discount_code($object_id);
|
||||
|
||||
if (!$migrated_discount_code) {
|
||||
|
||||
if ( ! $migrated_discount_code) {
|
||||
return;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevent double prefixing.
|
||||
@ -83,7 +78,5 @@ class Discount_Code_Compat {
|
||||
* returning anything else will prevent meta data from being saved.
|
||||
*/
|
||||
return null;
|
||||
|
||||
} // end check_update_coupon;
|
||||
|
||||
} // end class Discount_Code_Compat;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,5 @@ class Domain_Mapping_Compat {
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
|
||||
} // end init;
|
||||
|
||||
} // end class Domain_Mapping_Compat;
|
||||
}
|
||||
}
|
||||
|
@ -36,8 +36,7 @@ class Elementor_Compat {
|
||||
add_filter('wu_should_redirect_to_primary_domain', array($this, 'maybe_prevent_redirection'));
|
||||
|
||||
add_action('elementor/widget/shortcode/skins_init', array($this, 'maybe_setup_preview'));
|
||||
|
||||
} // end init;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure we force elementor to regenerate the styles when necessary.
|
||||
@ -48,31 +47,24 @@ class Elementor_Compat {
|
||||
*/
|
||||
public function regenerate_css($site) {
|
||||
|
||||
if (!class_exists('\Elementor\Plugin')) {
|
||||
|
||||
if ( ! class_exists('\Elementor\Plugin')) {
|
||||
return;
|
||||
}
|
||||
|
||||
} // end if;
|
||||
|
||||
if (!isset($site['site_id'])) {
|
||||
|
||||
if ( ! isset($site['site_id'])) {
|
||||
return;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
switch_to_blog($site['site_id']);
|
||||
|
||||
$file_manager = \Elementor\Plugin::$instance->files_manager; // phpcs:ignore
|
||||
|
||||
if (!empty($file_manager)) {
|
||||
|
||||
if ( ! empty($file_manager)) {
|
||||
$file_manager->clear_cache();
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
restore_current_blog();
|
||||
|
||||
} // end regenerate_css;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents redirection to primary domain when in Elementor preview mode.
|
||||
@ -85,8 +77,7 @@ class Elementor_Compat {
|
||||
public function maybe_prevent_redirection($should_redirect) {
|
||||
|
||||
return wu_request('elementor-preview', false) === false ? $should_redirect : false;
|
||||
|
||||
} // end maybe_prevent_redirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe adds the setup preview for elements inside elementor.
|
||||
@ -102,11 +93,7 @@ class Elementor_Compat {
|
||||
);
|
||||
|
||||
if (in_array(wu_request('action'), $elementor_actions, true)) {
|
||||
|
||||
wu_element_setup_preview();
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end maybe_setup_preview;
|
||||
|
||||
} // end class Elementor_Compat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,14 +35,14 @@ class General_Compat {
|
||||
* Woocommerce
|
||||
*
|
||||
* Removes the default woocommerce hook on switch_blog to another more performant
|
||||
*
|
||||
*
|
||||
* @see https://wordpress.org/plugins/woocommerce/
|
||||
*/
|
||||
add_action('woocommerce_loaded', array($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'));
|
||||
@ -67,7 +67,7 @@ class General_Compat {
|
||||
|
||||
/**
|
||||
* WP Hide Pro
|
||||
*
|
||||
*
|
||||
* @see https://wp-hide.com/
|
||||
*/
|
||||
add_filter('wu_append_preview_parameter', array($this, 'fix_wp_hide_preview_url'));
|
||||
@ -142,15 +142,16 @@ class General_Compat {
|
||||
* @since 2.0.0
|
||||
* @see https://getkeypress.com/dns-manager/
|
||||
*/
|
||||
add_action('wu_before_pending_site_published', function() {
|
||||
add_action(
|
||||
'wu_before_pending_site_published',
|
||||
function () {
|
||||
|
||||
if (function_exists('KPDNS')) {
|
||||
|
||||
KPDNS(); // phpcs:ignore
|
||||
|
||||
} // end if;
|
||||
|
||||
}, 5); // need to hook before 10
|
||||
if (function_exists('KPDNS')) {
|
||||
KPDNS(); // phpcs:ignore
|
||||
}
|
||||
},
|
||||
5
|
||||
); // need to hook before 10
|
||||
|
||||
/**
|
||||
* Perfmatters.
|
||||
@ -167,17 +168,16 @@ class General_Compat {
|
||||
*
|
||||
* @since 2.0.5
|
||||
*/
|
||||
add_action('wp', function() {
|
||||
add_action(
|
||||
'wp',
|
||||
function () {
|
||||
|
||||
if (wu_request('et_pb_preview')) {
|
||||
|
||||
wu_element_setup_preview();
|
||||
|
||||
} // end if;
|
||||
|
||||
});
|
||||
|
||||
} // end init;
|
||||
if (wu_request('et_pb_preview')) {
|
||||
wu_element_setup_preview();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixes a performance problem with Woocommerce.
|
||||
@ -205,22 +205,20 @@ class General_Compat {
|
||||
);
|
||||
|
||||
foreach ( $tables as $name => $table ) {
|
||||
|
||||
$wpdb->tables[] = $table;
|
||||
}
|
||||
|
||||
} // end foreach;
|
||||
add_action(
|
||||
'switch_blog',
|
||||
function () use ($wpdb, $tables) {
|
||||
|
||||
add_action('switch_blog', function() use ($wpdb, $tables) {
|
||||
|
||||
foreach ( $tables as $name => $table ) {
|
||||
|
||||
$wpdb->$name = $wpdb->prefix . $table;
|
||||
|
||||
} // end foreach;
|
||||
|
||||
}, 0);
|
||||
|
||||
} // end replace_wc_wpdb_table_fix;
|
||||
foreach ( $tables as $name => $table ) {
|
||||
$wpdb->$name = $wpdb->prefix . $table;
|
||||
}
|
||||
},
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixes incompatibility with the plugin WP Typography.
|
||||
@ -244,8 +242,7 @@ class General_Compat {
|
||||
$settings['smartQuotes'] = false;
|
||||
|
||||
return $settings;
|
||||
|
||||
} // end fix_wp_typography;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a warning message to let customers know why smart quotes are not working.
|
||||
@ -256,8 +253,7 @@ class General_Compat {
|
||||
public function add_wp_typography_warning_message() {
|
||||
|
||||
WP_Ultimo()->notices->add(__('WP Typography "Smart Quotes" replacement is not compatible with WP Multisite WaaS and will be automatically disabled.', 'wp-ultimo'), 'warning');
|
||||
|
||||
} // end add_wp_typography_warning_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixes brizy media URLs while on Ultimo's template preview
|
||||
@ -278,8 +274,7 @@ class General_Compat {
|
||||
public function fix_brizy_preview_url($value) {
|
||||
|
||||
return class_exists('Brizy_Editor') ? false : $value;
|
||||
|
||||
} // end fix_brizy_preview_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix the Brizy editor with domain mapping.
|
||||
@ -292,20 +287,15 @@ class General_Compat {
|
||||
public function fix_brizy_editor_screen($should_redirect) {
|
||||
|
||||
if (class_exists('\Brizy_Editor')) {
|
||||
|
||||
$key = \Brizy_Editor::prefix('-edit-iframe');
|
||||
|
||||
if (wu_request($key, null) !== null) {
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
}
|
||||
|
||||
return $should_redirect;
|
||||
|
||||
} // end fix_brizy_editor_screen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix the Divi editor with domain mapping.
|
||||
@ -318,14 +308,11 @@ class General_Compat {
|
||||
public function fix_divi_editor_screen(bool $should_redirect): bool {
|
||||
|
||||
if (isset($_GET['et_fb']) && (bool) $_GET['et_fb']) {
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return $should_redirect;
|
||||
|
||||
} // end fix_divi_editor_screen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixes WP Hide Pro URLs while on Ultimo's template preview
|
||||
@ -337,8 +324,7 @@ class General_Compat {
|
||||
public function fix_wp_hide_preview_url($value) {
|
||||
|
||||
return class_exists('WPH') ? false : $value;
|
||||
|
||||
} // end fix_wp_hide_preview_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix the load URL for WP Frontend Admin.
|
||||
@ -353,8 +339,7 @@ class General_Compat {
|
||||
public function fix_frontend_admin_loading_url($final_url, $page_path_only, $blog_id) {
|
||||
|
||||
return wu_restore_original_url($final_url, $blog_id);
|
||||
|
||||
} // end fix_frontend_admin_loading_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Oxygen renders things very strangely, so we need to handle it separately.
|
||||
@ -369,10 +354,8 @@ class General_Compat {
|
||||
public function maybe_parse_oxygen_content($should_enqueue, $post, $shortcode_tag) {
|
||||
|
||||
if (function_exists('oxygen_vsb_current_user_can_access') === false) {
|
||||
|
||||
return $should_enqueue;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$shortcode_content = get_post_meta($post->ID, 'ct_builder_shortcodes', true);
|
||||
|
||||
@ -382,17 +365,14 @@ class General_Compat {
|
||||
* Oxygen now base64 encodes shortcodes for some reason...
|
||||
* Supporting third-party page builders is such a pain.
|
||||
*/
|
||||
if (!$has_shortcode) {
|
||||
|
||||
if ( ! $has_shortcode) {
|
||||
$base64 = base64_encode("[$shortcode_tag]");
|
||||
|
||||
$has_shortcode = strpos((string) $shortcode_content, $base64);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return $has_shortcode;
|
||||
|
||||
} // end maybe_parse_oxygen_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent Oxygen from removing the real wp_head hook from the template
|
||||
@ -403,13 +383,15 @@ class General_Compat {
|
||||
*/
|
||||
public function prevent_oxygen_cleanup_on_template_previewer() {
|
||||
|
||||
add_action('wp_head', function() {
|
||||
add_action(
|
||||
'wp_head',
|
||||
function () {
|
||||
|
||||
remove_action('wp_head', 'oxy_print_cached_css', 999999);
|
||||
|
||||
}, 10);
|
||||
|
||||
} // end prevent_oxygen_cleanup_on_template_previewer;
|
||||
remove_action('wp_head', 'oxy_print_cached_css', 999999);
|
||||
},
|
||||
10
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds SSO to WP Maintenance Mode.
|
||||
@ -422,8 +404,7 @@ class General_Compat {
|
||||
public function add_sso_to_maintenance_mode($sso) {
|
||||
|
||||
add_action('wpmm_head', array($sso, 'enqueue_script'));
|
||||
|
||||
} // end add_sso_to_maintenance_mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run wp action on template previewer to prevent some errors like
|
||||
@ -434,12 +415,11 @@ class General_Compat {
|
||||
public function run_wp_on_template_previewer() {
|
||||
|
||||
if (class_exists('Avada')) {
|
||||
|
||||
do_action('wp'); //phpcs:disable
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
} // end run_wp_on_template_previewer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run wp action on template previewer to prevent some errors like
|
||||
@ -467,13 +447,13 @@ class General_Compat {
|
||||
|
||||
fusion_reset_all_caches();
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
restore_current_blog();
|
||||
|
||||
} // end clear_avada_cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix the FluentCRM Pro on site duplication due to fc_meta table not exist
|
||||
@ -491,9 +471,9 @@ class General_Compat {
|
||||
// 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);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
} // end fix_fluent_pro_site_duplication;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes RankMath and RankMath Pro Installer::wpmu_new_blog action
|
||||
@ -517,11 +497,11 @@ class General_Compat {
|
||||
$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);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
|
||||
} // end fix_rank_math_site_creation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes WP E-Signature and WP E-Signature Business add-ons
|
||||
@ -545,11 +525,11 @@ class General_Compat {
|
||||
// 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);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
|
||||
} // end fix_wp_e_signature_site_creation;
|
||||
}
|
||||
|
||||
/**
|
||||
* A way to remove an action if instance is not available
|
||||
@ -569,7 +549,7 @@ class General_Compat {
|
||||
|
||||
return;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$handler_id = '';
|
||||
|
||||
@ -579,19 +559,19 @@ class General_Compat {
|
||||
|
||||
$handler_id = $handler_key;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
|
||||
if (!empty($handler_id)) {
|
||||
|
||||
remove_filter( $tag, $handler_id, $priority );
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
} // end hard_remove_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove action from perfamatters that disabled password strength meter script.
|
||||
@ -605,8 +585,8 @@ class General_Compat {
|
||||
|
||||
remove_action('wp_print_scripts', 'perfmatters_disable_password_strength_meter', 100);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
} // end remove_perfmatters_checkout_dep;
|
||||
}
|
||||
|
||||
} // end class General_Compat;
|
||||
}
|
||||
|
@ -35,14 +35,11 @@ class Gutenberg_Support {
|
||||
public function should_load() {
|
||||
|
||||
if (function_exists('has_blocks')) {
|
||||
|
||||
return true;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return apply_filters('wu_gutenberg_support_should_load', true);
|
||||
|
||||
} // end should_load;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Class, if we need it.
|
||||
@ -53,12 +50,9 @@ class Gutenberg_Support {
|
||||
public function init() {
|
||||
|
||||
if ($this->should_load()) {
|
||||
|
||||
add_action('admin_enqueue_scripts', array($this, 'add_scripts'));
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end init;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the Gutenberg Filters scripts.
|
||||
@ -70,16 +64,18 @@ class Gutenberg_Support {
|
||||
|
||||
wp_register_script('wu-gutenberg-support', wu_get_asset('gutenberg-support.js', 'js'), array('jquery'), wu_get_version(), true);
|
||||
|
||||
// translators: the placeholder is replaced with the network name.
|
||||
// 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')));
|
||||
|
||||
wp_localize_script('wu-gutenberg-support', 'wu_gutenberg', array(
|
||||
'logo' => esc_url(wu_get_network_logo()),
|
||||
'replacement_message' => $preview_message,
|
||||
));
|
||||
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');
|
||||
|
||||
} // end add_scripts;
|
||||
|
||||
} // end class Gutenberg_Support;
|
||||
}
|
||||
}
|
||||
|
@ -57,8 +57,7 @@ class Legacy_Shortcodes {
|
||||
add_shortcode('wu_pricing_table', array($this, 'pricing_table'));
|
||||
|
||||
add_shortcode('wu_templates_list', array($this, 'templates_list'));
|
||||
|
||||
} // end init;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of a user meta on the database.
|
||||
@ -81,39 +80,34 @@ class Legacy_Shortcodes {
|
||||
$customer = $site->get_customer();
|
||||
|
||||
if ($customer) {
|
||||
|
||||
$customer_id = $customer->get_id();
|
||||
|
||||
$user_id = $customer->get_user_id();
|
||||
}
|
||||
|
||||
} // end if;
|
||||
|
||||
$atts = shortcode_atts(array(
|
||||
'user_id' => $user_id,
|
||||
'meta_name' => 'first_name',
|
||||
'default' => false,
|
||||
'unique' => true,
|
||||
), $atts, 'wu_user_meta');
|
||||
$atts = shortcode_atts(
|
||||
array(
|
||||
'user_id' => $user_id,
|
||||
'meta_name' => 'first_name',
|
||||
'default' => false,
|
||||
'unique' => true,
|
||||
),
|
||||
$atts,
|
||||
'wu_user_meta'
|
||||
);
|
||||
|
||||
if ($customer_id) {
|
||||
|
||||
$value = $customer->get_meta($atts['meta_name']);
|
||||
|
||||
} else {
|
||||
|
||||
$value = get_user_meta($atts['user_id'], $atts['meta_name'], $atts['unique']);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
|
||||
$value = implode(', ', $value);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return $value ? $value : '--';
|
||||
|
||||
} // end user_meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of paying users on the platform.
|
||||
@ -129,13 +123,14 @@ class Legacy_Shortcodes {
|
||||
|
||||
$atts = shortcode_atts(array(), $atts, 'wu_paying_users');
|
||||
|
||||
$paying_customers = wu_get_customers(array(
|
||||
'count' => true,
|
||||
));
|
||||
$paying_customers = wu_get_customers(
|
||||
array(
|
||||
'count' => true,
|
||||
)
|
||||
);
|
||||
|
||||
return $paying_customers;
|
||||
|
||||
} // end paying_users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plan Link shortcode.
|
||||
@ -147,22 +142,24 @@ 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');
|
||||
$atts = shortcode_atts(
|
||||
array(
|
||||
'plan_id' => 0,
|
||||
'plan_freq' => 1,
|
||||
'skip_plan' => 1,
|
||||
),
|
||||
$atts,
|
||||
'wu_plan_link'
|
||||
);
|
||||
|
||||
/**
|
||||
* Treat the results to make sure we are getting numbers out of it
|
||||
*
|
||||
*
|
||||
* @since 1.5.1
|
||||
*/
|
||||
foreach (array('plan_id', 'plan_freq') as $att) {
|
||||
|
||||
$atts[$att] = wu_extract_number($atts[$att]);
|
||||
|
||||
} // end foreach;
|
||||
$atts[ $att ] = wu_extract_number($atts[ $att ]);
|
||||
}
|
||||
|
||||
$path = '';
|
||||
|
||||
@ -173,30 +170,23 @@ class Legacy_Shortcodes {
|
||||
$plan = wu_get_product_by('migrated_from_id', $atts['plan_id']);
|
||||
|
||||
if ($plan) {
|
||||
|
||||
$path = $plan->get_slug();
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
/**
|
||||
* Second pass: try via the real ID, if new customers
|
||||
* decide to use the old shortcode.
|
||||
*/
|
||||
if (empty($path)) {
|
||||
|
||||
$plan = wu_get_product($atts['plan_id']);
|
||||
|
||||
if ($plan) {
|
||||
|
||||
$path = $plan->get_slug();
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
}
|
||||
|
||||
return wu_get_registration_url($path);
|
||||
|
||||
} // end plan_link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the restrict content shortcode.
|
||||
@ -209,40 +199,38 @@ 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');
|
||||
$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'
|
||||
);
|
||||
|
||||
$atts['plan_id'] = !empty($atts['product_id']) ? $atts['product_id'] : $atts['plan_id'];
|
||||
|
||||
if (empty($atts) || !$atts['plan_id']) {
|
||||
$atts['plan_id'] = ! empty($atts['product_id']) ? $atts['product_id'] : $atts['plan_id'];
|
||||
|
||||
if (empty($atts) || ! $atts['plan_id']) {
|
||||
return __('You need to pass a valid plan ID.', 'wp-ultimo');
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$query_products = get_query_var('products', array());
|
||||
|
||||
$request_products = array();
|
||||
|
||||
foreach ($query_products as $product) {
|
||||
|
||||
$product = wu_get_product($product);
|
||||
|
||||
if (!$product) {
|
||||
|
||||
if ( ! $product) {
|
||||
continue;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$request_products[] = $product->get_id();
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
|
||||
$plan_ids = explode(',', $atts['plan_id']);
|
||||
$plan_ids = array_map('trim', $plan_ids);
|
||||
@ -251,16 +239,12 @@ class Legacy_Shortcodes {
|
||||
$else = '[wu_default_content]';
|
||||
|
||||
if (strpos($content, $else) !== false) {
|
||||
|
||||
list($if, $else) = explode($else, $content, 2);
|
||||
|
||||
} else {
|
||||
|
||||
$if = $content;
|
||||
|
||||
$else = '';
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$condition = false;
|
||||
|
||||
@ -268,12 +252,11 @@ class Legacy_Shortcodes {
|
||||
|
||||
$user_logged_in = is_user_logged_in();
|
||||
|
||||
$should_check = !(bool) $atts['only_logged'] || $user_logged_in;
|
||||
$should_check = ! (bool) $atts['only_logged'] || $user_logged_in;
|
||||
|
||||
$from_request = $atts['from_request'] && count(array_intersect($plan_ids, $request_products)) > 0;
|
||||
|
||||
if ($membership && $should_check && !$from_request) {
|
||||
|
||||
if ($membership && $should_check && ! $from_request) {
|
||||
$membership_products = array_merge(
|
||||
array($membership->get_plan_id()),
|
||||
$membership->get_addon_ids()
|
||||
@ -281,29 +264,21 @@ class Legacy_Shortcodes {
|
||||
|
||||
$condition = in_array('all', $plan_ids, true) || count(array_intersect($membership_products, $plan_ids)) > 0;
|
||||
|
||||
if ((bool) $atts['only_active']) {
|
||||
|
||||
if ( (bool) $atts['only_active']) {
|
||||
$condition = $condition && ($membership->is_active() || $membership->get_status() === 'trialing');
|
||||
}
|
||||
|
||||
} // end if;
|
||||
|
||||
if ((bool) $atts['exclude_trials']) {
|
||||
|
||||
$condition = $condition && !$membership->is_trialing();
|
||||
|
||||
} // end if;
|
||||
|
||||
if ( (bool) $atts['exclude_trials']) {
|
||||
$condition = $condition && ! $membership->is_trialing();
|
||||
}
|
||||
} else {
|
||||
|
||||
$condition = $from_request && $should_check;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$final_content = wpautop($condition ? $if : $else);
|
||||
|
||||
return do_shortcode($final_content);
|
||||
|
||||
} // end restricted_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the pricing table shortcode.
|
||||
@ -321,27 +296,29 @@ 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),
|
||||
'plan_id' => false,
|
||||
'show_selector' => true,
|
||||
// New Options
|
||||
'layout' => 'legacy',
|
||||
'period_selector_layout' => 'legacy',
|
||||
), $atts, 'wu_pricing_table');
|
||||
$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),
|
||||
'plan_id' => false,
|
||||
'show_selector' => true,
|
||||
// New Options
|
||||
'layout' => 'legacy',
|
||||
'period_selector_layout' => 'legacy',
|
||||
),
|
||||
$atts,
|
||||
'wu_pricing_table'
|
||||
);
|
||||
|
||||
/**
|
||||
* In the case of the legacy layout, we need to load extra styles.
|
||||
*/
|
||||
if ($atts['layout'] === 'legacy') {
|
||||
|
||||
wp_enqueue_style('legacy-signup', wu_get_asset('legacy-signup.css', 'css'));
|
||||
|
||||
wp_add_inline_style('legacy-signup', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles());
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
do_action('wu_checkout_scripts', $post);
|
||||
|
||||
@ -349,7 +326,7 @@ class Legacy_Shortcodes {
|
||||
|
||||
$atts['plan_id'] = is_string($atts['plan_id']) && $atts['plan_id'] !== 'all' ? explode(',', $atts['plan_id']) : false;
|
||||
|
||||
$checkout_form = new \WP_Ultimo\Models\Checkout_Form;
|
||||
$checkout_form = new \WP_Ultimo\Models\Checkout_Form();
|
||||
|
||||
$fields = array();
|
||||
|
||||
@ -358,13 +335,10 @@ class Legacy_Shortcodes {
|
||||
);
|
||||
|
||||
if ($atts['plan_id']) {
|
||||
|
||||
$search_arguments['id__in'] = $atts['plan_id'];
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
if ($atts['show_selector']) {
|
||||
|
||||
$fields[] = array(
|
||||
'step' => 'checkout',
|
||||
'name' => '',
|
||||
@ -389,8 +363,7 @@ class Legacy_Shortcodes {
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$layout = $atts['layout'];
|
||||
|
||||
@ -410,18 +383,16 @@ class Legacy_Shortcodes {
|
||||
* we'll need a submit field.
|
||||
*/
|
||||
if ($layout !== 'legacy') {
|
||||
|
||||
$fields[] = array (
|
||||
$fields[] = array(
|
||||
'step' => 'checkout',
|
||||
'name' => __('Get Started →', 'wp-ultimo'),
|
||||
'type' => 'submit_button',
|
||||
'id' => 'checkout',
|
||||
);
|
||||
}
|
||||
|
||||
} // end if;
|
||||
|
||||
$steps = array (
|
||||
array (
|
||||
$steps = array(
|
||||
array(
|
||||
'id' => 'checkout',
|
||||
'name' => __('Checkout', 'wp-ultimo'),
|
||||
'desc' => '',
|
||||
@ -441,14 +412,21 @@ class Legacy_Shortcodes {
|
||||
|
||||
do_action('wu_setup_checkout');
|
||||
|
||||
wp_add_inline_script('wu-checkout', sprintf('
|
||||
wp_add_inline_script(
|
||||
'wu-checkout',
|
||||
sprintf(
|
||||
'
|
||||
|
||||
/**
|
||||
* Set the auto-submittable field, if one exists.
|
||||
*/
|
||||
window.wu_auto_submittable_field = %s;
|
||||
|
||||
', json_encode($auto_submittable_field)), 'after');
|
||||
',
|
||||
json_encode($auto_submittable_field)
|
||||
),
|
||||
'after'
|
||||
);
|
||||
|
||||
$final_fields = wu_create_checkout_fields($checkout_form->get_step('checkout', true)['fields']);
|
||||
|
||||
@ -469,16 +447,18 @@ class Legacy_Shortcodes {
|
||||
'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,
|
||||
));
|
||||
|
||||
} // end pricing_table;
|
||||
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,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the template sites shortcode.
|
||||
@ -496,18 +476,22 @@ 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');
|
||||
$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'
|
||||
);
|
||||
|
||||
/**
|
||||
* Hide header, if necessary
|
||||
*/
|
||||
* Hide header, if necessary
|
||||
*/
|
||||
add_filter('wu_step_template_display_header', $atts['show_title'] ? '__return_true' : '__return_false');
|
||||
|
||||
/**
|
||||
@ -521,14 +505,12 @@ class Legacy_Shortcodes {
|
||||
* In the case of the legacy layout, we need to load extra styles.
|
||||
*/
|
||||
if ($atts['layout'] === 'legacy') {
|
||||
|
||||
wp_enqueue_style('legacy-signup', wu_get_asset('legacy-signup.css', 'css'));
|
||||
|
||||
wp_add_inline_style('legacy-signup', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles());
|
||||
}
|
||||
|
||||
} // end if;
|
||||
|
||||
$checkout_form = new \WP_Ultimo\Models\Checkout_Form;
|
||||
$checkout_form = new \WP_Ultimo\Models\Checkout_Form();
|
||||
|
||||
$fields = array();
|
||||
|
||||
@ -549,8 +531,8 @@ class Legacy_Shortcodes {
|
||||
'element_classes' => $layout === 'legacy' ? 'wu-content-templates' : '',
|
||||
);
|
||||
|
||||
$steps = array (
|
||||
array (
|
||||
$steps = array(
|
||||
array(
|
||||
'id' => 'checkout',
|
||||
'name' => __('Checkout', 'wp-ultimo'),
|
||||
'desc' => '',
|
||||
@ -572,14 +554,21 @@ class Legacy_Shortcodes {
|
||||
|
||||
do_action('wu_setup_checkout');
|
||||
|
||||
wp_add_inline_script('wu-checkout', sprintf('
|
||||
wp_add_inline_script(
|
||||
'wu-checkout',
|
||||
sprintf(
|
||||
'
|
||||
|
||||
/**
|
||||
* Set the auto-submittable field, if one exists.
|
||||
*/
|
||||
window.wu_auto_submittable_field = %s;
|
||||
|
||||
', json_encode($auto_submittable_field)), 'after');
|
||||
',
|
||||
json_encode($auto_submittable_field)
|
||||
),
|
||||
'after'
|
||||
);
|
||||
|
||||
$final_fields['pre-flight'] = array(
|
||||
'type' => 'hidden',
|
||||
@ -588,16 +577,18 @@ class Legacy_Shortcodes {
|
||||
|
||||
$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,
|
||||
));
|
||||
|
||||
} // end templates_list;
|
||||
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,
|
||||
)
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Makes sure we don't return any invalid values.
|
||||
*
|
||||
@ -609,7 +600,5 @@ class Legacy_Shortcodes {
|
||||
$list = array_map('trim', explode(',', $templates));
|
||||
|
||||
return array_filter($list);
|
||||
|
||||
} // end treat_template_list;
|
||||
|
||||
} // end class Legacy_Shortcodes;
|
||||
}
|
||||
}
|
||||
|
@ -82,10 +82,8 @@ class Multiple_Accounts_Compat {
|
||||
|
||||
// Adds the number of additional accounts.
|
||||
add_filter('manage_users_custom_column', array($this, 'add_column_content'), 10, 3);
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end init;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixes the object cache to allow multiple accounts.
|
||||
@ -98,16 +96,13 @@ class Multiple_Accounts_Compat {
|
||||
public function fix_object_cache_on_multiple_accounts(): void {
|
||||
|
||||
$to_remove = array(
|
||||
'useremail'
|
||||
'useremail',
|
||||
);
|
||||
|
||||
if (function_exists('wp_cache_add_non_persistent_groups')) {
|
||||
|
||||
wp_cache_add_non_persistent_groups($to_remove);
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end fix_object_cache_on_multiple_accounts;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the database query so that we can get the right user.
|
||||
@ -124,7 +119,6 @@ class Multiple_Accounts_Compat {
|
||||
$search = "\$db->get_row(\"SELECT * FROM $wpdb->users WHERE user_email";
|
||||
|
||||
if ( strpos($wpdb->func_call, $search) === 0) {
|
||||
|
||||
$prefix = "SELECT * FROM $wpdb->users WHERE user_email";
|
||||
|
||||
$last = substr($query, strlen($prefix));
|
||||
@ -135,17 +129,19 @@ class Multiple_Accounts_Compat {
|
||||
* We can't use the $wpdb->prepare() method here because it will
|
||||
* escape the %s placeholder, which will break the query.
|
||||
*/
|
||||
return sprintf("SELECT u.*
|
||||
return sprintf(
|
||||
"SELECT u.*
|
||||
FROM $wpdb->users u
|
||||
JOIN $wpdb->usermeta m on u.id = m.user_id
|
||||
WHERE m.meta_key = \"wp_%d_capabilities\"
|
||||
AND u.user_email%s", $site_id, $last);
|
||||
|
||||
} // end if;
|
||||
AND u.user_email%s",
|
||||
$site_id,
|
||||
$last
|
||||
);
|
||||
}
|
||||
|
||||
return $query;
|
||||
|
||||
} // end fix_user_query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooks into email_exists verification to allow duplicate emails in different sites.
|
||||
@ -159,16 +155,13 @@ class Multiple_Accounts_Compat {
|
||||
public function allow_duplicate_emails($user_id, string $email) {
|
||||
|
||||
if ($user_id) {
|
||||
|
||||
$site_user = $this->get_right_user($email);
|
||||
|
||||
return $site_user ? $site_user->ID : false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return $user_id;
|
||||
|
||||
} // end allow_duplicate_emails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent WooCommerce from adding users to site without us knowing.
|
||||
@ -186,8 +179,7 @@ class Multiple_Accounts_Compat {
|
||||
add_filter('can_add_user_to_blog', '__return_false');
|
||||
|
||||
return $results;
|
||||
|
||||
} // end prevent_woo_from_adding_to_blog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the user belongs to a site they are currently viewing and unset them if they don't.
|
||||
@ -200,10 +192,8 @@ class Multiple_Accounts_Compat {
|
||||
global $current_user;
|
||||
|
||||
if (is_admin() || is_main_site() || current_user_can('manage_network')) {
|
||||
|
||||
return;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow developers to bypass the unset current user code.
|
||||
@ -222,10 +212,8 @@ class Multiple_Accounts_Compat {
|
||||
* @return mixed
|
||||
*/
|
||||
if (apply_filters('wu_bypass_unset_current_user', null, $current_user) !== null) {
|
||||
|
||||
return;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$user = wp_get_current_user();
|
||||
|
||||
@ -237,16 +225,13 @@ class Multiple_Accounts_Compat {
|
||||
* currently logged in.
|
||||
*/
|
||||
if ($has_user === false) {
|
||||
|
||||
wu_x_header('X-Ultimo-Multiple-Accounts: user-unset');
|
||||
|
||||
$current_user = null;
|
||||
|
||||
wp_set_current_user(0);
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end maybe_unset_current_user;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow plugin developers to disable this functionality to prevent compatibility issues.
|
||||
@ -258,8 +243,7 @@ class Multiple_Accounts_Compat {
|
||||
public function should_load() {
|
||||
|
||||
return apply_filters('wu_should_load_multiple_accounts_support', wu_get_setting('enable_multiple_accounts', true));
|
||||
|
||||
} // end should_load;
|
||||
}
|
||||
|
||||
// Methods
|
||||
|
||||
@ -272,20 +256,27 @@ class Multiple_Accounts_Compat {
|
||||
*/
|
||||
public function add_settings() {
|
||||
|
||||
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',
|
||||
'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,
|
||||
));
|
||||
|
||||
} // end add_settings;
|
||||
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,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the Multiple accounts column to the users table.
|
||||
@ -300,8 +291,7 @@ class Multiple_Accounts_Compat {
|
||||
$columns['multiple_accounts'] = __('Multiple Accounts', 'wp-ultimo');
|
||||
|
||||
return $columns;
|
||||
|
||||
} // end add_multiple_account_column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the content of our custom column.
|
||||
@ -321,11 +311,13 @@ class Multiple_Accounts_Compat {
|
||||
$user = get_user_by('ID', $user_id);
|
||||
|
||||
// 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'),
|
||||
));
|
||||
$users = new \WP_User_Query(
|
||||
array(
|
||||
'blog_id' => 0,
|
||||
'search' => $user->user_email,
|
||||
'fields' => array('ID', 'user_login'),
|
||||
)
|
||||
);
|
||||
|
||||
// translators: the %d is the account count for that email address.
|
||||
$html = sprintf(__('<strong>%d</strong> accounts using this email.', 'wp-ultimo'), $users->total_users);
|
||||
@ -333,10 +325,8 @@ class Multiple_Accounts_Compat {
|
||||
$html .= sprintf("<br><a href='%s' class=''>" . __('See all', 'wp-ultimo') . ' »</a>', network_admin_url('users.php?s=' . $user->user_email));
|
||||
|
||||
echo $html;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end add_column_content;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles password resetting.
|
||||
@ -351,18 +341,14 @@ class Multiple_Accounts_Compat {
|
||||
|
||||
// Only do thing if is login by email
|
||||
if (is_email($_REQUEST['user_login'])) {
|
||||
|
||||
$user = $this->get_right_user($_REQUEST['user_login']);
|
||||
|
||||
$_REQUEST['user_login'] = $user->user_login;
|
||||
|
||||
$_POST['user_login'] = $user->user_login;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end handle_reset_password;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given user is a member in the site.
|
||||
@ -391,12 +377,10 @@ class Multiple_Accounts_Compat {
|
||||
* @since 2.0.11
|
||||
*/
|
||||
if ($user_id) {
|
||||
|
||||
$query['include'] = array(
|
||||
absint($user_id),
|
||||
);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
// Now we search for the correct user based on the password and the blog information
|
||||
$users = new \WP_User_Query($query);
|
||||
@ -406,43 +390,36 @@ class Multiple_Accounts_Compat {
|
||||
|
||||
// Check for the pertinence of that user in this site
|
||||
if ($this->user_can_for_blog($user_with_email, get_current_blog_id(), 'read')) {
|
||||
|
||||
$has_user = true;
|
||||
|
||||
break;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
}
|
||||
|
||||
// If nothing was found return false;
|
||||
return $has_user;
|
||||
}
|
||||
/**
|
||||
* Gets the right user when logging-in.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param null|\WP_User|\WP_Error $user The current user object. Usually false.
|
||||
* @param string $username The username to search for.
|
||||
* @param string $password The user password.
|
||||
* @return null|\WP_User|\WP_Error
|
||||
*/
|
||||
public function fix_login($user, $username, $password) {
|
||||
|
||||
} // end check_for_user_in_site;
|
||||
/**
|
||||
* Gets the right user when logging-in.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param null|\WP_User|\WP_Error $user The current user object. Usually false.
|
||||
* @param string $username The username to search for.
|
||||
* @param string $password The user password.
|
||||
* @return null|\WP_User|\WP_Error
|
||||
*/
|
||||
public function fix_login($user, $username, $password) {
|
||||
|
||||
if (!is_email($username)) {
|
||||
|
||||
if ( ! is_email($username)) {
|
||||
return $user;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
// Sets the right user to be returned;
|
||||
$user = $this->get_right_user($username, $password);
|
||||
|
||||
return $user ? $user : null;
|
||||
|
||||
} // end fix_login;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user can do something in a specific blog.
|
||||
@ -461,42 +438,35 @@ class Multiple_Accounts_Compat {
|
||||
$current_user = $user;
|
||||
|
||||
if (empty($current_user)) {
|
||||
|
||||
if ($switched) {
|
||||
|
||||
restore_current_blog();
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$args = array_slice(func_get_args(), 2);
|
||||
|
||||
$args = array_merge(array($capability), $args);
|
||||
|
||||
$can = call_user_func_array(\Closure::fromCallable([$current_user, 'has_cap']), $args);
|
||||
$can = call_user_func_array(\Closure::fromCallable(array($current_user, 'has_cap')), $args);
|
||||
|
||||
if ($switched) {
|
||||
|
||||
restore_current_blog();
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return $can;
|
||||
|
||||
} // end user_can_for_blog;
|
||||
/**
|
||||
* Gets the right user for a given domain.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param string $email User email address.
|
||||
* @param boolean $password User password.
|
||||
* @return \WP_User|false
|
||||
*/
|
||||
protected function get_right_user($email, $password = false) {
|
||||
}
|
||||
/**
|
||||
* Gets the right user for a given domain.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param string $email User email address.
|
||||
* @param boolean $password User password.
|
||||
* @return \WP_User|false
|
||||
*/
|
||||
protected function get_right_user($email, $password = false) {
|
||||
|
||||
// Sets the right user to be returned;
|
||||
$right_user = false;
|
||||
@ -507,7 +477,6 @@ class Multiple_Accounts_Compat {
|
||||
|
||||
// Loop the results and check which one is in this group
|
||||
foreach ($users->results as $user_with_email) {
|
||||
|
||||
$conditions = $password == false ? true : wp_check_password($password, $user_with_email->user_pass, $user_with_email->ID);
|
||||
|
||||
// Check for the pertinence of that user in this site
|
||||
@ -517,14 +486,10 @@ class Multiple_Accounts_Compat {
|
||||
$right_user = $user_with_email;
|
||||
|
||||
continue;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
}
|
||||
|
||||
// Return right user
|
||||
return $right_user;
|
||||
|
||||
} // end get_right_user;
|
||||
|
||||
} // end class Multiple_Accounts_Compat;
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,7 @@ class Product_Compat {
|
||||
add_filter('wu_product_options_sections', array($this, 'add_legacy_section'), 100, 2);
|
||||
|
||||
add_filter('update_post_metadata', array($this, 'check_update_plan'), 10, 5);
|
||||
|
||||
} // end init;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves meta data from old plugins on the new plugin.
|
||||
@ -53,22 +52,18 @@ class Product_Compat {
|
||||
/*
|
||||
* Check if we are in the main site of the network.
|
||||
*/
|
||||
if (!is_main_site()) {
|
||||
|
||||
if ( ! is_main_site()) {
|
||||
return;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if we have a new entity with this ID.
|
||||
*/
|
||||
$migrated_product = wu_get_product($object_id);
|
||||
|
||||
if (!$migrated_product) {
|
||||
|
||||
if ( ! $migrated_product) {
|
||||
return;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevent double prefixing.
|
||||
@ -85,8 +80,7 @@ class Product_Compat {
|
||||
* returning anything else will prevent meta data from being saved.
|
||||
*/
|
||||
return null;
|
||||
|
||||
} // end check_update_plan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Injects the compatibility panels to products Advanced Options.
|
||||
@ -142,7 +136,5 @@ class Product_Compat {
|
||||
);
|
||||
|
||||
return $sections;
|
||||
|
||||
} // end add_legacy_section;
|
||||
|
||||
} // end class Product_Compat;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user