| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: LearnPress - Course Wishlist |
| 4 |
* Plugin URI: http://thimpress.com/learnpress |
| 5 |
* Description: Wishlist feature. |
| 6 |
* Author: ThimPress |
| 7 |
* Version: 4.0.8 |
| 8 |
* Author URI: http://thimpress.com |
| 9 |
* Tags: learnpress |
| 10 |
* Text Domain: learnpress-wishlist |
| 11 |
* Domain Path: /languages/ |
| 12 |
* Require_LP_Version: 4.2.7-beta.0 |
| 13 |
* |
| 14 |
* @package LearnPress-Course-Wishlist |
| 15 |
*/ |
| 16 |
|
| 17 |
/** |
| 18 |
* Prevent loading this file directly |
| 19 |
*/ |
| 20 |
defined( 'ABSPATH' ) || exit(); |
| 21 |
|
| 22 |
const LP_ADDON_WISHLIST_FILE = __FILE__; |
| 23 |
|
| 24 |
/** |
| 25 |
* Class LP_Addon_Wishlist_Preload |
| 26 |
*/ |
| 27 |
class LP_Addon_Wishlist_Preload { |
| 28 |
/** |
| 29 |
* @var array|string[] |
| 30 |
*/ |
| 31 |
public static $addon_info = array(); |
| 32 |
/** |
| 33 |
* @var LP_Addon_Wishlist $addon |
| 34 |
*/ |
| 35 |
public static $addon; |
| 36 |
|
| 37 |
/** |
| 38 |
* Singleton. |
| 39 |
* |
| 40 |
* @return LP_Addon_Wishlist_Preload|mixed |
| 41 |
*/ |
| 42 |
public static function instance() { |
| 43 |
static $instance; |
| 44 |
if ( is_null( $instance ) ) { |
| 45 |
$instance = new self(); |
| 46 |
} |
| 47 |
|
| 48 |
return $instance; |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* LP_Addon_Wishlist_Preload constructor. |
| 53 |
*/ |
| 54 |
protected function __construct() { |
| 55 |
// Set Base name plugin. |
| 56 |
define( 'LP_ADDON_WISHLIST_BASENAME', plugin_basename( LP_ADDON_WISHLIST_FILE ) ); |
| 57 |
|
| 58 |
// Set version addon for LP check . |
| 59 |
include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 60 |
self::$addon_info = get_file_data( |
| 61 |
LP_ADDON_WISHLIST_FILE, |
| 62 |
array( |
| 63 |
'Name' => 'Plugin Name', |
| 64 |
'Require_LP_Version' => 'Require_LP_Version', |
| 65 |
'Version' => 'Version', |
| 66 |
) |
| 67 |
); |
| 68 |
|
| 69 |
define( 'LP_ADDON_WISHLIST_VER', self::$addon_info['Version'] ); |
| 70 |
define( 'LP_ADDON_WISHLIST_REQUIRE_VER', self::$addon_info['Require_LP_Version'] ); |
| 71 |
|
| 72 |
// Check LP activated . |
| 73 |
if ( ! is_plugin_active( 'learnpress/learnpress.php' ) ) { |
| 74 |
add_action( 'admin_notices', array( $this, 'show_note_errors_require_lp' ) ); |
| 75 |
|
| 76 |
deactivate_plugins( LP_ADDON_WISHLIST_BASENAME ); |
| 77 |
|
| 78 |
if ( isset( $_GET['activate'] ) ) { |
| 79 |
unset( $_GET['activate'] ); |
| 80 |
} |
| 81 |
|
| 82 |
return; |
| 83 |
} |
| 84 |
|
| 85 |
// Sure LP loaded. |
| 86 |
add_action( 'learn-press/ready', array( $this, 'load' ) ); |
| 87 |
} |
| 88 |
|
| 89 |
/** |
| 90 |
* Load addon |
| 91 |
*/ |
| 92 |
public function load() { |
| 93 |
self::$addon = LP_Addon::load( 'LP_Addon_Wishlist', 'inc/load.php', __FILE__ ); |
| 94 |
} |
| 95 |
|
| 96 |
public function show_note_errors_require_lp() { |
| 97 |
?> |
| 98 |
<div class="notice notice-error"> |
| 99 |
<p><?php echo( 'Please active <strong>LP version ' . LP_ADDON_WISHLIST_REQUIRE_VER . ' or later</strong> before active <strong>' . self::$addon_info['Name'] . '</strong>' ); ?></p> |
| 100 |
</div> |
| 101 |
<?php |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
LP_Addon_Wishlist_Preload::instance(); |
| 106 |
|