| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package FireBox |
| 4 |
* @version 2.0.6 Free |
| 5 |
* |
| 6 |
* @author FirePlugins <info@fireplugins.com> |
| 7 |
* @link https://www.fireplugins.com |
| 8 |
* @copyright Copyright © 2023 FirePlugins All Rights Reserved |
| 9 |
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace FireBox\Core; |
| 13 |
|
| 14 |
if (!defined('ABSPATH')) |
| 15 |
{ |
| 16 |
exit; // Exit if accessed directly. |
| 17 |
} |
| 18 |
|
| 19 |
use FPFramework\Libs\Registry; |
| 20 |
|
| 21 |
class Frontend |
| 22 |
{ |
| 23 |
public function __construct() |
| 24 |
{ |
| 25 |
// ensure we run only on front-end |
| 26 |
if (is_admin()) |
| 27 |
{ |
| 28 |
return; |
| 29 |
} |
| 30 |
|
| 31 |
// Prepare Gutenberg Blocks that contain attributes by FireBox |
| 32 |
new \FireBox\Core\FB\BoxBlocksParser(); |
| 33 |
|
| 34 |
/** |
| 35 |
* Event that runs before any rendering of popups. |
| 36 |
*/ |
| 37 |
do_action('firebox/boxes/before_render'); |
| 38 |
|
| 39 |
$this->render(); |
| 40 |
|
| 41 |
\FireBox\Core\Helpers\Actions::run(); |
| 42 |
|
| 43 |
/** |
| 44 |
* Event that runs after popups have been rendered. |
| 45 |
*/ |
| 46 |
do_action('firebox/boxes/after_render'); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Renders all boxes on front-end |
| 51 |
* |
| 52 |
* @return void |
| 53 |
*/ |
| 54 |
private function render() |
| 55 |
{ |
| 56 |
if ($this->checkForBoxPreview()) |
| 57 |
{ |
| 58 |
return; |
| 59 |
} |
| 60 |
|
| 61 |
// increment session counter |
| 62 |
\FPFramework\Libs\Functions::incrementSession(); |
| 63 |
|
| 64 |
/** |
| 65 |
* Adds all boxes at the end of page. |
| 66 |
*/ |
| 67 |
add_action('wp', function() { |
| 68 |
firebox()->boxes->render(); |
| 69 |
}); |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Check if we are previewing a box and do not show other boxes. |
| 74 |
* |
| 75 |
* @return boolean |
| 76 |
*/ |
| 77 |
private function checkForBoxPreview() |
| 78 |
{ |
| 79 |
$previewer = new Previewer(); |
| 80 |
return $previewer->init(); |
| 81 |
} |
| 82 |
} |