forked from iandunn/WordPress-Plugin-Skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
80 lines (65 loc) · 2.35 KB
/
bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/*
Plugin Name: WordPress Plugin Skeleton
Plugin URI: https://github.com/iandunn/WordPress-Plugin-Skeleton
Description: The skeleton for an object-oriented/MVC WordPress plugin
Version: 0.4a
Author: Ian Dunn
Author URI: http://iandunn.name
*/
/*
* This plugin was built on top of WordPress-Plugin-Skeleton by Ian Dunn.
* See https://github.com/iandunn/WordPress-Plugin-Skeleton for details.
*/
if( $_SERVER[ 'SCRIPT_FILENAME' ] == __FILE__ )
die( 'Access denied.' );
define( 'WPPS_NAME', 'WordPress Plugin Skeleton' );
define( 'WPPS_REQUIRED_PHP_VERSION', '5.3' ); // because of get_called_class()
define( 'WPPS_REQUIRED_WP_VERSION', '3.1' ); // because of esc_textarea()
/**
* Checks if the system requirements are met
* @author Ian Dunn <[email protected]>
* @return bool True if system requirements are met, false if not
*/
function wpps_requirementsMet()
{
global $wp_version;
//require_once( ABSPATH .'/wp-admin/includes/plugin.php' ); // to get is_plugin_active() early
if( version_compare( PHP_VERSION, WPPS_REQUIRED_PHP_VERSION, '<' ) )
return false;
if( version_compare( $wp_version, WPPS_REQUIRED_WP_VERSION, '<' ) )
return false;
//if( !is_plugin_active( 'plugin-directory/plugin-file.php' ) )
//return false;
return true;
}
/**
* Prints an error that the system requirements weren't met.
* @author Ian Dunn <[email protected]>
*/
function wpps_requirementsError()
{
global $wp_version;
$class = 'error';
ob_start();
require_once( dirname( __FILE__ ) . '/views/requirements-error.php' );
$message = ob_get_contents();
ob_end_clean();
require( dirname( __FILE__ ) . '/includes/IDAdminNotices/v-admin-notice.php' );
}
// Check requirements and load main class
// The main program needs to be in a separate file that only gets loaded if the plugin requirements are met. Otherwise older PHP installations could crash when trying to parse it.
if( wpps_requirementsMet() )
{
require_once( dirname( __FILE__ ) . '/classes/wpps-module.php' );
require_once( dirname( __FILE__ ) . '/classes/wordpress-plugin-skeleton.php' );
if( class_exists( 'WordPressPluginSkeleton' ) )
{
$wpps = WordPressPluginSkeleton::getInstance();
register_activation_hook( __FILE__, array( $wpps, 'activate' ) );
register_deactivation_hook( __FILE__, array( $wpps, 'deactivate' ) );
}
}
else
add_action( 'admin_notices', 'wpps_requirementsError' );
?>