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/class.php +81 -13 1.7.52.7.0 View file →
@@ -75,9 +75,13 @@
75 75 $page_id = self::get_page_id();
76 76 }
77 77
78 78 if ( empty( $page_id ) ) {
79 - return;
79 + $page_id = $this->get_funnel_step_homepage_id();
80 +
81 + if ( empty( $page_id ) ) {
82 + return;
83 + }
80 84 }
81 85
82 86 $this->set_funnel_data( $page_id );
83 87
@@ -88,8 +92,57 @@
88 92 add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_funnel_frontend_script' ] );
89 93 }
90 94
91 95 /**
96 + * Gets funnel step homepage id.
97 + *
98 + * @since 1.9.6
99 + * @return int|bool
100 + */
101 + private function get_funnel_step_homepage_id() {
102 + if ( is_admin() ) {
103 + return false;
104 + }
105 +
106 + $front_page_id = get_option( 'page_on_front', 0 );
107 +
108 + if ( empty( $front_page_id ) ) {
109 + return false;
110 + }
111 +
112 + $scheme = ( ! empty( $_SERVER['HTTPS'] ) && 'off' !== $_SERVER['HTTPS'] ) ? 'https' : 'http';
113 +
114 + $host = sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ); // phpcs:ignore
115 + $request_uri = esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ); // phpcs:ignore
116 +
117 + $url = esc_url( "$scheme://$host$request_uri" );
118 + $home_url = get_home_url() . '/';
119 +
120 + if ( '/' !== substr( $url, -1 ) ) {
121 + $home_url = get_home_url();
122 + }
123 +
124 + if ( $home_url !== $url ) {
125 + return false;
126 + }
127 +
128 + $post_id = url_to_postid( $url );
129 +
130 + if ( empty( $post_id ) ) {
131 + return false;
132 + }
133 +
134 + $post_type = get_post_type( $post_id );
135 + $status = Funnel_Homepage::check_funnel_step_status( $post_id, $post_type );
136 +
137 + if ( $status && intval( $post_id ) === intval( $front_page_id ) ) {
138 + return $front_page_id;
139 + }
140 +
141 + return false;
142 + }
143 +
144 + /**
92 145 * Class Instance.
93 146 *
94 147 * @since 1.1.0
95 148 * @return Sellkit_Funnel|null
@@ -195,12 +248,16 @@
195 248 * @return array
196 249 */
197 250 public function get_localize_data() {
198 251 if ( ! empty( $this->next_step_data['page_id'] ) ) {
199 - $next_step_link = add_query_arg( [
200 - 'post_type' => Sellkit_Admin_Steps::SELLKIT_STEP_POST_TYPE,
201 - 'p' => $this->next_step_data['page_id'],
202 - ], site_url() );
252 + $next_step_link = ! empty( $this->next_step_data['page_id'] ) ? get_the_permalink( $this->next_step_data['page_id'] ) : '';
253 +
254 + if ( empty( $next_step_link ) ) {
255 + $next_step_link = add_query_arg( [
256 + 'post_type' => Sellkit_Admin_Steps::SELLKIT_STEP_POST_TYPE,
257 + 'p' => $this->next_step_data['page_id'],
258 + ], site_url() );
259 + }
203 260 }
204 261
205 262 return [
206 263 'currentStep' => $this->current_step_data,
@@ -218,9 +275,8 @@
218 275 * @SuppressWarnings(PHPMD.NPathComplexity)
219 276 */
220 277 public static function get_page_id() {
221 278 $page_id = sellkit_htmlspecialchars( INPUT_POST, 'sellkit_current_page_id' );
222 - $preview = sellkit_htmlspecialchars( INPUT_GET, 'preview' );
223 279 $structure = get_option( 'permalink_structure' );
224 280 $post_data = filter_input( INPUT_POST, 'post_data', FILTER_DEFAULT );
225 281
226 282 if ( ! empty( $post_data ) ) {
@@ -230,14 +286,24 @@
230 286 return (int) $post_data['sellkit_current_page_id'];
231 287 }
232 288 }
233 289
234 - if ( ! empty( $preview ) ) {
235 - return false;
290 + if ( is_numeric( $page_id ) ) {
291 + return $page_id;
236 292 }
237 293
238 - if ( is_numeric( $page_id ) ) {
239 - return $page_id;
294 + // Stripe Express Checkout (and similar express flows) POST to wc-ajax=checkout
295 + // without SellKit's hidden fields. Fall back to the checkout step id stored in
296 + // the WC session when the user first landed on the funnel checkout page so we
297 + // can still resolve the funnel context on the server side. The stored value is
298 + // only trusted when recent, to avoid reusing stale ids from older visits.
299 + if ( wp_doing_ajax() && function_exists( 'WC' ) && is_object( WC()->session ) ) {
300 + $session_page_id = (int) WC()->session->get( 'sellkit_current_page_id' );
301 + $session_time = (int) WC()->session->get( 'sellkit_current_page_id_time' );
302 +
303 + if ( $session_page_id > 0 && ( time() - $session_time ) < HOUR_IN_SECONDS ) {
304 + return $session_page_id;
305 + }
240 306 }
241 307
242 308 $current_url = esc_url_raw( remove_query_arg( 'order-key' ) );
243 309
@@ -244,9 +310,9 @@
244 310 if ( ! empty( $structure ) ) {
245 311 $current_url = self::get_base_url( $current_url );
246 312 }
247 313
248 - if ( empty( strpos( $current_url, 'sellkit_step' ) ) ) {
314 + if ( empty( strpos( $current_url, Funnel_Redirect::$step_base ) ) && ! empty( get_option( 'rewrite_rules' ) ) ) {
249 315 return false;
250 316 }
251 317
252 318 if ( empty( $current_url ) ) {
@@ -346,9 +412,10 @@
346 412 $order_number = $parent_order->get_order_number();
347 413 $parent_order_html = sprintf( '<p class="form-field form-field-wide" style= "margin-top: 20px;"><strong>%s: </strong>', esc_html__( 'SellKit Parent Order', 'sellkit' ) );
348 414 $parent_order_html .= sprintf( '<span style= "display: block;"><a href="%1s"><strong>#%2s</strong></a></span>', get_edit_post_link( $main_order_id ), esc_attr( $order_number ) );
349 415 $parent_order_html .= '</p>';
350 - echo $parent_order_html;
416 +
417 + echo wp_kses_post( $parent_order_html );
351 418 }
352 419
353 420 if ( is_numeric( $upsell_order_id ) ) {
354 421 $upsell_order = wc_get_order( $upsell_order_id );
@@ -355,9 +422,10 @@
355 422 $order_number = $upsell_order->get_order_number();
356 423 $upsell_order_html = sprintf( '<p class="form-field form-field-wide" style= "margin-top: 20px;"><strong>%s: </strong>', esc_html__( 'SellKit Upsell Order', 'sellkit' ) );
357 424 $upsell_order_html .= sprintf( '<span style= "display: block;"><a href="%1s"><strong>#%2s</strong></a></span>', get_edit_post_link( $upsell_order_id ), esc_attr( $order_number ) );
358 425 $upsell_order_html .= '</p>';
359 - echo $upsell_order_html;
426 +
427 + echo wp_kses_post( $upsell_order_html );
360 428 }
361 429 }
362 430
363 431 /**