PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 3.5.2
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v3.5.2
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 / includes / admin / settings / class-evf-setting-utilities.php
everest-forms / includes / admin / settings Last commit date
class-evf-setting-utilities.php 3 months ago class-evf-settings-advanced.php 4 weeks ago class-evf-settings-email.php 4 weeks ago class-evf-settings-general.php 3 months ago class-evf-settings-integrations.php 3 months ago class-evf-settings-page.php 3 months ago class-evf-settings-payments.php 4 weeks ago class-evf-settings-reporting.php 2 years ago class-evf-settings-security.php 3 months ago class-evf-settings-validation.php 11 months ago
class-evf-setting-utilities.php
328 lines
1 <?php
2 /**
3 * EverestForms Utilities Settings
4 *
5 * @package EverestForms\Admin
6 * @version 1.0.0
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 if ( class_exists( 'EVF_Settings_Utilities', false ) ) {
12 return new EVF_Settings_Utilities();
13 }
14
15 /**
16 * EVF_Settings_Utilities.
17 */
18 class EVF_Settings_Utilities extends EVF_Settings_Page {
19
20 /**
21 * Constructor.
22 */
23 public function __construct() {
24 $this->id = 'utilities';
25 $this->label = __( 'Utilities', 'everest-forms' );
26
27 parent::__construct();
28
29 add_action( 'everest_forms_sections_' . $this->id, array( $this, 'output_sections' ) );
30 }
31
32 /**
33 * Get the current active section key.
34 *
35 * @return string
36 */
37 private function get_current_section() {
38 $sections = $this->get_sections();
39 $default = ! empty( $sections ) ? array_key_first( $sections ) : '';
40
41 return isset( $_GET['section'] ) // phpcs:ignore WordPress.Security.NonceVerification
42 ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) // phpcs:ignore WordPress.Security.NonceVerification
43 : $default;
44 }
45
46 /**
47 * Get sections.
48 *
49 * @return array
50 */
51 public function get_sections() {
52 $sections = apply_filters( 'everest_forms_utilities_sections', array() );
53
54 $upsells = EVF_Addon_Upsell::get_upsells_for_category( 'utilities' );
55 foreach ( $upsells as $id => $upsell ) {
56 if ( ! isset( $sections[ $id ] ) ) {
57 $sections[ $id ] = $upsell;
58 }
59 }
60
61 return apply_filters( 'everest_forms_get_sections_' . $this->id, $sections );
62 }
63
64 /**
65 * Returns true if at least one real (non-upsell) section exists.
66 *
67 * @return bool
68 */
69 public function has_real_sections() {
70 if ( ! defined( 'EFP_PLUGIN_FILE' ) ) {
71 return true;
72 }
73
74 foreach ( $this->get_sections() as $section ) {
75 if ( ! $this->is_upsell_section( $section ) ) {
76 return true;
77 }
78 }
79 return false;
80 }
81
82 /**
83 * Returns the label string for a section regardless of format.
84 *
85 * @param mixed $section String label or config array.
86 * @return string
87 */
88 private function get_section_label( $section ) {
89 return is_array( $section ) ? ( $section['label'] ?? '' ) : (string) $section;
90 }
91
92 /**
93 * Returns true when a section is an upsell placeholder.
94 *
95 * @param mixed $section String label or config array.
96 * @return bool
97 */
98 private function is_upsell_section( $section ) {
99 return is_array( $section ) && ! empty( $section['upsell'] );
100 }
101
102 /**
103 * Returns true when a section links to an external page.
104 *
105 * @param mixed $section String label or config array.
106 * @return bool
107 */
108 private function is_external_section( $section ) {
109 return is_array( $section ) && ! empty( $section['url'] );
110 }
111
112 /**
113 * Output sections in navigation sidebar.
114 */
115 public function output_sections() {
116 global $current_section;
117
118 $sections = $this->get_sections();
119 $current_section = $this->get_current_section();
120
121 if ( empty( $sections ) ) {
122 return;
123 }
124
125 $lock_icon = '<svg class="evf-sidebar-upsell-icon" width="14" height="14" viewBox="0 0 20 20"
126 fill="none" xmlns="http://www.w3.org/2000/svg"
127 style="vertical-align:middle;margin-left:5px;flex-shrink:0;" aria-hidden="true">
128 <path d="M0 2C0 0.895431 0.895431 0 2 0H18C19.1046 0 20 0.895431 20 2V18C20 19.1046 19.1046 20 18 20H2C0.895431 20 0 19.1046 0 18V2Z" fill="#FF8C39"/>
129 <path d="M10 4.1666L13.5 13.4999H6.5L10 4.1666Z" fill="#EFEFEF"/>
130 <path d="M14.9994 15.833H4.99939V14.167H14.9994V15.833ZM15.0004 13.5H5.00037L4.16638 6.5L10.0004 11.3125L15.8334 6.5L15.0004 13.5Z" fill="white"/>
131 </svg>';
132
133 echo '<ul class="evf-subsections">';
134
135 foreach ( $sections as $id => $section ) {
136 $label = $this->get_section_label( $section );
137 $is_upsell = $this->is_upsell_section( $section );
138 $is_external = $this->is_external_section( $section );
139
140 if ( $is_external ) {
141 $url = $section['url'];
142 } else {
143 $url = add_query_arg(
144 array(
145 'page' => 'evf-settings',
146 'tab' => $this->id,
147 'section' => sanitize_title( $id ),
148 ),
149 admin_url( 'admin.php' )
150 );
151 }
152
153 printf(
154 '<li><a href="%s" class="%s">%s%s</a></li>',
155 esc_url( $url ),
156 esc_attr( $current_section === $id ? 'current' : '' ),
157 esc_html( $label ),
158 $is_upsell ? $lock_icon : '' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
159 );
160 }
161
162 echo '</ul>';
163 }
164
165 /**
166 * Get settings array for the active section.
167 *
168 * @return array
169 */
170 public function get_settings() {
171 global $current_section;
172
173 $current_section = $this->get_current_section();
174
175 $settings = apply_filters( 'everest_forms_utilities_settings_' . $current_section, array() );
176
177 return apply_filters( 'everest_forms_get_settings_' . $this->id, $settings, $current_section );
178 }
179
180 /**
181 * Render the upsell card for an inactive addon section.
182 *
183 * @param array $section Section config array.
184 */
185 private function render_upsell_card( array $section ) {
186 $title = $section['label'] ?? '';
187 $description = $section['description'] ?? '';
188 $icon = $section['icon'] ?? '';
189 $video_id = $section['vedio_id'] ?? '';
190 $upgrade_url = $section['upgrade_url'] ?? 'https://wpeverest.com/wordpress-plugins/everest-forms/pricing/';
191 $docs_url = $section['docs_url'] ?? 'https://docs.everestforms.net/docs/';
192 $features = $section['features'] ?? array();
193
194 $check_icon = '<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24"
195 fill="none" stroke="currentColor" stroke-width="2.5"
196 stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
197 <polyline points="20 6 9 17 4 12"/>
198 </svg>';
199 ?>
200 <div class="evf-upsell-integration-card">
201 <div class="evf-upsell-card-header">
202 <?php if ( $icon ) : ?>
203 <span class="evf-upsell-icon">
204 <img src="<?php echo esc_url( $icon ); ?>" alt="<?php echo esc_attr( $title ); ?>">
205 </span>
206 <?php endif; ?>
207
208 <div class="evf-upsell-card-heading">
209 <h3><?php echo esc_html( $title ); ?></h3>
210 </div>
211 <span class="evf-upsell-lock-icon">
212 <svg width="14" height="14" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
213 <path d="M0 2C0 0.895431 0.895431 0 2 0H18C19.1046 0 20 0.895431 20 2V18C20 19.1046 19.1046 20 18 20H2C0.895431 20 0 19.1046 0 18V2Z" fill="#FF8C39"/>
214 <path d="M10 4.1666L13.5 13.4999H6.5L10 4.1666Z" fill="#EFEFEF"/>
215 <path d="M14.9994 15.833H4.99939V14.167H14.9994V15.833ZM15.0004 13.5H5.00037L4.16638 6.5L10.0004 11.3125L15.8334 6.5L15.0004 13.5Z" fill="white"/>
216 </svg>
217 </span>
218 </div>
219
220 <?php if ( ! empty( $features ) ) : ?>
221 <hr class="evf-upsell-divider">
222 <ul class="evf-upsell-features">
223 <?php foreach ( $features as $feature ) : ?>
224 <li><?php echo $check_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><?php echo esc_html( $feature ); ?></li>
225 <?php endforeach; ?>
226 </ul>
227 <?php endif; ?>
228
229 <div class="evf-upsell-actions">
230 <a href="<?php echo esc_url( $upgrade_url ); ?>"
231 class="evf-upsell-btn evf-upsell-btn-primary"
232 target="_blank" rel="noopener noreferrer">
233 <?php
234 printf(
235 /* translators: %s: section name */
236 esc_html__( 'Unlock %s — Upgrade to Pro', 'everest-forms' ),
237 esc_html( $title )
238 );
239 ?>
240 <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
241 fill="none" stroke="currentColor" stroke-width="2"
242 stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
243 <line x1="7" y1="17" x2="17" y2="7"/>
244 <polyline points="7 7 17 7 17 17"/>
245 </svg>
246 </a>
247 <?php if ( $video_id ) : ?>
248 <a href="<?php echo esc_url( 'https://www.youtube.com/watch?v=' . $video_id ); ?>"
249 class="evf-upsell-btn evf-upsell-upgrade-trigger"
250 data-name="<?php echo esc_attr( $title ); ?>"
251 data-links="<?php echo esc_attr( $video_id ); ?>"
252 data-upgrade-url="<?php echo esc_url( $upgrade_url ); ?>">
253 <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24"
254 fill="currentColor" aria-hidden="true">
255 <path d="M10 16.5l6-4.5-6-4.5v9zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10
256 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8
257 8-8 8 3.59 8 8-3.59 8-8 8z"/>
258 </svg>
259 <?php esc_html_e( 'Watch Demo', 'everest-forms' ); ?>
260 </a>
261 <?php endif; ?>
262
263 <a href="<?php echo esc_url( $docs_url ); ?>"
264 class="evf-upsell-btn evf-upsell-btn-ghost"
265 target="_blank" rel="noopener noreferrer">
266 <?php esc_html_e( 'View Documentation', 'everest-forms' ); ?>
267 </a>
268 </div>
269 </div>
270 <?php
271 }
272
273 /**
274 * Output the settings.
275 *
276 * Render modes:
277 * 1. Upsell — section config has 'upsell' => true.
278 * 2. Custom — callback hooked on everest_forms_utilities_output_{section}.
279 * 3. Fields — standard EVF settings fields array.
280 */
281 public function output() {
282 global $current_section;
283
284 $current_section = $this->get_current_section();
285 $sections = $this->get_sections();
286 $section_config = $sections[ $current_section ] ?? null;
287
288 if ( $section_config && $this->is_upsell_section( $section_config ) ) {
289 $GLOBALS['hide_save_button'] = true;
290 $this->render_upsell_card( $section_config );
291 return;
292 }
293
294 if ( has_action( 'everest_forms_utilities_output_' . $current_section ) ) {
295 $GLOBALS['hide_save_button'] = true;
296 do_action( 'everest_forms_utilities_output_' . $current_section );
297 return;
298 }
299
300 $settings = $this->get_settings();
301 EVF_Admin_Settings::output_fields( $settings );
302 }
303
304 /**
305 * Save settings.
306 */
307 public function save() {
308 global $current_section;
309
310 $current_section = $this->get_current_section();
311 $sections = $this->get_sections();
312 $section_config = $sections[ $current_section ] ?? null;
313
314 if ( $section_config && $this->is_upsell_section( $section_config ) ) {
315 return;
316 }
317
318 if ( has_action( 'everest_forms_utilities_output_' . $current_section ) ) {
319 return;
320 }
321
322 $settings = $this->get_settings();
323 EVF_Admin_Settings::save_fields( $settings );
324 }
325 }
326
327 return new EVF_Settings_Utilities();
328