PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 2.8.16
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v2.8.16
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 / admin / modules / funnels / class-wpfnl-funnels.php

class-wpfnl-funnels.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 2.8.16, at admin/modules/funnels/class-wpfnl-funnels.php

203 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Module
4 *
5 * @package
6 */
7 namespace WPFunnels\Modules\Admin\Funnels;
8
9 use WPFunnels\Admin\Module\Wpfnl_Admin_Module;
10 use WPFunnels\Data_Store\Wpfnl_Funnel_Store_Data;
11 use WPFunnels\Traits\SingletonTrait;
12
13 class Module extends Wpfnl_Admin_Module
14 {
15 use SingletonTrait;
16
17
18 /**
19 * List of published funnels
20 *
21 * @var
22 * @since 1.0.0
23 */
24 protected $funnels;
25
26
27 /**
28 * Ff needs to show pagination
29 *
30 * @var bool
31 * @since 1.0.0
32 */
33 protected $pagination = false;
34
35
36 /**
37 * Total number of funnels
38 *
39 * @var
40 * @since 1.0.0
41 */
42 protected $total_funnels;
43
44
45 /**
46 * Total number of pages
47 *
48 * @var
49 * @since 1.0.0
50 */
51 protected $total_page = 1;
52
53
54 /**
55 * Current page number
56 *
57 * @var
58 * @since 1.0.0
59 */
60 protected $current_page = 1;
61
62
63 /**
64 * Offset
65 *
66 * @var int
67 * @since 1.0.0
68 */
69 protected $offset = 1;
70
71 protected $utm_settings;
72
73
74 /**
75 * Get view of the funnel list
76 *
77 * @since 1.0.0
78 */
79 public function get_view()
80 {
81 $this->current_page = isset( $_GET[ 'pageno' ] ) ? sanitize_text_field( $_GET[ 'pageno' ] ) : 1;
82 $per_page = isset( $_GET[ 'per_page' ] ) ? sanitize_text_field( $_GET[ 'per_page' ] ) : WPFNL_FUNNEL_PER_PAGE;
83 $this->offset = ( $this->current_page - 1 ) * $per_page;
84
85 $this->init_all_funnels( $per_page, $this->offset );
86 require_once WPFNL_DIR . '/admin/modules/funnels/views/view.php';
87 }
88
89
90 /**
91 * Get arguments for funnel
92 * query
93 *
94 * @return array
95 * @since 1.0.0
96 */
97 public function get_args( $per_page = WPFNL_FUNNEL_PER_PAGE )
98 {
99 $args = [
100 'post_type' => WPFNL_FUNNELS_POST_TYPE,
101 'posts_per_page' => $per_page,
102 'offset' => $this->offset,
103 'post_status' => array('publish', 'draft'),
104 ];
105 if (isset($_GET['s'])) {
106 $args['s'] = sanitize_text_field($_GET['s']);
107
108 }
109 return $args;
110 }
111
112
113 /**
114 * Get all funnel list
115 *
116 * @param int $limit
117 * @param int $offset
118 *
119 * @since 1.0.0
120 */
121 public function init_all_funnels($limit = 10, $offset = 0)
122 {
123 $args = [
124 'post_type' => WPFNL_FUNNELS_POST_TYPE,
125 'posts_per_page' => -1,
126 'post_status' => array('publish', 'draft'),
127 'suppress_filters' => true,
128 'fields' => 'ids'
129 ];
130 if (isset($_GET['s'])) {
131 $args['s'] = sanitize_text_field($_GET['s']);
132 }
133 $all_funnels = get_posts($args);
134 $funnels = get_posts($this->get_args( $limit ));
135 $this->funnels = $this->get_formatted_funnel_array($funnels);
136
137 $this->total_funnels = count( $all_funnels );
138 $this->pagination = (bool)count( $this->funnels );
139 if (count($this->funnels)) {
140 $this->total_page = ceil($this->total_funnels / $limit);
141 }
142 $this->utm_settings = $this->get_utm_settings();
143 }
144
145
146 /**
147 * Get all funnel list
148 *
149 * @return array
150 * @since 1.0.0
151 */
152 public function get_formatted_funnel_array($funnels)
153 {
154 $_funnels = [];
155 if ($funnels) {
156 foreach ($funnels as $funnel) {
157 $_funnel = new Wpfnl_Funnel_Store_Data();
158 $_funnel->read($funnel->ID);
159 $_funnel->set_data($funnel);
160 $_funnels[] = $_funnel;
161 }
162 }
163 return $_funnels;
164 }
165
166
167 /**
168 * Get name
169 *
170 * @return String
171 * @since 2.0.4
172 */
173 public function get_name()
174 {
175 return __('funnels','wpfnl');
176 }
177
178
179 /**
180 * Get GTM Settings
181 *
182 * @return array
183 */
184 public function get_utm_settings() {
185 $default_settings = array(
186 'utm_enable' => 'off',
187 'utm_source' => '',
188 'utm_medium' => '',
189 'utm_campaign' => '',
190 'utm_content' => '',
191 );
192 $utm_settings = get_option('_wpfunnels_utm_params', $default_settings);
193 return wp_parse_args($utm_settings, $default_settings);
194 }
195
196 /**
197 * Init ajax
198 */
199 public function init_ajax(){
200
201 }
202 }
203