wpo365-custom-fields.php
4.43 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
* Plugin Name: WPO365 | CUSTOM USER FIELDS
* Plugin URI: https://www.wpo365.com/downloads/wpo365-custom-user-fields/
* Description: Synchronize Azure AD user attributes e.g. department, job title etc. to WordPress user profiles (includes the PROFILE+ extension).
* Version: 25.1
* Author: support@wpo365.com
* Author URI: https://www.wpo365.com
* License: See license.txt
*/
namespace Wpo;
require __DIR__ . '/vendor/autoload.php';
// Prevent public access to this script
defined('ABSPATH') or die();
if (!class_exists('\Wpo\Custom_Fields')) {
class Custom_Fields
{
public function __construct()
{
// Show admin notification when BASIC edition is not installed
add_action('admin_notices', array($this, 'ensure_wpo365_login'), 10, 0);
add_action('network_admin_notices', array($this, 'ensure_wpo365_login'), 10, 0);
add_action('plugins_loaded', array($this, 'ensure_wpo365_login'), 10, 0);
}
public function ensure_wpo365_login()
{
$version_exists = \class_exists('\Wpo\Core\Version') && isset(\Wpo\Core\Version::$current) && \Wpo\Core\Version::$current >= 20;
if (current_action() == 'plugins_loaded') {
if (!$version_exists) {
if (false === function_exists('deactivate_plugins')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
deactivate_plugins(plugin_basename(__FILE__));
}
return;
}
$plugin_exists = \file_exists(dirname(__DIR__) . '/wpo365-login');
// Required version installed and activated
if ($version_exists) {
return;
}
// Required plugin not installed
if (!$plugin_exists) {
$install_url = wp_nonce_url(
add_query_arg(
array(
'action' => 'install-plugin',
'plugin' => 'wpo365-login',
'from' => 'plugins',
),
self_admin_url('update.php')
),
'install-plugin_wpo365-login'
);
echo '<div class="notice notice-error" style="margin-left: 2px;"><p>'
. sprintf(__('The %s plugin requires the latest version of %s to be installed and activated.', 'wpo365-login'), '<strong>WPO365 | CUSTOM USER FIELDS</strong>', '<strong>WPO365 | LOGIN (free)</strong>')
. '</p><p>'
. '<a class="button button-primary" href="' . esc_url($install_url) . '">' . __('Install plugin', 'wpo365-login') . '</a>.'
. '</p></div>';
return;
}
// Required plubin installed but must either be activated or upgraded
$activate_url = add_query_arg(
array(
'_wpnonce' => wp_create_nonce('activate-plugin_wpo365-login/wpo365-login.php'),
'action' => 'activate',
'plugin' => 'wpo365-login/wpo365-login.php',
),
network_admin_url('plugins.php')
);
if (is_network_admin()) {
$activate_url = add_query_arg(array('networkwide' => 1), $activate_url);
}
$update_url = wp_nonce_url(
self_admin_url('update.php?action=upgrade-plugin&plugin=') . 'wpo365-login/wpo365-login.php',
'upgrade-plugin_wpo365-login/wpo365-login.php'
);
echo '<div class="notice notice-error" style="margin-left: 2px;"><p>'
. sprintf(__('The %s plugin requires the latest version of %s to be installed and activated.', 'wpo365-login'), '<strong>WPO365 | CUSTOM USER FIELDS</strong>', '<strong>WPO365 | LOGIN (free)</strong>')
. '</p><p>'
. '<a class="button button-primary" href="' . esc_url($activate_url) . '">' . __('Activate plugin', 'wpo365-login') . '</a> '
. '<a class="button button-primary" href="' . esc_url($update_url) . '">' . __('Update plugin', 'wpo365-login') . '</a>'
. '</p></div>';
}
}
}
$wpo365_custom_fields = new Custom_Fields();