PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.4.1
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.4.1
4.3.2 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 All 165 releases
← All changes | Libs/adminify-framework/functions/actions.php +123 -126 4.2.163.2.4.1 View file →
@@ -1,5 +1,6 @@
1 -<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
1 +<?php if ( ! defined( 'ABSPATH' ) ) {
2 + die; } // Cannot access directly.
2 3 /**
3 4 *
4 5 * Get icons from admin ajax
5 6 *
@@ -4,56 +5,42 @@
4 5 * Get icons from admin ajax
5 6 *
6 7 * @since 1.0.0
7 8 * @version 1.0.0
8 - *
9 9 */
10 10 if ( ! function_exists( 'adminify_get_icons' ) ) {
11 - function adminify_get_icons() {
11 + function adminify_get_icons() {
12 + $nonce = ( ! empty( $_POST['nonce'] ) ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
12 13
13 - $nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
14 + if ( ! wp_verify_nonce( $nonce, 'adminify_icon_nonce' ) ) {
15 + wp_send_json_error( [ 'error' => esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) ] );
16 + }
14 17
15 - if ( ! wp_verify_nonce( $nonce, 'adminify_icon_nonce' ) ) {
16 - wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) ) );
17 - }
18 + ob_start();
18 19
19 - // Authorization: this icon picker is an editor-facing admin helper.
20 - if ( ! current_user_can( 'edit_posts' ) ) {
21 - wp_send_json_error( array( 'error' => esc_html__( 'Error: You do not have permission to perform this action.', 'adminify' ) ) );
22 - }
20 + $icon_library = ( apply_filters( 'adminify_fa4', false ) ) ? 'fa4' : 'fa5';
23 21
24 - ob_start();
22 + ADMINIFY::include_plugin_file( 'fields/icon/' . $icon_library . '-icons.php' );
25 23
26 - $icon_library = ( apply_filters( 'adminify_fa4', false ) ) ? 'fa4' : 'fa5';
24 + $icon_lists = apply_filters( 'adminify_field_icon_add_icons', adminify_get_default_icons() );
27 25
28 - ADMINIFY::include_plugin_file( 'fields/icon/'. $icon_library .'-icons.php' );
26 + if ( ! empty( $icon_lists ) ) {
27 + foreach ( $icon_lists as $list ) {
28 + echo ( count( $icon_lists ) >= 2 ) ? '<div class="adminify-icon-title">' . esc_attr( $list['title'] ) . '</div>' : '';
29 29
30 - $icon_lists = apply_filters( 'pxlbsadminify_field_icon_add_icons', adminify_get_default_icons() );
30 + foreach ( $list['icons'] as $icon ) {
31 + echo '<i title="' . esc_attr( $icon ) . '" class="' . esc_attr( $icon ) . '"></i>';
32 + }
33 + }
34 + } else {
35 + echo '<div class="adminify-error-text">' . esc_html__( 'No data available.', 'adminify' ) . '</div>';
36 + }
31 37
32 - if ( ! empty( $icon_lists ) ) {
38 + $content = ob_get_clean();
33 39
34 - foreach ( $icon_lists as $list ) {
35 -
36 - echo ( count( $icon_lists ) >= 2 ) ? '<div class="adminify-icon-title">'. esc_attr( $list['title'] ) .'</div>' : '';
37 -
38 - foreach ( $list['icons'] as $icon ) {
39 - echo '<i title="'. esc_attr( $icon ) .'" class="'. esc_attr( $icon ) .'"></i>';
40 - }
41 -
42 - }
43 -
44 - } else {
45 -
46 - echo '<div class="adminify-error-text">'. esc_html__( 'No data available.', 'adminify' ) .'</div>';
47 -
48 - }
49 -
50 - $content = ob_get_clean();
51 -
52 - wp_send_json_success( array( 'content' => $content ) );
53 -
54 - }
55 - add_action( 'wp_ajax_adminify-get-icons', 'adminify_get_icons' );
40 + wp_send_json_success( [ 'content' => $content ] );
41 + }
42 + add_action( 'wp_ajax_adminify-get-icons', 'adminify_get_icons' );
56 43 }
57 44
58 45 /**
59 46 *
@@ -60,42 +47,34 @@
60 47 * Export
61 48 *
62 49 * @since 1.0.0
63 50 * @version 1.0.0
64 - *
65 51 */
66 52 if ( ! function_exists( 'adminify_export' ) ) {
67 - function adminify_export() {
53 + function adminify_export() {
54 + $nonce = ( ! empty( $_GET['nonce'] ) ) ? sanitize_text_field( wp_unslash( $_GET['nonce'] ) ) : '';
55 + $unique = ( ! empty( $_GET['unique'] ) ) ? sanitize_text_field( wp_unslash( $_GET['unique'] ) ) : '';
68 56
69 - $nonce = ( ! empty( $_GET[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_GET[ 'nonce' ] ) ) : '';
70 - $unique = ( ! empty( $_GET[ 'unique' ] ) ) ? sanitize_text_field( wp_unslash( $_GET[ 'unique' ] ) ) : '';
57 + if ( ! wp_verify_nonce( $nonce, 'adminify_backup_nonce' ) ) {
58 + die( esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) );
59 + }
71 60
72 - if ( ! wp_verify_nonce( $nonce, 'adminify_backup_nonce' ) ) {
73 - die( esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) );
74 - }
61 + if ( empty( $unique ) ) {
62 + die( esc_html__( 'Error: Invalid key.', 'adminify' ) );
63 + }
75 64
76 - // Authorization: only administrators may export settings.
77 - if ( ! current_user_can( 'manage_options' ) ) {
78 - die( esc_html__( 'Error: You do not have permission to perform this action.', 'adminify' ) );
79 - }
65 + // Export
66 + header( 'Content-Type: application/json' );
67 + header( 'Content-disposition: attachment; filename=backup-' . gmdate( 'd-m-Y' ) . '.json' );
68 + header( 'Content-Transfer-Encoding: binary' );
69 + header( 'Pragma: no-cache' );
70 + header( 'Expires: 0' );
80 71
81 - if ( empty( $unique ) ) {
82 - die( esc_html__( 'Error: Invalid key.', 'adminify' ) );
83 - }
72 + echo json_encode( get_option( $unique ) );
84 73
85 - // Export
86 - header('Content-Type: application/json');
87 - header('Content-disposition: attachment; filename=backup-'. gmdate( 'd-m-Y' ) .'.json');
88 - header('Content-Transfer-Encoding: binary');
89 - header('Pragma: no-cache');
90 - header('Expires: 0');
91 -
92 - echo wp_json_encode( get_option( $unique ) );
93 -
94 - die();
95 -
96 - }
97 - add_action( 'wp_ajax_adminify-export', 'adminify_export' );
74 + die();
75 + }
76 + add_action( 'wp_ajax_adminify-export', 'adminify_export' );
98 77 }
99 78
100 79 /**
101 80 *
@@ -102,42 +81,48 @@
102 81 * Import Ajax
103 82 *
104 83 * @since 1.0.0
105 84 * @version 1.0.0
106 - *
107 85 */
108 86 if ( ! function_exists( 'adminify_import_ajax' ) ) {
109 - function adminify_import_ajax() {
87 + function adminify_import_ajax() {
88 + if ( ! empty( $_POST['nonce'] ) ) {
89 + $nonce = sanitize_text_field( wp_unslash( $_POST['nonce'] ) );
90 + } else {
91 + $nonce = '';
92 + }
110 93
111 - $nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
112 - $unique = ( ! empty( $_POST[ 'unique' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'unique' ] ) ) : '';
113 - // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce verified below before any data is processed.
114 - $data = ( ! empty( $_POST[ 'data' ] ) ) ? wp_kses_post_deep( json_decode( trim( wp_unslash( $_POST[ 'data' ] ) ), true ) ) : array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- each field is sanitized individually by the framework's per-field sanitize handlers.
94 + if ( ! empty( $_POST['unique'] ) ) {
95 + $unique = sanitize_text_field( wp_unslash( $_POST['unique'] ) );
96 + } else {
97 + $unique = '';
98 + }
115 99
116 - if ( ! wp_verify_nonce( $nonce, 'adminify_backup_nonce' ) ) {
117 - wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) ) );
118 - }
100 + if ( ! empty( $_POST['data'] ) ) {
101 + // sanitized after decode
102 + $data = wp_kses_post_deep( json_decode( wp_unslash( $_POST['data'] ), true ) );
103 + } else {
104 + $data = [];
105 + }
119 106
120 - // Authorization: only administrators may import settings.
121 - if ( ! current_user_can( 'manage_options' ) ) {
122 - wp_send_json_error( array( 'error' => esc_html__( 'Error: You do not have permission to perform this action.', 'adminify' ) ) );
123 - }
107 + if ( ! wp_verify_nonce( $nonce, 'adminify_backup_nonce' ) ) {
108 + wp_send_json_error( [ 'error' => esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) ] );
109 + }
124 110
125 - if ( empty( $unique ) ) {
126 - wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid key.', 'adminify' ) ) );
127 - }
111 + if ( empty( $unique ) ) {
112 + wp_send_json_error( [ 'error' => esc_html__( 'Error: Invalid key.', 'adminify' ) ] );
113 + }
128 114
129 - if ( empty( $data ) || ! is_array( $data ) ) {
130 - wp_send_json_error( array( 'error' => esc_html__( 'Error: The response is not a valid JSON response.', 'adminify' ) ) );
131 - }
115 + if ( empty( $data ) || ! is_array( $data ) ) {
116 + wp_send_json_error( [ 'error' => esc_html__( 'Error: The response is not a valid JSON response.', 'adminify' ) ] );
117 + }
132 118
133 - // Success
134 - update_option( $unique, $data );
119 + // Success
120 + update_option( $unique, $data );
135 121
136 - wp_send_json_success();
137 -
138 - }
139 - add_action( 'wp_ajax_adminify-import', 'adminify_import_ajax' );
122 + wp_send_json_success();
123 + }
124 + add_action( 'wp_ajax_adminify-import', 'adminify_import_ajax' );
140 125 }
141 126
142 127 /**
143 128 *
@@ -144,27 +129,24 @@
144 129 * Reset Ajax
145 130 *
146 131 * @since 1.0.0
147 132 * @version 1.0.0
148 - *
149 133 */
150 134 if ( ! function_exists( 'adminify_reset_ajax' ) ) {
151 - function adminify_reset_ajax() {
135 + function adminify_reset_ajax() {
136 + $nonce = ( ! empty( $_POST['nonce'] ) ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
137 + $unique = ( ! empty( $_POST['unique'] ) ) ? sanitize_text_field( wp_unslash( $_POST['unique'] ) ) : '';
152 138
153 - $nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
154 - $unique = ( ! empty( $_POST[ 'unique' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'unique' ] ) ) : '';
139 + if ( ! wp_verify_nonce( $nonce, 'adminify_backup_nonce' ) ) {
140 + wp_send_json_error( [ 'error' => esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) ] );
141 + }
155 142
156 - if ( ! wp_verify_nonce( $nonce, 'adminify_backup_nonce' ) ) {
157 - wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) ) );
158 - }
143 + // Success
144 + delete_option( $unique );
159 145
160 - // Success
161 - delete_option( $unique );
162 -
163 - wp_send_json_success();
164 -
165 - }
166 - add_action( 'wp_ajax_adminify-reset', 'adminify_reset_ajax' );
146 + wp_send_json_success();
147 + }
148 + add_action( 'wp_ajax_adminify-reset', 'adminify_reset_ajax' );
167 149 }
168 150
169 151 /**
170 152 *
@@ -171,37 +153,52 @@
171 153 * Chosen Ajax
172 154 *
173 155 * @since 1.0.0
174 156 * @version 1.0.0
175 - *
176 157 */
177 158 if ( ! function_exists( 'adminify_chosen_ajax' ) ) {
178 - function adminify_chosen_ajax() {
159 + function adminify_chosen_ajax() {
160 + if ( ! empty( $_POST['nonce'] ) ) {
161 + $nonce = sanitize_text_field( wp_unslash( $_POST['nonce'] ) );
162 + } else {
163 + $nonce = '';
164 + }
179 165
180 - $nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
181 - $type = ( ! empty( $_POST[ 'type' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'type' ] ) ) : '';
182 - $term = ( ! empty( $_POST[ 'term' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'term' ] ) ) : '';
183 - // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce verified below before any data is processed.
184 - $query = ( ! empty( $_POST[ 'query_args' ] ) ) ? wp_kses_post_deep( wp_unslash( $_POST[ 'query_args' ] ) ) : array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- each field is sanitized individually by the framework's per-field sanitize handlers.
166 + if ( ! empty( $_POST['type'] ) ) {
167 + $type = sanitize_text_field( wp_unslash( $_POST['type'] ) );
168 + } else {
169 + $type = '';
170 + }
185 171
186 - if ( ! wp_verify_nonce( $nonce, 'adminify_chosen_ajax_nonce' ) ) {
187 - wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) ) );
188 - }
172 + if ( ! empty( $_POST['term'] ) ) {
173 + $term = sanitize_text_field( wp_unslash( $_POST['term'] ) );
174 + } else {
175 + $term = '';
176 + }
189 177
190 - if ( empty( $type ) || empty( $term ) ) {
191 - wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid term ID.', 'adminify' ) ) );
192 - }
178 + if ( ! empty( $_POST['query_args'] ) ) {
179 + $query = sanitize_text_field( wp_unslash( $_POST['query_args'] ) );
180 + } else {
181 + $query = [];
182 + }
193 183
194 - $capability = apply_filters( 'adminify_chosen_ajax_capability', 'manage_options' );
184 + if ( ! wp_verify_nonce( $nonce, 'adminify_chosen_ajax_nonce' ) ) {
185 + wp_send_json_error( [ 'error' => esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) ] );
186 + }
195 187
196 - if ( ! current_user_can( $capability ) ) {
197 - wp_send_json_error( array( 'error' => esc_html__( 'Error: You do not have permission to do that.', 'adminify' ) ) );
198 - }
188 + if ( empty( $type ) || empty( $term ) ) {
189 + wp_send_json_error( [ 'error' => esc_html__( 'Error: Invalid term ID.', 'adminify' ) ] );
190 + }
199 191
200 - // Success
201 - $options = ADMINIFY_Fields::field_data( $type, $term, $query );
192 + $capability = apply_filters( 'adminify_chosen_ajax_capability', 'manage_options' );
202 193
203 - wp_send_json_success( $options );
194 + if ( ! current_user_can( $capability ) ) {
195 + wp_send_json_error( [ 'error' => esc_html__( 'Error: You do not have permission to do that.', 'adminify' ) ] );
196 + }
204 197
205 - }
206 - add_action( 'wp_ajax_adminify-chosen', 'adminify_chosen_ajax' );
198 + // Success
199 + $options = ADMINIFY_Fields::field_data( $type, $term, $query );
200 +
201 + wp_send_json_success( $options );
202 + }
203 + add_action( 'wp_ajax_adminify-chosen', 'adminify_chosen_ajax' );
207 204 }