Skip to content

Commit

Permalink
Merge pull request #1166 from publishpress/release-4.0.30
Browse files Browse the repository at this point in the history
Release 4.0.30
  • Loading branch information
agapetry authored Sep 26, 2024
2 parents 0b8dc64 + a879fca commit 2633bb1
Show file tree
Hide file tree
Showing 23 changed files with 764 additions and 472 deletions.
1 change: 1 addition & 0 deletions classes/PublishPress/Permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ private function load($args = [])
'suppress_administrator_metagroups' => 0,
'users_bulk_groups' => 1,
'limit_front_end_term_filtering' => 0,
'list_all_constants' => 0,
];
$this->default_advanced_options = apply_filters('presspermit_default_advanced_options', $this->default_advanced_options);

Expand Down
164 changes: 125 additions & 39 deletions classes/PublishPress/Permissions/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class Constants
public $constants_by_type = [];

public function __construct() {
do_action('presspermit_load_constants');

$this->loadConstants();
$this->loadConstantTypes();
}
Expand Down Expand Up @@ -38,8 +40,22 @@ private function loadConstants() {
'PP_FUTURE_POSTS_BLOGROLL' => esc_html__("Include scheduled posts in the posts query if user can edit them", 'press-permit-core-hints'),
'PP_UNFILTERED_TERM_COUNTS' => esc_html__("Don't filter term post counts in get_terms() call", 'press-permit-core-hints'),
'PP_DISABLE_NAV_MENU_FILTER' => esc_html__("Leave unreadable posts on WP Navigation Menus", 'press-permit-core-hints'),
'PRESSPERMIT_NO_NAV_MENU_SCRIPTS' => esc_html__("Don't apply CSS to hide empty Nav Menus", 'press-permit-core-hints'),
'PRESSPERMIT_HIDE_EMPTY_NAV_MENU_DIV' => esc_html__("For legacy Nav Menus, hide empty nav menu div", 'press-permit-core-hints'),
'PP_NAV_MENU_SHOW_EMPTY_TERMS' => esc_html__("Leave terms with no readable posts on WP Navigation Menus", 'press-permit-core-hints'),
];

if (defined('PRESSPERMIT_TEASER_VERSION')) {
$consts = array_merge(
$consts,
[
'PRESSPERMIT_TEASER_REDIRECT_ARG' => esc_html__("When Teaser is applied with Redirect enabled, append original url as redirect_to argument", 'press-permit-core-hints'),
'PRESSPERMIT_TEASER_REDIRECT_VAR' => esc_html__("For Teaser compatibility, specify a redirect argument to use instead of redirect_to", 'press-permit-core-hints'),
'PRESSPERMIT_TEASER_REDIRECT_ALTERNATE' => esc_html__("For Teaser compatibility, specify an additional redirect argument other than redirect_to", 'press-permit-core-hints'),
'PRESSPERMIT_TEASER_LOGIN_REDIRECT_NO_PP_ARG' => esc_html__("For Teaser compatibility, prevent the pp_permissions argument from being appended to redirects", 'press-permit-core-hints'),
]
);
}
foreach ($consts as $k => $v) $this->constants[$k] = (object)['descript' => $v, 'type' => $type];

$type = 'get-pages';
Expand All @@ -49,8 +65,16 @@ private function loadConstants() {
'PPC_FORCE_PAGE_REMAP' => esc_html__("If some pages have been suppressed from get_pages() results, change child pages' corresponding post_parent values to a visible ancestor", 'press-permit-core-hints'),
'PPC_NO_PAGE_REMAP' => esc_html__("Never modify the post_parent value in the get_pages() result set, even if some pages have been suppressed", 'press-permit-core-hints'),
'PP_GET_PAGES_LEAN' => esc_html__("For performance, change the get_pages() database query to return only a subset of fields, excluding post_content", 'press-permit-core-hints'),
'PP_TEASER_HIDE_PAGE_LISTING' => esc_html__("PRO: Don't apply content teaser to get_pages() results (leave unreadable posts hidden)", 'press-permit-core-hints'),
];

