Your IP : 216.73.216.196


Current Path : /home/icmq6107/clients/ImpactNumerik/Projets/refonte/wp-content/plugins/victim-core/
Upload File :
Current File : /home/icmq6107/clients/ImpactNumerik/Projets/refonte/wp-content/plugins/victim-core/victim-core.php

<?php
/**
 * @link              https://softhopper.net
 * @since             1.0.0
 * @package           Victim_Core
 *
 * @wordpress-plugin
 * Plugin Name:       Victim Core
 * Plugin URI:        https://victim.softhopper.net
 * Description:       This plugin is add-on to Victim Creative Portfolio WordPress theme which offers exclusive premium features, Specially design for Victim, to enhance your overall WordPress experience.
 * Version:           1.0.9
 * Author:            SoftHopper
 * Author URI:        https://softhopper.net
 * Text Domain:       victim-core
 * Domain Path:       /languages
 */

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
	die;
}

/**
 * Currently plugin version.
 * Start at version 1.0.0 and use SemVer - https://semver.org
 * Rename this for your plugin and update it as you release new versions.
 */
define( 'VICTIM_CORE_VERSION', '1.0.0' );
define( 'VICTIM_PLUGIN_PATH', ABSPATH . 'wp-content/plugins/victim-core' );
define( 'VICTIM_PLUGIN_URL', plugins_url( '', __FILE__ ) );

$theme = get_template();

if ( $theme !== 'victim' ) {
	add_action( 'admin_notices', 'victim_display_wrong_theme_notice' );
	add_action( 'admin_init', 'victim_disable_wrong_theme_notice' );

	return;
}

/**
 * Notice displayed if the theme is not Victim or a child theme of Victim.
 *
 * @since 0.0.1
 */
function victim_display_wrong_theme_notice() {

	global $current_user;
	$user_id        = $current_user->ID;
	$ignored_notice = get_user_meta( $user_id, 'victim_nag_ignore_theme_notice' );
	if ( ! empty( $ignored_notice ) ) {
		return;
	}

	$dismiss_button = sprintf(
		'<a href="%s" class="notice-dismiss" style="text-decoration:none;"></a>',
		'?victim_nag_ignore_theme_notice=ignore'
	);

	$strings = array(
		'errOccured'      => __( 'An error occurred. Please refresh the page and try again.', 'victim' ),
		'activating'      => __( 'Activating...', 'victim-core' ),
		'activate'        => __( 'Activate Victim', 'victim-core' ),
		'installActivate' => __( 'Install and Activate Victim', 'victim-core' ),
	);

	$themes      = wp_get_themes();
	$button_text = $strings['installActivate'];
	$action      = 'install';
	$url         = esc_url( admin_url( 'update.php?action=install-theme&theme=victim&_wpnonce=' . wp_create_nonce( 'install-theme_victim' ) ) );
	if ( isset( $themes['victim'] ) ) {
		$url         = esc_url( admin_url( 'themes.php?action=activate&amp;template=victim&amp;stylesheet=victim&_wpnonce=' . wp_create_nonce( 'switch-theme_victim' ) ) );
		$button_text = $strings['activate'];
		$action      = 'activate';
	}

	/* translators: %1$s - plugin name, %2$s - theme name, %3$s - call to action */
	$message = sprintf( __( '%1$s requires the %2$s theme to be activated to work. %3$s', 'victim' ), sprintf( '<strong>%s</strong>', 'victim-core' ), sprintf( '<strong>%s</strong>', 'Victim' ), sprintf( '<br/><a class="install-activate-victim theme-install button button-primary" data-action="%4$s" data-name="Victim" data-slug="victim" href="%1$s" aria-label="%3$s">%2$s</a>', $url, $button_text, $button_text, $action ) );

	printf(
		'<div class="notice notice-error install-victim" style="position:relative;">%1$s<p>%2$s</p></div>',
		$dismiss_button,
		$message
	); ?>
	<style>
		.install-victim .error-message {
			background-color: #F56E28;
			color: #fff;
		}
		.install-victim .install-activate-victim {
			margin-top: 10px;
		}
	</style>
	<script>
		( function($) {
			var button = $( '.install-activate-victim' );

			$( button ).on( 'click', function(e) {
				if ( $( this ).data( 'action' ) === 'activate' ) {
					$( button ).html( '<?php echo esc_html( $strings['activating'] ); ?>' );
					$( button ).addClass( 'updating-message' );
					return;
				}
				e.preventDefault();
				wp.updates.installTheme( {
					slug: 'victim',
					success: function(response) {
						if ( response.activateUrl ) {
							$( button ).html( '<?php echo esc_html( $strings['activating'] ); ?>' );
							location.href = response.activateUrl;
						}
					},
					error: function(error) {
						var message;
						if ( error.errorMessage ) {
							message = error.errorMessage;
						} else {
							message = '<?php echo esc_html( $strings['errOccured'] ); ?>';
						}
						$( button ).replaceWith( '<code class="error-message">Error: ' + message + '</code>' );
					}
				} );
			} );
		} )( jQuery );
	</script>
	<?php
}

/**
 * Disable the notice that appears if the theme is not Victim or a child theme of Victim.
 *
 * @since 0.0.1
 */
function victim_disable_wrong_theme_notice() {
	global $current_user;
	$user_id = $current_user->ID;
	/* If user clicks to ignore the notice, add that to their user meta */
	if ( isset( $_GET['victim_nag_ignore_theme_notice'] ) && 'ignore' === $_GET['victim_nag_ignore_theme_notice'] ) {
		add_user_meta( $user_id, 'victim_nag_ignore_theme_notice', 'true', true );
	}
}

/**
 * The code that runs during plugin activation.
 * This action is documented in includes/class-victim-core-activator.php
 */
function activate_victim_core() {
	require_once plugin_dir_path( __FILE__ ) . 'includes/class-victim-core-activator.php';
	Victim_Core_Activator::activate();
}

/**
 * The code that runs during plugin deactivation.
 * This action is documented in includes/class-victim-core-deactivator.php
 */
function deactivate_victim_core() {
	require_once plugin_dir_path( __FILE__ ) . 'includes/class-victim-core-deactivator.php';
	Victim_Core_Deactivator::deactivate();
}

register_activation_hook( __FILE__, 'activate_victim_core' );
register_deactivation_hook( __FILE__, 'deactivate_victim_core' );

/**
 * The core plugin class that is used to define internationalization,
 * admin-specific hooks, and public-facing site hooks.
 */
require plugin_dir_path( __FILE__ ) . 'includes/class-victim-core.php';

/**
 * Begins execution of the plugin.
 *
 * Since everything within the plugin is registered via hooks,
 * then kicking off the plugin from this point in the file does
 * not affect the page life cycle.
 *
 * @since    1.0.0
 */
function run_victim_core() {

	$plugin = new Victim_Core();
	$plugin->run();

}
run_victim_core();