BeaverBuilder.php
45 lines
| 1 | <?php |
| 2 | |
| 3 | namespace EmbedPress\ThirdParty; |
| 4 | |
| 5 | (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed."); |
| 6 | |
| 7 | /** |
| 8 | * Entity responsible for adding support for the Beaver Builder. |
| 9 | * |
| 10 | * @package EmbedPress |
| 11 | * @author EmbedPress <help@embedpress.com> |
| 12 | * @copyright Copyright (C) 2023 WPDeveloper. All rights reserved. |
| 13 | * @license GPLv3 or later |
| 14 | * @since 1.0.0 |
| 15 | */ |
| 16 | class BeaverBuilder |
| 17 | { |
| 18 | /** |
| 19 | * Method that replaces the embed shortcodes, before Beaver calls WP's native embed shortcode. |
| 20 | * It forces that when it runs $wp_embed->run_shortcode. |
| 21 | * |
| 22 | * @param string $content |
| 23 | * |
| 24 | * @return string |
| 25 | */ |
| 26 | public static function before_render_shortcodes($content) |
| 27 | { |
| 28 | global $shortcode_tags; |
| 29 | |
| 30 | // Back up current registered shortcodes and clear them all out |
| 31 | $orig_shortcode_tags = $shortcode_tags; |
| 32 | remove_all_shortcodes(); |
| 33 | |
| 34 | add_shortcode(EMBEDPRESS_SHORTCODE, ['\\EmbedPress\\Shortcode', 'do_shortcode']); |
| 35 | |
| 36 | // Do the shortcode (only the [embed] one is registered) |
| 37 | $content = do_shortcode($content, true); |
| 38 | |
| 39 | // Put the original shortcodes back |
| 40 | $shortcode_tags = $orig_shortcode_tags; |
| 41 | |
| 42 | return $content; |
| 43 | } |
| 44 | } |
| 45 |