PluginProbe
LearnPress – bbPress Integration / 4.0.4
LearnPress – bbPress Integration v4.0.4
trunk 0.9.3 1.0 1.1 2.0 2.1.2 3.0.0 3.0.1 3.0.2 3.0.3 4.0.4 4.0.5 4.0.6 4.0.7
learnpress-bbpress / learnpress-bbpress.php

learnpress-bbpress.php in LearnPress – bbPress Integration 4.0.4, at learnpress-bbpress.php

140 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: LearnPress - bbPress Integration
4 * Plugin URI: http://thimpress.com/learnpress
5 * Description: Using the forum for courses provided by bbPress.
6 * Author: ThimPress
7 * Version: 4.0.4
8 * Author URI: http://thimpress.com
9 * Tags: learnpress, lms, add-on, bbpress
10 * Text Domain: learnpress-bbpress
11 * Domain Path: /languages/
12 * Require_LP_Version: 4.2.6
13 * Require_BBpress_Version: 2.0.0
14 *
15 * @package LearnPress-bbPress-Integration
16 */
17
18 defined( 'ABSPATH' ) || exit;
19
20 const LP_ADDON_BBPRESS_FILE = __FILE__;
21
22 /**
23 * Class LP_Addon_bbPress_Preload
24 */
25 class LP_Addon_bbPress_Preload {
26 /**
27 * @var array|string[]
28 */
29 public static $addon_info = array();
30
31 /**
32 * LP_Addon_bbPress_Preload constructor.
33 */
34 public function __construct() {
35 // Set Base name plugin.
36 define( 'LP_ADDON_BBPRESS_BASENAME', plugin_basename( LP_ADDON_BBPRESS_FILE ) );
37
38 if ( ! function_exists( 'get_plugin_data' ) ) {
39 require_once ABSPATH . 'wp-admin/includes/plugin.php';
40 }
41
42 // Set version addon for LP check .
43 self::$addon_info = get_file_data(
44 LP_ADDON_BBPRESS_FILE,
45 array(
46 'Name' => 'Plugin Name',
47 'Require_LP_Version' => 'Require_LP_Version',
48 'Version' => 'Version',
49 'Require_BBpress_Version' => 'Require_BBpress_Version',
50 )
51 );
52
53 define( 'LP_ADDON_BBPRESS_VER', self::$addon_info['Version'] );
54 define( 'LP_ADDON_BBPRESS_REQUIRE_VER', self::$addon_info['Require_LP_Version'] );
55
56 // Check LP activated .
57 if ( ! is_plugin_active( 'learnpress/learnpress.php' ) ) {
58 add_action( 'admin_notices', array( $this, 'show_note_errors_require_lp' ) );
59
60 deactivate_plugins( LP_ADDON_BBPRESS_BASENAME );
61
62 if ( isset( $_GET['activate'] ) ) {
63 unset( $_GET['activate'] );
64 }
65
66 return;
67 }
68
69 // Check BBpress activated.
70 $bbpress_valid = true;
71 if ( ! is_plugin_active( 'bbpress/bbpress.php' ) ) {
72 $bbpress_valid = false;
73 } else {
74 $bbpress_info = get_plugin_data( WP_PLUGIN_DIR . '/bbpress/bbpress.php' );
75
76 if ( version_compare( self::$addon_info['Require_BBpress_Version'], $bbpress_info['Version'], '>' ) ) {
77 $bbpress_valid = false;
78 }
79 }
80
81 if ( ! $bbpress_valid ) {
82 add_action( 'admin_notices', array( $this, 'show_notices_bbpress' ) );
83
84 deactivate_plugins( LP_ADDON_BBPRESS_BASENAME );
85
86 if ( isset( $_GET['activate'] ) ) {
87 unset( $_GET['activate'] );
88 }
89
90 return;
91 }
92
93 // Sure LP loaded.
94 add_action( 'learn-press/ready', array( $this, 'load' ) );
95 }
96
97 /**
98 * Load addon
99 */
100 public function load() {
101 LP_Addon::load( 'LP_Addon_bbPress', 'inc/load.php', __FILE__ );
102 }
103
104 public function show_note_errors_require_lp() {
105 ?>
106 <div class="notice notice-error">
107 <p><?php echo( 'Please active <strong>LearnPress version ' . LP_ADDON_BBPRESS_REQUIRE_VER . ' or later</strong> before active <strong>' . self::$addon_info['Name'] . '</strong>' ); ?></p>
108 </div>
109 <?php
110 }
111
112 /**
113 * Show admin notice when inactive bbPress.
114 */
115 public function show_notices_bbpress() {
116 ?>
117 <div class="notice notice-error">
118 <p>
119 <?php echo wp_kses(
120 sprintf(
121 __( '<strong>BBPress</strong> addon for <strong>LearnPress</strong> requires %s version %s is <strong>activated</strong>.',
122 'learnpress-bbpress' ),
123 sprintf( '<a href="%s" target="_blank">bbPress</a>',
124 admin_url( 'plugin-install.php?tab=search&type=term&s=bbpress' ) ),
125 self::$addon_info['Require_BBpress_Version']
126 ), array(
127 'a' => array(
128 'href' => array(),
129 'target' => array(),
130 ),
131 'strong' => array()
132 )
133 ); ?>
134 </p>
135 </div>
136 <?php }
137 }
138
139 new LP_Addon_bbPress_Preload();
140