@@ -186,11 +186,13 @@ public function enqueue_admin_scripts()
186
186
{
187
187
wp_enqueue_script ('jquery-listfilterizer ' );
188
188
wp_enqueue_script (
189
- 'workflow-authors ' ,
190
- $ this ->module_url . 'authors.js ' ,
191
- array ('jquery ' ,
192
- 'jquery-listfilterizer ' ),
193
- plugin ()->getVersion (),
189
+ 'workflow-authors ' ,
190
+ $ this ->module_url . 'authors.js ' ,
191
+ array (
192
+ 'jquery ' ,
193
+ 'jquery-listfilterizer '
194
+ ),
195
+ plugin ()->getVersion (),
194
196
true
195
197
);
196
198
@@ -205,9 +207,9 @@ public function enqueue_admin_styles()
205
207
{
206
208
wp_enqueue_style ('jquery-listfilterizer ' );
207
209
wp_enqueue_style (
208
- 'workflow-authors ' ,
209
- $ this ->module ->module_url . 'authors.css ' ,
210
- false ,
210
+ 'workflow-authors ' ,
211
+ $ this ->module ->module_url . 'authors.css ' ,
212
+ false ,
211
213
plugin ()->getVersion (),
212
214
);
213
215
}
@@ -229,7 +231,7 @@ public function add_post_meta_box($post_type)
229
231
230
232
public function authors_meta_box ($ post )
231
233
{
232
- ?>
234
+ ?>
233
235
<div id="workflow-post-authors-box">
234
236
<p><?php _e ('Wählen Sie die Autoren zum Dokument ' , 'cms-workflow ' ); ?> </p>
235
237
<div id="workflow-post-authors-inside">
@@ -416,7 +418,7 @@ private function add_post_users($post, $users, $append = true)
416
418
417
419
public function add_post_usergroups ($ post , $ usergroups , $ append = true )
418
420
{
419
-
421
+
420
422
421
423
if (!$ this ->module_activated ('user_groups ' )) {
422
424
return ;
@@ -604,6 +606,14 @@ public function filter_user_has_cap($allcaps, $caps, $args)
604
606
$ user_id = isset ($ args [1 ]) ? $ args [1 ] : 0 ;
605
607
$ post_id = isset ($ args [2 ]) ? $ args [2 ] : 0 ;
606
608
609
+ if (is_a ($ post_id , 'WP_Block_Editor_Context ' )) {
610
+ $ post_id = $ post_id ->post ->ID ;
611
+ }
612
+
613
+ if (!is_int ($ post_id ) || $ post_id == 0 ) {
614
+ return $ allcaps ;
615
+ }
616
+
607
617
if ($ revision_parent_id = wp_is_post_revision ($ post_id )) {
608
618
$ post_id = $ revision_parent_id ;
609
619
}
@@ -616,7 +626,7 @@ public function filter_user_has_cap($allcaps, $caps, $args)
616
626
617
627
$ post_type_obj = get_post_type_object ($ post_type );
618
628
619
- if (! $ post_type_obj ) {
629
+ if (is_null ( $ post_type_obj) ) {
620
630
return $ allcaps ;
621
631
}
622
632
@@ -630,6 +640,13 @@ public function filter_user_has_cap($allcaps, $caps, $args)
630
640
return $ allcaps ;
631
641
}
632
642
643
+ $ status = get_post_status ($ post_id );
644
+
645
+ if ($ status == 'publish ' && isset ($ allcaps ["edit_published_ {$ post_type }s " ]) && !isset ($ allcaps ["publish_ {$ post_type }s " ])) {
646
+ $ allcaps ["publish_ {$ post_type }s " ] = true ;
647
+ $ current_user ->allcaps ["publish_ {$ post_type }s " ] = true ;
648
+ }
649
+
633
650
if (isset ($ post_type_obj ->cap ->edit_others_posts ) && !empty ($ current_user ->allcaps [$ post_type_obj ->cap ->edit_posts ])) {
634
651
$ allcaps [$ post_type_obj ->cap ->edit_others_posts ] = true ;
635
652
}
@@ -638,6 +655,10 @@ public function filter_user_has_cap($allcaps, $caps, $args)
638
655
$ allcaps [$ post_type_obj ->cap ->delete_others_posts ] = true ;
639
656
}
640
657
658
+ // error_log($current_user->user_login);
659
+ // error_log(print_r($allcaps, true));
660
+ // error_log(print_r($current_user->allcaps, true));
661
+ // error_log(print_r($post_type_obj->cap, true));
641
662
return $ allcaps ;
642
663
}
643
664
@@ -980,7 +1001,7 @@ public static function get_authors($post_id, $return = null)
980
1001
981
1002
private function get_authors_usergroups ($ post_id , $ return = 'all ' )
982
1003
{
983
-
1004
+
984
1005
985
1006
if ($ return == 'slugs ' ) {
986
1007
$ fields = 'all ' ;
0 commit comments