PluginProbe
Elementor Website Builder – more than just a page builder / 3.34.1
Elementor Website Builder – more than just a page builder v3.34.1
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / modules / editor-one / classes / url-matcher.php

url-matcher.php in Elementor Website Builder – more than just a page builder 3.34.1, at modules/editor-one/classes/url-matcher.php

58 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\EditorOne\Classes;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 class Url_Matcher {
10
11 public function get_match_score( string $menu_url, string $current_uri ): int {
12 $menu_parsed = wp_parse_url( $menu_url );
13
14 if ( empty( $menu_parsed['path'] ) ) {
15 return -1;
16 }
17
18 $current_parsed = wp_parse_url( $current_uri );
19
20 if ( empty( $current_parsed['path'] ) ) {
21 return -1;
22 }
23
24 if ( basename( $menu_parsed['path'] ) !== basename( $current_parsed['path'] ) ) {
25 return -1;
26 }
27
28 $menu_query = $this->parse_query_string( $menu_parsed['query'] ?? '' );
29 $current_query = $this->parse_query_string( $current_parsed['query'] ?? '' );
30
31 if ( ! $this->query_params_match( $menu_query, $current_query ) ) {
32 return -1;
33 }
34
35 return count( $menu_query );
36 }
37
38 public function parse_query_string( string $query ): array {
39 $params = [];
40
41 if ( '' !== $query ) {
42 parse_str( $query, $params );
43 }
44
45 return $params;
46 }
47
48 public function query_params_match( array $required, array $actual ): bool {
49 foreach ( $required as $key => $value ) {
50 if ( ! isset( $actual[ $key ] ) || $actual[ $key ] !== $value ) {
51 return false;
52 }
53 }
54
55 return true;
56 }
57 }
58