if (defined('PRESSPERMIT_TEASER_VERSION')) {
$consts = array_merge(
$consts,
[
'PP_TEASER_HIDE_PAGE_LISTING' => esc_html__("PRO: Don't apply content teaser to get_pages() results (leave unreadable posts hidden)", 'press-permit-core-hints'),
]
);
}
foreach ($consts as $k => $v) $this->constants[$k] = (object)['descript' => $v, 'type' => $type];

$type = 'get-terms';
Expand All @@ -60,24 +84,47 @@ private function loadConstants() {
];
foreach ($consts as $k => $v) $this->constants[$k] = (object)['descript' => $v, 'type' => $type];


$type = 'post-author';
$consts = [
'PRESSPERMIT_AUTOSET_AUTHOR' => esc_html__("Set Author to current user if autoset_post_author / autoset_page_author capability is assigned", 'press-permit-core-hints'),
];
foreach ($consts as $k => $v) $this->constants[$k] = (object)['descript' => $v, 'type' => $type];


$type = 'media';
$consts = [
'PP_MEDIA_LIB_UNFILTERED' => esc_html__("Leave Media Library with normal access criteria based on user's role capabilities ", 'press-permit-core-hints'),
'PRESSPERMIT_MEDIA_UPLOAD_GRANT_PAGE_EDIT_CAPS' => esc_html__("Accommodate front end uploading solutions that require page editing capabilities for the async upload request", 'press-permit-core-hints'),
'PRESSPERMIT_MEDIA_IGNORE_UNREGISTERED_PARENT_TYPES' => esc_html__('Treat media attached to unregistered post types as unattached, to avoid improper and confusing filtering', 'press-permit-core-hints'),
];

if (defined('PRESSPERMIT_FILE_ACCESS_VERSION')) {
$consts = array_merge(
$consts,
[
'PP_ATTACHED_FILE_AUTOPRIVACY' => esc_html__("Attached Files Private setting available", 'press-permit-core-hints'),
'PPFF_EXCLUDE_MIME_TYPES' => esc_html__("Comma-separated list of mime types to exclude from File Access filtering", 'press-permit-core-hints'),
'PPFF_INCLUDE_MIME_TYPES' => esc_html__("Comma-separated list of mime types to include in File Access filtering (bypassing others)", 'press-permit-core-hints'),
'PP_QUIET_FILE_404' => esc_html__("When file access is blocked, do not set the WP_Query 404 / 403 property", 'press-permit-core-hints'),
'PPFF_STATUS_CODE' => esc_html__("HTTP status code to send when file access is blocked", 'press-permit-core-hints'),
]
);
}
foreach ($consts as $k => $v) $this->constants[$k] = (object)['descript' => $v, 'type' => $type];

$type = 'admin';
$consts = [
'PP_USERS_UI_GROUP_FILTER_LINK' => esc_html__("On Users listing, Permission groups in custom column are list filter links instead of group edit links", 'press-permit-core-hints'),
'PP_ADMIN_READONLY_LISTABLE' => esc_html__("Unlock Permissions > Settings > Core > Admin Back End > 'Hide non-editable posts'", 'press-permit-core-hints'),
'PP_UPLOADS_FORCE_FILTERING' => esc_html__("Within the async-upload.php script, filtering author's retrieval of the attachment they just uploaded", 'press-permit-core-hints'),
'PP_ADMIN_TERMS_READONLY_LISTABLE' => esc_html__("Unlock Permissions > Settings > Core > Admin Back End > 'Hide non-editable posts'", 'press-permit-core-hints'),
'PP_UPLOADS_FORCE_FILTERING' => esc_html__("Within the async-upload.php script, filter author's retrieval of the attachment they just uploaded", 'press-permit-core-hints'),
'PP_NO_COMMENT_FILTERING' => esc_html__("Don't filter comment display or moderation within wp-admin", 'press-permit-core-hints'),
];
foreach ($consts as $k => $v) $this->constants[$k] = (object)['descript' => $v, 'type' => $type];

