Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/user-access-manager/includes/language.php
+++ b/user-access-manager/includes/language.php
@@ -171,6 +171,8 @@
define('TXT_UAM_REDIRECT_TO_PAGE', __('Custom page: ', 'user-access-manager'));
define('TXT_UAM_REDIRECT_TO_URL', __('Custom URL: ', 'user-access-manager'));
define('TXT_UAM_REDIRECT_TO_ORIGIN', __('To origin page (the page the user came from)', 'user-access-manager'));
+define('TXT_UAM_APPEND_REDIRECT_TO_PARAMETER', __('Append requested URL to the redirect', 'user-access-manager'));
+define('TXT_UAM_APPEND_REDIRECT_TO_PARAMETER_DESC', __('Selecting "Yes" will append the originally requested URL as "redirect_to" parameter to the redirect URL, so that a custom login page can send the user back to it after the login.', 'user-access-manager'));
define('TXT_UAM_LOCK_RECURSIVE', __('Lock recursive', 'user-access-manager'));
define('TXT_UAM_LOCK_RECURSIVE_DESC', __('Selecting "Yes" will lock all child posts/pages of a post/page if a user has no access to the parent page. Note: Setting this option to "No" could result in display errors relating to the hierarchy.', 'user-access-manager'));
define('TXT_UAM_BLOG_ADMIN_HINT_TEXT', __('Admin hint text', 'user-access-manager'));
--- a/user-access-manager/src/Cache/CacheProviderFactory.php
+++ b/user-access-manager/src/Cache/CacheProviderFactory.php
@@ -41,6 +41,7 @@
public function createRedisCacheProvider(): RedisCacheProvider
{
return new RedisCacheProvider(
+ $this->wordpress,
$this->configFactory,
$this->configParameterFactory
);
--- a/user-access-manager/src/Cache/RedisCacheProvider.php
+++ b/user-access-manager/src/Cache/RedisCacheProvider.php
@@ -8,6 +8,7 @@
use UserAccessManagerConfigConfig;
use UserAccessManagerConfigConfigFactory;
use UserAccessManagerConfigConfigParameterFactory;
+use UserAccessManagerWrapperWordpress;
class RedisCacheProvider implements CacheProviderInterface
{
@@ -21,6 +22,7 @@
private ?Config $config = null;
public function __construct(
+ private Wordpress $wordpress,
private ConfigFactory $configFactory,
private ConfigParameterFactory $configParameterFactory
) {
@@ -78,12 +80,12 @@
public function add(string $key, mixed $value): void
{
- wp_cache_set($this->buildKey($key), $value, self::ID, $this->getTtl());
+ $this->wordpress->wpCacheSet($this->buildKey($key), $value, self::ID, $this->getTtl());
}
public function get(string $key): mixed
{
- $value = wp_cache_get($this->buildKey($key), self::ID);
+ $value = $this->wordpress->wpCacheGet($this->buildKey($key), self::ID);
// wp_cache_get returns false on a miss; normalize to null per interface contract.
return ($value === false) ? null : $value;
@@ -91,6 +93,6 @@
public function invalidate(string $key): void
{
- wp_cache_delete($this->buildKey($key), self::ID);
+ $this->wordpress->wpCacheDelete($this->buildKey($key), self::ID);
}
}
--- a/user-access-manager/src/Config/BooleanConfigParameter.php
+++ b/user-access-manager/src/Config/BooleanConfigParameter.php
@@ -18,9 +18,9 @@
private function valueToBoolConverter(mixed $value): mixed
{
- if (in_array($value, [1, '1', 'true'])) {
+ if (in_array($value, [1, '1', 'true'], true)) {
$value = true;
- } elseif (in_array($value, [0, '0', 'false'])) {
+ } elseif (in_array($value, [0, '0', 'false'], true)) {
$value = false;
}
--- a/user-access-manager/src/Config/MainConfig.php
+++ b/user-access-manager/src/Config/MainConfig.php
@@ -49,6 +49,9 @@
$id = 'redirect_custom_url';
$configParameters[$id] = $this->configParameterFactory->createStringConfigParameter($id);
+ $id = 'append_redirect_to_parameter';
+ $configParameters[$id] = $this->configParameterFactory->createBooleanConfigParameter($id);
+
$id = 'lock_recursive';
$configParameters[$id] = $this->configParameterFactory->createBooleanConfigParameter($id, true);
@@ -336,6 +339,11 @@
return $this->getParameterValue('redirect_custom_url');
}
+ public function appendRedirectToParameter(): bool
+ {
+ return (bool) $this->getParameterValue('append_redirect_to_parameter');
+ }
+
public function lockRecursive(): bool
{
return (bool) $this->getParameterValue('lock_recursive');
--- a/user-access-manager/src/Controller/Backend/AboutController.php
+++ b/user-access-manager/src/Controller/Backend/AboutController.php
@@ -21,14 +21,14 @@
$path = [$realPath, 'assets'];
$path = implode(DIRECTORY_SEPARATOR, $path) . DIRECTORY_SEPARATOR;
$fileWithPath = $path . self::SUPPORTER_FILE;
- $needsUpdate = is_file($fileWithPath) === false
- || filemtime($fileWithPath) < $this->wordpress->currentTime('timestamp') - 24 * 60 * 60;
- $fileContent = ($needsUpdate === true) ? @file_get_contents(self::SUPPORTER_FILE_URL) : false;
+ $needsUpdate = $this->php->isFile($fileWithPath) === false
+ || $this->php->fileMTime($fileWithPath) < $this->wordpress->currentTime('timestamp') - 24 * 60 * 60;
+ $fileContent = ($needsUpdate === true) ? $this->php->fileGetContents(self::SUPPORTER_FILE_URL) : false;
if ($fileContent !== false) {
- file_put_contents($fileWithPath, $fileContent);
- } elseif (is_file($fileWithPath) === true) {
- $fileContent = file_get_contents($fileWithPath);
+ $this->php->filePutContents($fileWithPath, $fileContent);
+ } elseif ($this->php->isFile($fileWithPath) === true) {
+ $fileContent = $this->php->fileGetContents($fileWithPath);
}
$this->supporters = (is_string($fileContent) === true) ? json_decode($fileContent, true) : [];
--- a/user-access-manager/src/Controller/Backend/SettingsController.php
+++ b/user-access-manager/src/Controller/Backend/SettingsController.php
@@ -175,7 +175,7 @@
return true;
}
- $content = @file_get_contents($this->wordpress->getSiteUrl() . '?testXSendFile');
+ $content = $this->php->fileGetContents($this->wordpress->getSiteUrl() . '?testXSendFile');
$this->fileHandler->removeXSendFileTestFile();
return ($content === 'success');
@@ -347,6 +347,7 @@
'lock_recursive',
'protect_feed',
$redirect,
+ 'append_redirect_to_parameter',
'blog_admin_hint',
'blog_admin_hint_text',
'show_assigned_groups',
--- a/user-access-manager/src/Controller/Frontend/PostController.php
+++ b/user-access-manager/src/Controller/Frontend/PostController.php
@@ -19,6 +19,7 @@
use UserAccessManagerWrapperWordpress;
use WeakMap;
use WP_Comment;
+use WP_Error;
use WP_Hook;
use WP_Post;
use WP_Query;
@@ -27,8 +28,11 @@
class PostController extends ContentController
{
+ private const REST_OBJECT_ROUTE_PATTERN = '#^/[^/]+/vd+/([^/]+)/(d+)(?:/(w+))?#';
+
private array $wordpressFilters = [];
private stdClass|array|null $cachedCounts = [];
+ private ?array $restBaseToPostTypeMap = null;
private WeakMap $posts;
@@ -256,11 +260,20 @@
return $this->filterRawPosts($rawPages);
}
+ private function getRestAccessDeniedError(): WP_Error
+ {
+ return $this->wordpress->getWpError(
+ 'uam_rest_access_denied',
+ TXT_UAM_REST_ACCESS_DENIED,
+ ['status' => $this->wordpress->isUserLoggedIn() === true ? 403 : 401]
+ );
+ }
+
private function isSingleObjectRestRequest(mixed $request, WP_Post $post): bool
{
- return $request instanceof WP_REST_Request
- && $request->get_param('id') !== null
- && (int) $request->get_param('id') === (int) $post->ID;
+ $routeId = $request instanceof WP_REST_Request ? ($request->get_url_params()['id'] ?? null) : null;
+
+ return $routeId !== null && (int) $routeId === (int) $post->ID;
}
private function setRestField(array &$data, string $field, string $value): void
@@ -269,27 +282,22 @@
return;
}
- if (is_array($data[$field]) === true) {
- if (array_key_exists('rendered', $data[$field]) === true) {
- $data[$field]['rendered'] = $value;
- }
+ if (is_array($data[$field]) === false) {
+ $data[$field] = $value;
- if (array_key_exists('raw', $data[$field]) === true) {
- $data[$field]['raw'] = $value;
- }
+ return;
+ }
+
+ $restrictedValues = ['rendered' => $value, 'raw' => $value, 'protected' => false];
- if (array_key_exists('protected', $data[$field]) === true) {
- $data[$field]['protected'] = false;
+ foreach ($restrictedValues as $key => $restrictedValue) {
+ if (array_key_exists($key, $data[$field]) === true) {
+ $data[$field][$key] = $restrictedValue;
}
- } else {
- $data[$field] = $value;
}
}
/**
- * The_posts / posts_where_paged never run for REST single-item requests,
- * which resolve through get_post() directly, so access is enforced here too.
- *
* @throws UserGroupTypeException
*/
public function restrictRestResponse(mixed $response, mixed $post = null, mixed $request = null): mixed
@@ -304,11 +312,7 @@
if ($this->removePostFromList($post->post_type) === true
&& $this->isSingleObjectRestRequest($request, $post) === true
) {
- return $this->wordpress->getWpError(
- 'uam_rest_access_denied',
- TXT_UAM_REST_ACCESS_DENIED,
- ['status' => $this->wordpress->isUserLoggedIn() === true ? 403 : 401]
- );
+ return $this->getRestAccessDeniedError();
}
$restrictedContent = $this->processPostContent($post);
@@ -340,6 +344,72 @@
return $queryArgs;
}
+ private function getRestBaseToPostTypeMap(): array
+ {
+ if ($this->restBaseToPostTypeMap !== null) {
+ return $this->restBaseToPostTypeMap;
+ }
+
+ $this->restBaseToPostTypeMap = [];
+
+ foreach ((array) $this->objectHandler->getPostTypes() as $postType) {
+ $restBase = $this->wordpress->getPostTypeObject($postType)?->rest_base;
+ $this->restBaseToPostTypeMap[empty($restBase) === true ? $postType : $restBase] = $postType;
+ }
+
+ return $this->restBaseToPostTypeMap;
+ }
+
+ /**
+ * @return array{0: string, 1: int}|null
+ */
+ private function getGuardedRestRouteTarget(WP_REST_Request $request): ?array
+ {
+ if (preg_match(self::REST_OBJECT_ROUTE_PATTERN, (string) $request->get_route(), $matches) !== 1) {
+ return null;
+ }
+
+ $isSubResourceRoute = ($matches[3] ?? '') !== '';
+ $isReadingRequest = in_array(
+ strtoupper((string) $request->get_method()),
+ Wordpress::REST_READING_METHODS,
+ true
+ );
+
+ if ($isReadingRequest === true && $isSubResourceRoute === false) {
+ return null;
+ }
+
+ $postType = $this->getRestBaseToPostTypeMap()[$matches[1]] ?? null;
+
+ return $postType === null ? null : [$postType, (int) $matches[2]];
+ }
+
+ /**
+ * @throws UserGroupTypeException
+ */
+ public function restrictRestRequest(mixed $result, mixed $server = null, mixed $request = null): mixed
+ {
+ if (($request instanceof WP_REST_Request) === false) {
+ return $result;
+ }
+
+ $routeTarget = $this->getGuardedRestRouteTarget($request);
+
+ $this->wordpress->setRestRequestContext(
+ $routeTarget !== null || $request->get_param('context') === 'edit'
+ );
+
+ if ($result !== null
+ || $routeTarget === null
+ || $this->accessHandler->checkObjectAccess($routeTarget[0], $routeTarget[1], true) === true
+ ) {
+ return $result;
+ }
+
+ return $this->getRestAccessDeniedError();
+ }
+
/**
* @throws UserGroupTypeException
*/
--- a/user-access-manager/src/Controller/Frontend/RedirectController.php
+++ b/user-access-manager/src/Controller/Frontend/RedirectController.php
@@ -25,6 +25,7 @@
use LoginControllerTrait;
public const POST_URL_CACHE_KEY = 'PostUrls';
+ public const REDIRECT_TO_PARAMETER = 'redirect_to';
public function __construct(
Php $php,
@@ -188,6 +189,10 @@
$currentUrl = $this->util->getCurrentUrl();
if ($url !== null && $url !== $currentUrl && $permalink !== $currentUrl) {
+ if ($this->mainConfig->appendRedirectToParameter() === true) {
+ $url = $this->wordpress->addQueryArg([self::REDIRECT_TO_PARAMETER => $currentUrl], $url);
+ }
+
$this->wordpress->wpRedirect($url);
$this->php->callExit();
}
--- a/user-access-manager/src/File/ApacheFileProtection.php
+++ b/user-access-manager/src/File/ApacheFileProtection.php
@@ -60,7 +60,7 @@
return $this->applyFilters($content);
}
- private function getPermalinkFileContent(?string $objectType, ?bool $isSubSite = false): string
+ private function getPermalinkFileContent(?string $objectType, ?bool $isSubSite): string
{
if ($objectType === null) {
$objectType = ObjectHandler::ATTACHMENT_OBJECT_TYPE;
--- a/user-access-manager/src/File/FileHandler.php
+++ b/user-access-manager/src/File/FileHandler.php
@@ -32,7 +32,7 @@
ob_clean();
}
- flush();
+ $this->php->flush();
}
private function getFileMineType(string $file): string
@@ -53,7 +53,7 @@
if ($this->php->functionExists('finfo_open') === true) {
$fileInfo = finfo_open(FILEINFO_MIME);
$fileMimeType = finfo_file($fileInfo, $file);
- finfo_close($fileInfo);
+ $this->php->fInfoClose($fileInfo);
} elseif ($this->php->functionExists('mime_content_type')) {
$fileMimeType = mime_content_type($file);
} elseif (isset($mimeTypes[$fileExt]) === true) {
@@ -71,9 +71,9 @@
$contentDisposition = ($isInline === true) ? 'inline' : 'attachment';
$baseName = str_replace(' ', '_', basename($file));
- header('Content-Description: File Transfer');
- header('Content-Type: ' . $fileMimeType);
- header("Content-Disposition: $contentDisposition; filename="$baseName"");
+ $this->php->header('Content-Description: File Transfer');
+ $this->php->header('Content-Type: ' . $fileMimeType);
+ $this->php->header("Content-Disposition: $contentDisposition; filename="$baseName"");
}
private function deliverFileViaFopen(string $file): void
@@ -91,7 +91,7 @@
private function deliverFile(string $file, bool $isInline): void
{
- header("HTTP/1.1 200 OK");
+ $this->php->header("HTTP/1.1 200 OK");
$downloadType = $this->mainConfig->getDownloadType();
if ($downloadType === 'xsendfile') {
@@ -99,9 +99,9 @@
// Use /uam-files/ prefix so the internal redirect goes to a dedicated
// internal location that bypasses UAM's rewrite rules, avoiding a loop.
$uri = '/uam-files' . str_replace(rtrim(ABSPATH, '/'), '', $file);
- header("X-Accel-Redirect: $uri");
+ $this->php->header("X-Accel-Redirect: $uri");
} elseif ($this->wordpress->isApacheModuleLoaded('mod_xsendfile')) {
- header("X-Sendfile: $file");
+ $this->php->header("X-Sendfile: $file");
} else {
// mod_xsendfile is not available — fall back to fopen so the file
// is still delivered rather than sending an empty response.
@@ -112,8 +112,8 @@
$this->addDefaultHeader($file, $isInline);
if ($downloadType !== 'xsendfile') {
- header('Content-Transfer-Encoding: binary');
- header('Content-Length: ' . filesize($file));
+ $this->php->header('Content-Transfer-Encoding: binary');
+ $this->php->header('Content-Length: ' . filesize($file));
$this->clearBuffer();
if ($downloadType === 'fopen') {
@@ -222,20 +222,20 @@
if ($ranges !== []) {
$extraContents = $this->getExtraContents($file, $ranges, $contentLength, $boundary);
- header('HTTP/1.1 206 Partial Content');
- header('Content-Transfer-Encoding: binary');
- header('Accept-Ranges: bytes');
+ $this->php->header('HTTP/1.1 206 Partial Content');
+ $this->php->header('Content-Transfer-Encoding: binary');
+ $this->php->header('Accept-Ranges: bytes');
if ($extraContents === []) {
$this->addDefaultHeader($file, $isInline);
[$seekStart, $seekEnd] = $ranges[0];
$contentLength = ($seekEnd - $seekStart + 1);
- header("Content-Range: bytes $seekStart-$seekEnd/$fileSize");
+ $this->php->header("Content-Range: bytes $seekStart-$seekEnd/$fileSize");
} else {
- header("Content-Type: multipart/x-byteranges; boundary=$boundary");
+ $this->php->header("Content-Type: multipart/x-byteranges; boundary=$boundary");
}
- header("Content-Length: $contentLength");
+ $this->php->header("Content-Length: $contentLength");
$fileHandler = fopen($file, 'r');
foreach ($ranges as $index => $range) {
@@ -244,7 +244,7 @@
}
[$seekStart, $seekEnd] = $ranges[0];
- fseek($fileHandler, $seekStart);
+ $this->php->fseek($fileHandler, $seekStart);
$this->readFilePartly($fileHandler, $seekEnd - $seekStart + 1);
}
@@ -253,8 +253,8 @@
$this->clearBuffer();
}
} else {
- header('HTTP/1.1 416 Requested Range Not Satisfiable');
- header("Content-Range: */$fileSize");
+ $this->php->header('HTTP/1.1 416 Requested Range Not Satisfiable');
+ $this->php->header("Content-Range: */$fileSize");
}
}
@@ -337,9 +337,9 @@
$file = $this->wordpressConfig->getUploadDirectory() . DIRECTORY_SEPARATOR . self::X_SEND_FILE_TEST_FILE;
file_put_contents($file, 'success');
- header("X-Sendfile: $file");
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename="' . basename($file) . '"');
+ $this->php->header("X-Sendfile: $file");
+ $this->php->header('Content-Type: application/octet-stream');
+ $this->php->header('Content-Disposition: attachment; filename="' . basename($file) . '"');
$this->php->callExit();
}
@@ -347,8 +347,8 @@
{
$file = $this->wordpressConfig->getUploadDirectory() . DIRECTORY_SEPARATOR . self::X_SEND_FILE_TEST_FILE;
- if (file_exists($file) === true) {
- unlink($file);
+ if ($this->php->isFile($file) === true) {
+ $this->php->unlink($file);
}
}
}
--- a/user-access-manager/src/Form/FormHelper.php
+++ b/user-access-manager/src/Form/FormHelper.php
@@ -24,7 +24,7 @@
) {
}
- private function getObjectText(string $ident, bool $description = false, $objectKey = null): string
+ private function getObjectText(string $ident, bool $description, $objectKey = null): string
{
$ident .= ($description === true) ? '_DESC' : '';
--- a/user-access-manager/src/Setup/Database/DatabaseHandler.php
+++ b/user-access-manager/src/Setup/Database/DatabaseHandler.php
@@ -287,7 +287,7 @@
);
foreach ($tables as $table) {
- if (preg_match('/.*_([0-9-]+)/i', $table, $matches) === 1) {
+ if (preg_match('/.*_([0-9-]+)/', $table, $matches) === 1) {
$version = str_replace('-', '.', $matches[1]);
$versions[$version] = $version;
}
--- a/user-access-manager/src/UserAccessManager.php
+++ b/user-access-manager/src/UserAccessManager.php
@@ -32,7 +32,7 @@
class UserAccessManager
{
- public const VERSION = '2.3.14';
+ public const VERSION = '2.3.15';
public const DB_VERSION = '1.6.2';
public function __construct(
@@ -470,8 +470,15 @@
$this->wordpress->addFilter('getarchives_where', [$frontendPostController, 'showPostSql']);
$this->wordpress->addFilter('wp_count_posts', [$frontendPostController, 'showPostCount'], 10, 3);
- // Registered on rest_api_init so that all REST-enabled post types are known.
$this->wordpress->addAction('rest_api_init', function () use ($frontendPostController) {
+ //Runs first, so that no access check caches the context before the guard.
+ $this->wordpress->addFilter(
+ 'rest_pre_dispatch',
+ [$frontendPostController, 'restrictRestRequest'],
+ 1,
+ 3
+ );
+
foreach ((array) $this->objectHandler->getPostTypes() as $postType) {
$this->wordpress->addFilter(
"rest_prepare_$postType",
--- a/user-access-manager/src/Wrapper/Php.php
+++ b/user-access-manager/src/Wrapper/Php.php
@@ -53,6 +53,14 @@
}
/**
+ * @see header()
+ */
+ public function header(string $header, bool $replace = true, int $responseCode = 0): void
+ {
+ header($header, $replace, $responseCode);
+ }
+
+ /**
* @see set_time_limit()
*/
public function setTimeLimit(int $seconds): bool
@@ -98,6 +106,30 @@
}
/**
+ * @see is_file()
+ */
+ public function isFile(string $filename): bool
+ {
+ return is_file($filename);
+ }
+
+ /**
+ * @see filemtime()
+ */
+ public function fileMTime(string $filename): int|false
+ {
+ return filemtime($filename);
+ }
+
+ /**
+ * @see file_get_contents()
+ */
+ public function fileGetContents(string $filename): string|false
+ {
+ return @file_get_contents($filename);
+ }
+
+ /**
* @see igbinary_serialize()
*/
public function igbinarySerialize(mixed $value): ?string
@@ -138,4 +170,28 @@
{
return fclose($handle);
}
+
+ /**
+ * @see fseek()
+ */
+ public function fseek($handle, int $offset, int $whence = SEEK_SET): int
+ {
+ return fseek($handle, $offset, $whence);
+ }
+
+ /**
+ * @see flush()
+ */
+ public function flush(): void
+ {
+ flush();
+ }
+
+ /**
+ * @see finfo_close()
+ */
+ public function fInfoClose($fileInfo): bool
+ {
+ return finfo_close($fileInfo);
+ }
}
--- a/user-access-manager/src/Wrapper/Wordpress.php
+++ b/user-access-manager/src/Wrapper/Wordpress.php
@@ -20,6 +20,7 @@
use function add_menu_page;
use function add_meta_box;
use function add_option;
+use function add_query_arg;
use function add_shortcode;
use function add_submenu_page;
use function attachment_url_to_postid;
@@ -90,6 +91,11 @@
class Wordpress
{
+ public const REST_READING_METHODS = ['GET', 'HEAD'];
+
+ private bool $restRequestDispatched = false;
+ private bool $editingRestRequestDetected = false;
+
public function getDatabase(): wpdb
{
global $wpdb;
@@ -347,6 +353,30 @@
}
/**
+ * @see wp_cache_set
+ */
+ public function wpCacheSet(string $key, mixed $data, string $group = '', int $expire = 0): bool
+ {
+ return wp_cache_set($key, $data, $group, $expire);
+ }
+
+ /**
+ * @see wp_cache_get
+ */
+ public function wpCacheGet(string $key, string $group = ''): mixed
+ {
+ return wp_cache_get($key, $group);
+ }
+
+ /**
+ * @see wp_cache_delete
+ */
+ public function wpCacheDelete(string $key, string $group = ''): bool
+ {
+ return wp_cache_delete($key, $group);
+ }
+
+ /**
* @see is_super_admin
*/
public function isSuperAdmin(bool|int|string|null $userId = false): bool
@@ -399,6 +429,14 @@
}
/**
+ * @see add_query_arg
+ */
+ public function addQueryArg(array $arguments, string $url): string
+ {
+ return add_query_arg($arguments, $url);
+ }
+
+ /**
* @see get_home_path
*/
public function getHomePath(): string
@@ -484,17 +522,50 @@
return $wp_query;
}
+ public function isRestRequest(): bool
+ {
+ return defined('REST_REQUEST') === true && REST_REQUEST === true;
+ }
+
+ public function setRestRequestContext(bool $isEditingRequest): void
+ {
+ $this->restRequestDispatched = true;
+ //Nested requests, like the ones for embedded objects, must not lower the context again.
+ $this->editingRestRequestDetected = $this->editingRestRequestDetected || $isEditingRequest;
+ }
+
+ private function isReadingRestMethod(string $method): bool
+ {
+ return in_array(strtoupper($method), self::REST_READING_METHODS, true);
+ }
+
+ private function isEditingRestRequest(): bool
+ {
+ if ($this->isRestRequest() === false) {
+ return false;
+ }
+
+ if ($this->restRequestDispatched === true) {
+ return $this->editingRestRequestDetected;
+ }
+
+ //Undispatched requests only expose the raw data, so an editing request is assumed.
+ return $this->isReadingRestMethod((string) ($_SERVER['REQUEST_METHOD'] ?? 'GET')) === false
+ || ($_REQUEST['context'] ?? '') === 'edit';
+ }
+
/**
* @see is_admin
*/
public function isAdmin(): bool
{
//Ajax request are always identified as an administrative interface page
- if (wp_doing_ajax() === true || defined('REST_REQUEST') && REST_REQUEST) {
+ if (wp_doing_ajax() === true || $this->isRestRequest() === true) {
//So let's check if we are calling the ajax data for the frontend or backend
//If the referer is an admin url we are requesting the data for the backend
$adminUrl = get_admin_url();
- return str_starts_with((string)($_SERVER['HTTP_REFERER'] ?? ''), $adminUrl);
+ return str_starts_with((string)($_SERVER['HTTP_REFERER'] ?? ''), $adminUrl)
+ || $this->isEditingRestRequest() === true;
}
//No ajax request just uses the normal function
--- a/user-access-manager/user-access-manager.php
+++ b/user-access-manager/user-access-manager.php
@@ -3,7 +3,7 @@
* Plugin Name: User Access Manager
* Plugin URI: https://wordpress.org/plugins/user-access-manager/
* Author URI: https://twitter.com/GM_Alex
- * Version: 2.3.14
+ * Version: 2.3.15
* Requires PHP: 8.0
* Author: Alexander Schneider
* Description: Manage the access to your posts, pages, categories and files.
--- a/user-access-manager/vendor/autoload.php
+++ b/user-access-manager/vendor/autoload.php
@@ -19,4 +19,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
-return ComposerAutoloaderInitdaa845b7071a2ebafc731b437b87bad7::getLoader();
+return ComposerAutoloaderInit24362f9b9ff49b43fd181a99a110dbc4::getLoader();
--- a/user-access-manager/vendor/composer/autoload_real.php
+++ b/user-access-manager/vendor/composer/autoload_real.php
@@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
-class ComposerAutoloaderInitdaa845b7071a2ebafc731b437b87bad7
+class ComposerAutoloaderInit24362f9b9ff49b43fd181a99a110dbc4
{
private static $loader;
@@ -24,12 +24,12 @@
require __DIR__ . '/platform_check.php';
- spl_autoload_register(array('ComposerAutoloaderInitdaa845b7071a2ebafc731b437b87bad7', 'loadClassLoader'), true, true);
+ spl_autoload_register(array('ComposerAutoloaderInit24362f9b9ff49b43fd181a99a110dbc4', 'loadClassLoader'), true, true);
self::$loader = $loader = new ComposerAutoloadClassLoader(dirname(__DIR__));
- spl_autoload_unregister(array('ComposerAutoloaderInitdaa845b7071a2ebafc731b437b87bad7', 'loadClassLoader'));
+ spl_autoload_unregister(array('ComposerAutoloaderInit24362f9b9ff49b43fd181a99a110dbc4', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
- call_user_func(ComposerAutoloadComposerStaticInitdaa845b7071a2ebafc731b437b87bad7::getInitializer($loader));
+ call_user_func(ComposerAutoloadComposerStaticInit24362f9b9ff49b43fd181a99a110dbc4::getInitializer($loader));
$loader->register(true);
--- a/user-access-manager/vendor/composer/autoload_static.php
+++ b/user-access-manager/vendor/composer/autoload_static.php
@@ -4,7 +4,7 @@
namespace ComposerAutoload;
-class ComposerStaticInitdaa845b7071a2ebafc731b437b87bad7
+class ComposerStaticInit24362f9b9ff49b43fd181a99a110dbc4
{
public static $prefixLengthsPsr4 = array (
'U' =>
@@ -27,9 +27,9 @@
public static function getInitializer(ClassLoader $loader)
{
return Closure::bind(function () use ($loader) {
- $loader->prefixLengthsPsr4 = ComposerStaticInitdaa845b7071a2ebafc731b437b87bad7::$prefixLengthsPsr4;
- $loader->prefixDirsPsr4 = ComposerStaticInitdaa845b7071a2ebafc731b437b87bad7::$prefixDirsPsr4;
- $loader->classMap = ComposerStaticInitdaa845b7071a2ebafc731b437b87bad7::$classMap;
+ $loader->prefixLengthsPsr4 = ComposerStaticInit24362f9b9ff49b43fd181a99a110dbc4::$prefixLengthsPsr4;
+ $loader->prefixDirsPsr4 = ComposerStaticInit24362f9b9ff49b43fd181a99a110dbc4::$prefixDirsPsr4;
+ $loader->classMap = ComposerStaticInit24362f9b9ff49b43fd181a99a110dbc4::$classMap;
}, null, ClassLoader::class);
}
--- a/user-access-manager/vendor/composer/installed.php
+++ b/user-access-manager/vendor/composer/installed.php
@@ -1,8 +1,8 @@
<?php return array(
'root' => array(
'name' => 'gmalex/user-access-manager',
- 'pretty_version' => '2.3.14',
- 'version' => '2.3.14.0',
+ 'pretty_version' => '2.3.15',
+ 'version' => '2.3.15.0',
'reference' => null,
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
@@ -11,8 +11,8 @@
),
'versions' => array(
'gmalex/user-access-manager' => array(
- 'pretty_version' => '2.3.14',
- 'version' => '2.3.14.0',
+ 'pretty_version' => '2.3.15',
+ 'version' => '2.3.15.0',
'reference' => null,
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',