Commit realizado el 12:13:52 08-04-2024
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
/*!
|
||||
* Plugin: Rank Math - Role Manager
|
||||
* URL: https://rankmath.com/wordpress/plugin/seo-suite/
|
||||
* Name: role-manager.css
|
||||
*/@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(-360deg)}}@keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(-360deg)}}@keyframes bounce{from{-webkit-transform:translateY(0px);transform:translateY(0px)}to{-webkit-transform:translateY(-5px);transform:translateY(-5px)}}@-webkit-keyframes bounce{from{-webkit-transform:translateY(0px);transform:translateY(0px)}to{-webkit-transform:translateY(-5px);transform:translateY(-5px)}}@-webkit-keyframes loading{0%{background-size:20% 50% ,20% 50% ,20% 50%}20%{background-size:20% 20% ,20% 50% ,20% 50%}40%{background-size:20% 100%,20% 20% ,20% 50%}60%{background-size:20% 50% ,20% 100%,20% 20%}80%{background-size:20% 50% ,20% 50% ,20% 100%}100%{background-size:20% 50% ,20% 50% ,20% 50%}}@keyframes loading{0%{background-size:20% 50% ,20% 50% ,20% 50%}20%{background-size:20% 20% ,20% 50% ,20% 50%}40%{background-size:20% 100%,20% 20% ,20% 50%}60%{background-size:20% 50% ,20% 100%,20% 20%}80%{background-size:20% 50% ,20% 50% ,20% 100%}100%{background-size:20% 50% ,20% 50% ,20% 50%}}:root{--rankmath-wp-adminbar-height: 0}.cmb-form>header{margin:-1.875rem -1.875rem 30px;padding:1.875rem 1.875rem 0;text-align:center;border-bottom:1px solid #b5bfc9;border-radius:6px 6px 0 0;background:#f8f9fa}.cmb-form>header h2{font-size:30px;font-weight:500;margin:0}.cmb-form>header>p{font-size:1rem;max-width:715px;margin:0 auto 2rem}.cmb-form>header .notice p{font-size:13px}.cmb-form .cmb2-option-administrator-role-manager,.cmb-form .cmb2-option-administrator-role-manager+label{opacity:.7;pointer-events:none}.cmb-form>footer.form-footer{margin:30px -1.875rem -1.875rem;padding:1.875rem;text-align:center;border:0;border-top:1px solid #b5bfc9;border-radius:0 0 6px 6px;background:#f8f9fa;overflow:hidden;width:auto;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-wrap:wrap;flex-wrap:wrap}@media (min-width: 1200px){.cmb2-wrap .cmb-big-labels .cmb2-checkbox-list li{width:33.33%}}
|
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var n={n:function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,{a:e}),e},d:function(t,e){for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},o:function(n,t){return Object.prototype.hasOwnProperty.call(n,t)}},t=jQuery,e=n.n(t),o=wp.i18n;e()((function(){e()(".reset-options").on("click",(function(){return!!window.confirm((0,o.__)("Are you sure? You want to reset settings.","rank-math"))&&(e()(window).off("beforeunload"),!0)}))}))}();
|
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/**
|
||||
* The Capability Manager.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Role_Manager
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
*/
|
||||
|
||||
namespace RankMath\Role_Manager;
|
||||
|
||||
use RankMath\Helper;
|
||||
use RankMath\Traits\Hooker;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Capability_Manager class.
|
||||
*/
|
||||
class Capability_Manager {
|
||||
|
||||
use Hooker;
|
||||
|
||||
/**
|
||||
* Registered capabilities.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $capabilities = [];
|
||||
|
||||
/**
|
||||
* Main instance
|
||||
*
|
||||
* Ensure only one instance is loaded or can be loaded.
|
||||
*
|
||||
* @return Capability_Manager
|
||||
*/
|
||||
public static function get() {
|
||||
static $instance;
|
||||
|
||||
if ( is_null( $instance ) && ! ( $instance instanceof Capability_Manager ) ) {
|
||||
$instance = new Capability_Manager();
|
||||
$instance->set_capabilities();
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default capabilities.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function set_capabilities() {
|
||||
$this->register( 'rank_math_titles', esc_html__( 'Titles & Meta Settings', 'rank-math' ) );
|
||||
$this->register( 'rank_math_general', esc_html__( 'General Settings', 'rank-math' ) );
|
||||
$this->register( 'rank_math_sitemap', esc_html__( 'Sitemap Settings', 'rank-math' ) );
|
||||
$this->register( 'rank_math_404_monitor', esc_html__( '404 Monitor Log', 'rank-math' ) );
|
||||
$this->register( 'rank_math_link_builder', esc_html__( 'Link Builder', 'rank-math' ) );
|
||||
$this->register( 'rank_math_redirections', esc_html__( 'Redirections', 'rank-math' ) );
|
||||
$this->register( 'rank_math_role_manager', esc_html__( 'Role Manager', 'rank-math' ) );
|
||||
$this->register( 'rank_math_analytics', esc_html__( 'Analytics', 'rank-math' ) );
|
||||
$this->register( 'rank_math_site_analysis', esc_html__( 'Site-Wide Analysis', 'rank-math' ) );
|
||||
$this->register( 'rank_math_onpage_analysis', esc_html__( 'On-Page Analysis', 'rank-math' ) );
|
||||
$this->register( 'rank_math_onpage_general', esc_html__( 'On-Page General Settings', 'rank-math' ) );
|
||||
$this->register( 'rank_math_onpage_advanced', esc_html__( 'On-Page Advanced Settings', 'rank-math' ) );
|
||||
$this->register( 'rank_math_onpage_snippet', esc_html__( 'On-Page Schema Settings', 'rank-math' ) );
|
||||
$this->register( 'rank_math_onpage_social', esc_html__( 'On-Page Social Settings', 'rank-math' ) );
|
||||
$this->register( 'rank_math_content_ai', esc_html__( 'Content AI', 'rank-math' ) );
|
||||
$this->register( 'rank_math_admin_bar', esc_html__( 'Top Admin Bar', 'rank-math' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a capability.
|
||||
*
|
||||
* @param string $capability Capability to register.
|
||||
* @param string $title Capability human title.
|
||||
*/
|
||||
public function register( $capability, $title ) {
|
||||
$this->capabilities[ $capability ] = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all registered capabilitities.
|
||||
*
|
||||
* @param bool $caps Capabilities as keys.
|
||||
*
|
||||
* @return string[] Registered capabilities.
|
||||
*/
|
||||
public function get_capabilities( $caps = false ) {
|
||||
return $caps ? array_keys( $this->capabilities ) : $this->capabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add capabilities on install.
|
||||
*/
|
||||
public function create_capabilities() {
|
||||
foreach ( Helper::get_roles() as $slug => $role ) {
|
||||
$role = get_role( $slug );
|
||||
if ( ! $role ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->loop_capabilities( $this->get_default_capabilities_by_role( $slug ), 'add_cap', $role );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove capabilities on uninstall.
|
||||
*/
|
||||
public function remove_capabilities() {
|
||||
$capabilities = $this->get_capabilities( true );
|
||||
foreach ( Helper::get_roles() as $slug => $role ) {
|
||||
$role = get_role( $slug );
|
||||
if ( ! $role ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->loop_capabilities( $capabilities, 'remove_cap', $role );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loop capabilities and perform action.
|
||||
*
|
||||
* @param array $caps Capabilities.
|
||||
* @param string $perform Action to perform.
|
||||
* @param object $role Role object.
|
||||
*/
|
||||
private function loop_capabilities( $caps, $perform, $role ) {
|
||||
foreach ( $caps as $cap ) {
|
||||
$role->$perform( $cap );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default capabilities by roles.
|
||||
*
|
||||
* @param string $role Capabilities for this role.
|
||||
* @return array
|
||||
*/
|
||||
private function get_default_capabilities_by_role( $role ) {
|
||||
|
||||
if ( 'administrator' === $role ) {
|
||||
return $this->get_capabilities( true );
|
||||
}
|
||||
|
||||
if ( 'editor' === $role ) {
|
||||
return [
|
||||
'rank_math_site_analysis',
|
||||
'rank_math_onpage_analysis',
|
||||
'rank_math_onpage_general',
|
||||
'rank_math_onpage_snippet',
|
||||
'rank_math_onpage_social',
|
||||
];
|
||||
}
|
||||
|
||||
if ( 'author' === $role ) {
|
||||
return [
|
||||
'rank_math_onpage_analysis',
|
||||
'rank_math_onpage_general',
|
||||
'rank_math_onpage_snippet',
|
||||
'rank_math_onpage_social',
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset capabilities.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function reset_capabilities() {
|
||||
$this->remove_capabilities();
|
||||
$this->create_capabilities();
|
||||
}
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* Members plugin integration.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Role_Manager
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
*/
|
||||
|
||||
namespace RankMath\Role_Manager;
|
||||
|
||||
use RankMath\Traits\Hooker;
|
||||
use RankMath\Helpers\Param;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Members class.
|
||||
*/
|
||||
class Members {
|
||||
|
||||
use Hooker;
|
||||
|
||||
/**
|
||||
* Members cap group name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const GROUP = 'rank_math';
|
||||
|
||||
/**
|
||||
* Class Members constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->action( 'members_register_caps', 'register_caps' );
|
||||
$this->action( 'members_register_cap_groups', 'register_cap_groups' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers cap group.
|
||||
*/
|
||||
public function register_cap_groups() {
|
||||
\members_register_cap_group(
|
||||
self::GROUP,
|
||||
[
|
||||
'label' => esc_html__( 'Rank Math', 'rank-math' ),
|
||||
'caps' => [],
|
||||
'icon' => 'dashicons-chart-area',
|
||||
'priority' => 30,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers caps.
|
||||
*/
|
||||
public function register_caps() {
|
||||
$caps = Capability_Manager::get()->get_capabilities();
|
||||
if ( 'administrator' === Param::get( 'role' ) ) {
|
||||
$caps['rank_math_edit_htaccess'] = esc_html__( 'Edit .htaccess', 'rank-math' );
|
||||
}
|
||||
|
||||
foreach ( $caps as $key => $value ) {
|
||||
\members_register_cap(
|
||||
$key,
|
||||
[
|
||||
'label' => html_entity_decode( $value ),
|
||||
'group' => self::GROUP,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
/**
|
||||
* The Role Manager Module.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Role_Manager
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
*/
|
||||
|
||||
namespace RankMath\Role_Manager;
|
||||
|
||||
use RankMath\Helper;
|
||||
use RankMath\Helpers\Param;
|
||||
use RankMath\Module\Base;
|
||||
use RankMath\Admin\Page;
|
||||
use RankMath\Traits\Hooker;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Role_Manager class.
|
||||
*/
|
||||
class Role_Manager extends Base {
|
||||
use Hooker;
|
||||
|
||||
/**
|
||||
* The Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$directory = dirname( __FILE__ );
|
||||
$this->config(
|
||||
[
|
||||
'id' => 'role-manager',
|
||||
'directory' => $directory,
|
||||
]
|
||||
);
|
||||
parent::__construct();
|
||||
|
||||
$this->action( 'cmb2_admin_init', 'register_form' );
|
||||
add_filter( 'cmb2_override_option_get_rank-math-role-manager', [ '\RankMath\Helper', 'get_roles_capabilities' ] );
|
||||
$this->action( 'admin_post_rank_math_handle_capabilities', 'handle_form' );
|
||||
$this->filter( 'cmb2_list_input_attributes', 'input_attributes', 10, 4 );
|
||||
|
||||
if ( $this->page->is_current_page() ) {
|
||||
add_action( 'admin_enqueue_scripts', [ 'CMB2_Hookup', 'enqueue_cmb_css' ], 25 );
|
||||
}
|
||||
|
||||
// Members plugin integration.
|
||||
if ( \function_exists( 'members_plugin' ) ) {
|
||||
new Members();
|
||||
}
|
||||
|
||||
// User Role Editor plugin integration.
|
||||
if ( defined( 'URE_PLUGIN_URL' ) ) {
|
||||
new User_Role_Editor();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register admin page.
|
||||
*/
|
||||
public function register_admin_page() {
|
||||
$uri = untrailingslashit( plugin_dir_url( __FILE__ ) );
|
||||
|
||||
$this->page = new Page(
|
||||
'rank-math-role-manager',
|
||||
esc_html__( 'Role Manager', 'rank-math' ),
|
||||
[
|
||||
'position' => 20,
|
||||
'parent' => 'rank-math',
|
||||
'capability' => 'rank_math_role_manager',
|
||||
'render' => $this->directory . '/views/main.php',
|
||||
'classes' => [ 'rank-math-page' ],
|
||||
'assets' => [
|
||||
'styles' => [
|
||||
'rank-math-common' => '',
|
||||
'rank-math-cmb2' => '',
|
||||
'rank-math-role-manager' => $uri . '/assets/css/role-manager.css',
|
||||
],
|
||||
'scripts' => [ 'rank-math-role-manager-script' => $uri . '/assets/js/role-manager.js' ],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register form for Add New Record.
|
||||
*/
|
||||
public function register_form() {
|
||||
|
||||
$cmb = new_cmb2_box(
|
||||
[
|
||||
'id' => 'rank-math-role-manager',
|
||||
'object_types' => [ 'options-page' ],
|
||||
'option_key' => 'rank-math-role-manager',
|
||||
'hookup' => false,
|
||||
'save_fields' => false,
|
||||
]
|
||||
);
|
||||
|
||||
$caps = Capability_Manager::get()->get_capabilities();
|
||||
|
||||
foreach ( Helper::get_roles() as $role => $label ) {
|
||||
$cmb->add_field(
|
||||
[
|
||||
'id' => esc_attr( $role ),
|
||||
'type' => 'multicheck_inline',
|
||||
'name' => translate_user_role( $label ),
|
||||
'options' => $caps,
|
||||
'select_all_button' => false,
|
||||
'classes' => 'cmb-big-labels',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save capabilities form submit handler.
|
||||
*/
|
||||
public function handle_form() {
|
||||
// If no form submission, bail!
|
||||
if ( empty( $_POST ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
check_admin_referer( 'rank-math-handle-capabilities', 'security' );
|
||||
|
||||
if ( ! Helper::has_cap( 'role_manager' ) ) {
|
||||
Helper::add_notification( esc_html__( 'You are not authorized to perform this action.', 'rank-math' ), [ 'type' => 'error' ] );
|
||||
Helper::redirect( Helper::get_admin_url( 'role-manager' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( Param::post( 'reset-capabilities' ) ) {
|
||||
Capability_Manager::get()->reset_capabilities();
|
||||
} else {
|
||||
$cmb = cmb2_get_metabox( 'rank-math-role-manager' );
|
||||
Helper::set_capabilities( $cmb->get_sanitized_values( $_POST ) );
|
||||
}
|
||||
|
||||
Helper::redirect( Helper::get_admin_url( 'role-manager' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update checkbox input attributes
|
||||
*
|
||||
* @param array $args The array of attribute arguments.
|
||||
* @param array $type_defaults The array of default values.
|
||||
* @param array $field The `CMB2_Field` object.
|
||||
* @param object $types This `CMB2_Types` object.
|
||||
* @return array Parsed and filtered arguments.
|
||||
*/
|
||||
public function input_attributes( $args, $type_defaults, $field, $types ) {
|
||||
if ( ! isset( $type_defaults['class'] ) || ! isset( $type_defaults['name'] ) || ! isset( $args['label'] ) ) {
|
||||
return $args;
|
||||
}
|
||||
|
||||
$classes = [];
|
||||
|
||||
if ( isset( $args['class'] ) ) {
|
||||
$classes[] = $args['class'];
|
||||
}
|
||||
|
||||
$classes[] = $type_defaults['class'];
|
||||
$classes[] = implode(
|
||||
'-',
|
||||
[
|
||||
$type_defaults['class'],
|
||||
$type_defaults['name'],
|
||||
sanitize_title_with_dashes( $args['label'] ),
|
||||
]
|
||||
);
|
||||
|
||||
$args['class'] = implode( ' ', $classes );
|
||||
|
||||
return $args;
|
||||
}
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* User Role Editor plugin integration.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Role_Manager
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
*/
|
||||
|
||||
namespace RankMath\Role_Manager;
|
||||
|
||||
use RankMath\Traits\Hooker;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* User_Role_Editor class.
|
||||
*/
|
||||
class User_Role_Editor {
|
||||
|
||||
use Hooker;
|
||||
|
||||
/**
|
||||
* Members cap group name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const GROUP = 'rank_math';
|
||||
|
||||
/**
|
||||
* Hold caps.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $caps = [];
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->filter( 'ure_capabilities_groups_tree', 'register_group' );
|
||||
$this->filter( 'ure_custom_capability_groups', 'register_capability_groups', 10, 2 );
|
||||
|
||||
$this->caps = Capability_Manager::get()->get_capabilities();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Rank Math capability group in the User Role Editor plugin.
|
||||
*
|
||||
* @param array $groups Current groups.
|
||||
* @return array Filtered list of capabilty groups.
|
||||
*/
|
||||
public function register_group( $groups = [] ) {
|
||||
$groups = (array) $groups;
|
||||
|
||||
$groups[ self::GROUP ] = [
|
||||
'caption' => esc_html__( 'Rank Math', 'rank-math' ),
|
||||
'parent' => 'custom',
|
||||
'level' => 3,
|
||||
];
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds capabilities to the Rank Math group in the User Role Editor plugin.
|
||||
*
|
||||
* @param array $groups Current capability groups.
|
||||
* @param string $cap_id Capability identifier.
|
||||
* @return array List of filtered groups.
|
||||
*/
|
||||
public function register_capability_groups( $groups = [], $cap_id = '' ) {
|
||||
if ( array_key_exists( $cap_id, $this->caps ) ) {
|
||||
$groups = (array) $groups;
|
||||
$groups[] = self::GROUP;
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
<?php // Silence is golden.
|
@@ -0,0 +1 @@
|
||||
<?php // Silence is golden.
|
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Role Manager main view.
|
||||
*
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Role_Manager
|
||||
*/
|
||||
|
||||
use RankMath\KB;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
// Header.
|
||||
rank_math()->admin->display_admin_header();
|
||||
?>
|
||||
<div class="wrap rank-math-wrap">
|
||||
<div class="rank-math-box container">
|
||||
|
||||
<span class="wp-header-end"></span>
|
||||
|
||||
<form class="cmb-form" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post">
|
||||
|
||||
<header>
|
||||
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
|
||||
<p>
|
||||
<?php
|
||||
/* translators: %s is a Learn More link to the documentation. */
|
||||
printf( esc_html__( 'Control which user has access to which options of Rank Math. %s', 'rank-math' ), '<a href="' . esc_url_raw( KB::get( 'role-manager', 'Role Manager Page' ) ) . '" target="_blank">' . esc_html__( 'Learn more', 'rank-math' ) . '</a>.' );
|
||||
?>
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<input type="hidden" name="action" value="rank_math_handle_capabilities">
|
||||
<?php
|
||||
wp_nonce_field( 'rank-math-handle-capabilities', 'security' );
|
||||
$cmb = cmb2_get_metabox( 'rank-math-role-manager', 'rank-math-role-manager' );
|
||||
$cmb->show_form();
|
||||
?>
|
||||
|
||||
<footer class="form-footer rank-math-ui">
|
||||
<input type="submit" name="reset-capabilities" id="rank-math-reset-cmb" value="<?php esc_attr_e( 'Reset', 'rank-math' ); ?>" class="button button-secondary reset-options alignleft">
|
||||
<button type="submit" class="button button-primary"><?php esc_html_e( 'Update Capabilities', 'rank-math' ); ?></button>
|
||||
</footer>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
jQuery( function( $ ) {
|
||||
var toggle = '<p><button class="button button-small toggle-all-capabilities"><?php echo esc_js( __( 'Toggle All', 'rank-math' ) ); ?></button></p>',
|
||||
$table = $( '#cmb2-metabox-rank-math-role-manager' );
|
||||
|
||||
$( '.cmb-th', $table ).each( function( index, elem ) {
|
||||
$( elem ).append( toggle );
|
||||
} );
|
||||
|
||||
$( '.toggle-all-capabilities' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
var $checkboxes = $( this ).closest( '.cmb-row' ).find( 'input.cmb2-option:not(#administrator7)' ),
|
||||
should_check = ! $checkboxes.filter(':checked').length;
|
||||
|
||||
$checkboxes.prop( 'checked', should_check );
|
||||
} );
|
||||
} );
|
||||
</script>
|
Reference in New Issue
Block a user