https://t.me/RX1948
Server : Apache
System : Linux server.lienzindia.com 4.18.0-348.7.1.el8_5.x86_64 #1 SMP Wed Dec 22 13:25:12 UTC 2021 x86_64
User : plutus ( 1007)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /home/plutus/public_html/wp-content/themes/vrm/inc/updates/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/plutus/public_html/wp-content/themes/vrm/inc/updates/plugin-updater.php
<?php

namespace TotalTheme\Updates;

use TotalTheme\Admin\Recommended_Plugins;

\defined( 'ABSPATH' ) || exit;

/**
 * Displays plugin update notifications for some bundled theme plugins to make it easier for the end user.
 */
class Plugin_Updater {

	/**
	 * Instance.
	 */
	private static $instance;

	/**
	 * Create or retrieve the instance of Plugin_Updater.
	 */
	public static function instance() {
		if ( \is_null( static::$instance ) ) {
			static::$instance = new self();
			static::$instance->init_hooks();
		}

		return static::$instance;
	}

	/**
	 * Run action hooks.
	 */
	public function init_hooks() {
		// For testing purposes only !!!
		//set_site_transient( 'update_plugins', [] );

		\add_filter( 'pre_set_site_transient_update_plugins', [ $this, 'check_for_updates' ] );
	}

	/**
	 * Returns list of plugins to check
	 */
	public function get_plugins_to_check() {
		$recommended_plugins = Recommended_Plugins::get_list();

		if ( empty( $recommended_plugins ) ) {
			return;
		}

		$plugins_to_check = [
			'total-theme-core',
		];

		foreach ( $plugins_to_check as $k => $v ) {
			if ( \array_key_exists( $v, $recommended_plugins ) ) {
				$plugin = $recommended_plugins[$v];
				if ( empty( $plugin['package' ] ) && isset( $plugin['source' ] ) ) {
					$plugin['package' ] = $plugin['source' ];
					unset( $plugin['source' ] );
				}
				$plugin['id' ]     = $this->get_plugin_base( $plugin );
				$plugin['plugin' ] = $plugin['id'];
			} else {
				unset( $plugins_to_check[$k] );
			}
			$plugins_to_check[$k] = $plugin;
		}

		return $plugins_to_check;
	}

	/**
	 * Check transients
	 */
	public function check_for_updates( $transient ) {
		if ( empty( $transient->checked ) ) {
			return $transient;
		}

		// Get plugins to check
		$plugins_to_check = $this->get_plugins_to_check();

		if ( empty( $plugins_to_check ) ) {
			return $transient;
		}

		// Return array of installed plugins
		$installed_plugins = $this->get_installed_plugins();

		// No plugins installed
		if ( empty( $installed_plugins ) || ! \is_array( $installed_plugins ) ) {
			return $transient;
		}

		// Loop through plugins and check if an update is available
		foreach ( $plugins_to_check as $plugin ) {

			if ( $this->is_plugin_installed( $plugin, $installed_plugins ) ) {

				$has_update = $this->has_update( $plugin, $installed_plugins );

				if ( $has_update ) {

					$response = (object) [
						'id'            => $plugin['id'],
						'slug'          => $plugin['slug'],
						'plugin'        => $plugin['plugin'],
						'new_version'   => $plugin['version'],
						'package'       => $plugin['package'],
						'url'           => '',
						'icons'         => [],
						'banners'       => [],
						'banners_rtl'   => [],
						'tested'        => '',
						'requires_php'  => '',
						'compatibility' => '',

					];

					$transient->response[ $plugin['id' ] ] = $response;

				} elseif ( isset( $transient->no_update ) ) {

					$item = (object) [
						'id'            => $plugin['id'],
						'slug'          => $plugin['slug'],
						'plugin'        => $plugin['plugin'],
						'new_version'   => $plugin['version'],
						'package'       => '',
						'url'           => '',
						'icons'         => [],
						'banners'       => [],
						'banners_rtl'   => [],
						'tested'        => '',
						'requires_php'  => '',
						'compatibility' => '',
					];

					$transient->no_update[ $plugin['id' ] ] = $item;

				}

			}

		}

		//var_dump( $transient );

		return $transient;
	}

	/**
	 * Get list of installed plugins.
	 */
	public function get_installed_plugins( $plugin_folder = '' ) {
		if ( ! \function_exists( 'get_plugins' ) ) {
			require_once ABSPATH . 'wp-admin/includes/plugin.php';
		}
		return \get_plugins( $plugin_folder );
	}

	/**
	 * Check if a specific plugin is installed.
	 */
	public function is_plugin_installed( $plugin, $installed_plugins ) {
		return \array_key_exists( $this->get_plugin_base( $plugin ), $installed_plugins );
	}

	/**
	 * Check if a plugin has an update available
	 */
	private function has_update( $plugin, $installed_plugins ) {
		$base = $this->get_plugin_base( $plugin );
		if ( ! empty( $installed_plugins[$base]['Version'] ) ) {
			return \version_compare( $plugin['version'], $installed_plugins[$base]['Version'], '>' );
		}
	}

	/**
	 * Returns plugin base from slug
	 */
	private function get_plugin_base( $plugin ) {
		return "{$plugin['slug']}/{$plugin['slug']}.php";
	}

}

https://t.me/RX1948 - 2025