Capability Manager Enhanced - Version 2.2.1

Version Description

  • 8 Dec 2021 =
    • Fixed : Security issue
Download this release

Release Info

Developer kevinB
Plugin Icon 128x128 Capability Manager Enhanced
Version 2.2.1
Comparing to
See all releases

Code changes from version 2.3.1 to 2.2.1

capsman-enhanced.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: PublishPress Capabilities
4
  * Plugin URI: https://publishpress.com/capability-manager/
5
  * Description: Manage WordPress role definitions, per-site or network-wide. Organizes post capabilities by post type and operation.
6
- * Version: 2.3.1
7
  * Author: PublishPress
8
  * Author URI: https://publishpress.com/
9
  * Text Domain: capsman-enhanced
@@ -25,13 +25,13 @@
25
  * @copyright Copyright (C) 2009, 2010 Jordi Canals; modifications Copyright (C) 2020 PublishPress
26
  * @license GNU General Public License version 3
27
  * @link https://publishpress.com/
28
- * @version 2.3.1
29
  */
30
 
31
  if (!defined('CAPSMAN_VERSION')) {
32
- define('CAPSMAN_VERSION', '2.3.1');
33
- define('CAPSMAN_ENH_VERSION', '2.3.1');
34
- define('PUBLISHPRESS_CAPS_VERSION', '2.3.1');
35
  }
36
 
37
  foreach (get_option('active_plugins') as $plugin_file) {
@@ -141,21 +141,3 @@ add_action( 'init', '_cme_cap_helper', 49 ); // Press Permit Cap Helper, regist
141
 
142
  if ( is_multisite() )
143
  require_once ( dirname(__FILE__) . '/includes/network.php' );
144
-
145
- // Display message inviting to install Permissions
146
- if (
147
- ((defined('WP_DEBUG') && defined('CAPSMAN_INSTALL_PERMISSIONS')) || (!cme_is_plugin_active('press-permit-core.php') && !cme_is_plugin_active('presspermit-pro.php')))
148
- && !isset( $_GET['pp-after-click'])
149
- && !defined('CAPSMAN_DISABLE_PERMISSIONS_PROMO')
150
- ) {
151
- add_action('init', function() {
152
- global $pagenow;
153
-
154
- if (in_array($pagenow, ['edit.php', 'plugins.php', 'plugin-install.php'])
155
- || ('admin.php' == $pagenow && !empty($_REQUEST['page']) && (false !== strpos($_REQUEST['page'], 'pp-capabilities')))
156
- || (!empty($_REQUEST['action']) && ('ppc_permissions_action' == $_REQUEST['action']))
157
- ) {
158
- require_once ( dirname(__FILE__) . '/includes-core/pp-capabilities-permissions.php' );
159
- }
160
- });
161
- }
3
  * Plugin Name: PublishPress Capabilities
4
  * Plugin URI: https://publishpress.com/capability-manager/
5
  * Description: Manage WordPress role definitions, per-site or network-wide. Organizes post capabilities by post type and operation.
6
+ * Version: 2.2.1
7
  * Author: PublishPress
8
  * Author URI: https://publishpress.com/
9
  * Text Domain: capsman-enhanced
25
  * @copyright Copyright (C) 2009, 2010 Jordi Canals; modifications Copyright (C) 2020 PublishPress
26
  * @license GNU General Public License version 3
27
  * @link https://publishpress.com/
28
+ * @version 2.2.1
29
  */
30
 
31
  if (!defined('CAPSMAN_VERSION')) {
32
+ define('CAPSMAN_VERSION', '2.2.1');
33
+ define('CAPSMAN_ENH_VERSION', '2.2.1');
34
+ define('PUBLISHPRESS_CAPS_VERSION', '2.2.1');
35
  }
36
 
37
  foreach (get_option('active_plugins') as $plugin_file) {
141
 
142
  if ( is_multisite() )
143
  require_once ( dirname(__FILE__) . '/includes/network.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
common/css/admin.css CHANGED
@@ -36,7 +36,7 @@ a.cap_type {
36
  a.cap_type:hover {
37
  text-decoration: underline;
38
  }
39
-
40
  ul.cme-listhoriz li {
41
  text-align: center;
42
  padding-right: 1em;
@@ -61,7 +61,7 @@ float: left;
61
  margin: 0;
62
  }
63
 
64
-
65
  div.cme-listhoriz h3 {
66
  margin: 0.2em;
67
  }
@@ -70,28 +70,15 @@ div.cme-cap-type-tables {
70
  border: 1px solid black;
71
  }
72
 
73
- /*
74
- table.cme-typecaps {
75
-
76
- }
77
- */
78
-
79
- table .cme-typecaps td:first-of-type {
80
- text-align: left;
81
- }
82
-
83
  table .cme-typecaps td {
84
  text-align: center;
85
  height: 2em;
86
  }
87
 
88
- table .cme-typecaps th:first-of-type {
89
- width: 160px;
90
- }
91
-
92
  table .cme-typecaps th {
 
 
93
  cursor: pointer;
94
- text-align: center;
95
  }
96
 
97
  table.cme-typecaps span.cap-x {
@@ -103,10 +90,6 @@ table.cme-checklist span.cap-x {
103
  cursor: pointer;
104
  }
105
 
106
- table.cme-checklist tr td input[type="checkbox"] {
107
- margin-right: 10px !important;
108
- }
109
-
110
  h3.cme-cap-section {
111
  margin-top:0;
112
  }
@@ -258,40 +241,40 @@ table#akmin td.sidebar li.publishpress-contact a{
258
  min-width:600px;
259
  }
260
 
261
- #pp_features div.pp-logo {
262
  text-align: center;
263
  }
264
 
265
- #pp_features div.features-wrap {
266
- margin-left: auto;
267
- margin-right: auto;
268
- text-align: center;
269
  width: 600px;
270
  }
271
 
272
- #pp_features ul.pp-features {
273
- list-style: none;
274
- padding-top:10px;
275
- text-align:left;
276
  margin-left: auto;
277
  }
278
 
279
- #pp_features ul.pp-features li:before {
280
  content: "\2713\0020";
281
  }
282
 
283
- #pp_features ul.pp-features li {
284
  padding-bottom: 5px;
285
  }
286
 
287
- #pp_features img.cme-play {
288
- margin-bottom: -3px;
289
  margin-left: 5px;
290
  }
291
 
292
  div.publishpress-caps-manage span.manage-members {
293
- margin-left:5px;
294
- font-weight:normal;
295
  color: #777;
296
  }
297
 
@@ -300,7 +283,7 @@ div.publishpress-caps-manage span.manage-members a {
300
  }
301
 
302
  div.publishpress-caps-manage span.manage-members a:hover {
303
- text-decoration: underline;
304
  color:#655997;
305
  }
306
 
@@ -313,8 +296,8 @@ div.publishpress-headline .cme-subtext a:hover {
313
  }
314
 
315
  div.publishpress-caps-backup th {
316
- text-align:right;
317
- padding-top:28px;
318
  width: 140px;
319
  }
320
 
@@ -357,7 +340,7 @@ div.pp-caps-backup-button {
357
  }
358
 
359
  div.cme-restore-button {
360
- margin-top: 25px;
361
  padding-left: 5px;
362
  }
363
 
@@ -378,7 +361,7 @@ div.publishpress-caps-backup td.cme-backup-info li.cme-change {
378
  }
379
 
380
  div.publishpress-caps-backup td.cme-backup-info .cme-plus {
381
- font-weight: bold;
382
  color: green;
383
  }
384
 
@@ -396,14 +379,14 @@ span.pp-restore-caps-no-change {
396
  }
397
 
398
  div.publishpress-caps-backup td.cme-backup-info .cme-minus {
399
- font-weight: bold;
400
- color: #a00;
401
  text-decoration: line-through;
402
  }
403
 
404
  div.publishpress-caps-backup td.cme-backup-info .cme-negate {
405
- font-weight: bold;
406
- background-color: #a00;
407
  color: white;
408
  text-decoration: line-through;
409
  }
@@ -432,241 +415,4 @@ div.publishpress-caps-backup td.cme-backup-info .cme-negate {
432
 
433
  table#akmin tr td input[type=checkbox] {
434
  margin: 0;
435
- }
436
-
437
-
438
- .pp-capability-menus {
439
- width: 100%;
440
- overflow: hidden;
441
- background: #fff;
442
- background: linear-gradient(90deg, #fafafa 0%, #fafafa 20%, #fff 20%, #fff 100%);
443
- }
444
-
445
- .pp-capability-menus .pp-capability-menus-wrap {
446
- float: left;
447
- width: 100%;
448
- margin-left: -1px;
449
- margin-right: 20px;
450
- }
451
-
452
-
453
- #pp-capability-menu-wrapper table {
454
- border-right: none;
455
- border-top: none;
456
- border-bottom: none;
457
- }
458
-
459
- #pp-capability-menu-wrapper table td,
460
- #pp-capability-menu-wrapper table th {
461
- padding: 10px;
462
- padding-bottom: 10px;
463
- font-size: 13px;
464
- line-height: 20px;
465
- }
466
-
467
- #pp-capability-menu-wrapper table td h4.ppc-menu-row-section {
468
- margin-bottom: 0;
469
- }
470
-
471
- #pp-capability-menu-wrapper table td {
472
- padding: 9px;
473
- }
474
-
475
- #pp-capability-menu-wrapper tbody tr:last-of-type td {
476
- border-bottom: none;
477
- }
478
-
479
- #pp-capability-menu-wrapper tfoot th {
480
- border-color: #eee;
481
- }
482
-
483
-
484
- table#akmin .pp-capability-menus-select .restrict-column {
485
- width: 70px !important;
486
- text-align: center;
487
- display: table-cell !important;
488
- clear: none !important;
489
- }
490
-
491
- .pp-capability-menus .menu-item-link {
492
- display: inline;
493
- color: #0073aa;
494
- margin: -4px;
495
- line-height: inherit;
496
- padding: 4px 8px;
497
- border: 1px solid transparent;
498
- background: transparent;
499
- border-radius: 0;
500
- outline: none;
501
- -webkit-transition: all 0.25s ease-out;
502
- -moz-transition: all 0.25s ease-out;
503
- -o-transition: all 0.25s ease-out;
504
- transition: all 0.25s ease-out;
505
- }
506
-
507
- .pp-capability-menus .menu-item-link:hover,
508
- .pp-capability-menus .menu-item-link:focus {
509
- border-color: #eee;
510
- background: #fafafa;
511
- cursor: pointer;
512
- }
513
-
514
- .pp-capability-menus .menu-item-link:active {
515
- color: #0073aa;
516
- border-color: #0073aa;
517
- }
518
-
519
- .pp-capability-menus .check-all-menu-link,
520
- .pp-capability-menus .check-all-menu-link:active {
521
- color: #555;
522
- }
523
-
524
- .pp-capability-menus .menu-item-link.restricted,
525
- .pp-capability-menus .menu-item-link.restricted:active {
526
- color: crimson;
527
- }
528
-
529
- .pp-capability-menus .menu-item-link.disabled,
530
- .pp-capability-menus .menu-item-link.disabled:active {
531
- color: #555;
532
- }
533
-
534
- .pp-capability-menus .menu-item-link + .dashicons {
535
- display: none;
536
- margin-top: 1px;
537
- margin-bottom: -1px;
538
- line-height: inherit;
539
- }
540
-
541
- .pp-capability-menus .menu-item-link:hover + .dashicons,
542
- .pp-capability-menus .menu-item-link:focus + .dashicons {
543
- display: inline-block;
544
- }
545
-
546
- .pp-capability-menus-wrapper .button-primary {
547
- margin-bottom: 25px !important;
548
- }
549
-
550
-
551
- .pp-capability-menus-wrapper .tooltip {
552
- position: relative;
553
- display: inline-block;
554
- border-bottom: 1px dotted black;
555
- }
556
-
557
- .pp-capability-menus-wrapper .tooltip .tooltiptext {
558
- visibility: hidden;
559
- width: 120px;
560
- background-color: black;
561
- color: #fff;
562
- text-align: center;
563
- padding: 5px 0;
564
- border-radius: 6px;
565
-
566
- position: absolute;
567
- z-index: 1;
568
- }
569
-
570
- .pp-capability-menus-wrapper .tooltip:hover .tooltiptext {
571
- visibility: visible;
572
- }
573
-
574
- .capabilities_page_pp-capabilities-admin-menus input.ppc-admin-menu-submit,
575
- .capabilities_page_pp-capabilities-nav-menus input.ppc-nav-menu-submit {
576
- margin-bottom: 10px !important;
577
- }
578
-
579
- .pp-capability-menus-wrapper .features-section-header {
580
- padding-left: 35px !important;
581
- }
582
-
583
- /* ====================================================== Main Screen */
584
-
585
- #ppc-capabilities-wrapper {
586
- display: grid;
587
- grid-template-columns: 1fr 4fr;
588
- min-height: 400px;
589
- }
590
-
591
- /*
592
- #ppc-capabilities-wrapper .ppc-capabilities-tabs {
593
-
594
- }
595
- */
596
-
597
- #ppc-capabilities-wrapper .ppc-capabilities-tabs > ul {
598
- padding: 0;
599
- margin: 0;
600
- display: block;
601
- }
602
-
603
- #ppc-capabilities-wrapper .ppc-capabilities-tabs > ul > li {
604
- margin: 0;
605
- padding: 15px 12px;
606
- background: #f0f0f1;
607
- cursor: pointer;
608
- border-bottom: 1px solid #ccc;
609
- border-right: 1px solid #ccc;
610
- font-size: 1.1em;
611
- line-height: 1.3em;
612
- }
613
-
614
- #ppc-capabilities-wrapper .ppc-capabilities-tabs > ul > li:last-child {
615
- margin-bottom: 20px;
616
- }
617
-
618
- #ppc-capabilities-wrapper .ppc-capabilities-tabs > ul > li.ppc-capabilities-tab-active {
619
- background: #fff;
620
- border-right-color: #fff;
621
- }
622
-
623
- #ppc-capabilities-wrapper .ppc-capabilities-content > div {
624
- padding: 20px;
625
- }
626
-
627
- #ppc-capabilities-wrapper .ppc-capabilities-content > div > h3 {
628
- margin-top: 0;
629
- }
630
-
631
- @media (max-width: 1199px) {
632
-
633
- #ppc-capabilities-wrapper {
634
- display: block;
635
- }
636
-
637
- #ppc-capabilities-wrapper .ppc-capabilities-tabs > ul > li,
638
- #ppc-capabilities-wrapper .ppc-capabilities-tabs > ul > li.ppc-capabilities-tab-active {
639
- border-right: none;
640
- }
641
-
642
- #publishpress_caps_form #akmin td.content,
643
- #publishpress_caps_form #akmin td.sidebar {
644
- display: block;
645
- padding: 0;
646
- }
647
-
648
- #publishpress_caps_form #akmin td.content {
649
- margin-bottom: 40px;
650
- }
651
- }
652
-
653
- @media (max-width: 782px) {
654
-
655
- table.cme-checklist.form-table tr td {
656
- padding: 15px 10px;
657
- }
658
-
659
- table .cme-typecaps th:first-of-type {
660
- width: 110px;
661
- }
662
-
663
- .pp-capability-menus {
664
- background: linear-gradient(90deg, #fafafa 0%, #fafafa 48px, #fff 48px, #fff 100%);
665
- }
666
-
667
- #pp-capability-menu-wrapper table td,
668
- #pp-capability-menu-wrapper table th {
669
- line-height: 24px;
670
- }
671
-
672
- }
36
  a.cap_type:hover {
37
  text-decoration: underline;
38
  }
39
+
40
  ul.cme-listhoriz li {
41
  text-align: center;
42
  padding-right: 1em;
61
  margin: 0;
62
  }
63
 
64
+
65
  div.cme-listhoriz h3 {
66
  margin: 0.2em;
67
  }
70
  border: 1px solid black;
71
  }
72
 
 
 
 
 
 
 
 
 
 
 
73
  table .cme-typecaps td {
74
  text-align: center;
75
  height: 2em;
76
  }
77
 
 
 
 
 
78
  table .cme-typecaps th {
79
+ padding-left: 0.3em;
80
+ padding-right: 0.3em;
81
  cursor: pointer;
 
82
  }
83
 
84
  table.cme-typecaps span.cap-x {
90
  cursor: pointer;
91
  }
92
 
 
 
 
 
93
  h3.cme-cap-section {
94
  margin-top:0;
95
  }
241
  min-width:600px;
242
  }
243
 
244
+ #pp_features div.pp-logo {
245
  text-align: center;
246
  }
247
 
248
+ #pp_features div.features-wrap {
249
+ margin-left: auto;
250
+ margin-right: auto;
251
+ text-align: center;
252
  width: 600px;
253
  }
254
 
255
+ #pp_features ul.pp-features {
256
+ list-style: none;
257
+ padding-top:10px;
258
+ text-align:left;
259
  margin-left: auto;
260
  }
261
 
262
+ #pp_features ul.pp-features li:before {
263
  content: "\2713\0020";
264
  }
265
 
266
+ #pp_features ul.pp-features li {
267
  padding-bottom: 5px;
268
  }
269
 
270
+ #pp_features img.cme-play {
271
+ margin-bottom: -3px;
272
  margin-left: 5px;
273
  }
274
 
275
  div.publishpress-caps-manage span.manage-members {
276
+ margin-left:5px;
277
+ font-weight:normal;
278
  color: #777;
279
  }
280
 
283
  }
284
 
285
  div.publishpress-caps-manage span.manage-members a:hover {
286
+ text-decoration: underline;
287
  color:#655997;
288
  }
289
 
296
  }
297
 
298
  div.publishpress-caps-backup th {
299
+ text-align:right;
300
+ padding-top:28px;
301
  width: 140px;
302
  }
303
 
340
  }
341
 
342
  div.cme-restore-button {
343
+ margin-top: 25px;
344
  padding-left: 5px;
345
  }
346
 
361
  }
362
 
363
  div.publishpress-caps-backup td.cme-backup-info .cme-plus {
364
+ font-weight: bold;
365
  color: green;
366
  }
367
 
379
  }
380
 
381
  div.publishpress-caps-backup td.cme-backup-info .cme-minus {
382
+ font-weight: bold;
383
+ color: #a00;
384
  text-decoration: line-through;
385
  }
386
 
387
  div.publishpress-caps-backup td.cme-backup-info .cme-negate {
388
+ font-weight: bold;
389
+ background-color: #a00;
390
  color: white;
391
  text-decoration: line-through;
392
  }
415
 
416
  table#akmin tr td input[type=checkbox] {
417
  margin: 0;
418
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
common/img/capabilities-wp-logo.png DELETED
Binary file
composer.json CHANGED
@@ -16,7 +16,6 @@
16
  "require": {
17
  "php": ">=5.6.20",
18
  "pimple/pimple": "3.2.3.*",
19
- "publishpress/wordpress-reviews": "^1.1",
20
  "publishpress/wordpress-version-notices": "dev-master"
21
  }
22
  }
16
  "require": {
17
  "php": ">=5.6.20",
18
  "pimple/pimple": "3.2.3.*",
 
19
  "publishpress/wordpress-version-notices": "dev-master"
20
  }
21
  }
includes-core/pp-capabilities-permissions.php DELETED
@@ -1,445 +0,0 @@
1
- <?php
2
- /**
3
- * Original Author: danieliser
4
- * Original Author URL: https://danieliser.com
5
- */
6
-
7
- if ( ! defined( 'ABSPATH' ) ) {
8
- exit;
9
- }
10
-
11
- /**
12
- * Class Ppc_Install_Permissions
13
- *
14
- * This class adds a message inviting to install Permissions
15
- */
16
- if( !class_exists('Ppc_Install_Permissions') ) {
17
- class Ppc_Install_Permissions {
18
-
19
- /**
20
- * Tracking API Endpoint.
21
- *
22
- * @var string
23
- */
24
- public static $api_url = '';
25
-
26
- /**
27
- *
28
- */
29
- public static function init() {
30
- if (!isset( $_GET['pp-after-click'])) {
31
- self::hooks();
32
-
33
- add_action( 'wp_ajax_ppc_permissions_action', array( __CLASS__, 'ajax_handler' ) );
34
- }
35
- }
36
-
37
- /**
38
- * Hook into relevant WP actions.
39
- */
40
- public static function hooks() {
41
- if ( is_admin() && current_user_can( 'edit_posts' ) ) {
42
- self::installed_on();
43
- add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
44
- add_action( 'network_admin_notices', array( __CLASS__, 'admin_notices' ) );
45
- add_action( 'user_admin_notices', array( __CLASS__, 'admin_notices' ) );
46
- }
47
- }
48
-
49
- /**
50
- * Get the install date for comparisons. Sets the date to now if none is found.
51
- *
52
- * @return false|string
53
- */
54
- public static function installed_on() {
55
- $installed_on = get_option( 'ppc_permissions_installed_on', false );
56
-
57
- if ( ! $installed_on ) {
58
- $installed_on = current_time( 'mysql' );
59
- update_option( 'ppc_permissions_installed_on', $installed_on );
60
- }
61
-
62
- return $installed_on;
63
- }
64
-
65
- /**
66
- *
67
- */
68
- public static function ajax_handler() {
69
- $args = wp_parse_args( $_REQUEST, array(
70
- 'group' => self::get_trigger_group(),
71
- 'code' => self::get_trigger_code(),
72
- 'pri' => self::get_current_trigger( 'pri' ),
73
- 'reason' => 'maybe_later',
74
- ) );
75
-
76
- if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'ppc_permissions_action' ) ) {
77
- wp_send_json_error();
78
- }
79
-
80
- try {
81
- $user_id = get_current_user_id();
82
-
83
- $dismissed_triggers = self::dismissed_triggers();
84
- $dismissed_triggers[ $args['group'] ] = $args['pri'];
85
- update_user_meta( $user_id, '_ppc_permissions_dismissed_triggers', $dismissed_triggers );
86
- update_user_meta( $user_id, '_ppc_permissions_last_dismissed', current_time( 'mysql' ) );
87
-
88
- switch ( $args['reason'] ) {
89
- case 'maybe_later':
90
- update_user_meta( $user_id, '_ppc_permissions_last_dismissed', current_time( 'mysql' ) );
91
- break;
92
- case 'am_now':
93
- case 'already_did':
94
- self::already_did( true );
95
- break;
96
- }
97
-
98
- wp_send_json_success();
99
-
100
- } catch ( Exception $e ) {
101
- wp_send_json_error( $e );
102
- }
103
- }
104
-
105
- /**
106
- * @return int|string
107
- */
108
- public static function get_trigger_group() {
109
- static $selected;
110
-
111
- if ( ! isset( $selected ) ) {
112
-
113
- $dismissed_triggers = self::dismissed_triggers();
114
-
115
- $triggers = self::triggers();
116
-
117
- foreach ( $triggers as $g => $group ) {
118
- foreach ( $group['triggers'] as $t => $trigger ) {
119
- if ( ! in_array( false, $trigger['conditions'] ) && ( empty( $dismissed_triggers[ $g ] ) || $dismissed_triggers[ $g ] < $trigger['pri'] ) ) {
120
- $selected = $g;
121
- break;
122
- }
123
- }
124
-
125
- if ( isset( $selected ) ) {
126
- break;
127
- }
128
- }
129
- }
130
-
131
- return $selected;
132
- }
133
-
134
- /**
135
- * @return int|string
136
- */
137
- public static function get_trigger_code() {
138
- static $selected;
139
-
140
- if ( ! isset( $selected ) ) {
141
-
142
- $dismissed_triggers = self::dismissed_triggers();
143
-
144
- foreach ( self::triggers() as $g => $group ) {
145
- foreach ( $group['triggers'] as $t => $trigger ) {
146
- if ( ! in_array( false, $trigger['conditions'] ) && ( empty( $dismissed_triggers[ $g ] ) || $dismissed_triggers[ $g ] < $trigger['pri'] ) ) {
147
- $selected = $t;
148
- break;
149
- }
150
- }
151
-
152
- if ( isset( $selected ) ) {
153
- break;
154
- }
155
- }
156
- }
157
-
158
- return $selected;
159
- }
160
-
161
- /**
162
- * @param null $key
163
- *
164
- * @return bool|mixed|void
165
- */
166
- public static function get_current_trigger( $key = null ) {
167
- $group = self::get_trigger_group();
168
- $code = self::get_trigger_code();
169
-
170
- if ( ! $group || ! $code ) {
171
- return false;
172
- }
173
-
174
- $trigger = self::triggers( $group, $code );
175
-
176
- if(empty($key)){
177
- $return = $trigger;
178
- }elseif(isset($trigger[$key])){
179
- $return = $trigger[$key];
180
- }else {
181
- $return = false;
182
- }
183
-
184
- return $return;
185
- }
186
-
187
- /**
188
- * Returns an array of dismissed trigger groups.
189
- *
190
- * Array contains the group key and highest priority trigger that has been shown previously for each group.
191
- *
192
- * $return = array(
193
- * 'group1' => 20
194
- * );
195
- *
196
- * @return array|mixed
197
- */
198
- public static function dismissed_triggers() {
199
- $user_id = get_current_user_id();
200
-
201
- $dismissed_triggers = get_user_meta( $user_id, '_ppc_permissions_dismissed_triggers', true );
202
-
203
- if ( ! $dismissed_triggers ) {
204
- $dismissed_triggers = array();
205
- }
206
-
207
- return $dismissed_triggers;
208
- }
209
-
210
- /**
211
- * Returns true if the user has opted to never see this again. Or sets the option.
212
- *
213
- * @param bool $set If set this will mark the user as having opted to never see this again.
214
- *
215
- * @return bool
216
- */
217
- public static function already_did( $set = false ) {
218
- $user_id = get_current_user_id();
219
-
220
- if ( $set ) {
221
- update_user_meta( $user_id, '_ppc_permissions_already_did', true );
222
-
223
- return true;
224
- }
225
-
226
- return (bool) get_user_meta( $user_id, '_ppc_permissions_already_did', true );
227
- }
228
-
229
- /**
230
- * Gets a list of triggers.
231
- *
232
- * @param null $group
233
- * @param null $code
234
- *
235
- * @return bool|mixed|void
236
- */
237
- public static function triggers( $group = null, $code = null ) {
238
- static $triggers;
239
-
240
- if ( ! isset( $triggers ) ) {
241
-
242
- $time_message = __( 'Do you want to control permissions for specific posts and pages?', 'capsman-enhanced' );
243
-
244
- $triggers = apply_filters( 'ppc_permissions_triggers', array(
245
- 'time_installed' => array(
246
- 'triggers' => array(
247
- 'one_week' => array(
248
- 'message' => sprintf( $time_message, __( '1 week', 'capsman-enhanced' ) ),
249
- 'conditions' => array(
250
- strtotime( self::installed_on() . ' +1 week' ) < time(),
251
- ),
252
- 'link' => admin_url( 'plugin-install.php?s=publishpress+permissions+control+access&tab=search&type=term&pp-after-click' ),
253
- 'pri' => 10,
254
- ),
255
- ),
256
- 'pri' => 10,
257
- ),
258
- ) );
259
-
260
- // Sort Groups
261
- uasort( $triggers, array( __CLASS__, 'rsort_by_priority' ) );
262
-
263
- // Sort each groups triggers.
264
- foreach ( $triggers as $k => $v ) {
265
- uasort( $triggers[ $k ]['triggers'], array( __CLASS__, 'rsort_by_priority' ) );
266
- }
267
- }
268
-
269
- if ( isset( $group ) ) {
270
- if ( ! isset( $triggers[ $group ] ) ) {
271
- return false;
272
- }
273
-
274
- if (!isset($code)) {
275
- $return = $triggers[$group];
276
- } elseif (isset($triggers[$group]['triggers'][$code])) {
277
- $return = $triggers[$group]['triggers'][$code];
278
- } else {
279
- $return = false;
280
- }
281
-
282
- return $return;
283
- }
284
-
285
- return $triggers;
286
- }
287
-
288
- /**
289
- * Render admin notices if available.
290
- */
291
- public static function admin_notices() {
292
- if ( self::hide_notices() ) {
293
- return;
294
- }
295
-
296
- $group = self::get_trigger_group();
297
- $code = self::get_trigger_code();
298
- $pri = self::get_current_trigger( 'pri' );
299
- $tigger = self::get_current_trigger();
300
-
301
- // Used to anonymously distinguish unique site+user combinations in terms of effectiveness of each trigger.
302
- $uuid = wp_hash( home_url() . '-' . get_current_user_id() );
303
-
304
- ?>
305
-
306
- <script type="text/javascript">
307
- (function ($) {
308
- var trigger = {
309
- group: '<?php echo $group; ?>',
310
- code: '<?php echo $code; ?>',
311
- pri: '<?php echo $pri; ?>'
312
- };
313
-
314
- function dismiss(reason) {
315
- $.ajax({
316
- method: "POST",
317
- dataType: "json",
318
- url: ajaxurl,
319
- data: {
320
- action: 'ppc_permissions_action',
321
- nonce: '<?php echo wp_create_nonce( 'ppc_permissions_action' ); ?>',
322
- group: trigger.group,
323
- code: trigger.code,
324
- pri: trigger.pri,
325
- reason: reason
326
- }
327
- });
328
-
329
- <?php if ( ! empty( self::$api_url ) ) : ?>
330
- $.ajax({
331
- method: "POST",
332
- dataType: "json",
333
- url: '<?php echo self::$api_url; ?>',
334
- data: {
335
- trigger_group: trigger.group,
336
- trigger_code: trigger.code,
337
- reason: reason,
338
- uuid: '<?php echo $uuid; ?>'
339
- }
340
- });
341
- <?php endif; ?>
342
- }
343
-
344
- $(document)
345
- .on('click', '.ppc-notice .ppc-dismiss', function (event) {
346
- var $this = $(this),
347
- reason = $this.data('reason'),
348
- notice = $this.parents('.ppc-notice');
349
-
350
- notice.fadeTo(100, 0, function () {
351
- notice.slideUp(100, function () {
352
- notice.remove();
353
- });
354
- });
355
-
356
- dismiss(reason);
357
- })
358
- .ready(function () {
359
- setTimeout(function () {
360
- $('.ppc-notice button.notice-dismiss').click(function (event) {
361
- dismiss('maybe_later');
362
- });
363
- }, 1000);
364
- });
365
- }(jQuery));
366
- </script>
367
-
368
- <div class="notice notice-success is-dismissible ppc-notice">
369
-
370
- <p>
371
- <?php echo $tigger['message']; ?>
372
- </p>
373
- <p>
374
- <a class="button button-primary ppc-dismiss" target="_blank" href="<?php echo admin_url( 'plugin-install.php?s=publishpress+permissions+control+access&tab=search&type=term&pp-after-click' ) ?>" data-reason="am_now">
375
- <strong><?php _e( 'Install PublishPress Permissions', 'capsman-enhanced' ); ?></strong>
376
- </a>
377
- </p>
378
-
379
- </div>
380
-
381
- <?php
382
- }
383
-
384
- /**
385
- * Checks if notices should be shown.
386
- *
387
- * @return bool
388
- */
389
- public static function hide_notices() {
390
- $conditions = array(
391
- self::already_did(),
392
- self::last_dismissed() && strtotime( self::last_dismissed() . ' +2 weeks' ) > time(),
393
- empty( self::get_trigger_code() ),
394
- );
395
-
396
- return in_array( true, $conditions );
397
- }
398
-
399
- /**
400
- * Gets the last dismissed date.
401
- *
402
- * @return false|string
403
- */
404
- public static function last_dismissed() {
405
- $user_id = get_current_user_id();
406
-
407
- return get_user_meta( $user_id, '_ppc_permissions_last_dismissed', true );
408
- }
409
-
410
- /**
411
- * Sort array by priority value
412
- *
413
- * @param $a
414
- * @param $b
415
- *
416
- * @return int
417
- */
418
- public static function sort_by_priority( $a, $b ) {
419
- if ( ! isset( $a['pri'] ) || ! isset( $b['pri'] ) || $a['pri'] === $b['pri'] ) {
420
- return 0;
421
- }
422
-
423
- return ( $a['pri'] < $b['pri'] ) ? - 1 : 1;
424
- }
425
-
426
- /**
427
- * Sort array in reverse by priority value
428
- *
429
- * @param $a
430
- * @param $b
431
- *
432
- * @return int
433
- */
434
- public static function rsort_by_priority( $a, $b ) {
435
- if ( ! isset( $a['pri'] ) || ! isset( $b['pri'] ) || $a['pri'] === $b['pri'] ) {
436
- return 0;
437
- }
438
-
439
- return ( $a['pri'] < $b['pri'] ) ? 1 : - 1;
440
- }
441
-
442
- }
443
-
444
- Ppc_Install_Permissions::init();
445
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin-load.php CHANGED
@@ -35,7 +35,7 @@ class PP_Capabilities_Admin_UI {
35
  add_action('user_register', [$this, 'action_profile_update'], 9);
36
  }
37
 
