PluginProbe
FunnelKit – Funnel Builder for WooCommerce Checkout / trunk
FunnelKit – Funnel Builder for WooCommerce Checkout vtrunk
3.16.0.5 3.16.0.4 3.16.0.3 3.16.0.2 3.16.0 3.16.0.1 3.15.0.9 3.15.0.8 3.0.0.1 3.0.1.1 3.0.2.1 3.1.0.1 3.1.1.1 3.1.2.1 3.10.0.1 3.10.1.1 3.10.2.1 3.11.0.0.1 3.11.0.1.1 3.11.0.2.1 3.11.1.1 3.12.0.0.1 3.12.0.1.1 3.13.0.0.1 3.13.1.0.1 All 219 releases
funnel-builder / admin / includes / class-wffn-header.php

class-wffn-header.php in FunnelKit – Funnel Builder for WooCommerce Checkout trunk, at admin/includes/class-wffn-header.php

518 lines 19.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 } // Exit if accessed directly
6
7 if ( ! class_exists( 'WFFN_Header' ) ) {
8 #[AllowDynamicProperties]
9 final class WFFN_Header {
10
11 public $data = array();
12
13 /**
14 * Constructor.
15 *
16 * @since 1.0.0
17 */
18 public function __construct() {
19
20 $this->data['back_link'] = '';
21 $this->data['back_link_label'] = __( 'Funnels', 'funnel-builder' );
22 $this->data['level_1_navigation_active'] = '';
23 $this->data['level_2_title'] = '';
24 $this->data['level_2_post_title'] = '';
25 $this->data['level_2_right_wrap_type'] = 'menu';
26 $this->data['level_2_right_side_navigation'] = array();
27 $this->data['level_2_navigation_pos'] = 'left';
28 $this->data['level_2_right_side_navigation_active'] = '';
29 $this->data['page_back_link'] = '';
30 $this->data['page_heading'] = '';
31 $this->data['page_heading_meta'] = '';
32 }
33
34 public function set_back_link( $enable = 0, $link = '' ) {
35 if ( 0 === $enable || empty( $link ) ) {
36 return;
37 }
38 $this->data['back_link'] = $link;
39 }
40
41 public function set_level_1_navigation_active( $active = '' ) {
42 if ( empty( $active ) ) {
43 return;
44 }
45 if ( 'funnels' === $active && isset( $_GET['funnel_id'] ) && absint( $_GET['funnel_id'] ) === WFFN_Common::get_store_checkout_id() ) {// phpcs:ignore
46 $active = 'store-checkout';
47 }
48 $this->data['level_1_navigation_active'] = $active;
49 }
50
51 public static function left_navigation() {
52 $header_menu = array(
53 'dashboard' => array(
54 'name' => __( 'Dashboard', 'funnel-builder' ),
55 'link' => admin_url( 'admin.php?page=bwf' ),
56 ),
57 'funnels' => array(
58 'name' => __( 'Funnels', 'funnel-builder' ),
59 'link' => admin_url( 'admin.php?page=bwf&path=/funnels' ),
60 ),
61 'store-checkout' => array(
62 'name' => __( 'Store Checkout', 'funnel-builder' ),
63 'link' => admin_url( 'admin.php?page=bwf&path=/store-checkout' ),
64 ),
65 'analytics' => array(
66 'name' => __( 'Analytics', 'funnel-builder' ),
67 'link' => admin_url( 'admin.php?page=bwf&path=/analytics' ),
68 ),
69 'templates' => array(
70 'name' => __( 'Templates', 'funnel-builder' ),
71 'link' => admin_url( 'admin.php?page=bwf&path=/templates' ),
72 ),
73 );
74
75 if ( 'activated' !== WFFN_Common::get_plugin_status( 'cart-for-woocommerce/plugin.php' ) ) {
76 $header_menu['cart'] = array(
77 'name' => __( 'Cart', 'funnel-builder' ),
78 'link' => admin_url( 'admin.php?page=bwf&path=/cart' ),
79 );
80 }
81
82 if ( ! WFFN_Common::skip_automation_page() ) {
83 $header_menu['automations'] = array(
84 'name' => __( 'Automations', 'funnel-builder' ),
85 'link' => admin_url( 'admin.php?page=bwf&path=/automations' ),
86 );
87 }
88
89 if ( ! WFFN_Common::skip_subscriptions_page() && 'activated' !== WFFN_Common::get_plugin_status( 'sublium-subscriptions-for-woocommerce/sublium-subscriptions-for-woocommerce.php' ) ) {
90 $header_menu['subscriptions'] = array(
91 'name' => __( 'Subscriptions', 'funnel-builder' ),
92 'link' => admin_url( 'admin.php?page=bwf&path=/subscriptions' ),
93 );
94 }
95
96 return apply_filters( 'wffn_header_menu', $header_menu );
97 }
98
99 private static function prepare_web_url( $link ) {
100 return add_query_arg(
101 array(
102 'utm_source' => 'website',
103 'utm_medium' => 'text',
104 'utm_campaign' => 'header',
105 ),
106 $link
107 );
108 }
109
110 public static function right_navigation() {
111
112 return array(
113 'menu_react' => array(
114 'settings' => array(
115 'name' => __( 'Settings', 'funnel-builder' ),
116 'icon' => 'settings',
117 'link' => admin_url( 'admin.php?page=bwf&path=/settings' ),
118 'desc' => '',
119 'target' => '_blank',
120 ),
121 'setup' => array(
122 'name' => __( 'Setup & Help', 'funnel-builder' ),
123 'icon' => 'help-circle',
124 'link' => admin_url( 'admin.php?page=bwf&path=/setup' ),
125 'desc' => '',
126 'position' => 'bottom left',
127 'target' => '_blank',
128 ),
129 ),
130 'menu' => array(
131 'settings' => array(
132 'name' => __( 'Settings', 'funnel-builder' ),
133 'icon' => 'settings',
134 'link' => admin_url( 'admin.php?page=bwf&path=/settings' ),
135 'desc' => '',
136 'target' => '_blank',
137 ),
138 'setup_help' => array(
139 'support' => array(
140 'name' => __( 'Get Help', 'funnel-builder' ),
141 'desc' => __( 'Contact support team', 'funnel-builder' ),
142 'icon' => 'support',
143 'link' => self::prepare_web_url( 'https://funnelkit.com/support/?utm_source=WordPress&utm_medium=Admin+Menu+Support&utm_campaign=FB+Lite+Plugin' ),
144 'target' => '_blank',
145 ),
146 'help' => array(
147 'name' => __( 'Read Docs', 'funnel-builder' ),
148 'desc' => __( 'Get help along the way', 'funnel-builder' ),
149 'icon' => 'help',
150 'link' => self::prepare_web_url( 'https://funnelkit.com/documentation/?utm_source=WordPress&utm_medium=Admin+Menu+Doc&utm_campaign=FB+Lite+Plugin' ),
151 'target' => '_blank',
152 ),
153 ),
154 ),
155 );
156 }
157
158 /**
159 * For React Menu Render
160 */
161 public function get_render_data() {
162 return array(
163 'logo' => esc_url( plugin_dir_url( WooFunnel_Loader::$ultimate_path ) . 'woofunnels/assets/img/menu/funnelkit-logo.svg' ),
164 'logo_link' => admin_url( 'admin.php?page=bwf' ),
165 'left_nav' => self::left_navigation(),
166 'right_nav' => self::right_navigation(),
167 'data' => $this->data,
168 'pluginDir' => WFFN_PLUGIN_FILE,
169 );
170 }
171
172
173 public function render() {
174 ob_start();
175 ?>
176 <style>
177 div#wpcontent {
178 padding: 0;
179 overflow-x: hidden !important;
180 min-height: calc(100vh - 32px);
181 }
182 </style>
183 <div class="bwfan_header">
184 <div class="bwfan_header_l1">
185 <div class="bwfan_header_l">
186 <div>
187 <a class="bwf-breadcrumb-svg-icon" href="<?php echo esc_url( admin_url( 'admin.php?page=bwf' ) ); ?>">
188 <img src="<?php echo esc_url( plugin_dir_url( WooFunnel_Loader::$ultimate_path ) . 'woofunnels/assets/img/menu/funnelkit-logo.svg' ); ?>" alt="Funnel Builder"/>
189 </a>
190 </div>
191 <div class="bwfan_navigation">
192 <?php
193 $navigation = self::left_navigation();
194 $this->output_navigation( $navigation, $this->data['level_1_navigation_active'] );
195 ?>
196 </div>
197 </div>
198 <div class="bwfan_header_r">
199 <?php
200 $navigation = self::right_navigation();
201 ?>
202 <?php $this->outputSettingsMenu( $navigation['menu'] ); ?>
203 <div class="bwfan_navigation bwf-header-ellipses-wrap">
204 <?php
205 $this->outputEllipsisMenu( $navigation['menu']['setup_help'] );
206 ?>
207 </div>
208 </div>
209 </div>
210 <?php if ( ! empty( $this->data['page_back_link'] ) ) : ?>
211 <div class="bwfan_header_backlink">
212 <a href="<?php echo esc_url( $this->data['page_back_link'] ); ?>" class="bwf-a-no-underline bwfan_backlink">
213 <svg fill="none" xmlns="http://www.w3.org/2000/svg" width="20" height="14" viewBox="0 0 20 14">
214 <path d="M19.3771 6.22958H2.04183L7.22782 1.06353C7.4714 0.819954 7.4714 0.425641 7.22782 0.182684C6.98424 -0.0608946 6.58993 -0.0608946 6.34697 0.182684L0.179888 6.3492C-0.0599626 6.58905 -0.0599626 6.99019 0.179888 7.23005L6.34702 13.3972C6.5906 13.6408 6.98491 13.6408 7.22787 13.3972C7.47145 13.1536 7.47145 12.7593 7.22787 12.5163L2.04183 7.47544H19.3771C19.721 7.47544 20 7.19634 20 6.85251C20 6.50868 19.721 6.22958 19.3771 6.22958Z" fill="#353030"></path>
215 </svg>
216 <?php esc_html_e( 'Back', 'funnel-builder' ); ?>
217 </a>
218 </div>
219 <?php endif ?>
220 <div class="bwfan_page_header">
221 <?php
222 if ( ! empty( $this->data['page_heading'] ) ) {
223 ?>
224 <span class="bwfan_page_title" data-prefix="<?php echo esc_attr( 'Edit ' ); ?>"><?php echo esc_html( $this->data['page_heading'] ); ?></span>
225 <?php
226 } else {
227 esc_html_e( 'Funnels', 'funnel-builder' );
228 }
229 if ( isset( $_GET['bwf_exp_ref'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
230 $experiment = new BWFABT_Experiment( wffn_clean( wp_unslash( $_GET['bwf_exp_ref'] ) ) ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended
231 $get_control_id = $experiment->get_control();
232
233 $is_control = ( intval( $get_control_id ) === intval( $this->edit_id() ) ) ? 'clr-green' : 'clr-sky-blue';
234
235 ?>
236 <span>
237 <span class="bwfan-tag-rounded bwfan_ml_12 <?php echo esc_attr( $is_control ); ?>"><?php echo esc_html( ( 'clr-green' === $is_control ) ? __( 'Original', 'funnel-builder' ) : __( 'Variant', 'funnel-builder' ) ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended ?></span>
238 </span>
239 <?php
240 }
241 if ( ! empty( $this->data['page_heading_meta'] ) ) {
242
243 echo $this->data['page_heading_meta']; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
244 }
245 ?>
246 </div>
247 <div class="bwfan_header_l2">
248 <div class="bwfan_header_l">
249 <?php
250
251 if ( ! empty( $this->data['back_link'] ) ) {
252 echo '<span class="bwfan_header_l2_back"><a href="' . esc_url( $this->data['back_link'] ) . '">' . $this->data['back_link_label'] . '</a></span>';//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
253 }
254 echo '<span class="bwfan_header_l2_wrap">';
255 if ( ! empty( $this->data['level_2_title'] ) ) {
256 echo '<span id="bwfan_automation_name">' . $this->data['level_2_title'] . '</span>';//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
257 }
258 if ( ! empty( $this->data['level_2_post_title'] ) ) {
259 echo $this->data['level_2_post_title'];//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
260 }
261 echo '</span>';
262 if ( ( 'menu' === $this->data['level_2_right_wrap_type'] || 'both' === $this->data['level_2_right_wrap_type'] ) && 'right' !== $this->data['level_2_navigation_pos'] ) {
263 $navigation = $this->data['level_2_right_side_navigation'];
264 $active = $this->data['level_2_right_side_navigation_active'];
265
266 echo '<div class="bwfan_navigation">';
267 $this->output_navigation( $navigation, $active );
268 echo '</div>';
269 }
270 ?>
271 </div>
272 <div class="bwfan_header_r">
273 <?php
274 if ( 'right' === $this->data['level_2_navigation_pos'] ) {
275
276 $navigation = $this->data['level_2_right_side_navigation'];
277 $active = $this->data['level_2_right_side_navigation_active'];
278
279 echo '<div class="bwfan_navigation">';
280 $this->output_navigation( $navigation, $active );
281 echo '</div>';
282 }
283 if ( ( 'html' === $this->data['level_2_right_wrap_type'] || 'both' === $this->data['level_2_right_wrap_type'] ) && ! empty( $this->data['level_2_right_html'] ) ) {
284 echo $this->data['level_2_right_html'];//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
285 }
286 ?>
287 </div>
288 </div>
289 <hr class="wp-header-end"/>
290 </div>
291 <?php
292 return ob_get_clean();
293 }
294
295 public function edit_id() {
296 $step_id = 0;
297 /**
298 * Register nodes for experiments
299 */
300 if ( 0 < filter_input( INPUT_GET, 'edit', FILTER_UNSAFE_RAW ) ) {// phpcs:ignore
301 $step_id = filter_input( INPUT_GET, 'edit', FILTER_UNSAFE_RAW );// phpcs:ignore
302 } elseif ( 0 < filter_input( INPUT_GET, 'wfacp_id', FILTER_UNSAFE_RAW ) ) {// phpcs:ignore
303 $step_id = filter_input( INPUT_GET, 'wfacp_id', FILTER_UNSAFE_RAW );// phpcs:ignore
304 } elseif ( 0 < filter_input( INPUT_GET, 'wfob_id', FILTER_UNSAFE_RAW ) ) {// phpcs:ignore
305 $step_id = filter_input( INPUT_GET, 'wfob_id', FILTER_UNSAFE_RAW );// phpcs:ignore
306 }
307
308 return $step_id;
309 }
310
311 public function output_navigation( $navigation, $active_slug = '' ) {
312
313 if ( 'string' === gettype( $navigation ) ) {
314 echo $navigation;//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
315
316 return;
317 }
318
319 if ( ! is_array( $navigation ) || 0 === count( $navigation ) ) {
320 return;
321 }
322 foreach ( $navigation as $key => $item ) {
323 $active = ( ! empty( $active_slug ) && $key === $active_slug ) ? 'bwfan_navigation_active' : '';
324
325 $menu_title = isset( $item['name'] ) ? $item['name'] : $item['title'];
326
327 $icon = '';
328
329 $target = ( isset( $item['target'] ) && ! empty( $item['target'] ) ) ? ' target="' . $item['target'] . '"' : '';
330
331 echo '<span><a href="' . esc_url( $item['link'] ) . '" class="' . esc_attr( $active ) . '"' . $target . '>' . $icon . $menu_title . '</a></span>';//phpcs:ignore
332 }
333 $active = null;
334 }
335
336 public function outputSettingsMenu( $navigation ) {
337 if ( ! is_array( $navigation ) || 0 === count( $navigation ) ) {
338 return;
339 }
340 ?>
341 <div class="bwfan_navigation bwf-header-ellipses-wrap nav-right">
342
343 <a href="<?php echo esc_url( admin_url( 'admin.php?page=bwf&path=/settings' ) ); ?>" type="button" title="Quick Actions" aria-expanded="false" class="components-button bwf-ellipsis-menu__toggle has-text has-icon">
344 <?php echo file_get_contents( plugin_dir_path( WFFN_PLUGIN_FILE ) . 'admin/assets/img/menu/settings.svg' )// phpcs:ignore ?>
345 </a>
346 </div>
347 <?php
348 }
349
350
351 public function outputEllipsisMenu( $navigation ) {
352 if ( ! is_array( $navigation ) || 0 === count( $navigation ) ) {
353 return;
354 }
355 ?>
356 <div class="bwf-ellipsis-menu bwf-ellipsis--alter-alter">
357 <div class="components-dropdown">
358 <button type="button" title="Quick Actions" aria-expanded="false" class="components-button bwf-ellipsis-menu__toggle has-text has-icon">
359 <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
360 <path d="M12 17.7617C12.5393 17.7617 12.9766 17.3245 12.9766 16.7852C12.9766 16.2458 12.5393 15.8086 12 15.8086C11.4607 15.8086 11.0234 16.2458 11.0234 16.7852C11.0234 17.3245 11.4607 17.7617 12 17.7617Z" fill="#353030"></path>
361 <path d="M12 2C6.47328 2 2 6.47254 2 12C2 17.5267 6.47254 22 12 22C17.5267 22 22 17.5275 22 12C22 6.47328 17.5275 2 12 2ZM12 20.4375C7.33684 20.4375 3.5625 16.6638 3.5625 12C3.5625 7.33684 7.33621 3.5625 12 3.5625C16.6632 3.5625 20.4375 7.33621 20.4375 12C20.4375 16.6632 16.6638 20.4375 12 20.4375Z" fill="#353030"></path>
362 <path d="M12 7.01953C10.2769 7.01953 8.875 8.42141 8.875 10.1445C8.875 10.576 9.22477 10.9258 9.65625 10.9258C10.0877 10.9258 10.4375 10.576 10.4375 10.1445C10.4375 9.28297 11.1384 8.58203 12 8.58203C12.8616 8.58203 13.5625 9.28297 13.5625 10.1445C13.5625 11.0061 12.8616 11.707 12 11.707C11.5685 11.707 11.2188 12.0568 11.2188 12.4883V14.4414C11.2188 14.8729 11.5685 15.2227 12 15.2227C12.4315 15.2227 12.7812 14.8729 12.7812 14.4414V13.1707C14.1276 12.8229 15.125 11.598 15.125 10.1445C15.125 8.42141 13.7231 7.01953 12 7.01953Z" fill="#353030"></path>
363 </svg>
364 </button>
365 <div tabindex="-1">
366 <div class="components-popover components-dropdown__content bwf-ellipsis-menu__popover components-animate__appear is-from-top is-from-right is-without-arrow" data-x-axis="left" data-y-axis="bottom">
367 <div class="components-popover__content" tabindex="-1">
368 <div style="position: relative;">
369 <div role="menu" aria-orientation="vertical" class="bwf-ellipsis-menu__content">
370 <?php
371 foreach ( $navigation as $item ) {
372 ?>
373 <a href="<?php echo esc_url( $item['link'] ); ?>" target="<?php echo esc_attr( $item['target'] ); ?>" role="menuitem" tabindex="0" class="bwf-ellipsis-menu__item">
374 <div class="components-flex css-1ahbsz-Flex eboqfv50">
375 <div class="components-flex__item css-1s295sp-Item eboqfv51">
376 <?php
377 $icon = ( isset( $item['icon'] ) && ! empty( $item['icon'] ) ) ? file_get_contents( plugin_dir_path( WFFN_PLUGIN_FILE ) . 'admin/assets/img/menu/' . $item['icon'] . '.svg' ) : '';
378 echo $icon;//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
379 ?>
380 </div>
381 <div class="components-flex__block css-yr442k-Item-Block eboqfv52">
382 <div class="bwf_display_block">
383 <div class="menu-item-title"><?php echo esc_html( $item['name'] ); ?></div>
384 <div class="menu-item-desc"><?php echo esc_html( $item['desc'] ); ?></div>
385 </div>
386 </div>
387 </div>
388 </a>
389 <?php
390 }
391 ?>
392 </div>
393 </div>
394 </div>
395 </div>
396 </div>
397 </div>
398 </div>
399 <?php
400 }
401
402 public function set_level_2_title( $title = '' ) {
403 if ( empty( $title ) ) {
404 return;
405 }
406 $this->data['level_2_title'] = $title;
407 }
408
409 public function set_level_2_post_title( $html = '' ) {
410 if ( empty( $html ) ) {
411 return;
412 }
413 $this->data['level_2_post_title'] = $html;
414 }
415
416 public function set_level_2_side_type( $type = 'menu' ) {
417 if ( empty( $type ) ) {
418 return;
419 }
420 $this->data['level_2_right_wrap_type'] = $type;
421 }
422
423 public function set_level_2_side_navigation( $navigation = array() ) {
424 if ( empty( $navigation ) ) {
425 return;
426 }
427 $this->data['level_2_right_side_navigation'] = $navigation;
428 }
429
430 public function set_level_2_navigation_pos( $positions = 'left' ) {
431 if ( empty( $positions ) ) {
432 return;
433 }
434 $this->data['level_2_navigation_pos'] = $positions;
435 }
436
437 public function set_level_2_side_navigation_active( $active = '' ) {
438 if ( empty( $active ) ) {
439 return;
440 }
441 $this->data['level_2_right_side_navigation_active'] = $active;
442 }
443
444 public function set_level_2_right_html( $html = '' ) {
445 if ( empty( $html ) ) {
446 return;
447 }
448 $this->data['level_2_right_html'] = $html;
449 }
450
451 public function set_page_heading( $mixstring = '' ) {
452 if ( empty( $mixstring ) ) {
453 return;
454 }
455 $this->data['page_heading'] = $mixstring;
456 }
457
458 public function set_page_heading_meta( $html = '' ) {
459 if ( empty( $html ) ) {
460 return;
461 }
462 $this->data['page_heading_meta'] = $html;
463 }
464
465 public function set_page_back_link( $url = '' ) {
466 if ( empty( $url ) ) {
467 return;
468 }
469 $this->data['page_back_link'] = $url;
470 }
471
472
473 public static function level_2_navigation_single_funnel( $funnel_id ) {
474 return array(
475 'steps' => array(
476 'name' => __( 'Steps', 'funnel-builder' ),
477 'link' => admin_url( "admin.php?page=bwf&path=/funnels/$funnel_id/funnel" ),
478 ),
479 'contacts' => array(
480 'name' => __( 'Contacts', 'funnel-builder' ),
481 'link' => admin_url( "admin.php?page=bwf&path=/funnels/$funnel_id/contacts" ),
482 ),
483 'analytics' => array(
484 'name' => __( 'Analytics', 'funnel-builder' ),
485 'link' => admin_url( "admin.php?page=bwf&path=/funnels/$funnel_id/analytics" ),
486 'isProFeature' => true,
487 'showOnClick' => true,
488 ),
489 'settings' => array(
490 'name' => __( 'Settings', 'funnel-builder' ),
491 'link' => admin_url( "admin.php?page=bwf&path=/funnels/$funnel_id/settings" ),
492 ),
493 );
494 }
495
496 public static function level_2_navigation_licenses() {
497 return array(
498 'licenses' => array(
499 'name' => __( 'Licenses', 'funnel-builder' ),
500 'link' => admin_url( 'admin.php?page=woofunnels&tab=licenses' ),
501 ),
502 'support' => array(
503 'name' => __( 'Support', 'funnel-builder' ),
504 'link' => admin_url( 'admin.php?page=woofunnels&tab=support' ),
505 ),
506 'tools' => array(
507 'name' => __( 'Tools', 'funnel-builder' ),
508 'link' => admin_url( 'admin.php?page=woofunnels&tab=tools' ),
509 ),
510 'logs' => array(
511 'name' => __( 'Logs', 'funnel-builder' ),
512 'link' => admin_url( 'admin.php?page=woofunnels&tab=logs' ),
513 ),
514 );
515 }
516 }
517 }
518