PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 2.7.0
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v2.7.0
2.7.0 2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 All 43 releases
← All changes | includes/funnel/steps.php +21 -7 1.5.82.7.0 View file →
@@ -52,8 +52,9 @@
52 52 /**
53 53 * Initialize steps.
54 54 *
55 55 * @since 1.1.0
56 + * @SuppressWarnings(PHPMD.NPathComplexity)
56 57 */
57 58 public function init() {
58 59 if ( empty( $this->funnel->current_step_data ) ) {
59 60 return;
@@ -65,8 +66,13 @@
65 66 if ( is_user_logged_in() && current_user_can( 'administrator' ) ) {
66 67 return;
67 68 }
68 69
70 + if ( ! empty( $this->funnel->funnel_id ) && 'publish' !== get_post_status( $this->funnel->funnel_id ) ) {
71 + echo esc_html__( 'There is nothing to view here.', 'sellkit' );
72 + die();
73 + }
74 +
69 75 if ( ! empty( $this->funnel->current_step_data['status'] ) && 'publish' === $this->funnel->current_step_data['status'] ) {
70 76 return;
71 77 }
72 78
@@ -151,18 +157,16 @@
151 157 if ( ! session_id() ) {
152 158 session_start();
153 159 }
154 160
155 - if ( array_key_exists( 'sellkit_viewed_funnels', $_SESSION ) && in_array( $this->funnel->funnel_id, $_SESSION['sellkit_viewed_funnels'] ) ) { // phpcs:ignore
161 + $viewed_funnel_ids = isset( $_SESSION['sellkit_viewed_funnels'] ) ? array_map( 'absint', (array) $_SESSION['sellkit_viewed_funnels'] ) : [];
162 +
163 + if ( in_array( absint( $this->funnel->funnel_id ), $viewed_funnel_ids, true ) ) {
156 164 return;
157 165 }
158 166
159 - if ( empty( $_SESSION['sellkit_viewed_funnels'] ) ) {
160 - $_SESSION['sellkit_viewed_funnels'] = [];
161 - }
167 + $_SESSION['sellkit_viewed_funnels'] = array_merge( $viewed_funnel_ids, [ absint( $this->funnel->funnel_id ) ] );
162 168
163 - $_SESSION['sellkit_viewed_funnels'] = array_merge( $_SESSION['sellkit_viewed_funnels'], [ $this->funnel->funnel_id ] );
164 -
165 169 add_action( 'init', function () {
166 170 $this->analytics_updater->add_new_visit( true );
167 171 } );
168 172 }
@@ -176,11 +180,21 @@
176 180 public function add_start_and_finish_logs() {
177 181 $funnel = sellkit_funnel();
178 182 $analytics_updater = new Data_Updater();
179 183
184 + if ( empty( $funnel->funnel_id ) && ! empty( Funnel_Homepage::$first_step ) ) {
185 + $funnel = new Sellkit_Funnel( Funnel_Homepage::$first_step );
186 + }
187 +
180 188 $analytics_updater->set_funnel_id( $funnel->funnel_id );
189 + $first_key = 0;
181 190
182 - if ( isset( $funnel->current_step_data['number'] ) && 0 === $funnel->current_step_data['number'] ) {
191 + if ( isset( $funnel->funnel_id ) ) {
192 + $nodes = get_post_meta( $funnel->funnel_id, 'nodes', true );
193 + $first_key = array_key_first( $nodes );
194 + }
195 +
196 + if ( isset( $funnel->current_step_data['number'] ) && $first_key === $funnel->current_step_data['number'] ) {
183 197 $analytics_updater->add_new_start_log();
184 198 }
185 199
186 200 if ( empty( $funnel->next_step_data ) ) {