| @@ -77,9 +77,13 @@ | ||
| 77 | 77 | |
| 78 | 78 | // Check post type. |
| 79 | 79 | $post_type = get_post_type(); |
| 80 | 80 | if ( empty( $post_type ) && ! empty( $_GET['post_type'] ) ) { |
| 81 | - $post_type = intval( $_GET['post_type'] ); | |
| 81 | + // A post type is a slug, not a number: intval() made this always 0. | |
| 82 | + // is_scalar() because ?post_type[]=x would otherwise reach strtolower( array ). | |
| 83 | + $post_type = is_scalar( $_GET['post_type'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 84 | + ? sanitize_key( wp_unslash( $_GET['post_type'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 85 | + : ''; | |
| 82 | 86 | } |
| 83 | 87 | |
| 84 | 88 | if ( 'rmp_menu' !== $post_type || ! empty( $_GET['page'] ) ) { |
| 85 | 89 | return; |
| @@ -134,9 +138,13 @@ | ||
| 134 | 138 | */ |
| 135 | 139 | public function rmp_upgrade_pro_admin_notice() { |
| 136 | 140 | $post_type = get_post_type(); |
| 137 | 141 | if ( empty( $post_type ) && ! empty( $_GET['post_type'] ) ) { |
| 138 | - $post_type = intval( $_GET['post_type'] ); | |
| 142 | + // A post type is a slug, not a number: intval() made this always 0. | |
| 143 | + // is_scalar() because ?post_type[]=x would otherwise reach strtolower( array ). | |
| 144 | + $post_type = is_scalar( $_GET['post_type'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 145 | + ? sanitize_key( wp_unslash( $_GET['post_type'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 146 | + : ''; | |
| 139 | 147 | } |
| 140 | 148 | |
| 141 | 149 | if ( 'rmp_menu' !== $post_type ) { |
| 142 | 150 | return; |