GhostManSec
Server: LiteSpeed
System: Linux premium197.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: parhudrw (1725)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/parhudrw/roflma.it/wp-content/plugins/lesya-plugin/lesya-plugin.php
<?php
/**
 * Plugin Name: Lesya Plugin
 * Plugin URI:
 * Description: This plugin it's designed for Lesya Theme
 * Version: 1.4.1
 * Author: bslthemes
 * Author URI: https://www.templatemonster.com/products/author/bslthemes/
 * Text Domain: lesya-plugin
 * Domain Path: /languages/
 * License: http://www.gnu.org/licenses/gpl.html
 */

// Block direct access to the main plugin file.
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );

// Init all plugins constants
if ( ! defined( 'LESYA_PLUGIN_PATH' ) ) {
	define( 'LESYA_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'LESYA_PLUGIN_URI' ) ) {
	define( 'LESYA_PLUGIN_URI', plugin_dir_url( __FILE__ ) );
}
if ( ! defined( 'LESYA_PLUGIN_THEME_NAME' ) ) {
	define( 'LESYA_PLUGIN_THEME_NAME', 'Lesya' );
}

// Main Class
if ( ! class_exists( 'LesyaPlugin' ) ) {

	class LesyaPlugin {

		public function __construct() {

		}

		public function init() {

			/*init*/
			$this->init_hooks();
			$this->init_cpt();
			$this->init_theme_helpers();
			$this->init_acf_ext();
			$this->init_elementor_addons();
			$this->init_dashboard();
		}

		public function plugin_load_textdomain() {
			/* load plugin text-domain */
			load_plugin_textdomain( 'lesya-plugin', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
		}

		public function init_hooks() {
			/* hooks */

			/* load languages */
			add_action( 'plugins_loaded', [$this, 'plugin_load_textdomain'] );

			/* fixed theme update */
			function lesya_fix_trans_after_update() {
				$transient = get_option( '_site_transient_update_themes' );
				$theme_slug = 'lesya';

				if ( isset( $transient->response[$theme_slug] ) && !empty( $transient ) ) {
					if ( $transient->response[$theme_slug]['new_version'] == wp_get_theme()->Version ) {
						unset($transient->response[$theme_slug]);
					}
					update_option( '_site_transient_update_themes', $transient );
				}
			}
			add_action('admin_init', 'lesya_fix_trans_after_update');

			/* notice register */
			add_action( 'admin_head', array( $this, 'dismiss' ) );
			add_action( 'upgrader_process_complete', array( $this, 'after_theme_upgrade' ), 10, 2 );
			add_action( 'switch_theme', array( $this, 'update_dismiss' ) );
		}

		public function init_cpt() {
			/* include custom post types */
			require_once LESYA_PLUGIN_PATH . 'inc/custom-post-types.php';
		}

		public function init_acf_ext() {
			/* include acf fields extention */
			require_once LESYA_PLUGIN_PATH . 'acf-ext/acf-ui-google-font/acf-ui-google-font.php';
			require_once LESYA_PLUGIN_PATH . 'acf-ext/acf-cf7/acf-cf7.php';
			require_once LESYA_PLUGIN_PATH . 'acf-ext/acf-fa/acf-font-awesome-font.php';
		}

		public function init_theme_helpers() {
		}

		public function init_elementor_addons() {
			/* include elementor addons */
			require_once LESYA_PLUGIN_PATH . 'elementor/functions.php';
		}

		public function init_dashboard() {
			/* include theme dashboard */
			require LESYA_PLUGIN_PATH . 'admin/dashboard-theme-helper.php';
			require LESYA_PLUGIN_PATH . 'admin/dashboard-theme-init.php';
			require LESYA_PLUGIN_PATH . 'admin/dashboard-theme-activation.php';
		}

		public function dismiss() {
			if ( isset( $_GET['lesya-dismiss'] ) && check_admin_referer( 'lesya-dismiss-' . get_current_user_id() ) ) {
				update_user_meta( get_current_user_id(), 'lesya_dismissed_notice', 1 );
			}
		}

		public function after_theme_upgrade( $upgrader_object, $options ) {
			if ( ( $options['action'] == 'install' ) && $options['type'] == 'theme' ) {
				 if ( $upgrader_object->new_theme_data['Name'] == 'Lesya' ) {
					 self::update_dismiss();
				 }
			}
			if ( ( $options['action'] == 'install' ) && $options['type'] == 'plugin' ) {
				 if ( $upgrader_object->new_plugin_data['Name'] == 'Lesya Plugin' ) {
					 self::update_dismiss();
				 }
			}
		}

		static function update_dismiss() {
			delete_metadata( 'user', null, 'lesya_dismissed_notice', null, true );
		}

		static function get_plugin_info() {
			if ( !function_exists( 'get_plugin_data' ) ) {
				require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
			}
			return get_plugin_data( __FILE__, true, false );
		}

		static function clear_rewrite_rules() {
			update_option( 'rewrite_rules', '' );
		}

		static function elementor_init_cpt_support() {
			$cpt_support = get_option( 'elementor_cpt_support' );

			if( ! $cpt_support ) {
			    $cpt_support = [ 'page', 'post', 'portfolio', 'services' ];
			    update_option( 'elementor_cpt_support', $cpt_support );
			} else if( ! in_array( 'portfolio', $cpt_support ) ) {
			    $cpt_support[] = 'portfolio';
			    update_option( 'elementor_cpt_support', $cpt_support );
			} else if( ! in_array( 'services', $cpt_support ) ) {
			    $cpt_support[] = 'services';
			    update_option( 'elementor_cpt_support', $cpt_support );
			}
		}

		static function elementor_disable_default_schemes() {
			$color_schemes = get_option( 'elementor_disable_color_schemes' );
			$typography_schemes = get_option( 'elementor_disable_typography_schemes' );

			if( ! $color_schemes ) {
			    update_option( 'elementor_disable_color_schemes', 'yes' );
			}
			if( ! $typography_schemes ) {
			    update_option( 'elementor_disable_typography_schemes', 'yes' );
			}
		}

		static function activation() {
			self::clear_rewrite_rules();
			self::elementor_init_cpt_support();
			self::elementor_disable_default_schemes();
			self::update_dismiss();
		}

		static function deactivation() {
			self::clear_rewrite_rules();
			self::update_dismiss();
		}
	}

}

$lesyaPlugin = new LesyaPlugin();
$lesyaPlugin->init();

register_activation_hook( __FILE__, array( $lesyaPlugin, 'activation' ) );
register_deactivation_hook( __FILE__, array( $lesyaPlugin, 'deactivation' ) );