$type = 'permissions-admin';
$consts = [
'PP_DISABLE_BULK_ROLES' => "",
'PP_FORCE_EXCEPTION_OVERWRITE' => esc_html__("If propagating permissions are assigned to a page branch, overwrite any explicitly assigned permissions in sub-pages", 'press-permit-core-hints'),
'PP_EXCEPTIONS_MAX_INSERT_ROWS' => esc_html__("Max number of specific permissions to insert in a single database query (default 1000)", 'press-permit-core-hints'),
'PP_DISABLE_MENU_TWEAK' => esc_html__("Don't tweak the admin menu indexes to position Permissions menu under Users", 'press-permit-core-hints'),
Expand Down Expand Up @@ -112,19 +159,15 @@ private function loadConstants() {
];
foreach ($consts as $k => $v) $this->constants[$k] = (object)['descript' => $v, 'type' => $type];

$type = 'user-sync';
$consts = [
'PP_SKIP_USER_SYNC' => esc_html__("Don't auto-assign role metagroups for all users. Instead, assign per-user at first login.", 'press-permit-core-hints'),
'PP_AUTODELETE_ROLE_METAGROUPS' => esc_html__("When synchronizing role metagroups to currently defined WP roles, don't delete groups for previously defined WP roles.", 'press-permit-core-hints'),
];
foreach ($consts as $k => $v) $this->constants[$k] = (object)['descript' => $v, 'type' => $type];

$type = 'force-pp-settings';
$type = 'users';
$consts = [
'PP_AUTODELETE_ROLE_METAGROUPS' => esc_html__("When synchronizing role metagroups to currently defined WP roles, don't delete groups for previously defined WP roles.", 'press-permit-core-hints'),
'PP_FORCE_DYNAMIC_ROLES' => esc_html__("Force detection of WP user roles which are appended dynamically but not stored to the WP database.", 'press-permit-core-hints'),
];
foreach ($consts as $k => $v) $this->constants[$k] = (object)['descript' => $v, 'type' => $type];


$type = 'perf';
$consts = [
'PP_NO_FRONTEND_ADMIN' => esc_html__("To save memory on front end access, don't register any filters related to content editing", 'press-permit-core-hints'),
Expand All @@ -136,13 +179,8 @@ private function loadConstants() {
];
foreach ($consts as $k => $v) $this->constants[$k] = (object)['descript' => $v, 'type' => $type];

$type = 'wp-compat';
$consts = [
'PP_UNFILTERED_PAGE_URI' => esc_html__("Don't restore pre-4.4 behavior of not requiring 'publish' status for inclusion in page uri hierarchy", 'press-permit-core-hints'),
];
foreach ($consts as $k => $v) $this->constants[$k] = (object)['descript' => $v, 'type' => $type];


/*
if (defined('PUBLISHPRESS_REVISIONS_VERSION') || defined("REVISIONARY_VERSION")) {
$type = 'third-party';
$consts = [
Expand All @@ -151,41 +189,89 @@ private function loadConstants() {
];
foreach ($consts as $k => $v) $this->constants[$k] = (object)['descript' => $v, 'type' => $type];
}
*/

$type = 'support';
$consts = [
'PPI_LEGACY_UPLOAD' => "",
'PPI_ERROR_LOG_UPLOAD_LIMIT' => "",
];
foreach ($consts as $k => $v) $this->constants[$k] = (object)['descript' => $v, 'type' => $type, 'suppress_display' => true];
$this->constants = apply_filters('presspermit_constants', $this->constants);

$arr = [];

$type = 'debug-dev';
$type = 'debug-dev-unsupported';
$consts = [
'PRESSPERMIT_DEBUG' => "",
'PRESSPERMIT_DEBUG_LOGFILE' => "",
'PRESSPERMIT_MEMORY_LOG' => "",
'AGP_NO_USAGE_MSG' => "",
'PRESSPERMIT_DEBUG_ACTIVATE_KEY' => "",
'PRESSPERMIT_DEBUG_DEACTIVATE_KEY' => "",
'PRESSPERMIT_DEBUG_UPDATE_CHECK_PPC' => "",
'PRESSPERMIT_DEBUG_EXT_INFO' => "",
'PRESSPERMIT_DEBUG_CHANGELOG_PPC' => "",
'PRESSPERMIT_DEBUG_CONFIG_CHECK' => "",
'PRESSPERMIT_DEBUG_CONFIG_UPLOAD' => "",
'PP_FORCE_PPCOM_INFO' => "",
'PP_DISABLE_CAP_CACHE' => "",
'PP_FILTER_JSON_REST' => "",
'PRESSPERMIT_DISABLE_TERM_PREASSIGN' => '',
'PP_DISABLE_UNFILTERED_TYPES_CLAUSE' => esc_html__("Development use only (suppresses post_status = 'publish' clause for unfiltered post types with anonymous user)", 'press-permit-core-hints'),
'PP_RETAIN_PUBLISH_FILTER' => esc_html__("Development use only (on front end, do not replace 'post_status = 'publish'' clause with filtered equivalent)", 'press-permit-core-hints'),
'PP_GET_TERMS_SHORTCUT' => "",
'PP_LEGACY_HTTP_REDIRECT' => "",
'PP_AGENTS_CAPTION_LIMIT' => "",
'PP_AGENTS_EMSIZE_THRESHOLD' => "",
'PP_UI_EMS_PER_CHARACTER' => "",
'PP_DISABLE_BULK_ROLES' => "",
'PUBLISHPRESS_ACTION_PRIORITY_INIT' => '',
'PRESSPERMIT_NO_EARLY_CAPS_INIT' => '',
'PRESSPERMIT_DISABLE_QUERYFILTERS' => '',
'PP_ADMIN_POSTS_NO_FILTER' => '',
'PRESSPERMIT_FORCE_POST_FILTERING' => '',
'PRESSPERMIT_DISABLE_POST_COUNT_FILTER' => '',
'PP_NO_PROPAGATING_EXCEPTION_DELETION' => '',
'PP_EXCEPTIONS_MAX_INSERT_ROWS' => '',
'PP_FORCE_EXCEPTION_OVERWRITE' => '',
'PP_DISABLE_OPTIMIZED_EXCEPTIONS' => '',
'PRESSPERMIT_SAVE_POST_ALLOW_BYPASS' => '',
'PRESSPERMIT_AUTOSAVE_BYPASS_SAVE_FILTERS' => '',
'PP_GET_PAGES_LIMIT_ADMIN_FILTERING' => '',
'PRESSPERMIT_GET_PAGES_DISABLE_IN_CLAUSE' => '',
'PRESSPERMIT_GET_PAGES_IGNORE_EXCLUDE_ARGS' => '',
'PP_LEGACY_PAGE_URI_FILTER' => '',
//'PRESSPERMIT_READ_PUBLIC_CAP' => '',
'PRESSPERMIT_STRICT_READ_CAP' => '',
'PRESSPERMIT_SIMPLIFY_READ_PERMISSIONS' => '',
'PRESSPERMIT_LEGACY_HOOKS' => '',
'PRESSPERMIT_NO_LEGACY_API' => '',
'PRESSPERMIT_FIND_POST_TYPE_NO_DEFAULT_TYPE' => '',
'PRESSPERMIT_LIMIT_ASYNC_UPLOAD_FILTERING' => '',
'PRESSPERMIT_FILTER_PRIVATE_TAXONOMIES' => '',
'PUBLISHPRESS_PERMISSIONS_MENU_GROUPING' => '',
'PP_DEFAULT_APPEARANCE_MENU' => '',
'PRESSPERMIT_TILE' => '',
'PRESSPERMIT_LEGACY_POST_TYPE_ENABLE_METABOX' => '',
'PP_LEGACY_POST_TAG_CAPS' => '',
'PRESSPERMIT_NO_PROCESS_BEFORE_REDIRECT' => '',
'PRESSPERMIT_MENU_EDITOR_ADD_UNPUBLISHED' => '',
'PP_NAV_MENU_ENABLE_POSTMETA_FILTER' => '',
'PP_NAV_MENU_DISABLE_POSTMETA_FILTER' => '',
'PRESSPERMIT_EDIT_NAV_MENUS_NO_PAGING' => '',
'PP_PAGE_PARENT_NOPAGING' => '',
];
foreach ($consts as $k => $v) $this->constants[$k] = (object)['descript' => $v, 'type' => $type, 'suppress_display' => true];
foreach ($consts as $k => $v) $arr[$k] = (object)['descript' => $v, 'type' => $type];

$this->constants = apply_filters('presspermit_constants', $this->constants);

$type = 'deprecated';
$consts = [
'PRESSPERMIT_TERM_FILTERS_LEGACY_LOAD' => '',
'PP_LEGACY_POST_BLOCKAGE' => '',
'PP_GET_PAGES_LEGACY_FILTER' => '',
'PP_LEGACY_REST_FILTERING' => '',
'PRESSPERMIT_LEGACY_ADMIN_TERM_COUNT_FILTER' => '',
'PRESSPERMIT_LEGACY_SAVE_POST_TERM_ASSIGNMENT' => '',
'PRESSPERMIT_LEGACY_PREASSIGN_TERMS' => '',
'PRESSPERMIT_LEGACY_COMMENT_FILTERING' => '',
'PRESSPERMIT_LEGACY_MAIN_SITE_CHECK' => '',
'PRESSPERMIT_NAV_MENU_EDIT_DEBUG' => '',
'PP_AGENTS_CAPTION_LIMIT' => '',
'PP_AGENTS_EMSIZE_THRESHOLD' => '',
'PP_UI_EMS_PER_CHARACTER' => '',
'PP_FILTER_JSON_REST' => '',
'PRESSPERMIT_NO_USER_LOCALE' => '',
'PP_FORCE_PLUGIN_MENU' => '',
'PP_FORCE_USERS_MENU' => '',
'PRESSPERMIT_OWN_DESCENDENT_CHECK' => '',
'PRESSPERMIT_FILTER_VALIDATE_PAGE_PARENT' => '',
'PRESSPERMIT_NO_PROCESS_BEFORE_PARENT_REVERT' => '',
'PRESSPERMIT_PAGE_LISTING_FLUSH_CACHE' => '',
];
foreach ($consts as $k => $v) $arr[$k] = (object)['descript' => $v, 'type' => $type];

$this->constants = $this->constants + $arr;

} // end function

Expand Down
58 changes: 58 additions & 0 deletions classes/PublishPress/Permissions/UI/AgentPermissionsAjax.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,64 @@ public function __construct() {

echo '<!--ppResponse-->' . 'exceptions_mirror' . '~' . esc_attr(implode('|', $edited_input_ids)) . '<--ppResponse-->';
break;
} elseif (0 === strpos($action, 'exceptions_convert_')) {

$arr = explode('_', $action);

if (count($arr) < 3) {
break;
}

$modification = $arr[2];

if (!in_array($modification, ['include', 'exclude', 'additional'])) {
break;
}

$edited_input_ids = [];
$all_eitem_ids = [];

$input_vals = (!empty($_GET['pp_eitem_ids'])) ? explode('|', PWP::sanitizeCSV(sanitize_text_field($_GET['pp_eitem_ids']))) : [];

if (!$input_vals) {
exit;
}

foreach ($input_vals as $id_csv) {
$eitem_ids = $this->editableEitemIDs(explode(',', $id_csv));

if ($agent_type && $agent_id) {
$agent_clause = "e.agent_type = '$agent_type' AND e.agent_id = '$agent_id' AND";
} else {
$agent_clause = '';
}

$eitem_id_csv = implode("','", array_map('intval', $eitem_ids));

$mod_type_clause = $wpdb->prepare("AND e.mod_type != %s", $modification); // don't change exceptions that already have requested mod_type

// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
foreach ($results = $wpdb->get_results(
"SELECT * FROM $wpdb->ppc_exception_items AS i"
. " INNER JOIN $wpdb->ppc_exceptions AS e ON i.exception_id = e.exception_id"
. " WHERE $agent_clause eitem_id IN ('$eitem_id_csv') $mod_type_clause" // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
) as $row) {
$args = (array)$row;
$args['mod_type'] = $modification;
$agents = [$row->assign_for => [$agent_id => true]];
$pp->assignExceptions($agents, $agent_type, $args);

$edited_input_ids[] = $id_csv;
$all_eitem_ids[] = $row->eitem_id;
}
}

\PublishPress\Permissions\DB\PermissionsUpdate::removeExceptionItemsById($all_eitem_ids);

do_action('presspermit_exception_items_converted', $all_eitem_ids, $agent_type, $agent_id);

echo '<!--ppResponse-->' . 'exceptions_convert' . '~' . esc_attr(implode('|', $edited_input_ids)) . '<--ppResponse-->';
break;
}

} // end switch
Expand Down
13 changes: 13 additions & 0 deletions classes/PublishPress/Permissions/UI/AgentPermissionsUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static function exceptionAssignmentScripts()
'submissionMsg' => esc_html__('Permissions submission in progress...', 'press-permit-core'),
'reloadRequired' => esc_html__('Reload form for further changes to this permission', 'press-permit-core'),
'mirrorDone' => esc_html__('Permissions mirrored. Reload form to view newly saved permissions.', 'press-permit-core'),
'convertDone' => esc_html__('Permissions converted. Reload form to view newly saved permissions.', 'press-permit-core'),
'noMode' => esc_html__('No Qualification selected!', 'press-permit-core'),
'ajaxurl' => wp_nonce_url(admin_url(''), 'pp-ajax'),
];
Expand Down Expand Up @@ -1093,6 +1094,12 @@ public static function currentExceptionsUI($exc_results, $args = [])
$_op = $operation;
}

