PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.2.12
Adminify – White Label, Admin Menu Editor, Login Customizer v4.2.12
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 / Libs / adminify-framework / functions / actions.php

actions.php in Adminify – White Label, Admin Menu Editor, Login Customizer 4.2.12, at Libs/adminify-framework/functions/actions.php

208 lines 6.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 /**
3 *
4 * Get icons from admin ajax
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! function_exists( 'adminify_get_icons' ) ) {
11 function adminify_get_icons() {
12
13 $nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
14
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
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 }
23
24 ob_start();
25
26 $icon_library = ( apply_filters( 'adminify_fa4', false ) ) ? 'fa4' : 'fa5';
27
28 ADMINIFY::include_plugin_file( 'fields/icon/'. $icon_library .'-icons.php' );
29
30 $icon_lists = apply_filters( 'pxlbsadminify_field_icon_add_icons', adminify_get_default_icons() );
31
32 if ( ! empty( $icon_lists ) ) {
33
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' );
56 }
57
58 /**
59 *
60 * Export
61 *
62 * @since 1.0.0
63 * @version 1.0.0
64 *
65 */
66 if ( ! function_exists( 'adminify_export' ) ) {
67 function adminify_export() {
68
69 $nonce = ( ! empty( $_GET[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_GET[ 'nonce' ] ) ) : '';
70 $unique = ( ! empty( $_GET[ 'unique' ] ) ) ? sanitize_text_field( wp_unslash( $_GET[ 'unique' ] ) ) : '';
71
72 if ( ! wp_verify_nonce( $nonce, 'adminify_backup_nonce' ) ) {
73 die( esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) );
74 }
75
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 }
80
81 if ( empty( $unique ) ) {
82 die( esc_html__( 'Error: Invalid key.', 'adminify' ) );
83 }
84
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' );
98 }
99
100 /**
101 *
102 * Import Ajax
103 *
104 * @since 1.0.0
105 * @version 1.0.0
106 *
107 */
108 if ( ! function_exists( 'adminify_import_ajax' ) ) {
109 function adminify_import_ajax() {
110
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.
115
116 if ( ! wp_verify_nonce( $nonce, 'adminify_backup_nonce' ) ) {
117 wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) ) );
118 }
119
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 }
124
125 if ( empty( $unique ) ) {
126 wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid key.', 'adminify' ) ) );
127 }
128
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 }
132
133 // Success
134 update_option( $unique, $data );
135
136 wp_send_json_success();
137
138 }
139 add_action( 'wp_ajax_adminify-import', 'adminify_import_ajax' );
140 }
141
142 /**
143 *
144 * Reset Ajax
145 *
146 * @since 1.0.0
147 * @version 1.0.0
148 *
149 */
150 if ( ! function_exists( 'adminify_reset_ajax' ) ) {
151 function adminify_reset_ajax() {
152
153 $nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
154 $unique = ( ! empty( $_POST[ 'unique' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'unique' ] ) ) : '';
155
156 if ( ! wp_verify_nonce( $nonce, 'adminify_backup_nonce' ) ) {
157 wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'adminify' ) ) );
158 }
159
160 // Success
161 delete_option( $unique );
162
163 wp_send_json_success();
164
165 }
166 add_action( 'wp_ajax_adminify-reset', 'adminify_reset_ajax' );
167 }
168
169 /**
170 *
171 * Chosen Ajax
172 *
173 * @since 1.0.0
174 * @version 1.0.0
175 *
176 */
177 if ( ! function_exists( 'adminify_chosen_ajax' ) ) {
178 function adminify_chosen_ajax() {
179
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.
185
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 }
189
190 if ( empty( $type ) || empty( $term ) ) {
191 wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid term ID.', 'adminify' ) ) );
192 }
193
194 $capability = apply_filters( 'adminify_chosen_ajax_capability', 'manage_options' );
195
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 }
199
200 // Success
201 $options = ADMINIFY_Fields::field_data( $type, $term, $query );
202
203 wp_send_json_success( $options );
204
205 }
206 add_action( 'wp_ajax_adminify-chosen', 'adminify_chosen_ajax' );
207 }
208