| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 1.1.1 Free | |
| 4 | + * @version 2.0.12 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <info@fireplugins.com> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2022 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2023 FirePlugins All Rights Reserved | |
| 9 | 9 | * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace FireBox\Core; |
| @@ -30,16 +30,18 @@ | ||
| 30 | 30 | |
| 31 | 31 | // Prepare Gutenberg Blocks that contain attributes by FireBox |
| 32 | 32 | new \FireBox\Core\FB\BoxBlocksParser(); |
| 33 | 33 | |
| 34 | + $this->prepare(); | |
| 35 | + | |
| 34 | 36 | /** |
| 35 | 37 | * Event that runs before any rendering of popups. |
| 36 | 38 | */ |
| 37 | 39 | do_action('firebox/boxes/before_render'); |
| 38 | 40 | |
| 39 | - $this->render(); | |
| 41 | + add_action('template_redirect', [$this, 'render']); | |
| 40 | 42 | |
| 41 | - $this->init_dependencies(); | |
| 43 | + \FireBox\Core\Helpers\Actions::run(); | |
| 42 | 44 | |
| 43 | 45 | /** |
| 44 | 46 | * Event that runs after popups have been rendered. |
| 45 | 47 | */ |
| @@ -44,28 +46,30 @@ | ||
| 44 | 46 | * Event that runs after popups have been rendered. |
| 45 | 47 | */ |
| 46 | 48 | do_action('firebox/boxes/after_render'); |
| 47 | 49 | } |
| 48 | - | |
| 49 | - /** | |
| 50 | - * Initializes the dependencies | |
| 51 | - * | |
| 52 | - * @return void | |
| 53 | - */ | |
| 54 | - private function init_dependencies() | |
| 50 | + | |
| 51 | + private function prepare() | |
| 55 | 52 | { |
| 56 | - $actions = []; | |
| 57 | - | |
| 58 | - | |
| 53 | + add_filter('the_content', [$this, 'prepareContent'], 0); | |
| 54 | + } | |
| 59 | 55 | |
| 60 | - // Initialize Sounds | |
| 61 | - $actions[] = new \FireBox\Core\FB\Actions\Sounds(); | |
| 62 | - | |
| 63 | - // Make actions filterable | |
| 64 | - $actions = apply_filters('firebox/actions/box/edit', $actions); | |
| 56 | + public function prepareContent($content) | |
| 57 | + { | |
| 58 | + global $post; | |
| 59 | + | |
| 60 | + if (!$post instanceof \WP_Post) | |
| 61 | + { | |
| 62 | + return $content; | |
| 63 | + } | |
| 64 | + | |
| 65 | + // Check if the current post type is 'firebox' | |
| 66 | + if ($post->post_type === 'firebox') | |
| 67 | + { | |
| 68 | + remove_filter('the_content', 'wptexturize'); | |
| 69 | + } | |
| 65 | 70 | |
| 66 | - // Run actions | |
| 67 | - new \FireBox\Core\FB\Actions\ActionsBase($actions); | |
| 71 | + return $content; | |
| 68 | 72 | } |
| 69 | 73 | |
| 70 | 74 | /** |
| 71 | 75 | * Renders all boxes on front-end |
| @@ -71,9 +75,9 @@ | ||
| 71 | 75 | * Renders all boxes on front-end |
| 72 | 76 | * |
| 73 | 77 | * @return void |
| 74 | 78 | */ |
| 75 | - private function render() | |
| 79 | + public function render() | |
| 76 | 80 | { |
| 77 | 81 | if ($this->checkForBoxPreview()) |
| 78 | 82 | { |
| 79 | 83 | return; |
| @@ -84,11 +88,9 @@ | ||
| 84 | 88 | |
| 85 | 89 | /** |
| 86 | 90 | * Adds all boxes at the end of page. |
| 87 | 91 | */ |
| 88 | - add_action('wp', function() { | |
| 89 | - firebox()->boxes->render(); | |
| 90 | - }); | |
| 92 | + firebox()->boxes->render(); | |
| 91 | 93 | } |
| 92 | 94 | |
| 93 | 95 | /** |
| 94 | 96 | * Check if we are previewing a box and do not show other boxes. |