azure-active-directory.php
3.34 KB
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
81
82
83
84
85
86
87
<?php
/*
Plugin Name: Azure Active Directory
Plugin URI: http://wordpress.org/extend/plugins/azure-active-directory/
Version: 0.1
Author: Jeff Balicki
Description: Azure Active Directory
Text Domain: azure-active-directory
License: GPLv3
*/
/*
"WordPress Plugin Template" Copyright (C) 2017 Michael Simpson (email : michael.d.simpson@gmail.com)
This following part of this file is part of WordPress Plugin Template for WordPress.
WordPress Plugin Template is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
WordPress Plugin Template is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Contact Form to Database Extension.
If not, see http://www.gnu.org/licenses/gpl-3.0.html
*/
$AzureActiveDirectory_minimalRequiredPhpVersion = '5.0';
/**
* Check the PHP version and give a useful error message if the user's version is less than the required version
* @return boolean true if version check passed. If false, triggers an error which WP will handle, by displaying
* an error message on the Admin page
*/
function AzureActiveDirectory_noticePhpVersionWrong() {
global $AzureActiveDirectory_minimalRequiredPhpVersion;
echo '<div class="updated fade">' .
__('Error: plugin "Azure Active Directory" requires a newer version of PHP to be running.', 'azure-active-directory').
'<br/>' . __('Minimal version of PHP required: ', 'azure-active-directory') . '<strong>' . $AzureActiveDirectory_minimalRequiredPhpVersion . '</strong>' .
'<br/>' . __('Your server\'s PHP version: ', 'azure-active-directory') . '<strong>' . phpversion() . '</strong>' .
'</div>';
}
function AzureActiveDirectory_PhpVersionCheck() {
global $AzureActiveDirectory_minimalRequiredPhpVersion;
if (version_compare(phpversion(), $AzureActiveDirectory_minimalRequiredPhpVersion) < 0) {
add_action('admin_notices', 'AzureActiveDirectory_noticePhpVersionWrong');
return false;
}
return true;
}
/**
* Initialize internationalization (i18n) for this plugin.
* References:
* http://codex.wordpress.org/I18n_for_WordPress_Developers
* http://www.wdmac.com/how-to-create-a-po-language-translation#more-631
* @return void
*/
function AzureActiveDirectory_i18n_init() {
$pluginDir = dirname(plugin_basename(__FILE__));
load_plugin_textdomain('azure-active-directory', false, $pluginDir . '/languages/');
}
//////////////////////////////////
// Run initialization
/////////////////////////////////
// Initialize i18n
add_action('plugins_loaded','AzureActiveDirectory_i18n_init');
// Run the version check.
// If it is successful, continue with initialization for this plugin
if (AzureActiveDirectory_PhpVersionCheck()) {
// Only load and run the init function if we know PHP version can parse it
include_once('azure-active-directory_init.php');
include_once('api/GraphServiceAccessHelper.php');
AzureActiveDirectory_init(__FILE__);
}