Skip to content

Commit

Permalink
Merge pull request #1313 from publishpress/release-4.1.0
Browse files Browse the repository at this point in the history
Release 4.1.0
  • Loading branch information
richaferry authored Dec 18, 2024
2 parents 876d9df + b3c2218 commit fa0942e
Show file tree
Hide file tree
Showing 51 changed files with 14,710 additions and 10,326 deletions.
17 changes: 12 additions & 5 deletions classes/PressShack/LibWP.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static function isBlockEditorActive($post_type = '', $args = [])
}
}

$use_block = $use_block && apply_filters('use_block_editor_for_post_type', $use_block, $post_type, PHP_INT_MAX);
$use_block = $use_block && apply_filters('use_block_editor_for_post_type', $use_block, $post_type);

if (version_compare($wp_version, '5.9-beta', '>=') && !empty($has_nav_filter)) {
add_filter('use_block_editor_for_post_type', '_disable_block_editor_for_navigation_post_type', 10, 2 );
Expand Down Expand Up @@ -162,12 +162,14 @@ public static function isBlockEditorActive($post_type = '', $args = [])
}
}

$_post = get_post(self::getPostID());

$conditions[] = (self::isWp5() || $pluginsState['gutenberg'])
&& ! $pluginsState['classic-editor']
&& ! $pluginsState['gutenberg-ramp']
&& ! $pluginsState['disable-gutenberg']
&& apply_filters('use_block_editor_for_post_type', true, $post_type, PHP_INT_MAX)
&& apply_filters('use_block_editor_for_post', true, get_post(self::getPostID()), PHP_INT_MAX);
&& apply_filters('use_block_editor_for_post_type', true, $post_type)
&& (empty($_post) || !is_a($_post, 'WP_Post') || apply_filters('use_block_editor_for_post', true, $_post));

$conditions[] = self::isWp5()
&& $pluginsState['classic-editor']
Expand All @@ -180,7 +182,7 @@ public static function isBlockEditorActive($post_type = '', $args = [])
&& self::is_GET('classic-editor__forget'));

$conditions[] = $pluginsState['gutenberg-ramp']
&& apply_filters('use_block_editor_for_post', true, get_post(self::getPostID()), PHP_INT_MAX);
&& (empty($_post) || !is_a($_post, 'WP_Post') || apply_filters('use_block_editor_for_post', true, $_post));

$conditions[] = $pluginsState['disable-gutenberg']
&& !self::disableGutenberg(self::getPostID());
Expand Down Expand Up @@ -837,7 +839,12 @@ public static function postAuthorClause($args = []) {
'join' => '',
];

