| @@ -19,9 +19,9 @@ | ||
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | $meta = get_post_meta($postId); |
| 22 | 22 | |
| 23 | - $templateMeta = usk_optional($meta)[Meta::TEMPLATE_TYPE]; | |
| 23 | + $templateMeta = ultimate_store_kit_optional($meta)[Meta::TEMPLATE_TYPE]; | |
| 24 | 24 | |
| 25 | 25 | if (!isset($templateMeta[0])) { |
| 26 | 26 | return; |
| 27 | 27 | } |
| @@ -47,10 +47,13 @@ | ||
| 47 | 47 | $wp_query = new \WP_Query($args); |
| 48 | 48 | |
| 49 | 49 | if ($wp_query->have_posts()) { |
| 50 | 50 | $post = $wp_query->posts[0]; |
| 51 | - set_transient('ultimate_store_template_id_' . get_current_user_id(), $postId); | |
| 52 | - set_transient('ultimate_store_template_sample_post_' . get_current_user_id(), $wp_query); | |
| 51 | + // An explicit lifetime is required: a transient stored with no expiry is | |
| 52 | + // autoloaded on every request, so these editor-preview handoffs otherwise | |
| 53 | + // accumulate one permanent wp_options row per user who opens the builder. | |
| 54 | + set_transient('ultimate_store_kit_template_id_' . get_current_user_id(), $postId, HOUR_IN_SECONDS); | |
| 55 | + set_transient('ultimate_store_kit_template_sample_post_' . get_current_user_id(), $wp_query, HOUR_IN_SECONDS); | |
| 53 | 56 | $GLOBALS['post'] = $post; |
| 54 | 57 | setup_postdata($post); |
| 55 | 58 | } |
| 56 | 59 | } |