'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; } add_action( 'switch_blog', function () use ($wpdb, $tables) { foreach ( $tables as $name => $table ) { $wpdb->$name = $wpdb->prefix . $table; } }, 0 ); } /** * Fixes incompatibility with the plugin WP Typography. * * This plugin has a setting that replaces quotes on the content. * This breaks our moment configuration strings, and is generally * not compatible with WP Multisite WaaS vue templates. * * Here on this filter, we manually disable the smart quotes * settings to prevent that kind of processing, as well as add * an admin message telling admins that this is not supported. * * @see https://de.wordpress.org/plugins/wp-typography/ * @since 2.0.0 * * @param array $settings The wp-typography settings. * @return array */ public function fix_wp_typography($settings) { $settings['smartQuotes'] = false; return $settings; } /** * Adds a warning message to let customers know why smart quotes are not working. * * @since 2.0.0 * @return void */ 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'); } /** * Fixes brizy media URLs while on Ultimo's template preview * * In pages created with Brizy, the URLs break when * we add the preview=1 parameter to urls. * * This fix prevent that addition. * It is far from an optimal solution, but it will do * for now. * * @todo Find a better way to exclude only Brizy urls. * * @since 2.0.0 * @param bool $value The current filter value. * @return bool */ public function fix_brizy_preview_url($value) { return class_exists('Brizy_Editor') ? false : $value; } /** * Fix the Brizy editor with domain mapping. * * @since 2.0.10 * * @param bool $should_redirect If we should redirect to the mapped domain. * @return bool */ 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; } } return $should_redirect; } /** * Fix the Divi editor with domain mapping. * * @since 2.1.4 * * @param bool $should_redirect If we should redirect to the mapped domain. * @return bool */ public function fix_divi_editor_screen(bool $should_redirect): bool { if (isset($_GET['et_fb']) && (bool) $_GET['et_fb']) { return false; } return $should_redirect; } /** * Fixes WP Hide Pro URLs while on Ultimo's template preview * * @since 2.0.20 * @param bool $value The current filter value. * @return bool */ public function fix_wp_hide_preview_url($value) { return class_exists('WPH') ? false : $value; } /** * Fix the load URL for WP Frontend Admin. * * @since 2.0.0 * * @param string $final_url The URL WFA wants to load. * @param string $page_path_only The page path. * @param int $blog_id The blog ID. * @return string */ public function fix_frontend_admin_loading_url($final_url, $page_path_only, $blog_id) { return wu_restore_original_url($final_url, $blog_id); } /** * Oxygen renders things very strangely, so we need to handle it separately. * * @since 2.0.0 * * @param bool $should_enqueue If we should include the elements scripts. * @param \WP_Post $post The post object. * @param string $shortcode_tag The shortcode. * @return bool */ public function maybe_parse_oxygen_content($should_enqueue, $post, $shortcode_tag) { if (function_exists('oxygen_vsb_current_user_can_access') === false) { return $should_enqueue; } $shortcode_content = get_post_meta($post->ID, 'ct_builder_shortcodes', true); $has_shortcode = has_shortcode($shortcode_content, $shortcode_tag); /* * Oxygen now base64 encodes shortcodes for some reason... * Supporting third-party page builders is such a pain. */ if ( ! $has_shortcode) { $base64 = base64_encode("[$shortcode_tag]"); $has_shortcode = strpos((string) $shortcode_content, $base64); } return $has_shortcode; } /** * Prevent Oxygen from removing the real wp_head hook from the template * previewer page. * * @since 2.0.4 * @return void */ public function prevent_oxygen_cleanup_on_template_previewer(): void { add_action( 'wp_head', function () { remove_action('wp_head', 'oxy_print_cached_css', 999999); }, 10 ); } /** * Adds SSO to WP Maintenance Mode. * * @since 2.0.0 * * @param \WP_Ultimo\Domain_Mapping\SSO $sso The SSO class instance. * @return void */ public function add_sso_to_maintenance_mode($sso): void { add_action('wpmm_head', [$sso, 'enqueue_script']); } /** * Run wp action on template previewer to prevent some errors like * images not loading due lazy loading funcionality * * @since 2.0.11 */ public function run_wp_on_template_previewer(): void { if (class_exists('Avada')) { do_action('wp'); //phpcs:disable } } /** * Run wp action on template previewer to prevent some errors like * images not loading due lazy loading functionality * * @since 2.0.11 */ public function clear_avada_cache($data): void { switch_to_blog($data['blog_id']); if (function_exists('fusion_reset_all_caches')) { fusion_reset_all_caches(); } else { $theme = strtolower(wp_get_theme()) === 'avada' ? 'avada' : strtolower(wp_get_theme()->parent()); $file_path = get_parent_theme_file_path('includes/lib/inc/functions.php'); if ($theme === 'avada' && file_exists($file_path)) { require_once get_parent_theme_file_path('includes/lib/inc/functions.php'); fusion_reset_all_caches(); } } restore_current_blog(); } /** * Fix the FluentCRM Pro on site duplication due to fc_meta table not exist * The function causing problem should run after a user receive a role on the * site to tag him on CRM as a customer. * * @since 2.0.11 */ 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', [$class_name, 'maybeAutoAlterTags'], 11); } } /** * Removes RankMath and RankMath Pro Installer::wpmu_new_blog action * This registered action causes error on database during site creation * and serves only to force activate the plugin * * @since 2.0.20 */ public function fix_rank_math_site_creation(): void { $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', [$class_name, 'activate_blog'], 10); $this->hard_remove_action('wp_initialize_site', [$class_name, 'initialize_site'], 10); } } } /** * Removes WP E-Signature and WP E-Signature Business add-ons * ESIG_SAD::wpmu_new_blog and ESIG_SIF::wpmu_new_blog actions * This registered action causes error on database during site creation * and serves only to force activate the plugin * * @since 2.1 */ public function fix_wp_e_signature_site_creation(): void { $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', [$class_name, 'activate_new_site'], 10); } } } /** * A way to remove an action if instance is not available * * @since 2.0.11 * * @param string $tag The class name. * @param array $handler The action handler. * @param int $priority The The action priority. * @return void */ public function hard_remove_action($tag, $handler, $priority): void { global $wp_filter; if (!isset($wp_filter[$tag][$priority])) { return; } $handler_id = ''; foreach($wp_filter[$tag][$priority] as $handler_key => $filter_handler) { 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; } } if (!empty($handler_id)) { remove_filter( $tag, $handler_id, $priority ); } return; } /** * Remove action from perfamatters that disabled password strength meter script. * * @since 2.1.1 * @return void */ public function remove_perfmatters_checkout_dep(): void { if (is_main_site() || is_admin()) { remove_action('wp_print_scripts', 'perfmatters_disable_password_strength_meter', 100); } } }