← All changes
|
includes/core/data-store/class-wpfnl-store-steps-data.php
+37
-1
3.13.1
→
3.13.3
View file →
| @@ -70,14 +70,50 @@ | ||
| 70 | 70 | $this->funnel_id = $funnel_id; |
| 71 | 71 | $this->type = $type; |
| 72 | 72 | $this->set_id($step_id); |
| 73 | 73 | $this->set_default_props(); |
| 74 | - | |
| 74 | + $this->maybe_mark_step_as_divi_built($step_id, $post_content); | |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | do_action('wpfunnels_after_step_creation'); |
| 78 | 78 | update_post_meta($step_id, '_wp_page_template', 'wpfunnels_default'); |
| 79 | 79 | return $step_id; |
| 80 | + } | |
| 81 | + | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * Flag a blank Divi step as builder-enabled so Divi offers its editor toggle. | |
| 85 | + * | |
| 86 | + * Divi's block editor integration only injects the "Edit With The Divi Builder" | |
| 87 | + * placeholder when et_pb_is_pagebuilder_used() is true, or when the post is a | |
| 88 | + * brand new unsaved one. A step is wp_insert_post()'d and published before the | |
| 89 | + * user ever opens it, so it is never "new" by the time Divi looks — without | |
| 90 | + * this meta a scratch-built step opens in Gutenberg with no way to reach Divi. | |
| 91 | + * Imported steps work today only because the template meta they copy already | |
| 92 | + * carries _et_pb_use_builder. | |
| 93 | + * | |
| 94 | + * Only blank steps are touched: import and clone pass content through here too, | |
| 95 | + * and those carry their own (possibly non-Divi) builder meta. | |
| 96 | + * | |
| 97 | + * @param int $step_id Newly created step id. | |
| 98 | + * @param string $post_content Content the step was created with. | |
| 99 | + * | |
| 100 | + * @return void | |
| 101 | + */ | |
| 102 | + private function maybe_mark_step_as_divi_built($step_id, $post_content) | |
| 103 | + { | |
| 104 | + if ('' !== trim((string) $post_content)) { | |
| 105 | + return; | |
| 106 | + } | |
| 107 | + | |
| 108 | + if ('divi-builder' !== Wpfnl_functions::get_builder_type()) { | |
| 109 | + return; | |
| 110 | + } | |
| 111 | + | |
| 112 | + update_post_meta($step_id, '_et_pb_use_builder', 'on'); | |
| 113 | + // Divi stores the post type the layout was built for; steps mirror pages, | |
| 114 | + // which is what imported Divi templates carry. | |
| 115 | + update_post_meta($step_id, '_et_pb_built_for_post_type', 'page'); | |
| 80 | 116 | } |
| 81 | 117 | |
| 82 | 118 | |
| 83 | 119 | public function set_default_props() |