plugin_path = end( $plugin_path ); // Set plugin file. $this->plugin_file = $plugin_file; // Set plugin name. if ( isset( $plugins[ $this->plugin_path . '/' . $this->plugin_file ]['Name'] ) ) { $this->plugin_name = str_replace( 'AffiliateWP - ', '', $plugins[ $this->plugin_path . '/' . $this->plugin_file ]['Name'] ); } else { $this->plugin_name = __( 'This plugin', 'affiliatewp-order-details-for-affiliates' ); } // Is EDD installed? foreach ( $plugins as $plugin_path => $plugin ) { if ( 'AffiliateWP' === $plugin['Name'] ) { $this->has_affiliatewp = true; break; } } } /** * Process plugin deactivation. * * @since 1.0.0 * * @return void */ public function run() { // We need plugin.php! require_once ABSPATH . 'wp-admin/includes/plugin.php'; // Deactivate this plugin. deactivate_plugins( $this->plugin_path . '/' . $this->plugin_file ); unset( $_GET['activate'] ); // Display notice. add_action( 'admin_notices', array( $this, 'missing_affiliatewp_notice' ) ); } /** * Display notice if AffiliateWP isn't installed. * * @since 1.0.0 * * @return void */ public function missing_affiliatewp_notice() { if ( $this->has_affiliatewp ) { /* translators: 1: opening link tag to the AffiliateWP website, 2: closing link tag. */ $message = sprintf( __( ' requires %1$sAffiliateWP%2$s. Please activate it to continue.', 'affiliatewp-order-details-for-affiliates' ), '', '' ); } else { /* translators: 1: opening link tag to the AffiliateWP website, 2: closing link tag. */ $message = sprintf( __( ' requires %1$sAffiliateWP%2$s. Please install it to continue.', 'affiliatewp-order-details-for-affiliates' ), '', '' ); } echo '
' . esc_html( $this->plugin_name ) . wp_kses_post( $message ) . '