/** * Print out the JS section templates * * @since 1.0.0. * * @return void */ public function print_templates() { global $hook_suffix, $typenow, $ttfmake_is_js_template; $ttfmake_is_js_template = true; // Only show when adding/editing pages if (!ttfmake_post_type_supports_builder($typenow) || !in_array($hook_suffix, array('post.php', 'post-new.php'))) { return; } // Print the templates foreach (ttfmake_get_sections() as $key => $section) { ?> <script type="text/html" id="tmpl-ttfmake-<?php echo esc_attr($section['id']); ?> "> <?php ob_start(); $this->load_section($section, array()); $html = ob_get_clean(); $html = str_replace(array('temp'), array('{{{ id }}}'), $html); echo $html; ?> </script> <?php } unset($GLOBALS['ttfmake_is_js_template']); }
/** * Print out the JS section templates * * @since 1.0.0. * * @return void */ public function print_templates() { global $hook_suffix, $typenow, $ttfmake_is_js_template; $ttfmake_is_js_template = true; // Only show when adding/editing pages if (!ttfmake_post_type_supports_builder($typenow) || !in_array($hook_suffix, array('post.php', 'post-new.php'))) { return; } // Print the templates foreach (ttfmake_get_sections() as $section) { ?> <script type="text/html" id="tmpl-ttfmake-<?php echo esc_attr($section['id']); ?> "> <?php ob_start(); $this->load_section($section, array()); $html = ob_get_clean(); echo $html; ?> </script> <?php } unset($GLOBALS['ttfmake_is_js_template']); // Load the overlay for TinyMCE get_template_part('/inc/builder/core/templates/overlay', 'tinymce'); // Print the template for removing images ?> <script type="text/html" id="tmpl-ttfmake-remove-image"> <div class="ttfmake-remove-current-image"> <h3><?php esc_html_e('Current image', 'make'); ?> </h3> <a href="#" class="ttfmake-remove-image-from-modal"> <?php esc_html_e('Remove Current Image', 'make'); ?> </a> </div> </script> <?php }
/** * Based on section data, generate a post's post_content. * * @since 1.0.4. * * @param array $data Data for sections used to comprise a page's post_content. * @return string The post content. */ public function generate_post_content($data) { // Run wpautop when saving the data add_filter('make_the_builder_content', 'wpautop'); // Handle oEmbeds correctly add_filter('make_the_builder_content', array($this, 'embed_handling'), 8); add_filter('embed_handler_html', array($this, 'embed_handler_html'), 10, 3); add_filter('embed_oembed_html', array($this, 'embed_oembed_html'), 10, 4); // Remove editor image constraints while rendering section data. add_filter('editor_max_image_size', array(&$this, 'remove_image_constraints')); // Start the output buffer to collect the contents of the templates ob_start(); // For each sections, render it using the template foreach ($data as $section) { global $ttfmake_section_data, $ttfmake_sections; $ttfmake_section_data = $section; $ttfmake_sections = $data; // Get the registered sections $registered_sections = ttfmake_get_sections(); // Get the template for the section ttfmake_load_section_template($registered_sections[$section['section-type']]['display_template'], $registered_sections[$section['section-type']]['path']); // Cleanup the global unset($GLOBALS['ttfmake_section_data']); } // Get the rendered templates from the output buffer $post_content = ob_get_clean(); // Allow constraints again after builder data processing is complete. remove_filter('editor_max_image_size', array(&$this, 'remove_image_constraints')); /** * Filter the generated post content. * * This content is the full HTML version of the content that will be saved as "post_content". * * @since 1.2.3. * * @param string $post_content The fully generated post content. * @param array $data The data used to generate the content. */ return apply_filters('make_generate_post_content', $post_content, $data); }