43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Plugin Name: User Organizations
|
|
* Plugin URI: https://wordpress.org/plugins/wp-user-groups/
|
|
* Author: Saburly
|
|
* Description: Hierarchical organization managment
|
|
*/
|
|
|
|
// Exit if accessed directly
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
function load() {
|
|
if (class_exists('WP_User_Taxonomy')) {
|
|
require_once ('includes/class_user_organization_taxonomy.php');
|
|
require_once ('includes/class-user-organizations-directory.php');
|
|
require_once('includes/class-order-managment.php');
|
|
|
|
do_action('user_organizations_loaded');
|
|
}
|
|
}
|
|
|
|
function remove_default_user_groups() {
|
|
remove_action( 'init', 'wp_register_default_user_group_taxonomy' );
|
|
remove_action( 'init', 'wp_register_default_user_type_taxonomy' );
|
|
}
|
|
|
|
function fetch_user_organization() {
|
|
return User_Organizations_Directory::get_user_organization();
|
|
}
|
|
|
|
add_action('init', 'load');
|
|
|
|
add_action('plugins_loaded', 'remove_default_user_groups', 30);
|
|
|
|
add_action('user_organizations_loaded', function() {
|
|
register_rest_route('wiaas/v1', '/organization', array(
|
|
'methods' => 'GET',
|
|
'permission_callback' => 'check_permission',
|
|
'callback' => 'fetch_user_organization',
|
|
));
|
|
});
|