| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.13 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 © 2026 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; |
| @@ -24,10 +24,8 @@ | ||
| 24 | 24 | * @var array |
| 25 | 25 | */ |
| 26 | 26 | public $box_data; |
| 27 | 27 | |
| 28 | - protected $embed_html = ''; | |
| 29 | - | |
| 30 | 28 | /** |
| 31 | 29 | * Inits Previewer |
| 32 | 30 | * |
| 33 | 31 | * @return void |
| @@ -49,40 +47,30 @@ | ||
| 49 | 47 | * @return boolean |
| 50 | 48 | */ |
| 51 | 49 | public function is_preview_page() |
| 52 | 50 | { |
| 53 | - global $post; | |
| 54 | - $post_type = isset($_GET['post_type']) ? sanitize_key($_GET['post_type']) : false; //phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 55 | - $post_id = isset($_GET['p']) ? \absint($_GET['p']) : false; //phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 56 | - | |
| 57 | - if (!$post_type && !$post_id && $post) | |
| 58 | - { | |
| 59 | - $post_type = $post->post_type; | |
| 60 | - $post_id = $post->ID; | |
| 61 | - } | |
| 62 | - | |
| 63 | 51 | // Only proceed if we have a item to preview |
| 64 | - if (empty($post_type)) | |
| 52 | + if (empty($_GET['post_type'])) | |
| 65 | 53 | { |
| 66 | 54 | return false; |
| 67 | 55 | } |
| 68 | 56 | |
| 69 | - if ($post_type != 'firebox') | |
| 57 | + if ($_GET['post_type'] != 'firebox') | |
| 70 | 58 | { |
| 71 | 59 | return false; |
| 72 | 60 | } |
| 73 | 61 | |
| 74 | - if (empty($post_id)) | |
| 62 | + if (empty($_GET['p'])) | |
| 75 | 63 | { |
| 76 | 64 | return false; |
| 77 | 65 | } |
| 78 | 66 | |
| 79 | - if (empty($_GET['preview'])) //phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 67 | + if (empty($_GET['preview'])) | |
| 80 | 68 | { |
| 81 | 69 | return false; |
| 82 | 70 | } |
| 83 | 71 | |
| 84 | - if (!sanitize_key(wp_unslash($_GET['preview']))) //phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 72 | + if (!$_GET['preview']) | |
| 85 | 73 | { |
| 86 | 74 | return false; |
| 87 | 75 | } |
| 88 | 76 | |
| @@ -91,14 +79,16 @@ | ||
| 91 | 79 | { |
| 92 | 80 | return false; |
| 93 | 81 | } |
| 94 | 82 | |
| 95 | - if (!\current_user_can('read_firebox', $post_id)) | |
| 83 | + if (!\current_user_can('manage_options')) | |
| 96 | 84 | { |
| 97 | 85 | return false; |
| 98 | 86 | } |
| 99 | 87 | |
| 100 | - if (!$this->box_data = firebox()->box->get($post_id)) | |
| 88 | + $box_id = \absint($_GET['p']); | |
| 89 | + | |
| 90 | + if (!$this->box_data = firebox()->box->get($box_id)) | |
| 101 | 91 | { |
| 102 | 92 | return false; |
| 103 | 93 | } |
| 104 | 94 | |
| @@ -111,14 +101,10 @@ | ||
| 111 | 101 | * @return void |
| 112 | 102 | */ |
| 113 | 103 | public function hooks() |
| 114 | 104 | { |
| 115 | - if ($this->box_data->params->get('mode') !== 'embed') | |
| 116 | - { | |
| 117 | - // Set to trigger on Page Load | |
| 118 | - $this->box_data->params->set('triggermethod', 'pageload'); | |
| 119 | - } | |
| 120 | - | |
| 105 | + // Set to trigger on Page Load | |
| 106 | + $this->box_data->params->set('triggermethod', 'pageload'); | |
| 121 | 107 | // Remove Impressions |
| 122 | 108 | $this->box_data->params->set('assign_impressions_param_type', 'always'); |
| 123 | 109 | // Remove Assignments |
| 124 | 110 | $this->box_data->params->remove('assignments'); |
| @@ -129,19 +115,11 @@ | ||
| 129 | 115 | // Disable Statistics to prevent impressions from being tracked into the database |
| 130 | 116 | $this->box_data->params->set('stats', 0); |
| 131 | 117 | |
| 132 | 118 | \FireBox\Core\Helpers\Actions::run(); |
| 119 | + | |
| 120 | + firebox()->box->setBox($this->box_data)->render(); | |
| 133 | 121 | |
| 134 | - if ($this->box_data->params->get('mode') !== 'embed') | |
| 135 | - { | |
| 136 | - firebox()->box->setBox($this->box_data)->render(); | |
| 137 | - } | |
| 138 | - else | |
| 139 | - { | |
| 140 | - global $post; | |
| 141 | - $this->embed_html = \FireBox\Core\Helpers\Embed::renderCampaign($post->ID, ['draft']); | |
| 142 | - } | |
| 143 | - | |
| 144 | 122 | \add_filter('the_title', [$this, 'the_title'], 100, 1); |
| 145 | 123 | |
| 146 | 124 | \add_filter('the_content', [$this, 'the_content'], 999); |
| 147 | 125 | |
| @@ -154,9 +132,9 @@ | ||
| 154 | 132 | { |
| 155 | 133 | return ''; |
| 156 | 134 | } |
| 157 | 135 | |
| 158 | - if (!current_user_can('read_firebox', $this->box_data->ID)) | |
| 136 | + if (!current_user_can('manage_options')) | |
| 159 | 137 | { |
| 160 | 138 | return ''; |
| 161 | 139 | } |
| 162 | 140 | |
| @@ -171,9 +149,9 @@ | ||
| 171 | 149 | ], |
| 172 | 150 | admin_url('post.php') |
| 173 | 151 | ) |
| 174 | 152 | ), |
| 175 | - 'text' => esc_html(firebox()->_('FB_EDIT_CAMPAIGN')), | |
| 153 | + 'text' => esc_html(firebox()->_('FB_EDIT_FIREBOX')), | |
| 176 | 154 | ]; |
| 177 | 155 | |
| 178 | 156 | $links[] = [ |
| 179 | 157 | 'url' => esc_url( |
| @@ -183,32 +161,29 @@ | ||
| 183 | 161 | ], |
| 184 | 162 | admin_url('edit.php') |
| 185 | 163 | ) |
| 186 | 164 | ), |
| 187 | - 'text' => esc_html(firebox()->_('FB_VIEW_CAMPAIGNS')), | |
| 165 | + 'text' => esc_html(firebox()->_('FB_VIEW_FIREBOX_ITEMS')), | |
| 188 | 166 | ]; |
| 189 | 167 | |
| 190 | 168 | $content = '<div style="padding: 15px; background: #ededed;">'; |
| 191 | 169 | $content .= '<p>'; |
| 192 | 170 | $content .= esc_html(firebox()->_('FB_FIREBOX_PREVIEW_DESC')); |
| 193 | - $content .= '<br>'; | |
| 194 | - foreach ($links as $key => $link) | |
| 195 | - { | |
| 196 | - $content .= '<a href="' . esc_url($link['url']) . '">' . esc_html($link['text']) . '</a>'; | |
| 197 | - $l = array_keys($links); | |
| 198 | - if (end($l) !== $key) | |
| 199 | - { | |
| 200 | - $content .= ' <span style="display:inline-block;margin:0 6px;opacity: 0.5">|</span> '; | |
| 171 | + if (!empty($links)) | |
| 172 | + { | |
| 173 | + $content .= '<br>'; | |
| 174 | + foreach ($links as $key => $link) | |
| 175 | + { | |
| 176 | + $content .= '<a href="' . esc_url($link['url']) . '">' . esc_html($link['text']) . '</a>'; | |
| 177 | + $l = array_keys($links); | |
| 178 | + if (end($l) !== $key) | |
| 179 | + { | |
| 180 | + $content .= ' <span style="display:inline-block;margin:0 6px;opacity: 0.5">|</span> '; | |
| 181 | + } | |
| 201 | 182 | } |
| 202 | 183 | } |
| 203 | 184 | $content .= '</p>'; |
| 204 | 185 | $content .= '</div>'; |
| 205 | - | |
| 206 | - // Add embed campaign to preview page | |
| 207 | - if ($this->box_data->params->get('mode') === 'embed') | |
| 208 | - { | |
| 209 | - $content .= '<div style="margin: 30px auto; display: flex; justify-content: center;">' . $this->embed_html . '</div>'; | |
| 210 | - } | |
| 211 | 186 | |
| 212 | 187 | return $content; |
| 213 | 188 | } |
| 214 | 189 | |
| @@ -224,9 +199,9 @@ | ||
| 224 | 199 | if (in_the_loop()) |
| 225 | 200 | { |
| 226 | 201 | $title = sprintf( |
| 227 | 202 | esc_html('%s'), |
| 228 | - ! empty($this->box_data->post_title) ? sanitize_text_field($this->box_data->post_title) . ' ' . firebox()->_('FB_PREVIEW') : esc_html(firebox()->_('FB_FIREBOX_CAMPAIGN_PREVIEW')) | |
| 203 | + ! empty($this->box_data->post_title) ? sanitize_text_field($this->box_data->post_title) . ' ' . firebox()->_('FB_PREVIEW') : esc_html(firebox()->_('FB_FIREBOX_POPUP_PREVIEW')) | |
| 229 | 204 | ); |
| 230 | 205 | } |
| 231 | 206 | |
| 232 | 207 | return $title; |