Skip to content

Commit

Permalink
Merge pull request #132 from publishpress/release/3.2.2
Browse files Browse the repository at this point in the history
Release/3.2.2
  • Loading branch information
agapetry authored Jul 8, 2020
2 parents cb714dd + 04d1377 commit 4aba916
Show file tree
Hide file tree
Showing 27 changed files with 504 additions and 317 deletions.
4 changes: 2 additions & 2 deletions classes/PressShack/LibWP.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -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)
Expand Down
20 changes: 16 additions & 4 deletions classes/PublishPress/Permissions/DB/Permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}']);
}
}
}

Expand Down Expand Up @@ -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"
Expand Down
31 changes: 26 additions & 5 deletions classes/PublishPress/Permissions/PostFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 1 addition & 3 deletions classes/PublishPress/Permissions/UI/GroupsQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '',
Expand Down
11 changes: 7 additions & 4 deletions classes/PublishPress/Permissions/UI/HintsPro.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -85,9 +89,8 @@ public static function proPromo()
</style>

<div id="pp_features" style="display:none">
<div class="pp-logo"><a href="https://publishpress.com">
<img src="<?php echo $img_url; ?>pp-logo.png"/></a>

<div class="pp-logo">
<p></p>
<ul class="pp-features">

<li>
Expand Down
26 changes: 14 additions & 12 deletions classes/PublishPress/Permissions/UI/SettingsTabCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function optionCaptions($captions)
'display_user_profile_groups' => __('Permission Groups on User Profile', 'press-permit-core'),
'display_user_profile_roles' => __('Supplemental Roles on User Profile', 'press-permit-core'),
'new_user_groups_ui' => __('Select Permission Groups at User creation', 'press-permit-core'),
'admin_hide_uneditable_posts' => __('Hide non-editable posts', 'press-permit-core'),
'post_blockage_priority' => __('Post-specific Permissions take priority', 'press-permit-core'),
];

Expand Down Expand Up @@ -301,18 +300,21 @@ public function optionsUI()
<?php
$ui->optionCheckbox('display_branding', $tab, $section, '');

$listable = defined('PP_ADMIN_READONLY_LISTABLE');

$hint = ($pp->moduleExists('collaboration') && !$listable)
? __('Note: To allow listing of uneditable posts in wp-admin, define constant PP_ADMIN_READONLY_LISTABLE', 'press-permit-core')
: '';

$args = ($pp->moduleActive('collaboration') && !$listable)
? ['val' => 1, 'disabled' => true, 'no_storage' => true]
: [];

$ui->optionCheckbox('admin_hide_uneditable_posts', $tab, $section, $hint, '', $args);
if (defined('PP_ADMIN_READONLY_LISTABLE') && (!$pp->getOption('admin_hide_uneditable_posts') || defined('PP_ADMIN_POSTS_NO_FILTER'))) {
$hint = __('Unmodified from WordPress default behavior. To enable filtering, remove constant definition PP_ADMIN_READONLY_LISTABLE.', 'press-permit-core');
} else {
$hint = ($pp->moduleActive('collaboration'))
? __('Uneditable posts are hidden from wp-admin listings. To expose them, use a role editor to add desired capabilities: list_posts, list_other_pages etc.', 'press-permit-core')
: __('To customize editing permissions, enable the Collaborative Publishing module.', 'press-permit-core');
}
?>
<!--
<p style="margin-top:20px">
<?php
printf(__('%sPosts / Pages Listing:%s %s', 'press-permit-core'), '<b>', '</b>', $hint);
?>
</p>
-->
</td>
</tr>
<?php
Expand Down
16 changes: 12 additions & 4 deletions classes/PublishPress/PermissionsHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ public function actInit()

// --- version check ---
if ( ! $ver = get_option('presspermitpro_version') ) {
if ( ! $ver = get_option('presspermit_version') ) {
$ver = get_option('pp_c_version');
if (!defined('PRESSPERMIT_PRO_VERSION')) {
if ( ! $ver = get_option('presspermit_version') ) {
$ver = get_option('pp_c_version');
}
}
}

Expand All @@ -188,7 +190,10 @@ public function actInit()
}

