{ return str_replace( 'frameborder="0"', '', $html ); } } // If there's no URL match, return the HTML string without modification. return $html; } add_filter( 'oembed_dataparse', 'et_divi_oembed_dataparse_remove_yt_frameborder', 10, 3 ); /** * Get the list of plugins that shouldn't be activated with Divi 5. * * @return array List of disallowed plugin slugs. */ function et_divi_get_disallowed_plugins() { return []; } /** * Get the list of plugins that shouldn't be activated with Divi 5. * * @return bool Is the current request the top window in the VB. */ function et_divi_is_vb_top_window() { static $is_top_window = null; if ( null === $is_top_window ) { $is_vb_enabled = et_core_is_fb_enabled(); $is_app_window = isset( $_GET['app_window'] ) && '1' === $_GET['app_window']; if ( $is_vb_enabled && ! $is_app_window ) { $is_top_window = true; } } return $is_top_window; } /** * Prevents the theme from being activated if certain plugins are active. * * Checks the list of disallowed plugins and prevents the theme activation if * any of these plugins are currently active. Displays an error message in the * WordPress dashboard if activation is blocked. */ function et_divi_prevent_theme_activation() { $previous_theme = get_option( 'theme_switched' ); $disallowed_plugins = et_divi_get_disallowed_plugins(); $active_plugins = []; // Loop through the disallowed plugins and check if any are active. foreach ( $disallowed_plugins as $plugin ) { if ( is_plugin_active( $plugin ) ) { $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); $active_plugins[] = $plugin_data['Name']; } } // If any disallowed plugins are active, prevent theme activation. if ( ! empty( $active_plugins ) ) { // Switch back to the previously-activated Theme. switch_theme( $previous_theme ); $message = '

' . esc_html__( 'Unsupported Plugins Detected', 'Divi' ) . '

'; $message .= '

' . esc_html__( 'Divi 5 cannot be activated while the following plugins are active. Please deactivate these plugins and activate Divi 5 again.', 'Divi' ) . '

'; $message .= ''; $message .= '

' . esc_html__( 'The creators of these plugins have chosen to opt out of the Divi 5 Public Alpha while they focus on creating new versions of their modules in preparation for the final release of Divi 5. 🎉', 'Divi' ) . '

'; $message .= '

' . esc_html__( 'While Divi 5 was built to be backward compatible, the backward compatibility system is in its alpha stage. Some creators don\'t want to participate in the testing phase.', 'Divi' ) . '

'; $message .= '

' . esc_html__( 'Third party modules aren\'t expected to be ready for Divi 5 during the alpha and beta phases.', 'Divi' ) . '

'; $message .= '

' . esc_html__( 'This block will eventually be removed, so please check back again in the future. Thanks for testing Divi 5!', 'Divi' ) . '

'; $message .= '' . esc_html__( '« Go Back', 'Divi' ) . ''; wp_die( $message, esc_html__( 'Unsupported Plugins Detected', 'Divi' ) ); } } add_action( 'after_switch_theme', 'et_divi_prevent_theme_activation' ); /** * Prevents certain plugins from being activated if the theme is active. * * Checks the list of disallowed plugins and prevents their activation if the * active theme is the specified one. Displays an error message in the WordPress * dashboard if activation is blocked. * * @param string $plugin The plugin being activated. */ function et_divi_prevent_plugin_activation( $plugin ) { $disallowed_plugins = et_divi_get_disallowed_plugins(); if ( in_array( $plugin, $disallowed_plugins, true ) ) { deactivate_plugins( $plugin ); $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); $message = '

' . esc_html__( 'This Plugin Can\'t Be Activated While Using Divi 5', 'Divi' ) . '

'; $message .= '

' . esc_html__( 'The creators of ' . esc_html( $plugin_data['Name'] ) . ' have chosen to opt out of the Divi 5 Public Alpha while they focus on creating new versions of their modules in preparation for the final release of Divi 5. 🎉', 'Divi' ) . '

'; $message .= '

' . esc_html__( 'While Divi 5 was built to be backward compatible, the backward compatibility system is in its alpha stage. Some creators don\'t want to participate in the testing phase.', 'Divi' ) . '

'; $message .= '

' . esc_html__( 'Third party modules aren\'t expected to be ready for Divi 5 during the alpha and beta phases.', 'Divi' ) . '

'; $message .= '

' . esc_html__( 'This block will eventually be removed, so please check back again in the future. Thanks for testing Divi 5!', 'Divi' ) . '

'; $message .= '' . esc_html__( '« Go Back', 'Divi' ) . ''; wp_die( $message, esc_html__( 'This Plugin Can\'t Be Activated While Using Divi 5', 'Divi' ) ); } } add_action( 'activate_plugin', 'et_divi_prevent_plugin_activation' ); /** * TODO: Make this detect if blocks exist on the page, rather than just checking the Divi Builder is used. * Dequeue inline block styles if the Divi Builder is used. * * @since ?.? */ function et_divi_maybe_dequeue_block_css() { // If this isn't a page that could be built with the Divi Builder, return. if ( ! ( is_single() || is_front_page() ) ) { return; } $post_id = get_the_id(); $is_page_builder_used = et_pb_is_pagebuilder_used( $post_id ); // If the Divi Builder is used, it's highly unlikely a WordPress block is used, at least for now. if ( $is_page_builder_used ) { wp_dequeue_style('wp-block-library-theme'); wp_dequeue_style('global-styles'); } } add_filter( 'wp_enqueue_scripts', 'et_divi_maybe_dequeue_block_css', 100 );