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/admin/class-steps.php +66 -7 1.5.92.7.0 View file →
@@ -60,8 +60,10 @@
60 60 add_action( 'wp_ajax_sellkit_steps_get_coupons', [ $this, 'get_coupons' ] );
61 61 add_action( 'wp_loaded', [ $this, 'sellkit_steps_flush_rules' ] );
62 62 add_action( 'sellkit_after_toggle_status_sellkit-funnels', [ $this, 'update_steps_post_status' ], 10, 2 );
63 63 add_action( 'sellkit_funnels_after_delete_posts_sellkit-funnels', [ $this, 'remove_steps_pages' ], 10, 1 );
64 +
65 + add_action( 'wp_loaded', [ $this, 'sellkit_set_sellkit_translation_mode' ] );
64 66 }
65 67
66 68 /**
67 69 * Removes steps pages.
@@ -77,9 +79,11 @@
77 79 return;
78 80 }
79 81
80 82 foreach ( $nodes[0] as $node ) {
81 - wp_delete_post( $node['page_id'] );
83 + if ( isset( $node['page_id'] ) ) {
84 + wp_delete_post( $node['page_id'] );
85 + }
82 86 }
83 87 }
84 88
85 89 /**
@@ -91,12 +95,12 @@
91 95 return [
92 96 'sales-page' => esc_html__( 'Sales Page', 'sellkit' ),
93 97 'checkout' => esc_html__( 'Checkout', 'sellkit' ),
94 98 'thankyou' => esc_html__( 'Thank You', 'sellkit' ),
95 - 'decision' => esc_html__( 'Decision', 'sellkit' ),
99 + 'decision' => esc_html__( 'Condition', 'sellkit' ),
96 100 'upsell' => esc_html__( 'Upsell', 'sellkit' ),
97 101 'downsell' => esc_html__( 'Downsell', 'sellkit' ),
98 - 'optin-confirmation' => esc_html__( 'Opt-in Confirmation' ),
102 + 'optin-confirmation' => esc_html__( 'Opt-in Confirmation', 'sellkit' ),
99 103 'optin' => esc_html__( 'Opt-in', 'sellkit' ),
100 104 ];
101 105 }
102 106
@@ -111,9 +115,17 @@
111 115 foreach ( $steps as $step_number => $step ) {
112 116 $step['funnel_id'] = $funnel_id;
113 117 $step['number'] = $step_number;
114 118
115 - update_post_meta( $step['page_id'], 'step_data', $step );
119 + if ( array_key_exists( 'page_id', $step ) ) {
120 + $translated_step = apply_filters( 'wpml_object_id', $step['page_id'], 'sellkit_step', true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WPML API.
121 +
122 + if ( $step['page_id'] !== $translated_step ) {
123 + update_post_meta( $translated_step, 'step_data', $step );
124 + }
125 +
126 + update_post_meta( $step['page_id'], 'step_data', $step );
127 + }
116 128 }
117 129 }
118 130
119 131 /**
@@ -213,9 +225,9 @@
213 225 wp_send_json_error( __( 'Please install and activate WooCommerce.', 'sellkit' ) );
214 226 }
215 227
216 228 if ( empty( $products_id ) ) {
217 - wp_send_json_error( __( 'Please send some product ids' ) );
229 + wp_send_json_error( __( 'Please send some product ids', 'sellkit' ) );
218 230 }
219 231
220 232 $products_id = is_array( $products_id ) ? $products_id : [ $products_id ];
221 233
@@ -225,8 +237,14 @@
225 237 if ( empty( $product ) ) {
226 238 continue;
227 239 }
228 240
241 + $data = $product->get_data();
242 +
243 + if ( 'trash' === $data['status'] ) {
244 + continue;
245 + }
246 +
229 247 $attributes = $product->get_attributes();
230 248 $label = $product->get_title();
231 249
232 250 if ( $product->get_type() === 'variation' ) {
@@ -309,9 +327,9 @@
309 327 $nodes[ end( $old_node_keys ) + 1 ] = $last_node;
310 328 $keys = array_keys( $nodes );
311 329
312 330 if (
313 - 'last-node' !== $origin_node &&
331 + 'last-node' !== $origin_node && ! empty( $nodes[ $origin_node ] ) &&
314 332 'decision' !== $nodes[ $origin_node ]['type']['key'] &&
315 333 'upsell' !== $nodes[ $origin_node ]['type']['key'] &&
316 334 'downsell' !== $nodes[ $origin_node ]['type']['key']
317 335 ) {
@@ -318,9 +336,9 @@
318 336 $nodes[ $origin_node ]['targets'] = [ [ 'nodeId' => strval( end( $keys ) ) ] ];
319 337 }
320 338
321 339 if (
322 - 'last-node' !== $origin_node &&
340 + 'last-node' !== $origin_node && isset( $nodes[ $origin_node ]['type'] ) &&
323 341 (
324 342 'decision' === $nodes[ $origin_node ]['type']['key'] ||
325 343 'upsell' === $nodes[ $origin_node ]['type']['key'] ||
326 344 'downsell' === $nodes[ $origin_node ]['type']['key']
@@ -374,8 +392,12 @@
374 392 if ( 'string' !== gettype( $template ) || ! is_object( $post ) || self::SELLKIT_STEP_POST_TYPE !== $post->post_type ) {
375 393 return $template;
376 394 }
377 395
396 + if ( has_blocks( $post ) ) {
397 + return $template;
398 + }
399 +
378 400 remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' );
379 401 add_filter( 'next_post_rel_link', '__return_empty_string' );
380 402 add_filter( 'previous_post_rel_link', '__return_empty_string' );
381 403
@@ -499,8 +521,12 @@
499 521 */
500 522 public function update_steps_post_status( $funnel_id, $new_status ) {
501 523 $steps = get_post_meta( $funnel_id, 'sellkit_steps', true );
502 524
525 + if ( ! is_array( $steps ) ) {
526 + return;
527 + }
528 +
503 529 foreach ( $steps as $step ) {
504 530 if ( $step['page_id'] === $funnel_id ) {
505 531 continue;
506 532 }
@@ -508,8 +534,41 @@
508 534 wp_update_post(array(
509 535 'ID' => $step['page_id'],
510 536 'post_status' => $new_status,
511 537 ) );
538 + }
539 + }
540 +
541 + /**
542 + * Make SellKit custom post types translatable by default and set step_data custom field to "Copy".
543 + *
544 + * @since 2.3.2
545 + */
546 + public function sellkit_set_sellkit_translation_mode() {
547 + if ( function_exists( 'wpml_load_settings_helper' ) ) {
548 + global $sitepress;
549 +
550 + if ( $sitepress instanceof SitePress ) {
551 + $settings_helper = wpml_load_settings_helper();
552 +
553 + $post_types = [
554 + 'sellkit_step',
555 + 'sellkit-discount',
556 + 'sellkit-coupon',
557 + 'sellkit-alert',
558 + ];
559 +
560 + foreach ( $post_types as $post_type ) {
561 + $settings_helper->set_post_type_translatable( $post_type );
562 + $settings_helper->set_post_type_translation_unlocked_option( $post_type, true );
563 +
564 + if ( class_exists( '\WPML\Settings\PostType\Automatic' ) ) {
565 + \WPML\Settings\PostType\Automatic::set( $post_type, true );
566 + }
567 + }
568 +
569 + do_action( 'wpml_save_custom_field_translation_option', 'step_data', WPML_COPY_CUSTOM_FIELD ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WPML API.
570 + }
512 571 }
513 572 }
514 573 }
515 574