PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.12.2
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.12.2
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / public / classes / class-wpfnl-step-template.php

class-wpfnl-step-template.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.12.2, at public/classes/class-wpfnl-step-template.php

66 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The public-facing template functionality of the plugin.
5 *
6 * @package Wpfnl
7 * @subpackage Wpfnl/public
8 */
9
10
11 /**
12 * The public-facing template functionality of the plugin.
13 *
14 * @link https://rextheme.com
15 * @since 1.0.0
16 *
17 * @package Wpfnl
18 * @subpackage Wpfnl/public
19 */
20
21 class Wpfnl_Step_Template
22 {
23 public function init()
24 {
25 add_filter('template_include', [ $this, 'wpfnl_include_step_template' ]);
26 }
27
28 public function wpfnl_include_step_template($template)
29 {
30 //try and get the query var we registered in our query_vars() function
31 $step_page = get_query_var('funnel_step');
32
33 //if the query var has data, we must be on the right page, load our custom template
34 if ($step_page) {
35 return plugin_dir_path(__FILE__) . 'template/step-view.php';
36 }
37
38 return $template;
39 }
40
41 public function flush_rules()
42 {
43 $this->rewrite_rules();
44
45 flush_rewrite_rules();
46 }
47
48 public function rewrite_rules()
49 {
50 add_rewrite_rule('funnel/(.+?)/?$', 'index.php?funnel_step=$matches[1]', 'top');
51 add_rewrite_tag('%funnel_step%', '([^&]+)');
52 }
53
54 public function get_next_step($order, $current)
55 {
56 $current_key = array_search($current, array_column($order, 'id'));
57 if (isset($order[$current_key + 1])) {
58 $next_key = $order[$current_key + 1];
59 $next_id = $next_key['id'];
60 return $next_id;
61 } else {
62 return false;
63 }
64 }
65 }
66