HEX
Server: Apache/2.4.57 (Unix) OpenSSL/1.1.1k
System: Linux tam.zee-supreme-vps.net 4.18.0-513.9.1.el8_9.x86_64 #1 SMP Sat Dec 2 05:23:44 EST 2023 x86_64
User: adltc (1070)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/adltc/public_html/wp-content/plugins/feeds-for-youtube/inc/Services/ActivationService.php
<?php

namespace SmashBalloon\YouTubeFeed\Services;

use Smashballoon\Stubs\Services\ServiceProvider;

class ActivationService extends ServiceProvider {

	public function register() {
		add_action( 'activated_plugin', [ $this, 'on_plugin_activation' ] );
	}

	public function on_plugin_activation( $plugin ) {
		if ( ! in_array( basename( $plugin ), array( 'youtube-feed.php', 'youtube-feed-pro.php' ) ) ) {
			return;
		}

		$plugin_to_deactivate = 'youtube-feed.php';
		if ( basename( $plugin ) === $plugin_to_deactivate ) {
			$plugin_to_deactivate = 'youtube-feed-pro.php';
		}

		foreach ( $this->get_active_plugins() as $basename ) {
			if ( false !== strpos( $basename, $plugin_to_deactivate ) ) {
				deactivate_plugins( $basename );

				return;
			}
		}
	}

	private function get_active_plugins() {
		if ( is_multisite() ) {
			$active_plugins = array_keys( (array) get_site_option( 'active_sitewide_plugins', array() ) );
		} else {
			$active_plugins = (array) get_option( 'active_plugins', array() );
		}

		return $active_plugins;
	}

}