25f14345 by Jeff Balicki

WPO365 | CUSTOM USER FIELDS

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent d7b2bbe7
=== WPO365 | CUSTOM USER FIELDS ===
Contributors: wpo365
Tags: office 365, O365, Microsoft 365, avatar, user profile, Microsoft Graph
Requires at least: 5.0
Tested up to: 6.4
Stable tag: 25.1
Requires PHP: 5.6.40
== Description ==
Synchronize Azure AD user attributes e.g. department, job title etc. to WordPress user profiles (includes the PROFILE+ extension).
= Plugin Features =
- Synchronize Microsoft 365 / Azure AD profile fields e.g. job title, department or employee number to WordPress / BuddyPress.
= Prerequisites =
- The [WPO365 | LOGIN plugin](https://wordpress.org/plugins/wpo365-login/) must be installed and activated. See [online documentation](https://docs.wpo365.com/article/98-synchronize-microsoft-365-azure-ad-profile-fields) for configuration example.
= Support =
We will go to great length trying to support you if the plugin doesn't work as expected. Go to our [Support Page](https://www.wpo365.com/how-to-get-support/) to get in touch with us. We haven't been able to test our plugin in all endless possible Wordpress configurations and versions so we are keen to hear from you and happy to learn!
= Feedback =
We are keen to hear from you so share your feedback with us on [Twitter](https://twitter.com/WPO365) and help us get better!
== Installation ==
1. Purchase the plugin from the [website](https://www.wpo365.com/).
2. Navigate to [Your Account](https://www.wpo365.com/your-account/) to download the premium extension.
3. Go to WP Admin > Plugins > Add new and click Upload plugin.
4. Upload the plugin.
5. Wait until the installation finishes and then click Activate.
6. See [online documentation](https://docs.wpo365.com/article/98-synchronize-microsoft-365-azure-ad-profile-fields) for configuration example.
== Frequently Asked Questions ==
== Screenshots ==
== Upgrade Notice ==
== Changelog ==
Please check the [online change log](https://www.wpo365.com/change-log/) for changes.
\ No newline at end of file
<?php
namespace Wpo\Services;
use \Wpo\Core\WordPress_Helpers;
use \Wpo\Services\Log_Service;
use \Wpo\Services\Options_Service;
use \Wpo\Services\User_Details_Service;
// Prevent public access to this script
defined('ABSPATH') or die();
if (!class_exists('\Wpo\Services\BuddyPress_Service')) {
class BuddyPress_Service
{
/**
* Adds an additional section to the bottom of the user profile page
*
* @since 5.3
*
* @param WP_User $user whose profile is being shown
* @return void
*/
public static function bp_show_extra_user_fields($user)
{
if (false === Options_Service::get_global_boolean_var('graph_user_details')) {
Log_Service::write_log('DEBUG', __METHOD__ . ' -> Extra user fields disabled as per configuration');
return;
} elseif (true === Options_Service::get_global_boolean_var('use_bp_extended')) {
Log_Service::write_log('DEBUG', __METHOD__ . ' -> Extra user fields will be display on BuddyPress Extended Profile instead');
return;
} elseif (!class_exists('\Wpo\Services\User_Details_Service')) {
Log_Service::write_log('WARN', __METHOD__ . ' -> Cannot show extra BuddyPress fields because of missing dependency');
return;
} else {
echo ('<div class="bp-widget base">');
echo ('<h3 class="screen-heading profile-group-title">' . __('Directory Info', 'wpo365-login') . '</h3>');
echo ('<table class="profile-fields bp-tables-user"><tbody>');
\Wpo\Services\User_Custom_Fields_Service::process_extra_user_fields(function ($name, $title) use (&$user) {
$parsed_user_field_key = User_Details_Service::parse_user_field_key($name);
$name = $parsed_user_field_key[0];
$wp_user_meta_key = $parsed_user_field_key[1];
$value = get_user_meta(\bp_displayed_user_id(), $wp_user_meta_key, true);
echo ('<tr class="field_1 field_name required-field visibility-public field_type_textbox"><td class="label">' . esc_html($title) . '</td>');
if (is_array($value)) {
echo ('<td class="data">');
foreach ($value as $idx => $val)
echo ('<p>' . esc_html($val) . '</p>');
echo ('</td>');
} else
echo ('<td class="data"><p>' . esc_html($value) . '</p></td>');
echo ("</tr>");
});
echo ('</tbody></table></div>');
}
}
/**
* Helper method that returns the O365 avatar for Buddy Press.
*
* @since 9.0
*
* @param $avatar Image tag for the user's avatar.
* @return string Image tag for the user's avatar possibly with img URL replaced with O365 profile image URL.
*/
public static function fetch_buddy_press_avatar($bp_avatar, $params)
{
if (false === Options_Service::get_global_boolean_var('use_bp_avatar')) {
return $bp_avatar;
}
if (!is_array($params) || !isset($params['item_id'])) {
return $bp_avatar;
}
if (!class_exists('\Wpo\Services\Avatar_Service')) {
Log_Service::write_log('WARN', __METHOD__ . ' -> Cannot BuddyPress avatar because of missing dependency');
return $bp_avatar;
}
/**
* @since 10.5
*
* Don't return avatar if objec is not a user (e.g. but a group)
*/
if (is_array($params) && isset($params['object']) && false === WordPress_Helpers::stripos($params['object'], 'user')) {
return $bp_avatar;
}
$o365_avatar_url = \Wpo\Services\Avatar_Service::get_o365_avatar_url(intval($params['item_id']));
return empty($o365_avatar_url)
? $bp_avatar
: \preg_replace('/src=".+?"/', 'src="' . $o365_avatar_url . '"', $bp_avatar);
}
}
}
<?php
namespace Wpo\Services;
// Prevent public access to this script
defined('ABSPATH') or die();
use \Wpo\Core\User;
use \Wpo\Core\WordPress_Helpers;
use \Wpo\Services\Log_Service;
use \Wpo\Services\Options_Service;
use \Wpo\Services\Graph_Service;
use \Wpo\Services\User_Service;
if (!class_exists('\Wpo\Services\User_Details_Service')) {
class User_Details_Service
{
/**
* @since 11.0
*/
public static function try_improve_core_fields(&$wpo_usr)
{
Log_Service::write_log('DEBUG', '##### -> ' . __METHOD__);
if (isset($wpo_usr->graph_resource['userPrincipalName'])) {
$wpo_usr->upn = $wpo_usr->graph_resource['userPrincipalName'];
}
if (isset($wpo_usr->graph_resource['mail'])) {
$wpo_usr->email = $wpo_usr->graph_resource['mail'];
}
if (isset($wpo_usr->graph_resource['givenName'])) {
$wpo_usr->first_name = $wpo_usr->graph_resource['givenName'];
}
if (isset($wpo_usr->graph_resource['surname'])) {
$wpo_usr->last_name = $wpo_usr->graph_resource['surname'];
}
if (isset($wpo_usr->graph_resource['displayName'])) {
$wpo_usr->full_name = $wpo_usr->graph_resource['displayName'];
}
$graph_display_name_format = Options_Service::get_global_string_var('graph_display_name_format');
if ($graph_display_name_format == 'skip') {
$wpo_usr->full_name = '';
} else {
if (!empty($wpo_usr->first_name) && !empty($wpo_usr->last_name)) {
if ($graph_display_name_format == 'givenNameSurname') {
$wpo_usr->full_name = sprintf('%s %s', $wpo_usr->first_name, $wpo_usr->last_name);
} elseif ($graph_display_name_format == 'surnameGivenName') {
$wpo_usr->full_name = sprintf('%s, %s', $wpo_usr->last_name, $wpo_usr->first_name);
}
}
}
}
/**
* Retrieves the user's AAD group memberships and adds them to the internally used User.
*
* @since 11.0
*
* @param string $resource_identifier Object ID or user principal name
* @param bool $use_me Deprecated, the method will decide for itself
* @param bool $use_delegated If the true the plugin will use a token with delegated permissions
* @param bool $return_error Whether the method should return the error if one occurs
*
* @return object The graph resource if request or else null
*/
public static function get_graph_user($resource_identifier = null, $use_me = false, $use_delegated = false, $return_error = false)
{
Log_Service::write_log('DEBUG', '##### -> ' . __METHOD__);
$query = empty($resource_identifier)
? '/me'
: '/users/' . \rawurlencode($resource_identifier);
$select_properties = Options_Service::get_global_list_var('graph_select_properties');
if (!empty($select_properties)) {
$default_properties = array('businessPhones', 'displayName', 'givenName', 'jobTitle', 'mail', 'mobilePhone', 'officeLocation', 'preferredLanguage', 'surname', 'userPrincipalName', 'id', 'city', 'companyName', 'country', 'department', 'employeeId', 'streetAddress', 'state', 'postalCode');
$select_properties = array_merge($select_properties, $default_properties);
$select_properties = array_map(function ($item) {
return \trim($item);
}, $select_properties);
$query = sprintf(
'%s?$select=%s',
$query,
\implode(',', $select_properties)
);
}
$headers = array(
'Accept: application/json;odata.metadata=minimal',
'Content-Type: application/json',
);
$graph_resource = Graph_Service::fetch($query, 'GET', false, $headers, $use_delegated);
if (Graph_Service::is_fetch_result_ok($graph_resource, 'Could not retrieve user details')) {
return $graph_resource['payload'];
}
return $return_error ? $graph_resource : null;
}
/**
* This helper will create a new member graph_resource on the wpo_usr parameter,
* populates it with fields from the ID token instead and eventually returns the
* wpo_usr.
*
* @since 18.0
*
* @param object &$wpo_usr By reference
* @param object $id_token
* @return void
*/
public static function update_wpo_usr_from_id_token(&$wpo_usr, $id_token)
{
$extra_user_fields = Options_Service::get_global_list_var('extra_user_fields');
$wpo_usr->graph_resource = array();
// Just copy these "core" fields for User_Details_Service::try_improve_core_fields
if (!empty($wpo_usr->email)) {
$wpo_usr->graph_resource['mail'] = $wpo_usr->email;
}
if (!empty($wpo_usr->first_name)) {
$wpo_usr->graph_resource['givenName'] = $wpo_usr->first_name;
}
if (!empty($wpo_usr->last_name)) {
$wpo_usr->graph_resource['surname'] = $wpo_usr->last_name;
}
// Now try to add custom user fields to the mocked graph_resource
if (!empty($extra_user_fields)) {
$id_token_props = get_object_vars($id_token);
foreach ($extra_user_fields as $index => $keyValuePair) {
if (empty($keyValuePair) || !is_array($keyValuePair) || empty($keyValuePair['key'])) {
continue;
}
$parsed_user_field_key = self::parse_user_field_key($keyValuePair['key']);
$name = $parsed_user_field_key[0];
$value = array_key_exists($name, $id_token_props)
? $id_token_props[$name]
: false;
if (empty($value)) {
continue;
}
$wpo_usr->graph_resource[$name] = $value;
}
}
}
/**
* This helper will create a new member graph_resource on the wpo_usr parameter,
* populates it with fields from the SAML response instead and eventually returns the
* wpo_usr.
*
* @since 20.0
*
* @param mixed $wpo_usr
* @param mixed $saml_attributes
* @return void
*/
public static function update_wpo_usr_from_saml_attributes(&$wpo_usr, $saml_attributes)
{
if (is_array($saml_attributes)) {
$wpo_usr->saml_attributes = $saml_attributes;
}
}
/**
* Parses the extra_user_fields key that since v19.5 may be a compound field that contains
* the name for the usermeta field in WordPress for the user attribute retrieved from Microsoft
* Graph.
*
* @since 20.0
*
* @param mixed $name The name of the Microsoft Graph property possibly combined with a proposed name for the key for the usermeta e.g. mobilePhone;#msGraphMobilePhone
* @return array The name of the Microsoft Graph property and the proposed name for the key for the usermeta.
*/
public static function parse_user_field_key($name)
{
if (false !== WordPress_Helpers::stripos($name, ';#')) {
$name_arr = explode(';#', $name);
$name = $name_arr[0];
if (sizeof($name_arr) > 1) {
$wp_user_meta_key = $name_arr[1];
}
}
$wp_user_meta_key = empty($wp_user_meta_key) ? $name : $wp_user_meta_key;
return array(
$name,
$wp_user_meta_key
);
}
/**
* Administrators can prevent WordPress from sending emails when their email changed.
* This is especially useful since WordPress doesn't compare new and old email addresses
* case insensitive.
*
* @since 11.9
*
* @return boolean Whether or not to send the email changed notification.
*/
public static function prevent_send_email_change_email()
{
Log_Service::write_log('DEBUG', '##### -> ' . __METHOD__);
if (Options_Service::get_global_boolean_var('prevent_send_email_change_email')) {
return false;
}
return true;
}
}
}
<?php
namespace Wpo\Services;
use WP_Role;
use \Wpo\Core\Permissions_Helpers;
use \Wpo\Services\Log_Service;
use \Wpo\Services\Options_Service;
// Prevent public access to this script
defined('ABSPATH') or die();
if (!class_exists('\Wpo\Services\User_Role_Service')) {
class User_Role_Service
{
public static function update_user_roles($wp_usr_id, $wpo_usr)
{
Log_Service::write_log('DEBUG', '##### -> ' . __METHOD__);
if (Options_Service::get_global_boolean_var('enable_audiences') && class_exists('\Wpo\Services\Audiences_Service')) {
// Optionally update audience assignments
\Wpo\Services\Audiences_Service::aad_group_x_audience($wp_usr_id, $wpo_usr);
}
if (class_exists('\Wpo\Services\Mapped_Itthinx_Groups_Service') && method_exists('\Wpo\Services\Mapped_Itthinx_Groups_Service', 'aad_group_x_itthinx_group')) {
// Optionally update itthinx group assignments
\Wpo\Services\Mapped_Itthinx_Groups_Service::aad_group_x_itthinx_group($wp_usr_id, $wpo_usr);
}
if (class_exists('\Wpo\Services\Mapped_Itthinx_Groups_Service') && method_exists('\Wpo\Services\Mapped_Itthinx_Groups_Service', 'custom_field_x_itthinx_group')) {
// Optionally update itthinx group assignments
\Wpo\Services\Mapped_Itthinx_Groups_Service::custom_field_x_itthinx_group($wp_usr_id, $wpo_usr);
}
/**
* @since 24.0 LearnDash Integration
*/
if (class_exists('\Wpo\Services\LearnDash_Integration_Service') && method_exists('\Wpo\Services\LearnDash_Integration_Service', 'update_ld_assignments')) {
\Wpo\Services\LearnDash_Integration_Service::update_ld_assignments($wp_usr_id, $wpo_usr->groups);
}
$update_strategy = strtolower(Options_Service::get_global_string_var('replace_or_update_user_roles'));
if ($update_strategy == 'skip') {
Log_Service::write_log('DEBUG', __METHOD__ . ' -> Target role for user could not be determined because the administrator configured the plugin to not update user roles');
return;
}
// Get all possible roles for user
$user_roles = self::get_user_roles($wp_usr_id, $wpo_usr);
$wp_usr = \get_user_by('ID', $wp_usr_id);
if (!Options_Service::get_global_boolean_var('update_admins') && (\in_array('administrator', $wp_usr->roles) || is_super_admin($wp_usr_id))) {
Log_Service::write_log('DEBUG', __METHOD__ . ' -> Not updating the role for a user that is already an administrator.');
return;
}
$usr_default_role = is_main_site()
? Options_Service::get_global_string_var('new_usr_default_role')
: Options_Service::get_global_string_var('mu_new_usr_default_role');
// Remove default role -> It will be added later if requested as fallback
if (in_array($usr_default_role, $wp_usr->roles)) {
$wp_usr->remove_role($usr_default_role);
// refresh the user meta for
$wp_usr = \get_user_by('ID', $wp_usr_id);
}
// Empty any existing roles when configured to do so
if ($update_strategy == 'replace') {
foreach ($wp_usr->roles as $current_user_role) {
/**
* @since 24.0 Filters whether the role should be removed.
*/
$skip_remove_role = apply_filters('wpo365/roles/remove', false, $current_user_role);
if (!$skip_remove_role) {
$wp_usr->remove_role($current_user_role);
}
}
// refresh the user meta for
$wp_usr = \get_user_by('ID', $wp_usr_id);
}
// Add from new roles if not already added
foreach ($user_roles as $user_role) {
if (false === in_array($user_role, $wp_usr->roles)) {
$wp_usr->add_role($user_role);
}
}
// refresh the user meta for
$wp_usr = \get_user_by('ID', $wp_usr_id);
// Add default role if needed / configured
if (empty($wp_usr->roles) || (!empty($wp_usr->roles) && false === Options_Service::get_global_boolean_var('default_role_as_fallback'))) {
if (!empty($usr_default_role)) {
$wp_role = self::get_wp_role_case($usr_default_role);
if (empty($wp_role)) {
Log_Service::write_log('ERROR', __METHOD__ . ' -> Trying to add the default role but it appears undefined');
} else {
$wp_usr->add_role($usr_default_role);
}
}
}
}
/**
* Find a WP role in an case insensitive matter.
*
* @since 24.0
*
* @param mixed $role_name
* @return WP_Role|null
*/
public static function get_wp_role_case($role_name)
{
$wp_roles_objects = wp_roles()->role_objects;
foreach ($wp_roles_objects as $wp_role) {
if (strcasecmp($wp_role->name, $role_name) === 0) {
return $wp_role;
}
}
return null;
}
/**
* Gets the user's default role or if a mapping exists overrides that default role
* and returns the role according to the mapping.
*
* @since 3.2
*
*
* @return mixed(array|WP_Error) user's role as string or an WP_Error if not defined
*/
private static function get_user_roles($wp_usr_id, $wpo_usr)
{
$user_roles = array();
// Graph user resource property x WP role
if (class_exists('\Wpo\Services\Mapped_Custom_Fields_Service') && method_exists('\Wpo\Services\Mapped_Custom_Fields_Service', 'custom_field_x_role')) {
\Wpo\Services\Mapped_Custom_Fields_Service::custom_field_x_role($user_roles, $wpo_usr);
}
// AAD group x WP role
if (class_exists('\Wpo\Services\Mapped_Aad_Groups_Service') && method_exists('\Wpo\Services\Mapped_Aad_Groups_Service', 'aad_group_x_role')) {
\Wpo\Services\Mapped_Aad_Groups_Service::aad_group_x_role($user_roles, $wpo_usr);
}
// AAD group x Super Admin
if (class_exists('\Wpo\Services\Mapped_Aad_Groups_Service') && method_exists('\Wpo\Services\Mapped_Aad_Groups_Service', 'aad_group_x_super_admin')) {
\Wpo\Services\Mapped_Aad_Groups_Service::aad_group_x_super_admin($wp_usr_id, $wpo_usr, true);
}
// Logon Domain x WP role
if (class_exists('\Wpo\Services\Mapped_Domains_Service') && method_exists('\Wpo\Services\Mapped_Domains_Service', 'domain_x_role')) {
\Wpo\Services\Mapped_Domains_Service::domain_x_role($user_roles, $wpo_usr);
}
return $user_roles;
}
}
}
{
"name": "wpo365/wpo365-custom-fields",
"type": "plugin",
"description": "Synchronize Azure AD user attributes e.g. department, job title etc. to WordPress user profiles (includes the PROFILE+ extension).",
"keywords": ["wordpress", "Office 365", "O365", "Azure AD"],
"homepage": "https://www.wpo365.com/",
"license": "",
"authors": [
{
"name": "Marco van Wieren",
"email": "support@wpo365.com",
"homepage": "https://www.wpo365.com/",
"role": "Developer"
}
],
"require": {
"php": ">=5.6.40"
},
"autoload": {
"psr-4": {
"Wpo\\": "",
"Wpo\\Services\\": "Services"
}
}
}
Downloads by van Wieren - WPO365 | EXTENSION
Copyright 2012 - 2014
End User License Agreement
Commercial use
After you have purchased the plus version of our plugin
and have downloaded the plugin as ZIP file, you are licensed
to install the plugin only into the number of website(s)
corresponding to the license you purchased plus into a
corresponding staging environments.
You may not duplicate the plugin in whole or in part,
except that you may make one copy of it for backup or
archival purposes.
You may terminate this license at any time by destroying the
original and all copies of the plugin in whatever form.
You may permanently transfer all of your rights under this
EULA provided you transfer all copies of the plugin (including
copies of all prior versions if the plugin is an upgrade) and
retain none, and the recipient agrees to the terms of this EULA.
You may not redistribute, modify or resold the plugin in any
way without the written permission of Downloads by van Wieren. You may not rent,
lease, or lend the plugin. You may not use the plugin in any
software or application that compete with products and services
of Downloads by van Wieren.
School / Non-profit
If you purchase the School / Non-profit license, Downloads by van Wieren may
request you to submit proof of your organization’s status in
writing.
Warranty
Plugins sold and distributed by Downloads by van Wieren are done so in the hope
that they will be useful, but WITHOUT ANY WARRANTY. Inasmuch as
WordPress functions correctly on a clean install of itself,
Downloads by van Wieren plugins are guaranteed to function on a clean install
of the minimum, stable and required version of WordPress for
the plugins. Because the number and variety of third-party
plugins and themes is vast and wide, we do not guarantee that
the plugin will function with all third-party plugins,
themes or browsers of any kind.
We do not assume responsibility and will not be held responsible
for any conflicts or compatibility issues that may occur due to
third-party software. We assume no responsibility for any data
loss as a result of installing or using Downloads by van Wieren plugins.
Should conflicts occur with third-party software, we may provide support
at our discretion.
Refund Policy
We firmly believe in and stand behind our products 100%, but
we understand that they cannot work perfectly for everyone all
of the time. If you would like to request a refund, please contact
us at info@wpo365.com.
When requesting a refund, we respectfully ask that you meet the
following refund policy conditions:
Eligibility conditions for a refund request:
- You are within the first 30 days of the original purchase of the plugin.
- We cannot grant refunds after the first 30 days of the original purchase.
- You have purchased the plugin and after installing and testing the plugin,
have found that it will not work for your business or required setup.
Or
- You have an issue that we are unable to resolve which makes the system unusable.
We may ask you questions regarding the nature of your refund request so we can
improve the plugin in the future.
- If your issue(s) comes from not being able to install the plugin properly
or get the plugin to perform its basic functions, we will happily consider
your refund request.
- You have contacted our support team and allowed us to attempt to resolve
your issue(s), or have explained why the plugin will not work for you.
Please note, technical issues caused by 3rd party plugins, themes or other
software will not provide grounds for a refund.
- You agree to deactivate and uninstall the plugin from your site if a refund
is granted.
- Refunds will be offered at our sole discretion. By purchasing plugin(s) from
our site, you agree to this refund policy and relinquish any rights to subject
it to any questions, judgment or legal actions. We are not liable to cover any
differences in exchange rates between the time you purchased and the time you are
refunded.
Restrictions
Prohibition on Reverse Engineering, Decompilation, and Disassembly. You may not
reverse engineer, decompile, or disassemble the plugin in any way without the
written permission of Downloads by van Wieren.
Copyright
The plugin is owned by Downloads by van Wieren, and is protected by copyright laws
and international copyright treaties, as well as other intellectual property laws
and treaties. The plugin is licensed, not sold, to You for use solely subject to
the terms and conditions of this Agreement.
Termination
Without prejudice to any other rights, Downloads by van Wieren may terminate this
EULA if you fail to comply with the terms and conditions of this EULA. In such event,
you must destroy all copies of the plugin.
\ No newline at end of file
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitf106db3bb07a0cc7f373b495de3213f9::getLoader();
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Wpo\\Services\\' => array($baseDir . '/Services'),
'Wpo\\' => array($baseDir . '/'),
);
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitf106db3bb07a0cc7f373b495de3213f9
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitf106db3bb07a0cc7f373b495de3213f9', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitf106db3bb07a0cc7f373b495de3213f9', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitf106db3bb07a0cc7f373b495de3213f9::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
return $loader;
}
}
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInitf106db3bb07a0cc7f373b495de3213f9
{
public static $prefixLengthsPsr4 = array (
'W' =>
array (
'Wpo\\Services\\' => 13,
'Wpo\\' => 4,
),
);
public static $prefixDirsPsr4 = array (
'Wpo\\Services\\' =>
array (
0 => __DIR__ . '/../..' . '/Services',
),
'Wpo\\' =>
array (
0 => __DIR__ . '/../..' . '/',
),
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitf106db3bb07a0cc7f373b495de3213f9::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf106db3bb07a0cc7f373b495de3213f9::$prefixDirsPsr4;
}, null, ClassLoader::class);
}
}
<?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>&nbsp;'
. '<a class="button button-primary" href="' . esc_url($update_url) . '">' . __('Update plugin', 'wpo365-login') . '</a>'
. '</p></div>';
}
}
}
$wpo365_custom_fields = new Custom_Fields();