updater = new WC_EDM_Updater(); } // Also deliberately before the WooCommerce check, and for the same // reason as the updater above: the shared parent menu is registered by // whichever of the five plugins boots first, and its label must not // depend on whether THIS plugin got past a gate. // // Registered here rather than by editing includes/shared-menu.php: // that file is byte-identical in all five, and which copy a site loads // is decided by activation order. Changing it there would make a site // with three of five updated show "Manager" or "Nolimit" depending on // who booted first, and change its mind when a plugin is deactivated. // The filter is idempotent, so a plugin still on the old build changes // nothing. add_filter( 'wpmgr_menu_title', array( $this, 'shared_menu_title' ) ); if ( ! class_exists( 'WooCommerce' ) ) { add_action( 'admin_notices', array( $this, 'woocommerce_missing_notice' ) ); return; } load_plugin_textdomain( 'wc-email-discount', false, dirname( plugin_basename( WC_EDM_PLUGIN_FILE ) ) . '/languages' ); $this->includes(); if ( ! empty( $this->missing_files ) ) { add_action( 'admin_notices', array( $this, 'incomplete_install_notice' ) ); } // Everything else builds on these two, so without them the plugin // stays dormant and shows the notice instead of erroring out. if ( ! class_exists( 'WC_EDM_DB' ) || ! class_exists( 'WC_EDM_Helpers' ) ) { return; } // Upgrade the DB schema after plugin updates that skip re-activation. add_action( 'init', array( 'WC_EDM_DB', 'maybe_upgrade' ), 5 ); if ( is_admin() && class_exists( 'WC_EDM_Admin' ) ) { $this->admin = new WC_EDM_Admin(); } if ( class_exists( 'WC_EDM_Frontend' ) ) { $this->frontend = new WC_EDM_Frontend(); } if ( class_exists( 'WC_EDM_Audit_Log' ) ) { $this->audit_log = new WC_EDM_Audit_Log(); } if ( class_exists( 'WC_EDM_REST_API' ) ) { $this->rest_api = new WC_EDM_REST_API(); } } /** * Warn that the plugin folder is incomplete. */ public function incomplete_install_notice() { if ( ! current_user_can( 'activate_plugins' ) ) { return; } echo '
'; echo esc_html__( 'WooCommerce Email Discount Manager could not load all of its files, so some features are unavailable. If you just updated the plugin, reload this page — the upload may still have been in progress. If the warning persists, upload the plugin again.', 'wc-email-discount' ); echo '
';
echo implode( ', ', array_map( 'esc_html', $this->missing_files ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '
'; esc_html_e( 'WooCommerce Email Discount Manager requires WooCommerce to be installed and active.', 'wc-email-discount' ); echo '