PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 2.3.0
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v2.3.0
2.8.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 All 44 releases
← All changes | includes/funnel/class.php +67 -13 1.7.5 → 2.3.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,12 +286,8 @@
230 286 return (int) $post_data['sellkit_current_page_id'];
231 287 }
232 288 }
233 289
234 - if ( ! empty( $preview ) ) {
235 - return false;
236 - }
237 -
238 290 if ( is_numeric( $page_id ) ) {
239 291 return $page_id;
240 292 }
241 293
@@ -244,9 +296,9 @@
244 296 if ( ! empty( $structure ) ) {
245 297 $current_url = self::get_base_url( $current_url );
246 298 }
247 299
248 - if ( empty( strpos( $current_url, 'sellkit_step' ) ) ) {
300 + if ( empty( strpos( $current_url, Funnel_Redirect::$step_base ) ) && ! empty( get_option( 'rewrite_rules' ) ) ) {
249 301 return false;
250 302 }
251 303
252 304 if ( empty( $current_url ) ) {
@@ -346,9 +398,10 @@
346 398 $order_number = $parent_order->get_order_number();
347 399 $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 400 $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 401 $parent_order_html .= '</p>';
350 - echo $parent_order_html;
402 +
403 + echo wp_kses_post( $parent_order_html );
351 404 }
352 405
353 406 if ( is_numeric( $upsell_order_id ) ) {
354 407 $upsell_order = wc_get_order( $upsell_order_id );
@@ -355,9 +408,10 @@
355 408 $order_number = $upsell_order->get_order_number();
356 409 $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 410 $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 411 $upsell_order_html .= '</p>';
359 - echo $upsell_order_html;
412 +
413 + echo wp_kses_post( $upsell_order_html );
360 414 }
361 415 }
362 416
363 417 /**