meets_requirements() ) { return; } require_once CEFD_PATH . 'includes/helpers/class-cefd-category.php'; require_once CEFD_PATH . 'includes/helpers/class-cefd-icons.php'; CEFD_Category::init(); // Divi 5 ships with a backward compatibility layer that keeps Divi 4 // (shortcode framework) modules working, so the legacy module set is // always registered. require_once CEFD_PATH . 'includes/divi4/class-cefd-divi4-modules.php'; CEFD_Divi4_Modules::init(); // Native Divi 5 modules (module.json + React front-end) are loaded // only when the Divi 5 module-library framework is available. if ( $this->is_divi5_active() ) { require_once CEFD_PATH . 'includes/divi5/class-cefd-divi5-modules.php'; CEFD_Divi5_Modules::init(); } $this->register_assets(); } /** * Validates that Divi is present and meets the minimum version, * registering the matching admin notice when it does not. * * @return bool True when the plugin can boot. */ private function meets_requirements() { if ( ! $this->is_divi_present() ) { add_action( 'admin_notices', array( $this, 'notice_divi_required' ) ); return false; } if ( ! version_compare( ET_CORE_VERSION, self::MIN_DIVI_VERSION, '>=' ) ) { add_action( 'admin_notices', array( $this, 'notice_divi_version' ) ); return false; } return true; } /** * Whether the Divi theme or the standalone Divi Builder plugin is active * (both load the same `ET_CORE_VERSION`-versioned framework). * * @return bool */ public function is_divi_present() { return defined( 'ET_CORE_VERSION' ); } /** * Whether the site is running the Divi 5 native builder framework. * * Confirmed against a live Divi 5.13 install: Divi 5 defines * `et_builder_d5_enabled()` (in `et-pagebuilder/builder-5.php`, always * loaded once Divi 5 is present) and `ET_BUILDER_5_DIR`/`ET_BUILDER_5_URI` * constants. Neither `ET_BUILDER_5_VERSION` nor `\ET\Builder\Framework\Framework` * exist; that was an unverified guess from before Divi 5 was available to test against. * * @return bool */ public function is_divi5_active() { return function_exists( 'et_builder_d5_enabled' ) && et_builder_d5_enabled(); } /** * Whether the Divi theme is installed (active or not). * * @return bool */ private function is_divi_theme_installed() { return wp_get_theme( 'Divi' )->exists(); } /** * Whether the Divi theme is the active theme or parent theme. * * @return bool */ private function is_divi_theme_active() { return in_array( 'Divi', array( get_template(), get_stylesheet() ), true ); } /** * Whether the standalone Divi Builder plugin is installed (active or not). * * @return bool */ private function is_divi_builder_plugin_installed() { if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $installed_plugins = get_plugins(); return isset( $installed_plugins[ self::DIVI_BUILDER_PLUGIN ] ); } /** * Whether the standalone Divi Builder plugin is active. * * @return bool */ private function is_divi_builder_plugin_active() { if ( ! function_exists( 'is_plugin_active' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } return is_plugin_active( self::DIVI_BUILDER_PLUGIN ); } /** * Admin notice shown when neither the Divi theme nor the Divi Builder * plugin is active. Distinguishes "installed but inactive" (offers an * activation link) from "not installed at all" (offers an install link), * same pattern WordPress.org reviewers expect from dependent plugins. * * @return void */ public function notice_divi_required() { $plugin_name = '' . esc_html__( 'Card Elements for Divi', 'card-elements-for-divi' ) . ''; if ( $this->is_divi_theme_installed() && ! $this->is_divi_theme_active() ) { $message = sprintf( /* translators: %s: Plugin name. */ esc_html__( '%s requires the Divi theme to be active, or the Divi Builder plugin installed instead.', 'card-elements-for-divi' ), $plugin_name ); $this->render_notice( $message, self::DIVI_THEME_URL, esc_html__( 'Get Divi', 'card-elements-for-divi' ), true ); return; } if ( $this->is_divi_builder_plugin_installed() && ! $this->is_divi_builder_plugin_active() ) { if ( ! current_user_can( 'activate_plugins' ) ) { return; } $activation_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=' . rawurlencode( self::DIVI_BUILDER_PLUGIN ) . '&plugin_status=all&paged=1&s' ), 'activate-plugin_' . self::DIVI_BUILDER_PLUGIN ); $message = sprintf( /* translators: %s: Plugin name. */ esc_html__( '%s requires the Divi Builder plugin to be active.', 'card-elements-for-divi' ), $plugin_name ); $this->render_notice( $message, $activation_url, esc_html__( 'Activate Divi Builder', 'card-elements-for-divi' ) ); return; } $message = sprintf( /* translators: %s: Plugin name. */ esc_html__( '%s requires the Divi theme or the Divi Builder plugin. Neither was found on this site.', 'card-elements-for-divi' ), $plugin_name ); $this->render_notice( $message, self::DIVI_BUILDER_URL, esc_html__( 'Get Divi Builder', 'card-elements-for-divi' ), true ); } /** * Admin notice shown when Divi is active but older than the minimum * supported version. * * @return void */ public function notice_divi_version() { if ( ! current_user_can( 'update_plugins' ) ) { return; } $message = sprintf( /* translators: 1: Plugin name, 2: Required Divi version. */ esc_html__( '%1$s requires Divi version %2$s or greater. Please update Divi.', 'card-elements-for-divi' ), '' . esc_html__( 'Card Elements for Divi', 'card-elements-for-divi' ) . '', self::MIN_DIVI_VERSION ); echo '
' . wp_kses( $message, array( 'strong' => array() ) ) . '
' . wp_kses( $message, array( 'strong' => array() ) ) . '
'; echo '