Initial commit

This commit is contained in:
Fill committed 2023-04-10 12:42:23 +03:00
1 parent bd472155ce
commit a1ea747e34
8 files changed
+5166

No files matched your search

+227
View File
@@ -0,0 +1,227 @@
<?php
/**
* Ajax controller.
*
* @author Ivan Filipov <ivan@web-lab.solutions>
*
* @version 1.0
* @date updated Jan 26, 2023
*/
namespace wlsrm;
class Ajax {
private static $_instance = null;
private function __construct() {
$this->addActions();
}
private function addActions() {
add_action('wp_ajax_add_role', array($this, 'wl_add_role'));
//add_action( 'wp_ajax_nopriv_add_role', array($this, 'wl_add_role' ));
add_action('wp_ajax_remove_role', array($this, 'wl_remove_role'));
//add_action( 'wp_ajax_nopriv_remove_role', array($this, 'wl_remove_role' ));
add_action('wp_ajax_add_capability', array($this, 'wl_add_capability'));
//add_action( 'wp_ajax_nopriv_add_capability', array($this, 'wl_add_capability' ));
add_action('wp_ajax_get_editable_roles', array($this, 'wl_get_editable_roles'));
//add_action( 'wp_ajax_nopriv_get_editable_roles', array($this, 'wl_get_editable_roles' ));
add_action('wp_ajax_get_roles', array($this, 'wl_get_roles'));
add_action('wp_ajax_get_capabilities', array($this, 'wl_get_capabilities'));
//add_action( 'wp_ajax_nopriv_get_capabilities', array($this, 'wl_get_capabilities' ));
// Remove Administrator from "Editable Roles"
add_action('editable_roles', array($this, 'wl_hide_adminstrator_editable_roles'));
}
/* AJAX function for add role */
function wl_add_role() {
if (current_user_can('administrator') || current_user_can('manage_roles')) {
$new_role = $_POST['new_role'];
$new_role_slug = str_replace(' ', '_', strtolower( $new_role));
add_role(
$new_role_slug,
__( $new_role ),
array(
// 'read' => true, // true allows this capability
// 'edit_posts' => true,
)
);
$result = 'success';
$message = __("Role added.", 'wlsrm');
}else{
$result = 'error';
$message = __("You don't have rights to do that", 'wlsrm');
}
echo json_encode(array('result'=>$result, 'message'=>$message));
wp_die();
}
/* end AJAX function for add role */
/* AJAX function for remove role */
function wl_remove_role() {
if (current_user_can('administrator') || current_user_can('manage_roles')) {
$remove_role = $_POST['remove_role'];
if($remove_role == "0"){
$result = 'error';
$message = __("Please select role to delete.", 'wlsrm');
}else if( get_role($remove_role) ){
remove_role( $remove_role );
$result = 'success';
$message = __("Role deleted.", 'wlsrm');
}else{
$result = 'error';
$message = __("Role doesn't exist.", 'wlsrm');
}
}else{
$result = 'error';
$message = __("You don't have rights to do that", 'wlsrm');
}
echo json_encode(array('result'=>$result, 'message'=>$message));
wp_die();
}
/* end AJAX function for remove role*/
/* AJAX function for add capability */
function wl_add_capability() {
if (current_user_can('administrator') || current_user_can('manage_roles')) {
$addCapability = trim($_POST['add_capability']);
if(preg_match("/^[a-zA-Z0-9_]+$/",$addCapability)){
$roles = get_editable_roles();
$role = get_role('administrator');
$role->add_cap($addCapability);
$result = 'success';
$message = __("Capability added.", 'wlsrm');
}else{
$result = 'error';
$message = __("You can use only string and underscore", 'wlsrm');
}
}else{
$result = 'error';
$message = __("You don't have rights to do that", 'wlsrm');
}
echo json_encode(array('result'=>$result, 'message'=>$message));
wp_die();
}
/* end AJAX function for add capability */
/* AJAX function for get editable roles */
public function wl_get_editable_roles() {
if ( ! check_ajax_referer( 'wl-role-mngmnt', 'security', false ) ) {
// wp_send_json_error( 'Invalid security token sent.' );
// wp_send_json_success( 'Valid security token sent.' );
echo json_encode(array('result'=> 'error', 'message' => __('Invalid security token sent.')));
wp_die();
}
$wp_capabilities = array();
if (current_user_can('administrator') || current_user_can('manage_roles')) {
$wp_capabilities = $this->wl_getEditableRoleNames();
$result = 'success';
$message = __("Roles loaded.", 'wlsrm');
}else{
$result = 'error';
$message = __("You don't have rights to do that", 'wlsrm');
}
echo json_encode(array('result'=>$result, 'data'=>$wp_capabilities, 'message' => $message));
wp_die();
}
/* end AJAX function for get editable roles */
/* AJAX function for get roles */
public function wl_get_roles() {
$wp_roles = array();
if (current_user_can('administrator') || current_user_can('manage_roles')) {
$roles = get_editable_roles();
$capabilities_exclude = array('level_0', 'level_1', 'level_2', 'level_3', 'level_4', 'level_5', 'level_6', 'level_7', 'level_8', 'level_9', 'level_10');
foreach ($roles as $key => $value) {
$wp_capabilities = $roles[$key]['capabilities'];
$wp_capabilities = array_diff_key($wp_capabilities, array_flip($capabilities_exclude));
$wp_roles[$key]['capabilities'] = $wp_capabilities;
$wp_roles[$key]['name'] = $value['name'];
}
$result = 'success';
$message = __("Roles loaded.", 'wlsrm');
} else {
$result = 'error';
$message = __("You don't have rights to do that", 'wlsrm');
}
echo json_encode(array('result' => $result, 'data' => $wp_roles, 'message' => $message));
wp_die();
}
/* end AJAX function for get roles */
/* AJAX function for get capabilities */
function wl_get_capabilities() {
if (current_user_can('administrator') || current_user_can('manage_roles')) {
$wp_capabilities = $this->wl_getAllCapabilities();
$result = 'success';
$message = __("Capabilities loaded.", 'wlsrm');
} else {
$result = 'error';
$message = __("You don't have rights to do that", 'wlsrm');
}
echo json_encode(array('result' => $result, 'data' => $wp_capabilities, 'message' => $message));
wp_die();
}
/* end AJAX function for get capability */
public function wl_hide_adminstrator_editable_roles($roles) {
$currScreen = get_current_screen();
if (!empty($currScreen) && $currScreen->id != 'users_page_role-management') {
if (isset($roles['administrator'])) {
unset($roles['administrator']);
}
}
return $roles;
}
private function wl_getAllCapabilities() {
$role_exclude = array('level_0', 'level_1', 'level_2', 'level_3', 'level_4', 'level_5', 'level_6', 'level_7', 'level_8', 'level_9', 'level_10');
$wp_capabilities = get_role('administrator')->capabilities;
$wp_capabilities = array_diff_key($wp_capabilities, array_flip($role_exclude));
return $wp_capabilities;
}
private function wl_getEditableRoleNames() {
$roles = get_editable_roles();
$role_arr = array();
foreach ($roles as $key => $value) {
if ($key != 'administrator') {
$role_arr[$key] = $value['name'];
}
}
return $role_arr;
}
/**
*
* @return \wlsrm\Ajax
*/
public static function getInstance() {
if (self::$_instance == null) {
self::$_instance = new self;
}
return self::$_instance;
}
}
+39
View File
@@ -0,0 +1,39 @@
<?php
/**
* Loader controller.
*
* @author Ivan Filipov <ivan@web-lab.solutions>
*
* @version 1.0
* @date updated Jan 26, 2023
*/
namespace wlsrm;
class Loader {
private static $defaultNamespace = 'wlsrm';
private function __construct() {
}
public static function registerAutoLoad() {
spl_autoload_register(array('\wlsrm\Loader', 'autoload'));
}
public static function autoload($class) {
self::loadClass($class);
}
public static function loadClass($class) {
$file = realpath(substr_replace(str_replace('\\', DIRECTORY_SEPARATOR, $class), WLSRM_PATH, 0, strlen(self::$defaultNamespace)) . '.php');
if ($file && is_readable($file)) {
include $file;
}
}
}
+4
View File
@@ -1,3 +1,7 @@
# plugin-wl-srm
WL Simple Role Management plugin
*The goal of the plugin is to make possible to manage user roles and capabilites.*
The plugin create user sub-page in administration part of the site, called "Roles", where the administrator is able to create, edit and delete user roles and capabilities.
+4448
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -0,0 +1 @@
:root .wl{--font-family:system-ui,-apple-system,"Segoe UI","Roboto","Ubuntu","Cantarell","Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--line-height:1.5em;--font-weight:400;--font-size:16px;--border-radius:0.25em;--border-width:1px;--outline-width:3px;--spacing:1em;--typography-spacing-vertical:1.5em;--block-spacing-vertical:calc(var(--spacing) * 2);--block-spacing-horizontal:var(--spacing);--grid-spacing-vertical:0;--grid-spacing-horizontal:var(--spacing);--form-element-spacing-vertical:0.75em;--form-element-spacing-horizontal:1em;--box-header-spaceing:0.25em;--transition:0.2s ease-in-out;--nav-color:#f5f5f5;--icon-external:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(115,130,140,0.999)' opacity='0.66' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'%3E%3C/path%3E%3Cpolyline points='15 3 21 3 21 9'%3E%3C/polyline%3E%3Cline x1='10' y1='14' x2='21' y2='3'%3E%3C/line%3E%3C/svg%3E");--icon-check:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23FFF' stroke-width='5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");--icon-check-dark:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(0,0,0,0.75)' stroke-width='5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");--icon-chevron:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(65,84,98,0.999)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");--icon-chevron-white:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.999)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");--icon-date:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(65,84,98,0.999)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");--icon-time:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(65,84,98,0.999)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cpolyline points='12 6 12 12 16 14'%3E%3C/polyline%3E%3C/svg%3E");--icon-search:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(65,84,98,0.999)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");--icon-checkbox:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23FFF' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");--icon-minus:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23FFF' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'%3E%3C/line%3E%3C/svg%3E");--icon-valid:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(56,142,60,0.999)' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");--icon-invalid:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(198,40,40,0.999)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='8' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'%3E%3C/line%3E%3C/svg%3E")}@media (min-width:36em){:root .wl{--font-size:17px}}@media (min-width:48em){:root .wl{--font-size:18px}}@media (min-width:62em){:root .wl{--font-size:19px}}@media (min-width:75em){:root .wl{--font-size:20px}}[data-theme=light] .wl,.wl [data-theme=light],:not([data-theme=dLine truncated
+210
View File
@@ -0,0 +1,210 @@
jQuery(document).ready(function ($) {
var changes = {};
$('body').on('click', '#add-role', function (e) {
e.preventDefault();
var end_point = wl_rm.ajax_url;
var val = $('#add-role-name').val();
$.post(end_point, {'action': 'add_role', 'new_role': val, security: wl_rm.security}, function (response) {
var response = JSON.parse(response);
if (response.result == 'success') {
alert(response.message);
$('#add-role-name').val('');
laod_data();
} else {
alert(response.message);
}
}).fail(function (response) {
alert(wl_rm.error_refresh);
});
});
$('body').on('click', '#remove-role', function (e) {
e.preventDefault();
var end_point = wl_rm.ajax_url;
var val = $('#remove-role-name').val();
$.post(end_point, {'action': 'remove_role', 'remove_role': val, security: wl_rm.security}, function (response) {
var response = JSON.parse(response);
if (response.result == 'success') {
alert(response.message);
laod_data();
} else {
alert(response.message);
}
}).fail(function (response) {
alert(wl_rm.error_refresh);
});
});
$('body').on('click', '#add-capability', function (e) {
e.preventDefault();
var end_point = wl_rm.ajax_url;
var val = $('#add-capability-name').val();
$.post(end_point, {'action': 'add_capability', 'add_capability': val, security: wl_rm.security}, function (response) {
var response = JSON.parse(response);
if (response.result == 'success') {
alert(response.message);
laod_data();
} else {
alert(response.message);
}
}).fail(function (response) {
alert(wl_rm.error_refresh);
});
});
$('body').on('click', '#remove-capability', function (e) {
e.preventDefault();
var end_point = wl_rm.ajax_url;
var val = $('#remove-capability-name').val();
$.post(end_point, {'action': 'remove_capability', 'remove_capability': val, security: wl_rm.security}, function (response) {
var response = JSON.parse(response);
if (response.result == 'success') {
alert(response.message);
laod_data();
} else {
alert(response.message);
}
}).fail(function (response) {
alert(wl_rm.error_refresh);
});
});
$('body').on('click', '#submit', function (e) {
e.preventDefault();
var end_point = wl_rm.ajax_url;
var val = JSON.stringify(changes);
console.log(val);
input = {'action': 'save_capability', 'data': changes, security: wl_rm.security};
console.log(input);
$.post(end_point, input, function (response) {
var response = JSON.parse(response);
if (response.result == 'success') {
console.log(response.message);
alert(response.message);
} else {
alert(response.message);
}
}).fail(function (response) {
console.log(response);
alert(wl_rm.error_refresh);
});
});
$('body').on('change', 'input[type="checkbox"]', function (e) {
role = $(this).attr('data-role');
capability = $(this).attr('data-capability');
if (!(role in changes)) {
changes[role] = {};
}
if (capability in changes[role]) {
delete changes[role][capability];
} else {
if ($(this).is(':checked')) {
changes[role][capability] = 1;
} else {
changes[role][capability] = 0;
}
}
if (Object.keys(changes[role]).length == 0) {
delete changes[role];
}
console.log(JSON.stringify(changes));
});
function load_combo_roles() {
comboRoles = '<option value="0"> -------- </option>';
var end_point = wl_rm.ajax_url;
$.post(end_point, {'action': 'get_editable_roles', security: wl_rm.security}, function (response) {
var response = JSON.parse(response);
if (response.result == 'success') {
roles = response.data;
for (var key in roles) {
comboRoles = comboRoles + '<option value="' + key + '">' + roles[key] + '</option>';
}
$('#remove-role-name').html(comboRoles);
} else {
alert(response.message);
}
}).fail(function (response) {
alert(wl_rm.error_refresh);
});
}
function load_combo_capabilities() {
comboCapabilities = '<option value="0"> -------- </option>';
var end_point = wl_rm.ajax_url;
$.post(end_point, {'action': 'get_capabilities', security: wl_rm.security}, function (response) {
var response = JSON.parse(response);
if (response.result == 'success') {
capabilities = response.data;
for (var key in capabilities) {
comboCapabilities = comboCapabilities + '<option value="' + key + '">' + key + '</option>';
}
$('#remove-capability-name').html(comboCapabilities);
} else {
alert(response.message);
}
}).fail(function (response) {
alert(wl_rm.error_refresh);
});
}
function load_role_tabs() {
navContent = '';
tabContent = '';
var end_point = wl_rm.ajax_url;
$.post(end_point, {'action': 'get_roles', security: wl_rm.security}, function (response) {
var response = JSON.parse(response);
if (response.result == 'success') {
allCap = response.data.administrator.capabilities || {};
delete response.data.administrator;
roles = response.data;
capability = '';
i = 1;
for (var role in roles) {
hidden = (i == 1) ? "" : "hidden";
checked = (i == 1) ? 'checked = "checked"' : "";
active = (i == 1) ? "nav-tab-active" : "";
navContent += '<a href="javascript: void(0)" onclick="showTab(this, ' + i + ')" class="nav-tab ' + active + '">' + roles[role].name + '</a>';
tabContent += '<input id="tab-' + i + '" type="radio" name="roles" ' + checked + ' >' +
'<label for="tab-' + i + '">' + roles[role].name + '</label>' +
'<div class ="tab">';
for (var key in allCap) {
checked = roles[role].capabilities[key] ? ' checked="checked"' : '';
capability = '<span class="inb">' +
'<label for="' + role + '-' + key + '" >' +
'<input id="' + role + '-' + key + '" type="checkbox" name="' + role + '-' + key + '"' + checked + ' data-role="' + role + '" data-capability="' + key + '" ' + ' role="switch" >' +
key +
'</label>' +
'</span>';
tabContent += capability;
}
tabContent += '</div>';
i++;
}
$('#tab_wrapper').html(tabContent);
} else {
alert(response.message);
}
}).fail(function (response) {
alert(wl_rm.error_refresh);
});
}
function laod_data() {
load_combo_roles();
load_combo_capabilities();
load_role_tabs();
}
laod_data();
});
+40
View File
@@ -0,0 +1,40 @@
<?php
/**
* Plugin Name: WL Simple Role Manager
* Description: Simple plugin to manage the roles ins WordPress
* Plugin URI: https://web-lab.solutions
* Author: Ivan Filipov ( Web Lab )
* Version: 1.0.0
* Author URI: ttps://web-lab.solutions
*
* Text Domain: wlsrm
*
* @package wlsrm
* @category roles
*
*/
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
define( 'WLSRM_PATH', plugin_dir_path( __FILE__ ) );
define( 'WLSRM_URL', plugin_dir_url( __FILE__ ) );
add_action('plugins_loaded', 'wlsrm_load_plugin_textdomain');
/**
* Load wlsrm textdomain.
*
* Load gettext translate for wlsrm text domain.
*
* @since 1.0.0
*
* @return void
*/
function wlsrm_load_plugin_textdomain() {
load_plugin_textdomain('wlsrm');
}
if (is_admin()) {
include 'wlsrm.php';
}
+197
View File
@@ -0,0 +1,197 @@
<?php
/**
* wlsrm controller.
*
* @author Ivan Filipov <ivan@web-lab.solutions>
*
* @version 1.0
* @date updated Jan 26, 2023
*/
namespace wlsrm;
class wlsrm {
private static $_instance = null;
/**
* Plugin constructor.
*
* Initializing WL simple role manager plugin.
*
* @since 1.0.0
* @access private
*/
private function __construct() {
$this->register_autoloader();
if(wp_doing_ajax()){
$registerAjax = \wlsrm\Ajax::getInstance();
}else{
if(is_admin()){
$this->register_admin_menu();
global $pagenow;
if ( $pagenow === 'users.php' && isset($_GET['page']) && $_GET['page'] == 'user-management') {
// role management page
add_action('admin_enqueue_scripts', array($this, 'addScriptsAndStyles'));
}
}
}
}
/**
* Add styles and scripts if needed
*/
public function addScriptsAndStyles() {
wp_enqueue_style(' wllcf', WLSRM_URL.'/assets/css/wllcf.css', array(), filemtime(WLSRM_PATH.'/assets/css/wllcf.css'));
wp_enqueue_script('role-managemet', WLSRM_URL . '/assets/js/role-managemet.js', [ 'jquery' ], false, true);
wp_localize_script(
'role-managemet',
'wl_rm',
[
'ajax_url' => admin_url( 'admin-ajax.php' ),
'security' => wp_create_nonce( 'wl-role-mngmnt' ),
'error_refresh' => __("Error! Please refresh the page and try again.", 'wlsrm'),
]
);
}
/**
* Register autoloader.
*
* WL simple role manager autoloader loads all the classes needed to run the plugin.
*
* @since 1.6.0
* @access private
*/
private function register_autoloader() {
require_once WLSRM_PATH . '/Loader.php';
Loader::registerAutoLoad();
}
/**
* Add function to admin_menu hook
*/
private function register_admin_menu() {
add_action('admin_menu', array($this, 'addRolesMenu'));
}
/**
* Add menu
*/
public function addRolesMenu() {
// Add Role management page to user menu
add_users_page(__('Roles', 'wlsrm'), __('Roles', 'wlsrm'), 'edit_users', 'user-management', array($this, 'roleManagementPage'));
}
/**
* Function that generate Role management page
*/
public function roleManagementPage() {
// $role_exclude = array('level_0', 'level_1', 'level_2', 'level_3', 'level_4', 'level_5', 'level_6', 'level_7', 'level_8', 'level_9', 'level_10');
if (!isset($_REQUEST['settings-updated']))
$_REQUEST['settings-updated'] = false; // This checks whether the form has just been submitted.
?>
<style>
.wlsrm-wrap{
padding: 20px
}
.inb{display: inline-block}
#tab_wrapper .tab>.inb{
margin:10px 0;
/*min-width: 270px*/
width: 25%;
font-size: 0.85em
}
#tab_wrapper .tab>.inb label{
margin-right: 10px
}
.wl input[type=radio]:checked::before{
content: initial
}
.wl [type=checkbox][role=switch]:before{
margin-top: 0;
margin-bottom: 0
}
.btn-sm{
font-size: 0.95em !important;
--form-element-spacing-vertical: 0.25em;
--form-element-spacing-horizontal: 0.3em;
}
</style>
<?php
echo "<h2>" . wp_get_theme() . " ". __('User managemet', 'wlsrm') . "</h2>";
// This shows the page's name and an icon if one has been provided
?>
<div class="wlsrm-wrap wl">
<div data-theme="light">
<form id="capabilities" method="post" action="">
<div class="row end-lg">
<div class="col-lg-2">
<input class="btn-sm" type="text" id="add-role-name" />
</div>
<div class="col-lg-2" data-theme="green">
<button class="btn-sm" id="add-role"><?php _e('Add role', 'wlsrm'); ?></button>
</div>
<div class="col-lg-2">
<select class="btn-sm" id="remove-role-name">
</select>
</div>
<div class="col-lg-2" data-theme="red">
<button class="btn-sm" id="remove-role"><?php _e('Remove role', 'wlsrm'); ?></button>
</div>
</div>
<div class="row end-lg">
<div class="col-lg-2">
<input class="btn-sm" type="text" id="add-capability-name" />
</div>
<div class="col-lg-2" data-theme="green">
<button class="btn-sm" id="add-capability"><?php _e('Add capability', 'wlsrm'); ?></button>
</div>
<div class="col-lg-2">
<select class="btn-sm" id="remove-capability-name">
</select>
</div>
<div class="col-lg-2" data-theme="red">
<button class="btn-sm" id="remove-capability"><?php _e('Remove capability', 'wlsrm'); ?></button>
</div>
</div>
<?php if (false !== $_REQUEST['settings-updated']) : ?>
<div class="updated fade"><p><strong><?php _e('Options saved', 'wlsrm'); ?></strong></p></div>
<?php endif; // If the form has just been submitted, this shows the notification ?>
<section id="tab_wrapper" class="tabs" style="padding: 20px">
</section>
<p class="submit"><input id="submit" type="submit" class="button-primary" value="<?php _e("Save capabilities", 'wlsrm'); ?> " /></p>
</form>
</div>
</div>
<?php
}
/**
*
* @return \wlsrm\wlsrm
*/
public static function getInstance() {
if (self::$_instance == null) {
self::$_instance = new self;
}
return self::$_instance;
}
}
wlsrm::getInstance();