PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.14
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.14
3.1.14 3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 All 123 releases
firebox / Inc / Core / Helpers / PHPExecution.php

PHPExecution.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 3.1.14, at Inc/Core/Helpers/PHPExecution.php

78 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FireBox
4 * @version 3.1.14 Free
5 *
6 * @author FirePlugins <[email protected]>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2026 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core\Helpers;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 /**
20 * Decides whether a campaign may run server-side PHP: the "PHP" display condition
21 * and the Pro "PHP Scripts" hooks. Both execute campaign-authored PHP through
22 * \FPFramework\Base\Executer, so they are limited to campaigns whose author holds
23 * the firebox_execute_php capability.
24 *
25 * That capability is separate from the campaign-editing capabilities on purpose:
26 * editing a campaign never grants the ability to run PHP. Administrators hold it by
27 * default (see Admin\Capabilities); a site owner can grant it to another role
28 * deliberately. The check is a stateless function of the post author, so it applies
29 * however the meta was saved (block editor, REST, import, or legacy).
30 */
31 class PHPExecution
32 {
33 /**
34 * Whether the given campaign's author may run server-side PHP.
35 *
36 * @param int $post_id The campaign (firebox) post ID.
37 *
38 * @return bool
39 */
40 public static function isAllowedForCampaign($post_id)
41 {
42 if (!self::isFeatureEnabled())
43 {
44 return false;
45 }
46
47 $post_id = (int) $post_id;
48
49 if (!$post_id)
50 {
51 return false;
52 }
53
54 $author_id = (int) get_post_field('post_author', $post_id);
55
56 if (!$author_id)
57 {
58 return false;
59 }
60
61 return user_can($author_id, 'firebox_execute_php');
62 }
63
64 /**
65 * Whether server-side PHP features are enabled site-wide. Lets a site switch
66 * them off entirely regardless of who authored the campaign.
67 *
68 * @return bool
69 */
70 public static function isFeatureEnabled()
71 {
72 /**
73 * @param bool $enabled
74 */
75 return (bool) apply_filters('firebox/php/enabled', true);
76 }
77 }
78