Skip to content

Commit

Permalink
Merge pull request #1127 from publishpress/release-4.0.25
Browse files Browse the repository at this point in the history
Release 4.0.25
  • Loading branch information
agapetry authored Jun 27, 2024
2 parents 943f619 + 9a65b52 commit f89a687
Show file tree
Hide file tree
Showing 14 changed files with 147 additions and 41 deletions.
38 changes: 38 additions & 0 deletions classes/PressShack/LibWP.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,16 @@ public static function isBlockEditorActive($post_type = '', $args = [])
}
}

// Divi: Classic Editor option
if (function_exists('et_get_option') && ( 'on' == et_get_option( 'et_enable_classic_editor', 'off' ))) {
return false;
}

$pluginsState = array(
'classic-editor' => class_exists( 'Classic_Editor' ),
'gutenberg' => function_exists( 'the_gutenberg_project' ),
'gutenberg-ramp' => class_exists('Gutenberg_Ramp'),
'disable-gutenberg' => class_exists('DisableGutenberg'),
);

$conditions = [];
Expand All @@ -159,6 +165,7 @@ public static function isBlockEditorActive($post_type = '', $args = [])
$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);

Expand All @@ -175,6 +182,9 @@ public static function isBlockEditorActive($post_type = '', $args = [])
$conditions[] = $pluginsState['gutenberg-ramp']
&& apply_filters('use_block_editor_for_post', true, get_post(self::getPostID()), PHP_INT_MAX);

$conditions[] = $pluginsState['disable-gutenberg']
&& !self::disableGutenberg(self::getPostID());

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 All @@ -196,6 +206,34 @@ function ($c) {
return $result;
}

// Port function from Disable Gutenberg plugin due to problematic early is_plugin_active() function call
private static function disableGutenberg($post_id = false) {

if (function_exists('disable_gutenberg_whitelist_id') && disable_gutenberg_whitelist_id($post_id)) return false;

if (function_exists('disable_gutenberg_whitelist_slug') && disable_gutenberg_whitelist_slug($post_id)) return false;

if (function_exists('disable_gutenberg_whitelist_title') && disable_gutenberg_whitelist_title($post_id)) return false;

if (isset($_GET['block-editor'])) return false;

if (isset($_GET['classic-editor'])) return true;

if (isset($_POST['classic-editor'])) return true;

if (function_exists('disable_gutenberg_disable_all') && disable_gutenberg_disable_all()) return true;

if (function_exists('disable_gutenberg_disable_user_role') && disable_gutenberg_disable_user_role()) return true;

if (function_exists('disable_gutenberg_disable_post_type') && disable_gutenberg_disable_post_type()) return true;

if (function_exists('disable_gutenberg_disable_templates') && disable_gutenberg_disable_templates()) return true;

if (function_exists('disable_gutenberg_disable_ids') && disable_gutenberg_disable_ids($post_id)) return true;

return false;
}

