Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 9 additions & 23 deletions inc-setup/helping_hands.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,29 +178,15 @@ function _mw_adminimize_check_page_access( $slug ) {
return false;
}

// Parse the slug to extract its path and query components for comparison.
$slug_parts = wp_parse_url( $slug );
$slug_path = isset( $slug_parts['path'] ) ? $slug_parts['path'] : $slug;
$slug_query = isset( $slug_parts['query'] ) ? $slug_parts['query'] : '';

// Check if the current page path matches the blocked slug path.
if ( strpos( $uri['path'], $slug_path ) !== false ) {
// If the slug has its own query params (e.g. edit.php?post_type=page),
// verify those params are present in the current request.
if ( $slug_query ) {
$request_query = isset( $uri['query'] ) ? $uri['query'] : '';
parse_str( $slug_query, $slug_params );
parse_str( $request_query, $request_params );

// All slug query params must be present in the request.
foreach ( $slug_params as $key => $value ) {
if ( ! isset( $request_params[ $key ] ) || $request_params[ $key ] !== $value ) {
return false;
}
}
}
// URI without query parameter, like WP core edit.php.
if ( ! isset( $uri['query'] ) && strpos( $uri['path'], $slug ) !== false ) {
add_action( 'load-' . $slug, '_mw_adminimize_block_page_access' );
return true;
}

add_action( 'load-' . $uri['path'], '_mw_adminimize_block_page_access' );
// URL is equal the slug of WP menu.
if ( $slug === $url ) {
add_action( 'load-' . basename( $uri['path'] ), '_mw_adminimize_block_page_access' );
return true;
}
}
Expand Down Expand Up @@ -236,4 +222,4 @@ function _mw_adminimize_is_checked( $option, $haystack ) {
}

return '';
}
}
Loading