if ($ppma_active = defined('PUBLISHPRESS_MULTIPLE_AUTHORS_VERSION') && version_compare(PUBLISHPRESS_MULTIPLE_AUTHORS_VERSION, '3.8.0', '>=') && !empty($args['join']) && strpos($args['join'], 'ppma_t')) {
if ($ppma_active = defined('PUBLISHPRESS_MULTIPLE_AUTHORS_VERSION')
&& version_compare(PUBLISHPRESS_MULTIPLE_AUTHORS_VERSION, '3.8.0', '>=')
&& !empty($args['join'])
&& strpos($args['join'], 'ppma_t')
&& (empty($args['context']) || ('tally_term_counts' != $args['context']))
) {
$defaults['join_table'] = 'ppma_t';
}

Expand Down
4 changes: 4 additions & 0 deletions classes/PublishPress/Permissions/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public function forceDistinctPostCaps()

// post types which are enabled for PP filtering must have distinct type-related cap definitions
foreach ($enabled_types as $post_type) {
if (empty($wp_post_types[$post_type]) || empty($wp_post_types[$post_type]->cap)) {
continue;
}

if (('attachment' == $post_type) && !$pp->getOption('define_media_post_caps')) {
if (isset($wp_post_types['attachment']) && is_object($wp_post_types['attachment']->cap)) {
foreach(['edit_posts', 'edit_others_posts', 'delete_posts', 'delete_others_posts'] as $_post_cap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function fltAdjustReqdCaps($reqd_caps, $orig_cap, $user_id, $args)
}

if ($did_admin_init) {
if (!empty($args[0])) {
if (!empty($args[0]) && (is_scalar($args[0]) || !empty($args[0]->ID))) {
$item_id = (is_object($args[0])) ? $args[0]->ID : (int) $args[0];
} else {
$item_id = 0;
Expand Down
2 changes: 1 addition & 1 deletion classes/PublishPress/Permissions/DB/DatabaseSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private static function updateSchema($last_db_ver = false)
";

// For existing installations, don't risk existing data violating unique key requirement
$unique = ($last_db_ver) ? '' : 'UNIQUE ';
$unique = ($last_db_ver && defined('PRESSPERMIT_LEGACY_DB_SETUP')) ? '' : 'UNIQUE ';

// User2Group table def
$tabledefs .= "CREATE TABLE $wpdb->pp_group_members (
Expand Down
6 changes: 5 additions & 1 deletion classes/PublishPress/Permissions/PostFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,11 @@ public static function constructPostsRequest($clauses = [], $args = [])
}

public function fltPostsJoin($join, $args = []) {
if (!defined('PUBLISHPRESS_MULTIPLE_AUTHORS_VERSION') || !version_compare(PUBLISHPRESS_MULTIPLE_AUTHORS_VERSION, '3.8.0', '>=') || defined('PRESSPERMIT_DISABLE_AUTHORS_JOIN')) {
if (!defined('PUBLISHPRESS_MULTIPLE_AUTHORS_VERSION')
|| !version_compare(PUBLISHPRESS_MULTIPLE_AUTHORS_VERSION, '3.8.0', '>=')
|| defined('PRESSPERMIT_DISABLE_AUTHORS_JOIN')
|| (!empty($args['context']) && ('tally_term_counts' == $args['context']))
) {
return $join;
}

Expand Down
3 changes: 2 additions & 1 deletion classes/PublishPress/Permissions/PostFiltersExtra.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public static function fltPostsRequest($request, $args = [])
// Other plugins need to use switch_to_blog() rather than just executing a query on a non-main site.
$matches = [];
if (preg_match('/SELECT .* FROM [^ ]+posts AS ([^ ]) .*/', $request, $matches)) {
$args['source_alias'] = $matches[2];
$args['source_alias'] = $matches[1];

} elseif ($return = preg_match('/SELECT .* FROM ([^ ]+)posts .*/', $request, $matches)) {
$args['source_alias'] = $matches[1] . 'posts';
}
Expand Down
4 changes: 3 additions & 1 deletion classes/PublishPress/Permissions/REST.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ function fltRestPostCapRequirement($orig_cap, $item_id)

if ($type_obj = get_post_type_object($post_type)) {
if ($orig_cap == $type_obj->cap->read_post) {
$orig_cap = $type_obj->cap->edit_post;
if ('auto-draft' != get_post_field('post_status', $item_id)) {
$orig_cap = $type_obj->cap->edit_post;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions classes/PublishPress/Permissions/TermQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public static function tallyTermCounts(&$terms, $taxonomy, $args = [])

if ( class_exists('\PublishPress\Permissions\PostFilters') && ! presspermit()->isUserUnfiltered() ) {
// will default to src_table $wpdb->posts
$join = \PublishPress\Permissions\PostFilters::instance()->fltPostsJoin('', []);
$join = \PublishPress\Permissions\PostFilters::instance()->fltPostsJoin('', ['context' => 'tally_term_counts']);

// need to apply term restrictions in case post is restricted by another taxonomy
$type_status_clause = \PublishPress\Permissions\PostFilters::instance()->getPostsWhere(
['post_types' => $object_types, 'required_operation' => $required_operation, 'join' => $join]
['post_types' => $object_types, 'required_operation' => $required_operation, 'join' => $join, 'context' => 'tally_term_counts']
);
} else {
$join = '';
Expand Down
Loading

0 comments on commit fa0942e

Please sign in to comment.