PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 3.5.3
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v3.5.3
3.5.3 3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / addons / StyleCustomizer / includes / class-evf-style-customizer-ajax.php
everest-forms / addons / StyleCustomizer / includes Last commit date
configs 1 year ago customize 1 year ago views 5 months ago class-everest-forms-style-customizer.php 1 year ago class-evf-style-customizer-ajax.php 1 year ago class-evf-style-customizer-api.php 1 year ago functions.php 1 year ago
class-evf-style-customizer-ajax.php
156 lines
1 <?php
2 /**
3 * EverestForms Style Customizer Ajax
4 *
5 * @package EverestForms_Style_Customizer
6 * @since 1.0.5
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * Main EverestForms Style Customizer Ajax Class.
13 *
14 * @class EVF_Style_Customizer_Ajax
15 */
16 final class EVF_Style_Customizer_Ajax {
17
18 /**
19 * Constructor.
20 */
21 public function __construct() {
22 add_action( 'wp_ajax_save_template', array( $this, 'save_template' ) );
23 add_action( 'wp_ajax_delete_template', array( $this, 'delete_template' ) );
24 add_action( 'wp_ajax_save_custom_color_palette', array( $this, 'evf_save_custom_color_palette' ) );
25
26 }
27
28 /**
29 * Handle AJAX request to save custom color palette.
30 */
31 public function evf_save_custom_color_palette() {
32 $nonce = isset( $_POST['_nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['_nonce'] ) ) : '';
33
34 if ( ! wp_verify_nonce( $nonce, 'color_palette' ) ) {
35 wp_send_json_error( __( 'Nonce error. Please refresh the page.', 'everest-forms' ) );
36 exit;
37 }
38
39 $label = isset( $_POST['label'] ) ? sanitize_text_field( $_POST['label'] ) : '';
40 $colors = isset( $_POST['colors'] ) ? $_POST['colors'] : array();
41
42 if ( empty( $colors ) ) {
43 wp_send_json_error( __( 'Colors array is empty.', 'everest-forms' ) );
44 exit;
45 }
46
47 delete_option( 'everest_forms_custom_color_palettes' );
48
49 $color_palettes = array();
50
51 $color_palettes[] = array(
52 'label' => $label,
53 'colors' => $colors,
54 'is_pro' => true,
55 'is_custom' => true,
56 );
57
58 update_option( 'everest_forms_custom_color_palettes', $color_palettes );
59
60 wp_send_json_success( esc_html__( 'Color palette saved successfully!', 'everest-forms' ) );
61
62 }
63
64
65
66 /**
67 * Save styles as a template.
68 *
69 * @retEVFn void
70 */
71 public function save_template() {
72 $nonce = isset( $_POST['_nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['_nonce'] ) ) : '';
73
74 if ( ! wp_verify_nonce( $nonce, 'save_template' ) ) {
75 wp_send_json_error(
76 array(
77 'message' => __( 'Nonce error. Please refresh the page.', 'everest-forms' ),
78 )
79 );
80 exit;
81 }
82
83 $form_id = isset( $_POST['form_id'] ) ? sanitize_text_field( wp_unslash( $_POST['form_id'] ) ) : '0';
84
85 if ( ! empty( $form_id ) ) {
86 $template_name = isset( $_POST['name'] ) ? sanitize_text_field( wp_unslash( $_POST['name'] ) ) : '';
87
88 if ( empty( $template_name ) ) {
89 $template_name = strval( time() );
90 }
91
92 $template_slug = str_replace( ' ', '-', strtolower( $template_name ) );
93 $templates = json_decode( get_option( 'evf_style_templates' ) );
94 $styles = get_option( 'everest_forms_styles' );
95
96 if ( isset( $templates->$template_slug ) ) {
97 wp_send_json_error(
98 array(
99 'message' => __( 'Template name exists. Please change the template name and try again.', 'everest-forms' ),
100 )
101 );
102 exit;
103 }
104
105 $template = new stdClass();
106 $template->name = $template_name;
107 $template->image = plugins_url( 'addons/StyleCustomizer/assets/images/templates/default.png', EVF_PLUGIN_FILE );
108 $template->data = isset( $styles[ $form_id ] ) ? $styles[ $form_id ] : '';
109
110 if ( ! empty( $template->data ) ) {
111 unset( $template->data['template'] );
112 }
113
114 $templates->$template_slug = $template;
115
116 update_option( 'evf_style_templates', wp_json_encode( $templates ) );
117
118 wp_send_json_success(
119 array(
120 'template_id' => $template_slug,
121 'message' => __( 'Template saved successfully. Please reload the page to view changes. Reload Now?', 'everest-forms' ),
122 )
123 );
124 exit;
125 }
126 }
127
128
129 /**
130 * Delete template.
131 *
132 * @retEVFn void
133 */
134 public function delete_template() {
135 $nonce = isset( $_POST['_nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['_nonce'] ) ) : '';
136
137 if ( ! wp_verify_nonce( $nonce, 'delete_template' ) ) {
138 wp_send_json_error( __( 'Nonce error. Please refresh the page.', 'everest-forms' ) );
139 exit;
140 }
141
142 $template_slug = isset( $_POST['name'] ) ? sanitize_text_field( wp_unslash( $_POST['name'] ) ) : '';
143 $templates = json_decode( get_option( 'evf_style_templates' ) );
144
145 if ( isset( $templates->$template_slug ) ) {
146 unset( $templates->$template_slug );
147 }
148
149 update_option( 'evf_style_templates', wp_json_encode( $templates ) );
150 wp_send_json_success( __( 'Template deleted successfully.', 'everest-forms' ) );
151 exit;
152 }
153 }
154
155 new EVF_Style_Customizer_Ajax();
156