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 -109 4.1.173.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,51 +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 - ob_start();
20 + $icon_library = ( apply_filters( 'adminify_fa4', false ) ) ? 'fa4' : 'fa5';
20 21
21 - $icon_library = ( apply_filters( 'adminify_fa4', false ) ) ? 'fa4' : 'fa5';
22 + ADMINIFY::include_plugin_file( 'fields/icon/' . $icon_library . '-icons.php' );
22 23
23 - ADMINIFY::include_plugin_file( 'fields/icon/'. $icon_library .'-icons.php' );
24 + $icon_lists = apply_filters( 'adminify_field_icon_add_icons', adminify_get_default_icons() );
24 25
25 - $icon_lists = apply_filters( 'adminify_field_icon_add_icons', adminify_get_default_icons() );
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>' : '';
26 29
27 - if ( ! empty( $icon_lists ) ) {
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 + }
28 37
29 - foreach ( $icon_lists as $list ) {
38 + $content = ob_get_clean();
30 39
31 - echo ( count( $icon_lists ) >= 2 ) ? '<div class="adminify-icon-title">'. esc_attr( $list['title'] ) .'</div>' : '';
32 -
33 - foreach ( $list['icons'] as $icon ) {
34 - echo '<i title="'. esc_attr( $icon ) .'" class="'. esc_attr( $icon ) .'"></i>';
35 - }
36 -
37 - }
38 -
39 - } else {
40 -
41 - echo '<div class="adminify-error-text">'. esc_html__( 'No data available.', 'adminify' ) .'</div>';
42 -
43 - }
44 -
45 - $content = ob_get_clean();
46 -
47 - wp_send_json_success( array( 'content' => $content ) );
48 -
49 - }
50 - 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' );
51 43 }
52 44
53 45 /**
54 46 *
@@ -55,37 +47,34 @@
55 47 * Export
56 48 *
57 49 * @since 1.0.0
58 50 * @version 1.0.0
59 - *
60 51 */
61 52 if ( ! function_exists( 'adminify_export' ) ) {
62 - 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'] ) ) : '';
63 56
64 - $nonce = ( ! empty( $_GET[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_GET[ 'nonce' ] ) ) : '';
65 - $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 + }
66 60
67 - if ( ! wp_verify_nonce( $nonce, 'adminify_backup_nonce' ) ) {
68 - die( esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) );
69 - }
61 + if ( empty( $unique ) ) {
62 + die( esc_html__( 'Error: Invalid key.', 'adminify' ) );
63 + }
70 64
71 - if ( empty( $unique ) ) {
72 - die( esc_html__( 'Error: Invalid key.', 'adminify' ) );
73 - }
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' );
74 71
75 - // Export
76 - header('Content-Type: application/json');
77 - header('Content-disposition: attachment; filename=backup-'. gmdate( 'd-m-Y' ) .'.json');
78 - header('Content-Transfer-Encoding: binary');
79 - header('Pragma: no-cache');
80 - header('Expires: 0');
72 + echo json_encode( get_option( $unique ) );
81 73
82 - echo json_encode( get_option( $unique ) );
83 -
84 - die();
85 -
86 - }
87 - add_action( 'wp_ajax_adminify-export', 'adminify_export' );
74 + die();
75 + }
76 + add_action( 'wp_ajax_adminify-export', 'adminify_export' );
88 77 }
89 78
90 79 /**
91 80 *
@@ -92,36 +81,48 @@
92 81 * Import Ajax
93 82 *
94 83 * @since 1.0.0
95 84 * @version 1.0.0
96 - *
97 85 */
98 86 if ( ! function_exists( 'adminify_import_ajax' ) ) {
99 - 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 + }
100 93
101 - $nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
102 - $unique = ( ! empty( $_POST[ 'unique' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'unique' ] ) ) : '';
103 - $data = ( ! empty( $_POST[ 'data' ] ) ) ? wp_kses_post_deep( json_decode( wp_unslash( trim( $_POST[ 'data' ] ) ), true ) ) : array();
94 + if ( ! empty( $_POST['unique'] ) ) {
95 + $unique = sanitize_text_field( wp_unslash( $_POST['unique'] ) );
96 + } else {
97 + $unique = '';
98 + }
104 99
105 - if ( ! wp_verify_nonce( $nonce, 'adminify_backup_nonce' ) ) {
106 - wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) ) );
107 - }
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 + }
108 106
109 - if ( empty( $unique ) ) {
110 - wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid key.', 'adminify' ) ) );
111 - }
107 + if ( ! wp_verify_nonce( $nonce, 'adminify_backup_nonce' ) ) {
108 + wp_send_json_error( [ 'error' => esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) ] );
109 + }
112 110
113 - if ( empty( $data ) || ! is_array( $data ) ) {
114 - wp_send_json_error( array( 'error' => esc_html__( 'Error: The response is not a valid JSON response.', 'adminify' ) ) );
115 - }
111 + if ( empty( $unique ) ) {
112 + wp_send_json_error( [ 'error' => esc_html__( 'Error: Invalid key.', 'adminify' ) ] );
113 + }
116 114
117 - // Success
118 - update_option( $unique, $data );
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 + }
119 118
120 - wp_send_json_success();
119 + // Success
120 + update_option( $unique, $data );
121 121
122 - }
123 - 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' );
124 125 }
125 126
126 127 /**
127 128 *
@@ -128,27 +129,24 @@
128 129 * Reset Ajax
129 130 *
130 131 * @since 1.0.0
131 132 * @version 1.0.0
132 - *
133 133 */
134 134 if ( ! function_exists( 'adminify_reset_ajax' ) ) {
135 - 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'] ) ) : '';
136 138
137 - $nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
138 - $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 + }
139 142
140 - if ( ! wp_verify_nonce( $nonce, 'adminify_backup_nonce' ) ) {
141 - wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) ) );
142 - }
143 + // Success
144 + delete_option( $unique );
143 145
144 - // Success
145 - delete_option( $unique );
146 -
147 - wp_send_json_success();
148 -
149 - }
150 - 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' );
151 149 }
152 150
153 151 /**
154 152 *
@@ -155,36 +153,52 @@
155 153 * Chosen Ajax
156 154 *
157 155 * @since 1.0.0
158 156 * @version 1.0.0
159 - *
160 157 */
161 158 if ( ! function_exists( 'adminify_chosen_ajax' ) ) {
162 - 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 + }
163 165
164 - $nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
165 - $type = ( ! empty( $_POST[ 'type' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'type' ] ) ) : '';
166 - $term = ( ! empty( $_POST[ 'term' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'term' ] ) ) : '';
167 - $query = ( ! empty( $_POST[ 'query_args' ] ) ) ? wp_kses_post_deep( $_POST[ 'query_args' ] ) : array();
166 + if ( ! empty( $_POST['type'] ) ) {
167 + $type = sanitize_text_field( wp_unslash( $_POST['type'] ) );
168 + } else {
169 + $type = '';
170 + }
168 171
169 - if ( ! wp_verify_nonce( $nonce, 'adminify_chosen_ajax_nonce' ) ) {
170 - wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) ) );
171 - }
172 + if ( ! empty( $_POST['term'] ) ) {
173 + $term = sanitize_text_field( wp_unslash( $_POST['term'] ) );
174 + } else {
175 + $term = '';
176 + }
172 177
173 - if ( empty( $type ) || empty( $term ) ) {
174 - wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid term ID.', 'adminify' ) ) );
175 - }
178 + if ( ! empty( $_POST['query_args'] ) ) {
179 + $query = sanitize_text_field( wp_unslash( $_POST['query_args'] ) );
180 + } else {
181 + $query = [];
182 + }
176 183
177 - $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 + }
178 187
179 - if ( ! current_user_can( $capability ) ) {
180 - wp_send_json_error( array( 'error' => esc_html__( 'Error: You do not have permission to do that.', 'adminify' ) ) );
181 - }
188 + if ( empty( $type ) || empty( $term ) ) {
189 + wp_send_json_error( [ 'error' => esc_html__( 'Error: Invalid term ID.', 'adminify' ) ] );
190 + }
182 191
183 - // Success
184 - $options = ADMINIFY_Fields::field_data( $type, $term, $query );
192 + $capability = apply_filters( 'adminify_chosen_ajax_capability', 'manage_options' );
185 193
186 - 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 + }
187 197
188 - }
189 - 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' );
190 204 }