| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: PublishPress Revisions Free |
| 4 |
* Plugin URI: https://publishpress.com/revisionary/ |
| 5 |
* Description: Maintain published content with teamwork and precision using the Revisions model to submit, approve and schedule changes. |
| 6 |
* Author: PublishPress |
| 7 |
* Author URI: https://publishpress.com |
| 8 |
* Version: 4.0.2 |
| 9 |
* Text Domain: revisionary |
| 10 |
* Domain Path: /languages/ |
| 11 |
* Min WP Version: 5.5 |
| 12 |
* Requires PHP: 7.2.5 |
| 13 |
* |
| 14 |
* Copyright (c) 2026 PublishPress |
| 15 |
* |
| 16 |
* GNU General Public License, Free Software Foundation <https://www.gnu.org/licenses/gpl-3.0.html> |
| 17 |
* |
| 18 |
* This program is free software: you can redistribute it and/or modify |
| 19 |
* it under the terms of the GNU General Public License as published by |
| 20 |
* the Free Software Foundation, either version 3 of the License, or |
| 21 |
* (at your option) any later version. |
| 22 |
* |
| 23 |
* This program is distributed in the hope that it will be useful, |
| 24 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 26 |
* GNU General Public License for more details. |
| 27 |
* |
| 28 |
* You should have received a copy of the GNU General Public License |
| 29 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 30 |
* |
| 31 |
* @package PublishPress\Revisions |
| 32 |
* @author PublishPress |
| 33 |
* @copyright Copyright (C) 2026 PublishPress. All rights reserved. |
| 34 |
* |
| 35 |
**/ |
| 36 |
|
| 37 |
if (!defined('ABSPATH')) exit; // Exit if accessed directly |
| 38 |
|
| 39 |
// Temporary usage within this module only; avoids multiple instances of version string |
| 40 |
global $pp_revisions_version; |
| 41 |
|
| 42 |
$pp_revisions_version = '4.0.2'; |
| 43 |
|
| 44 |
global $wp_version; |
| 45 |
|
| 46 |
$min_php_version = '7.2.5'; |
| 47 |
$min_wp_version = '5.5'; |
| 48 |
|
| 49 |
$invalid_php_version = version_compare(phpversion(), $min_php_version, '<'); |
| 50 |
$invalid_wp_version = version_compare($wp_version, $min_wp_version, '<'); |
| 51 |
|
| 52 |
// If the PHP version is not compatible, terminate the plugin execution and show an admin notice. |
| 53 |
if (is_admin() && $invalid_php_version) { |
| 54 |
add_action( |
| 55 |
'admin_notices', |
| 56 |
function () use ($min_php_version) { |
| 57 |
if (current_user_can('activate_plugins')) { |
| 58 |
echo '<div class="notice notice-error"><p>'; |
| 59 |
printf( |
| 60 |
'PublishPress Revisions requires PHP version %s or higher.', |
| 61 |
esc_html($min_php_version) |
| 62 |
); |
| 63 |
echo '</p></div>'; |
| 64 |
} |
| 65 |
} |
| 66 |
); |
| 67 |
} |
| 68 |
|
| 69 |
// If the WP version is not compatible, terminate the plugin execution and show an admin notice. |
| 70 |
if (is_admin() && $invalid_wp_version) { |
| 71 |
add_action( |
| 72 |
'admin_notices', |
| 73 |
function () use ($min_wp_version) { |
| 74 |
if (current_user_can('activate_plugins')) { |
| 75 |
echo '<div class="notice notice-error"><p>'; |
| 76 |
printf( |
| 77 |
'PublishPress Revisions requires WordPress version %s or higher.', |
| 78 |
esc_html($min_wp_version) |
| 79 |
); |
| 80 |
echo '</p></div>'; |
| 81 |
} |
| 82 |
} |
| 83 |
); |
| 84 |
} |
| 85 |
|
| 86 |
if ($invalid_php_version || $invalid_wp_version) { |
| 87 |
return; |
| 88 |
} |
| 89 |
|
| 90 |
$revisionary_pro_active = false; |
| 91 |
|
| 92 |
global $revisionary_loaded_by_pro; |
| 93 |
|
| 94 |
$revisionary_loaded_by_pro = strpos(str_replace('\\', '/', __FILE__), 'vendor/publishpress/'); |
| 95 |
|
| 96 |
// Detect separate Pro plugin activation, but not self-activation (this file loaded in vendor library by Pro) |
| 97 |
if (false === $revisionary_loaded_by_pro) { |
| 98 |
foreach ((array)get_option('active_plugins') as $plugin_file) { |
| 99 |
if (false !== strpos($plugin_file, 'revisionary-pro.php')) { |
| 100 |
$revisionary_pro_active = true; |
| 101 |
break; |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
if (!$revisionary_pro_active && is_multisite()) { |
| 106 |
foreach (array_keys((array)get_site_option('active_sitewide_plugins')) as $plugin_file) { |
| 107 |
if (false !== strpos($plugin_file, 'revisionary-pro.php')) { |
| 108 |
$revisionary_pro_active = true; |
| 109 |
break; |
| 110 |
} |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
if ($revisionary_pro_active) { |
| 115 |
add_filter( |
| 116 |
'plugin_row_meta', |
| 117 |
function($links, $file) |
| 118 |
{ |
| 119 |
if ($file == plugin_basename(__FILE__)) { |
| 120 |
$links[]= __('<strong>This plugin can be deleted.</strong>', 'revisionary'); |
| 121 |
} |
| 122 |
|
| 123 |
return $links; |
| 124 |
}, |
| 125 |
10, 2 |
| 126 |
); |
| 127 |
|
| 128 |
add_action( |
| 129 |
'admin_notices', |
| 130 |
function () { |
| 131 |
if (current_user_can('activate_plugins')) { |
| 132 |
echo '<div class="notice notice-error"><p>' |
| 133 |
. 'Revisions Pro requires the free plugin (PublishPress Revisions) to be deactivated.' |
| 134 |
. '</p></div>'; |
| 135 |
} |
| 136 |
} |
| 137 |
); |
| 138 |
|
| 139 |
return; |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
if (isset($_SERVER['SCRIPT_NAME']) && (strpos(esc_url_raw(wp_unslash($_SERVER['SCRIPT_NAME'])), 'p-admin/index-extra.php') || strpos(esc_url_raw(wp_unslash($_SERVER['SCRIPT_NAME'])), 'p-admin/update.php'))) { |
| 144 |
return; |
| 145 |
} |
| 146 |
|
| 147 |
if (! defined('REVISIONS_INTERNAL_VENDORPATH')) { |
| 148 |
define('REVISIONS_INTERNAL_VENDORPATH', __DIR__ . '/lib/vendor'); |
| 149 |
} |
| 150 |
|
| 151 |
if (!defined('REVISIONARY_FILE') && !$revisionary_loaded_by_pro) { |
| 152 |
$includeFileRelativePath = REVISIONS_INTERNAL_VENDORPATH . '/publishpress/publishpress-instance-protection/include.php'; |
| 153 |
if (file_exists($includeFileRelativePath)) { |
| 154 |
require_once $includeFileRelativePath; |
| 155 |
} |
| 156 |
|
| 157 |
if (class_exists('PublishPressInstanceProtection\\Config')) { |
| 158 |
$pluginCheckerConfig = new PublishPressInstanceProtection\Config(); |
| 159 |
$pluginCheckerConfig->pluginSlug = 'revisionary'; |
| 160 |
$pluginCheckerConfig->pluginFolder = 'revisionary'; |
| 161 |
$pluginCheckerConfig->pluginName = 'PublishPress Revisions'; |
| 162 |
|
| 163 |
$pluginChecker = new PublishPressInstanceProtection\InstanceChecker($pluginCheckerConfig); |
| 164 |
} |
| 165 |
|
| 166 |
if (! class_exists('ComposerAutoloaderInitRevisionary') |
| 167 |
&& file_exists(REVISIONS_INTERNAL_VENDORPATH . '/autoload.php') |
| 168 |
) { |
| 169 |
require_once REVISIONS_INTERNAL_VENDORPATH . '/autoload.php'; |
| 170 |
} |
| 171 |
|
| 172 |
include_once REVISIONS_INTERNAL_VENDORPATH . '/publishpress/wordpress-version-notices/src/include.php'; |
| 173 |
|
| 174 |
// Load bundled-translations library |
| 175 |
$bundledTranslationsPath = '/publishpress/bundled-translations/core/include.php'; |
| 176 |
if (file_exists(REVISIONS_INTERNAL_VENDORPATH . $bundledTranslationsPath)) { |
| 177 |
require_once REVISIONS_INTERNAL_VENDORPATH . $bundledTranslationsPath; |
| 178 |
} |
| 179 |
|
| 180 |
// Initialize bundled translations |
| 181 |
add_action('plugins_loaded', function() { |
| 182 |
if (class_exists('PublishPress\BundledTranslations\BundledTranslations')) { |
| 183 |
$bundledTranslations = new PublishPress\BundledTranslations\BundledTranslations( |
| 184 |
'revisionary', |
| 185 |
__DIR__ . '/languages', |
| 186 |
__FILE__ |
| 187 |
); |
| 188 |
$bundledTranslations->init(); |
| 189 |
} |
| 190 |
}, 10); |
| 191 |
} |
| 192 |
|
| 193 |
if (!defined('REVISIONARY_FILE') && (!$revisionary_pro_active || $revisionary_loaded_by_pro)) { |
| 194 |
define('REVISIONARY_FILE', __FILE__); |
| 195 |
|
| 196 |
add_action( |
| 197 |
'init', |
| 198 |
function() { |
| 199 |
global $pp_revisions_version; |
| 200 |
|
| 201 |
if (!function_exists('revisionary')) { |
| 202 |
require_once(dirname(__FILE__).'/functions.php'); |
| 203 |
} |
| 204 |
|
| 205 |
pp_revisions_plugin_updated($pp_revisions_version); |
| 206 |
}, |
| 207 |
2 |
| 208 |
); |
| 209 |
|
| 210 |
// register these functions before any early exits so normal activation/deactivation can still run with RS_DEBUG |
| 211 |
register_activation_hook(__FILE__, function() |
| 212 |
{ |
| 213 |
global $pp_revisions_version; |
| 214 |
|
| 215 |
if (!function_exists('revisionary')) { |
| 216 |
require_once(dirname(__FILE__).'/functions.php'); |
| 217 |
} |
| 218 |
|
| 219 |
pp_revisions_plugin_updated($pp_revisions_version); |
| 220 |
pp_revisions_plugin_activation(); |
| 221 |
} |
| 222 |
); |
| 223 |
|
| 224 |
register_deactivation_hook(__FILE__, function() |
| 225 |
{ |
| 226 |
if (!function_exists('rvy_init')) { |
| 227 |
require_once( dirname(__FILE__).'/rvy_init.php'); |
| 228 |
} |
| 229 |
|
| 230 |
if (!rvy_is_plugin_active('revisionary-pro/revisionary-pro.php')) { |
| 231 |
pp_revisions_plugin_deactivation(); |
| 232 |
} |
| 233 |
} |
| 234 |
); |
| 235 |
|
| 236 |
// negative priority to precede any default WP action handlers |
| 237 |
function revisionary_load() { |
| 238 |
global $pp_revisions_version; |
| 239 |
|
| 240 |
define('PUBLISHPRESS_REVISIONS_VERSION', '4.0.2'); |
| 241 |
|
| 242 |
if ( ! defined( 'RVY_VERSION' ) ) { |
| 243 |
define( 'RVY_VERSION', PUBLISHPRESS_REVISIONS_VERSION ); // back compat |
| 244 |
} |
| 245 |
|
| 246 |
define ('COLS_ALL_RVY', 0); |
| 247 |
define ('COL_ID_RVY', 1); |
| 248 |
|
| 249 |
if ( defined('RS_DEBUG') ) { |
| 250 |
include_once( dirname(__FILE__).'/lib/debug.php'); |
| 251 |
add_action( 'admin_footer', 'rvy_echo_usage_message' ); |
| 252 |
} else |
| 253 |
include_once( dirname(__FILE__).'/lib/debug_shell.php'); |
| 254 |
|
| 255 |
require_once( dirname(__FILE__).'/defaults_rvy.php'); |
| 256 |
|
| 257 |
// === awp_is_mu() function definition and usage: must be executed in this order, and before any checks of IS_MU_RVY constant === |
| 258 |
require_once( dirname(__FILE__).'/lib/agapetry_wp_core_lib.php'); |
| 259 |
define( 'IS_MU_RVY', awp_is_mu() ); |
| 260 |
// ------------------------------------------- |
| 261 |
|
| 262 |
require_once( dirname(__FILE__).'/content-roles_rvy.php'); |
| 263 |
|
| 264 |
if ( is_admin() || defined('XMLRPC_REQUEST') ) { |
| 265 |
require_once( dirname(__FILE__).'/lib/agapetry_wp_admin_lib.php'); |
| 266 |
|
| 267 |
// skip WP version check and init operations when a WP plugin auto-update is in progress |
| 268 |
if (isset($_SERVER['SCRIPT_NAME']) && false !== strpos(esc_url_raw(wp_unslash($_SERVER['SCRIPT_NAME'])), 'update.php') ) |
| 269 |
return; |
| 270 |
} |
| 271 |
|
| 272 |
require_once( dirname(__FILE__).'/classes/PublishPress/Revisionary.php'); |
| 273 |
require_once( dirname(__FILE__).'/rvy_init.php'); // Contains activate, deactivate, init functions. Adds mod_rewrite_rules. |
| 274 |
require_once( dirname(__FILE__).'/functions.php'); |
| 275 |
|
| 276 |
// avoid lockout in case of editing plugin via wp-admin |
| 277 |
if ( defined('RS_DEBUG') && is_admin() && isset($_SERVER['REQUEST_URI']) && ( strpos( urldecode(esc_url_raw(wp_unslash($_SERVER['REQUEST_URI']))), 'p-admin/plugin-editor.php' ) || strpos( urldecode(esc_url_raw(wp_unslash($_SERVER['REQUEST_URI']))), 'p-admin/plugins.php' ) ) && false === strpos( esc_url_raw(wp_unslash($_SERVER['REQUEST_URI'])), 'activate' ) ) |
| 278 |
return; |
| 279 |
|
| 280 |
define('RVY_ABSPATH', __DIR__); |
| 281 |
|
| 282 |
if (is_admin() && !defined('PUBLISHPRESS_REVISIONS_PRO_VERSION')) { |
| 283 |
require_once(__DIR__ . '/includes/CoreAdmin.php'); |
| 284 |
new \PublishPress\Revisions\CoreAdmin(); |
| 285 |
} |
| 286 |
|
| 287 |
rvy_refresh_options_sitewide(); |
| 288 |
|
| 289 |
// since sequence of set_current_user and init actions seems unreliable, make sure our current_user is loaded first |
| 290 |
add_action('init', 'rvy_init', 1); |
| 291 |
|
| 292 |
if (!defined('IFRAME_REQUEST')) { |
| 293 |
add_action('init', 'rvy_add_revisor_custom_caps', 99); |
| 294 |
add_action('wp_loaded', 'rvy_add_revisor_custom_caps', 99); |
| 295 |
} |
| 296 |
|
| 297 |
add_action('init', 'rvy_configuration_late_init', PHP_INT_MAX - 1); |
| 298 |
|
| 299 |
revisionary(); |
| 300 |
} |
| 301 |
|
| 302 |
// negative priority to precede any default WP action handlers |
| 303 |
if ($revisionary_loaded_by_pro) { |
| 304 |
revisionary_load(); // Pro support |
| 305 |
} else { |
| 306 |
add_action('plugins_loaded', 'revisionary_load', -10); |
| 307 |
} |
| 308 |
} |
| 309 |
|