diff --git a/classes/PressShack/LibWP.php b/classes/PressShack/LibWP.php index 1361fef5..78c35dfc 100644 --- a/classes/PressShack/LibWP.php +++ b/classes/PressShack/LibWP.php @@ -157,7 +157,7 @@ public static function doingCron() } // support array matching for post type - public static function getPostStatuses($args, $return = 'names', $operator = 'and') + public static function getPostStatuses($args, $return = 'names', $operator = 'and', $params = []) { if (isset($args['post_type'])) { $post_type = $args['post_type']; @@ -174,7 +174,7 @@ public static function getPostStatuses($args, $return = 'names', $operator = 'an $statuses = get_post_stati($args, $return, $operator); } - return apply_filters('presspermit_get_post_statuses', $statuses, $args, $return, $operator); + return apply_filters('presspermit_get_post_statuses', $statuses, $args, $return, $operator, $params); } public static function findPostType($post_id = 0, $return_default = true) diff --git a/classes/PublishPress/Permissions/DB/Permissions.php b/classes/PublishPress/Permissions/DB/Permissions.php index 23e1a585..21c13836 100644 --- a/classes/PublishPress/Permissions/DB/Permissions.php +++ b/classes/PublishPress/Permissions/DB/Permissions.php @@ -395,10 +395,7 @@ public static function addExceptionClauses($where, $required_operation, $post_ty if ('edit' == $required_operation) { if (!empty($user->except['revise_post']['term'][$taxonomy]['additional'][$post_type][''])) { - if (!empty($tt_ids[''])) { $revise_ttids['{published}'] = array_merge($revise_ttids['{published}'], $user->except['revise_post']['term'][$taxonomy]['additional'][$post_type]['']); - $tt_ids[''] = array_diff($tt_ids[''], $revise_ttids['{published}']); - } } } @@ -626,7 +623,22 @@ public static function addTermRestrictionsClause($required_operation, $post_type . "') ) $type_exemption_clause ) $term_additions_clause $post_additions_clause )"; } - return $where; + $args = compact( + 'required_operation', + 'post_type', + 'src_table', + 'merge_additions', + 'exempt_post_types', + 'mod_types', + 'tx_args', + 'additional_ttids', + 'apply_object_additions', + 'term_additions_clause', + 'post_additions_clause', + 'type_exemption_clause' + ); + + return apply_filters('presspermit_term_restrictions_clause', $where, $args); } // returns propagated exceptions items for which (a) the base eitem no longer exists, or (b) the base eitem was changed to "item only" diff --git a/classes/PublishPress/Permissions/PostFilters.php b/classes/PublishPress/Permissions/PostFilters.php index 0a195e11..1f7d3e2c 100644 --- a/classes/PublishPress/Permissions/PostFilters.php +++ b/classes/PublishPress/Permissions/PostFilters.php @@ -153,8 +153,12 @@ public function fltPostsClauses($clauses, $_wp_query = false, $args = []) } if ( + // This solution is deprecated in favor of capability support for list_posts, list_others_pages, etc. + // But with removal of settings checkbox, need to maintain support for sites that rely on this previous workaround, which was enabled by constant PP_ADMIN_READONLY_LISTABLE + // (1) Sites that have the admin_hide_uneditable_posts option stored with false value + // (2) Sites that inadvertantly set options to defaults but want to restore this workaround. Now supporting an additional constant definition (disclosed by support as needed) rather than the checkbox UI. is_admin() && (!$pp->moduleActive('collaboration') || defined('PP_ADMIN_READONLY_LISTABLE')) - && !$pp->getOption('admin_hide_uneditable_posts') + && (!$pp->getOption('admin_hide_uneditable_posts') || defined('PP_ADMIN_NO_FILTER')) ) { return $clauses; } @@ -382,7 +386,7 @@ public function fltPostsWhere($where, $args = []) $valid_stati['future'] = 'future'; } } else { - $valid_stati = PWP::getPostStatuses(['internal' => false, 'post_type' => $post_types], 'names'); + $valid_stati = PWP::getPostStatuses(['internal' => false, 'post_type' => $post_types], 'names', '', ['context' => 'edit']); } if (in_array('attachment', $post_types, true)) { @@ -511,7 +515,7 @@ public function getPostsWhere($args) if (isset($_REQUEST['context']) && ('edit' == $_REQUEST['context'])) { $required_operation = (!empty($_REQUEST['parent_exclude'])) ? 'associate' : 'edit'; // @todo: better criteria } else { - $required_operation = 'read'; + $required_operation = (presspermit_is_preview()) ? 'edit' : 'read'; } } else { $required_operation = (PWP::isFront() && !presspermit_is_preview()) ? 'read' : 'edit'; @@ -547,7 +551,7 @@ public function getPostsWhere($args) $use_statuses = array_merge($use_statuses, $limit_statuses); } } else { - $use_statuses = PWP::getPostStatuses(['internal' => false, 'post_type' => $post_types], 'object'); + $use_statuses = PWP::getPostStatuses(['internal' => false, 'post_type' => $post_types], '', 'object', ['context' => 'edit']); } $use_statuses = apply_filters('presspermit_query_post_statuses', $use_statuses, $args ); @@ -628,13 +632,30 @@ public function getPostsWhere($args) } if ($reqd_caps) { // note: this function is called only for listing query filters (not for user_has_cap filter) - if (apply_filters( + if ($missing_caps = apply_filters( 'presspermit_query_missing_caps', array_diff($reqd_caps, array_keys($user->allcaps)), $reqd_caps, $post_type, $meta_cap )) { + // Support list_posts, list_others_posts, list_pitch_pages etc. for listing uneditable posts on Posts screen + if (('edit' == $required_operation) && empty($args['has_cap_check']) && empty(presspermit()->flags['cap_filter_in_process'])) { + foreach($reqd_caps as $key => $cap) { + if (in_array($cap, $missing_caps)) { + $list_cap = str_replace('edit_', 'list_', $cap); + + if (!empty($user->allcaps[$list_cap])) { + $reqd_caps[$key] = $list_cap; + } + } + } + + if (!array_diff($reqd_caps, array_keys($user->allcaps))) { + $have_site_caps['user'][] = $status; + } + } + // remove "others" and "private" cap requirements for post author $owner_reqd_caps = self::getBaseCaps($reqd_caps, $post_type); diff --git a/classes/PublishPress/Permissions/UI/GroupsQuery.php b/classes/PublishPress/Permissions/UI/GroupsQuery.php index 301bcd97..76987bc4 100644 --- a/classes/PublishPress/Permissions/UI/GroupsQuery.php +++ b/classes/PublishPress/Permissions/UI/GroupsQuery.php @@ -39,10 +39,8 @@ class GroupQuery public function __construct($query = null) { if (!empty($query)) { - global $blog_id; - $this->query_vars = wp_parse_args($query, [ - 'blog_id' => $blog_id, + 'blog_id' => get_current_blog_id(), 'include' => [], 'exclude' => [], 'search' => '', diff --git a/classes/PublishPress/Permissions/UI/HintsPro.php b/classes/PublishPress/Permissions/UI/HintsPro.php index 1c62b191..49bd8b18 100644 --- a/classes/PublishPress/Permissions/UI/HintsPro.php +++ b/classes/PublishPress/Permissions/UI/HintsPro.php @@ -41,6 +41,10 @@ public static function proPromo() background-color: white } +div.pp-logo { + padding-top:20px; +} + div.pp-logo, div.pp-logo img { text-align: left; @@ -51,7 +55,7 @@ public static function proPromo() list-style: none; padding-top: 10px; text-align: left; - margin-left: 50px; + margin-left: 25px; margin-top: 0; } @@ -85,9 +89,8 @@ public static function proPromo()