38
- if (is_admin() && (isset($_REQUEST['page']) && (in_array($_REQUEST['page'], ['pp-capabilities', 'pp-capabilities-backup', 'pp-capabilities-roles', 'pp-capabilities-admin-menus', 'pp-capabilities-editor-features', 'pp-capabilities-nav-menus', 'pp-capabilities-settings', 'pp-capabilities-admin-features']))
39
 
40
  || (!empty($_REQUEST['action']) && in_array($_REQUEST['action'], ['pp-roles-add-role', 'pp-roles-delete-role', 'pp-roles-hide-role', 'pp-roles-unhide-role']))
41
  || ( ! empty($_SERVER['SCRIPT_NAME']) && strpos( $_SERVER['SCRIPT_NAME'], 'p-admin/plugins.php' ) && ! empty($_REQUEST['action'] ) )
@@ -53,36 +53,6 @@ class PP_Capabilities_Admin_UI {
53
  } else {
54
  add_action( 'admin_menu', [$this, 'cmeSubmenus'], 20 );
55
  }
56
-
57
- add_action('init', function() { // late execution avoids clash with autoloaders in other plugins
58
- global $pagenow;
59
-
60
- if ((($pagenow == 'admin.php') && isset($_GET['page']) && in_array($_GET['page'], ['pp-capabilities', 'pp-capabilities-roles', 'pp-capabilities-backup'])) // @todo: CSS for button alignment in Editor Features, Admin Features
61
- || (defined('DOING_AJAX') && DOING_AJAX && (false !== strpos($_REQUEST['action'], 'capability-manager-enhanced')))
62
- ) {
63
- if (!class_exists('\PublishPress\WordPressReviews\ReviewsController')) {
64
- include_once PUBLISHPRESS_CAPS_ABSPATH . '/vendor/publishpress/wordpress-reviews/ReviewsController.php';
65
- }
66
-
67
- if (class_exists('\PublishPress\WordPressReviews\ReviewsController')) {
68
- $reviews = new \PublishPress\WordPressReviews\ReviewsController(
69
- 'capability-manager-enhanced',
70
- 'PublishPress Capabilities',
71
- plugin_dir_url(CME_FILE) . 'common/img/capabilities-wp-logo.png'
72
- );
73
-
74
- add_filter('publishpress_wp_reviews_display_banner_capability-manager-enhanced', [$this, 'shouldDisplayBanner']);
75
-
76
- $reviews->init();
77
- }
78
- }
79
- });
80
- }
81
-
82
- public function shouldDisplayBanner() {
83
- global $pagenow;
84
-
85
- return ($pagenow == 'admin.php') && isset($_GET['page']) && in_array($_GET['page'], ['pp-capabilities', 'pp-capabilities-roles', 'pp-capabilities-backup']);
86
  }
87
 
88
  private function applyFeatureRestrictions($editor = 'gutenberg') {
@@ -287,7 +257,6 @@ class PP_Capabilities_Admin_UI {
287
 
288
  add_submenu_page('pp-capabilities', __('Roles', 'capsman-enhanced'), __('Roles', 'capsman-enhanced'), $cap_name, 'pp-capabilities-roles', 'cme_fakefunc');
289
  add_submenu_page('pp-capabilities', __('Editor Features', 'capsman-enhanced'), __('Editor Features', 'capsman-enhanced'), $cap_name, 'pp-capabilities-editor-features', 'cme_fakefunc');
290
- add_submenu_page('pp-capabilities', __('Admin Features', 'capsman-enhanced'), __('Admin Features', 'capsman-enhanced'), $cap_name, 'pp-capabilities-admin-features', 'cme_fakefunc');
291
  add_submenu_page('pp-capabilities', __('Admin Menus', 'capsman-enhanced'), __('Admin Menus', 'capsman-enhanced'), $cap_name, 'pp-capabilities-admin-menus', 'cme_fakefunc');
292
  add_submenu_page('pp-capabilities', __('Nav Menus', 'capsman-enhanced'), __('Nav Menus', 'capsman-enhanced'), $cap_name, 'pp-capabilities-nav-menus', 'cme_fakefunc');
293
  add_submenu_page('pp-capabilities', __('Backup', 'capsman-enhanced'), __('Backup', 'capsman-enhanced'), $cap_name, 'pp-capabilities-backup', 'cme_fakefunc');
35
  add_action('user_register', [$this, 'action_profile_update'], 9);
36
  }
37
 
38
+ if (is_admin() && (isset($_REQUEST['page']) && (in_array($_REQUEST['page'], ['pp-capabilities', 'pp-capabilities-backup', 'pp-capabilities-roles', 'pp-capabilities-admin-menus', 'pp-capabilities-editor-features', 'pp-capabilities-nav-menus', 'pp-capabilities-settings']))
39
 
40
  || (!empty($_REQUEST['action']) && in_array($_REQUEST['action'], ['pp-roles-add-role', 'pp-roles-delete-role', 'pp-roles-hide-role', 'pp-roles-unhide-role']))
41
  || ( ! empty($_SERVER['SCRIPT_NAME']) && strpos( $_SERVER['SCRIPT_NAME'], 'p-admin/plugins.php' ) && ! empty($_REQUEST['action'] ) )
53
  } else {
54
  add_action( 'admin_menu', [$this, 'cmeSubmenus'], 20 );
55
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
 
58
  private function applyFeatureRestrictions($editor = 'gutenberg') {
257
 
258
  add_submenu_page('pp-capabilities', __('Roles', 'capsman-enhanced'), __('Roles', 'capsman-enhanced'), $cap_name, 'pp-capabilities-roles', 'cme_fakefunc');
259
  add_submenu_page('pp-capabilities', __('Editor Features', 'capsman-enhanced'), __('Editor Features', 'capsman-enhanced'), $cap_name, 'pp-capabilities-editor-features', 'cme_fakefunc');
 
260
  add_submenu_page('pp-capabilities', __('Admin Menus', 'capsman-enhanced'), __('Admin Menus', 'capsman-enhanced'), $cap_name, 'pp-capabilities-admin-menus', 'cme_fakefunc');
261
  add_submenu_page('pp-capabilities', __('Nav Menus', 'capsman-enhanced'), __('Nav Menus', 'capsman-enhanced'), $cap_name, 'pp-capabilities-nav-menus', 'cme_fakefunc');
262
  add_submenu_page('pp-capabilities', __('Backup', 'capsman-enhanced'), __('Backup', 'capsman-enhanced'), $cap_name, 'pp-capabilities-backup', 'cme_fakefunc');
includes/admin.php CHANGED
@@ -1,1342 +1,1189 @@
1
- <?php
2
- /**
3
- * PublishPress Capabilities [Free]
4
- *
5
- * UI output for Capabilities screen.
6
- *
7
- * Provides admin pages to create and manage roles and capabilities.
8
- *
9
- * @author Jordi Canals, Kevin Behrens
10
- * @copyright Copyright (C) 2009, 2010 Jordi Canals, (C) 2020 PublishPress
11
- * @license GNU General Public License version 2
12
- * @link https://publishpress.com
13
- *
14
- * Copyright 2009, 2010 Jordi Canals <devel@jcanals.cat>
15
- * Modifications Copyright 2020, PublishPress <help@publishpress.com>
16
- *
17
- * This program is free software; you can redistribute it and/or
18
- * modify it under the terms of the GNU General Public License
19
- * version 2 as published by the Free Software Foundation.
20
- *
21
- * This program is distributed in the hope that it will be useful,
22
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- * GNU General Public License for more details.
25
- *
26
- * You should have received a copy of the GNU General Public License
27
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
28
- **/
29
-
30
- global $capsman, $cme_cap_helper, $current_user;
31
-
32
- do_action('publishpress-caps_manager-load');
33
-
34
- $roles = $this->roles;
35
- $default = $this->current;
36
-
37
- if ( $block_read_removal = _cme_is_read_removal_blocked( $this->current ) ) {
38
- if ( $current = get_role($default) ) {
39
- if ( empty( $current->capabilities['read'] ) ) {
40
- ak_admin_error( sprintf( __( 'Warning: This role cannot access the dashboard without the read capability. %1$sClick here to fix this now%2$s.', 'capsman-enhanced' ), '<a href="javascript:void(0)" class="cme-fix-read-cap">', '</a>' ) );
41
- }
42
- }
43
- }
44
-
45
- require_once (dirname(CME_FILE) . '/includes/roles/roles-functions.php');
46
-
47
- require_once( dirname(__FILE__).'/pp-ui.php' );
48
- $pp_ui = new Capsman_PP_UI();
49
-
50
- if( defined('PRESSPERMIT_ACTIVE') ) {
51
- $pp_metagroup_caps = $pp_ui->get_metagroup_caps( $default );
52
- } else {
53
- $pp_metagroup_caps = array();
54
- }
55
- ?>
56
- <div class="wrap publishpress-caps-manage pressshack-admin-wrapper">
57
- <?php /*if( defined('PRESSPERMIT_ACTIVE') ) :
58
- pp_icon();
59
- $style = 'style="height:60px;"';
60
- */
61
- ?>
62
- <?php /* else: */
63
- $style = '';
64
- ?>
65
- <div id="icon-capsman-admin" class="icon32"></div>
66
- <?php /* endif; */ ?>
67
-
68
- <h1 <?php echo $style;?>><?php _e('Role Capabilities', 'capsman-enhanced') ?></h1>
69
-
70
- <?php
71
- echo pp_capabilities_roles()->notify->display();
72
- ?>
73
-
74
- <script type="text/javascript">
75
- /* <![CDATA[ */
76
- jQuery(document).ready( function($) {
77
- $('#publishpress_caps_form').attr('action', 'admin.php?page=pp-capabilities&role=' + $('select[name="role"]').val());
78
-
79
- $('select[name="role"]').change(function(){
80
- window.location = '<?php echo admin_url('admin.php?page=pp-capabilities&role='); ?>' + $(this).val() + '';
81
- });
82
- });
83
- /* ]]> */
84
- </script>
85
-
86
- <form id="publishpress_caps_form" method="post" action="admin.php?page=<?php echo $this->ID ?>">
87
- <?php wp_nonce_field('capsman-general-manager'); ?>
88
-
89
- <?php
90
- $tab = (!empty($_REQUEST['pp_caps_tab'])) ? sanitize_key($_REQUEST['pp_caps_tab']) : 'edit';
91
- ?>
92
-
93
- <input type="hidden" name="pp_caps_tab" value="<?php echo $tab;?>" />
94
-
95
- <p>
96
- <select name="role">
97
- <?php
98
- foreach ( $roles as $role => $name ) {
99
- if (pp_capabilities_is_editable_role($role)) {
100
- $name = translate_user_role($name);
101
- echo '<option value="' . $role .'"'; selected($default, $role); echo '> ' . $name . ' &nbsp;</option>';
102
- }
103
- }
104
- ?>
105
- </select>
106
- </p>
107
-
108
- <fieldset>
109
- <table id="akmin">
110
- <tr>
111
- <td class="content">
112
-
113
- <div style="float:right">
114
- <input type="submit" name="SaveRole" value="<?php echo (in_array(get_locale(), ['en_EN', 'en_US'])) ? 'Save Capabilities' : _e('Save Changes', 'capsman-enhanced'); ?>" class="button-primary" />
115
- </div>
116
-
117
- <?php
118
- global $capsman;
119
- $img_url = $capsman->mod_url . '/images/';
120
- ?>
121
- <div class="publishpress-headline" style="margin-bottom:20px;">
122
- <span class="cme-subtext">
123
- <?php
124
- $msg = __( '<strong>Note:</strong> Capability changes <strong>remain in the database</strong> after plugin deactivation.', 'capsman-enhanced' );
125
-
126
- if (defined('PRESSPERMIT_ACTIVE') && function_exists('presspermit')) {
127
- if ($group = presspermit()->groups()->getMetagroup('wp_role', $this->current)) {
128
- $msg = sprintf(
129
- __('<strong>Note:</strong> Capability changes <strong>remain in the database</strong> after plugin deactivation. You can also configure this role as a %sPermission Group%s.', 'capsman-enhanced'),
130
- '<a href="' . admin_url("admin.php?page=presspermit-edit-permissions&action=edit&agent_id={$group->ID}") . '">',
131
- '</a>'
132
- );
133
- }
134
- }
135
- echo $msg;
136
- ?>
137
- </span>
138
- </div>
139
-
140
- <?php
141
- if ( defined( 'PRESSPERMIT_ACTIVE' ) ) {
142
- $pp_ui->show_capability_hints( $default );
143
- }
144
-
145
- if ( MULTISITE ) {
146
- global $wp_roles;
147
- global $wpdb;
148
-
149
- if ( ! empty($_REQUEST['cme_net_sync_role'] ) ) {
150
- $main_site_id = (function_exists('get_main_site_id')) ? get_main_site_id() : 1;
151
- switch_to_blog($main_site_id);
152
- wp_cache_delete( $wpdb->prefix . 'user_roles', 'options' );
153
- }
154
-
155
- ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
156
- }
157
- $capsman->reinstate_db_roles();
158
-
159
- $current = get_role($default);
160
-
161
- $rcaps = $current->capabilities;
162
-
163
- $is_administrator = current_user_can( 'administrator' ) || (is_multisite() && is_super_admin());
164
-
165
- $custom_types = get_post_types( array( '_builtin' => false ), 'names' );
166
- $custom_tax = get_taxonomies( array( '_builtin' => false ), 'names' );
167
-
168
- $defined = [];
169
- $defined['type'] = apply_filters('cme_filterable_post_types', get_post_types(['public' => true, 'show_ui' => true], 'object', 'or'));
170
- $defined['taxonomy'] = apply_filters('cme_filterable_taxonomies', get_taxonomies(['public' => true, 'show_ui' => true], 'object', 'or'));
171
-
172
- // bbPress' dynamic role def requires additional code to enforce stored caps
173
- $unfiltered['type'] = apply_filters('presspermit_unfiltered_post_types', ['forum','topic','reply','wp_block']);
174
- $unfiltered['type'] = (defined('PP_CAPABILITIES_NO_LEGACY_FILTERS')) ? $unfiltered['type'] : apply_filters('pp_unfiltered_post_types', $unfiltered['type']);
175
-
176
- $unfiltered['taxonomy'] = apply_filters('presspermit_unfiltered_post_types', ['post_status', 'topic-tag']); // avoid confusion with Edit Flow administrative taxonomy
177
- $unfiltered['taxonomy'] = (defined('PP_CAPABILITIES_NO_LEGACY_FILTERS')) ? $unfiltered['taxonomy'] : apply_filters('pp_unfiltered_taxonomies', $unfiltered['taxonomy']);
178
-
179
- $enabled_taxonomies = cme_get_assisted_taxonomies();
180
-
181
- /*
182
- if ( ( count($custom_types) || count($custom_tax) ) && ( $is_administrator || current_user_can( 'manage_pp_settings' ) ) ) {
183
- $cap_properties[''] = array();
184
- $force_distinct_ui = true;
185
- }
186
- */
187
-
188
- $cap_properties['edit']['type'] = array( 'edit_posts' );
189
-
190
- foreach( $defined['type'] as $type_obj ) {
191
- if ( 'attachment' != $type_obj->name ) {
192
- if ( isset( $type_obj->cap->create_posts ) && ( $type_obj->cap->create_posts != $type_obj->cap->edit_posts ) ) {
193
- $cap_properties['edit']['type'][]= 'create_posts';
194
- break;
195
- }
196
- }
197
- }
198
-
199
- $cap_properties['edit']['type'][]= 'edit_others_posts';
200
- $cap_properties['edit']['type'] = array_merge( $cap_properties['edit']['type'], array( 'publish_posts', 'edit_published_posts', 'edit_private_posts' ) );
201
-
202
- $cap_properties['edit']['taxonomy'] = array( 'manage_terms' );
203
-
204
- if ( ! defined( 'OLD_PRESSPERMIT_ACTIVE' ) )
205
- $cap_properties['edit']['taxonomy'] = array_merge( $cap_properties['edit']['taxonomy'], array( 'edit_terms', 'assign_terms' ) );
206
-
207
- $cap_properties['delete']['type'] = array( 'delete_posts', 'delete_others_posts' );
208
- $cap_properties['delete']['type'] = array_merge( $cap_properties['delete']['type'], array( 'delete_published_posts', 'delete_private_posts' ) );
209
-
210
- if ( ! defined( 'OLD_PRESSPERMIT_ACTIVE' ) )
211
- $cap_properties['delete']['taxonomy'] = array( 'delete_terms' );
212
- else
213
- $cap_properties['delete']['taxonomy'] = array();
214
-
215
- $cap_properties['read']['type'] = array( 'read_private_posts' );
216
- $cap_properties['read']['taxonomy'] = array();
217
-
218
- $stati = get_post_stati( array( 'internal' => false ) );
219
-
220
- $cap_type_names = array(
221
- '' => __( '&nbsp;', 'capsman-enhanced' ),
222
- 'read' => __( 'Reading', 'capsman-enhanced' ),
223
- 'edit' => __( 'Editing', 'capsman-enhanced' ),
224
- 'delete' => __( 'Deletion', 'capsman-enhanced' )
225
- );
226
-
227
- $cap_tips = array(
228
- 'read_private' => __( 'can read posts which are currently published with private visibility', 'capsman-enhanced' ),
229
- 'edit' => __( 'has basic editing capability (but may need other capabilities based on post status and ownership)', 'capsman-enhanced' ),
230
- 'edit_others' => __( 'can edit posts which were created by other users', 'capsman-enhanced' ),
231
- 'edit_published' => __( 'can edit posts which are currently published', 'capsman-enhanced' ),
232
- 'edit_private' => __( 'can edit posts which are currently published with private visibility', 'capsman-enhanced' ),
233
- 'publish' => __( 'can make a post publicly visible', 'capsman-enhanced' ),
234
- 'delete' => __( 'has basic deletion capability (but may need other capabilities based on post status and ownership)', 'capsman-enhanced' ),
235
- 'delete_others' => __( 'can delete posts which were created by other users', 'capsman-enhanced' ),
236
- 'delete_published' => __( 'can delete posts which are currently published', 'capsman-enhanced' ),
237
- 'delete_private' => __( 'can delete posts which are currently published with private visibility', 'capsman-enhanced' ),
238
- );
239
-
240
- $default_caps = array( 'read_private_posts', 'edit_posts', 'edit_others_posts', 'edit_published_posts', 'edit_private_posts', 'publish_posts', 'delete_posts', 'delete_others_posts', 'delete_published_posts', 'delete_private_posts',
241
- 'read_private_pages', 'edit_pages', 'edit_others_pages', 'edit_published_pages', 'edit_private_pages', 'publish_pages', 'delete_pages', 'delete_others_pages', 'delete_published_pages', 'delete_private_pages',
242
- 'manage_categories'
243
- );
244
- $type_caps = array();
245
- $type_metacaps = array();
246
-
247
- // Role Scoper and PP1 adjust attachment access based only on user's capabilities for the parent post
248
- if ( defined('OLD_PRESSPERMIT_ACTIVE') ) {
249
- unset( $defined['type']['attachment'] );
250
- }
251
- ?>
252
-
253
- <script type="text/javascript">
254
- /* <![CDATA[ */
255
- jQuery(document).ready( function($) {
256
- // Tabs and Content display
257
- $('.ppc-capabilities-tabs > ul > li').click( function() {
258
- var $tab = $(this).attr('data-content');
259
- //console.log( $tab );
260
-
261
- $("[name='pp_caps_tab']").val($(this).attr('data-slug'));
262
-
263
- // Show current Content
264
- $('.ppc-capabilities-content > div').hide();
265
- $('#' + $tab).show();
266
-
267
- $('#' + $tab + '-taxonomy').show();
268
-
269
- // Active current Tab
270
- $('.ppc-capabilities-tabs > ul > li').removeClass('ppc-capabilities-tab-active');
271
- $(this).addClass('ppc-capabilities-tab-active');
272
- });
273
- });
274
- /* ]]> */
275
- </script>
276
-
277
- <div id="ppc-capabilities-wrapper" class="postbox">
278
- <div class="ppc-capabilities-tabs">
279
- <ul>
280
- <?php
281
- $active_tab_slug = (!empty($_REQUEST['pp_caps_tab'])) ? sanitize_key($_REQUEST['pp_caps_tab']) : 'edit';
282
- $active_tab_id = "cme-cap-type-tables-{$active_tab_slug}";
283
-
284
- $ppc_tab_active = ' class="ppc-capabilities-tab-active"';
285
-
286
- // caps: edit, delete, read
287
- foreach( array_keys($cap_properties) as $cap_type ) {
288
- $tab_id = "cme-cap-type-tables-$cap_type";
289
- $tab_active = ($tab_id == $active_tab_id) ? $ppc_tab_active : '';
290
-
291
- echo '<li data-slug="'. $cap_type . '"' . ' data-content="cme-cap-type-tables-' . $cap_type . '"' . $tab_active . '>'
292
- . $cap_type_names[$cap_type] .
293
- '</li>';
294
- }
295
-
296
- if ($extra_tabs = apply_filters('pp_capabilities_extra_post_capability_tabs', [])) {
297
- foreach($extra_tabs as $tab_slug => $tab_caption) {
298
- $tab_id = "cme-cap-type-tables-{$tab_slug}";
299
- $tab_active = ($tab_id == $active_tab_id) ? $ppc_tab_active : '';
300
-
301
- echo '<li data-slug="' . $tab_slug . '"' . ' data-content="' . $tab_id . '"' . $tab_active . '>'
302
- . $tab_caption .
303
- '</li>';
304
- }
305
- }
306
-
307
- // caps: other
308
- $tab_id = "cme-cap-type-tables-other";
309
- $tab_active = ($tab_id == $active_tab_id) ? $ppc_tab_active : '';
310
- $tab_caption = __( 'WordPress Core', 'capsman-enhanced' );
311
-
312
- echo '<li data-slug="other" data-content="' . $tab_id . '"' . $tab_active . '>' . $tab_caption . '</li>';
313
-
314
- // caps: plugins
315
- $plugin_caps = [];
316
- if (defined('PUBLISHPRESS_VERSION')) {
317
- $plugin_caps['PublishPress'] = apply_filters('cme_publishpress_capabilities',
318
- array(
319
- 'edit_metadata',
320
- 'edit_post_subscriptions',
321
- 'pp_manage_roles',
322
- 'pp_set_notification_channel',
323
- 'pp_view_calendar',
324
- 'pp_view_content_overview',
325
- )
326
- );
327
- }
328
-
329
- if (defined('PUBLISHPRESS_MULTIPLE_AUTHORS_VERSION')) {
330
- if ($_caps = apply_filters('cme_multiple_authors_capabilities', array())) {
331
- $plugin_caps['PublishPress Authors'] = $_caps;
332
- }
333
- }
334
-
335
- if (defined('PRESSPERMIT_VERSION')) {
336
- $plugin_caps['PublishPress Permissions'] = apply_filters('cme_presspermit_capabilities',
337
- array(
338
- 'edit_own_attachments',
339
- 'list_others_unattached_files',
340
- 'pp_administer_content',
341
- 'pp_assign_roles',
342
- 'pp_associate_any_page',
343
- 'pp_create_groups',
344
- 'pp_create_network_groups',
345
- 'pp_define_moderation',
346
- 'pp_define_post_status',
347
- 'pp_define_privacy',
348
- 'pp_delete_groups',
349
- 'pp_edit_groups',
350
- 'pp_exempt_edit_circle',
351
- 'pp_exempt_read_circle',
352
- 'pp_force_quick_edit',
353
- 'pp_list_all_files',
354
- 'pp_manage_capabilities',
355
- 'pp_manage_members',
356
- 'pp_manage_network_members',
357
- 'pp_manage_settings',
358
- 'pp_moderate_any',
359
- 'pp_set_associate_exceptions',
360
- 'pp_set_edit_exceptions',
361
- 'pp_set_read_exceptions',
362
- 'pp_set_revise_exceptions',
363
- 'pp_set_term_assign_exceptions',
364
- 'pp_set_term_associate_exceptions',
365
- 'pp_set_term_manage_exceptions',
366
- 'pp_unfiltered',
367
- 'set_posts_status',
368
- )
369
- );
370
- }
371
-
372
- if (defined('WC_PLUGIN_FILE')) {
373
- $plugin_caps['WooCommerce'] = apply_filters('cme_woocommerce_capabilities',
374
- array(
375
- 'assign_product_terms',
376
- 'assign_shop_coupon_terms',
377
- 'assign_shop_discount_terms',
378
- 'assign_shop_order_terms',
379
- 'assign_shop_payment_terms',
380
- 'create_shop_orders',
381
- 'delete_others_products',
382
- 'delete_others_shop_coupons',
383
- 'delete_others_shop_discounts',
384
- 'delete_others_shop_orders',
385
- 'delete_others_shop_payments',
386
- 'delete_private_products',
387
- 'delete_private_shop_coupons',
388
- 'delete_private_shop_orders',
389
- 'delete_private_shop_discounts',
390
- 'delete_private_shop_payments',
391
- 'delete_product_terms',
392
- 'delete_products',
393
- 'delete_published_products',
394
- 'delete_published_shop_coupons',
395
- 'delete_published_shop_discounts',
396
- 'delete_published_shop_orders',
397
- 'delete_published_shop_payments',
398
- 'delete_shop_coupons',
399
- 'delete_shop_coupon_terms',
400
- 'delete_shop_discount_terms',
401
- 'delete_shop_discounts',
402
- 'delete_shop_order_terms',
403
- 'delete_shop_orders',
404
- 'delete_shop_payments',
405
- 'delete_shop_payment_terms',
406
- 'edit_others_products',
407
- 'edit_others_shop_coupons',
408
- 'edit_others_shop_discounts',
409
- 'edit_others_shop_orders',
410
- 'edit_others_shop_payments',
411
- 'edit_private_products',
412
- 'edit_private_shop_coupons',
413
- 'edit_private_shop_discounts',
414
- 'edit_private_shop_orders',
415
- 'edit_private_shop_payments',
416
- 'edit_product_terms',
417
- 'edit_products',
418
- 'edit_published_products',
419
- 'edit_published_shop_coupons',
420
- 'edit_published_shop_discounts',
421
- 'edit_published_shop_orders',
422
- 'edit_published_shop_payments',
423
- 'edit_shop_coupon_terms',
424
- 'edit_shop_coupons',
425
- 'edit_shop_discounts',
426
- 'edit_shop_discount_terms',
427
- 'edit_shop_order_terms',
428
- 'edit_shop_orders',
429
- 'edit_shop_payments',
430
- 'edit_shop_payment_terms',
431
- 'export_shop_payments',
432
- 'export_shop_reports',
433
- 'import_shop_discounts',
434
- 'import_shop_payments',
435
- 'manage_product_terms',
436
- 'manage_shop_coupon_terms',
437
- 'manage_shop_discounts',
438
- 'manage_shop_discount_terms',
439
- 'manage_shop_payment_terms',
440
- 'manage_shop_order_terms',
441
- 'manage_shop_settings',
442
- 'manage_woocommerce',
443
- 'publish_products',
444
- 'publish_shop_coupons',
445
- 'publish_shop_discounts',
446
- 'publish_shop_orders',
447
- 'publish_shop_payments',
448
- 'read_private_products',
449
- 'read_private_shop_coupons',
450
- 'read_private_shop_discounts',
451
- 'read_private_shop_payments',
452
- 'read_private_shop_orders',
453
- 'view_admin_dashboard',
454
- 'view_shop_discount_stats',
455
- 'view_shop_payment_stats',
456
- 'view_shop_reports',
457
- 'view_shop_sensitive_data',
458
- 'view_woocommerce_reports',
459
- )
460
- );
461
- }
462
- $plugin_caps = apply_filters('cme_plugin_capabilities', $plugin_caps);
463
- foreach($plugin_caps as $plugin => $__plugin_caps) {
464
- $_plugin_caps = array_fill_keys($__plugin_caps, true);
465
-
466
- $tab_slug = str_replace(' ', '-', strtolower($plugin));
467
- $tab_id = 'cme-cap-type-tables-' . $tab_slug;
468
- $tab_active = ($tab_id == $active_tab_id) ? $ppc_tab_active : '';
469
-
470
- echo '<li data-slug="' . $tab_slug . '" data-content="' . $tab_id .'"' . $tab_active . '>'
471
- . str_replace('_', ' ', $plugin ) .
472
- '</li>';
473
- }
474
-
475
- $tab_id = "cme-cap-type-tables-invalid";
476
- $tab_active = ($tab_id == $active_tab_id) ? $ppc_tab_active : '';
477
- $tab_caption = __( 'Invalid Capabilities', 'capsman-enhanced' );
478
- echo '<li id="cme_tab_invalid_caps" data-slug="invalid" data-content="cme-cap-type-tables-' . $tab_id . '"' . $tab_active . ' style="display:none;">' . $tab_caption . '</li>';
479
-
480
- $tab_id = "cme-cap-type-tables-additional";
481
- $tab_active = ($tab_id == $active_tab_id) ? $ppc_tab_active : '';
482
- $tab_caption = __( 'Additional', 'capsman-enhanced' );
483
- echo '<li data-slug="additional" data-content="' . $tab_id . '"' . $tab_active . '>' . $tab_caption . '</li>';
484
- ?>
485
- </ul>
486
- </div>
487
- <div class="ppc-capabilities-content">
488
- <?php
489
- // caps: read, edit, deletion
490
- foreach( array_keys($cap_properties) as $cap_type ) {
491
-
492
- foreach( array_keys($defined) as $item_type ) {
493
- if ( ( 'delete' == $cap_type ) && ( 'taxonomy' == $item_type ) ) {
494
- if ( defined('OLD_PRESSPERMIT_ACTIVE') ) {
495
- continue;
496
- }
497
-
498
- $any_term_deletion_caps = false;
499
- foreach( array_keys($defined['taxonomy']) as $_tax ) {
500
- if ( isset( $defined['taxonomy'][$_tax]->cap->delete_terms ) && ( 'manage_categories' != $defined['taxonomy'][$_tax]->cap->delete_terms ) && ! in_array( $_tax, $unfiltered['taxonomy'] ) ) {
501
- $any_term_deletion_caps = true;
502
- break;
503
- }
504
- }
505
-
506
- if ( ! $any_term_deletion_caps )
507
- continue;
508
- }
509
-
510
- if ( ! count( $cap_properties[$cap_type][$item_type] ) )
511
- continue;
512
-
513
- $id = "cme-cap-type-tables-$cap_type";
514
- $div_display = ($id == $active_tab_id) ? 'block' : 'none';
515
-
516
- $any_caps = false;
517
-
518
- if ($item_type == 'taxonomy') {
519
- $id .= '-taxonomy';
520
-
521
- ob_start();
522
- }
523
-
524
- echo "<div id='$id' style='display:$div_display;'>";
525
-
526
- $caption_pattern = ('taxonomy' == $item_type) ? __('Term %s Capabilities', 'capability-manager-enhanced') : __('Post %s Capabilities', 'capability-manager-enhanced');
527
-
528
- echo '<h3>' . sprintf($caption_pattern, $cap_type_names[$cap_type]) . '</h3>';
529
- echo "<table class='widefat fixed striped cme-typecaps cme-typecaps-$cap_type'>";
530
-
531
- echo '<thead><tr><th></th>';
532
-
533
- // label cap properties
534
- foreach( $cap_properties[$cap_type][$item_type] as $prop ) {
535
- $prop = str_replace( '_posts', '', $prop );
536
- $prop = str_replace( '_pages', '', $prop );
537
- $prop = str_replace( '_terms', '', $prop );
538
- $tip = ( isset( $cap_tips[$prop] ) ) ? "title='{$cap_tips[$prop]}'" : '';
539
- $prop = str_replace( '_', '<br />', $prop );
540
- $th_class = ( 'taxonomy' == $item_type ) ? ' class="term-cap"' : ' class="post-cap"';
541
- echo "<th style='text-align:center;' $tip{$th_class}>";
542
-
543
- if ( ( 'delete' != $prop ) || ( 'taxonomy' != $item_type ) || cme_get_detailed_taxonomies() ) {
544
- echo ucwords($prop);
545
- }
546
-
547
- echo '</th>';
548
- }
549
-
550
- echo '</tr></thead>';
551
-
552
- foreach( $defined[$item_type] as $key => $type_obj ) {
553
- if ( in_array( $key, $unfiltered[$item_type] ) )
554
- continue;
555
-
556
- $row = "<tr class='cme_type_{$key}'>";
557
-
558
- if ( $cap_type ) {
559
- if ( empty($force_distinct_ui) && empty( $cap_properties[$cap_type][$item_type] ) )
560
- continue;
561
-
562
- $type_label = (defined('CME_LEGACY_MENU_NAME_LABEL') && !empty($type_obj->labels->menu_name)) ? $type_obj->labels->menu_name : $type_obj->labels->name;
563
-
564
- $row .= "<td><a class='cap_type' href='#toggle_type_caps'>" . $type_label . '</a>';
565
- $row .= '<a href="#" class="neg-type-caps">&nbsp;x&nbsp;</a>';
566
- $row .= '</td>';
567
-
568
- $display_row = ! empty($force_distinct_ui);
569
- $col_count = 0;
570
-
571
- foreach( $cap_properties[$cap_type][$item_type] as $prop ) {
572
- $td_classes = array();
573
- $checkbox = '';
574
- $title = '';
575
-
576
- if ( ! empty($type_obj->cap->$prop) && ( in_array( $type_obj->name, array( 'post', 'page' ) )
577
- || ! in_array( $type_obj->cap->$prop, $default_caps )
578
- || ( ( 'manage_categories' == $type_obj->cap->$prop ) && ( 'manage_terms' == $prop ) && ( 'category' == $type_obj->name ) ) ) ) {
579
-
580
- // if edit_published or edit_private cap is same as edit_posts cap, don't display a checkbox for it
581
- if ( ( ! in_array( $prop, array( 'edit_published_posts', 'edit_private_posts', 'create_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->edit_posts ) )
582
- && ( ! in_array( $prop, array( 'delete_published_posts', 'delete_private_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->delete_posts ) )
583
- && ( ! in_array( $prop, array( 'edit_terms', 'delete_terms' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->manage_terms ) )
584
-
585
- && ( ! in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) )
586
- || empty($cme_cap_helper->all_taxonomy_caps[$type_obj->cap->$prop])
587
- || ( $cme_cap_helper->all_taxonomy_caps[ $type_obj->cap->$prop ] <= 1 )
588
- || $type_obj->cap->$prop == str_replace( '_terms', "_{$type_obj->name}s", $prop )
589
- || $type_obj->cap->$prop == str_replace( '_terms', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
590
- )
591
-
592
- && ( in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) )
593
- || empty($cme_cap_helper->all_type_caps[$type_obj->cap->$prop])
594
- || ( $cme_cap_helper->all_type_caps[ $type_obj->cap->$prop ] <= 1 )
595
- || $type_obj->cap->$prop == 'upload_files' && 'create_posts' == $prop && 'attachment' == $type_obj->name
596
- || $type_obj->cap->$prop == str_replace( '_posts', "_{$type_obj->name}s", $prop )
597
- || $type_obj->cap->$prop == str_replace( '_pages', "_{$type_obj->name}s", $prop )
598
- || $type_obj->cap->$prop == str_replace( '_posts', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
599
- || $type_obj->cap->$prop == str_replace( '_pages', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
600
- )
601
- ) {
602
- // only present these term caps up top if we are ensuring that they get enforced separately from manage_terms
603
- if ( in_array( $prop, array( 'edit_terms', 'delete_terms', 'assign_terms' ) ) && ( ! in_array( $type_obj->name, cme_get_detailed_taxonomies() ) || defined( 'OLD_PRESSPERMIT_ACTIVE' ) ) ) {
604
- continue;
605
- }
606
-
607
- $cap_name = $type_obj->cap->$prop;
608
-
609
- if ( 'taxonomy' == $item_type )
610
- $td_classes []= "term-cap";
611
- else
612
- $td_classes []= "post-cap";
613
-
614
- if ( ! empty($pp_metagroup_caps[$cap_name]) )
615
- $td_classes []='cm-has-via-pp';
616
-
617
- if ( $is_administrator || current_user_can($cap_name) ) {
618
- if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
619
- $title = ' title="' . sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name ) . '"';
620
- } else {
621
- $title = ' title="' . $cap_name . '"';
622
- }
623
-
624
- $disabled = '';
625
- $checked = checked(1, ! empty($rcaps[$cap_name]), false );
626
-
627
- $checkbox = '<input type="checkbox"' . $title . ' name="caps[' . $cap_name . ']" autocomplete="off" value="1" ' . $checked . $disabled . ' />';
628
-
629
- $type_caps [$cap_name] = true;
630
- $display_row = true;
631
- $any_caps = true;
632
- }
633
- } else {
634
- //$td_classes []= "cap-unreg";
635
- $title = 'title="' . sprintf( __( 'shared capability: %s', 'capsman-enhanced' ), esc_attr( $type_obj->cap->$prop ) ) . '"';
636
- }
637
-
638
- if ( isset($rcaps[$cap_name]) && empty($rcaps[$cap_name]) ) {
639
- $td_classes []= "cap-neg";
640
- }
641
- } else {
642
- $td_classes []= "cap-unreg";
643
- }
644
-
645
- $td_class = ( $td_classes ) ? 'class="' . implode(' ', $td_classes) . '"' : '';
646
-
647
- $row .= "<td $td_class $title><span class='cap-x'>X</span>$checkbox";
648
-
649
- if ( false !== strpos( $td_class, 'cap-neg' ) )
650
- $row .= '<input type="hidden" class="cme-negation-input" name="caps[' . $cap_name . ']" value="" />';
651
-
652
- $row .= "</td>";
653
-
654
- $col_count++;
655
- }
656
-
657
- if ('taxonomy' == $item_type) {
658
- for ($i = $col_count; $i < 3; $i++) {
659
- $row .= "<td></td>";
660
- }
661
- }
662
-
663
- if (!empty($type_obj->map_meta_cap) && !defined('PP_CAPABILITIES_NO_INVALID_SECTION')) {
664
- if ('type' == $item_type) {
665
- $type_metacaps[$type_obj->cap->read_post] = true;
666
- $type_metacaps[$type_obj->cap->edit_post] = isset($type_obj->cap->edit_posts) && ($type_obj->cap->edit_post != $type_obj->cap->edit_posts);
667
- $type_metacaps[$type_obj->cap->delete_post] = isset($type_obj->cap->delete_posts) && ($type_obj->cap->delete_post != $type_obj->cap->delete_posts);
668
-
669
- } elseif ('taxonomy' == $item_type && !empty($type_obj->cap->edit_term) && !empty($type_obj->cap->delete_term)) {
670
- $type_metacaps[$type_obj->cap->edit_term] = true;
671
- $type_metacaps[$type_obj->cap->delete_term] = true;
672
- }
673
- }
674
- }
675
-
676
- if ( $display_row ) {
677
- $row .= '</tr>';
678
- echo $row;
679
- }
680
- }
681
-
682
- echo '</table>';
683
- echo '</div>';
684
-
685
- if ($item_type == 'taxonomy') {
686
- if ($any_caps) {
687
- ob_flush();
688
- } else {
689
- ob_clean();
690
- }
691
- }
692
-
693
- } // end foreach item type
694
- }
695
-
696
- if (empty($caps_manager_postcaps_section)) {
697
- $caps_manager_postcaps_section = '';
698
- }
699
-
700
- do_action('publishpress-caps_manager_postcaps_section', compact('current', 'rcaps', 'pp_metagroup_caps', 'is_administrator', 'default_caps', 'custom_types', 'defined', 'unfiltered', 'pp_metagroup_caps','caps_manager_postcaps_section', 'active_tab_id'));
701
-
702
- $type_caps = apply_filters('publishpress_caps_manager_typecaps', $type_caps);
703
-
704
- // clicking on post type name toggles corresponding checkbox selections
705
- // caps: other
706
-
707
- $id = "cme-cap-type-tables-other";
708
- $div_display = ($id == $active_tab_id) ? 'block' : 'none';
709
- ?>
710
- <div id="<?php echo $id;?>" style="display:<?php echo $div_display;?>">
711
- <?php
712
-
713
- echo '<h3>' . __( 'WordPress Core Capabilities', 'capsman-enhanced' ) . '</h3>';
714
- echo '<table class="widefat fixed striped form-table cme-checklist"><tr>';
715
-
716
- $checks_per_row = get_option( 'cme_form-rows', 1 );
717
- $i = 0; $first_row = true;
718
-
719
- $core_caps = _cme_core_caps();
720
- foreach( array_keys($core_caps) as $cap_name ) {
721
- if ( ! $is_administrator && ! current_user_can($cap_name) )
722
- continue;
723
-
724
- if ( $i == $checks_per_row ) {
725
- echo '</tr><tr>';
726
- $i = 0;
727
- }
728
-
729
- if ( ! isset( $rcaps[$cap_name] ) )
730
- $class = 'cap-no';
731
- else
732
- $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
733
-
734
- if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
735
- $class .= ' cap-metagroup';
736
- $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
737
- } else {
738
- $title_text = $cap_name;
739
- }
740
-
741
- $disabled = '';
742
- $checked = checked(1, ! empty($rcaps[$cap_name]), false );
743
- $lock_capability = false;
744
- $title = $title_text;
745
-
746
- if ( 'read' == $cap_name ) {
747
- if ( ! empty( $block_read_removal ) ) {
748
- // prevent the read capability from being removed from a core role, but don't force it to be added
749
- if ( $checked || apply_filters( 'pp_caps_force_capability_storage', false, 'read', $default ) ) {
750
- if ( apply_filters( 'pp_caps_lock_capability', true, 'read', $default ) ) {
751
- $lock_capability = true;
752
- $class .= ' cap-locked';
753
- $disabled = 'disabled="disabled"';
754
- if ( 'administrator' != $this->current ) {
755
- $title = esc_attr( __('Lockout Prevention: To remove read capability, first remove WordPress admin / editing capabilities, or add "dashboard_lockout_ok" capability', 'capsman-enhanced' ) );
756
- }
757
- }
758
- }
759
- }
760
- }
761
-
762
- ?>
763
- <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
764
- <span>
765
- <?php
766
- echo str_replace( '_', ' ', $cap_name );
767
- ?>
768
- </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
769
- <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
770
- <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
771
- <?php endif; ?>
772
- </td>
773
-
774
- <?php
775
-
776
- if ( $lock_capability ) {
777
- echo '<input type="hidden" name="caps[' . $cap_name . ']" value="1" />';
778
- }
779
-
780
- ++$i;
781
- }
782
-
783
- if ( $i == $checks_per_row ) {
784
- echo '</tr>';
785
- $i = 0;
786
- } elseif ( ! $first_row ) {
787
- // Now close a wellformed table
788
- for ( $i; $i < $checks_per_row; $i++ ){
789
- echo '<td>&nbsp;</td>';
790
- }
791
- echo '</tr>';
792
- }
793
- ?>
794
-
795
- <tr class="cme-bulk-select">
796
- <td colspan="<?php echo $checks_per_row;?>">
797
- <span style="float:right">
798
- <input type="checkbox" class="cme-check-all" autocomplete="off" title="<?php _e('check/uncheck all', 'capsman-enhanced');?>">&nbsp;&nbsp;<a class="cme-neg-all" href="#" title="<?php _e('negate all (storing as disabled capabilities)', 'capsman-enhanced');?>">X</a> <a class="cme-switch-all" href="#" title="<?php _e('negate none (add/remove all capabilities normally)', 'capsman-enhanced');?>">X</a>
799
- </span>
800
- </td></tr>
801
-
802
- </table>
803
- </div>
804
-
805
- <?php
806
- $all_capabilities = apply_filters( 'capsman_get_capabilities', array_keys( $this->capabilities ), $this->ID );
807
- $all_capabilities = apply_filters( 'members_get_capabilities', $all_capabilities );
808
-
809
- /*
810
- $publishpress_status_change_caps = array();
811
- foreach( $all_capabilities as $cap_name ) {
812
- if (0 === strpos($cap_name, 'status_change_')) {
813
- $publishpress_status_change_caps []= $cap_name;
814
- }
815
- }
816
- */
817
-
818
- // caps: plugins
819
- $plugin_caps = apply_filters('cme_plugin_capabilities', $plugin_caps);
820
-
821
- foreach($plugin_caps as $plugin => $__plugin_caps) {
822
- $_plugin_caps = array_fill_keys($__plugin_caps, true);
823
-
824
- $id = 'cme-cap-type-tables-' . str_replace( ' ', '-', strtolower($plugin));
825
- $div_display = ($id == $active_tab_id) ? 'block' : 'none';
826
-
827
- echo '<div id="' . $id . '" style="display:' . $div_display . '">';
828
- echo '<table class="widefat fixed striped form-table cme-checklist"><tr>';
829
- echo '<h3 class="cme-cap-section">' . sprintf(__( 'Plugin Capabilities &ndash; %s', 'capsman-enhanced' ), str_replace('_', ' ', $plugin )) . '</h3>';
830
-
831
- $checks_per_row = get_option( 'cme_form-rows', 1 );
832
- $i = 0; $first_row = true;
833
-
834
- foreach( array_keys($_plugin_caps) as $cap_name ) {
835
- if ( isset( $type_caps[$cap_name] ) || isset($core_caps[$cap_name]) || isset($type_metacaps[$cap_name]) ) {
836
- continue;
837
- }
838
-
839
- if ( ! $is_administrator && ! current_user_can($cap_name) )
840
- continue;
841
-
842
- if ( $i == $checks_per_row ) {
843
- echo '</tr><tr>';
844
- $i = 0;
845
- }
846
-
847
- if ( ! isset( $rcaps[$cap_name] ) )
848
- $class = 'cap-no';
849
- else
850
- $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
851
-
852
- if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
853
- $class .= ' cap-metagroup';
854
- $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
855
- } else {
856
- $title_text = $cap_name;
857
- }
858
-
859
- $disabled = '';
860
- $checked = checked(1, ! empty($rcaps[$cap_name]), false );
861
- $title = $title_text;
862
- ?>
863
- <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
864
- <span>
865
- <?php
866
- echo str_replace( '_', ' ', $cap_name );
867
- ?>
868
- </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
869
- <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
870
- <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
871
- <?php endif; ?>
872
- </td>
873
-
874
- <?php
875
- ++$i;
876
- }
877
-
878
- if ( $i == $checks_per_row ) {
879
- echo '</tr>';
880
- $i = 0;
881
- } elseif ( ! $first_row ) {
882
- // Now close a wellformed table
883
- for ( $i; $i < $checks_per_row; $i++ ){
884
- echo '<td>&nbsp;</td>';
885
- }
886
- echo '</tr>';
887
- }
888
- ?>
889
-
890
- <tr class="cme-bulk-select">
891
- <td colspan="<?php echo $checks_per_row;?>">
892
- <span style="float:right">
893
- <input type="checkbox" class="cme-check-all" title="<?php _e('check/uncheck all', 'capsman-enhanced');?>">&nbsp;&nbsp;<a class="cme-neg-all" href="#" autocomplete="off" title="<?php _e('negate all (storing as disabled capabilities)', 'capsman-enhanced');?>">X</a> <a class="cme-switch-all" href="#" title="<?php _e('negate none (add/remove all capabilities normally)', 'capsman-enhanced');?>">X</a>
894
- </span>
895
- </td></tr>
896
-
897
- </table>
898
- </div>
899
- <?php
900
- }
901
-
902
- // caps: invalid
903
- if (array_intersect(array_keys(array_filter($type_metacaps)), $all_capabilities) && array_intersect_key($type_metacaps, array_filter($rcaps))) {
904
- $id = "cme-cap-type-tables-invalid";
905
- $div_display = ($id == $active_tab_id) ? 'block' : 'none';
906
-
907
- echo '<div id="' . $id . '" style="display:' . $div_display . '">';
908
- echo '<h3 class="cme-cap-section">' . __( 'Invalid Capabilities', 'capsman-enhanced' ) . '</h3>';
909
- ?>
910
-
911
- <script type="text/javascript">
912
- /* <![CDATA[ */
913
- jQuery(document).ready( function($) {
914
- $('#cme_tab_invalid_caps').show();
915
- });
916
- /* ]]> */
917
- </script>
918
-
919
- <div>
920
- <span class="cme-subtext">
921
- <?php _e('The following entries have no effect. Please assign desired capabilities in the Read / Edit / Delete grid above.', 'capsman-enhanced');?>
922
- </span>
923
- </div>
924
-
925
- <table class="widefat fixed striped form-table cme-checklist">
926
- <tr>
927
- <?php
928
- $i = 0; $first_row = true;
929
-
930
- foreach( $all_capabilities as $cap_name ) {
931
- if ( ! isset($this->capabilities[$cap_name]) )
932
- $this->capabilities[$cap_name] = str_replace( '_', ' ', $cap_name );
933
- }
934
-
935
- uasort( $this->capabilities, 'strnatcasecmp' ); // sort by array values, but maintain keys );
936
-
937
- foreach ( $this->capabilities as $cap_name => $cap ) :
938
- if (!isset($type_metacaps[$cap_name]) || empty($rcaps[$cap_name])) {
939
- continue;
940
- }
941
-
942
- if ( ! $is_administrator && empty( $current_user->allcaps[$cap_name] ) ) {
943
- continue;
944
- }
945
-
946
- if ( $i == $checks_per_row ) {
947
- echo '</tr><tr>';
948
- $i = 0; $first_row = false;
949
- }
950
-
951
- if ( ! isset( $rcaps[$cap_name] ) )
952
- $class = 'cap-no';
953
- else
954
- $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
955
-
956
- $title_text = $cap_name;
957
-
958
- $disabled = '';
959
- $checked = checked(1, ! empty($rcaps[$cap_name]), false );
960
- ?>
961
- <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title_text;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
962
- <span>
963
- <?php
964
- echo str_replace( '_', ' ', $cap );
965
- ?>
966
- </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
967
- <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
968
- <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
969
- <?php endif; ?>
970
- </td>
971
- <?php
972
- $i++;
973
- endforeach;
974
-
975
- if ( ! empty($lock_manage_caps_capability) ) {
976
- echo '<input type="hidden" name="caps[manage_capabilities]" value="1" />';
977
- }
978
-
979
- if ( $i == $checks_per_row ) {
980
- echo '</tr><tr>';
981
- $i = 0;
982
- } else {
983
- if ( ! $first_row ) {
984
- // Now close a wellformed table
985
- for ( $i; $i < $checks_per_row; $i++ ){
986
- echo '<td>&nbsp;</td>';
987
- }
988
- echo '</tr>';
989
- }
990
- }
991
- ?>
992
-
993
- </table>
994
- </div>
995
- <?php
996
- } // endif any invalid caps
997
-
998
- $id = "cme-cap-type-tables-additional";
999
- $div_display = ($id == $active_tab_id) ? 'block' : 'none';
1000
- ?>
1001
- <div id="<?php echo $id;?>" style="display:<?php echo $div_display;?>">
1002
- <?php
1003
- // caps: additional
1004
- echo '<h3 class="cme-cap-section">' . __( 'Additional Capabilities', 'capsman-enhanced' ) . '</h3>';
1005
-
1006
- ?>
1007
- <table class="widefat fixed striped form-table cme-checklist">
1008
- <tr>
1009
- <?php
1010
- $i = 0; $first_row = true;
1011
-
1012
- foreach( $all_capabilities as $cap_name ) {
1013
- if ( ! isset($this->capabilities[$cap_name]) )
1014
- $this->capabilities[$cap_name] = str_replace( '_', ' ', $cap_name );
1015
- }
1016
-
1017
- uasort( $this->capabilities, 'strnatcasecmp' ); // sort by array values, but maintain keys );
1018
-
1019
- $additional_caps = apply_filters('publishpress_caps_manage_additional_caps', $this->capabilities);
1020
-
1021
- foreach ($additional_caps as $cap_name => $cap) :
1022
-
1023
- if ((isset($type_caps[$cap_name]) && !isset($type_metacaps[$cap_name]))
1024
- || isset($core_caps[$cap_name])
1025
- || (isset($type_metacaps[$cap_name]) && !empty($rcaps[$cap_name])) ) {
1026
- continue;
1027
- }
1028
-
1029
- if (!isset($type_metacaps[$cap_name]) || !empty($rcaps[$cap_name])) {
1030
- foreach(array_keys($plugin_caps) as $plugin) {
1031
- if ( in_array( $cap_name, $plugin_caps[$plugin]) ) {
1032
- continue 2;
1033
- }
1034
- }
1035
- }
1036
-
1037
- if ( ! $is_administrator && empty( $current_user->allcaps[$cap_name] ) ) {
1038
- continue;
1039
- }
1040
-
1041
- // Levels are not shown.
1042
- if ( preg_match( '/^level_(10|[0-9])$/i', $cap_name ) ) {
1043
- continue;
1044
- }
1045
-
1046
- if ( $i == $checks_per_row ) {
1047
- echo '</tr><tr>';
1048
- $i = 0; $first_row = false;
1049
- }
1050
-
1051
- if ( ! isset( $rcaps[$cap_name] ) )
1052
- $class = 'cap-no';
1053
- else
1054
- $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
1055
-
1056
- if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
1057
- $class .= ' cap-metagroup';
1058
- $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
1059
- } else {
1060
- $title_text = $cap_name;
1061
- }
1062
-
1063
- $disabled = '';
1064
- $checked = checked(1, ! empty($rcaps[$cap_name]), false );
1065
-
1066
- if ( 'manage_capabilities' == $cap_name ) {
1067
- if (!current_user_can('administrator') && (!is_multisite() || !is_super_admin())) {
1068
- continue;
1069
- } elseif ( 'administrator' == $default ) {
1070
- $class .= ' cap-locked';
1071
- $lock_manage_caps_capability = true;
1072
- $disabled = 'disabled="disabled"';
1073
- }
1074
- }
1075
- ?>
1076
- <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title_text;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
1077
- <span>
1078
- <?php
1079
- echo str_replace( '_', ' ', $cap );
1080
- ?>
1081
- </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
1082
- <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
1083
- <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
1084
- <?php endif; ?>
1085
- </td>
1086
- <?php
1087
- $i++;
1088
- endforeach;
1089
-
1090
- if ( ! empty($lock_manage_caps_capability) ) {
1091
- echo '<input type="hidden" name="caps[manage_capabilities]" value="1" />';
1092
- }
1093
-
1094
- if ( $i == $checks_per_row ) {
1095
- echo '</tr><tr>';
1096
- $i = 0;
1097
- } else {
1098
- if ( ! $first_row ) {
1099
- // Now close a wellformed table
1100
- for ( $i; $i < $checks_per_row; $i++ ){
1101
- echo '<td>&nbsp;</td>';
1102
- }
1103
- echo '</tr>';
1104
- }
1105
- }
1106
- ?>
1107
-
1108
- <tr class="cme-bulk-select">
1109
- <td colspan="<?php echo $checks_per_row;?>">
1110
- <span style="float:right">
1111
- <input type="checkbox" class="cme-check-all" title="<?php _e('check/uncheck all', 'capsman-enhanced');?>">&nbsp;&nbsp;<a class="cme-neg-all" href="#" autocomplete="off" title="<?php _e('negate all (storing as disabled capabilities)', 'capsman-enhanced');?>">X</a> <a class="cme-switch-all" href="#" title="<?php _e('negate none (add/remove all capabilities normally)', 'capsman-enhanced');?>">X</a>
1112
- </span>
1113
- </td></tr>
1114
-
1115
- </table>
1116
- </div>
1117
- </div>
1118
- </div>
1119
-
1120
-
1121
- <script type="text/javascript">
1122
- /* <![CDATA[ */
1123
- jQuery(document).ready( function($) {
1124
- $('a[href="#pp-more"]').click( function() {
1125
- $('#pp_features').show();
1126
- return false;
1127
- });
1128
- $('a[href="#pp-hide"]').click( function() {
1129
- $('#pp_features').hide();
1130
- return false;
1131
- });
1132
- });
1133
- /* ]]> */
1134
- </script>
1135
-
1136
- <?php /* play.png icon by Pavel: http://kde-look.org/usermanager/search.php?username=InFeRnODeMoN */ ?>
1137
-
1138
- <div id="pp_features" style="display:none"><div class="pp-logo"><a href="https://publishpress.com/presspermit/"><img src="<?php echo $img_url;?>pp-logo.png" alt="<?php _e('PublishPress Permissions', 'capsman-enhanced');?>" /></a></div><div class="features-wrap"><ul class="pp-features">
1139
- <li>
1140
- <?php _e( "Automatically define type-specific capabilities for your custom post types and taxonomies", 'capsman-enhanced' );?>
1141
- <a href="https://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
1142
-
1143
- <li>
1144
- <?php _e( "Assign standard WP roles supplementally for a specific post type", 'capsman-enhanced' );?>
1145
- <a href="https://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
1146
-
1147
- <li>
1148
- <?php _e( "Assign custom WP roles supplementally for a specific post type <em>(Pro)</em>", 'capsman-enhanced' );?>
1149
- </li>
1150
-
1151
- <li>
1152
- <?php _e( "Customize reading permissions per-category or per-post", 'capsman-enhanced' );?>
1153
- <a href="https://presspermit.com/tutorial/category-exceptions" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
1154
-
1155
- <li>
1156
- <?php _e( "Customize editing permissions per-category or per-post <em>(Pro)</em>", 'capsman-enhanced' );?>
1157
- <a href="https://presspermit.com/tutorial/page-editing-exceptions" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
1158
-
1159
- <li>
1160
- <?php _e( "Custom Post Visibility statuses, fully implemented throughout wp-admin <em>(Pro)</em>", 'capsman-enhanced' );?>
1161
- <a href="https://presspermit.com/tutorial/custom-post-visibility" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
1162
-
1163
- <li>
1164
- <?php _e( "Custom Moderation statuses for access-controlled, multi-step publishing workflow <em>(Pro)</em>", 'capsman-enhanced' );?>
1165
- <a href="https://presspermit.com/tutorial/multi-step-moderation" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
1166
-
1167
- <li>
1168
- <?php _e( "Regulate permissions for Edit Flow post statuses <em>(Pro)</em>", 'capsman-enhanced' );?>
1169
- <a href="https://presspermit.com/tutorial/edit-flow-integration" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
1170
-
1171
- <li>
1172
- <?php _e( "Customize the moderated editing of published content with Revisionary or Post Forking <em>(Pro)</em>", 'capsman-enhanced' );?>
1173
- <a href="https://presspermit.com/tutorial/published-content-revision" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
1174
-
1175
- <li>
1176
- <?php _e( "Grant Spectator, Participant or Moderator access to specific bbPress forums <em>(Pro)</em>", 'capsman-enhanced' );?>
1177
- </li>
1178
-
1179
- <li>
1180
- <?php _e( "Grant supplemental content permissions to a BuddyPress group <em>(Pro)</em>", 'capsman-enhanced' );?>
1181
- <a href="https://presspermit.com/tutorial/buddypress-content-permissions" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
1182
-
1183
- <li>
1184
- <?php _e( "WPML integration to mirror permissions to translations <em>(Pro)</em>", 'capsman-enhanced' );?>
1185
- </li>
1186
-
1187
- <li>
1188
- <?php _e( "Member support forum", 'capsman-enhanced' );?>
1189
- </li>
1190
-
1191
- </ul></div>
1192
-
1193
- <?php
1194
- echo '<div>';
1195
- printf( __('%1$sgrab%2$s %3$s', 'capsman-enhanced'), '<strong>', '</strong>', '<span class="plugins update-message"><a href="' . cme_plugin_info_url('press-permit-core') . '" class="thickbox" title="' . sprintf( __('%s (free install)', 'capsman-enhanced'), 'Permissions Pro' ) . '">Permissions Pro</a></span>' );
1196
- echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
1197
- printf( __('%1$sbuy%2$s %3$s', 'capsman-enhanced'), '<strong>', '</strong>', '<a href="https://publishpress.com/presspermit/" target="_blank" title="' . sprintf( __('%s info/purchase', 'capsman-enhanced'), 'Permissions Pro' ) . '">Permissions&nbsp;Pro</a>' );
1198
- echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
1199
- echo '<a href="#pp-hide">hide</a>';
1200
- echo '</div></div>';
1201
-
1202
- ///
1203
- ?>
1204
- <script type="text/javascript">
1205
- /* <![CDATA[ */
1206
- jQuery(document).ready( function($) {
1207
- $('a[href="#toggle_type_caps"]').click( function() {
1208
- var chks = $(this).closest('tr').find('input');
1209
- var set_checked = ! $(chks).first().is(':checked');
1210
-
1211
- $(chks).each(function(i,e) {
1212
- $('input[name="' + $(this).attr('name') + '"]').prop('checked', set_checked);
1213
- });
1214
-
1215
- return false;
1216
- });
1217
-
1218
- $('input[name^="caps["]').click(function() {
1219
- $('input[name="' + $(this).attr('name') + '"]').prop('checked', $(this).prop('checked'));
1220
- });
1221
- });
1222
- /* ]]> */
1223
- </script>
1224
-
1225
- <div style="display:inline-block; float:right;">
1226
- <?php
1227
- $level = ak_caps2level($rcaps);
1228
- ?>
1229
- <span title="<?php _e('Role level is mostly deprecated. However, it still determines eligibility for Post Author assignment and limits the application of user editing capabilities.', 'capsman-enhanced');?>">
1230
-
1231
- <?php (in_array(get_locale(), ['en_EN', 'en_US'])) ? printf('Role Level:') : _e('Level:', 'capsman-enhanced');?> <select name="level">
1232
- <?php for ( $l = $this->max_level; $l >= 0; $l-- ) {?>
1233
- <option value="<?php echo $l; ?>" style="text-align:right;"<?php selected($level, $l); ?>>&nbsp;<?php echo $l; ?>&nbsp;</option>
1234
- <?php }
1235
- ?>
1236
- </select>
1237
- </span>
1238
-
1239
- </div>
1240
-
1241
- <?php
1242
- $support_pp_only_roles = defined('PRESSPERMIT_ACTIVE');
1243
- cme_network_role_ui( $default );
1244
- ?>
1245
-
1246
- <p class="submit" style="padding-top:0;">
1247
- <input type="hidden" name="action" value="update" />
1248
- <input type="hidden" name="current" value="<?php echo $default; ?>" />
1249
- <input type="submit" name="SaveRole" value="<?php echo (in_array(get_locale(), ['en_EN', 'en_US'])) ? 'Save Capabilities' : _e('Save Changes', 'capsman-enhanced');?>" class="button-primary" /> &nbsp;
1250
-
1251
- <?php if ( current_user_can('administrator') && 'administrator' != $default ) : ?>
1252
- <a class="ak-delete" title="<?php echo esc_attr(__('Delete this role', 'capsman-enhanced')) ?>" href="<?php echo wp_nonce_url("admin.php?page={$this->ID}&amp;action=delete&amp;role={$default}", 'delete-role_' . $default); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf(__("You are about to delete the %s role.\n\n 'Cancel' to stop, 'OK' to delete.", 'capsman-enhanced'), $roles[$default])); ?>') ) { return true;}return false;"><?php _e('Delete Role', 'capsman-enhanced')?></a>
1253
- <?php endif; ?>
1254
- </p>
1255
-
1256
- </td>
1257
- <td class="sidebar">
1258
- <?php do_action('publishpress-caps_sidebar_top');?>
1259
-
1260
- <dl>
1261
- <dt><?php _e('Add Capability', 'capsman-enhanced'); ?></dt>
1262
- <dd style="text-align:center;">
1263
- <p><input type="text" name="capability-name" class="regular-text" placeholder="<?php echo 'capability_name';?>" /><br />
1264
- <input type="submit" name="AddCap" value="<?php _e('Add to role', 'capsman-enhanced') ?>" class="button" /></p>
1265
- </dd>
1266
- </dl>
1267
-
1268
- <?php
1269
- $pp_ui->pp_types_ui( $defined['type'] );
1270
- $pp_ui->pp_taxonomies_ui( $defined['taxonomy'] );
1271
-
1272
- do_action('publishpress-caps_sidebar_bottom');
1273
- ?>
1274
-
1275
- <dl>
1276
- <dt><?php (!in_array(get_locale(), ['en_EN', 'en_US'])) ? _e('Copy this role to', 'capsman-enhanced') : printf('Copy %s Role', translate_user_role($roles[$default])); ?></dt>
1277
- <dd style="text-align:center;">
1278
- <?php $class = ( $support_pp_only_roles ) ? 'tight-text' : 'regular-text'; ?>
1279
- <p><input type="text" name="copy-name" class="<?php echo $class;?>" placeholder="<?php _e('Role Name', 'capsman-enhanced') ?>" />
1280
-
1281
- <?php if( $support_pp_only_roles ) : ?>
1282
- <label for="copy_role_pp_only" title="<?php _e('Make role available for supplemental assignment to Permission Groups only', 'capsman-enhanced');?>"> <input type="checkbox" name="copy_role_pp_only" id="copy_role_pp_only" autocomplete="off" value="1"> <?php _e('hidden', 'capsman-enhanced'); ?> </label>
1283
- <?php endif; ?>
1284
-
1285
- <br />
1286
- <input type="submit" name="CopyRole" value="<?php _e('Copy', 'capsman-enhanced') ?>" class="button" />
1287
- </p>
1288
- </dd>
1289
- </dl>
1290
-
1291
- <dl>
1292
- <dt><?php _e('Rename Role', 'capsman-enhanced'); ?></dt>
1293
- <dd style="text-align:center;">
1294
- <p><input type="text" name="rename-name" class="regular-text" placeholder="<?php _e('New Role Name', 'capsman-enhanced') ?>" />
1295
-
1296
- <br />
1297
- <input type="submit" name="RenameRole" value="<?php _e('Rename', 'capsman-enhanced') ?>" class="button" />
1298
- </p>
1299
- </dd>
1300
- </dl>
1301
- </td>
1302
- </tr>
1303
- </table>
1304
- </fieldset>
1305
- </form>
1306
-
1307
- <?php if (!defined('PUBLISHPRESS_CAPS_PRO_VERSION') || get_option('cme_display_branding')) {
1308
- cme_publishpressFooter();
1309
- }
1310
- ?>
1311
- </div>
1312
-
1313
- <?php
1314
- function cme_network_role_ui( $default ) {
1315
- if (!is_multisite() || !is_super_admin() || !is_main_site()) {
1316
- return false;
1317
- }
1318
- ?>
1319
-
1320
- <div style="float:right;margin-left:10px;margin-right:10px">
1321
- <?php
1322
- if ( ! $autocreate_roles = get_site_option( 'cme_autocreate_roles' ) )
1323
- $autocreate_roles = array();
1324
- ?>
1325
- <div style="margin-bottom: 5px">
1326
- <label for="cme_autocreate_role" title="<?php _e('Create this role definition in new (future) sites', 'capsman-enhanced');?>"><input type="checkbox" name="cme_autocreate_role" id="cme_autocreate_role" autocomplete="off" value="1" <?php echo checked(in_array($default, $autocreate_roles));?>> <?php _e('include in new sites', 'capsman-enhanced'); ?> </label>
1327
- </div>
1328
- <div>
1329
- <label for="cme_net_sync_role" title="<?php echo esc_attr(__('Copy / update this role definition to all sites now', 'capsman-enhanced'));?>"><input type="checkbox" name="cme_net_sync_role" id="cme_net_sync_role" autocomplete="off" value="1"> <?php _e('sync role to all sites now', 'capsman-enhanced'); ?> </label>
1330
- </div>
1331
- <div>
1332
- <label for="cme_net_sync_options" title="<?php echo esc_attr(__('Copy option settings to all sites now', 'capsman-enhanced'));?>"><input type="checkbox" name="cme_net_sync_options" id="cme_net_sync_options" autocomplete="off" value="1"> <?php _e('sync options to all sites now', 'capsman-enhanced'); ?> </label>
1333
- </div>
1334
- </div>
1335
- <?php
1336
- return true;
1337
- }
1338
-
1339
- function cme_plugin_info_url( $plugin_slug ) {
1340
- $_url = "plugin-install.php?tab=plugin-information&plugin=$plugin_slug&TB_iframe=true&width=640&height=678";
1341
- return ( is_multisite() ) ? network_admin_url($_url) : admin_url($_url);
1342
- }
1
+ <?php
2
+ /**
3
+ * PublishPress Capabilities [Free]
4
+ *
5
+ * UI output for Capabilities screen.
6
+ *
7
+ * Provides admin pages to create and manage roles and capabilities.
8
+ *
9
+ * @author Jordi Canals, Kevin Behrens
10
+ * @copyright Copyright (C) 2009, 2010 Jordi Canals, (C) 2020 PublishPress
11
+ * @license GNU General Public License version 2
12
+ * @link https://publishpress.com
13
+ *
14
+ * Copyright 2009, 2010 Jordi Canals <devel@jcanals.cat>
15
+ * Modifications Copyright 2020, PublishPress <help@publishpress.com>
16
+ *
17
+ * This program is free software; you can redistribute it and/or
18
+ * modify it under the terms of the GNU General Public License
19
+ * version 2 as published by the Free Software Foundation.
20
+ *
21
+ * This program is distributed in the hope that it will be useful,
22
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ * GNU General Public License for more details.
25
+ *
26
+ * You should have received a copy of the GNU General Public License
27
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
28
+ **/
29
+
30
+ global $capsman, $cme_cap_helper, $current_user;
31
+
32
+ do_action('publishpress-caps_manager-load');
33
+
34
+ $roles = $this->roles;
35
+ $default = $this->current;
36
+
37
+ if ( $block_read_removal = _cme_is_read_removal_blocked( $this->current ) ) {
38
+ if ( $current = get_role($default) ) {
39
+ if ( empty( $current->capabilities['read'] ) ) {
40
+ ak_admin_error( sprintf( __( 'Warning: This role cannot access the dashboard without the read capability. %1$sClick here to fix this now%2$s.', 'capsman-enhanced' ), '<a href="javascript:void(0)" class="cme-fix-read-cap">', '</a>' ) );
41
+ }
42
+ }
43
+ }
44
+
45
+ require_once (dirname(CME_FILE) . '/includes/roles/roles-functions.php');
46
+
47
+ require_once( dirname(__FILE__).'/pp-ui.php' );
48
+ $pp_ui = new Capsman_PP_UI();
49
+
50
+ if( defined('PRESSPERMIT_ACTIVE') ) {
51
+ $pp_metagroup_caps = $pp_ui->get_metagroup_caps( $default );
52
+ } else {
53
+ $pp_metagroup_caps = array();
54
+ }
55
+ ?>
56
+ <div class="wrap publishpress-caps-manage pressshack-admin-wrapper">
57
+ <?php /*if( defined('PRESSPERMIT_ACTIVE') ) :
58
+ pp_icon();
59
+ $style = 'style="height:60px;"';
60
+ */
61
+ ?>
62
+ <?php /* else: */
63
+ $style = '';
64
+ ?>
65
+ <div id="icon-capsman-admin" class="icon32"></div>
66
+ <?php /* endif; */ ?>
67
+
68
+ <h1 <?php echo $style;?>><?php _e('Role Capabilities', 'capsman-enhanced') ?></h1>
69
+
70
+ <?php
71
+ echo pp_capabilities_roles()->notify->display();
72
+ ?>
73
+
74
+ <script type="text/javascript">
75
+ /* <![CDATA[ */
76
+ jQuery(document).ready( function($) {
77
+ $('#publishpress_caps_form').attr('action', 'admin.php?page=pp-capabilities&role=' + $('select[name="role"]').val());
78
+
79
+ $('select[name="role"]').change(function(){
80
+ window.location = '<?php echo admin_url('admin.php?page=pp-capabilities&role='); ?>' + $(this).val() + '';
81
+ });
82
+ });
83
+ /* ]]> */
84
+ </script>
85
+
86
+ <form id="publishpress_caps_form" method="post" action="admin.php?page=<?php echo $this->ID ?>">
87
+ <?php wp_nonce_field('capsman-general-manager'); ?>
88
+
89
+ <p>
90
+ <select name="role">
91
+ <?php
92
+ foreach ( $roles as $role => $name ) {
93
+ if (pp_capabilities_is_editable_role($role)) {
94
+ $name = translate_user_role($name);
95
+ echo '<option value="' . $role .'"'; selected($default, $role); echo '> ' . $name . ' &nbsp;</option>';
96
+ }
97
+ }
98
+ ?>
99
+ </select>
100
+ </p>
101
+
102
+ <fieldset>
103
+ <table id="akmin">
104
+ <tr>
105
+ <td class="content">
106
+ <dl>
107
+ <dd>
108
+ <div style="float:right">
109
+ <input type="submit" name="SaveRole" value="<?php echo (in_array(get_locale(), ['en_EN', 'en_US'])) ? 'Save Capabilities' : _e('Save Changes', 'capsman-enhanced'); ?>" class="button-primary" /> &nbsp;
110
+ </div>
111
+
112
+ <?php
113
+ global $capsman;
114
+ $img_url = $capsman->mod_url . '/images/';
115
+ ?>
116
+ <div class="publishpress-headline">
117
+ <span class="cme-subtext">
118
+ <?php
119
+ $msg = __( '<strong>Note:</strong> Capability changes <strong>remain in the database</strong> after plugin deactivation.', 'capsman-enhanced' );
120
+
121
+ if (defined('PRESSPERMIT_ACTIVE') && function_exists('presspermit')) {
122
+ if ($group = presspermit()->groups()->getMetagroup('wp_role', $this->current)) {
123
+ $msg = sprintf(
124
+ __('<strong>Note:</strong> Capability changes <strong>remain in the database</strong> after plugin deactivation. You can also configure this role as a %sPermission Group%s.', 'capsman-enhanced'),
125
+ '<a href="' . admin_url("admin.php?page=presspermit-edit-permissions&action=edit&agent_id={$group->ID}") . '">',
126
+ '</a>'
127
+ );
128
+ }
129
+ }
130
+ echo $msg;
131
+ ?>
132
+ </span>
133
+ </div>
134
+
135
+ <?php
136
+ if ( defined( 'PRESSPERMIT_ACTIVE' ) ) {
137
+ $pp_ui->show_capability_hints( $default );
138
+ }
139
+ ?>
140
+
141
+ <script type="text/javascript">
142
+ /* <![CDATA[ */
143
+ jQuery(document).ready( function($) {
144
+ $('a[href="#pp-more"]').click( function() {
145
+ $('#pp_features').show();
146
+ return false;
147
+ });
148
+ $('a[href="#pp-hide"]').click( function() {
149
+ $('#pp_features').hide();
150
+ return false;
151
+ });
152
+ });
153
+ /* ]]> */
154
+ </script>
155
+
156
+ <?php /* play.png icon by Pavel: http://kde-look.org/usermanager/search.php?username=InFeRnODeMoN */ ?>
157
+
158
+ <br /><div id="pp_features" style="display:none"><div class="pp-logo"><a href="https://publishpress.com/presspermit/"><img src="<?php echo $img_url;?>pp-logo.png" alt="<?php _e('PublishPress Permissions', 'capsman-enhanced');?>" /></a></div><div class="features-wrap"><ul class="pp-features">
159
+ <li>
160
+ <?php _e( "Automatically define type-specific capabilities for your custom post types and taxonomies", 'capsman-enhanced' );?>
161
+ <a href="https://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
162
+
163
+ <li>
164
+ <?php _e( "Assign standard WP roles supplementally for a specific post type", 'capsman-enhanced' );?>
165
+ <a href="https://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
166
+
167
+ <li>
168
+ <?php _e( "Assign custom WP roles supplementally for a specific post type <em>(Pro)</em>", 'capsman-enhanced' );?>
169
+ </li>
170
+
171
+ <li>
172
+ <?php _e( "Customize reading permissions per-category or per-post", 'capsman-enhanced' );?>
173
+ <a href="https://presspermit.com/tutorial/category-exceptions" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
174
+
175
+ <li>
176
+ <?php _e( "Customize editing permissions per-category or per-post <em>(Pro)</em>", 'capsman-enhanced' );?>
177
+ <a href="https://presspermit.com/tutorial/page-editing-exceptions" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
178
+
179
+ <li>
180
+ <?php _e( "Custom Post Visibility statuses, fully implemented throughout wp-admin <em>(Pro)</em>", 'capsman-enhanced' );?>
181
+ <a href="https://presspermit.com/tutorial/custom-post-visibility" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
182
+
183
+ <li>
184
+ <?php _e( "Custom Moderation statuses for access-controlled, multi-step publishing workflow <em>(Pro)</em>", 'capsman-enhanced' );?>
185
+ <a href="https://presspermit.com/tutorial/multi-step-moderation" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
186
+
187
+ <li>
188
+ <?php _e( "Regulate permissions for Edit Flow post statuses <em>(Pro)</em>", 'capsman-enhanced' );?>
189
+ <a href="https://presspermit.com/tutorial/edit-flow-integration" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
190
+
191
+ <li>
192
+ <?php _e( "Customize the moderated editing of published content with Revisionary or Post Forking <em>(Pro)</em>", 'capsman-enhanced' );?>
193
+ <a href="https://presspermit.com/tutorial/published-content-revision" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
194
+
195
+ <li>
196
+ <?php _e( "Grant Spectator, Participant or Moderator access to specific bbPress forums <em>(Pro)</em>", 'capsman-enhanced' );?>
197
+ </li>
198
+
199
+ <li>
200
+ <?php _e( "Grant supplemental content permissions to a BuddyPress group <em>(Pro)</em>", 'capsman-enhanced' );?>
201
+ <a href="https://presspermit.com/tutorial/buddypress-content-permissions" target="_blank"><img class="cme-play" alt="*" src="<?php echo $img_url;?>play.png" /></a></li>
202
+
203
+ <li>
204
+ <?php _e( "WPML integration to mirror permissions to translations <em>(Pro)</em>", 'capsman-enhanced' );?>
205
+ </li>
206
+
207
+ <li>
208
+ <?php _e( "Member support forum", 'capsman-enhanced' );?>
209
+ </li>
210
+
211
+ </ul></div>
212
+
213
+ <?php
214
+ echo '<div>';
215
+ printf( __('%1$sgrab%2$s %3$s', 'capsman-enhanced'), '<strong>', '</strong>', '<span class="plugins update-message"><a href="' . cme_plugin_info_url('press-permit-core') . '" class="thickbox" title="' . sprintf( __('%s (free install)', 'capsman-enhanced'), 'Permissions Pro' ) . '">Permissions Pro</a></span>' );
216
+ echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
217
+ printf( __('%1$sbuy%2$s %3$s', 'capsman-enhanced'), '<strong>', '</strong>', '<a href="https://publishpress.com/presspermit/" target="_blank" title="' . sprintf( __('%s info/purchase', 'capsman-enhanced'), 'Permissions Pro' ) . '">Permissions&nbsp;Pro</a>' );
218
+ echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
219
+ echo '<a href="#pp-hide">hide</a>';
220
+ echo '</div></div>';
221
+
222
+ if ( MULTISITE ) {
223
+ global $wp_roles;
224
+ global $wpdb;
225
+
226
+ if ( ! empty($_REQUEST['cme_net_sync_role'] ) ) {
227
+ $main_site_id = (function_exists('get_main_site_id')) ? get_main_site_id() : 1;
228
+ switch_to_blog($main_site_id);
229
+ wp_cache_delete( $wpdb->prefix . 'user_roles', 'options' );
230
+ }
231
+
232
+ ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
233
+ }
234
+ $capsman->reinstate_db_roles();
235
+
236
+ $current = get_role($default);
237
+
238
+ $rcaps = $current->capabilities;
239
+
240
+ $is_administrator = current_user_can( 'administrator' ) || (is_multisite() && is_super_admin());
241
+
242
+ $custom_types = get_post_types( array( '_builtin' => false ), 'names' );
243
+ $custom_tax = get_taxonomies( array( '_builtin' => false ), 'names' );
244
+
245
+ $defined = [];
246
+ $defined['type'] = apply_filters('cme_filterable_post_types', get_post_types(['public' => true, 'show_ui' => true], 'object', 'or'));
247
+ $defined['taxonomy'] = apply_filters('cme_filterable_taxonomies', get_taxonomies(['public' => true, 'show_ui' => true], 'object', 'or'));
248
+
249
+ // bbPress' dynamic role def requires additional code to enforce stored caps
250
+ $unfiltered['type'] = apply_filters('presspermit_unfiltered_post_types', ['forum','topic','reply','wp_block']);
251
+ $unfiltered['type'] = (defined('PP_CAPABILITIES_NO_LEGACY_FILTERS')) ? $unfiltered['type'] : apply_filters('pp_unfiltered_post_types', $unfiltered['type']);
252
+
253
+ $unfiltered['taxonomy'] = apply_filters('presspermit_unfiltered_post_types', ['post_status', 'topic-tag']); // avoid confusion with Edit Flow administrative taxonomy
254
+ $unfiltered['taxonomy'] = (defined('PP_CAPABILITIES_NO_LEGACY_FILTERS')) ? $unfiltered['taxonomy'] : apply_filters('pp_unfiltered_taxonomies', $unfiltered['taxonomy']);
255
+
256
+ $enabled_taxonomies = cme_get_assisted_taxonomies();
257
+
258
+ /*
259
+ if ( ( count($custom_types) || count($custom_tax) ) && ( $is_administrator || current_user_can( 'manage_pp_settings' ) ) ) {
260
+ $cap_properties[''] = array();
261
+ $force_distinct_ui = true;
262
+ }
263
+ */
264
+
265
+ $cap_properties['edit']['type'] = array( 'edit_posts' );
266
+
267
+ foreach( $defined['type'] as $type_obj ) {
268
+ if ( 'attachment' != $type_obj->name ) {
269
+ if ( isset( $type_obj->cap->create_posts ) && ( $type_obj->cap->create_posts != $type_obj->cap->edit_posts ) ) {
270
+ $cap_properties['edit']['type'][]= 'create_posts';
271
+ break;
272
+ }
273
+ }
274
+ }
275
+
276
+ $cap_properties['edit']['type'][]= 'edit_others_posts';
277
+ $cap_properties['edit']['type'] = array_merge( $cap_properties['edit']['type'], array( 'publish_posts', 'edit_published_posts', 'edit_private_posts' ) );
278
+
279
+ $cap_properties['edit']['taxonomy'] = array( 'manage_terms' );
280
+
281
+ if ( ! defined( 'OLD_PRESSPERMIT_ACTIVE' ) )
282
+ $cap_properties['edit']['taxonomy'] = array_merge( $cap_properties['edit']['taxonomy'], array( 'edit_terms', 'assign_terms' ) );
283
+
284
+ $cap_properties['delete']['type'] = array( 'delete_posts', 'delete_others_posts' );
285
+ $cap_properties['delete']['type'] = array_merge( $cap_properties['delete']['type'], array( 'delete_published_posts', 'delete_private_posts' ) );
286
+
287
+ if ( ! defined( 'OLD_PRESSPERMIT_ACTIVE' ) )
288
+ $cap_properties['delete']['taxonomy'] = array( 'delete_terms' );
289
+ else
290
+ $cap_properties['delete']['taxonomy'] = array();
291
+
292
+ $cap_properties['read']['type'] = array( 'read_private_posts' );
293
+ $cap_properties['read']['taxonomy'] = array();
294
+
295
+ $stati = get_post_stati( array( 'internal' => false ) );
296
+
297
+ $cap_type_names = array(
298
+ '' => __( '&nbsp;', 'capsman-enhanced' ),
299
+ 'read' => __( 'Reading', 'capsman-enhanced' ),
300
+ 'edit' => __( 'Editing Capabilities', 'capsman-enhanced' ),
301
+ 'delete' => __( 'Deletion Capabilities', 'capsman-enhanced' )
302
+ );
303
+
304
+ $cap_tips = array(
305
+ 'read_private' => __( 'can read posts which are currently published with private visibility', 'capsman-enhanced' ),
306
+ 'edit' => __( 'has basic editing capability (but may need other capabilities based on post status and ownership)', 'capsman-enhanced' ),
307
+ 'edit_others' => __( 'can edit posts which were created by other users', 'capsman-enhanced' ),
308
+ 'edit_published' => __( 'can edit posts which are currently published', 'capsman-enhanced' ),
309
+ 'edit_private' => __( 'can edit posts which are currently published with private visibility', 'capsman-enhanced' ),
310
+ 'publish' => __( 'can make a post publicly visible', 'capsman-enhanced' ),
311
+ 'delete' => __( 'has basic deletion capability (but may need other capabilities based on post status and ownership)', 'capsman-enhanced' ),
312
+ 'delete_others' => __( 'can delete posts which were created by other users', 'capsman-enhanced' ),
313
+ 'delete_published' => __( 'can delete posts which are currently published', 'capsman-enhanced' ),
314
+ 'delete_private' => __( 'can delete posts which are currently published with private visibility', 'capsman-enhanced' ),
315
+ );
316
+
317
+ $default_caps = array( 'read_private_posts', 'edit_posts', 'edit_others_posts', 'edit_published_posts', 'edit_private_posts', 'publish_posts', 'delete_posts', 'delete_others_posts', 'delete_published_posts', 'delete_private_posts',
318
+ 'read_private_pages', 'edit_pages', 'edit_others_pages', 'edit_published_pages', 'edit_private_pages', 'publish_pages', 'delete_pages', 'delete_others_pages', 'delete_published_pages', 'delete_private_pages',
319
+ 'manage_categories'
320
+ );
321
+ $type_caps = array();
322
+ $type_metacaps = array();
323
+
324
+ // Role Scoper and PP1 adjust attachment access based only on user's capabilities for the parent post
325
+ if ( defined('OLD_PRESSPERMIT_ACTIVE') ) {
326
+ unset( $defined['type']['attachment'] );
327
+ }
328
+
329
+ echo '<ul class="cme-listhoriz">';
330
+
331
+ // cap_types: read, edit, deletion
332
+ foreach( array_keys($cap_properties) as $cap_type ) {
333
+ echo '<li>';
334
+ echo '<h3>' . $cap_type_names[$cap_type] . '</h3>';
335
+
336
+ echo "<div class='cme-cap-type-tables cme-cap-type-tables-$cap_type'>";
337
+
338
+ foreach( array_keys($defined) as $item_type ) {
339
+ if ( ( 'delete' == $cap_type ) && ( 'taxonomy' == $item_type ) ) {
340
+ if ( defined('OLD_PRESSPERMIT_ACTIVE') ) {
341
+ continue;
342
+ }
343
+
344
+ $any_term_deletion_caps = false;
345
+ foreach( array_keys($defined['taxonomy']) as $_tax ) {
346
+ if ( isset( $defined['taxonomy'][$_tax]->cap->delete_terms ) && ( 'manage_categories' != $defined['taxonomy'][$_tax]->cap->delete_terms ) && ! in_array( $_tax, $unfiltered['taxonomy'] ) ) {
347
+ $any_term_deletion_caps = true;
348
+ break;
349
+ }
350
+ }
351
+
352
+ if ( ! $any_term_deletion_caps )
353
+ continue;
354
+ }
355
+
356
+ if ( ! count( $cap_properties[$cap_type][$item_type] ) )
357
+ continue;
358
+
359
+ echo "<table class='cme-typecaps cme-typecaps-$cap_type'>";
360
+
361
+ echo '<tr><th></th>';
362
+
363
+ // label cap properties
364
+ foreach( $cap_properties[$cap_type][$item_type] as $prop ) {
365
+ $prop = str_replace( '_posts', '', $prop );
366
+ $prop = str_replace( '_pages', '', $prop );
367
+ $prop = str_replace( '_terms', '', $prop );
368
+ $tip = ( isset( $cap_tips[$prop] ) ) ? "title='{$cap_tips[$prop]}'" : '';
369
+ $prop = str_replace( '_', '<br />', $prop );
370
+ $th_class = ( 'taxonomy' == $item_type ) ? ' class="term-cap"' : ' class="post-cap"';
371
+ echo "<th $tip{$th_class}>";
372
+
373
+ if ( ( 'delete' != $prop ) || ( 'taxonomy' != $item_type ) || cme_get_detailed_taxonomies() ) {
374
+ echo ucwords($prop);
375
+ }
376
+
377
+ echo '</th>';
378
+ }
379
+
380
+ echo '</tr>';
381
+
382
+ foreach( $defined[$item_type] as $key => $type_obj ) {
383
+ if ( in_array( $key, $unfiltered[$item_type] ) )
384
+ continue;
385
+
386
+ $row = "<tr class='cme_type_{$key}'>";
387
+
388
+ if ( $cap_type ) {
389
+ if ( empty($force_distinct_ui) && empty( $cap_properties[$cap_type][$item_type] ) )
390
+ continue;
391
+
392
+ $type_label = (defined('CME_LEGACY_MENU_NAME_LABEL') && !empty($type_obj->labels->menu_name)) ? $type_obj->labels->menu_name : $type_obj->labels->name;
393
+
394
+ $row .= "<td><a class='cap_type' href='#toggle_type_caps'>" . $type_label . '</a>';
395
+ $row .= '<a href="#" class="neg-type-caps">&nbsp;x&nbsp;</a>';
396
+ $row .= '</td>';
397
+
398
+ $display_row = ! empty($force_distinct_ui);
399
+
400
+ foreach( $cap_properties[$cap_type][$item_type] as $prop ) {
401
+ $td_classes = array();
402
+ $checkbox = '';
403
+ $title = '';
404
+
405
+ if ( ! empty($type_obj->cap->$prop) && ( in_array( $type_obj->name, array( 'post', 'page' ) )
406
+ || ! in_array( $type_obj->cap->$prop, $default_caps )
407
+ || ( ( 'manage_categories' == $type_obj->cap->$prop ) && ( 'manage_terms' == $prop ) && ( 'category' == $type_obj->name ) ) ) ) {
408
+
409
+ // if edit_published or edit_private cap is same as edit_posts cap, don't display a checkbox for it
410
+ if ( ( ! in_array( $prop, array( 'edit_published_posts', 'edit_private_posts', 'create_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->edit_posts ) )
411
+ && ( ! in_array( $prop, array( 'delete_published_posts', 'delete_private_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->delete_posts ) )
412
+ && ( ! in_array( $prop, array( 'edit_terms', 'delete_terms' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->manage_terms ) )
413
+
414
+ && ( ! in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) )
415
+ || empty($cme_cap_helper->all_taxonomy_caps[$type_obj->cap->$prop])
416
+ || ( $cme_cap_helper->all_taxonomy_caps[ $type_obj->cap->$prop ] <= 1 )
417
+ || $type_obj->cap->$prop == str_replace( '_terms', "_{$type_obj->name}s", $prop )
418
+ || $type_obj->cap->$prop == str_replace( '_terms', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
419
+ )
420
+
421
+ && ( in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) )
422
+ || empty($cme_cap_helper->all_type_caps[$type_obj->cap->$prop])
423
+ || ( $cme_cap_helper->all_type_caps[ $type_obj->cap->$prop ] <= 1 )
424
+ || $type_obj->cap->$prop == 'upload_files' && 'create_posts' == $prop && 'attachment' == $type_obj->name
425
+ || $type_obj->cap->$prop == str_replace( '_posts', "_{$type_obj->name}s", $prop )
426
+ || $type_obj->cap->$prop == str_replace( '_pages', "_{$type_obj->name}s", $prop )
427
+ || $type_obj->cap->$prop == str_replace( '_posts', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
428
+ || $type_obj->cap->$prop == str_replace( '_pages', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
429
+ )
430
+ ) {
431
+ // only present these term caps up top if we are ensuring that they get enforced separately from manage_terms
432
+ if ( in_array( $prop, array( 'edit_terms', 'delete_terms', 'assign_terms' ) ) && ( ! in_array( $type_obj->name, cme_get_detailed_taxonomies() ) || defined( 'OLD_PRESSPERMIT_ACTIVE' ) ) ) {
433
+ continue;
434
+ }
435
+
436
+ $cap_name = $type_obj->cap->$prop;
437
+
438
+ if ( 'taxonomy' == $item_type )
439
+ $td_classes []= "term-cap";
440
+ else
441
+ $td_classes []= "post-cap";
442
+
443
+ if ( ! empty($pp_metagroup_caps[$cap_name]) )
444
+ $td_classes []='cm-has-via-pp';
445
+
446
+ if ( $is_administrator || current_user_can($cap_name) ) {
447
+ if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
448
+ $title = ' title="' . sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name ) . '"';
449
+ } else {
450
+ $title = ' title="' . $cap_name . '"';
451
+ }
452
+
453
+ $disabled = '';
454
+ $checked = checked(1, ! empty($rcaps[$cap_name]), false );
455
+
456
+ $checkbox = '<input type="checkbox"' . $title . ' name="caps[' . $cap_name . ']" autocomplete="off" value="1" ' . $checked . $disabled . ' />';
457
+
458
+ $type_caps [$cap_name] = true;
459
+ $display_row = true;
460
+ }
461
+ } else {
462
+ //$td_classes []= "cap-unreg";
463
+ $title = 'title="' . sprintf( __( 'shared capability: %s', 'capsman-enhanced' ), esc_attr( $type_obj->cap->$prop ) ) . '"';
464
+ }
465
+
466
+ if ( isset($rcaps[$cap_name]) && empty($rcaps[$cap_name]) ) {
467
+ $td_classes []= "cap-neg";
468
+ }
469
+ } else {
470
+ $td_classes []= "cap-unreg";
471
+ }
472
+
473
+ $td_class = ( $td_classes ) ? 'class="' . implode(' ', $td_classes) . '"' : '';
474
+
475
+ $row .= "<td $td_class $title><span class='cap-x'>X</span>$checkbox";
476
+
477
+ if ( false !== strpos( $td_class, 'cap-neg' ) )
478
+ $row .= '<input type="hidden" class="cme-negation-input" name="caps[' . $cap_name . ']" value="" />';
479
+
480
+ $row .= "</td>";
481
+ }
482
+
483
+ if (!empty($type_obj->map_meta_cap) && !defined('PP_CAPABILITIES_NO_INVALID_SECTION')) {
484
+ if ('type' == $item_type) {
485
+ $type_metacaps[$type_obj->cap->read_post] = true;
486
+ $type_metacaps[$type_obj->cap->edit_post] = isset($type_obj->cap->edit_posts) && ($type_obj->cap->edit_post != $type_obj->cap->edit_posts);
487
+ $type_metacaps[$type_obj->cap->delete_post] = isset($type_obj->cap->delete_posts) && ($type_obj->cap->delete_post != $type_obj->cap->delete_posts);
488
+
489
+ } elseif ('taxonomy' == $item_type && !empty($type_obj->cap->edit_term) && !empty($type_obj->cap->delete_term)) {
490
+ $type_metacaps[$type_obj->cap->edit_term] = true;
491
+ $type_metacaps[$type_obj->cap->delete_term] = true;
492
+ }
493
+ }
494
+ }
495
+
496
+ if ( $display_row ) {
497
+ $row .= '</tr>';
498
+ echo $row;
499
+ }
500
+ }
501
+
502
+ echo '</table>';
503
+
504
+ } // end foreach item type
505
+
506
+ echo '</div>';
507
+
508
+ echo '</li>';
509
+ }
510
+
511
+
512
+ do_action('publishpress-caps_manager_postcaps_section', compact('current', 'rcaps', 'pp_metagroup_caps', 'is_administrator', 'default_caps', 'custom_types', 'defined', 'unfiltered', 'pp_metagroup_caps'));
513
+
514
+ $type_caps = apply_filters('publishpress_caps_manager_typecaps', $type_caps);
515
+
516
+ echo '</ul>';
517
+
518
+ // clicking on post type name toggles corresponding checkbox selections
519
+ ?>
520
+ <script type="text/javascript">
521
+ /* <![CDATA[ */
522
+ jQuery(document).ready( function($) {
523
+ $('a[href="#toggle_type_caps"]').click( function() {
524
+ var chks = $(this).closest('tr').find('input');
525
+ var set_checked = ! $(chks).first().is(':checked');
526
+
527
+ $(chks).each(function(i,e) {
528
+ $('input[name="' + $(this).attr('name') + '"]').prop('checked', set_checked);
529
+ });
530
+
531
+ return false;
532
+ });
533
+
534
+ $('input[name^="caps["]').click(function() {
535
+ $('input[name="' + $(this).attr('name') + '"]').prop('checked', $(this).prop('checked'));
536
+ });
537
+ });
538
+ /* ]]> */
539
+ </script>
540
+ <?php
541
+
542
+ echo '<p>&nbsp;</p><h3>' . __( 'Other WordPress Core Capabilities', 'capsman-enhanced' ) . '</h3>';
543
+ echo '<table class="form-table cme-checklist"><tr>';
544
+
545
+ $checks_per_row = get_option( 'cme_form-rows', 5 );
546
+ $i = 0; $first_row = true;
547
+
548
+ $core_caps = _cme_core_caps();
549
+ foreach( array_keys($core_caps) as $cap_name ) {
550
+ if ( ! $is_administrator && ! current_user_can($cap_name) )
551
+ continue;
552
+
553
+ if ( $i == $checks_per_row ) {
554
+ echo '</tr><tr>';
555
+ $i = 0;
556
+ }
557
+
558
+ if ( ! isset( $rcaps[$cap_name] ) )
559
+ $class = 'cap-no';
560
+ else
561
+ $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
562
+
563
+ if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
564
+ $class .= ' cap-metagroup';
565
+ $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
566
+ } else {
567
+ $title_text = $cap_name;
568
+ }
569
+
570
+ $disabled = '';
571
+ $checked = checked(1, ! empty($rcaps[$cap_name]), false );
572
+ $lock_capability = false;
573
+ $title = $title_text;
574
+
575
+ if ( 'read' == $cap_name ) {
576
+ if ( ! empty( $block_read_removal ) ) {
577
+ // prevent the read capability from being removed from a core role, but don't force it to be added
578
+ if ( $checked || apply_filters( 'pp_caps_force_capability_storage', false, 'read', $default ) ) {
579
+ if ( apply_filters( 'pp_caps_lock_capability', true, 'read', $default ) ) {
580
+ $lock_capability = true;
581
+ $class .= ' cap-locked';
582
+ $disabled = 'disabled="disabled"';
583
+ if ( 'administrator' != $this->current ) {
584
+ $title = esc_attr( __('Lockout Prevention: To remove read capability, first remove WordPress admin / editing capabilities, or add "dashboard_lockout_ok" capability', 'capsman-enhanced' ) );
585
+ }
586
+ }
587
+ }
588
+ }
589
+ }
590
+
591
+ ?>
592
+ <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
593
+ <span>
594
+ <?php
595
+ echo str_replace( '_', ' ', $cap_name );
596
+ ?>
597
+ </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
598
+ <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
599
+ <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
600
+ <?php endif; ?>
601
+ </td>
602
+
603
+ <?php
604
+
605
+ if ( $lock_capability ) {
606
+ echo '<input type="hidden" name="caps[' . $cap_name . ']" value="1" />';
607
+ }
608
+
609
+ ++$i;
610
+ }
611
+
612
+ if ( $i == $checks_per_row ) {
613
+ echo '</tr>';
614
+ $i = 0;
615
+ } elseif ( ! $first_row ) {
616
+ // Now close a wellformed table
617
+ for ( $i; $i < $checks_per_row; $i++ ){
618
+ echo '<td>&nbsp;</td>';
619
+ }
620
+ echo '</tr>';
621
+ }
622
+ ?>
623
+
624
+ <tr class="cme-bulk-select">
625
+ <td colspan="<?php echo $checks_per_row;?>">
626
+ <span style="float:right">
627
+ <input type="checkbox" class="cme-check-all" autocomplete="off" title="<?php _e('check/uncheck all', 'capsman-enhanced');?>">&nbsp;&nbsp;<a class="cme-neg-all" href="#" title="<?php _e('negate all (storing as disabled capabilities)', 'capsman-enhanced');?>">X</a> <a class="cme-switch-all" href="#" title="<?php _e('negate none (add/remove all capabilities normally)', 'capsman-enhanced');?>">X</a>
628
+ </span>
629
+ </td></tr>
630
+
631
+ </table>
632
+ <?php
633
+ $all_capabilities = apply_filters( 'capsman_get_capabilities', array_keys( $this->capabilities ), $this->ID );
634
+ $all_capabilities = apply_filters( 'members_get_capabilities', $all_capabilities );
635
+
636
+ /*
637
+ $publishpress_status_change_caps = array();
638
+ foreach( $all_capabilities as $cap_name ) {
639
+ if (0 === strpos($cap_name, 'status_change_')) {
640
+ $publishpress_status_change_caps []= $cap_name;
641
+ }
642
+ }
643
+ */
644
+
645
+ $plugin_caps = [];
646
+
647
+ if (defined('PUBLISHPRESS_VERSION')) {
648
+ $plugin_caps['PublishPress'] = apply_filters('cme_publishpress_capabilities',
649
+ array(
650
+ 'edit_metadata',
651
+ 'edit_post_subscriptions',
652
+ 'pp_manage_roles',
653
+ 'pp_set_notification_channel',
654
+ 'pp_view_calendar',
655
+ 'pp_view_content_overview',
656
+ )
657
+ );
658
+ }
659
+
660
+ if (defined('PUBLISHPRESS_MULTIPLE_AUTHORS_VERSION')) {
661
+ if ($_caps = apply_filters('cme_multiple_authors_capabilities', array())) {
662
+ $plugin_caps['PublishPress Authors'] = $_caps;
663
+ }
664
+ }
665
+
666
+ if (defined('PRESSPERMIT_VERSION')) {
667
+ $plugin_caps['PublishPress Permissions'] = apply_filters('cme_presspermit_capabilities',
668
+ array(
669
+ 'edit_own_attachments',
670
+ 'list_others_unattached_files',
671
+ 'pp_administer_content',
672
+ 'pp_assign_roles',
673
+ 'pp_associate_any_page',
674
+ 'pp_create_groups',
675
+ 'pp_create_network_groups',
676
+ 'pp_define_moderation',
677
+ 'pp_define_post_status',
678
+ 'pp_define_privacy',
679
+ 'pp_delete_groups',
680
+ 'pp_edit_groups',
681
+ 'pp_exempt_edit_circle',
682
+ 'pp_exempt_read_circle',
683
+ 'pp_force_quick_edit',
684
+ 'pp_list_all_files',
685
+ 'pp_manage_capabilities',
686
+ 'pp_manage_members',
687
+ 'pp_manage_network_members',
688
+ 'pp_manage_settings',
689
+ 'pp_moderate_any',
690
+ 'pp_set_associate_exceptions',
691
+ 'pp_set_edit_exceptions',
692
+ 'pp_set_read_exceptions',
693
+ 'pp_set_revise_exceptions',
694
+ 'pp_set_term_assign_exceptions',
695
+ 'pp_set_term_associate_exceptions',
696
+ 'pp_set_term_manage_exceptions',
697
+ 'pp_unfiltered',
698
+ 'set_posts_status',
699
+ )
700
+ );
701
+ }
702
+
703
+ if (defined('WC_PLUGIN_FILE')) {
704
+ $plugin_caps['WooCommerce'] = apply_filters('cme_woocommerce_capabilities',
705
+ array(
706
+ 'assign_product_terms',
707
+ 'assign_shop_coupon_terms',
708
+ 'assign_shop_discount_terms',
709
+ 'assign_shop_order_terms',
710
+ 'assign_shop_payment_terms',
711
+ 'create_shop_orders',
712
+ 'delete_others_products',
713
+ 'delete_others_shop_coupons',
714
+ 'delete_others_shop_discounts',
715
+ 'delete_others_shop_orders',
716
+ 'delete_others_shop_payments',
717
+ 'delete_private_products',
718
+ 'delete_private_shop_coupons',
719
+ 'delete_private_shop_orders',
720
+ 'delete_private_shop_discounts',
721
+ 'delete_private_shop_payments',
722
+ 'delete_product_terms',
723
+ 'delete_products',
724
+ 'delete_published_products',
725
+ 'delete_published_shop_coupons',
726
+ 'delete_published_shop_discounts',
727
+ 'delete_published_shop_orders',
728
+ 'delete_published_shop_payments',
729
+ 'delete_shop_coupons',
730
+ 'delete_shop_coupon_terms',
731
+ 'delete_shop_discount_terms',
732
+ 'delete_shop_discounts',
733
+ 'delete_shop_order_terms',
734
+ 'delete_shop_orders',
735
+ 'delete_shop_payments',
736
+ 'delete_shop_payment_terms',
737
+ 'edit_others_products',
738
+ 'edit_others_shop_coupons',
739
+ 'edit_others_shop_discounts',
740
+ 'edit_others_shop_orders',
741
+ 'edit_others_shop_payments',
742
+ 'edit_private_products',
743
+ 'edit_private_shop_coupons',
744
+ 'edit_private_shop_discounts',
745
+ 'edit_private_shop_orders',
746
+ 'edit_private_shop_payments',
747
+ 'edit_product_terms',
748
+ 'edit_products',
749
+ 'edit_published_products',
750
+ 'edit_published_shop_coupons',
751
+ 'edit_published_shop_discounts',
752
+ 'edit_published_shop_orders',
753
+ 'edit_published_shop_payments',
754
+ 'edit_shop_coupon_terms',
755
+ 'edit_shop_coupons',
756
+ 'edit_shop_discounts',
757
+ 'edit_shop_discount_terms',
758
+ 'edit_shop_order_terms',
759
+ 'edit_shop_orders',
760
+ 'edit_shop_payments',
761
+ 'edit_shop_payment_terms',
762
+ 'export_shop_payments',
763
+ 'export_shop_reports',
764
+ 'import_shop_discounts',
765
+ 'import_shop_payments',
766
+ 'manage_product_terms',
767
+ 'manage_shop_coupon_terms',
768
+ 'manage_shop_discounts',
769
+ 'manage_shop_discount_terms',
770
+ 'manage_shop_payment_terms',
771
+ 'manage_shop_order_terms',
772
+ 'manage_shop_settings',
773
+ 'manage_woocommerce',
774
+ 'publish_products',
775
+ 'publish_shop_coupons',
776
+ 'publish_shop_discounts',
777
+ 'publish_shop_orders',
778
+ 'publish_shop_payments',
779
+ 'read_private_products',
780
+ 'read_private_shop_coupons',
781
+ 'read_private_shop_discounts',
782
+ 'read_private_shop_payments',
783
+ 'read_private_shop_orders',
784
+ 'view_admin_dashboard',
785
+ 'view_shop_discount_stats',
786
+ 'view_shop_payment_stats',
787
+ 'view_shop_reports',
788
+ 'view_shop_sensitive_data',
789
+ 'view_woocommerce_reports',
790
+ )
791
+ );
792
+ }
793
+
794
+ $plugin_caps = apply_filters('cme_plugin_capabilities', $plugin_caps);
795
+
796
+ foreach($plugin_caps as $plugin => $__plugin_caps) {
797
+ $_plugin_caps = array_fill_keys($__plugin_caps, true);
798
+
799
+ echo '<h3 class="cme-cap-section">' . sprintf(__( '%s Capabilities', 'capsman-enhanced' ), str_replace('_', ' ', $plugin )) . '</h3>';
800
+ echo '<table class="form-table cme-checklist"><tr>';
801
+
802
+ $checks_per_row = get_option( 'cme_form-rows', 5 );
803
+ $i = 0; $first_row = true;
804
+
805
+ foreach( array_keys($_plugin_caps) as $cap_name ) {
806
+ if ( isset( $type_caps[$cap_name] ) || isset($core_caps[$cap_name]) || isset($type_metacaps[$cap_name]) ) {
807
+ continue;
808
+ }
809
+
810
+ if ( ! $is_administrator && ! current_user_can($cap_name) )
811
+ continue;
812
+
813
+ if ( $i == $checks_per_row ) {
814
+ echo '</tr><tr>';
815
+ $i = 0;
816
+ }
817
+
818
+ if ( ! isset( $rcaps[$cap_name] ) )
819
+ $class = 'cap-no';
820
+ else
821
+ $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
822
+
823
+ if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
824
+ $class .= ' cap-metagroup';
825
+ $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
826
+ } else {
827
+ $title_text = $cap_name;
828
+ }
829
+
830
+ $disabled = '';
831
+ $checked = checked(1, ! empty($rcaps[$cap_name]), false );
832
+ $title = $title_text;
833
+ ?>
834
+ <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
835
+ <span>
836
+ <?php
837
+ echo str_replace( '_', ' ', $cap_name );
838
+ ?>
839
+ </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
840
+ <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
841
+ <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
842
+ <?php endif; ?>
843
+ </td>
844
+
845
+ <?php
846
+ ++$i;
847
+ }
848
+
849
+ if ( $i == $checks_per_row ) {
850
+ echo '</tr>';
851
+ $i = 0;
852
+ } elseif ( ! $first_row ) {
853
+ // Now close a wellformed table
854
+ for ( $i; $i < $checks_per_row; $i++ ){
855
+ echo '<td>&nbsp;</td>';
856
+ }
857
+ echo '</tr>';
858
+ }
859
+ ?>
860
+
861
+ <tr class="cme-bulk-select">
862
+ <td colspan="<?php echo $checks_per_row;?>">
863
+ <span style="float:right">
864
+ <input type="checkbox" class="cme-check-all" title="<?php _e('check/uncheck all', 'capsman-enhanced');?>">&nbsp;&nbsp;<a class="cme-neg-all" href="#" autocomplete="off" title="<?php _e('negate all (storing as disabled capabilities)', 'capsman-enhanced');?>">X</a> <a class="cme-switch-all" href="#" title="<?php _e('negate none (add/remove all capabilities normally)', 'capsman-enhanced');?>">X</a>
865
+ </span>
866
+ </td></tr>
867
+
868
+ </table>
869
+ <?php
870
+ }
871
+
872
+
873
+ if (array_intersect(array_keys(array_filter($type_metacaps)), $all_capabilities) && array_intersect_key($type_metacaps, array_filter($rcaps))) {
874
+
875
+ echo '<h3 class="cme-cap-section">' . __( 'Invalid Capabilities', 'capsman-enhanced' ) . '</h3>';
876
+ ?>
877
+
878
+ <div>
879
+ <span class="cme-subtext">
880
+ <?php _e('The following entries have no effect. Please assign desired capabilities in the Read / Edit / Delete grid above.', 'capsman-enhanced');?>
881
+ </span>
882
+ </div>
883
+
884
+ <table class="form-table cme-checklist">
885
+ <tr>
886
+ <?php
887
+ $i = 0; $first_row = true;
888
+
889
+ foreach( $all_capabilities as $cap_name ) {
890
+ if ( ! isset($this->capabilities[$cap_name]) )
891
+ $this->capabilities[$cap_name] = str_replace( '_', ' ', $cap_name );
892
+ }
893
+
894
+ uasort( $this->capabilities, 'strnatcasecmp' ); // sort by array values, but maintain keys );
895
+
896
+ foreach ( $this->capabilities as $cap_name => $cap ) :
897
+ if (!isset($type_metacaps[$cap_name]) || empty($rcaps[$cap_name])) {
898
+ continue;
899
+ }
900
+
901
+ if ( ! $is_administrator && empty( $current_user->allcaps[$cap_name] ) ) {
902
+ continue;
903
+ }
904
+
905
+ if ( $i == $checks_per_row ) {
906
+ echo '</tr><tr>';
907
+ $i = 0; $first_row = false;
908
+ }
909
+
910
+ if ( ! isset( $rcaps[$cap_name] ) )
911
+ $class = 'cap-no';
912
+ else
913
+ $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
914
+
915
+ $title_text = $cap_name;
916
+
917
+ $disabled = '';
918
+ $checked = checked(1, ! empty($rcaps[$cap_name]), false );
919
+ ?>
920
+ <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title_text;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
921
+ <span>
922
+ <?php
923
+ echo str_replace( '_', ' ', $cap );
924
+ ?>
925
+ </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
926
+ <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
927
+ <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
928
+ <?php endif; ?>
929
+ </td>
930
+ <?php
931
+ $i++;
932
+ endforeach;
933
+
934
+ if ( ! empty($lock_manage_caps_capability) ) {
935
+ echo '<input type="hidden" name="caps[manage_capabilities]" value="1" />';
936
+ }
937
+
938
+ if ( $i == $checks_per_row ) {
939
+ echo '</tr><tr>';
940
+ $i = 0;
941
+ } else {
942
+ if ( ! $first_row ) {
943
+ // Now close a wellformed table
944
+ for ( $i; $i < $checks_per_row; $i++ ){
945
+ echo '<td>&nbsp;</td>';
946
+ }
947
+ echo '</tr>';
948
+ }
949
+ }
950
+ ?>
951
+
952
+ </table><p>&nbsp;</p>
953
+ <?php
954
+ } // endif any invalid caps
955
+
956
+
957
+ echo '<p>&nbsp;</p><h3 class="cme-cap-section">' . __( 'Additional Capabilities', 'capsman-enhanced' ) . '</h3>';
958
+
959
+ ?>
960
+ <table class="form-table cme-checklist">
961
+ <tr>
962
+ <?php
963
+ $i = 0; $first_row = true;
964
+
965
+ foreach( $all_capabilities as $cap_name ) {
966
+ if ( ! isset($this->capabilities[$cap_name]) )
967
+ $this->capabilities[$cap_name] = str_replace( '_', ' ', $cap_name );
968
+ }
969
+
970
+ uasort( $this->capabilities, 'strnatcasecmp' ); // sort by array values, but maintain keys );
971
+
972
+ $additional_caps = apply_filters('publishpress_caps_manage_additional_caps', $this->capabilities);
973
+
974
+ foreach ($additional_caps as $cap_name => $cap) :
975
+
976
+ if ((isset($type_caps[$cap_name]) && !isset($type_metacaps[$cap_name]))
977
+ || isset($core_caps[$cap_name])
978
+ || (isset($type_metacaps[$cap_name]) && !empty($rcaps[$cap_name])) ) {
979
+ continue;
980
+ }
981
+
982
+ if (!isset($type_metacaps[$cap_name]) || !empty($rcaps[$cap_name])) {
983
+ foreach(array_keys($plugin_caps) as $plugin) {
984
+ if ( in_array( $cap_name, $plugin_caps[$plugin]) ) {
985
+ continue 2;
986
+ }
987
+ }
988
+ }
989
+
990
+ if ( ! $is_administrator && empty( $current_user->allcaps[$cap_name] ) ) {
991
+ continue;
992
+ }
993
+
994
+ // Levels are not shown.
995
+ if ( preg_match( '/^level_(10|[0-9])$/i', $cap_name ) ) {
996
+ continue;
997
+ }
998
+
999
+ if ( $i == $checks_per_row ) {
1000
+ echo '</tr><tr>';
1001
+ $i = 0; $first_row = false;
1002
+ }
1003
+
1004
+ if ( ! isset( $rcaps[$cap_name] ) )
1005
+ $class = 'cap-no';
1006
+ else
1007
+ $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
1008
+
1009
+ if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
1010
+ $class .= ' cap-metagroup';
1011
+ $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
1012
+ } else {
1013
+ $title_text = $cap_name;
1014
+ }
1015
+
1016
+ $disabled = '';
1017
+ $checked = checked(1, ! empty($rcaps[$cap_name]), false );
1018
+
1019
+ if ( 'manage_capabilities' == $cap_name ) {
1020
+ if (!current_user_can('administrator') && (!is_multisite() || !is_super_admin())) {
1021
+ continue;
1022
+ } elseif ( 'administrator' == $default ) {
1023
+ $class .= ' cap-locked';
1024
+ $lock_manage_caps_capability = true;
1025
+ $disabled = 'disabled="disabled"';
1026
+ }
1027
+ }
1028
+ ?>
1029
+ <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label title="<?php echo $title_text;?>"><input type="checkbox" name="caps[<?php echo $cap_name; ?>]" autocomplete="off" value="1" <?php echo $checked . $disabled;?> />
1030
+ <span>
1031
+ <?php
1032
+ echo str_replace( '_', ' ', $cap );
1033
+ ?>
1034
+ </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
1035
+ <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
1036
+ <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
1037
+ <?php endif; ?>
1038
+ </td>
1039
+ <?php
1040
+ $i++;
1041
+ endforeach;
1042
+
1043
+ if ( ! empty($lock_manage_caps_capability) ) {
1044
+ echo '<input type="hidden" name="caps[manage_capabilities]" value="1" />';
1045
+ }
1046
+
1047
+ if ( $i == $checks_per_row ) {
1048
+ echo '</tr><tr>';
1049
+ $i = 0;
1050
+ } else {
1051
+ if ( ! $first_row ) {
1052
+ // Now close a wellformed table
1053
+ for ( $i; $i < $checks_per_row; $i++ ){
1054
+ echo '<td>&nbsp;</td>';
1055
+ }
1056
+ echo '</tr>';
1057
+ }
1058
+ }
1059
+ ?>
1060
+
1061
+ <tr class="cme-bulk-select">
1062
+ <td colspan="<?php echo $checks_per_row;?>">
1063
+ <span style="float:right">
1064
+ <input type="checkbox" class="cme-check-all" title="<?php _e('check/uncheck all', 'capsman-enhanced');?>">&nbsp;&nbsp;<a class="cme-neg-all" href="#" autocomplete="off" title="<?php _e('negate all (storing as disabled capabilities)', 'capsman-enhanced');?>">X</a> <a class="cme-switch-all" href="#" title="<?php _e('negate none (add/remove all capabilities normally)', 'capsman-enhanced');?>">X</a>
1065
+ </span>
1066
+ </td></tr>
1067
+
1068
+ </table>
1069
+
1070
+ <div>
1071
+ <?php
1072
+ $level = ak_caps2level($rcaps);
1073
+ ?>
1074
+ <span title="<?php _e('Role level is mostly deprecated. However, it still determines eligibility for Post Author assignment and limits the application of user editing capabilities.', 'capsman-enhanced');?>">
1075
+
1076
+ <?php (in_array(get_locale(), ['en_EN', 'en_US'])) ? printf('Role Level:') : _e('Level:', 'capsman-enhanced');?> <select name="level">
1077
+ <?php for ( $l = $this->max_level; $l >= 0; $l-- ) {?>
1078
+ <option value="<?php echo $l; ?>" style="text-align:right;"<?php selected($level, $l); ?>>&nbsp;<?php echo $l; ?>&nbsp;</option>
1079
+ <?php }
1080
+ ?>
1081
+ </select>
1082
+ </span>
1083
+
1084
+ </div>
1085
+ </dd>
1086
+ </dl>
1087
+
1088
+ <?php
1089
+ $support_pp_only_roles = defined('PRESSPERMIT_ACTIVE');
1090
+ cme_network_role_ui( $default );
1091
+ ?>
1092
+
1093
+ <p class="submit">
1094
+ <input type="hidden" name="action" value="update" />
1095
+ <input type="hidden" name="current" value="<?php echo $default; ?>" />
1096
+ <input type="submit" name="SaveRole" value="<?php echo (in_array(get_locale(), ['en_EN', 'en_US'])) ? 'Save Capabilities' : _e('Save Changes', 'capsman-enhanced');?>" class="button-primary" /> &nbsp;
1097
+
1098
+ <?php if ( current_user_can('administrator') && 'administrator' != $default ) : ?>
1099
+ <a class="ak-delete" title="<?php echo esc_attr(__('Delete this role', 'capsman-enhanced')) ?>" href="<?php echo wp_nonce_url("admin.php?page={$this->ID}&amp;action=delete&amp;role={$default}", 'delete-role_' . $default); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf(__("You are about to delete the %s role.\n\n 'Cancel' to stop, 'OK' to delete.", 'capsman-enhanced'), $roles[$default])); ?>') ) { return true;}return false;"><?php _e('Delete Role', 'capsman-enhanced')?></a>
1100
+ <?php endif; ?>
1101
+ </p>
1102
+
1103
+ </td>
1104
+ <td class="sidebar">
1105
+ <?php do_action('publishpress-caps_sidebar_top');?>
1106
+
1107
+ <dl>
1108
+ <dt><?php _e('Add Capability', 'capsman-enhanced'); ?></dt>
1109
+ <dd style="text-align:center;">
1110
+ <p><input type="text" name="capability-name" class="regular-text" placeholder="<?php echo 'capability_name';?>" /><br />
1111
+ <input type="submit" name="AddCap" value="<?php _e('Add to role', 'capsman-enhanced') ?>" class="button" /></p>
1112
+ </dd>
1113
+ </dl>
1114
+
1115
+ <?php
1116
+ $pp_ui->pp_types_ui( $defined['type'] );
1117
+ $pp_ui->pp_taxonomies_ui( $defined['taxonomy'] );
1118
+
1119
+ do_action('publishpress-caps_sidebar_bottom');
1120
+ ?>
1121
+
1122
+ <dl>
1123
+ <dt><?php (!in_array(get_locale(), ['en_EN', 'en_US'])) ? _e('Copy this role to', 'capsman-enhanced') : printf('Copy %s Role', translate_user_role($roles[$default])); ?></dt>
1124
+ <dd style="text-align:center;">
1125
+ <?php $class = ( $support_pp_only_roles ) ? 'tight-text' : 'regular-text'; ?>
1126
+ <p><input type="text" name="copy-name" class="<?php echo $class;?>" placeholder="<?php _e('Role Name', 'capsman-enhanced') ?>" />
1127
+
1128
+ <?php if( $support_pp_only_roles ) : ?>
1129
+ <label for="copy_role_pp_only" title="<?php _e('Make role available for supplemental assignment to Permission Groups only', 'capsman-enhanced');?>"> <input type="checkbox" name="copy_role_pp_only" id="copy_role_pp_only" autocomplete="off" value="1"> <?php _e('hidden', 'capsman-enhanced'); ?> </label>
1130
+ <?php endif; ?>
1131
+
1132
+ <br />
1133
+ <input type="submit" name="CopyRole" value="<?php _e('Copy', 'capsman-enhanced') ?>" class="button" />
1134
+ </p>
1135
+ </dd>
1136
+ </dl>
1137
+
1138
+ <dl>
1139
+ <dt><?php _e('Rename Role', 'capsman-enhanced'); ?></dt>
1140
+ <dd style="text-align:center;">
1141
+ <p><input type="text" name="rename-name" class="regular-text" placeholder="<?php _e('New Role Name', 'capsman-enhanced') ?>" />
1142
+
1143
+ <br />
1144
+ <input type="submit" name="RenameRole" value="<?php _e('Rename', 'capsman-enhanced') ?>" class="button" />
1145
+ </p>
1146
+ </dd>
1147
+ </dl>
1148
+ </td>
1149
+ </tr>
1150
+ </table>
1151
+ </fieldset>
1152
+ </form>
1153
+
1154
+ <?php if (!defined('PUBLISHPRESS_CAPS_PRO_VERSION') || get_option('cme_display_branding')) {
1155
+ cme_publishpressFooter();
1156
+ }
1157
+ ?>
1158
+ </div>
1159
+
1160
+ <?php
1161
+ function cme_network_role_ui( $default ) {
1162
+ if (!is_multisite() || !is_super_admin() || !is_main_site()) {
1163
+ return false;
1164
+ }
1165
+ ?>
1166
+
1167
+ <div style="float:right;margin-left:10px;margin-right:10px">
1168
+ <?php
1169
+ if ( ! $autocreate_roles = get_site_option( 'cme_autocreate_roles' ) )
1170
+ $autocreate_roles = array();
1171
+ ?>
1172
+ <div style="margin-bottom: 5px">
1173
+ <label for="cme_autocreate_role" title="<?php _e('Create this role definition in new (future) sites', 'capsman-enhanced');?>"><input type="checkbox" name="cme_autocreate_role" id="cme_autocreate_role" autocomplete="off" value="1" <?php echo checked(in_array($default, $autocreate_roles));?>> <?php _e('include in new sites', 'capsman-enhanced'); ?> </label>
1174
+ </div>
1175
+ <div>
1176
+ <label for="cme_net_sync_role" title="<?php echo esc_attr(__('Copy / update this role definition to all sites now', 'capsman-enhanced'));?>"><input type="checkbox" name="cme_net_sync_role" id="cme_net_sync_role" autocomplete="off" value="1"> <?php _e('sync role to all sites now', 'capsman-enhanced'); ?> </label>
1177
+ </div>
1178
+ <div>
1179
+ <label for="cme_net_sync_options" title="<?php echo esc_attr(__('Copy option settings to all sites now', 'capsman-enhanced'));?>"><input type="checkbox" name="cme_net_sync_options" id="cme_net_sync_options" autocomplete="off" value="1"> <?php _e('sync options to all sites now', 'capsman-enhanced'); ?> </label>
1180
+ </div>
1181
+ </div>
1182
+ <?php
1183
+ return true;
1184
+ }
1185
+
1186
+ function cme_plugin_info_url( $plugin_slug ) {
1187
+ $_url = "plugin-install.php?tab=plugin-information&plugin=$plugin_slug&TB_iframe=true&width=640&height=678";
1188
+ return ( is_multisite() ) ? network_admin_url($_url) : admin_url($_url);
1189
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/features/admin-features.php DELETED
@@ -1,303 +0,0 @@
1
- <?php
2
- /**
3
- * Capability Manager Admin Features.
4
- * Hide and block selected Admin Features like toolbar, dashboard widgets etc per-role.
5
- *
6
- * Copyright 2020, PublishPress <help@publishpress.com>
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU General Public License
10
- * version 2 as published by the Free Software Foundation.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- */
20
-
21
- require_once(dirname(CME_FILE) . '/includes/features/restrict-admin-features.php');
22
-
23
- global $capsman;
24
-
25
- $roles = $capsman->roles;
26
- $default_role = $capsman->get_last_role();
27
-
28
-
29
- $disabled_admin_items = !empty(get_option('capsman_disabled_admin_features')) ? (array)get_option('capsman_disabled_admin_features') : [];
30
- $disabled_admin_items = array_key_exists($default_role, $disabled_admin_items) ? (array)$disabled_admin_items[$default_role] : [];
31
-
32
- $admin_features_elements = PP_Capabilities_Admin_Features::elementsLayout();
33
- ?>
34
-
35
- <div class="wrap publishpress-caps-manage pressshack-admin-wrapper pp-capability-menus-wrapper">
36
- <div id="icon-capsman-admin" class="icon32"></div>
37
- <h2><?php _e('Admin Feature Restrictions', 'capabilities-pro'); ?></h2>
38
-
39
- <form method="post" id="ppc-admin-features-form" action="admin.php?page=pp-capabilities-admin-features">
40
- <?php wp_nonce_field('pp-capabilities-admin-features'); ?>
41
-
42
- <fieldset>
43
- <table id="akmin">
44
- <tr>
45
- <td class="content">
46
-
47
- <div class="publishpress-headline">
48
- <span class="cme-subtext">
49
- <span class='pp-capability-role-caption'>
50
- <?php
51
- _e('Note: You are only restricting access to admin features screens. Some plugins may also add features to other areas of WordPress.',
52
- 'capabilities-pro');
53
- ?>
54
- </span>
55
- </span>
56
- </div>
57
- <div class="publishpress-filters">
58
- <select name="ppc-admin-features-role" class="ppc-admin-features-role">
59
- <?php
60
- foreach ($roles as $role => $name) :
61
- $name = translate_user_role($name);
62
- ?>
63
- <option value="<?php echo $role; ?>" <?php selected($default_role,
64
- $role); ?>><?php echo $name; ?></option>
65
- <?php
66
- endforeach;
67
- ?>
68
- </select> &nbsp;
69
-
70
- <img class="loading" src="<?php echo $capsman->mod_url; ?>/images/wpspin_light.gif"
71
- style="display: none">
72
-
73
- <input type="submit" name="admin-features-submit"
74
- value="<?php _e('Save Changes', 'capabilities-pro') ?>"
75
- class="button-primary ppc-admin-features-submit" style="float:right"/>
76
- </div>
77
-
78
- <div id="pp-capability-menu-wrapper" class="postbox">
79
- <div class="pp-capability-menus">
80
-
81
- <div class="pp-capability-menus-wrap">
82
- <div id="pp-capability-menus-general"
83
- class="pp-capability-menus-content editable-role" style="display: block;">
84
-
85
- <table
86
- class="wp-list-table widefat fixed striped pp-capability-menus-select">
87
-
88
- <thead>
89
- <tr class="ppc-menu-row parent-menu">
90
-
91
- <td class="restrict-column ppc-menu-checkbox">
92
- <input id="check-all-item"
93
- class="check-item check-all-menu-item" type="checkbox"/>
94
- </td>
95
- <td class="menu-column ppc-menu-item">
96
- <label for="check-all-item">
97
- <span class="menu-item-link check-all-menu-link">
98
- <strong>
99
- <?php _e('Toggle all', 'capabilities-pro'); ?>
100
- </strong>
101
- </span></label>
102
- </td>
103
-
104
- </tr>
105
- </thead>
106
-
107
- <tfoot>
108
- <tr class="ppc-menu-row parent-menu">
109
-
110
- <td class="restrict-column ppc-menu-checkbox">
111
- <input id="check-all-item-2"
112
- class="check-item check-all-menu-item" type="checkbox"/>
113
- </td>
114
- <td class="menu-column ppc-menu-item">
115
- <label for="check-all-item-2">
116
- <span class="menu-item-link check-all-menu-link">
117
- <strong>
118
- <?php _e('Toggle all', 'capabilities-pro'); ?>
119
- </strong>
120
- </span>
121
- </label>
122
- </td>
123
-
124
- </tr>
125
- </tfoot>
126
-
127
- <tbody>
128
-
129
- <?php
130
- $icon_list = (array)PP_Capabilities_Admin_Features::elementLayoutItemIcons();
131
-
132
- $sn = 0;
133
- foreach ($admin_features_elements as $section_title => $section_elements) {
134
- $sn++;
135
- $section_slug = strtolower(ppc_remove_non_alphanumeric_space_characters($section_title));
136
- $icon_name = isset($icon_list[$section_slug]) ? $icon_list[$section_slug] : '&mdash;';
137
- ?>
138
-
139
-
140
- <tr class="ppc-menu-row parent-menu">
141
-
142
- <td class="features-section-header" colspan="2">
143
- <strong><i
144
- class="dashicons dashicons-<?php echo $icon_name ?>"></i> <?php echo $section_title; ?>
145
- </strong>
146
- </td>
147
-
148
- </tr>
149
-
150
- <?php
151
- foreach ($section_elements as $section_id => $section_array) {
152
- $sn++;
153
- if (!$section_id) {
154
- continue;
155
- }
156
- $item_name = $section_array['label'];
157
- $item_action = $section_array['action'];
158
- $restrict_value = $item_action.'||'.$section_id;
159
- if($item_action === 'ppc_dashboard_widget'){
160
- $restrict_value .= '||'.$section_array['context'];
161
- }
162
- ?>
163
-
164
- <tr class="ppc-menu-row child-menu">
165
-
166
- <td class="restrict-column ppc-menu-checkbox">
167
- <input
168
- id="check-item-<?php echo $sn; ?>"
169
- class="check-item" type="checkbox"
170
- name="capsman_disabled_admin_features[]"
171
- value="<?php echo $restrict_value; ?>"
172
- <?php echo (in_array($restrict_value, $disabled_admin_items)) ? 'checked' : ''; ?>/>
173
- </td>
174
- <td class="menu-column ppc-menu-item'">
175
-
176
- <label for="check-item-<?php echo $sn; ?>">
177
- <span
178
- class="menu-item-link<?php echo (in_array($restrict_value,
179
- $disabled_admin_items)) ? ' restricted' : ''; ?>">
180
- <strong>
181
- <?php
182
- if ((isset($section_array['step']) && $section_array['step'] > 0) && isset($section_array['parent']) && !empty($section_array['parent'])) {
183
- $step_margin = $section_array['step'] * 20;
184
- echo '<span style="margin-left: ' . $step_margin . 'px;"></span>';
185
- echo ' ' . $section_array['position'] . '. ';
186
- } else {
187
- if (isset($icon_list[$section_id])) {
188
- echo '<i class="dashicons dashicons-' . $icon_list[$section_id] . '"></i>';
189
- } else {
190
- echo '&mdash;';
191
- }
192
- }
193
- ?>
194
- <?php echo $item_name; ?>
195
- </strong></span>
196
- </label>
197
- </td>
198
-
199
- </tr>
200
-
201
- <?php
202
- }//end $section_elements subsection loop
203
- }// end $admin_features_elements section loop
204
-
205
- ?>
206
- </tbody>
207
- </table>
208
- </div>
209
-
210
- </div>
211
- </div>
212
- </div>
213
- <input type="submit" name="admin-features-submit"
214
- value="<?php _e('Save Changes', 'capabilities-pro') ?>"
215
- class="button-primary ppc-admin-features-submit"/>
216
- </td>
217
- </tr>
218
- </table>
219
-
220
- </fieldset>
221
-
222
- </form>
223
-
224
- <script type="text/javascript">
225
- /* <![CDATA[ */
226
- jQuery(document).ready(function($) {
227
-
228
- // -------------------------------------------------------------
229
- // reload page for instant reflection if user is updating own role
230
- // -------------------------------------------------------------
231
- <?php if(!empty($ppc_page_reload) && (int)$ppc_page_reload === 1){ ?>
232
- window.location = '<?php echo admin_url('admin.php?page=pp-capabilities-admin-features&role=' . $default_role . ''); ?>'
233
- <?php } ?>
234
-
235
- // -------------------------------------------------------------
236
- // Set form action attribute to include role
237
- // -------------------------------------------------------------
238
- $('#ppc-admin-features-form').attr('action', '<?php echo admin_url('admin.php?page=pp-capabilities-admin-features&role=' . $default_role . ''); ?>')
239
-
240
- // -------------------------------------------------------------
241
- // Instant restricted item class
242
- // -------------------------------------------------------------
243
- $(document).on('change', '.pp-capability-menus-wrapper .ppc-menu-row .check-item', function() {
244
-
245
- if ($(this).is(':checked')) {
246
- //add class if value is checked
247
- $(this).closest('tr').find('.menu-item-link').addClass('restricted')
248
-
249
- //toggle all checkbox
250
- if ($(this).hasClass('check-all-menu-item')) {
251
- $("input[type='checkbox'][name='capsman_disabled_admin_features[]']").prop('checked', true)
252
- $('.menu-item-link').addClass('restricted')
253
- } else {
254
- $('.check-all-menu-link').removeClass('restricted')
255
- $('.check-all-menu-item').prop('checked', false)
256
- }
257
-
258
- } else {
259
- //unchecked value
260
- $(this).closest('tr').find('.menu-item-link').removeClass('restricted')
261
-
262
- //toggle all checkbox
263
- if ($(this).hasClass('check-all-menu-item')) {
264
- $("input[type='checkbox'][name='capsman_disabled_admin_features[]']").prop('checked', false)
265
- $('.menu-item-link').removeClass('restricted')
266
- } else {
267
- $('.check-all-menu-link').removeClass('restricted')
268
- $('.check-all-menu-item').prop('checked', false)
269
- }
270
-
271
- }
272
-
273
- })
274
-
275
- // -------------------------------------------------------------
276
- // Load selected roles menu
277
- // -------------------------------------------------------------
278
- $(document).on('change', '.pp-capability-menus-wrapper .ppc-admin-features-role', function() {
279
-
280
- //disable select
281
- $('.pp-capability-menus-wrapper .ppc-admin-features-role').attr('disabled', true)
282
-
283
- //hide button
284
- $('.pp-capability-menus-wrapper .ppc-admin-features-submit').hide()
285
-
286
- //show loading
287
- $('#pp-capability-menu-wrapper').hide()
288
- $('div.publishpress-caps-manage img.loading').show()
289
-
290
- //go to url
291
- window.location = '<?php echo admin_url('admin.php?page=pp-capabilities-admin-features&role='); ?>' + $(this).val() + ''
292
-
293
- })
294
- })
295
- /* ]]> */
296
- </script>
297
-
298
- <?php if (!defined('PUBLISHPRESS_CAPS_PRO_VERSION') || get_option('cme_display_branding')) {
299
- cme_publishpressFooter();
300
- }
301
- ?>
302
- </div>
303
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/features/editor-features-classic.php CHANGED
@@ -12,10 +12,14 @@ foreach($def_post_types as $post_type) {
12
  ?>
13
 
14
  <table class="wp-list-table widefat fixed striped pp-capability-menus-select editor-features-classic" <?php if (empty($_REQUEST['ppc-tab']) || ('classic' != $_REQUEST['ppc-tab'])) echo 'style="display:none;"';?>>
15
- <?php foreach(['thead', 'tfoot'] as $tag):?>
 
 
 
 
16
  <<?php echo $tag;?>>
17
  <tr>
18
- <th class="menu-column"><?php if ('thead' == $tag || !defined('PUBLISHPRESS_CAPS_PRO_VERSION')) {_e('Classic Editor Screen', 'capsman-enhanced');}?></th>
19
 
20
  <?php foreach($def_post_types as $post_type) :
21
  $type_obj = get_post_type_object($post_type);
@@ -76,7 +80,6 @@ foreach($def_post_types as $post_type) {
76
  <?php
77
  }
78
  }
79
-
80
  do_action('pp_capabilities_features_classic_after_table_tr');
81
  ?>
82
 
12
  ?>
13
 
14
  <table class="wp-list-table widefat fixed striped pp-capability-menus-select editor-features-classic" <?php if (empty($_REQUEST['ppc-tab']) || ('classic' != $_REQUEST['ppc-tab'])) echo 'style="display:none;"';?>>
15
+ <?php foreach(['thead', 'tfoot'] as $tag):
16
+ if (defined('PUBLISHPRESS_CAPS_PRO_VERSION') && ('tfoot' == $tag)) {
17
+ continue;
18
+ }
19
+ ?>
20
  <<?php echo $tag;?>>
21
  <tr>
22
+ <th class="menu-column"><?php _e('Classic Editor Screen', 'capsman-enhanced');?></th>
23
 
24
  <?php foreach($def_post_types as $post_type) :
25
  $type_obj = get_post_type_object($post_type);
80
  <?php
81
  }
82
  }
 
83
  do_action('pp_capabilities_features_classic_after_table_tr');
84
  ?>
85
 
includes/features/editor-features-gutenberg.php CHANGED
@@ -12,10 +12,14 @@ foreach($def_post_types as $post_type) {
12
  ?>
13
 
14
  <table class="wp-list-table widefat fixed striped pp-capability-menus-select editor-features-gutenberg" <?php if (!empty($_REQUEST['ppc-tab']) && ('gutenberg' != $_REQUEST['ppc-tab'])) echo 'style="display:none;"';?>>
15
- <?php foreach(['thead', 'tfoot'] as $tag):?>
 
 
 
 
16
  <<?php echo $tag;?>>
17
  <tr>
18
- <th class="menu-column"><?php if ('thead' == $tag) {_e('Gutenberg Screen', 'capsman-enhanced');}?></th>
19
 
20
  <?php foreach($def_post_types as $post_type) :
21
  $type_obj = get_post_type_object($post_type);
@@ -73,7 +77,7 @@ foreach($def_post_types as $post_type) {
73
  <?php
74
  }
75
  }
76
-
77
  do_action('pp_capabilities_features_gutenberg_after_table_tr');
78
  ?>
79
 
12
  ?>
13
 
14
  <table class="wp-list-table widefat fixed striped pp-capability-menus-select editor-features-gutenberg" <?php if (!empty($_REQUEST['ppc-tab']) && ('gutenberg' != $_REQUEST['ppc-tab'])) echo 'style="display:none;"';?>>
15
+ <?php foreach(['thead', 'tfoot'] as $tag):
16
+ if (defined('PUBLISHPRESS_CAPS_PRO_VERSION') && ('tfoot' == $tag)) {
17
+ continue;
18
+ }
19
+ ?>
20
  <<?php echo $tag;?>>
21
  <tr>
22
+ <th class="menu-column"><?php _e('Gutenberg Screen', 'capsman-enhanced');?></th>
23
 
24
  <?php foreach($def_post_types as $post_type) :
25
  $type_obj = get_post_type_object($post_type);
77
  <?php
78
  }
79
  }
80
+
81
  do_action('pp_capabilities_features_gutenberg_after_table_tr');
82
  ?>
83
 
includes/features/restrict-admin-features.php DELETED
@@ -1,323 +0,0 @@
1
- <?php
2
-
3
- class PP_Capabilities_Admin_Features
4
- {
5
-
6
- /**
7
- * Get all admin features layout.
8
- *
9
- * @return array Elements layout.
10
- */
11
- public static function elementsLayout()
12
- {
13
- $elements = [];
14
-
15
- //Add toolbar
16
- $elements[__('Admin Toolbar', 'capsman-enhanced')] = self::formatAdminToolbar();
17
-
18
- //Add dashboard widget
19
- $elements[__('Dashboard widgets', 'capsman-enhanced')] = self::formatDashboardWidgets();
20
-
21
- return apply_filters('pp_capabilities_admin_features_elements', $elements);
22
- }
23
-
24
- /**
25
- * Retrieve all items icons.
26
- *
27
- * @return array Items icons.
28
- */
29
- public static function elementLayoutItemIcons()
30
- {
31
- $icons = [];
32
-
33
- $icons['admintoolbar'] = 'open-folder';
34
- $icons['dashboardwidgets'] = 'dashboard';
35
- $icons['menu-toggle'] = 'menu';
36
- $icons['wp-logo'] = 'wordpress';
37
- $icons['site-name'] = 'admin-home';
38
- $icons['updates'] = 'update';
39
- $icons['comments'] = 'admin-comments';
40
- $icons['new-content'] = 'plus';
41
- $icons['wpseo-menu'] = 'open-folder';
42
- $icons['top-secondary'] = 'admin-users';
43
-
44
- return apply_filters('pp_capabilities_admin_features_icons', $icons);
45
- }
46
-
47
- /**
48
- * Let provide support for known adminbar with empty title due to icon title only.
49
- *
50
- */
51
- public static function elementToolbarTitleFallback($id)
52
- {
53
- $title = [];
54
-
55
- $title['menu-toggle'] = __('Mobile Menu Toggle', 'capsman-enhanced');
56
- $title['wp-logo'] = __('WordPress Logo', 'capsman-enhanced');
57
- $title['wp-logo-external'] = __('WordPress External Links', 'capsman-enhanced');
58
- $title['updates'] = __('Updates', 'capsman-enhanced');
59
- $title['comments'] = __('Comments', 'capsman-enhanced');
60
- $title['top-secondary'] = __('Right bar', 'capsman-enhanced');
61
- $title['user-actions'] = __('User actions', 'capsman-enhanced');
62
- $title['new-content'] = __('New', 'capsman-enhanced');
63
- $title['new-content'] = __('New', 'capsman-enhanced');
64
- $title['user-info'] = __('User Display Name', 'capsman-enhanced');
65
- $title['wpseo-menu'] = __('Yoast SEO', 'capsman-enhanced');
66
-
67
- return isset($title[$id]) ? $title[$id] : $id;
68
- }
69
-
70
- /**
71
- * Get the list of dashboard widgets.
72
- *
73
- * @return array dashboard widgets.
74
- */
75
- public static function dashboardWidgets()
76
- {
77
- global $wp_meta_boxes;
78
-
79
- $screen = is_network_admin() ? 'dashboard-network' : 'dashboard';
80
- $action = is_network_admin() ? 'wp_network_dashboard_setup' : 'wp_dashboard_setup';
81
- $current_screen = get_current_screen();
82
-
83
- //set current screen as dashboard to get widgets
84
- if (!isset($wp_meta_boxes[$screen]) || !is_array($wp_meta_boxes[$screen])) {
85
- require_once ABSPATH . '/wp-admin/includes/dashboard.php';
86
- set_current_screen($screen);
87
- remove_action( $action, [ __CLASS__, 'disableDashboardWidgets' ], 99 );
88
- wp_dashboard_setup();
89
- add_action( $action, [ __CLASS__, 'disableDashboardWidgets' ], 99 );
90
- }
91
-
92
- $widgets = [];
93
- if (isset($wp_meta_boxes[$screen])) {
94
- $widgets = $wp_meta_boxes[$screen];
95
- }
96
-
97
- //set current screen to it original stage
98
- set_current_screen($current_screen);
99
-
100
- return $widgets;
101
- }
102
-
103
- /**
104
- * Format dashboard widgets.
105
- *
106
- * @return array Elements layout item.
107
- */
108
- public static function formatDashboardWidgets()
109
- {
110
- $widgets = self::dashboardWidgets();
111
-
112
- $elements_widget = [];
113
- //add widget that may not be part of wp_meta_boxes
114
- $elements_widget['dashboard_welcome_panel'] = ['label' => __('Welcome panel', 'capsman-enhanced'), 'context' => 'normal', 'action' => 'ppc_dashboard_widget'];
115
- //loop other widgets
116
- foreach ($widgets as $context => $priority) {
117
- foreach ($priority as $data) {
118
- foreach ($data as $id => $widget) {
119
- if ($widget) {
120
- $widget_title = isset($widget['title']) ? wp_strip_all_tags($widget['title']) : '';
121
- $elements_widget[$id] = ['label' => $widget_title, 'context' => $context, 'action' => 'ppc_dashboard_widget'];
122
- }
123
- }
124
- }
125
- }
126
-
127
- return $elements_widget;
128
- }
129
-
130
- /**
131
- * Format admin toolbar.
132
- *
133
- * @return array Elements layout item.
134
- */
135
- public static function formatAdminToolbar()
136
- {
137
- global $toolbar_items;
138
-
139
- $toolbars = (array)$GLOBALS['ppcAdminBar'];
140
- $toolbarTree = self::formatAdminToolbarTree($toolbars);
141
- //set toolbar element with steps
142
- self::setAdminToolbarElement($toolbarTree);
143
-
144
- return $toolbar_items;
145
- }
146
-
147
- /**
148
- * Build multidimensional array for admin toolbar.
149
- *
150
- * @return array.
151
- */
152
- public static function formatAdminToolbarTree(array $items, $parentId = '')
153
- {
154
- $branch = [];
155
-
156
- foreach ($items as $item) {
157
- if ($item['parent'] == $parentId) {
158
- $children = self::formatAdminToolbarTree($items, $item['id']);
159
- if ($children) {
160
- $item['children'] = $children;
161
- }
162
- $branch[] = $item;
163
- }
164
- }
165
-
166
- return $branch;
167
- }
168
-
169
- /**
170
- * Set admin toolbar element.
171
- *
172
- */
173
- public static function setAdminToolbarElement(array $toolbarTrees, $steps = 1, $step_list = [])
174
- {
175
- global $toolbar_items;
176
-
177
- $position = 0;
178
- foreach ($toolbarTrees as $toolbarTree) {
179
- $position++;
180
- $id = $toolbarTree['id'];
181
- $itemTitle = self::cleanTitleText($toolbarTree['title']);
182
-
183
- //let fall back to known title/id if title still empty
184
- if (empty(trim($itemTitle))) {
185
- $itemTitle = self::elementToolbarTitleFallback($id);
186
- }
187
-
188
- $toolbar_items[$id] = ['label' => $itemTitle,
189
- 'parent' => $toolbarTree['parent'],
190
- 'step' => $steps,
191
- 'position' => $position,
192
- 'action' => 'ppc_adminbar'
193
- ];
194
- foreach ($toolbarTree as $key => $value) {
195
- if (is_array($value)) {
196
- self::setAdminToolbarElement($value, $steps + 1, $step_list);
197
- }
198
- }
199
- }
200
- }
201
-
202
- /**
203
- * Process admin features title.
204
- *
205
- */
206
- public static function cleanTitleText($title)
207
- {
208
- //strip span and div content
209
- $title = preg_replace('#(<span.*?>).*?(</span>)#', '', $title);
210
- $title = preg_replace('#(<img.*?>)#', '', $title);
211
-
212
- //strip other html tags
213
- $title = strip_tags($title);
214
-
215
- return $title;
216
- }
217
-
218
- /**
219
- * Get array elements that starts with a specific word
220
- *
221
- * @param array $restricted_features All restricted elements to check agains.
222
- * @param string $start_with The word to look for in array.
223
- *
224
- * @return array Filtered array.
225
- */
226
- public static function adminFeaturesRestrictedElements($restricted_elements, $start_with = 'ppc_adminbar')
227
- {
228
- //get all items of the array starting with the specified string.
229
- $new_elements = array_filter(
230
- $restricted_elements,
231
- function($value, $key) use ($start_with) {return strpos($value, $start_with) === 0;}, ARRAY_FILTER_USE_BOTH
232
- );
233
-
234
- return $new_elements;
235
- }
236
-
237
-
238
- /**
239
- * Apply admin feature restrictions
240
- */
241
- public static function adminFeaturedRestriction()
242
- {
243
- global $ppc_disabled_toolbar, $ppc_disabled_widget;
244
- // Get all user roles.
245
- $user_roles = wp_get_current_user()->roles;
246
- $disabled_features = get_option("capsman_disabled_admin_features", []);
247
-
248
- $all_disabled_elements = [];
249
-
250
- foreach ($user_roles as $role) {
251
- if (!empty($disabled_features[$role])) {
252
- $all_disabled_elements[] = $disabled_features[$role];
253
- }
254
- }
255
-
256
- //merge all array values incase it's more than role
257
- //$all_disabled_elements = array_merge(...$all_disabled_elements); // This is a PHP 7.4 operator
258
- $all_disabled_elements = (is_array($all_disabled_elements) && isset($all_disabled_elements[0])) ? array_merge($all_disabled_elements[0]) : [];
259
-
260
- //disable toolbar
261
- $ppc_disabled_toolbar = self::adminFeaturesRestrictedElements($all_disabled_elements, 'ppc_adminbar');
262
- if(count($ppc_disabled_toolbar) > 0){
263
- add_action( 'wp_before_admin_bar_render', [ __CLASS__, 'disableDashboardBar' ], 99 );
264
- }
265
-
266
- if(is_admin()){
267
- $ppc_disabled_widget = self::adminFeaturesRestrictedElements($all_disabled_elements, 'ppc_dashboard_widget');
268
- //disable widget
269
- if(count($ppc_disabled_widget) > 0){
270
- add_action( 'wp_dashboard_setup', [ __CLASS__, 'disableDashboardWidgets' ], 99 );
271
- add_action( 'wp_network_dashboard_setup', [ __CLASS__, 'disableDashboardWidgets' ], 99 );
272
- }
273
- }
274
- }
275
-
276
- /**
277
- * Disable admin bar.
278
- *
279
- */
280
- public static function disableDashboardBar() {
281
- global $wp_admin_bar, $ppc_disabled_toolbar;
282
- $admin_bar_options = (array)$ppc_disabled_toolbar;
283
- $admin_bar_items = (array)$GLOBALS['ppcAdminBar'];
284
-
285
- if (count($admin_bar_options) > 0 && ( is_array($admin_bar_items) || is_object($admin_bar_items) ) ) {
286
- foreach ($admin_bar_items as $barItem) {
287
- $id = $barItem['id'];
288
- $item_id = 'ppc_adminbar||'.$id;
289
- if ($id && in_array($item_id, $admin_bar_options)) {
290
- $wp_admin_bar->remove_menu($id);
291
- }
292
- }
293
- }
294
-
295
- }
296
-
297
- /**
298
- * Disable dashboard widgets.
299
- *
300
- */
301
- public static function disableDashboardWidgets() {
302
- global $ppc_disabled_widget;
303
-
304
- $widgets = (array)$ppc_disabled_widget;
305
-
306
- if ( count($widgets) === 0 ) {
307
- return;
308
- }
309
-
310
- foreach ( $widgets as $widget) {
311
- $widget_data = explode("||", $widget);
312
- $widget_id = $widget_data[1];
313
- $widget_content = $widget_data[2];
314
-
315
- if ( $widget_id === 'dashboard_welcome_panel' ) {
316
- remove_action( 'welcome_panel', 'wp_welcome_panel' );
317
- }else{
318
- remove_meta_box( $widget_id, get_current_screen()->base, $widget_content );
319
- }
320
- }
321
- }
322
-
323
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/features/restrict-editor-features.php CHANGED
@@ -302,7 +302,7 @@ class PP_Capabilities_Post_Features {
302
  'undo' => ['label' => __('Undo', 'capsman-enhanced'), 'elements' => '.edit-post-header-toolbar .editor-history__undo'],
303
  'redo' => ['label' => __('Redo', 'capsman-enhanced'), 'elements' => '.edit-post-header-toolbar .editor-history__redo'],
304
  'details' => ['label' => __('Details', 'capsman-enhanced'), 'elements' => '.edit-post-header__toolbar .table-of-contents'],
305
- 'outline' => ['label' => __('Outline', 'capsman-enhanced'), 'elements' => '.edit-post-header__toolbar .edit-post-header-toolbar__list-view-toggle'],
306
  ],
307
 
308
  __('Top Bar - Right', 'capabilities-pro') => [
302
  'undo' => ['label' => __('Undo', 'capsman-enhanced'), 'elements' => '.edit-post-header-toolbar .editor-history__undo'],
303
  'redo' => ['label' => __('Redo', 'capsman-enhanced'), 'elements' => '.edit-post-header-toolbar .editor-history__redo'],
304
  'details' => ['label' => __('Details', 'capsman-enhanced'), 'elements' => '.edit-post-header__toolbar .table-of-contents'],
305
+ 'outline' => ['label' => __('Outline', 'capsman-enhanced'), 'elements' => '.edit-post-header__toolbar .block-editor-block-navigation'],
306
  ],
307
 
308
  __('Top Bar - Right', 'capabilities-pro') => [
includes/functions.php CHANGED
@@ -186,78 +186,5 @@ function pp_capabilities_is_classic_editor_available()
186
  return class_exists('Classic_Editor')
187
  || function_exists( 'the_gutenberg_project' )
188
  || class_exists('Gutenberg_Ramp')
189
- || version_compare($wp_version, '5.0', '<')
190
- || (function_exists('et_get_option') && 'on' === et_get_option('et_enable_classic_editor', 'off'));
191
  }
192
-
193
-
194
- /**
195
- * Get admin bar node and set as global for our usage.
196
- * Due to admin toolbar, this function need to run in frontend as well
197
- *
198
- * @return array||object $wp_admin_bar nodes.
199
- */
200
- function ppc_features_get_admin_bar_nodes($wp_admin_bar){
201
-
202
- $adminBarNode = is_object($wp_admin_bar) ? $wp_admin_bar->get_nodes() : '';
203
- $ppcAdminBar = [];
204
-
205
- if (is_array($adminBarNode) || is_object($adminBarNode)) {
206
- foreach ($adminBarNode as $adminBarnode) {
207
- $id = $adminBarnode->id;
208
- $title = $adminBarnode->title;
209
- $parent = $adminBarnode->parent;
210
- $ppcAdminBar[$id] = array('id' => $id, 'title' => $title, 'parent' => $parent);
211
- }
212
- }
213
-
214
- $GLOBALS['ppcAdminBar'] = $ppcAdminBar;
215
- }
216
- add_action('admin_bar_menu', 'ppc_features_get_admin_bar_nodes', 999);
217
-
218
- /**
219
- * Implement admin features restriction.
220
- * Due to admin toolbar, this function need to run in frontend as well
221
- *
222
- */
223
- function ppc_admin_feature_restrictions() {
224
- require_once ( dirname(CME_FILE) . '/includes/features/restrict-admin-features.php' );
225
- PP_Capabilities_Admin_Features::adminFeaturedRestriction();
226
- }
227
- add_action('plugins_loaded', 'ppc_admin_feature_restrictions');
228
-
229
- /**
230
- * List of capabilities admin pages
231
- *
232
- */
233
- function pp_capabilities_admin_pages(){
234
-
235
- $pp_capabilities_pages = [
236
- 'pp-capabilities',
237
- 'pp-capabilities-roles',
238
- 'pp-capabilities-admin-menus',
239
- 'pp-capabilities-nav-menus',
240
- 'pp-capabilities-editor-features',
241
- 'pp-capabilities-backup',
242
- 'pp-capabilities-settings',
243
- 'pp-capabilities-admin-features'
244
- ];
245
-
246
- return apply_filters('pp_capabilities_admin_pages', $pp_capabilities_pages);
247
- }
248
-
249
- /**
250
- * Check if user is in capabilities admin page
251
- *
252
- */
253
- function is_pp_capabilities_admin_page(){
254
-
255
- $pp_capabilities_pages = pp_capabilities_admin_pages();
256
-
257
- $is_pp_capabilities_page = false;
258
- if ( isset( $_GET['page'] ) && in_array( $_GET['page'], $pp_capabilities_pages )) {
259
- $is_pp_capabilities_page = true;
260
- }
261
-
262
- return apply_filters('is_pp_capabilities_admin_page', $is_pp_capabilities_page);
263
- }
186
  return class_exists('Classic_Editor')
187
  || function_exists( 'the_gutenberg_project' )
188
  || class_exists('Gutenberg_Ramp')
189
+ || version_compare($wp_version, '5.0', '<');
 
190
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/handler.php CHANGED
@@ -357,12 +357,17 @@ class CapsmanHandler
357
 
358
  // Add new capabilities to role
359
  foreach ( $add_caps as $cap => $grant ) {
360
- $blog_role->add_cap( $cap, $grant );
 
361
  }
362
 
363
  // Remove capabilities from role
364
  foreach ( $del_caps as $cap => $grant) {
365
- $blog_role->remove_cap($cap);
 
 
 
 
366
  }
367
  } else {
368
  $wp_roles->add_role( $role_name, $role_caption, $new_caps );
357
 
358
  // Add new capabilities to role
359
  foreach ( $add_caps as $cap => $grant ) {
360
+ $wp_roles->roles[$role_name]['capabilities'][$cap] = $grant;
361
+
362
  }
363
 
364
  // Remove capabilities from role
365
  foreach ( $del_caps as $cap => $grant) {
366
+ unset($wp_roles->roles[$role_name]['capabilities'][$cap]);
367
+ }
368
+
369
+ if ($wp_roles->use_db) {
370
+ update_option($wp_roles->role_key, $wp_roles->roles);
371
  }
372
  } else {
373
  $wp_roles->add_role( $role_name, $role_caption, $new_caps );
includes/manager.php CHANGED
@@ -178,7 +178,7 @@ class CapabilityManager
178
  if (empty($_REQUEST['page'])
179
  || !in_array(
180
  $_REQUEST['page'],
181
- ['pp-capabilities', 'pp-capabilities-roles', 'pp-capabilities-admin-menus', 'pp-capabilities-nav-menus', 'pp-capabilities-editor-features', 'pp-capabilities-backup', 'pp-capabilities-settings', 'pp-capabilities-admin-features']
182
  )
183
  ) {
184
  return;
@@ -201,7 +201,7 @@ class CapabilityManager
201
  'typeCapUnregistered' => __( 'Post type registration does not define this capability distinctly', 'capsman-enhanced' ),
202
  'capNegated' => __( 'This capability is explicitly negated. Click to add/remove normally.', 'capsman-enhanced' ),
203
  'chkCaption' => __( 'Add or remove this capability from the WordPress role', 'capsman-enhanced' ),
204
- 'switchableCaption' => __( 'Add or remove capability from the role normally', 'capsman-enhanced' ) ,
205
  'deleteWarning' => __( 'Are you sure you want to delete this item ?', 'capsman-enhanced' ),
206
  'saveWarning' => __( 'Add or clear custom item entry before saving changes.', 'capsman-enhanced' )
207
  ]
@@ -370,8 +370,6 @@ class CapabilityManager
370
 
371
  add_submenu_page('pp-capabilities', __('Editor Features', 'capsman-enhanced'), __('Editor Features', 'capsman-enhanced'), $cap_name, 'pp-capabilities-editor-features', [$this, 'ManageEditorFeatures']);
372
 
373
- add_submenu_page('pp-capabilities', __('Admin Features', 'capsman-enhanced'), __('Admin Features', 'capsman-enhanced'), $cap_name, 'pp-capabilities-admin-features', [$this, 'ManageAdminFeatures']);
374
-
375
  do_action('pp-capabilities-admin-submenus');
376
 
377
  add_submenu_page('pp-capabilities', __('Backup', 'capsman-enhanced'), __('Backup', 'capsman-enhanced'), $cap_name, 'pp-capabilities-backup', array($this, 'backupTool'));
@@ -444,12 +442,6 @@ class CapabilityManager
444
  require_once ( dirname(CME_FILE) . '/includes/roles/roles.php' );
445
  }
446
 
447
-
448
- /**
449
- * Manages Editor Features
450
- *
451
- * @return void
452
- */
453
  public function ManageEditorFeatures() {
454
  if ((!is_multisite() || !is_super_admin()) && !current_user_can('administrator') && !current_user_can('manage_capabilities')) {
455
  // TODO: Implement exceptions.
@@ -501,53 +493,6 @@ class CapabilityManager
501
  do_action('pp_capabilities_editor_features');
502
  include(dirname(CME_FILE) . '/includes/features/editor-features.php');
503
  }
504
-
505
- /**
506
- * Manages Admin Features
507
- *
508
- * @return void
509
- */
510
- public function ManageAdminFeatures() {
511
- if ((!is_multisite() || !is_super_admin()) && !current_user_can('administrator') && !current_user_can('manage_capabilities')) {
512
- // TODO: Implement exceptions.
513
- wp_die('<strong>' .__('You do not have permission to manage admin features.', 'capabilities-pro') . '</strong>');
514
- }
515
-
516
- $this->generateNames();
517
- $roles = array_keys($this->roles);
518
-
519
- if (!isset($this->current)) {
520
- if (empty($_POST) && !empty($_REQUEST['role'])) {
521
- $this->set_current_role($_REQUEST['role']);
522
- }
523
- }
524
-
525
- if (!isset($this->current) || !get_role($this->current)) {
526
- $this->current = get_option('default_role');
527
- }
528
-
529
- if (!in_array($this->current, $roles)) {
530
- $this->current = array_shift($roles);
531
- }
532
-
533
- if ('POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['ppc-admin-features-role'])) {
534
- $this->set_current_role($_POST['ppc-admin-features-role']);
535
-
536
- $disabled_admin_items = !empty(get_option('capsman_disabled_admin_features')) ? (array)get_option('capsman_disabled_admin_features') : [];
537
- $disabled_admin_items[$_POST['ppc-admin-features-role']] = isset($_POST['capsman_disabled_admin_features']) ? $_POST['capsman_disabled_admin_features'] : '';
538
-
539
- update_option('capsman_disabled_admin_features', $disabled_admin_items, false);
540
-
541
- //set reload option for instant reflection if user is updating own role
542
- if(in_array($_POST['ppc-admin-features-role'], wp_get_current_user()->roles)){
543
- $ppc_page_reload = '1';
544
- }
545
-
546
- ak_admin_notify(__('Settings updated.', 'capabilities-pro'));
547
- }
548
-
549
- include(dirname(CME_FILE) . '/includes/features/admin-features.php');
550
- }
551
 
552
  /**
553
  * Sets the 'manage_capabilities' cap to the administrator role.
@@ -575,7 +520,7 @@ class CapabilityManager
575
  {
576
  global $current_user;
577
 
578
- if (function_exists('wp_get_current_user') || defined('PP_CAPABILITIES_ROLES_FILTER_EARLY_EXECUTION')) { // Avoid downstream fatal error from premature current_user_can() call if get_editable_roles() is called too early
579
  $this->generateNames();
580
  $valid = array_keys($this->roles);
581
 
178
  if (empty($_REQUEST['page'])
179
  || !in_array(
180
  $_REQUEST['page'],
181
+ ['pp-capabilities', 'pp-capabilities-roles', 'pp-capabilities-admin-menus', 'pp-capabilities-nav-menus', 'pp-capabilities-editor-features', 'pp-capabilities-backup', 'pp-capabilities-settings']
182
  )
183
  ) {
184
  return;
201
  'typeCapUnregistered' => __( 'Post type registration does not define this capability distinctly', 'capsman-enhanced' ),
202
  'capNegated' => __( 'This capability is explicitly negated. Click to add/remove normally.', 'capsman-enhanced' ),
203
  'chkCaption' => __( 'Add or remove this capability from the WordPress role', 'capsman-enhanced' ),
204
+ 'switchableCaption' => __( 'Add or remove capability from the role normally', 'capsman-enhanced' ),
205
  'deleteWarning' => __( 'Are you sure you want to delete this item ?', 'capsman-enhanced' ),
206
  'saveWarning' => __( 'Add or clear custom item entry before saving changes.', 'capsman-enhanced' )
207
  ]
370
 
371
  add_submenu_page('pp-capabilities', __('Editor Features', 'capsman-enhanced'), __('Editor Features', 'capsman-enhanced'), $cap_name, 'pp-capabilities-editor-features', [$this, 'ManageEditorFeatures']);
372
 
 
 
373
  do_action('pp-capabilities-admin-submenus');
374
 
375
  add_submenu_page('pp-capabilities', __('Backup', 'capsman-enhanced'), __('Backup', 'capsman-enhanced'), $cap_name, 'pp-capabilities-backup', array($this, 'backupTool'));
442
  require_once ( dirname(CME_FILE) . '/includes/roles/roles.php' );
443
  }
444
 
 
 
 
 
 
 
445
  public function ManageEditorFeatures() {
446
  if ((!is_multisite() || !is_super_admin()) && !current_user_can('administrator') && !current_user_can('manage_capabilities')) {
447
  // TODO: Implement exceptions.
493
  do_action('pp_capabilities_editor_features');
494
  include(dirname(CME_FILE) . '/includes/features/editor-features.php');
495
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
496
 
497
  /**
498
  * Sets the 'manage_capabilities' cap to the administrator role.
520
  {
521
  global $current_user;
522
 
523
+ if (function_exists('wp_get_current_user')) { // Avoid downstream fatal error from premature current_user_can() call if get_editable_roles() is called too early
524
  $this->generateNames();
525
  $valid = array_keys($this->roles);
526
 
readme.txt CHANGED
@@ -1,4 +1,4 @@
1
- === PublishPress Capabilities - User Role Access, Editor Permissions, Admin Menus ===
2
 
3
  Contributors: publishpress, kevinB, stevejburge, andergmartins
4
  Author: PublishPress
@@ -7,7 +7,7 @@ Tags: user roles, capabilities, permissions, admin menus, post editing, post typ
7
  Requires at least: 4.9.7
8
  Tested up to: 5.8
9
  Requires PHP: 5.6.20
10
- Stable tag: 2.3.1
11
  License: GPLv3
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
13
 
@@ -35,16 +35,15 @@ PublishPress Capabilities is **safe to use**. Every time you change your site's
35
  1. **User role editor**: You can change the capabilities for any role.
36
  2. **Works for all post types**: Choose who can Publish, Read, Edit and Delete content for any post type.
37
  3. **Works for all taxonomies**: Choose who can Manage, Edit and Assign terms in any taxonomy.
38
- 4. **Hide admin area features**: Remove items from the WordPress toolbar, plus dashboard widgets.
39
- 5. **Hide editor features**: Decide what users see when they're writing posts in Gutenberg or the Classic Editor.
40
- 6. **Hide editor metaboxes (Pro version)**: You can hide metaboxes on the post editing screen.
41
- 7. **Safe backups**: Every time you change your permissions, PublishPress Capabilities saves a backup.
42
- 8. **Create or copy user roles**: Add new roles, or clone existing roles.
43
- 9. **Frontend menus (Pro version)**: Stop users from accessing any frontend menu link.
44
- 10. **Admin menus (Pro version)**: Stop users from accessing any admin menu link.
45
- 11. **Media library permissions**: Decide who can upload, edit and delete files.
46
- 12. **WooCommerce permissions**: Control access to WooCommerce products, orders, coupons and more.
47
- 13. **Multisite support**: Manage permissions on a single site or across your whole network.
48
 
49
  ## #1. WordPress User Role Editor ##
50
 
@@ -66,25 +65,19 @@ PublishPress Capabilities enables you to add extra permissions to the taxonomies
66
 
67
  [Click here to learn about taxonomy permissions](https://publishpress.com/knowledge-base/taxonomy-specific-capabilities/).
68
 
69
- ## #4. Hide Toolbar Link and Dashboard Widgets ##
70
-
71
- “Admin Features” allows you to hide features in the WordPress admin area and toolbar. You can decide what users see in your WordPress dashboard. You can use this option to hide all the links in the toolbar including "About WordPress", "Visit Site" and more. You can also hide dashboard widgets such as "At a Glance", "Quick Draft", and "WordPress Events and News".
72
-
73
- [Click here to learn about removing toolbar items and dashboard widgets](https://publishpress.com/knowledge-base/how-to-use-admin-features/).
74
-
75
- ## #5. Hide Gutenberg and Classic Editor Features ##
76
 
77
  PublishPress Capabilities has an option called "Editor Features" allows you to clean up the post editing screen. You can decide what users see when they're writing posts. You can hide anything on the Gutenberg or Classic Editor screens. You can hide boxes inside the sidebadd such Tags, Categories, or Excerpt. You can the "Publish" button. You can even hide the post title, body, or permalink. This is a great alternative to plugins such as Adminimize.
78
 
79
  [Click here to learn about hiding editor features](https://publishpress.com/knowledge-base/editor-features/).
80
 
81
- ## #6. Hide Metaboxes in WordPress Posts ##
82
 
83
  WordPress has a feature called “metaboxes”. This is a strange name, but you have seen them often if you use WordPress. When a user edits a post, the edit screen has several default boxes: Status & visibility, Featured image, Categories, Tags, etc. These boxes are metaboxes. Plugins can add also add their own metaboxes. The Pro version of the PublishPress Capabilities plugin allows you to hide metaboxes for specific user roles.
84
 
85
  [Click here to learn about hiding metaboxes](https://publishpress.com/knowledge-base/hide-metaboxes-in-wordpress-posts/).
86
 
87
- ## #7. Backup and Restore User Roles and Capabilities ##
88
 
89
  PublishPress Capabilities offers you the ability to back up and restore your permissions. This feature is very helpful if you want to test out changes on your site, or if you've installed a new plugin that has changed your site's permissions.
90
 
@@ -92,37 +85,37 @@ Every time you change your permissions, the PublishPress Capabilities plugin wil
92
 
93
  [Click here to see how to backup permissions](https://publishpress.com/knowledge-base/backup-restore-permissions/).
94
 
95
- ## #8. Create New User Roles or Copy User Roles ##
96
 
97
  With PublishPress Capabilities you can create or copy any existing WordPress user role. These roles can be customized in exactly the same way as the default WordPress roles. These new roles can be added to single sites or to an entire multisite network.
98
 
99
  [Click here to see how to create or copy user roles](https://publishpress.com/knowledge-base/create-or-copy-user-roles/).
100
 
101
- ## #9. Frontend Menu Restrictions (Pro version) ##
102
 
103
  PublishPress Capabilities enables you to restrict access to navigation menus by roles, logged in and logged out users. This is useful because a default WordPress site does not give you way to control the visibility of your links.
104
 
105
  [Click to see how to block frontend menu access](https://publishpress.com/knowledge-base/nav-menus/).
106
 
107
- ## #10. WordPress Admin Menu Restrictions (Pro version) ##
108
 
109
  With PublishPress Capabilities you can restrict access to admin menu screens by user roles. This is useful because many plugin do not have any way to control who can access their admin screens.
110
 
111
  [Click to see how to block Admin menu access](https://publishpress.com/knowledge-base/admin-menus/).
112
 
113
- ## #11. Support for Media Library Permissions ##
114
 
115
  PublishPress Capabilities enables you to decide who can upload, edit and delete files from your site's Media Library. By default, only Administrators are able to delete files in your Media Library. Subscribers and Contributors are not even allowed to upload files. You can customize these permissions for the Media Library and also the Featured Image box.
116
 
117
  [Click here to learn about Media Library permissions](https://publishpress.com/knowledge-base/control-media-library-access/).
118
 
119
- ## #12. Support for WooCommerce Permissions ##
120
 
121
  We mentioned earlier that PublishPress Capabilities has special support for WooCommerce taxonomies. This is true for the rest of WooCommerce also. With PublishPress Capabilities you can control permissions for WooCommerce products, orders and coupons.
122
 
123
  [Click here to learn about WooCommerce permissions](https://publishpress.com/knowledge-base/woocommerce-permissons/).
124
 
125
- ## #13. WordPress Multisite support ##
126
 
127
  PublishPress Capabilities allows you to control permissions on a single site or across your whole network. Every time you update permissions in PublishPress Capabilities, you can choose to sync those changes across your multisite network.
128
 
@@ -397,25 +390,16 @@ Common and incorrect typos include Capabilitise, Cpabilities, Capabiliites, Cspa
397
  10. Navigation Menu Restrictions: PublishPress Capabilities enables you to restrict access to navigation menus by roles, logged in and logged out users.
398
  11. Admin Menu Restrictions: With PublishPress Capabilities you can restrict access to admin menu screens by user roles.
399
  12. Editor Feature Restriction: PublishPress Capabilities enables you to decide what users see when they're writing posts.
400
- 13. Admin Feature Restriction: PublishPress Capabilities enables you remove items from the WordPress toolbar, plus dashboard widgets.
401
 
402
  == Upgrade Notice ==
403
 
404
  = 1.5.1 =
405
  Fixed : Non-administrators with user editing capabilities could add new Administrators
406
 
407
- = 2.3.1 =
408
- Fixed : Security issue. Please update.
409
-
410
  == Changelog ==
411
-
412
- = 2.3.1 - 6 Dec 2021 =
413
  * Fixed : Security issue
414
- * Fixed : PHP Notice on Capabilities screen
415
-
416
- = 2.3 - 28 Oct 2021 =
417
- * Change : Role Capabilities screen uses tabs
418
- * Feature : New "Admin Features" screen #200
419
 
420
  = 2.2 - 26 Aug 2021 =
421
  * Feature : Retain last role selection for Capabilities, Editor Features screens
@@ -436,7 +420,7 @@ Fixed : Security issue. Please update.
436
  * Compat : PublishPress - Authors without publish capability could directly publish on the Calendar screen
437
  * Change : Permissions - Hide / Unhide Role setting moved to Roles screen row actions
438
 
439
- = 2.0 - 18 Feb 2020 =
440
  * Feature : Roles screen
441
  * Feature : Multiple role assignment on Add / Edit User screen
442
  * Lang : Fixed handling, activated partial translations in German, Italian, Russian, Spanish, Swedish, Belarusian, Catalan
1
+ === PublishPress Capabilities - User Roles, Editor Permissions, Admin Menus ===
2
 
3
  Contributors: publishpress, kevinB, stevejburge, andergmartins
4
  Author: PublishPress
7
  Requires at least: 4.9.7
8
  Tested up to: 5.8
9
  Requires PHP: 5.6.20
10
+ Stable tag: 2.2.1
11
  License: GPLv3
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
13
 
35
  1. **User role editor**: You can change the capabilities for any role.
36
  2. **Works for all post types**: Choose who can Publish, Read, Edit and Delete content for any post type.
37
  3. **Works for all taxonomies**: Choose who can Manage, Edit and Assign terms in any taxonomy.
38
+ 4. **Hide editor features**: Decide what users see when they're writing posts in Gutenberg or the Classic Editor.
39
+ 5. **Hide editor metaboxes (Pro version)**: You can hide metaboxes on the post editing screen.
40
+ 6. **Safe backups**: Every time you change your permissions, PublishPress Capabilities saves a backup.
41
+ 7. **Create or copy user roles**: Add new roles, or clone existing roles.
42
+ 8. **Frontend menus (Pro version)**: Stop users from accessing any frontend menu link.
43
+ 8. **Admin menus (Pro version)**: Stop users from accessing any admin menu link.
44
+ 10. **Media library permissions**: Decide who can upload, edit and delete files.
45
+ 11. **WooCommerce permissions**: Control access to WooCommerce products, orders, coupons and more.
46
+ 12. **Multisite support**: Manage permissions on a single site or across your whole network.
 
47
 
48
  ## #1. WordPress User Role Editor ##
49
 
65
 
66
  [Click here to learn about taxonomy permissions](https://publishpress.com/knowledge-base/taxonomy-specific-capabilities/).
67
 
68
+ ## #4. Hide Gutenberg and Classic Editor Features ##
 
 
 
 
 
 
69
 
70
  PublishPress Capabilities has an option called "Editor Features" allows you to clean up the post editing screen. You can decide what users see when they're writing posts. You can hide anything on the Gutenberg or Classic Editor screens. You can hide boxes inside the sidebadd such Tags, Categories, or Excerpt. You can the "Publish" button. You can even hide the post title, body, or permalink. This is a great alternative to plugins such as Adminimize.
71
 
72
  [Click here to learn about hiding editor features](https://publishpress.com/knowledge-base/editor-features/).
73
 
74
+ ## #5. Hide Metaboxes in WordPress Posts ##
75
 
76
  WordPress has a feature called “metaboxes”. This is a strange name, but you have seen them often if you use WordPress. When a user edits a post, the edit screen has several default boxes: Status & visibility, Featured image, Categories, Tags, etc. These boxes are metaboxes. Plugins can add also add their own metaboxes. The Pro version of the PublishPress Capabilities plugin allows you to hide metaboxes for specific user roles.
77
 
78
  [Click here to learn about hiding metaboxes](https://publishpress.com/knowledge-base/hide-metaboxes-in-wordpress-posts/).
79
 
80
+ ## #6. Backup and Restore User Roles and Capabilities ##
81
 
82
  PublishPress Capabilities offers you the ability to back up and restore your permissions. This feature is very helpful if you want to test out changes on your site, or if you've installed a new plugin that has changed your site's permissions.
83
 
85
 
86
  [Click here to see how to backup permissions](https://publishpress.com/knowledge-base/backup-restore-permissions/).
87
 
88
+ ## #7. Create New User Roles or Copy User Roles ##
89
 
90
  With PublishPress Capabilities you can create or copy any existing WordPress user role. These roles can be customized in exactly the same way as the default WordPress roles. These new roles can be added to single sites or to an entire multisite network.
91
 
92
  [Click here to see how to create or copy user roles](https://publishpress.com/knowledge-base/create-or-copy-user-roles/).
93
 
94
+ ## #8. Frontend Menu Restrictions (Pro version) ##
95
 
96
  PublishPress Capabilities enables you to restrict access to navigation menus by roles, logged in and logged out users. This is useful because a default WordPress site does not give you way to control the visibility of your links.
97
 
98
  [Click to see how to block frontend menu access](https://publishpress.com/knowledge-base/nav-menus/).
99
 
100
+ ## #9. WordPress Admin Menu Restrictions (Pro version) ##
101
 
102
  With PublishPress Capabilities you can restrict access to admin menu screens by user roles. This is useful because many plugin do not have any way to control who can access their admin screens.
103
 
104
  [Click to see how to block Admin menu access](https://publishpress.com/knowledge-base/admin-menus/).
105
 
106
+ ## #10. Support for Media Library Permissions ##
107
 
108
  PublishPress Capabilities enables you to decide who can upload, edit and delete files from your site's Media Library. By default, only Administrators are able to delete files in your Media Library. Subscribers and Contributors are not even allowed to upload files. You can customize these permissions for the Media Library and also the Featured Image box.
109
 
110
  [Click here to learn about Media Library permissions](https://publishpress.com/knowledge-base/control-media-library-access/).
111
 
112
+ ## #11. Support for WooCommerce Permissions ##
113
 
114
  We mentioned earlier that PublishPress Capabilities has special support for WooCommerce taxonomies. This is true for the rest of WooCommerce also. With PublishPress Capabilities you can control permissions for WooCommerce products, orders and coupons.
115
 
116
  [Click here to learn about WooCommerce permissions](https://publishpress.com/knowledge-base/woocommerce-permissons/).
117
 
118
+ ## #12. WordPress Multisite support ##
119
 
120
  PublishPress Capabilities allows you to control permissions on a single site or across your whole network. Every time you update permissions in PublishPress Capabilities, you can choose to sync those changes across your multisite network.
121
 
390
  10. Navigation Menu Restrictions: PublishPress Capabilities enables you to restrict access to navigation menus by roles, logged in and logged out users.
391
  11. Admin Menu Restrictions: With PublishPress Capabilities you can restrict access to admin menu screens by user roles.
392
  12. Editor Feature Restriction: PublishPress Capabilities enables you to decide what users see when they're writing posts.
393
+
394
 
395
  == Upgrade Notice ==
396
 
397
  = 1.5.1 =
398
  Fixed : Non-administrators with user editing capabilities could add new Administrators
399
 
 
 
 
400
  == Changelog ==
401
+ = 2.2.1 - 8 Dec 2021 =
 
402
  * Fixed : Security issue
 
 
 
 
 
403
 
404
  = 2.2 - 26 Aug 2021 =
405
  * Feature : Retain last role selection for Capabilities, Editor Features screens
420
  * Compat : PublishPress - Authors without publish capability could directly publish on the Calendar screen
421
  * Change : Permissions - Hide / Unhide Role setting moved to Roles screen row actions
422
 
423
+ = 2.0 - 18 Feb 2021 =
424
  * Feature : Roles screen
425
  * Feature : Multiple role assignment on Add / Edit User screen
426
  * Lang : Fixed handling, activated partial translations in German, Italian, Russian, Spanish, Swedish, Belarusian, Catalan
vendor/publishpress/wordpress-reviews/LICENSE DELETED
@@ -1,674 +0,0 @@
1
- GNU GENERAL PUBLIC LICENSE
2
- Version 3, 29 June 2007
3
-
4
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
- Everyone is permitted to copy and distribute verbatim copies
6
- of this license document, but changing it is not allowed.
7
-
8
- Preamble
9
-
10
- The GNU General Public License is a free, copyleft license for
11
- software and other kinds of works.
12
-
13
- The licenses for most software and other practical works are designed
14
- to take away your freedom to share and change the works. By contrast,
15
- the GNU General Public License is intended to guarantee your freedom to
16
- share and change all versions of a program--to make sure it remains free
17
- software for all its users. We, the Free Software Foundation, use the
18
- GNU General Public License for most of our software; it applies also to
19
- any other work released this way by its authors. You can apply it to
20
- your programs, too.
21
-
22
- When we speak of free software, we are referring to freedom, not
23
- price. Our General Public Licenses are designed to make sure that you
24
- have the freedom to distribute copies of free software (and charge for
25
- them if you wish), that you receive source code or can get it if you
26
- want it, that you can change the software or use pieces of it in new
27
- free programs, and that you know you can do these things.
28
-
29
- To protect your rights, we need to prevent others from denying you
30
- these rights or asking you to surrender the rights. Therefore, you have
31
- certain responsibilities if you distribute copies of the software, or if
32
- you modify it: responsibilities to respect the freedom of others.
33
-
34
- For example, if you distribute copies of such a program, whether
35
- gratis or for a fee, you must pass on to the recipients the same
36
- freedoms that you received. You must make sure that they, too, receive
37
- or can get the source code. And you must show them these terms so they
38
- know their rights.
39
-
40
- Developers that use the GNU GPL protect your rights with two steps:
41
- (1) assert copyright on the software, and (2) offer you this License
42
- giving you legal permission to copy, distribute and/or modify it.
43
-
44
- For the developers' and authors' protection, the GPL clearly explains
45
- that there is no warranty for this free software. For both users' and
46
- authors' sake, the GPL requires that modified versions be marked as
47
- changed, so that their problems will not be attributed erroneously to
48
- authors of previous versions.
49
-
50
- Some devices are designed to deny users access to install or run
51
- modified versions of the software inside them, although the manufacturer
52
- can do so. This is fundamentally incompatible with the aim of
53
- protecting users' freedom to change the software. The systematic
54
- pattern of such abuse occurs in the area of products for individuals to
55
- use, which is precisely where it is most unacceptable. Therefore, we
56
- have designed this version of the GPL to prohibit the practice for those
57
- products. If such problems arise substantially in other domains, we
58
- stand ready to extend this provision to those domains in future versions
59
- of the GPL, as needed to protect the freedom of users.
60
-
61
- Finally, every program is threatened constantly by software patents.
62
- States should not allow patents to restrict development and use of
63
- software on general-purpose computers, but in those that do, we wish to
64
- avoid the special danger that patents applied to a free program could
65
- make it effectively proprietary. To prevent this, the GPL assures that
66
- patents cannot be used to render the program non-free.
67
-
68
- The precise terms and conditions for copying, distribution and
69
- modification follow.
70
-
71
- TERMS AND CONDITIONS
72
-
73
- 0. Definitions.
74
-
75
- "This License" refers to version 3 of the GNU General Public License.
76
-
77
- "Copyright" also means copyright-like laws that apply to other kinds of
78
- works, such as semiconductor masks.
79
-
80
- "The Program" refers to any copyrightable work licensed under this
81
- License. Each licensee is addressed as "you". "Licensees" and
82
- "recipients" may be individuals or organizations.
83
-
84
- To "modify" a work means to copy from or adapt all or part of the work
85
- in a fashion requiring copyright permission, other than the making of an
86
- exact copy. The resulting work is called a "modified version" of the
87
- earlier work or a work "based on" the earlier work.
88
-
89
- A "covered work" means either the unmodified Program or a work based
90
- on the Program.
91
-
92
- To "propagate" a work means to do anything with it that, without
93
- permission, would make you directly or secondarily liable for
94
- infringement under applicable copyright law, except executing it on a
95
- computer or modifying a private copy. Propagation includes copying,
96
- distribution (with or without modification), making available to the
97
- public, and in some countries other activities as well.
98
-
99
- To "convey" a work means any kind of propagation that enables other
100
- parties to make or receive copies. Mere interaction with a user through
101
- a computer network, with no transfer of a copy, is not conveying.
102
-
103
- An interactive user interface displays "Appropriate Legal Notices"
104
- to the extent that it includes a convenient and prominently visible
105
- feature that (1) displays an appropriate copyright notice, and (2)
106
- tells the user that there is no warranty for the work (except to the
107
- extent that warranties are provided), that licensees may convey the
108
- work under this License, and how to view a copy of this License. If
109
- the interface presents a list of user commands or options, such as a
110
- menu, a prominent item in the list meets this criterion.
111
-
112
- 1. Source Code.
113
-
114
- The "source code" for a work means the preferred form of the work
115
- for making modifications to it. "Object code" means any non-source
116
- form of a work.
117
-
118
- A "Standard Interface" means an interface that either is an official
119
- standard defined by a recognized standards body, or, in the case of
120
- interfaces specified for a particular programming language, one that
121
- is widely used among developers working in that language.
122
-
123
- The "System Libraries" of an executable work include anything, other
124
- than the work as a whole, that (a) is included in the normal form of
125
- packaging a Major Component, but which is not part of that Major
126
- Component, and (b) serves only to enable use of the work with that
127
- Major Component, or to implement a Standard Interface for which an
128
- implementation is available to the public in source code form. A
129
- "Major Component", in this context, means a major essential component
130
- (kernel, window system, and so on) of the specific operating system
131
- (if any) on which the executable work runs, or a compiler used to
132
- produce the work, or an object code interpreter used to run it.
133
-
134
- The "Corresponding Source" for a work in object code form means all
135
- the source code needed to generate, install, and (for an executable
136
- work) run the object code and to modify the work, including scripts to
137
- control those activities. However, it does not include the work's
138
- System Libraries, or general-purpose tools or generally available free
139
- programs which are used unmodified in performing those activities but
140
- which are not part of the work. For example, Corresponding Source
141
- includes interface definition files associated with source files for
142
- the work, and the source code for shared libraries and dynamically
143
- linked subprograms that the work is specifically designed to require,
144
- such as by intimate data communication or control flow between those
145
- subprograms and other parts of the work.
146
-
147
- The Corresponding Source need not include anything that users
148
- can regenerate automatically from other parts of the Corresponding
149
- Source.
150
-
151
- The Corresponding Source for a work in source code form is that
152
- same work.
153
-
154
- 2. Basic Permissions.
155
-
156
- All rights granted under this License are granted for the term of
157
- copyright on the Program, and are irrevocable provided the stated
158
- conditions are met. This License explicitly affirms your unlimited
159
- permission to run the unmodified Program. The output from running a
160
- covered work is covered by this License only if the output, given its
161
- content, constitutes a covered work. This License acknowledges your
162
- rights of fair use or other equivalent, as provided by copyright law.
163
-
164
- You may make, run and propagate covered works that you do not
165
- convey, without conditions so long as your license otherwise remains
166
- in force. You may convey covered works to others for the sole purpose
167
- of having them make modifications exclusively for you, or provide you
168
- with facilities for running those works, provided that you comply with
169
- the terms of this License in conveying all material for which you do
170
- not control copyright. Those thus making or running the covered works
171
- for you must do so exclusively on your behalf, under your direction
172
- and control, on terms that prohibit them from making any copies of
173
- your copyrighted material outside their relationship with you.
174
-
175
- Conveying under any other circumstances is permitted solely under
176
- the conditions stated below. Sublicensing is not allowed; section 10
177
- makes it unnecessary.
178
-
179
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
-
181
- No covered work shall be deemed part of an effective technological
182
- measure under any applicable law fulfilling obligations under article
183
- 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
- similar laws prohibiting or restricting circumvention of such
185
- measures.
186
-
187
- When you convey a covered work, you waive any legal power to forbid
188
- circumvention of technological measures to the extent such circumvention
189
- is effected by exercising rights under this License with respect to
190
- the covered work, and you disclaim any intention to limit operation or
191
- modification of the work as a means of enforcing, against the work's
192
- users, your or third parties' legal rights to forbid circumvention of
193
- technological measures.
194
-
195
- 4. Conveying Verbatim Copies.
196
-
197
- You may convey verbatim copies of the Program's source code as you
198
- receive it, in any medium, provided that you conspicuously and
199
- appropriately publish on each copy an appropriate copyright notice;
200
- keep intact all notices stating that this License and any
201
- non-permissive terms added in accord with section 7 apply to the code;
202
- keep intact all notices of the absence of any warranty; and give all
203
- recipients a copy of this License along with the Program.
204
-
205
- You may charge any price or no price for each copy that you convey,
206
- and you may offer support or warranty protection for a fee.
207
-
208
- 5. Conveying Modified Source Versions.
209
-
210
- You may convey a work based on the Program, or the modifications to
211
- produce it from the Program, in the form of source code under the
212
- terms of section 4, provided that you also meet all of these conditions:
213
-
214
- a) The work must carry prominent notices stating that you modified
215
- it, and giving a relevant date.
216
-
217
- b) The work must carry prominent notices stating that it is
218
- released under this License and any conditions added under section
219
- 7. This requirement modifies the requirement in section 4 to
220
- "keep intact all notices".
221
-
222
- c) You must license the entire work, as a whole, under this
223
- License to anyone who comes into possession of a copy. This
224
- License will therefore apply, along with any applicable section 7
225
- additional terms, to the whole of the work, and all its parts,
226
- regardless of how they are packaged. This License gives no
227
- permission to license the work in any other way, but it does not
228
- invalidate such permission if you have separately received it.
229
-
230
- d) If the work has interactive user interfaces, each must display
231
- Appropriate Legal Notices; however, if the Program has interactive
232
- interfaces that do not display Appropriate Legal Notices, your
233
- work need not make them do so.
234
-
235
- A compilation of a covered work with other separate and independent
236
- works, which are not by their nature extensions of the covered work,
237
- and which are not combined with it such as to form a larger program,
238
- in or on a volume of a storage or distribution medium, is called an
239
- "aggregate" if the compilation and its resulting copyright are not
240
- used to limit the access or legal rights of the compilation's users
241
- beyond what the individual works permit. Inclusion of a covered work
242
- in an aggregate does not cause this License to apply to the other
243
- parts of the aggregate.
244
-
245
- 6. Conveying Non-Source Forms.
246
-
247
- You may convey a covered work in object code form under the terms
248
- of sections 4 and 5, provided that you also convey the
249
- machine-readable Corresponding Source under the terms of this License,
250
- in one of these ways:
251
-
252
- a) Convey the object code in, or embodied in, a physical product
253
- (including a physical distribution medium), accompanied by the
254
- Corresponding Source fixed on a durable physical medium
255
- customarily used for software interchange.
256
-
257
- b) Convey the object code in, or embodied in, a physical product
258
- (including a physical distribution medium), accompanied by a
259
- written offer, valid for at least three years and valid for as
260
- long as you offer spare parts or customer support for that product
261
- model, to give anyone who possesses the object code either (1) a
262
- copy of the Corresponding Source for all the software in the
263
- product that is covered by this License, on a durable physical
264
- medium customarily used for software interchange, for a price no
265
- more than your reasonable cost of physically performing this
266
- conveying of source, or (2) access to copy the
267
- Corresponding Source from a network server at no charge.
268
-
269
- c) Convey individual copies of the object code with a copy of the
270
- written offer to provide the Corresponding Source. This
271
- alternative is allowed only occasionally and noncommercially, and
272
- only if you received the object code with such an offer, in accord
273
- with subsection 6b.
274
-
275
- d) Convey the object code by offering access from a designated
276
- place (gratis or for a charge), and offer equivalent access to the
277
- Corresponding Source in the same way through the same place at no
278
- further charge. You need not require recipients to copy the
279
- Corresponding Source along with the object code. If the place to
280
- copy the object code is a network server, the Corresponding Source
281
- may be on a different server (operated by you or a third party)
282
- that supports equivalent copying facilities, provided you maintain
283
- clear directions next to the object code saying where to find the
284
- Corresponding Source. Regardless of what server hosts the
285
- Corresponding Source, you remain obligated to ensure that it is
286
- available for as long as needed to satisfy these requirements.
287
-
288
- e) Convey the object code using peer-to-peer transmission, provided
289
- you inform other peers where the object code and Corresponding
290
- Source of the work are being offered to the general public at no
291
- charge under subsection 6d.
292
-
293
- A separable portion of the object code, whose source code is excluded
294
- from the Corresponding Source as a System Library, need not be
295
- included in conveying the object code work.
296
-
297
- A "User Product" is either (1) a "consumer product", which means any
298
- tangible personal property which is normally used for personal, family,
299
- or household purposes, or (2) anything designed or sold for incorporation
300
- into a dwelling. In determining whether a product is a consumer product,
301
- doubtful cases shall be resolved in favor of coverage. For a particular
302
- product received by a particular user, "normally used" refers to a
303
- typical or common use of that class of product, regardless of the status
304
- of the particular user or of the way in which the particular user
305
- actually uses, or expects or is expected to use, the product. A product
306
- is a consumer product regardless of whether the product has substantial
307
- commercial, industrial or non-consumer uses, unless such uses represent
308
- the only significant mode of use of the product.
309
-
310
- "Installation Information" for a User Product means any methods,
311
- procedures, authorization keys, or other information required to install
312
- and execute modified versions of a covered work in that User Product from
313
- a modified version of its Corresponding Source. The information must
314
- suffice to ensure that the continued functioning of the modified object
315
- code is in no case prevented or interfered with solely because
316
- modification has been made.
317
-
318
- If you convey an object code work under this section in, or with, or
319
- specifically for use in, a User Product, and the conveying occurs as
320
- part of a transaction in which the right of possession and use of the
321
- User Product is transferred to the recipient in perpetuity or for a
322
- fixed term (regardless of how the transaction is characterized), the
323
- Corresponding Source conveyed under this section must be accompanied
324
- by the Installation Information. But this requirement does not apply
325
- if neither you nor any third party retains the ability to install
326
- modified object code on the User Product (for example, the work has
327
- been installed in ROM).
328
-
329
- The requirement to provide Installation Information does not include a
330
- requirement to continue to provide support service, warranty, or updates
331
- for a work that has been modified or installed by the recipient, or for
332
- the User Product in which it has been modified or installed. Access to a
333
- network may be denied when the modification itself materially and
334
- adversely affects the operation of the network or violates the rules and
335
- protocols for communication across the network.
336
-
337
- Corresponding Source conveyed, and Installation Information provided,
338
- in accord with this section must be in a format that is publicly
339
- documented (and with an implementation available to the public in
340
- source code form), and must require no special password or key for
341
- unpacking, reading or copying.
342
-
343
- 7. Additional Terms.
344
-
345
- "Additional permissions" are terms that supplement the terms of this
346
- License by making exceptions from one or more of its conditions.
347
- Additional permissions that are applicable to the entire Program shall
348
- be treated as though they were included in this License, to the extent
349
- that they are valid under applicable law. If additional permissions
350
- apply only to part of the Program, that part may be used separately
351
- under those permissions, but the entire Program remains governed by
352
- this License without regard to the additional permissions.
353
-
354
- When you convey a copy of a covered work, you may at your option
355
- remove any additional permissions from that copy, or from any part of
356
- it. (Additional permissions may be written to require their own
357
- removal in certain cases when you modify the work.) You may place
358
- additional permissions on material, added by you to a covered work,
359
- for which you have or can give appropriate copyright permission.
360
-
361
- Notwithstanding any other provision of this License, for material you
362
- add to a covered work, you may (if authorized by the copyright holders of
363
- that material) supplement the terms of this License with terms:
364
-
365
- a) Disclaiming warranty or limiting liability differently from the
366
- terms of sections 15 and 16 of this License; or
367
-
368
- b) Requiring preservation of specified reasonable legal notices or
369
- author attributions in that material or in the Appropriate Legal
370
- Notices displayed by works containing it; or
371
-
372
- c) Prohibiting misrepresentation of the origin of that material, or
373
- requiring that modified versions of such material be marked in
374
- reasonable ways as different from the original version; or
375
-
376
- d) Limiting the use for publicity purposes of names of licensors or
377
- authors of the material; or
378
-
379
- e) Declining to grant rights under trademark law for use of some
380
- trade names, trademarks, or service marks; or
381
-
382
- f) Requiring indemnification of licensors and authors of that
383
- material by anyone who conveys the material (or modified versions of
384
- it) with contractual assumptions of liability to the recipient, for
385
- any liability that these contractual assumptions directly impose on
386
- those licensors and authors.
387
-
388
- All other non-permissive additional terms are considered "further
389
- restrictions" within the meaning of section 10. If the Program as you
390
- received it, or any part of it, contains a notice stating that it is
391
- governed by this License along with a term that is a further
392
- restriction, you may remove that term. If a license document contains
393
- a further restriction but permits relicensing or conveying under this
394
- License, you may add to a covered work material governed by the terms
395
- of that license document, provided that the further restriction does
396
- not survive such relicensing or conveying.
397
-
398
- If you add terms to a covered work in accord with this section, you
399
- must place, in the relevant source files, a statement of the
400
- additional terms that apply to those files, or a notice indicating
401
- where to find the applicable terms.
402
-
403
- Additional terms, permissive or non-permissive, may be stated in the
404
- form of a separately written license, or stated as exceptions;
405
- the above requirements apply either way.
406
-
407
- 8. Termination.
408
-
409
- You may not propagate or modify a covered work except as expressly
410
- provided under this License. Any attempt otherwise to propagate or
411
- modify it is void, and will automatically terminate your rights under
412
- this License (including any patent licenses granted under the third
413
- paragraph of section 11).
414
-
415
- However, if you cease all violation of this License, then your
416
- license from a particular copyright holder is reinstated (a)
417
- provisionally, unless and until the copyright holder explicitly and
418
- finally terminates your license, and (b) permanently, if the copyright
419
- holder fails to notify you of the violation by some reasonable means
420
- prior to 60 days after the cessation.
421
-
422
- Moreover, your license from a particular copyright holder is
423
- reinstated permanently if the copyright holder notifies you of the
424
- violation by some reasonable means, this is the first time you have
425
- received notice of violation of this License (for any work) from that
426
- copyright holder, and you cure the violation prior to 30 days after
427
- your receipt of the notice.
428
-
429
- Termination of your rights under this section does not terminate the
430
- licenses of parties who have received copies or rights from you under
431
- this License. If your rights have been terminated and not permanently
432
- reinstated, you do not qualify to receive new licenses for the same
433
- material under section 10.
434
-
435
- 9. Acceptance Not Required for Having Copies.
436
-
437
- You are not required to accept this License in order to receive or
438
- run a copy of the Program. Ancillary propagation of a covered work
439
- occurring solely as a consequence of using peer-to-peer transmission
440
- to receive a copy likewise does not require acceptance. However,
441
- nothing other than this License grants you permission to propagate or
442
- modify any covered work. These actions infringe copyright if you do
443
- not accept this License. Therefore, by modifying or propagating a
444
- covered work, you indicate your acceptance of this License to do so.
445
-
446
- 10. Automatic Licensing of Downstream Recipients.
447
-
448
- Each time you convey a covered work, the recipient automatically
449
- receives a license from the original licensors, to run, modify and
450
- propagate that work, subject to this License. You are not responsible
451
- for enforcing compliance by third parties with this License.
452
-
453
- An "entity transaction" is a transaction transferring control of an
454
- organization, or substantially all assets of one, or subdividing an
455
- organization, or merging organizations. If propagation of a covered
456
- work results from an entity transaction, each party to that
457
- transaction who receives a copy of the work also receives whatever
458
- licenses to the work the party's predecessor in interest had or could
459
- give under the previous paragraph, plus a right to possession of the
460
- Corresponding Source of the work from the predecessor in interest, if
461
- the predecessor has it or can get it with reasonable efforts.
462
-
463
- You may not impose any further restrictions on the exercise of the
464
- rights granted or affirmed under this License. For example, you may
465
- not impose a license fee, royalty, or other charge for exercise of
466
- rights granted under this License, and you may not initiate litigation
467
- (including a cross-claim or counterclaim in a lawsuit) alleging that
468
- any patent claim is infringed by making, using, selling, offering for
469
- sale, or importing the Program or any portion of it.
470
-
471
- 11. Patents.
472
-
473
- A "contributor" is a copyright holder who authorizes use under this
474
- License of the Program or a work on which the Program is based. The
475
- work thus licensed is called the contributor's "contributor version".
476
-
477
- A contributor's "essential patent claims" are all patent claims
478
- owned or controlled by the contributor, whether already acquired or
479
- hereafter acquired, that would be infringed by some manner, permitted
480
- by this License, of making, using, or selling its contributor version,
481
- but do not include claims that would be infringed only as a
482
- consequence of further modification of the contributor version. For
483
- purposes of this definition, "control" includes the right to grant
484
- patent sublicenses in a manner consistent with the requirements of
485
- this License.
486
-
487
- Each contributor grants you a non-exclusive, worldwide, royalty-free
488
- patent license under the contributor's essential patent claims, to
489
- make, use, sell, offer for sale, import and otherwise run, modify and
490
- propagate the contents of its contributor version.
491
-
492
- In the following three paragraphs, a "patent license" is any express
493
- agreement or commitment, however denominated, not to enforce a patent
494
- (such as an express permission to practice a patent or covenant not to
495
- sue for patent infringement). To "grant" such a patent license to a
496
- party means to make such an agreement or commitment not to enforce a
497
- patent against the party.
498
-
499
- If you convey a covered work, knowingly relying on a patent license,
500
- and the Corresponding Source of the work is not available for anyone
501
- to copy, free of charge and under the terms of this License, through a
502
- publicly available network server or other readily accessible means,
503
- then you must either (1) cause the Corresponding Source to be so
504
- available, or (2) arrange to deprive yourself of the benefit of the
505
- patent license for this particular work, or (3) arrange, in a manner
506
- consistent with the requirements of this License, to extend the patent
507
- license to downstream recipients. "Knowingly relying" means you have
508
- actual knowledge that, but for the patent license, your conveying the
509
- covered work in a country, or your recipient's use of the covered work
510
- in a country, would infringe one or more identifiable patents in that
511
- country that you have reason to believe are valid.
512
-
513
- If, pursuant to or in connection with a single transaction or
514
- arrangement, you convey, or propagate by procuring conveyance of, a
515
- covered work, and grant a patent license to some of the parties
516
- receiving the covered work authorizing them to use, propagate, modify
517
- or convey a specific copy of the covered work, then the patent license
518
- you grant is automatically extended to all recipients of the covered
519
- work and works based on it.
520
-
521
- A patent license is "discriminatory" if it does not include within
522
- the scope of its coverage, prohibits the exercise of, or is
523
- conditioned on the non-exercise of one or more of the rights that are
524
- specifically granted under this License. You may not convey a covered
525
- work if you are a party to an arrangement with a third party that is
526
- in the business of distributing software, under which you make payment
527
- to the third party based on the extent of your activity of conveying
528
- the work, and under which the third party grants, to any of the
529
- parties who would receive the covered work from you, a discriminatory
530
- patent license (a) in connection with copies of the covered work
531
- conveyed by you (or copies made from those copies), or (b) primarily
532
- for and in connection with specific products or compilations that
533
- contain the covered work, unless you entered into that arrangement,
534
- or that patent license was granted, prior to 28 March 2007.
535
-
536
- Nothing in this License shall be construed as excluding or limiting
537
- any implied license or other defenses to infringement that may
538
- otherwise be available to you under applicable patent law.
539
-
540
- 12. No Surrender of Others' Freedom.
541
-
542
- If conditions are imposed on you (whether by court order, agreement or
543
- otherwise) that contradict the conditions of this License, they do not
544
- excuse you from the conditions of this License. If you cannot convey a
545
- covered work so as to satisfy simultaneously your obligations under this
546
- License and any other pertinent obligations, then as a consequence you may
547
- not convey it at all. For example, if you agree to terms that obligate you
548
- to collect a royalty for further conveying from those to whom you convey
549
- the Program, the only way you could satisfy both those terms and this
550
- License would be to refrain entirely from conveying the Program.
551
-
552
- 13. Use with the GNU Affero General Public License.
553
-
554
- Notwithstanding any other provision of this License, you have
555
- permission to link or combine any covered work with a work licensed
556
- under version 3 of the GNU Affero General Public License into a single
557
- combined work, and to convey the resulting work. The terms of this
558
- License will continue to apply to the part which is the covered work,
559
- but the special requirements of the GNU Affero General Public License,
560
- section 13, concerning interaction through a network will apply to the
561
- combination as such.
562
-
563
- 14. Revised Versions of this License.
564
-
565
- The Free Software Foundation may publish revised and/or new versions of
566
- the GNU General Public License from time to time. Such new versions will
567
- be similar in spirit to the present version, but may differ in detail to
568
- address new problems or concerns.
569
-
570
- Each version is given a distinguishing version number. If the
571
- Program specifies that a certain numbered version of the GNU General
572
- Public License "or any later version" applies to it, you have the
573
- option of following the terms and conditions either of that numbered
574
- version or of any later version published by the Free Software
575
- Foundation. If the Program does not specify a version number of the
576
- GNU General Public License, you may choose any version ever published
577
- by the Free Software Foundation.
578
-
579
- If the Program specifies that a proxy can decide which future
580
- versions of the GNU General Public License can be used, that proxy's
581
- public statement of acceptance of a version permanently authorizes you
582
- to choose that version for the Program.
583
-
584
- Later license versions may give you additional or different
585
- permissions. However, no additional obligations are imposed on any
586
- author or copyright holder as a result of your choosing to follow a
587
- later version.
588
-
589
- 15. Disclaimer of Warranty.
590
-
591
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
- APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
- HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
- OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
- PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
- IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
- ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
-
600
- 16. Limitation of Liability.
601
-
602
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
- THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
- GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
- USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
- DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
- PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
- EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
- SUCH DAMAGES.
611
-
612
- 17. Interpretation of Sections 15 and 16.
613
-
614
- If the disclaimer of warranty and limitation of liability provided
615
- above cannot be given local legal effect according to their terms,
616
- reviewing courts shall apply local law that most closely approximates
617
- an absolute waiver of all civil liability in connection with the
618
- Program, unless a warranty or assumption of liability accompanies a
619
- copy of the Program in return for a fee.
620
-
621
- END OF TERMS AND CONDITIONS
622
-
623
- How to Apply These Terms to Your New Programs
624
-
625
- If you develop a new program, and you want it to be of the greatest
626
- possible use to the public, the best way to achieve this is to make it
627
- free software which everyone can redistribute and change under these terms.
628
-
629
- To do so, attach the following notices to the program. It is safest
630
- to attach them to the start of each source file to most effectively
631
- state the exclusion of warranty; and each file should have at least
632
- the "copyright" line and a pointer to where the full notice is found.
633
-
634
- <one line to give the program's name and a brief idea of what it does.>
635
- Copyright (C) <year> <name of author>
636
-
637
- This program is free software: you can redistribute it and/or modify
638
- it under the terms of the GNU General Public License as published by
639
- the Free Software Foundation, either version 3 of the License, or
640
- (at your option) any later version.
641
-
642
- This program is distributed in the hope that it will be useful,
643
- but WITHOUT ANY WARRANTY; without even the implied warranty of
644
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
- GNU General Public License for more details.
646
-
647
- You should have received a copy of the GNU General Public License
648
- along with this program. If not, see <https://www.gnu.org/licenses/>.
649
-
650
- Also add information on how to contact you by electronic and paper mail.
651
-
652
- If the program does terminal interaction, make it output a short
653
- notice like this when it starts in an interactive mode:
654
-
655
- <program> Copyright (C) <year> <name of author>
656
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
- This is free software, and you are welcome to redistribute it
658
- under certain conditions; type `show c' for details.
659
-
660
- The hypothetical commands `show w' and `show c' should show the appropriate
661
- parts of the General Public License. Of course, your program's commands
662
- might be different; for a GUI interface, you would use an "about box".
663
-
664
- You should also get your employer (if you work as a programmer) or school,
665
- if any, to sign a "copyright disclaimer" for the program, if necessary.
666
- For more information on this, and how to apply and follow the GNU GPL, see
667
- <https://www.gnu.org/licenses/>.
668
-
669
- The GNU General Public License does not permit incorporating your program
670
- into proprietary programs. If your program is a subroutine library, you
671
- may consider it more useful to permit linking proprietary applications with
672
- the library. If this is what you want to do, use the GNU Lesser General
673
- Public License instead of this License. But first, please read
674
- <https://www.gnu.org/licenses/why-not-lgpl.html>.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/publishpress/wordpress-reviews/README.md DELETED
@@ -1,142 +0,0 @@
1
- # PublishPress WordPress Reviews Library
2
- Library for displaying a banner asking for a 5-star review on WordPress plugins.
3
-
4
- ## Installation
5
-
6
- We recommend using composer for adding this library as requirement:
7
-
8
- ```shell
9
- $ composer require publishpress/wordpress-reviews
10
- ```
11
-
12
- ## How to use it
13
-
14
- If your plugin do not load composer's autoloader yet, you need to add the following code:
15
-
16
- ```php
17
- <?php
18
-
19
- require_once 'vendor/autoload.php';
20
- ```
21
-
22
- The library should be initialized in the method of your plugin that load the main WordPress hooks.
23
- You can add it to the main class fo the plugin. When instantiating it you have to pass 3 params: the plugin slug (the same one used in the URL of the WordPress repository), the plugin's name and the logo url (optional).
24
-
25
- Pro plugins doesn't require this library, if they use they embed the free plugin. If you instantiate this library on both free and pro plugins, users will probably see duplicated banners.
26
-
27
- It by default displays the banner when the following conditional is true:
28
-
29
- ```php
30
- is_admin() && current_user_can('edit_posts')
31
- ```
32
-
33
- But you are able to specify the criteria used on the conditional to display the banner. For that you can hook into the filter `publishpress_wp_reviews_display_banner_<plugin_slug>`.
34
-
35
- ```php
36
- <?php
37
-
38
- use PublishPress\WordPressReviews\ReviewsController;
39
-
40
- class MyPlugin
41
- {
42
- /**
43
- * @var ReviewsController
44
- */
45
- private $reviewController;
46
-
47
- public function __construct()
48
- {
49
- $this->reviewController = new ReviewsController(
50
- 'my-plugin',
51
- 'My Plugin',
52
- MY_PLUGIN_URL . '/assets/img/logo.png'
53
- );
54
- }
55
-
56
- public function init()
57
- {
58
- // .......
59
- add_filter('publishpress_wp_reviews_display_banner_publishpress', [$this, 'shouldDisplayBanner']);
60
-
61
- $this->reviewController->init();
62
- }
63
-
64
- public function shouldDisplayBanner($shouldDisplay)
65
- {
66
- global $pagenow;
67
-
68
- if (! is_admin() || ! current_user_can('edit_posts')) {
69
- return false;
70
- }
71
-
72
- if ($pagenow === 'admin.php' && isset($_GET['page'])) {
73
- if ($_GET['page'] === 'pp-page1') {
74
- return true;
75
- }
76
-
77
- if ($_GET['page'] === 'pp-page2') {
78
- return true;
79
- }
80
- }
81
-
82
- if ($pagenow === 'edit.php' && isset($_GET['post_type'])) {
83
- if ($_GET['post_type'] === 'pp_custom_post_type') {
84
- return true;
85
- }
86
- }
87
-
88
- return false;
89
- }
90
-
91
- // .......
92
- }
93
- ```
94
-
95
- By default, the library will use the plugin's slug as prefix for the actions, meta data and options:
96
-
97
- ```php
98
- [
99
- 'action_ajax_handler' => $this->pluginSlug . '_action',
100
- 'option_installed_on' => $this->pluginSlug . '_wp_reviews_installed_on',
101
- 'nonce_action' => $this->pluginSlug . '_wp_reviews_action',
102
- 'user_meta_dismissed_triggers' => '_' . $this->pluginSlug . '_wp_reviews_dismissed_triggers',
103
- 'user_meta_last_dismissed' => '_' . $this->pluginSlug . '_wp_reviews_last_dismissed',
104
- 'user_meta_already_did' => '_' . $this->pluginSlug . '_wp_reviews_already_did',
105
- 'filter_triggers' => $this->pluginSlug . '_wp_reviews_triggers',
106
- ]
107
- ```
108
-
109
- If you already use
110
- the original library in your plugin and want to keep compatibility with the current sites data, you can customize the
111
- hooks and keys for the data stored in the DB using the filter `publishpress_wp_reviews_meta_map_<plugin_slug>`:
112
-
113
- ```php
114
- <?php
115
-
116
- add_filter('publishpress_wp_reviews_meta_map_my_plugin', 'my_plugin_wp_reviews_meta_map');
117
-
118
- function my_plugin_wp_reviews_meta_map($metaMap)
119
- {
120
- // You can override all the array, or specific keys.
121
- $metaMap = [
122
- 'action_ajax_handler' => 'legacy_slug_ajax_action',
123
- 'option_installed_on' => 'legacy_slug_wp_reviews_installed_on',
124
- 'nonce_action' => 'legacy_slug_wp_reviews_action',
125
- 'user_meta_dismissed_triggers' => '_legacy_slug_wp_reviews_dismissed_triggers',
126
- 'user_meta_last_dismissed' => '_legacy_slug_wp_reviews_last_dismissed',
127
- 'user_meta_already_did' => '_legacy_slug_wp_reviews_already_did',
128
- 'filter_triggers' => 'legacy_slug_wp_reviews_triggers',
129
- ];
130
-
131
- return $metaMap;
132
- }
133
- ```
134
-
135
- ## Testing
136
-
137
- You can easily test the banner in the WordPress admin.
138
- After initializing the library, change the option `publishpress_wp_reviews_installed_on` in the options table. Set it for an older data to make sure the time difference is bigger than the trigger we are using.
139
-
140
- ## Copyright
141
-
142
- Based on the [library](https://github.com/danieliser/WP-Product-In-Dash-Review-Requests) created by [Daniel Iser](https://danieliser.com).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/publishpress/wordpress-reviews/ReviewsController.php DELETED
@@ -1,688 +0,0 @@
1
- <?php
2
- /**
3
- * @package PublishPress
4
- * @author PublishPress
5
- *
6
- * Copyright (c) 2021 PublishPress
7
- *
8
- * WordPressReviews is free software: you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation, either version 3 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * WordPressReviews is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with PublishPress. If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- * ---------------------------------------------------------------------
22
- * It includes:
23
- * - Multiple trigger groups which can be ordered by priority.
24
- * - Multiple triggers per group.
25
- * - Customizable messaging per trigger.
26
- * - Link to review page.
27
- * - Request reviews on a per-user basis rather than per site.
28
- * - Allows each user to dismiss it until later or permanently seamlessly via AJAX.
29
- * - Integrates with attached tracking server to keep anonymous records of each trigger's effectiveness.
30
- * - Tracking Server API: https://gist.github.com/danieliser/0d997532e023c46d38e1bdfd50f38801
31
- *
32
- * Original Author: danieliser
33
- * Original Author URL: https://danieliser.com
34
- * URL: https://github.com/danieliser/WP-Product-In-Dash-Review-Requests
35
- */
36
-
37
- namespace PublishPress\WordPressReviews;
38
-
39
-
40
- use Exception;
41
-
42
- /**
43
- * Class ReviewsController
44
- *
45
- * @package PublishPress\WordPressReviews
46
- */
47
- class ReviewsController
48
- {
49
- /**
50
- * @var string
51
- */
52
- private $pluginSlug;
53
-
54
- /**
55
- * @var string
56
- */
57
- private $pluginName;
58
-
59
- /**
60
- * @var string
61
- */
62
- private $apiUrl = '';
63
-
64
- /**
65
- * @var array
66
- */
67
- private $metaMap;
68
-
69
- /**
70
- * @var string
71
- */
72
- private $iconUrl;
73
-
74
- /**
75
- * @param string $pluginSlug
76
- * @param string $pluginName
77
- * @param string $iconUrl
78
- */
79
- public function __construct($pluginSlug, $pluginName, $iconUrl = '')
80
- {
81
- $this->pluginSlug = $pluginSlug;
82
- $this->pluginName = $pluginName;
83
- $this->iconUrl = esc_url_raw($iconUrl);
84
-
85
- /**
86
- * Filter to replace the meta map with options, filters and actions names.
87
- *
88
- * @param array
89
- *
90
- * @return array
91
- */
92
- $this->metaMap = apply_filters(
93
- "{$pluginSlug}_wp_reviews_meta_map",
94
- [
95
- 'action_ajax_handler' => "{$this->pluginSlug}_action",
96
- 'option_installed_on' => "{$this->pluginSlug}_wp_reviews_installed_on",
97
- 'nonce_action' => "{$this->pluginSlug}_wp_reviews_action",
98
- 'user_meta_dismissed_triggers' => "_{$this->pluginSlug}_wp_reviews_dismissed_triggers",
99
- 'user_meta_last_dismissed' => "_{$this->pluginSlug}_wp_reviews_last_dismissed",
100
- 'user_meta_already_did' => "_{$this->pluginSlug}_wp_reviews_already_did",
101
- 'filter_triggers' => "{$this->pluginSlug}_wp_reviews_triggers",
102
- ]
103
- );
104
-
105
- /**
106
- * Legacy filter to replace the meta map with options, filters and actions names.
107
- *
108
- * @param array
109
- * @return array
110
- * @deprecated 1.1.9
111
- *
112
- */
113
- $this->metaMap = apply_filters(
114
- "publishpress_wp_reviews_meta_map_{$this->pluginSlug}",
115
- $this->metaMap
116
- );
117
-
118
- add_action('admin_enqueue_scripts', [$this, 'enqueueStyle']);
119
- }
120
-
121
- /**
122
- * Initialize the library.
123
- */
124
- public function init()
125
- {
126
- $this->addHooks();
127
- }
128
-
129
- /**
130
- * Hook into relevant WP actions.
131
- */
132
- private function addHooks()
133
- {
134
- if (defined('DOING_AJAX') && DOING_AJAX) {
135
- add_action("wp_ajax_{$this->metaMap['action_ajax_handler']}", [$this, 'ajaxHandler']);
136
- }
137
-
138
- if ($this->screenIsAllowedToDisplayNotice()) {
139
- $this->installationPath();
140
- add_action('admin_notices', [$this, 'renderAdminNotices']);
141
- add_action('network_admin_notices', [$this, 'renderAdminNotices']);
142
- add_action('user_admin_notices', [$this, 'renderAdminNotices']);
143
- }
144
- }
145
-
146
- /**
147
- * @return bool
148
- */
149
- private function screenIsAllowedToDisplayNotice()
150
- {
151
- $displayNotice = is_admin() && current_user_can('edit_posts');
152
-
153
- /**
154
- * Deprecated filter to specify a custom conditional to display or not the notice.
155
- *
156
- * @param bool
157
- * @return bool
158
- * @deprecated 1.1.9
159
- *
160
- */
161
- $displayNotice = apply_filters(
162
- "publishpress_wp_reviews_display_banner_{$this->pluginSlug}",
163
- $displayNotice
164
- );
165
-
166
- /**
167
- * Filter to specify a custom conditional to display or not the notice.
168
- *
169
- * @param bool
170
- *
171
- * @return bool
172
- */
173
- return apply_filters("{$this->pluginSlug}_wp_reviews_allow_display_notice", $displayNotice);
174
- }
175
-
176
- /**
177
- * Get the installation date for comparisons. Sets the date to now if none is found.
178
- *
179
- * @return false|string
180
- */
181
- public function installationPath()
182
- {
183
- $installationPath = get_option($this->metaMap['option_installed_on'], false);
184
-
185
- if (! $installationPath) {
186
- $installationPath = current_time('mysql');
187
- update_option($this->metaMap['option_installed_on'], $installationPath);
188
- }
189
-
190
- return $installationPath;
191
- }
192
-
193
- /**
194
- * The function called by the ajax request.
195
- */
196
- public function ajaxHandler()
197
- {
198
- $args = wp_parse_args(
199
- $_REQUEST,
200
- [
201
- 'group' => $this->getTriggerGroup(),
202
- 'code' => $this->getTriggerCode(),
203
- 'priority' => $this->getCurrentTrigger('priority'),
204
- 'reason' => 'maybe_later',
205
- ]
206
- );
207
-
208
- if (! wp_verify_nonce($_REQUEST['nonce'], $this->metaMap['nonce_action'])) {
209
- wp_send_json_error();
210
- }
211
-
212
- try {
213
- $userId = get_current_user_id();
214
-
215
- $dismissedTriggers = $this->getDismissedTriggerGroups();
216
- $dismissedTriggers[$args['group']] = (int)$args['priority'];
217
-
218
- update_user_meta($userId, $this->metaMap['user_meta_dismissed_triggers'], $dismissedTriggers);
219
- update_user_meta($userId, $this->metaMap['user_meta_last_dismissed'], current_time('mysql'));
220
-
221
- switch ($args['reason']) {
222
- case 'maybe_later':
223
- update_user_meta($userId, $this->metaMap['user_meta_last_dismissed'], current_time('mysql'));
224
- break;
225
- case 'am_now':
226
- case 'already_did':
227
- $this->setUserAlreadyDid($userId);
228
- break;
229
- }
230
-
231
- wp_send_json_success();
232
- } catch (Exception $e) {
233
- wp_send_json_error($e);
234
- }
235
- }
236
-
237
- /**
238
- * Get the trigger group.
239
- *
240
- * @return int|string
241
- */
242
- private function getTriggerGroup()
243
- {
244
- static $selected;
245
-
246
- if (! isset($selected)) {
247
- $dismissedTriggers = $this->getDismissedTriggerGroups();
248
-
249
- $triggers = $this->getTriggers();
250
-
251
- foreach ($triggers as $g => $group) {
252
- foreach ($group['triggers'] as $trigger) {
253
- if (! in_array(
254
- false,
255
- $trigger['conditions']
256
- ) && (empty($dismissedTriggers[$g]) || $dismissedTriggers[$g] < $trigger['priority'])) {
257
- $selected = $g;
258
- break;
259
- }
260
- }
261
-
262
- if (isset($selected)) {
263
- break;
264
- }
265
- }
266
- }
267
-
268
- return $selected;
269
- }
270
-
271
- /**
272
- * Returns an array of dismissed trigger groups.
273
- *
274
- * Array contains the group key and highest priority trigger that has been shown previously for each group.
275
- *
276
- * $return = array(
277
- * 'group1' => 20
278
- * );
279
- *
280
- * @return array|mixed
281
- */
282
- private function getDismissedTriggerGroups()
283
- {
284
- $userId = get_current_user_id();
285
-
286
- $dismissedTriggers = get_user_meta($userId, $this->metaMap['user_meta_dismissed_triggers'], true);
287
-
288
- if (! $dismissedTriggers) {
289
- $dismissedTriggers = [];
290
- }
291
-
292
- return $dismissedTriggers;
293
- }
294
-
295
- /**
296
- * Gets a list of triggers.
297
- *
298
- * @param null $group
299
- * @param null $code
300
- *
301
- * @return bool|mixed|void
302
- */
303
- private function getTriggers($group = null, $code = null)
304
- {
305
- static $triggers;
306
-
307
- if (! isset($triggers)) {
308
- $timeMessage = __(
309
- 'Hey, you\'ve been using %1$s for %2$s on your site. We hope the plugin has been useful. Please could you quickly leave a 5-star rating on WordPress.org? It really does help to keep %1$s growing.',
310
- $this->pluginSlug
311
- );
312
-
313
- $triggers = apply_filters(
314
- $this->metaMap['filter_triggers'],
315
- [
316
- 'time_installed' => [
317
- 'triggers' => [
318
- 'one_week' => [
319
- 'message' => sprintf($timeMessage, $this->pluginName, __('1 week', $this->pluginSlug)),
320
- 'conditions' => [
321
- strtotime($this->installationPath() . ' +1 week') < time(),
322
- ],
323
- 'link' => "https://wordpress.org/support/plugin/{$this->pluginSlug}/reviews/?rate=5#rate-response",
324
- 'priority' => 10,
325
- ],
326
- 'one_month' => [
327
- 'message' => sprintf($timeMessage, $this->pluginName, __('1 month', $this->pluginSlug)),
328
- 'conditions' => [
329
- strtotime($this->installationPath() . ' +1 month') < time(),
330
- ],
331
- 'link' => "https://wordpress.org/support/plugin/{$this->pluginSlug}/reviews/?rate=5#rate-response",
332
- 'priority' => 20,
333
- ],
334
- 'three_months' => [
335
- 'message' => sprintf(
336
- $timeMessage,
337
- $this->pluginName,
338
- __('3 months', $this->pluginSlug)
339
- ),
340
- 'conditions' => [
341
- strtotime($this->installationPath() . ' +3 months') < time(),
342
- ],
343
- 'link' => "https://wordpress.org/support/plugin/{$this->pluginSlug}/reviews/?rate=5#rate-response",
344
- 'priority' => 30,
345
- ],
346
- ],
347
- 'priority' => 10,
348
- ],
349
- ]
350
- );
351
-
352
- // Sort Groups
353
- uasort($triggers, [$this, 'rsortByPriority']);
354
-
355
- // Sort each groups triggers.
356
- foreach ($triggers as $v) {
357
- uasort($v['triggers'], [$this, 'rsortByPriority']);
358
- }
359
- }
360
-
361
- if (isset($group)) {
362
- if (! isset($triggers[$group])) {
363
- return false;
364
- }
365
-
366
- if (! isset($code)) {
367
- $return = $triggers[$group];
368
- } elseif (isset($triggers[$group]['triggers'][$code])) {
369
- $return = $triggers[$group]['triggers'][$code];
370
- } else {
371
- $return = false;
372
- }
373
-
374
- return $return;
375
- }
376
-
377
- return $triggers;
378
- }
379
-
380
- /**
381
- * @return int|string
382
- */
383
- private function getTriggerCode()
384
- {
385
- static $selected;
386
-
387
- if (! isset($selected)) {
388
- $dismissedTriggers = $this->getDismissedTriggerGroups();
389
-
390
- foreach ($this->getTriggers() as $g => $group) {
391
- foreach ($group['triggers'] as $t => $trigger) {
392
- if (! in_array(
393
- false,
394
- $trigger['conditions']
395
- ) && (empty($dismissedTriggers[$g]) || $dismissedTriggers[$g] < $trigger['priority'])) {
396
- $selected = $t;
397
- break;
398
- }
399
- }
400
-
401
- if (isset($selected)) {
402
- break;
403
- }
404
- }
405
- }
406
-
407
- return $selected;
408
- }
409
-
410
- /**
411
- * @param null $key
412
- *
413
- * @return bool|mixed|void
414
- */
415
- private function getCurrentTrigger($key = null)
416
- {
417
- $group = $this->getTriggerGroup();
418
- $code = $this->getTriggerCode();
419
-
420
- if (! $group || ! $code) {
421
- return false;
422
- }
423
-
424
- $trigger = $this->getTriggers($group, $code);
425
-
426
- if (empty($key)) {
427
- $return = $trigger;
428
- } elseif (isset($trigger[$key])) {
429
- $return = $trigger[$key];
430
- } else {
431
- $return = false;
432
- }
433
-
434
- return $return;
435
- }
436
-
437
- /**
438
- * @param $userId
439
- */
440
- private function setUserAlreadyDid($userId)
441
- {
442
- update_user_meta($userId, $this->metaMap['user_meta_already_did'], true);
443
- }
444
-
445
- public function enqueueStyle()
446
- {
447
- if (! $this->screenIsAllowedToDisplayNotice()) {
448
- return;
449
- }
450
-
451
- wp_register_style('publishpress_wordpress_reviews_style', false);
452
- wp_enqueue_style('publishpress_wordpress_reviews_style');
453
- wp_add_inline_style(
454
- 'publishpress_wordpress_reviews_style',
455
- "
456
- .{$this->pluginSlug}-wp-reviews-notice .button,
457
- .{$this->pluginSlug}-wp-reviews-notice p {
458
- font-size: 15px;
459
- }
460
-
461
- .{$this->pluginSlug}-wp-reviews-notice .button:not(.notice-dismiss) {
462
- border-width: 1px;
463
- }
464
-
465
- .{$this->pluginSlug}-wp-reviews-notice .button.button-primary {
466
- background-color: #655897;
467
- border-color: #3d355c;
468
- color: #fff;
469
- }
470
-
471
- .{$this->pluginSlug}-wp-reviews-notice .notice-icon {
472
- float: right;
473
- height: 110px;
474
- margin-top: 10px;
475
- margin-left: 10px;
476
- }
477
-
478
- @media (min-width:1000px) {
479
- .{$this->pluginSlug}-wp-reviews-notice .notice-icon {
480
- height: 90px;
481
- }
482
- }
483
-
484
- @media (min-width:1700px) {
485
- .{$this->pluginSlug}-wp-reviews-notice .notice-icon {
486
- height: 70px;
487
- }
488
- }
489
- "
490
- );
491
- }
492
-
493
- /**
494
- * Render admin notices if available.
495
- */
496
- public function renderAdminNotices()
497
- {
498
- if ($this->hideNotices()) {
499
- return;
500
- }
501
-
502
- $group = $this->getTriggerGroup();
503
- $code = $this->getTriggerCode();
504
- $priority = $this->getCurrentTrigger('priority');
505
- $trigger = $this->getCurrentTrigger();
506
-
507
- // Used to anonymously distinguish unique site+user combinations in terms of effectiveness of each trigger.
508
- $uuid = wp_hash(home_url() . '-' . get_current_user_id());
509
-
510
- ?>
511
-
512
- <script type="text/javascript">
513
- (function ($) {
514
- var trigger = {
515
- group: '<?php echo $group; ?>',
516
- code: '<?php echo $code; ?>',
517
- priority: '<?php echo $priority; ?>'
518
- };
519
-
520
- function dismiss(reason) {
521
- $.ajax({
522
- method: "POST",
523
- dataType: "json",
524
- url: ajaxurl,
525
- data: {
526
- action: '<?php echo $this->metaMap['action_ajax_handler']; ?>',
527
- nonce: '<?php echo wp_create_nonce($this->metaMap['nonce_action']); ?>',
528
- group: trigger.group,
529
- code: trigger.code,
530
- priority: trigger.priority,
531
- reason: reason
532
- }
533
- });
534
-
535
- <?php if ( ! empty($this->apiUrl) ) : ?>
536
- $.ajax({
537
- method: "POST",
538
- dataType: "json",
539
- url: '<?php echo $this->apiUrl; ?>',
540
- data: {
541
- trigger_group: trigger.group,
542
- trigger_code: trigger.code,
543
- reason: reason,
544
- uuid: '<?php echo $uuid; ?>'
545
- }
546
- });
547
- <?php endif; ?>
548
- }
549
-
550
- $(document)
551
- .on('click', '.<?php echo $this->pluginSlug; ?>-wp-reviews-notice .<?php echo "$this->pluginSlug-dismiss"; ?>', function (event) {
552
- var $this = $(this),
553
- reason = $this.data('reason'),
554
- notice = $this.parents('.<?php echo $this->pluginSlug; ?>-wp-reviews-notice');
555
-
556
- notice.fadeTo(100, 0, function () {
557
- notice.slideUp(100, function () {
558
- notice.remove();
559
- });
560
- });
561
-
562
- dismiss(reason);
563
- })
564
- .ready(function () {
565
- setTimeout(function () {
566
- $('.<?php echo $this->pluginSlug; ?>-wp-reviews-notice button.notice-dismiss').click(function (event) {
567
- dismiss('maybe_later');
568
- });
569
- }, 1000);
570
- });
571
- }(jQuery));
572
- </script>
573
-
574
- <div class="notice notice-success is-dismissible <?php
575
- echo "$this->pluginSlug-wp-reviews-notice"; ?>">
576
- <?php
577
- if (! empty($this->iconUrl)) : ?>
578
- <img src="<?php
579
- echo $this->iconUrl; ?>" class="notice-icon" alt="<?php
580
- echo $this->pluginName; ?> logo"/>
581
- <?php
582
- endif; ?>
583
-
584
- <p><?php
585
- echo $trigger['message']; ?></p>
586
- <p>
587
- <a class="button button-primary <?php
588
- echo "$this->pluginSlug-dismiss"; ?>"
589
- target="_blank"
590
- href="<?php
591
- echo $trigger['link']; ?>"
592
- data-reason="am_now"
593
- >
594
- <strong><?php
595
- echo sprintf(
596
- __('Click here to add your rating for %s', $this->pluginSlug),
597
- $this->pluginName
598
- ); ?></strong>
599
- </a>
600
- <a href="#" class="button <?php
601
- echo "$this->pluginSlug-dismiss"; ?>" data-reason="maybe_later">
602
- <?php
603
- _e('Maybe later', $this->pluginSlug); ?>
604
- </a>
605
- <a href="#" class="button <?php
606
- echo "$this->pluginSlug-dismiss"; ?>" data-reason="already_did">
607
- <?php
608
- _e('I already did', $this->pluginSlug); ?>
609
- </a>
610
- </p>
611
- </div>
612
- <?php
613
- }
614
-
615
- /**
616
- * Checks if notices should be shown.
617
- *
618
- * @return bool
619
- */
620
- private function hideNotices()
621
- {
622
- $conditions = [
623
- $this->userSelectedAlreadyDid(),
624
- $this->lastDismissedDate() && strtotime($this->lastDismissedDate() . ' +2 weeks') > time(),
625
- empty($this->getTriggerCode()),
626
- ];
627
-
628
- return in_array(true, $conditions);
629
- }
630
-
631
- /**
632
- * Returns true if the user has opted to never see this again.
633
- *
634
- * @return bool
635
- */
636
- private function userSelectedAlreadyDid()
637
- {
638
- $userId = get_current_user_id();
639
-
640
- return (bool)get_user_meta($userId, $this->metaMap['user_meta_already_did'], true);
641
- }
642
-
643
- /**
644
- * Gets the last dismissed date.
645
- *
646
- * @return false|string
647
- */
648
- private function lastDismissedDate()
649
- {
650
- $userId = get_current_user_id();
651
-
652
- return get_user_meta($userId, $this->metaMap['user_meta_last_dismissed'], true);
653
- }
654
-
655
- /**
656
- * Sort array by priority value
657
- *
658
- * @param $a
659
- * @param $b
660
- *
661
- * @return int
662
- */
663
- public function sortByPriority($a, $b)
664
- {
665
- if (! isset($a['priority']) || ! isset($b['priority']) || $a['priority'] === $b['priority']) {
666
- return 0;
667
- }
668
-
669
- return ($a['priority'] < $b['priority']) ? -1 : 1;
670
- }
671
-
672
- /**
673
- * Sort array in reverse by priority value
674
- *
675
- * @param $a
676
- * @param $b
677
- *
678
- * @return int
679
- */
680
- public function rsortByPriority($a, $b)
681
- {
682
- if (! isset($a['priority']) || ! isset($b['priority']) || $a['priority'] === $b['priority']) {
683
- return 0;
684
- }
685
-
686
- return ($a['priority'] < $b['priority']) ? 1 : -1;
687
- }
688
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/publishpress/wordpress-reviews/composer.json DELETED
@@ -1,35 +0,0 @@
1
- {
2
- "name": "publishpress/wordpress-reviews",
3
- "type": "library",
4
- "license": "GPL-3.0-or-later",
5
- "description": "Library for showing a five-star review banner.",
6
- "keywords": ["reviews", "review", "wordpress plugin"],
7
- "homepage": "http://publishpress.com/",
8
- "authors": [
9
- {
10
- "name": "PublishPress",
11
- "email": "help@publishpress.com"
12
- },
13
- {
14
- "name": "Daniel Iser",
15
- "homepage": "https://github.com/danieliser/WP-Product-In-Dash-Review-Requests"
16
- }
17
- ],
18
- "minimum-stability": "dev",
19
- "prefer-stable": true,
20
- "autoload": {
21
- "files": [
22
- "ReviewsController.php"
23
- ]
24
- },
25
- "require": {
26
- "php": ">=5.6.20",
27
- "pimple/pimple": "3.2.3.*",
28
- "publishpress/wordpress-version-notices": "^1",
29
- "publishpress/wordpress-reviews": "^1.1",
30
- "psr/container": "1.0.0"
31
- },
32
- "require-dev": {
33
- "overtrue/phplint": "^2.1"
34
- }
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/publishpress/wordpress-reviews/composer.lock DELETED
@@ -1,1192 +0,0 @@
1
- {
2
- "_readme": [
3
- "This file locks the dependencies of your project to a known state",
4
- "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5
- "This file is @generated automatically"
6
- ],
7
- "content-hash": "a47c2b0c564dacf272772323aaf812ae",
8
- "packages": [],
9
- "packages-dev": [
10
- {
11
- "name": "n98/junit-xml",
12
- "version": "1.1.0",
13
- "source": {
14
- "type": "git",
15
- "url": "https://github.com/cmuench/junit-xml.git",
16
- "reference": "0017dd92ac8cb619f02e32f4cffd768cfe327c73"
17
- },
18
- "dist": {
19
- "type": "zip",
20
- "url": "https://api.github.com/repos/cmuench/junit-xml/zipball/0017dd92ac8cb619f02e32f4cffd768cfe327c73",
21
- "reference": "0017dd92ac8cb619f02e32f4cffd768cfe327c73",
22
- "shasum": ""
23
- },
24
- "require-dev": {
25
- "phpunit/phpunit": "^9.5.0"
26
- },
27
- "type": "library",
28
- "autoload": {
29
- "psr-4": {
30
- "N98\\JUnitXml\\": "src/N98/JUnitXml"
31
- }
32
- },
33
- "notification-url": "https://packagist.org/downloads/",
34
- "license": [
35
- "MIT"
36
- ],
37
- "authors": [
38
- {
39
- "name": "Christian Münch",
40
- "email": "c.muench@netz98.de"
41
- }
42
- ],
43
- "description": "JUnit XML Document generation library",
44
- "support": {
45
- "issues": "https://github.com/cmuench/junit-xml/issues",
46
- "source": "https://github.com/cmuench/junit-xml/tree/1.1.0"
47
- },
48
- "time": "2020-12-25T09:08:58+00:00"
49
- },
50
- {
51
- "name": "overtrue/phplint",
52
- "version": "2.4.1",
53
- "source": {
54
- "type": "git",
55
- "url": "https://github.com/overtrue/phplint.git",
56
- "reference": "59affacd0b09a1460e39acf2c64c963ddbf734cf"
57
- },
58
- "dist": {
59
- "type": "zip",
60
- "url": "https://api.github.com/repos/overtrue/phplint/zipball/59affacd0b09a1460e39acf2c64c963ddbf734cf",
61
- "reference": "59affacd0b09a1460e39acf2c64c963ddbf734cf",
62
- "shasum": ""
63
- },
64
- "require": {
65
- "ext-json": "*",
66
- "n98/junit-xml": "1.1.0",
67
- "php": ">=5.5.9",
68
- "symfony/console": "^3.2|^4.0|^5.0",
69
- "symfony/finder": "^3.0|^4.0|^5.0",
70
- "symfony/process": "^3.3|^4.0|^5.0",
71
- "symfony/yaml": "^3.0|^4.0|^5.0"
72
- },
73
- "require-dev": {
74
- "brainmaestro/composer-git-hooks": "^2.7",
75
- "friendsofphp/php-cs-fixer": "^2.16",
76
- "jakub-onderka/php-console-highlighter": "^0.3.2 || ^0.4"
77
- },
78
- "bin": [
79
- "bin/phplint"
80
- ],
81
- "type": "library",
82
- "extra": {
83
- "hooks": {
84
- "pre-commit": [
85
- "composer fix-style"
86
- ],
87
- "pre-push": [
88
- "composer check-style"
89
- ]
90
- }
91
- },
92
- "autoload": {
93
- "psr-4": {
94
- "Overtrue\\PHPLint\\": "src/"
95
- }
96
- },
97
- "notification-url": "https://packagist.org/downloads/",
98
- "license": [
99
- "MIT"
100
- ],
101
- "authors": [
102
- {
103
- "name": "overtrue",
104
- "email": "anzhengchao@gmail.com"
105
- }
106
- ],
107
- "description": "`phplint` is a tool that can speed up linting of php files by running several lint processes at once.",
108
- "keywords": [
109
- "check",
110
- "lint",
111
- "phplint",
112
- "syntax"
113
- ],
114
- "support": {
115
- "issues": "https://github.com/overtrue/phplint/issues",
116
- "source": "https://github.com/overtrue/phplint/tree/2.4.1"
117
- },
118
- "time": "2021-06-02T16:18:33+00:00"
119
- },
120
- {
121
- "name": "psr/container",
122
- "version": "1.1.1",
123
- "source": {
124
- "type": "git",
125
- "url": "https://github.com/php-fig/container.git",
126
- "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
127
- },
128
- "dist": {
129
- "type": "zip",
130
- "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
131
- "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
132
- "shasum": ""
133
- },
134
- "require": {
135
- "php": ">=7.2.0"
136
- },
137
- "type": "library",
138
- "autoload": {
139
- "psr-4": {
140
- "Psr\\Container\\": "src/"
141
- }
142
- },
143
- "notification-url": "https://packagist.org/downloads/",
144
- "license": [
145
- "MIT"
146
- ],
147
- "authors": [
148
- {
149
- "name": "PHP-FIG",
150
- "homepage": "https://www.php-fig.org/"
151
- }
152
- ],
153
- "description": "Common Container Interface (PHP FIG PSR-11)",
154
- "homepage": "https://github.com/php-fig/container",
155
- "keywords": [
156
- "PSR-11",
157
- "container",
158
- "container-interface",
159
- "container-interop",
160
- "psr"
161
- ],
162
- "support": {
163
- "issues": "https://github.com/php-fig/container/issues",
164
- "source": "https://github.com/php-fig/container/tree/1.1.1"
165
- },
166
- "time": "2021-03-05T17:36:06+00:00"
167
- },
168
- {
169
- "name": "symfony/console",
170
- "version": "v5.3.7",
171
- "source": {
172
- "type": "git",
173
- "url": "https://github.com/symfony/console.git",
174
- "reference": "8b1008344647462ae6ec57559da166c2bfa5e16a"
175
- },
176
- "dist": {
177
- "type": "zip",
178
- "url": "https://api.github.com/repos/symfony/console/zipball/8b1008344647462ae6ec57559da166c2bfa5e16a",
179
- "reference": "8b1008344647462ae6ec57559da166c2bfa5e16a",
180
- "shasum": ""
181
- },
182
- "require": {
183
- "php": ">=7.2.5",
184
- "symfony/deprecation-contracts": "^2.1",
185
- "symfony/polyfill-mbstring": "~1.0",
186
- "symfony/polyfill-php73": "^1.8",
187
- "symfony/polyfill-php80": "^1.16",
188
- "symfony/service-contracts": "^1.1|^2",
189
- "symfony/string": "^5.1"
190
- },
191
- "conflict": {
192
- "psr/log": ">=3",
193
- "symfony/dependency-injection": "<4.4",
194
- "symfony/dotenv": "<5.1",
195
- "symfony/event-dispatcher": "<4.4",
196
- "symfony/lock": "<4.4",
197
- "symfony/process": "<4.4"
198
- },
199
- "provide": {
200
- "psr/log-implementation": "1.0|2.0"
201
- },
202
- "require-dev": {
203
- "psr/log": "^1|^2",
204
- "symfony/config": "^4.4|^5.0",
205
- "symfony/dependency-injection": "^4.4|^5.0",
206
- "symfony/event-dispatcher": "^4.4|^5.0",
207
- "symfony/lock": "^4.4|^5.0",
208
- "symfony/process": "^4.4|^5.0",
209
- "symfony/var-dumper": "^4.4|^5.0"
210
- },
211
- "suggest": {
212
- "psr/log": "For using the console logger",
213
- "symfony/event-dispatcher": "",
214
- "symfony/lock": "",
215
- "symfony/process": ""
216
- },
217
- "type": "library",
218
- "autoload": {
219
- "psr-4": {
220
- "Symfony\\Component\\Console\\": ""
221
- },
222
- "exclude-from-classmap": [
223
- "/Tests/"
224
- ]
225
- },
226
- "notification-url": "https://packagist.org/downloads/",
227
- "license": [
228
- "MIT"
229
- ],
230
- "authors": [
231
- {
232
- "name": "Fabien Potencier",
233
- "email": "fabien@symfony.com"
234
- },
235
- {
236
- "name": "Symfony Community",
237
- "homepage": "https://symfony.com/contributors"
238
- }
239
- ],
240
- "description": "Eases the creation of beautiful and testable command line interfaces",
241
- "homepage": "https://symfony.com",
242
- "keywords": [
243
- "cli",
244
- "command line",
245
- "console",
246
- "terminal"
247
- ],
248
- "support": {
249
- "source": "https://github.com/symfony/console/tree/v5.3.7"
250
- },
251
- "funding": [
252
- {
253
- "url": "https://symfony.com/sponsor",
254
- "type": "custom"
255
- },
256
- {
257
- "url": "https://github.com/fabpot",
258
- "type": "github"
259
- },
260
- {
261
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
262
- "type": "tidelift"
263
- }
264
- ],
265
- "time": "2021-08-25T20:02:16+00:00"
266
- },
267
- {
268
- "name": "symfony/deprecation-contracts",
269
- "version": "v2.4.0",
270
- "source": {
271
- "type": "git",
272
- "url": "https://github.com/symfony/deprecation-contracts.git",
273
- "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627"
274
- },
275
- "dist": {
276
- "type": "zip",
277
- "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627",
278
- "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627",
279
- "shasum": ""
280
- },
281
- "require": {
282
- "php": ">=7.1"
283
- },
284
- "type": "library",
285
- "extra": {
286
- "branch-alias": {
287
- "dev-main": "2.4-dev"
288
- },
289
- "thanks": {
290
- "name": "symfony/contracts",
291
- "url": "https://github.com/symfony/contracts"
292
- }
293
- },
294
- "autoload": {
295
- "files": [
296
- "function.php"
297
- ]
298
- },
299
- "notification-url": "https://packagist.org/downloads/",
300
- "license": [
301
- "MIT"
302
- ],
303
- "authors": [
304
- {
305
- "name": "Nicolas Grekas",
306
- "email": "p@tchwork.com"
307
- },
308
- {
309
- "name": "Symfony Community",
310
- "homepage": "https://symfony.com/contributors"
311
- }
312
- ],
313
- "description": "A generic function and convention to trigger deprecation notices",
314
- "homepage": "https://symfony.com",
315
- "support": {
316
- "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0"
317
- },
318
- "funding": [
319
- {
320
- "url": "https://symfony.com/sponsor",
321
- "type": "custom"
322
- },
323
- {
324
- "url": "https://github.com/fabpot",
325
- "type": "github"
326
- },
327
- {
328
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
329
- "type": "tidelift"
330
- }
331
- ],
332
- "time": "2021-03-23T23:28:01+00:00"
333
- },
334
- {
335
- "name": "symfony/finder",
336
- "version": "v5.3.7",
337
- "source": {
338
- "type": "git",
339
- "url": "https://github.com/symfony/finder.git",
340
- "reference": "a10000ada1e600d109a6c7632e9ac42e8bf2fb93"
341
- },
342
- "dist": {
343
- "type": "zip",
344
- "url": "https://api.github.com/repos/symfony/finder/zipball/a10000ada1e600d109a6c7632e9ac42e8bf2fb93",
345
- "reference": "a10000ada1e600d109a6c7632e9ac42e8bf2fb93",
346
- "shasum": ""
347
- },
348
- "require": {
349
- "php": ">=7.2.5",
350
- "symfony/polyfill-php80": "^1.16"
351
- },
352
- "type": "library",
353
- "autoload": {
354
- "psr-4": {
355
- "Symfony\\Component\\Finder\\": ""
356
- },
357
- "exclude-from-classmap": [
358
- "/Tests/"
359
- ]
360
- },
361
- "notification-url": "https://packagist.org/downloads/",
362
- "license": [
363
- "MIT"
364
- ],
365
- "authors": [
366
- {
367
- "name": "Fabien Potencier",
368
- "email": "fabien@symfony.com"
369
- },
370
- {
371
- "name": "Symfony Community",
372
- "homepage": "https://symfony.com/contributors"
373
- }
374
- ],
375
- "description": "Finds files and directories via an intuitive fluent interface",
376
- "homepage": "https://symfony.com",
377
- "support": {
378
- "source": "https://github.com/symfony/finder/tree/v5.3.7"
379
- },
380
- "funding": [
381
- {
382
- "url": "https://symfony.com/sponsor",
383
- "type": "custom"
384
- },
385
- {
386
- "url": "https://github.com/fabpot",
387
- "type": "github"
388
- },
389
- {
390
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
391
- "type": "tidelift"
392
- }
393
- ],
394
- "time": "2021-08-04T21:20:46+00:00"
395
- },
396
- {
397
- "name": "symfony/polyfill-ctype",
398
- "version": "v1.23.0",
399
- "source": {
400
- "type": "git",
401
- "url": "https://github.com/symfony/polyfill-ctype.git",
402
- "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce"
403
- },
404
- "dist": {
405
- "type": "zip",
406
- "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce",
407
- "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce",
408
- "shasum": ""
409
- },
410
- "require": {
411
- "php": ">=7.1"
412
- },
413
- "suggest": {
414
- "ext-ctype": "For best performance"
415
- },
416
- "type": "library",
417
- "extra": {
418
- "branch-alias": {
419
- "dev-main": "1.23-dev"
420
- },
421
- "thanks": {
422
- "name": "symfony/polyfill",
423
- "url": "https://github.com/symfony/polyfill"
424
- }
425
- },
426
- "autoload": {
427
- "psr-4": {
428
- "Symfony\\Polyfill\\Ctype\\": ""
429
- },
430
- "files": [
431
- "bootstrap.php"
432
- ]
433
- },
434
- "notification-url": "https://packagist.org/downloads/",
435
- "license": [
436
- "MIT"
437
- ],
438
- "authors": [
439
- {
440
- "name": "Gert de Pagter",
441
- "email": "BackEndTea@gmail.com"
442
- },
443
- {
444
- "name": "Symfony Community",
445
- "homepage": "https://symfony.com/contributors"
446
- }
447
- ],
448
- "description": "Symfony polyfill for ctype functions",
449
- "homepage": "https://symfony.com",
450
- "keywords": [
451
- "compatibility",
452
- "ctype",
453
- "polyfill",
454
- "portable"
455
- ],
456
- "support": {
457
- "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0"
458
- },
459
- "funding": [
460
- {
461
- "url": "https://symfony.com/sponsor",
462
- "type": "custom"
463
- },
464
- {
465
- "url": "https://github.com/fabpot",
466
- "type": "github"
467
- },
468
- {
469
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
470
- "type": "tidelift"
471
- }
472
- ],
473
- "time": "2021-02-19T12:13:01+00:00"
474
- },
475
- {
476
- "name": "symfony/polyfill-intl-grapheme",
477
- "version": "v1.23.1",
478
- "source": {
479
- "type": "git",
480
- "url": "https://github.com/symfony/polyfill-intl-grapheme.git",
481
- "reference": "16880ba9c5ebe3642d1995ab866db29270b36535"
482
- },
483
- "dist": {
484
- "type": "zip",
485
- "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/16880ba9c5ebe3642d1995ab866db29270b36535",
486
- "reference": "16880ba9c5ebe3642d1995ab866db29270b36535",
487
- "shasum": ""
488
- },
489
- "require": {
490
- "php": ">=7.1"
491
- },
492
- "suggest": {
493
- "ext-intl": "For best performance"
494
- },
495
- "type": "library",
496
- "extra": {
497
- "branch-alias": {
498
- "dev-main": "1.23-dev"
499
- },
500
- "thanks": {
501
- "name": "symfony/polyfill",
502
- "url": "https://github.com/symfony/polyfill"
503
- }
504
- },
505
- "autoload": {
506
- "psr-4": {
507
- "Symfony\\Polyfill\\Intl\\Grapheme\\": ""
508
- },
509
- "files": [
510
- "bootstrap.php"
511
- ]
512
- },
513
- "notification-url": "https://packagist.org/downloads/",
514
- "license": [
515
- "MIT"
516
- ],
517
- "authors": [
518
- {
519
- "name": "Nicolas Grekas",
520
- "email": "p@tchwork.com"
521
- },
522
- {
523
- "name": "Symfony Community",
524
- "homepage": "https://symfony.com/contributors"
525
- }
526
- ],
527
- "description": "Symfony polyfill for intl's grapheme_* functions",
528
- "homepage": "https://symfony.com",
529
- "keywords": [
530
- "compatibility",
531
- "grapheme",
532
- "intl",
533
- "polyfill",
534
- "portable",
535
- "shim"
536
- ],
537
- "support": {
538
- "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.1"
539
- },
540
- "funding": [
541
- {
542
- "url": "https://symfony.com/sponsor",
543
- "type": "custom"
544
- },
545
- {
546
- "url": "https://github.com/fabpot",
547
- "type": "github"
548
- },
549
- {
550
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
551
- "type": "tidelift"
552
- }
553
- ],
554
- "time": "2021-05-27T12:26:48+00:00"
555
- },
556
- {
557
- "name": "symfony/polyfill-intl-normalizer",
558
- "version": "v1.23.0",
559
- "source": {
560
- "type": "git",
561
- "url": "https://github.com/symfony/polyfill-intl-normalizer.git",
562
- "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8"
563
- },
564
- "dist": {
565
- "type": "zip",
566
- "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8",
567
- "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8",
568
- "shasum": ""
569
- },
570
- "require": {
571
- "php": ">=7.1"
572
- },
573
- "suggest": {
574
- "ext-intl": "For best performance"
575
- },
576
- "type": "library",
577
- "extra": {
578
- "branch-alias": {
579
- "dev-main": "1.23-dev"
580
- },
581
- "thanks": {
582
- "name": "symfony/polyfill",
583
- "url": "https://github.com/symfony/polyfill"
584
- }
585
- },
586
- "autoload": {
587
- "psr-4": {
588
- "Symfony\\Polyfill\\Intl\\Normalizer\\": ""
589
- },
590
- "files": [
591
- "bootstrap.php"
592
- ],
593
- "classmap": [
594
- "Resources/stubs"
595
- ]
596
- },
597
- "notification-url": "https://packagist.org/downloads/",
598
- "license": [
599
- "MIT"
600
- ],
601
- "authors": [
602
- {
603
- "name": "Nicolas Grekas",
604
- "email": "p@tchwork.com"
605
- },
606
- {
607
- "name": "Symfony Community",
608
- "homepage": "https://symfony.com/contributors"
609
- }
610
- ],
611
- "description": "Symfony polyfill for intl's Normalizer class and related functions",
612
- "homepage": "https://symfony.com",
613
- "keywords": [
614
- "compatibility",
615
- "intl",
616
- "normalizer",
617
- "polyfill",
618
- "portable",
619
- "shim"
620
- ],
621
- "support": {
622
- "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0"
623
- },
624
- "funding": [
625
- {
626
- "url": "https://symfony.com/sponsor",
627
- "type": "custom"
628
- },
629
- {
630
- "url": "https://github.com/fabpot",
631
- "type": "github"
632
- },
633
- {
634
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
635
- "type": "tidelift"
636
- }
637
- ],
638
- "time": "2021-02-19T12:13:01+00:00"
639
- },
640
- {
641
- "name": "symfony/polyfill-mbstring",
642
- "version": "v1.23.1",
643
- "source": {
644
- "type": "git",
645
- "url": "https://github.com/symfony/polyfill-mbstring.git",
646
- "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6"
647
- },
648
- "dist": {
649
- "type": "zip",
650
- "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6",
651
- "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6",
652
- "shasum": ""
653
- },
654
- "require": {
655
- "php": ">=7.1"
656
- },
657
- "suggest": {
658
- "ext-mbstring": "For best performance"
659
- },
660
- "type": "library",
661
- "extra": {
662
- "branch-alias": {
663
- "dev-main": "1.23-dev"
664
- },
665
- "thanks": {
666
- "name": "symfony/polyfill",
667
- "url": "https://github.com/symfony/polyfill"
668
- }
669
- },
670
- "autoload": {
671
- "psr-4": {
672
- "Symfony\\Polyfill\\Mbstring\\": ""
673
- },
674
- "files": [
675
- "bootstrap.php"
676
- ]
677
- },
678
- "notification-url": "https://packagist.org/downloads/",
679
- "license": [
680
- "MIT"
681
- ],
682
- "authors": [
683
- {
684
- "name": "Nicolas Grekas",
685
- "email": "p@tchwork.com"
686
- },
687
- {
688
- "name": "Symfony Community",
689
- "homepage": "https://symfony.com/contributors"
690
- }
691
- ],
692
- "description": "Symfony polyfill for the Mbstring extension",
693
- "homepage": "https://symfony.com",
694
- "keywords": [
695
- "compatibility",
696
- "mbstring",
697
- "polyfill",
698
- "portable",
699
- "shim"
700
- ],
701
- "support": {
702
- "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1"
703
- },
704
- "funding": [
705
- {
706
- "url": "https://symfony.com/sponsor",
707
- "type": "custom"
708
- },
709
- {
710
- "url": "https://github.com/fabpot",
711
- "type": "github"
712
- },
713
- {
714
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
715
- "type": "tidelift"
716
- }
717
- ],
718
- "time": "2021-05-27T12:26:48+00:00"
719
- },
720
- {
721
- "name": "symfony/polyfill-php73",
722
- "version": "v1.23.0",
723
- "source": {
724
- "type": "git",
725
- "url": "https://github.com/symfony/polyfill-php73.git",
726
- "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010"
727
- },
728
- "dist": {
729
- "type": "zip",
730
- "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fba8933c384d6476ab14fb7b8526e5287ca7e010",
731
- "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010",
732
- "shasum": ""
733
- },
734
- "require": {
735
- "php": ">=7.1"
736
- },
737
- "type": "library",
738
- "extra": {
739
- "branch-alias": {
740
- "dev-main": "1.23-dev"
741
- },
742
- "thanks": {
743
- "name": "symfony/polyfill",
744
- "url": "https://github.com/symfony/polyfill"
745
- }
746
- },
747
- "autoload": {
748
- "psr-4": {
749
- "Symfony\\Polyfill\\Php73\\": ""
750
- },
751
- "files": [
752
- "bootstrap.php"
753
- ],
754
- "classmap": [
755
- "Resources/stubs"
756
- ]
757
- },
758
- "notification-url": "https://packagist.org/downloads/",
759
- "license": [
760
- "MIT"
761
- ],
762
- "authors": [
763
- {
764
- "name": "Nicolas Grekas",
765
- "email": "p@tchwork.com"
766
- },
767
- {
768
- "name": "Symfony Community",
769
- "homepage": "https://symfony.com/contributors"
770
- }
771
- ],
772
- "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions",
773
- "homepage": "https://symfony.com",
774
- "keywords": [
775
- "compatibility",
776
- "polyfill",
777
- "portable",
778
- "shim"
779
- ],
780
- "support": {
781
- "source": "https://github.com/symfony/polyfill-php73/tree/v1.23.0"
782
- },
783
- "funding": [
784
- {
785
- "url": "https://symfony.com/sponsor",
786
- "type": "custom"
787
- },
788
- {
789
- "url": "https://github.com/fabpot",
790
- "type": "github"
791
- },
792
- {
793
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
794
- "type": "tidelift"
795
- }
796
- ],
797
- "time": "2021-02-19T12:13:01+00:00"
798
- },
799
- {
800
- "name": "symfony/polyfill-php80",
801
- "version": "v1.23.1",
802
- "source": {
803
- "type": "git",
804
- "url": "https://github.com/symfony/polyfill-php80.git",
805
- "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be"
806
- },
807
- "dist": {
808
- "type": "zip",
809
- "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be",
810
- "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be",
811
- "shasum": ""
812
- },
813
- "require": {
814
- "php": ">=7.1"
815
- },
816
- "type": "library",
817
- "extra": {
818
- "branch-alias": {
819
- "dev-main": "1.23-dev"
820
- },
821
- "thanks": {
822
- "name": "symfony/polyfill",
823
- "url": "https://github.com/symfony/polyfill"
824
- }
825
- },
826
- "autoload": {
827
- "psr-4": {
828
- "Symfony\\Polyfill\\Php80\\": ""
829
- },
830
- "files": [
831
- "bootstrap.php"
832
- ],
833
- "classmap": [
834
- "Resources/stubs"
835
- ]
836
- },
837
- "notification-url": "https://packagist.org/downloads/",
838
- "license": [
839
- "MIT"
840
- ],
841
- "authors": [
842
- {
843
- "name": "Ion Bazan",
844
- "email": "ion.bazan@gmail.com"
845
- },
846
- {
847
- "name": "Nicolas Grekas",
848
- "email": "p@tchwork.com"
849
- },
850
- {
851
- "name": "Symfony Community",
852
- "homepage": "https://symfony.com/contributors"
853
- }
854
- ],
855
- "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
856
- "homepage": "https://symfony.com",
857
- "keywords": [
858
- "compatibility",
859
- "polyfill",
860
- "portable",
861
- "shim"
862
- ],
863
- "support": {
864
- "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1"
865
- },
866
- "funding": [
867
- {
868
- "url": "https://symfony.com/sponsor",
869
- "type": "custom"
870
- },
871
- {
872
- "url": "https://github.com/fabpot",
873
- "type": "github"
874
- },
875
- {
876
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
877
- "type": "tidelift"
878
- }
879
- ],
880
- "time": "2021-07-28T13:41:28+00:00"
881
- },
882
- {
883
- "name": "symfony/process",
884
- "version": "v5.3.7",
885
- "source": {
886
- "type": "git",
887
- "url": "https://github.com/symfony/process.git",
888
- "reference": "38f26c7d6ed535217ea393e05634cb0b244a1967"
889
- },
890
- "dist": {
891
- "type": "zip",
892
- "url": "https://api.github.com/repos/symfony/process/zipball/38f26c7d6ed535217ea393e05634cb0b244a1967",
893
- "reference": "38f26c7d6ed535217ea393e05634cb0b244a1967",
894
- "shasum": ""
895
- },
896
- "require": {
897
- "php": ">=7.2.5",
898
- "symfony/polyfill-php80": "^1.16"
899
- },
900
- "type": "library",
901
- "autoload": {
902
- "psr-4": {
903
- "Symfony\\Component\\Process\\": ""
904
- },
905
- "exclude-from-classmap": [
906
- "/Tests/"
907
- ]
908
- },
909
- "notification-url": "https://packagist.org/downloads/",
910
- "license": [
911
- "MIT"
912
- ],
913
- "authors": [
914
- {
915
- "name": "Fabien Potencier",
916
- "email": "fabien@symfony.com"
917
- },
918
- {
919
- "name": "Symfony Community",
920
- "homepage": "https://symfony.com/contributors"
921
- }
922
- ],
923
- "description": "Executes commands in sub-processes",
924
- "homepage": "https://symfony.com",
925
- "support": {
926
- "source": "https://github.com/symfony/process/tree/v5.3.7"
927
- },
928
- "funding": [
929
- {
930
- "url": "https://symfony.com/sponsor",
931
- "type": "custom"
932
- },
933
- {
934
- "url": "https://github.com/fabpot",
935
- "type": "github"
936
- },
937
- {
938
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
939
- "type": "tidelift"
940
- }
941
- ],
942
- "time": "2021-08-04T21:20:46+00:00"
943
- },
944
- {
945
- "name": "symfony/service-contracts",
946
- "version": "v2.4.0",
947
- "source": {
948
- "type": "git",
949
- "url": "https://github.com/symfony/service-contracts.git",
950
- "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb"
951
- },
952
- "dist": {
953
- "type": "zip",
954
- "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb",
955
- "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb",
956
- "shasum": ""
957
- },
958
- "require": {
959
- "php": ">=7.2.5",
960
- "psr/container": "^1.1"
961
- },
962
- "suggest": {
963
- "symfony/service-implementation": ""
964
- },
965
- "type": "library",
966
- "extra": {
967
- "branch-alias": {
968
- "dev-main": "2.4-dev"
969
- },
970
- "thanks": {
971
- "name": "symfony/contracts",
972
- "url": "https://github.com/symfony/contracts"
973
- }
974
- },
975
- "autoload": {
976
- "psr-4": {
977
- "Symfony\\Contracts\\Service\\": ""
978
- }
979
- },
980
- "notification-url": "https://packagist.org/downloads/",
981
- "license": [
982
- "MIT"
983
- ],
984
- "authors": [
985
- {
986
- "name": "Nicolas Grekas",
987
- "email": "p@tchwork.com"
988
- },
989
- {
990
- "name": "Symfony Community",
991
- "homepage": "https://symfony.com/contributors"
992
- }
993
- ],
994
- "description": "Generic abstractions related to writing services",
995
- "homepage": "https://symfony.com",
996
- "keywords": [
997
- "abstractions",
998
- "contracts",
999
- "decoupling",
1000
- "interfaces",
1001
- "interoperability",
1002
- "standards"
1003
- ],
1004
- "support": {
1005
- "source": "https://github.com/symfony/service-contracts/tree/v2.4.0"
1006
- },
1007
- "funding": [
1008
- {
1009
- "url": "https://symfony.com/sponsor",
1010
- "type": "custom"
1011
- },
1012
- {
1013
- "url": "https://github.com/fabpot",
1014
- "type": "github"
1015
- },
1016
- {
1017
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
1018
- "type": "tidelift"
1019
- }
1020
- ],
1021
- "time": "2021-04-01T10:43:52+00:00"
1022
- },
1023
- {
1024
- "name": "symfony/string",
1025
- "version": "v5.3.7",
1026
- "source": {
1027
- "type": "git",
1028
- "url": "https://github.com/symfony/string.git",
1029
- "reference": "8d224396e28d30f81969f083a58763b8b9ceb0a5"
1030
- },
1031
- "dist": {
1032
- "type": "zip",
1033
- "url": "https://api.github.com/repos/symfony/string/zipball/8d224396e28d30f81969f083a58763b8b9ceb0a5",
1034
- "reference": "8d224396e28d30f81969f083a58763b8b9ceb0a5",
1035
- "shasum": ""
1036
- },
1037
- "require": {
1038
- "php": ">=7.2.5",
1039
- "symfony/polyfill-ctype": "~1.8",
1040
- "symfony/polyfill-intl-grapheme": "~1.0",
1041
- "symfony/polyfill-intl-normalizer": "~1.0",
1042
- "symfony/polyfill-mbstring": "~1.0",
1043
- "symfony/polyfill-php80": "~1.15"
1044
- },
1045
- "require-dev": {
1046
- "symfony/error-handler": "^4.4|^5.0",
1047
- "symfony/http-client": "^4.4|^5.0",
1048
- "symfony/translation-contracts": "^1.1|^2",
1049
- "symfony/var-exporter": "^4.4|^5.0"
1050
- },
1051
- "type": "library",
1052
- "autoload": {
1053
- "psr-4": {
1054
- "Symfony\\Component\\String\\": ""
1055
- },
1056
- "files": [
1057
- "Resources/functions.php"
1058
- ],
1059
- "exclude-from-classmap": [
1060
- "/Tests/"
1061
- ]
1062
- },
1063
- "notification-url": "https://packagist.org/downloads/",
1064
- "license": [
1065
- "MIT"
1066
- ],
1067
- "authors": [
1068
- {
1069
- "name": "Nicolas Grekas",
1070
- "email": "p@tchwork.com"
1071
- },
1072
- {
1073
- "name": "Symfony Community",
1074
- "homepage": "https://symfony.com/contributors"
1075
- }
1076
- ],
1077
- "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way",
1078
- "homepage": "https://symfony.com",
1079
- "keywords": [
1080
- "grapheme",
1081
- "i18n",
1082
- "string",
1083
- "unicode",
1084
- "utf-8",
1085
- "utf8"
1086
- ],
1087
- "support": {
1088
- "source": "https://github.com/symfony/string/tree/v5.3.7"
1089
- },
1090
- "funding": [
1091
- {
1092
- "url": "https://symfony.com/sponsor",
1093
- "type": "custom"
1094
- },
1095
- {
1096
- "url": "https://github.com/fabpot",
1097
- "type": "github"
1098
- },
1099
- {
1100
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
1101
- "type": "tidelift"
1102
- }
1103
- ],
1104
- "time": "2021-08-26T08:00:08+00:00"
1105
- },
1106
- {
1107
- "name": "symfony/yaml",
1108
- "version": "v5.3.6",
1109
- "source": {
1110
- "type": "git",
1111
- "url": "https://github.com/symfony/yaml.git",
1112
- "reference": "4500fe63dc9c6ffc32d3b1cb0448c329f9c814b7"
1113
- },
1114
- "dist": {
1115
- "type": "zip",
1116
- "url": "https://api.github.com/repos/symfony/yaml/zipball/4500fe63dc9c6ffc32d3b1cb0448c329f9c814b7",
1117
- "reference": "4500fe63dc9c6ffc32d3b1cb0448c329f9c814b7",
1118
- "shasum": ""
1119
- },
1120
- "require": {
1121
- "php": ">=7.2.5",
1122
- "symfony/deprecation-contracts": "^2.1",
1123
- "symfony/polyfill-ctype": "~1.8"
1124
- },
1125
- "conflict": {
1126
- "symfony/console": "<4.4"
1127
- },
1128
- "require-dev": {
1129
- "symfony/console": "^4.4|^5.0"
1130
- },
1131
- "suggest": {
1132
- "symfony/console": "For validating YAML files using the lint command"
1133
- },
1134
- "bin": [
1135
- "Resources/bin/yaml-lint"
1136
- ],
1137
- "type": "library",
1138
- "autoload": {
1139
- "psr-4": {
1140
- "Symfony\\Component\\Yaml\\": ""
1141
- },
1142
- "exclude-from-classmap": [
1143
- "/Tests/"
1144
- ]
1145
- },
1146
- "notification-url": "https://packagist.org/downloads/",
1147
- "license": [
1148
- "MIT"
1149
- ],
1150
- "authors": [
1151
- {
1152
- "name": "Fabien Potencier",
1153
- "email": "fabien@symfony.com"
1154
- },
1155
- {
1156
- "name": "Symfony Community",
1157
- "homepage": "https://symfony.com/contributors"
1158
- }
1159
- ],
1160
- "description": "Loads and dumps YAML files",
1161
- "homepage": "https://symfony.com",
1162
- "support": {
1163
- "source": "https://github.com/symfony/yaml/tree/v5.3.6"
1164
- },
1165
- "funding": [
1166
- {
1167
- "url": "https://symfony.com/sponsor",
1168
- "type": "custom"
1169
- },
1170
- {
1171
- "url": "https://github.com/fabpot",
1172
- "type": "github"
1173
- },
1174
- {
1175
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
1176
- "type": "tidelift"
1177
- }
1178
- ],
1179
- "time": "2021-07-29T06:20:01+00:00"
1180
- }
1181
- ],
1182
- "aliases": [],
1183
- "minimum-stability": "dev",
1184
- "stability-flags": [],
1185
- "prefer-stable": true,
1186
- "prefer-lowest": false,
1187
- "platform": {
1188
- "php": ">=5.6.20"
1189
- },
1190
- "platform-dev": [],
1191
- "plugin-api-version": "2.1.0"
1192
- }