Skip to content

Commit

Permalink
Merge pull request #973 from publishpress/release-3.11.3
Browse files Browse the repository at this point in the history
Release 3.11.3
  • Loading branch information
agapetry authored Oct 25, 2023
2 parents 14d5fd0 + 590ffe3 commit 27cc3ac
Show file tree
Hide file tree
Showing 7 changed files with 361 additions and 632 deletions.
2 changes: 1 addition & 1 deletion classes/PublishPress/Permissions/PostFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public function fltPostsWhere($where, $args = [])
$valid_stati['future'] = 'future';
}
} else {
$valid_stati = PWP::getPostStatuses(['internal' => false, 'post_type' => $post_types], 'names', '', ['context' => 'edit']);
$valid_stati = PWP::getPostStatuses(['internal' => false, 'post_type' => $post_types], 'names', 'and', ['context' => 'edit']);
}

global $wp_query;
Expand Down
2 changes: 0 additions & 2 deletions classes/PublishPress/Permissions/UI/SettingsTabModules.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

class SettingsTabModules
{
const LEGACY_VERSION = '2.6.3';

public function __construct()
{
add_filter('presspermit_option_tabs', [$this, 'optionTabs'], 0);
Expand Down
72 changes: 44 additions & 28 deletions classes/PublishPress/PermissionsHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,49 +227,65 @@ public function actInit()
$pp = presspermit();

// --- version check ---
$compare_version = PRESSPERMIT_VERSION;
if (!$ver = get_option('presspermit_version')) {
$ver = get_option('pp_c_version');
}

$ver = get_option('presspermitpro_version');
$updated = false;

if (!$ver || !defined('PRESSPERMIT_PRO_VERSION') ) {
if ( ! $ver = get_option('presspermit_version') ) {
$ver = get_option('pp_c_version');
}
} else {
$compare_version = PRESSPERMIT_PRO_VERSION;
}
$prev_core_version = ($ver && is_array($ver) && !empty($ver['version'])) ? $ver['version'] : '';

if (!$ver || !is_array($ver) || empty($ver['db_version']) || version_compare(PRESSPERMIT_DB_VERSION, $ver['db_version'], '!=')) {
if (!$ver) {
require_once(PRESSPERMIT_CLASSPATH . '/PluginUpdated.php');
new Permissions\PluginUpdated('');
}
if (version_compare(PRESSPERMIT_VERSION, $prev_core_version, '!=')) {
require_once(PRESSPERMIT_CLASSPATH . '/PluginUpdated.php');
new Permissions\PluginUpdated($prev_core_version);

// Always store current PP Core version, even if loaded by Pro
update_option('presspermit_version', ['version' => PRESSPERMIT_VERSION, 'db_version' => PRESSPERMIT_DB_VERSION]);
$updated = true;

if ($ver && is_multisite() && !$pp->getOption('wp_role_sync')) {
Permissions\PluginUpdated::syncWordPressRoles();
}
}

if (defined('PRESSPERMIT_PRO_VERSION')) {
$ver_pro = get_option('presspermitpro_version');
$prev_pro_version = ($ver_pro && is_array($ver_pro) && !empty($ver_pro['version'])) ? $ver_pro['version'] : '';

if (version_compare(PRESSPERMIT_PRO_VERSION, $prev_pro_version, '!=')) {
do_action('presspermit_pro_version_updated', $prev_pro_version);

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

if ($ver && !empty($ver['version'])) {
// These maintenance operations only apply when a previous version of PP was installed
if (version_compare($compare_version, $ver['version'], '!=')) {
update_option('presspermit_previous_version', $ver);

require_once(PRESSPERMIT_CLASSPATH . '/PluginUpdated.php');
new Permissions\PluginUpdated($ver['version']);
update_option('presspermit_version', ['version' => PRESSPERMIT_VERSION, 'db_version' => PRESSPERMIT_DB_VERSION]);
if (!empty($updated)) {
// Core and Pro intentionally share the same version history log, to capture the installation sequence of any Free or Pro package

if ($ver_history = get_option('ppperm_version_history')) {
$ver_history = (array) json_decode($ver_history);
} else {
// Initiate version history log with the last stored version (Pro or Free)

if (defined('PRESSPERMIT_PRO_VERSION')) {
update_option('presspermitpro_version', ['version' => PRESSPERMIT_PRO_VERSION, 'db_version' => PRESSPERMIT_DB_VERSION]);
if (defined('PRESSPERMIT_PRO_VERSION') && !empty($prev_pro_version)) {
$ver_history = [(object) ['version' => $prev_pro_version, 'date' => '', 'isPro' => true]];
}

// In case last Pro version is an irrelevant old entry, also include last Core version if it's higher
if ($prev_core_version && (!defined('PRESSPERMIT_PRO_VERSION') || version_compare($prev_core_version, $prev_pro_version, '>'))) {
$ver_history = [(object) ['version' => $prev_core_version, 'date' => '', 'isPro' => false]];
}
}

if (is_multisite() && !$pp->getOption('wp_role_sync')) {
require_once(PRESSPERMIT_CLASSPATH . '/PluginUpdated.php');
Permissions\PluginUpdated::syncWordPressRoles();
// In the version history, log Core version changes only if they are installed directly by Free package
if (defined('PRESSPERMIT_PRO_VERSION')) {
$ver_history [] = (object) ['version' => PRESSPERMIT_PRO_VERSION, 'date' => gmdate('m/d/Y'), 'isPro' => true];
} else {
$ver_history [] = (object) ['version' => PRESSPERMIT_VERSION, 'date' => gmdate('m/d/Y'), 'isPro' => false];
}

update_option('ppperm_version_history', wp_json_encode($ver_history));
}
// --- end version check ---

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"build:clean": "ppbuild clean",
"get:version": "ppbuild version",
"gen:mo": "wp i18n make-mo ./languages ./languages --allow-root",
"gen:pot": "wp i18n make-pot . languages/publishpress-statuses.pot --domain=publishpress-statuses --exclude=dev-workspace,.wordpress-org,.github,dist,tests, --allow-root",
"gen:pot": "wp i18n make-pot . languages/press-permit-core.pot --domain=press-permit-core --exclude=dev-workspace,.wordpress-org,.github,dist,tests,vendor, --allow-root",
"check:longpath": "longpath .",
"check:lint": "phplint",
"check:phpcs": "phpcs",
Expand All @@ -64,7 +64,7 @@
"@check:php81",
"@check:php82"
],
"check:php56": "phpcs --standard=.phpcs-php-compatibility.xml --runtime-set testVersion 5.6 ./publishpress-statuses.php",
"check:php56": "phpcs --standard=.phpcs-php-compatibility.xml --runtime-set testVersion 5.6 ./press-permit-core.php",
"check:php72": "phpcs --standard=.phpcs-php-compatibility.xml --runtime-set testVersion 7.2",
"check:php74": "phpcs --standard=.phpcs-php-compatibility.xml --runtime-set testVersion 7.4",
"check:php80": "phpcs --standard=.phpcs-php-compatibility.xml --runtime-set testVersion 8.0",
Expand Down
4 changes: 4 additions & 0 deletions includes/CoreAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ function($modules){
}

function actAdminMenuPromos($pp_options_menu, $handler) {

// Disable custom status promos until PublishPress Statuses and compatible version of Permissions Pro are released
/*
add_submenu_page(
$pp_options_menu,
esc_html__('Workflow Statuses', 'press-permit-core'),
Expand All @@ -73,6 +76,7 @@ function actAdminMenuPromos($pp_options_menu, $handler) {
'presspermit-visibility-statuses',
$handler
);
*/

add_submenu_page(
$pp_options_menu,
Expand Down
65 changes: 46 additions & 19 deletions includes/SettingsTabInstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

class SettingsTabInstall
{
const LEGACY_VERSION = '2.6.3';

public function __construct()
{
add_filter('presspermit_option_tabs', [$this, 'optionTabs'], 90);
Expand Down Expand Up @@ -108,9 +106,9 @@ public function optionsUI()
$key_string = (is_array($opt_val) && count($opt_val) > 1) ? $opt_val[1] : '';
$expire_date = (is_array($opt_val) && isset($opt_val['expire_date_gmt'])) ? $opt_val['expire_date_gmt'] : '';

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

if ($msg || $downgrade_note || $key_string) :
if ($msg || $modern_pro_version || $key_string) :
$section = 'key'; // --- UPDATE KEY SECTION ---
if (!empty($ui->form_options[$tab][$section]) && !$suppress_updates) : ?>
<tr>
Expand All @@ -133,7 +131,7 @@ public function optionsUI()
);
}

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

} elseif ($activated) {
Expand All @@ -158,18 +156,6 @@ public function optionsUI()
?>
</li>
<?php endif;?>

<?php if ($downgrade_note):?>
<li class='pp-pro-extensions-migration-note'>
<?php
printf(
esc_html__('To temporarily restore Pro features before migrating to a publishpress.com account, delete this version and install %sPress Permit Core 2.6.x%s using Plugins > Add New > Upload.', 'press-permit-core'),
'<span style="white-space:nowrap"><a href="' . esc_url('https://downloads.wordpress.org/plugin/press-permit-core.' . self::LEGACY_VERSION . '.zip') . '" target="_blank">',
'</a></span>'
);
?>
</li>
<?php endif;?>
</ul>
</td>
</tr>
Expand Down Expand Up @@ -227,10 +213,51 @@ public function optionsUI()
);
}
?>
<br/>
<span style="display:none"><?php printf(esc_html__("Database Schema Version: %s", 'press-permit-core'), esc_html(PRESSPERMIT_DB_VERSION)); ?><br/></span>
</p>

<?php
if ($ver_history = get_option('ppperm_version_history')) :?>
<br />
<div>
<?php
if ($ver_history = (array) json_decode($ver_history)) :
$ver_history = array_reverse($ver_history, true);
?>
<div class="agp-vtight"><?php esc_html_e('Installation History', 'press-permit-core');?></div>
<?php
echo '<textarea id="pp_version_history" name="pp_version_history" rows="5" cols="30" style="width: 250px; height: 85px" readonly="readonly">';

for ($i = 0; $i < count($ver_history); $i++) {
if ($i) {
echo "\r\n";
}

$ver_data = current($ver_history);
next($ver_history);

if (!is_object($ver_data) || empty($ver_data->version)) {
continue;
}

$version = (!empty($ver_data->isPro)) ? $ver_data->version . ' Pro' : $ver_data->version;

if (!empty($ver_data->date)) {
echo esc_html($version) . ' : ' . esc_html($ver_data->date);
} else {
printf(
esc_html__('%s (previous install)', 'press-permit-core'),
$version
);
}
}

echo '</textarea>';
?>
<?php endif; ?>
</div>
<?php endif; ?>

<br />
<p>
<?php

Expand Down
Loading

0 comments on commit 27cc3ac

Please sign in to comment.