PluginProbe ʕ •ᴥ•ʔ
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus / 1.7.1
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus v1.7.1
2.45.0 2.44.0 trunk 1.10 1.10.1 1.4.1 1.4.10 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5 1.5.1 1.5.10 1.5.11 1.5.2 1.5.3 1.5.4 1.5.5 1.5.7 1.5.8 1.5.9 1.6 1.6.1 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.8.1 1.9 1.9.10 1.9.12 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.9 2.0 2.0.2 2.0.3 2.1 2.1.1 2.10.0 2.10.1 2.10.2 2.10.3 2.11.1 2.12.1 2.12.2 2.13.0 2.14.0 2.15.0 2.16.0 2.17.0 2.18.0 2.18.2 2.19.0 2.19.1 2.19.2 2.2 2.2.1 2.20.0 2.21.0 2.22.0 2.23.0 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.30.0 2.31.0 2.32.0 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.40.0 2.41.0 2.42.0 2.43.0 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.7.0 2.7.1 2.8.0 2.8.1 2.9.0 2.9.1
capability-manager-enhanced / capsman-enhanced.php
capability-manager-enhanced Last commit date
framework 7 years ago images 7 years ago includes 7 years ago lang 7 years ago admin.css 7 years ago admin.dev.js 7 years ago admin.js 7 years ago capsman-enhanced.php 7 years ago readme.txt 7 years ago
capsman-enhanced.php
192 lines
1 <?php
2 /**
3 * Plugin Name: Capability Manager Enhanced
4 * Plugin URI: https://publishpress.com
5 * Description: Manage WordPress role definitions, per-site or network-wide. Organizes post capabilities by post type and operation.
6 * Version: 1.7.1
7 * Author: PublishPress
8 * Author URI: https://publishpress.com
9 * Text Domain: capsman-enhanced
10 * Domain Path: /lang/
11 * License: GPLv3
12 *
13 * Copyright (c) 2019 PublishPress
14 *
15 * ------------------------------------------------------------------------------
16 * Based on Capability Manager
17 * Author: Jordi Canals
18 * Copyright (c) 2009, 2010 Jordi Canals
19 * ------------------------------------------------------------------------------
20 *
21 * @package capability-manager-enhanced
22 * @author PublishPress
23 * @copyright Copyright (C) 2009, 2010 Jordi Canals; modifications Copyright (C) 2019 PublishPress
24 * @license GNU General Public License version 3
25 * @link https://publishpress.com
26 * @version 1.7.1
27 */
28
29 if ( ! defined( 'CAPSMAN_VERSION' ) ) {
30 define( 'CAPSMAN_VERSION', '1.7.1' );
31 define( 'CAPSMAN_ENH_VERSION', '1.7.1' );
32 }
33
34 if ( cme_is_plugin_active( 'capsman.php' ) ) {
35 function _cme_conflict_notice() {
36 $message = __( '<strong>Error:</strong> Capability Manager Extended cannot function because another copy of Capability Manager is active.', 'capsman-enhanced' );
37 echo '<div id="message" class="error fade" style="color: black">' . $message . '</div>';
38 }
39 add_action('admin_notices', _cme_conflict_notice() );
40 return;
41 } else {
42 define ( 'CME_FILE', __FILE__ );
43
44 /**
45 * Sets an admin warning regarding required PHP version.
46 *
47 * @hook action 'admin_notices'
48 * @return void
49 */
50 function _cman_php_warning() {
51 $data = get_plugin_data(__FILE__);
52 load_plugin_textdomain('capsman-enhanced', false, basename(dirname(__FILE__)) .'/lang');
53
54 echo '<div class="error"><p><strong>' . __('Warning:', 'capsman-enhanced') . '</strong> '
55 . sprintf(__('The active plugin %s is not compatible with your PHP version.', 'capsman-enhanced') .'</p><p>',
56 '&laquo;' . $data['Name'] . ' ' . $data['Version'] . '&raquo;')
57 . sprintf(__('%s is required for this plugin.', 'capsman-enhanced'), 'PHP-5 ')
58 . '</p></div>';
59 }
60
61 // ============================================ START PROCEDURE ==========
62
63 // Check required PHP version.
64 if ( version_compare(PHP_VERSION, '5.0.0', '<') ) {
65 // Send an armin warning
66 add_action('admin_notices', '_cman_php_warning');
67 } else {
68 global $pagenow;
69
70 if ( is_admin() &&
71 ( isset($_REQUEST['page']) && in_array( $_REQUEST['page'], array( 'capsman', 'capsman-tool' ) )
72 || ( ! empty($_SERVER['SCRIPT_NAME']) && strpos( $_SERVER['SCRIPT_NAME'], 'p-admin/plugins.php' ) && ! empty($_REQUEST['action'] ) )
73 || ( isset($_GET['action']) && 'reset-defaults' == $_GET['action'] )
74 || in_array( $pagenow, array( 'users.php', 'user-edit.php', 'profile.php', 'user-new.php' ) )
75 ) ) {
76 global $capsman;
77
78 // Run the plugin
79 require_once ( dirname(__FILE__) . '/framework/lib/formating.php' );
80 require_once ( dirname(__FILE__) . '/framework/lib/users.php' );
81
82 require_once ( dirname(__FILE__) . '/includes/manager.php' );
83 $capsman = new CapabilityManager();
84
85 if ( isset($_REQUEST['page']) && ( 'capsman' == $_REQUEST['page'] ) ) {
86 add_action( 'admin_enqueue_scripts', '_cme_pp_scripts' );
87 }
88 } else {
89 load_plugin_textdomain('capsman-enhanced', false, basename(dirname(__FILE__)) .'/lang');
90 add_action( 'admin_menu', 'cme_submenus', 20 );
91 }
92 }
93 }
94
95 add_action( 'init', '_cme_init' );
96 add_action( 'plugins_loaded', '_cme_act_pp_active', 1 );
97
98 add_action( 'init', '_cme_cap_helper', 49 ); // Press Permit Cap Helper, registered at 50, will leave caps which we've already defined
99 //add_action( 'wp_loaded', '_cme_cap_helper_late_init', 99 ); // now instead adding registered_post_type, registered_taxonomy action handlers for latecomers
100 // @todo: do this in PP Core also
101
102 function _cme_act_pp_active() {
103 if ( defined('PRESSPERMIT_VERSION') || ( defined('PPC_VERSION') && function_exists( 'pp_init_cap_caster' ) ) ) {
104 define( 'PRESSPERMIT_ACTIVE', true );
105 } else {
106 if ( defined('SCOPER_VERSION') || ( defined('PP_VERSION') && function_exists('pp_init_users_interceptor') ) ) {
107 define( 'OLD_PRESSPERMIT_ACTIVE', true );
108 }
109 }
110 }
111
112 function _cme_cap_helper() {
113 global $cme_cap_helper;
114
115 require_once ( dirname(__FILE__) . '/includes/cap-helper.php' );
116 $cme_cap_helper = new CME_Cap_Helper();
117
118 add_action( 'registered_post_type', '_cme_post_type_late_reg', 5, 2 );
119 add_action( 'registered_taxonomy', '_cme_taxonomy_late_reg', 5, 2 );
120 }
121
122 function _cme_post_type_late_reg( $post_type, $type_obj ) {
123 global $cme_cap_helper;
124
125 if ( ! empty( $type_obj->public ) || ! empty( $type_obj->show_ui ) ) {
126 $cme_cap_helper->refresh();
127 }
128 }
129
130 function _cme_taxonomy_late_reg( $taxonomy, $tx_obj ) {
131 global $cme_cap_helper;
132
133 if ( ! empty( $tx_obj->public ) ) {
134 $cme_cap_helper->refresh();
135 }
136 }
137
138 function _cme_init() {
139 require_once ( dirname(__FILE__) . '/includes/filters.php' );
140
141 load_plugin_textdomain('capsman-enhanced', false, dirname(__FILE__) . '/lang');
142 }
143
144 function _cme_pp_scripts() {
145 wp_enqueue_style( 'plugin-install' );
146 wp_enqueue_script( 'plugin-install' );
147 add_thickbox();
148 }
149
150 // perf enchancement: display submenu links without loading framework and plugin code
151 function cme_submenus() {
152 $cap_name = ( is_super_admin() ) ? 'manage_capabilities' : 'restore_roles';
153 add_management_page(__('Capability Manager', 'capsman-enhanced'), __('Capability Manager', 'capsman-enhanced'), $cap_name, 'capsman' . '-tool', 'cme_fakefunc');
154
155 if ( did_action( 'pp_admin_menu' ) ) { // Put Capabilities link on Permissions menu if Press Permit is active and user has access to it
156 global $pp_admin;
157 $menu_caption = ( defined('WPLANG') && WPLANG && ( 'en_EN' != WPLANG ) ) ? __('Capabilities', 'capsman-enhanced') : 'Role Capabilities';
158 add_submenu_page( $pp_admin->get_menu('options'), __('Capability Manager', 'capsman-enhanced'), $menu_caption, 'manage_capabilities', 'capsman', 'cme_fakefunc' );
159 } else {
160 add_users_page( __('Capability Manager', 'capsman-enhanced'), __('Capabilities', 'capsman-enhanced'), 'manage_capabilities', 'capsman', 'cme_fakefunc');
161 }
162 }
163
164 function cme_is_plugin_active($check_plugin_file) {
165 if ( ! $check_plugin_file )
166 return false;
167
168 $plugins = get_option('active_plugins');
169
170 foreach ( $plugins as $plugin_file ) {
171 if ( false !== strpos($plugin_file, $check_plugin_file) )
172 return $plugin_file;
173 }
174 }
175
176 // if a role is marked as hidden, also default it for use by Press Permit as a Pattern Role (when PP Collaborative Editing is activated and Advanced Settings enabled)
177 function _cme_pp_default_pattern_role( $role ) {
178 if ( ! $pp_role_usage = get_option( 'pp_role_usage' ) )
179 $pp_role_usage = array();
180
181 if ( empty( $pp_role_usage[$role] ) ) {
182 $pp_role_usage[$role] = 'pattern';
183 update_option( 'pp_role_usage', $pp_role_usage );
184 }
185 }
186
187 function capsman_get_pp_option( $option_basename ) {
188 return ( function_exists( 'presspermit_get_option') ) ? presspermit_get_option($option_basename) : pp_get_option($option_basename);
189 }
190
191 if ( is_multisite() )
192 require_once ( dirname(__FILE__) . '/includes/network.php' );