PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.1.1
Kirki – Freeform Page Builder, Website Builder & Customizer v6.1.1
6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / includes / Ajax / WpAdmin.php
kirki / includes / Ajax Last commit date
Collaboration 3 weeks ago Apps.php 3 weeks ago Collection.php 1 month ago Comments.php 2 months ago DynamicContent.php 1 month ago ExportImport.php 3 days ago Form.php 3 weeks ago Media.php 3 days ago Page.php 3 days ago PageSettings.php 3 weeks ago RBAC.php 3 weeks ago Symbol.php 3 weeks ago Taxonomy.php 2 months ago TemplateExportImport.php 2 months ago UserData.php 3 weeks ago Users.php 2 months ago Walkthrough.php 2 months ago WordpressData.php 2 months ago WpAdmin.php 3 days ago
WpAdmin.php
147 lines
1 <?php
2 /**
3 * WpAdmin dashboard api calls
4 *
5 * @package kirki
6 */
7
8 namespace Kirki\Ajax;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit; // Exit if accessed directly.
12 }
13 use Kirki\HelperFunctions;
14
15
16 /**
17 * WpAdmin API Class
18 */
19 class WpAdmin {
20
21 /**
22 * Save common data from dashboard
23 *
24 * @return void wp_send_json.
25 */
26 public static function save_common_data() {
27 //phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
28 $data = isset( $_POST['data'] ) ? $_POST['data'] : null;
29 $data = json_decode( stripslashes( $data ), true );
30
31 $new_data = self::get_common_data( true );
32
33 if ( isset( $data['license_key'], $data['license_key']['key'] ) ) {
34 if ( $data['license_key']['key'] !== '' ) {
35 $license_key = $data['license_key']['key'];
36 $license_info = HelperFunctions::get_my_license_info( $license_key );
37 $new_data['license_key'] = $license_info;
38 } else {
39 $new_data['license_key'] = array(
40 'key' => '',
41 'valid' => false,
42 );
43 }
44 }
45
46 if ( isset( $data['json_upload'] ) ) {
47 $new_data['json_upload'] = $data['json_upload'];
48 }
49 if ( isset( $data['pexels_api_key'] ) ) {
50 $new_data['pexels_api_key'] = $data['pexels_api_key'];
51 }
52 if ( isset( $data['pexels_status'] ) ) {
53 $new_data['pexels_status'] = $data['pexels_status'];
54 }
55 if ( isset( $data['svg_upload'] ) ) {
56 $new_data['svg_upload'] = $data['svg_upload'];
57 }
58 if ( isset( $data['is_show_wp_theme_header_footer'] ) ) {
59 $new_data['is_show_wp_theme_header_footer'] = $data['is_show_wp_theme_header_footer'];
60 }
61 if ( isset( $data['image_optimization'] ) ) {
62 $new_data['image_optimization'] = $data['image_optimization'];
63 }
64
65 if ( isset( $data['google_font_api_key'] ) ) {
66 $new_data['google_font_api_key'] = $data['google_font_api_key'];
67 }
68
69 if ( isset( $data['unsplash_api_key'] ) ) {
70 $new_data['unsplash_api_key'] = $data['unsplash_api_key'];
71 }
72 if ( isset( $data['unsplash_status'] ) ) {
73 $new_data['unsplash_status'] = $data['unsplash_status'];
74 }
75
76 if ( isset( $data['reCAPTCHA_status'] ) ) {
77 $new_data['reCAPTCHA_status'] = $data['reCAPTCHA_status'];
78 }
79
80 if ( isset( $data['smooth_scroll'] ) ) {
81 $new_data['smooth_scroll'] = $data['smooth_scroll'];
82 }
83
84 if ( isset( $data['recaptcha'] ) ) {
85 // set data version wise, e.g: { GRC_version: '2.0', '2.0:{}, '3.0:{} }.
86 $new_data['recaptcha']['GRC_version'] = $data['recaptcha']['GRC_version'];
87 $new_data['recaptcha'][ $new_data['recaptcha']['GRC_version'] ] = $data['recaptcha'][ $data['recaptcha']['GRC_version'] ];
88 }
89
90 if ( isset( $data['chatGPT_api_key'] ) ) {
91 $new_data['chatGPT_api_key'] = $data['chatGPT_api_key'];
92 }
93 if ( isset( $data['chatGPT_status'] ) ) {
94 $new_data['chatGPT_status'] = $data['chatGPT_status'];
95 }
96
97 update_option( KIRKI_WP_ADMIN_COMMON_DATA, $new_data, false );
98
99 wp_send_json(
100 array(
101 'status' => 'success',
102 'data' => self::get_common_data( true ),
103 )
104 );
105 }
106
107 /**
108 * Get common data
109 *
110 * @param boolean $inernal if this method call from intenally.
111 * @return void|array wp_send_json.
112 */
113 public static function get_common_data( $inernal = false ) {
114 $data = get_option( KIRKI_WP_ADMIN_COMMON_DATA, array() );
115 $data['post_max_size'] = ini_get( 'post_max_size' );
116 $data['php_zip_ext_enabled'] = class_exists( 'ZipArchive' );
117 if ( ! isset( $data['is_show_wp_theme_header_footer'] ) ) {
118 $data['is_show_wp_theme_header_footer'] = true;
119 }
120 if ( $inernal ) {
121 return $data;
122 } else {
123 if ( HelperFunctions::is_api_call_from_editor_preview() ) {
124 wp_send_json( array( 'license_key' => $data['license_key'] ) );
125 }
126 wp_send_json( $data );
127 }
128 }
129
130 /**
131 * Update common data license and editor type data.
132 *
133 * @return void wp_send_json_success.
134 */
135 public static function update_license_validity() {
136 $valid = filter_input( INPUT_POST, 'valid', FILTER_VALIDATE_BOOLEAN );
137 $data = self::get_common_data( true );
138
139 if ( isset( $data['license_key'] ) ) {
140 $data['license_key']['valid'] = $valid;
141
142 update_option( KIRKI_WP_ADMIN_COMMON_DATA, $data, false );
143 wp_send_json_success( true );
144 }
145 }
146 }
147