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