PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.0.2.5
Adminify – White Label, Admin Menu Editor, Login Customizer v4.0.2.5
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Inc / Admin / Frames / Init.php

Init.php in Adminify – White Label, Admin Menu Editor, Login Customizer 4.0.2.5, at Inc/Admin/Frames/Init.php

144 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPAdminify\Inc\Admin\Frames;
4
5 // no direct access allowed
6 if (!defined('ABSPATH')) {
7 exit;
8 }
9 /**
10 * WP Adminify
11 * Init Class
12 *
13 * @author Jewel Theme <support@jeweltheme.com>
14 */
15
16 if (!class_exists('Init')) {
17 class Init
18 {
19 public static $instance;
20 public $admin;
21 public $frame;
22
23 public static function instance()
24 {
25 if (is_null(self::$instance)) {
26 self::$instance = new self();
27 }
28 return self::$instance;
29 }
30
31 public function __construct()
32 {
33
34 if ( ! $this->is_allowed() ) {
35 if ( is_iframe() ) {
36 Frames::custom_plugin_change_reload();
37 }
38 return;
39 }
40
41 if ( is_iframe() ) {
42 $this->frame = new Frames();
43 } else {
44 $this->admin = new Admin();
45 }
46
47 }
48
49 public function is_allowed() {
50
51 $not_allowed_urls = Admin::get_not_allowed_urls();
52
53 foreach ( $not_allowed_urls as $url_object ) {
54
55 if ( is_string( $url_object ) ) {
56
57 $is_allowed = true; // Scoped Default allowed
58 if ( $url_object === $_SERVER['PHP_SELF'] ) $is_allowed = false; // not allowed
59
60 } else {
61
62 $is_allowed = false; // Scoped Default not allowed
63
64 if ( $url_object['url'] !== '*' && $url_object['url'] !== $_SERVER['PHP_SELF'] ) $is_allowed = true; // allowed
65
66 if ( ! $is_allowed && array_key_exists( 'query_params', $url_object ) ) {
67 if ( ! $this->check_query_params( $url_object['query_params'] ) ) $is_allowed = true; // allowed
68 }
69
70 if ( ! $is_allowed && array_key_exists( 'post_type', $url_object ) ) {
71 if ( ! $this->check_post_type( $url_object['post_type'] ) ) $is_allowed = true; // allowed
72 }
73
74 }
75
76 if ( ! $is_allowed ) return $is_allowed;
77
78 }
79
80 return true;
81
82 }
83
84 function check_query_params($query_params) {
85
86 // Pattern 1: Check for only keys in $_GET, no need to check their values
87 if (array_values($query_params) === $query_params) {
88 foreach ($query_params as $param) {
89
90 if ( substr($param, -1) === '!' ) {
91 $param = substr($param, 0, -1);
92 if ( isset($_GET[$param]) ) return false; // The key exists in $_GET
93 } else {
94 if ( ! isset($_GET[$param]) ) return false; // The key doesn't exist in $_GET
95 }
96
97 }
98 return true; // All keys exist
99 }
100
101 // Pattern 2: Both keys and their values should check in $_GET
102 if (array_keys($query_params) === $query_params) {
103 foreach ($query_params as $key => $value) {
104 if (!isset($_GET[$key]) || $_GET[$key] != $value) {
105 return false; // Key doesn't exist or the value doesn't match
106 }
107 }
108 return true; // All keys and values match
109 }
110
111 // Pattern 3: A mix of key existence and key-value matching
112 foreach ($query_params as $key => $value) {
113 if (is_numeric($key)) {
114 // For numeric keys, we're checking only existence (Pattern 1 behavior)
115 if ( substr($value, -1) === '!' ) {
116 $value = substr($value, 0, -1);
117 if ( isset($_GET[$value]) ) return false; // The key exists in $_GET
118 } else {
119 if ( ! isset($_GET[$value]) ) return false; // The key doesn't exist in $_GET
120 }
121 } else {
122 // For associative keys, we check for both key and value (Pattern 2 behavior)
123 if (!isset($_GET[$key]) || $_GET[$key] != $value) {
124 return false; // Key doesn't exist or value doesn't match
125 }
126 }
127 }
128
129 return true; // All conditions are met
130 }
131
132 function check_post_type($post_types) {
133 if ( isset( $_GET['post_type'] ) ) {
134 return in_array( $_GET['post_type'], $post_types );
135 } else if ( isset( $_GET['post'] ) ) {
136 return in_array( get_post_type( $_GET['post'] ), $post_types );
137 }
138 return in_array( 'post', $post_types );
139 }
140
141 }
142
143 }
144