update_option('presspermit_version', ['version' => PRESSPERMIT_VERSION, 'db_version' => PRESSPERMIT_DB_VERSION]);
update_option('presspermitpro_version', ['version' => PRESSPERMIT_VERSION, 'db_version' => PRESSPERMIT_DB_VERSION]);

if (defined('PRESSPERMIT_PRO_VERSION')) {
update_option('presspermitpro_version', ['version' => PRESSPERMIT_PRO_VERSION, 'db_version' => PRESSPERMIT_DB_VERSION]);
}
}

if ($ver && !empty($ver['version'])) {
Expand All @@ -197,7 +202,10 @@ public function actInit()
require_once(PRESSPERMIT_CLASSPATH . '/PluginUpdated.php');
new Permissions\PluginUpdated($ver['version']);
update_option('presspermit_version', ['version' => PRESSPERMIT_VERSION, 'db_version' => PRESSPERMIT_DB_VERSION]);
update_option('presspermitpro_version', ['version' => PRESSPERMIT_VERSION, 'db_version' => PRESSPERMIT_DB_VERSION]);

if (defined('PRESSPERMIT_PRO_VERSION')) {
update_option('presspermitpro_version', ['version' => PRESSPERMIT_PRO_VERSION, 'db_version' => PRESSPERMIT_DB_VERSION]);
}
}

if (is_multisite() && !$pp->getOption('wp_role_sync')) {
Expand Down
Binary file removed common/img/pp-logo.png
Binary file not shown.
42 changes: 25 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
{
"name": "publishpress/publishpress-permissions",
"type": "wordpress-plugin",
"description": "",
"license": "GPL-2",
"authors": [
{
"name": "PublishPress",
"email": "help@publishpress.com"
}
],
"config": {
"preferred-install": "dist"
"name": "publishpress/publishpress-permissions",
"type": "wordpress-plugin",
"description": "WordPress plugin: control permissions for publishing workflow and presentation",
"homepage": "https://publishpress.com/",
"license": "GPL-2",
"authors": [
{
"name": "PublishPress",
"email": "help@publishpress.com"
},
"minimum-stability": "stable",
"require": {
"php": ">=5.6.20",
"publishpress/wordpress-version-notices": "dev-master"
{
"name": "Kevin Behrens",
"email": "kevin@agapetry.net",
"homepage": "https://agapetry.net",
"role": "Lead Developer"
}
}
],
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=5.6.20",
"publishpress/wordpress-version-notices": "1.1.1"
}
}
18 changes: 8 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ function presspermit_is_preview() {
if (!$is_preview = is_preview()) {
if (defined('ELEMENTOR_VERSION')) {
$is_preview = !empty($_REQUEST['elementor-preview']);
} elseif (defined('ET_CORE')) {
$is_preview = !empty($_REQUEST['et_fb']);
}
}

Expand Down
6 changes: 5 additions & 1 deletion includes/SettingsTabInstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ public function optionsUI()
'admin.php?page=presspermit-settings&amp;pp_renewal=1'
);
}

} elseif ($modern_pro_version = get_option('presspermitpro_version')) {
$msg = __('Permissions Pro was previously active. You are now running the free version, with fewer features.', 'press-permit-core');

} elseif ($activated) {
$url = "https://publishpress.com/contact/?pp_topic=presspermit-migration&presspermit_account=$key_string";

Expand All @@ -163,7 +167,7 @@ public function optionsUI()
);
}

$downgrade_note = (is_array($opt_val) && count($opt_val) > 1) || get_option('ppce_version') || get_option('pps_version') || get_option('ppp_version');
$downgrade_note = empty($modern_pro_version) && ((is_array($opt_val) && count($opt_val) > 1) || get_option('pps_version') || get_option('ppp_version'));

if ($msg || $downgrade_note || $key_string) :
$section = 'key'; // --- UPDATE KEY SECTION ---
Expand Down
Binary file modified languages/press-permit-core.mo
Binary file not shown.
Loading

0 comments on commit 4aba916

Please sign in to comment.