$convert_caption = [
'additional' => __('Convert to "Enabled"', 'press-permit-core'),
'exclude' => __('Convert to "Blocked"', 'press-permit-core'),
'include' => __('Convert to "Limit to"', 'press-permit-core'),
];

if (in_array($via_src, ['post', 'term'])) {
switch ($_op) {
case 'read':
Expand Down Expand Up @@ -1160,6 +1167,12 @@ public static function currentExceptionsUI($exc_results, $args = [])
. esc_html($caption)
. '</option>';
}

foreach (['additional', 'exclude', 'include'] as $_mod_type) {
echo "<option value='convert_" . esc_attr($_mod_type) . "'>"
. $convert_caption[$_mod_type]
. '</option>';
}
}

echo '</select>';
Expand Down
2 changes: 1 addition & 1 deletion classes/PublishPress/Permissions/UI/AgentsAjax.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function __construct()
$args = [
'fields' => ['ID', 'user_login', 'display_name'],
'search' => $search_str,
'search_columns' => ['user_login', 'user_nicename', 'display_name'],
'search_columns' => ['user_login', 'user_nicename', 'display_name', 'user_email'],
'include' => $include_ids,
'role' => $role_filter,
'orderby' => $orderby,
Expand Down
Loading

0 comments on commit 2633bb1

Please sign in to comment.