| @@ -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\Admin\Analytics\Overview; |
| @@ -29,15 +29,8 @@ | ||
| 29 | 29 | 'date' => 'this_month' |
| 30 | 30 | ]; |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | - * Configuration | |
| 34 | - * | |
| 35 | - * @var array | |
| 36 | - */ | |
| 37 | - private $configuration; | |
| 38 | - | |
| 39 | - /** | |
| 40 | 33 | * Analytics Toolbar |
| 41 | 34 | * |
| 42 | 35 | * @var Toolbar |
| 43 | 36 | */ |
| @@ -42,24 +35,18 @@ | ||
| 42 | 35 | * @var Toolbar |
| 43 | 36 | */ |
| 44 | 37 | private $toolbar; |
| 45 | 38 | |
| 46 | - public function __construct($configuration = []) | |
| 39 | + public function __construct() | |
| 47 | 40 | { |
| 48 | - // set the configuration data of the Analytics Helper class | |
| 49 | - AnalyticsHelper::setConfigurationData($configuration); | |
| 50 | - | |
| 51 | 41 | // Ensure we can show analytics overview on current page |
| 52 | - if (!wp_doing_ajax() && !$this->canRun()) | |
| 42 | + if (!\FireBox\Core\Admin\Analytics\Helpers\AnalyticsHelper::canRun('firebox')) | |
| 53 | 43 | { |
| 54 | 44 | return; |
| 55 | 45 | } |
| 56 | 46 | |
| 57 | - $this->configuration = $configuration; | |
| 58 | - $this->toolbar = new \FireBox\Core\Admin\Analytics\Toolbar($configuration); | |
| 47 | + $this->init(); | |
| 59 | 48 | |
| 60 | - $this->ajax = new Ajax($this); | |
| 61 | - | |
| 62 | 49 | // render overview filters |
| 63 | 50 | add_action('firebox/analytics/overview/filters', [$this, 'renderFilters']); |
| 64 | 51 | |
| 65 | 52 | // render overview |
| @@ -65,42 +52,11 @@ | ||
| 65 | 52 | // render overview |
| 66 | 53 | add_action('firebox/dashboard/content', [$this, 'render']); |
| 67 | 54 | } |
| 68 | 55 | |
| 69 | - /** | |
| 70 | - * Whether we can run analytics overview or not | |
| 71 | - * | |
| 72 | - * @return boolean | |
| 73 | - */ | |
| 74 | - protected function canRun() | |
| 56 | + public function init() | |
| 75 | 57 | { |
| 76 | - // we must be on admin panel | |
| 77 | - if (!is_admin()) | |
| 78 | - { | |
| 79 | - return false; | |
| 80 | - } | |
| 81 | - | |
| 82 | - // ensure we have correct priviledges | |
| 83 | - if (!is_user_logged_in() || !current_user_can('manage_options')) | |
| 84 | - { | |
| 85 | - return false; | |
| 86 | - } | |
| 87 | - | |
| 88 | - // we must be on admin.php page | |
| 89 | - global $pagenow; | |
| 90 | - if (!$pagenow == 'admin.php') | |
| 91 | - { | |
| 92 | - return false; | |
| 93 | - } | |
| 94 | - | |
| 95 | - // ensure we are on firebox dashboard | |
| 96 | - $page = fpframework()->getPluginPage(); | |
| 97 | - if (!$page || !in_array($page, ['firebox'])) | |
| 98 | - { | |
| 99 | - return false; | |
| 100 | - } | |
| 101 | - | |
| 102 | - return true; | |
| 58 | + $this->toolbar = new \FireBox\Core\Admin\Analytics\Toolbar(); | |
| 103 | 59 | } |
| 104 | 60 | |
| 105 | 61 | /** |
| 106 | 62 | * Display the Analytics Overview |
| @@ -110,10 +66,8 @@ | ||
| 110 | 66 | public function render() |
| 111 | 67 | { |
| 112 | 68 | // Load CSS & JS files |
| 113 | 69 | $this->loadMedia(); |
| 114 | - | |
| 115 | - $payload = $this->getOverviewItemsPayload(); | |
| 116 | 70 | |
| 117 | 71 | firebox()->renderer->admin->render('analytics/overview/tmpl', [ |
| 118 | 72 | 'overview_items_names' => $this->getOverviewItemsNames(), |
| 119 | 73 | 'default_filters' => $this->default_filters |
| @@ -122,9 +76,9 @@ | ||
| 122 | 76 | |
| 123 | 77 | public function renderFilters() |
| 124 | 78 | { |
| 125 | 79 | firebox()->renderer->admin->render('analytics/overview/filters', [ |
| 126 | - 'configuration' => $this->configuration, | |
| 80 | + 'configuration' => firebox()->analytics_configuration, | |
| 127 | 81 | 'filters' => $this->getFilters() |
| 128 | 82 | ]); |
| 129 | 83 | } |
| 130 | 84 | |
| @@ -129,21 +83,33 @@ | ||
| 129 | 83 | } |
| 130 | 84 | |
| 131 | 85 | public function getOverviewItemsNames() |
| 132 | 86 | { |
| 133 | - $payload = $this->getOverviewItemsPayload(); | |
| 87 | + $names = array_keys($this->getOverviewItemsPayload()); | |
| 88 | + | |
| 134 | 89 | |
| 135 | - return array_keys($payload); | |
| 90 | + if (FBOX_LICENSE_TYPE === 'lite') | |
| 91 | + { | |
| 92 | + unset($names['submissions']); | |
| 93 | + unset($names['conversionrate']); | |
| 94 | + unset($names['countries']); | |
| 95 | + unset($names['referrers']); | |
| 96 | + unset($names['pie']); // Devices | |
| 97 | + } | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + return $names; | |
| 136 | 103 | } |
| 137 | 104 | |
| 138 | 105 | public function getOverviewItemsPayload() |
| 139 | 106 | { |
| 140 | - $configuration = $this->toolbar->getConfiguration(); | |
| 107 | + $configuration = firebox()->analytics_configuration; | |
| 141 | 108 | |
| 142 | 109 | return [ |
| 143 | 110 | 'impressions' => [ |
| 144 | 111 | 'overview_type' => 'chart', |
| 145 | - 'url_chart_metrics' => ['impressions'], | |
| 146 | 112 | 'metrics' => ['impressions'], |
| 147 | 113 | 'allowed_filters' => [ |
| 148 | 114 | 'box', |
| 149 | 115 | 'date' |
| @@ -156,10 +122,9 @@ | ||
| 156 | 122 | ], |
| 157 | 123 | ], |
| 158 | 124 | 'avg_time_open' => [ |
| 159 | 125 | 'overview_type' => 'chart', |
| 160 | - 'url_chart_metrics' => ['theaveragetimeopen'], | |
| 161 | - 'metrics' => ['theaveragetimeopen'], | |
| 126 | + 'metrics' => ['averagetimeopen'], | |
| 162 | 127 | 'allowed_filters' => [ |
| 163 | 128 | 'box', |
| 164 | 129 | 'date' |
| 165 | 130 | ], |
| @@ -169,8 +134,9 @@ | ||
| 169 | 134 | 'options_key' => 'this_month', |
| 170 | 135 | ] |
| 171 | 136 | ], |
| 172 | 137 | ], |
| 138 | + | |
| 173 | 139 | 'boxes' => [ |
| 174 | 140 | 'overview_title' => firebox()->_('FB_TOP_BOXES'), |
| 175 | 141 | 'overview_type' => 'boxestable', |
| 176 | 142 | 'layout' => 'table', |
| @@ -220,8 +186,30 @@ | ||
| 220 | 186 | ], |
| 221 | 187 | ], |
| 222 | 188 | |
| 223 | 189 | |
| 190 | + 'submissions_pro' => [ | |
| 191 | + 'overview_title' => fpframework()->_('FPF_SUBMISSIONS'), | |
| 192 | + 'overview_type' => 'pro', | |
| 193 | + 'layout' => 'pro', | |
| 194 | + 'redirect_base' => true, | |
| 195 | + 'feature' => fpframework()->_('FPF_SUBMISSIONS_CHART'), | |
| 196 | + 'image' => FBOX_MEDIA_ADMIN_URL . 'images/analytics_overview_submissions.png', | |
| 197 | + 'show_overlay_message' => true, | |
| 198 | + 'class' => 'overlay-bg corner', | |
| 199 | + 'message' => 'FPF_ANALYTICS_OVERVIEW_OVERLAY_PRO_MSG1' | |
| 200 | + ], | |
| 201 | + 'conversionrate_pro' => [ | |
| 202 | + 'overview_title' => fpframework()->_('FPF_CONVERSION_RATE'), | |
| 203 | + 'overview_type' => 'pro', | |
| 204 | + 'layout' => 'pro', | |
| 205 | + 'redirect_base' => true, | |
| 206 | + 'feature' => fpframework()->_('FPF_CONVERSION_RATE_CHART'), | |
| 207 | + 'image' => FBOX_MEDIA_ADMIN_URL . 'images/analytics_overview_conversionrate.png', | |
| 208 | + 'show_overlay_message' => true, | |
| 209 | + 'class' => 'overlay-bg corner', | |
| 210 | + 'message' => 'FPF_ANALYTICS_OVERVIEW_OVERLAY_PRO_MSG1' | |
| 211 | + ], | |
| 224 | 212 | 'devices_pro' => [ |
| 225 | 213 | 'overview_title' => fpframework()->_('FPF_TOP_DEVICES'), |
| 226 | 214 | 'overview_type' => 'pro', |
| 227 | 215 | 'layout' => 'pro', |
| @@ -269,9 +257,9 @@ | ||
| 269 | 257 | 'default_label' => firebox()->_('FB_ALL_POPUPS'), |
| 270 | 258 | 'item' => firebox()->_('FB_POPUP_SELECTION') |
| 271 | 259 | ], |
| 272 | 260 | 'date_pro' => [ |
| 273 | - 'default_label' => fpframework()->_('FB_THIS_MONTH'), | |
| 261 | + 'default_label' => firebox()->_('FB_THIS_MONTH'), | |
| 274 | 262 | 'item' => fpframework()->_('FPF_DATE_PERIOD') |
| 275 | 263 | ] |
| 276 | 264 | |
| 277 | 265 | ]; |