public static function sanitizeWord($key)
{
return preg_replace('/[^A-Za-z0-9_\-\.:]/', '', $key);
Expand Down
4 changes: 2 additions & 2 deletions classes/PublishPress/Permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public function isInsertedPost($post_id) {
return !empty($this->inserted_posts[$post_id]);
}

public function capDefs() {
if (!isset($this->cap_defs)) {
public function capDefs($args = []) {
if (!isset($this->cap_defs) || !empty($args['force'])) {
require_once(PRESSPERMIT_CLASSPATH . '/Capabilities.php');
$this->cap_defs = new Permissions\Capabilities();
}
Expand Down
3 changes: 2 additions & 1 deletion classes/PublishPress/Permissions/PostFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ public function fltForcePostMetacapCheck($force, $args)
private function getTeaserPostTypes($post_types, $args = [])
{
if (
is_admin() || presspermit()->isContentAdministrator() || !empty($args['skip_teaser'])
(is_admin() && (!defined('DOING_AJAX') || ! DOING_AJAX))
|| presspermit()->isContentAdministrator() || !empty($args['skip_teaser'])
|| defined('XMLRPC_REQUEST') || (defined('REST_REQUEST') && REST_REQUEST)
) {
return [];
Expand Down
43 changes: 42 additions & 1 deletion classes/PublishPress/Permissions/UI/AgentsDynamicUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,48 @@ private function registerAjaxScripts($agent_type, $id_sfx, $context = '', $agent
$arr = array_merge($args, ['agent_type' => $agent_type, 'ajaxurl' => wp_nonce_url(admin_url(''), 'pp-ajax')]);
wp_localize_script('presspermit-agent-select', 'ppException', $arr);
} else {
wp_localize_script('presspermit-listbox', 'ppListbox', ['omit_admins' => '1', 'metagroups' => 0]);
// @todo: API
$_args = ['omit_admins' => '1', 'metagroups' => 0];

if (!empty($_REQUEST['page']) && ('presspermit-edit-permissions' == $_REQUEST['page'])) {
if ($group = presspermit()->groups()->getGroupByName('[Pending Revision Monitors]')) {
if ($group->ID == $agent_id) {
$_args['omit_admins'] = 0;
}
}

if ($group = presspermit()->groups()->getGroupByName('Pending Revision Monitors')) {
if ($group->ID == $agent_id) {
$_args['omit_admins'] = 0;
}
}

if ($group = presspermit()->groups()->getGroupByName('[Change Request Notifications]')) {
if ($group->ID == $agent_id) {
$_args['omit_admins'] = 0;
}
}

if ($group = presspermit()->groups()->getGroupByName('Change Request Notifications')) {
if ($group->ID == $agent_id) {
$_args['omit_admins'] = 0;
}
}

if ($group = presspermit()->groups()->getGroupByName('Scheduled Revision Monitors')) {
if ($group->ID == $agent_id) {
$_args['omit_admins'] = 0;
}
}

if ($group = presspermit()->groups()->getGroupByName('[Scheduled Revision Monitors]')) {
if ($group->ID == $agent_id) {
$_args['omit_admins'] = 0;
}
}
}

wp_localize_script('presspermit-listbox', 'ppListbox', $_args);

if (!apply_filters('presspermit_override_agent_select_js', false)) {
wp_enqueue_script('presspermit-agent-select', PRESSPERMIT_URLPATH . "/common/js/agent-select{$suffix}.js", ['jquery', 'jquery-form'], PRESSPERMIT_VERSION, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public static function fltUserQueryExceptions($query_obj)

// Filter the Users Query to support various group filtering / sorting parameters

if (PWP::is_REQUEST('orderby', 'pp_group')) {
if (PWP::is_REQUEST('orderby', 'pp_group') && !defined('AC_VERSION')) { // Admin Columns plugin conflict
$query_obj->query_where = " INNER JOIN $wpdb->pp_group_members AS gm ON gm.user_id = $wpdb->users.ID" // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.user_meta__wpdb__users
. " INNER JOIN $wpdb->pp_groups as g ON gm.group_id = g.ID AND g.metagroup_id='' "
. $query_obj->query_where;
Expand Down
6 changes: 5 additions & 1 deletion classes/PublishPress/PermissionsHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ public function fltForceAdvancedDefaults($options)

public function loadFilters()
{
if (!defined('PRESSPERMIT_NO_EARLY_CAPS_INIT')) {
add_action('init', function() {presspermit()->capDefs(['force' => true]);}, 5);
}

add_action('set_current_user', [$this, 'actSetCurrentUser'], 99);
add_action('init', [$this, 'actInit'], 50);
add_action('wp_loaded', [presspermit(), 'refreshUserAllcaps'], 18); // account for any type / condition caps adding by late registration
Expand Down Expand Up @@ -130,7 +134,7 @@ class_alias('\PressShack\LibWP', '\PublishPress\Permissions\UI\Handlers\PWP');
require_once(PRESSPERMIT_CLASSPATH . '/Roles.php');
presspermit()->role_defs = new Permissions\Roles();

if (defined('SSEO_VERSION')) {
if (defined('SSEO_VERSION') && function_exists('sseo_register_parameter')) {
require_once(PRESSPERMIT_CLASSPATH . '/Compat/EyesOnly.php');
new Permissions\Compat\EyesOnly();
}
Expand Down
2 changes: 1 addition & 1 deletion classes/PublishPress/PermissionsHooksAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct()

add_action('admin_menu', [$this, 'actSettingsPageMaybeRedirect'], 999);

if (defined('SSEO_VERSION')) {
if (defined('SSEO_VERSION') && function_exists('sseo_register_parameter')) {
require_once(PRESSPERMIT_CLASSPATH . '/Compat/EyesOnlyAdmin.php');
new Permissions\Compat\EyesOnlyAdmin();
}
Expand Down
Binary file modified languages/press-permit-core-es_ES.mo
Binary file not shown.
Binary file modified languages/press-permit-core-fr_FR.mo
Binary file not shown.
Binary file modified languages/press-permit-core-it_IT.mo
Binary file not shown.
62 changes: 40 additions & 22 deletions languages/press-permit-core.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the same license as the PublishPress Permissions plugin.
msgid ""
msgstr ""
"Project-Id-Version: PublishPress Permissions 4.0.23\n"
"Project-Id-Version: PublishPress Permissions 4.0.25\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/project\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-05-07T18:10:16+00:00\n"
"POT-Creation-Date: 2024-06-27T16:10:02+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.10.0\n"
"X-Domain: press-permit-core\n"
Expand Down Expand Up @@ -470,6 +470,11 @@ msgstr ""
msgid "Edit Permissions (%s)"
msgstr ""

#: classes/PublishPress/Permissions/UI/AgentPermissions.php:170
#: classes/PublishPress/Permissions/UI/Groups.php:179
msgid "Add New"
msgstr ""

#: classes/PublishPress/Permissions/UI/AgentPermissions.php:197
msgid "User Login:"
msgstr ""
Expand Down Expand Up @@ -913,6 +918,10 @@ msgstr ""
msgid "Copy Roles and Permissions from:"
msgstr ""

#: classes/PublishPress/Permissions/UI/AgentPermissionsUI.php:1381
msgid "Do Clone"
msgstr ""

#: classes/PublishPress/Permissions/UI/AgentPermissionsUI.php:1413
msgid "Blocked:"
msgstr ""
Expand Down Expand Up @@ -1325,6 +1334,7 @@ msgid "Permission Groups adjust user access with type-specific Roles and item-sp
msgstr ""

#: classes/PublishPress/Permissions/UI/Groups.php:197
#: classes/PublishPress/Permissions/UI/GroupsListTable.php:325
msgid "WordPress Role"
msgstr ""

Expand Down Expand Up @@ -1830,8 +1840,16 @@ msgstr ""
msgid "PublishPress Revisions integration requires the Collaborative Publishing module. Please notify your Administrator."
msgstr ""

#: includes/CoreAdmin.php:25
msgid "You're using PublishPress Permissions Free. The Pro version has more features and support. %sUpgrade to Pro%s"
msgstr ""

#: includes/CoreAdmin.php:114
#: includes/CoreAdmin.php:115
#: includes/promo/posts-teaser-promo.php:23
#: includes/promo/statuses-promo.php:23
#: includes/promo/sync-promo.php:23
#: includes/promo/visibility-statuses-promo.php:23
msgid "Upgrade to Pro"
msgstr ""

Expand Down Expand Up @@ -2266,7 +2284,7 @@ msgid "Pages can be set or removed from Top Level by:"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:52
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:351
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:347
msgid "Specified element IDs also require the following site-wide Role:"
msgstr ""

Expand Down Expand Up @@ -2350,76 +2368,76 @@ msgstr ""
msgid "Assign Publish Permissions separate from Edit Permissions"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:198
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:194
msgid "lock"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:269
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:265
msgid "no Page Parent filter"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:269
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:265
msgid "Page Authors, Editors and Administrators"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:269
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:265
msgid "Page Editors and Administrators"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:269
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:265
msgid "Administrators"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:310
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:306
msgid "Edit Form HTML IDs:"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:320
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:316
msgid "%1$s sample IDs:%2$s %3$s"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:353
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:360
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:349
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:356
msgid "Content Administrator"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:356
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:352
msgid "no requirement"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:357
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:353
msgid "Contributor / Author / Editor"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:358
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:354
msgid "Author / Editor"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:361
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:357
msgid "User Administrator"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:362
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:358
msgid "Option Administrator"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:398
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:394
msgid "The following settings apply to users who have the upload_files or edit_files capability:"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:452
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:446
msgid "User editing capabilities apply for"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:455
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:449
msgid "any user"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:455
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:449
msgid "equal or lower role levels"
msgstr ""

#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:455
#: modules/presspermit-collaboration/classes/Permissions/Collab/UI/SettingsTabEditing.php:449
msgid "lower role levels"
msgstr ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ function optionSections($sections)
'post_forking' => ['fork_published_only', 'fork_require_edit_others'],
];

if (!presspermit()->getOption('define_media_post_caps')) {
$new['media_library'] = array_diff($new['media_library'], ['attachment_edit_requires_parent_access']);
}

if (!PWP::isBlockEditorActive()) {
if (presspermit()->getOption('advanced_options'))
$new['limited_editing_elements'] = ['editor_hide_html_ids', 'editor_ids_sitewide_requirement'];
Expand Down Expand Up @@ -409,9 +405,7 @@ function optionsUI()

$ret = $ui->optionCheckbox('edit_others_attached_files', $tab, $section, true, '');

if (presspermit()->getOption('define_media_post_caps')) {
$ret = $ui->optionCheckbox('attachment_edit_requires_parent_access', $tab, $section, true, '');
}
$ret = $ui->optionCheckbox('attachment_edit_requires_parent_access', $tab, $section, true, '');

$ret = $ui->optionCheckbox('own_attachments_always_editable', $tab, $section, true, '');
?>
Expand Down
6 changes: 3 additions & 3 deletions press-permit-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Advanced yet accessible content permissions. Give users or groups type-specific roles. Enable or block access for specific posts or terms.
* Author: PublishPress
* Author URI: https://publishpress.com/
* Version: 4.0.23
* Version: 4.0.25
* Text Domain: press-permit-core
* Domain Path: /languages/
* Requires at least: 5.5
Expand Down Expand Up @@ -201,8 +201,8 @@ function presspermit_load() {
if (is_admin() && isset($pagenow) && ('customize.php' == $pagenow)) {
return;
}
define('PRESSPERMIT_VERSION', '4.0.23');

define('PRESSPERMIT_VERSION', '4.0.25');

if (!defined('PRESSPERMIT_READ_PUBLIC_CAP')) {
define('PRESSPERMIT_READ_PUBLIC_CAP', 'read');
Expand Down
Loading

0 comments on commit f89a687

Please sign in to comment.