Changeset 3297409
- Timestamp:
- 05/20/2025 01:26:01 PM (10 months ago)
- Location:
- burst-statistics/trunk
- Files:
-
- 20 added
- 16 edited
-
burst.php (modified) (1 diff)
-
src/Admin/App/build/18.ef0b376280c46dae144c.js (added)
-
src/Admin/App/build/955.b98a1801158946e926ac.js (added)
-
src/Admin/App/build/index.1324b7aed572329298f8.asset.php (added)
-
src/Admin/App/build/index.1324b7aed572329298f8.js (added)
-
src/Admin/App/class-app.php (modified) (6 diffs)
-
src/Admin/App/config/fields.php (modified) (1 diff)
-
src/Admin/App/src/components/Fields/RestoreArchivesField.jsx (modified) (1 diff)
-
src/Admin/App/src/components/Goals/GoalsSettings.js (modified) (1 diff)
-
src/Admin/App/src/components/Inputs/CheckboxGroupInput.tsx (modified) (1 diff)
-
src/Admin/App/src/store/useArchivesStore.js (modified) (1 diff)
-
src/Admin/App/src/store/useLicenseStore.js (modified) (1 diff)
-
src/Admin/App/src/utils/Icon.tsx (modified) (2 diffs)
-
src/Admin/Burst_Wp_Cli/class-burst-wp-cli.php (modified) (1 diff)
-
src/Admin/Installer/class-installer.php (modified) (1 diff)
-
src/Admin/Mailer/class-mail-reports.php (modified) (7 diffs)
-
src/Admin/Mailer/config (added)
-
src/Admin/Mailer/config/blocks.php (added)
-
src/Admin/Statistics/class-statistics.php (modified) (1 diff)
-
src/Admin/class-admin.php (modified) (2 diffs)
-
src/Frontend/class-frontend.php (modified) (1 diff)
-
src/TeamUpdraft (added)
-
src/TeamUpdraft/SharedComponents (added)
-
src/TeamUpdraft/SharedComponents/dist (added)
-
src/TeamUpdraft/SharedComponents/dist/Components (added)
-
src/TeamUpdraft/SharedComponents/dist/Components/Blocks (added)
-
src/TeamUpdraft/SharedComponents/dist/Components/Blocks/Block.jsx (added)
-
src/TeamUpdraft/SharedComponents/dist/Components/Blocks/CollapsableBlock.jsx (added)
-
src/TeamUpdraft/SharedComponents/dist/Components/Button.jsx (added)
-
src/TeamUpdraft/SharedComponents/dist/Components/Common (added)
-
src/TeamUpdraft/SharedComponents/dist/Components/Common/ErrorBoundary.jsx (added)
-
src/TeamUpdraft/SharedComponents/dist/Components/index.js (added)
-
src/TeamUpdraft/SharedComponents/dist/index.js (added)
-
src/TeamUpdraft/src (added)
-
src/TeamUpdraft/src/Onboarding (added)
-
src/class-burst.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
burst-statistics/trunk/burst.php
r3296551 r3297409 4 4 * Plugin URI: https://www.wordpress.org/plugins/burst-statistics 5 5 * Description: Get detailed insights into visitors’ behavior with Burst Statistics, the privacy-friendly analytics dashboard. 6 * Version: 2.0. 56 * Version: 2.0.6 7 7 * Requires at least: 6.2 8 8 * Requires PHP: 7.4 -
burst-statistics/trunk/src/Admin/App/class-app.php
r3296551 r3297409 826 826 $this->remove_fallback_notice(); 827 827 } 828 829 828 switch ( $action ) { 830 829 case 'plugin_actions': … … 900 899 'slug' => 'all-in-one-wp-security-and-firewall', 901 900 'constant_free' => 'AIO_WP_SECURITY_VERSION', 902 'constant_pro' => false, 901 'premium' => [ 902 'type' => 'constant', 903 'value' => 'AIOWPS_PREMIUM_VERSION', 904 ], 903 905 'wordpress_url' => 'https://wordpress.org/plugins/all-in-one-wp-security-and-firewall/', 904 906 'upgrade_url' => 'https://aiosplugin.com/product/all-in-one-wp-security-and-firewall-premium/?src=plugin-burst-other-plugins', … … 906 908 ], 907 909 [ 908 'slug' => 'updraftplus', 909 'constant_free' => 'UPDRAFTPLUS_DIR', 910 'constant_pro' => false, 911 'wordpress_url' => 'https://wordpress.org/plugins/updraftplus/', 912 'upgrade_url' => 'https://updraftplus.com/shop/updraftplus-premium/?src=plugin-burst-other-plugins', 913 'title' => 'UpdraftPlus - Back-up & migrate your site with ease', 910 'slug' => 'updraftplus', 911 'constant_free' => 'UPDRAFTPLUS_DIR', 912 // 'premium' => [ 913 // 'type' => 'function', 914 // 'value' => '$updraftplus_addons2 && method_exists($updraftplus_addons2, 'connection_status')) {' 915 // ], 916 'wordpress_url' => 'https://wordpress.org/plugins/updraftplus/', 917 'upgrade_url' => 'https://updraftplus.com/shop/updraftplus-premium/?src=plugin-burst-other-plugins', 918 'title' => 'UpdraftPlus - Back-up & migrate your site with ease', 914 919 ], 915 920 [ 916 921 'slug' => 'wp-optimize', 917 922 'constant_free' => 'WPO_VERSION', 918 'constant_pro' => false, 923 'premium' => [ 924 'type' => 'slug', 925 'value' => 'wp-optimize-premium/wp-optimize.php', 926 ], 919 927 'wordpress_url' => 'https://wordpress.org/plugins/wp-optimize/', 920 928 'upgrade_url' => 'https://getwpo.com/buy/?src=plugin-burst-other-plugins', … … 925 933 foreach ( $plugins as $index => $plugin ) { 926 934 $installer = new Installer( $plugin['slug'] ); 927 // @phpstan-ignore-next-line, constant_pro contain value in the future 928 if ( $plugin['constant_pro'] && defined( $plugin['constant_pro'] ) ) { 935 if ( isset( $plugin['premium'] ) && $this->plugin_is_installed( $plugin['premium']['type'], $plugin['premium']['value'] ) ) { 929 936 $plugins[ $index ]['pluginAction'] = 'installed'; 930 937 } elseif ( ! $installer->plugin_is_downloaded() && ! $installer->plugin_is_activated() ) { … … 932 939 } elseif ( $installer->plugin_is_downloaded() && ! $installer->plugin_is_activated() ) { 933 940 $plugins[ $index ]['pluginAction'] = 'activate'; 934 // @phpstan-ignore-next-line, might be true in the future 935 } elseif ( $plugin['constant_pro'] ) { 941 } elseif ( isset( $plugin['premium'] ) ) { 936 942 $plugins[ $index ]['pluginAction'] = 'upgrade-to-pro'; 937 943 } else { … … 949 955 950 956 return $plugins; 957 } 958 959 /** 960 * Check if a plugin is installed based on the detection type and value. 961 */ 962 private function plugin_is_installed( string $detection_type, string $detection_value ): bool { 963 if ( $detection_type === 'constant' ) { 964 return defined( $detection_value ); 965 } elseif ( $detection_type === 'slug' ) { 966 return file_exists( WP_PLUGIN_DIR . '/' . $detection_value ); 967 } elseif ( $detection_type === 'function' ) { 968 return function_exists( $detection_value ); 969 } elseif ( $detection_type === 'class' ) { 970 return class_exists( $detection_value ); 971 } 972 return false; 951 973 } 952 974 -
burst-statistics/trunk/src/Admin/App/config/fields.php
r3296551 r3297409 87 87 'disabled' => false, 88 88 'default' => false, 89 ], 90 [ 91 'id' => 'send_email_report', 92 'menu_id' => 'general', 93 'group_id' => 'email_reports', 94 'type' => 'button', 95 'action' => 'send_email_report', 96 'button_text' => __( 'Send', 'burst-statistics' ), 97 'label' => __( 'Send an e-mail report', 'burst-statistics' ), 98 'comment' => __( 'This will send an e-mail to all listed recipients.', 'burst-statistics' ), 99 'disabled' => false, 100 'default' => false, 89 101 ], 90 102 -
burst-statistics/trunk/src/Admin/App/src/components/Fields/RestoreArchivesField.jsx
r3296551 r3297409 51 51 setSelectedArchives([]); 52 52 await startRestoreArchives( ids ); 53 addHelpNotice(54 'archive_data',55 'warning',56 __( 'Because restoring files can conflict with the archiving functionality, archiving has been disabled.', 'burst-statistics' ),57 __( 'Archiving disabled', 'burst-statistics' )58 );53 // addHelpNotice( 54 // 'archive_data', 55 // 'warning', 56 // __( 'Because restoring files can conflict with the archiving functionality, archiving has been disabled.', 'burst-statistics' ), 57 // __( 'Archiving disabled', 'burst-statistics' ) 58 // ); 59 59 }; 60 60 -
burst-statistics/trunk/src/Admin/App/src/components/Goals/GoalsSettings.js
r3296551 r3297409 26 26 const {getValue} = useSettingsData(); 27 27 const cookieless = getValue( 'enable_cookieless_tracking' ); 28 29 console.log(isLicenseValid);30 28 31 29 const handleAddPredefinedGoal = ( goal ) => { -
burst-statistics/trunk/src/Admin/App/src/components/Inputs/CheckboxGroupInput.tsx
r3296551 r3297409 121 121 name={indeterminate ? 'indeterminate' : 'check'} 122 122 size={14} 123 color="dark-blue" 124 tooltip="" 125 onClick={() => {}} 126 className="" 123 color="blue" 127 124 /> 128 125 </Checkbox.Indicator> -
burst-statistics/trunk/src/Admin/App/src/store/useArchivesStore.js
r3296551 r3297409 30 30 }, 31 31 fetchData: async( ) => { 32 if ( !burst_settings.is_pro) { 33 return; 34 } 32 35 if ( get().fetching ) { 33 return;34 }36 return; 37 } 35 38 set({fetching: true}); 36 39 let data = {}; -
burst-statistics/trunk/src/Admin/App/src/store/useLicenseStore.js
r3296551 r3297409 12 12 // Property that returns true if license is valid 13 13 get isLicenseValid() { 14 console.log(get().licenseStatus);15 console.log(burst_settings.is_pro);16 14 return 'valid' === get().licenseStatus && burst_settings.is_pro === '1'; 17 15 } -
burst-statistics/trunk/src/Admin/App/src/utils/Icon.tsx
r3296551 r3297409 1 1 import { memo } from 'react'; 2 2 import Tooltip from '../components/Common/Tooltip'; 3 import clsx from 'clsx';4 3 import { LucideProps } from 'lucide-react'; 5 4 import { … … 172 171 strokeWidth 173 172 }; 174 173 174 175 175 // Render the icon 176 176 const renderIcon = () => { -
burst-statistics/trunk/src/Admin/Burst_Wp_Cli/class-burst-wp-cli.php
r3296551 r3297409 118 118 } 119 119 120 // remove empty values, and duplicates. 121 $urls = array_filter( 122 $urls, 123 function ( $v ) { 124 return ! empty( $v ); 125 } 126 ); 127 $urls = array_unique( $urls ); 128 // remove keys. 129 $urls = array_values( $urls ); 130 120 131 echo wp_json_encode( $urls, JSON_PRETTY_PRINT ); 121 132 } -
burst-statistics/trunk/src/Admin/Installer/class-installer.php
r3296551 r3297409 76 76 return false; 77 77 } 78 78 79 if ( get_transient( 'burst_plugin_download_active' ) !== $this->slug ) { 79 80 set_transient( 'burst_plugin_download_active', $this->slug, MINUTE_IN_SECONDS ); -
burst-statistics/trunk/src/Admin/Mailer/class-mail-reports.php
r3296551 r3297409 23 23 public function __construct() { 24 24 add_action( 'burst_every_hour', [ $this, 'maybe_send_report' ] ); 25 add_action( 'admin_init', [ $this, 'test_report' ] ); 25 add_action( 'admin_init', [ $this, 'test_report_on_query_var' ] ); 26 add_filter( 'burst_do_action', [ $this, 'send_test_report_action' ], 10, 3 ); 27 } 28 29 /** 30 * User can send a report by clicking the button in the settings page. 31 * 32 * @return array<string, mixed> The modified output array. 33 */ 34 public function send_test_report_action( array $output, string $action, array $data ): array { 35 // phpcs warning fixed. 36 unset( $data ); 37 if ( ! $this->user_can_manage() ) { 38 return $output; 39 } 40 41 if ( $action === 'send_email_report' ) { 42 $this->send_test_report(); 43 $output = [ 44 'success' => true, 45 'message' => __( 'E-mail report sent.', 'burst-statistics' ), 46 ]; 47 } 48 49 return $output; 50 } 51 52 /** 53 * User can add query var burst_test_report to send a report 54 */ 55 public function test_report_on_query_var(): void { 56 // not processing, just checking existence. 57 // phpcs:ignore 58 if ( ! isset( $_GET['burst_test_report'] ) ) { 59 return; 60 } 61 $this->send_test_report(); 26 62 } 27 63 … … 29 65 * Send a test email. 30 66 */ 31 public function test_report(): void { 32 // no formdata processed, only existence check. 33 if ( ! isset( $_GET['burst_test_report'] ) ) { // phpcs:ignore 67 public function send_test_report(): void { 68 if ( ! $this->user_can_manage() ) { 34 69 return; 35 70 } 36 // no formdata processed, only comparison check. 37 $frequency = $_GET['burst_test_report'] === 'monthly' ? 'monthly' : 'weekly'; // phpcs:ignore 71 $frequency = 'weekly'; 38 72 $mailinglist = $this->get_option( 'email_reports_mailinglist' ); 39 $emails = []; 73 $monthly = []; 74 $weekly = []; 40 75 foreach ( $mailinglist as $mailing ) { 41 76 if ( isset( $mailing['email'] ) ) { 42 $emails[] = $mailing['email']; 43 } 44 } 45 $this->send_report( $emails, $frequency ); 77 if ( $mailing['frequency'] === 'monthly' ) { 78 $monthly[] = $mailing['email']; 79 } 80 if ( $mailing['frequency'] === 'weekly' ) { 81 $weekly[] = $mailing['email']; 82 } 83 } 84 } 85 if ( count( $weekly ) > 0 ) { 86 $this->send_report( $weekly, 'weekly' ); 87 } 88 if ( count( $monthly ) > 0 ) { 89 $this->send_report( $monthly, 'monthly' ); 90 } 46 91 } 47 92 … … 90 135 */ 91 136 private function send_report( array $mailinglist, string $frequency = 'weekly' ): void { 92 global $wpdb;93 137 $mailer = new Mailer(); 94 138 $mailer->to = $mailinglist; … … 155 199 } 156 200 201 $compare = $this->get_compare_data( $date_start, $date_end, $compare_date_start, $compare_date_end ); 202 update_option( 'burst_last_report_sent', time(), false ); 203 204 $blocks = []; 205 $blocks[] = [ 206 'title' => __( 'Compare', 'burst-statistics' ), 207 'subtitle' => $frequency === 'weekly' ? __( 'vs. previous week', 'burst-statistics' ) : __( 'vs. previous month', 'burst-statistics' ), 208 'table' => self::format_array_as_table( $compare ), 209 'url' => $this->admin_url( 'burst#/statistics' ), 210 ]; 211 212 $custom_blocks = $this->get_blocks(); 213 foreach ( $custom_blocks as $index => $block ) { 214 $results = $this->get_top_results( $date_start, $date_end, $block['type'] ); 215 $completed_block = [ 216 'title' => $block['title'], 217 'table' => self::format_array_as_table( $results ), 218 'url' => $this->admin_url( 'burst' . $block['url'] ), 219 ]; 220 $custom_blocks[ $index ] = $completed_block; 221 } 222 223 $blocks = array_merge( $blocks, $custom_blocks ); 224 $blocks = apply_filters( 'burst_mail_reports_blocks', $blocks, $date_start, $date_end ); 225 226 $mailer->blocks = $blocks; 227 $attachment_id = $this->get_option( 'logo_attachment_id' ); 228 if ( (int) $attachment_id > 0 ) { 229 $mailer->logo = wp_get_attachment_url( $attachment_id ); 230 } 231 $mailer->send_mail_queue(); 232 } 233 234 /** 235 * Get blocks for the email report. 236 * 237 * @return array<int, array<string, mixed>> List of blocks for the email report. 238 */ 239 public function get_blocks(): array { 240 $blocks = require BURST_PATH . 'src/Admin/Mailer/config/blocks.php'; 241 return apply_filters( 'burst_email_blocks', $blocks ); 242 } 243 244 /** 245 * Get top results for the email report. 246 * 247 * @return array<int, array<int, string>> List of results 248 */ 249 public function get_top_results( int $start_date, int $end_date, string $type ): array { 250 global $wpdb; 251 $metrics = [ 252 $type, 253 'pageviews', 254 ]; 255 $sql = \Burst\burst_loader()->admin->statistics->get_sql_table( 256 $start_date, 257 $end_date, 258 $metrics, 259 [], 260 $type, 261 'pageviews DESC', 262 apply_filters( 'burst_mail_report_limit', 5 ), 263 ); 264 $raw_results = $wpdb->get_results( $sql, ARRAY_A ); 265 266 switch ( $type ) { 267 case 'page_url': 268 $header = __( 'Page', 'burst-statistics' ); 269 break; 270 case 'source': 271 $header = __( 'Campaign', 'burst-statistics' ); 272 break; 273 default: 274 $header = __( 'Referrers', 'burst-statistics' ); 275 break; 276 } 277 278 $results = [ 279 'header' => [ $header, __( 'Pageviews', 'burst-statistics' ) ], 280 ]; 281 282 foreach ( $raw_results as $row ) { 283 if ( $type !== 'referrer' || $row[ $type ] !== 'Direct' ) { 284 $results[] = [ $row[ $type ], $row['pageviews'] ]; 285 } 286 } 287 288 return $results; 289 } 290 291 /** 292 * Get compare data for the email report. 293 * 294 * @return array<int, array<int, string>> List of compare rows grouped by type. 295 */ 296 private function get_compare_data( int $date_start, int $date_end, int $compare_date_start, int $compare_date_end ): array { 157 297 $args = [ 158 298 'date_start' => $date_start, … … 194 334 $compare[] = $this->get_compare_row( $type, $compare_data ); 195 335 } 196 197 $sql = \Burst\burst_loader()->admin->statistics->get_sql_table( 198 $args['date_start'], 199 $args['date_end'], 200 [ 201 'page_url', 202 'pageviews', 203 ], 204 [], 205 'page_url', 206 'pageviews DESC' 207 ); 208 $results = $wpdb->get_results( $sql, ARRAY_A ); 209 210 // max five urls. 211 $results = array_slice( $results, 0, 5 ); 212 213 $urls = [ 214 'header' => [ __( 'Page', 'burst-statistics' ), __( 'Pageviews', 'burst-statistics' ) ], 215 ]; 216 217 foreach ( $results as $index => $row ) { 218 $urls[] = [ $row['page_url'], $row['pageviews'] ]; 219 } 220 $refferers_sql = \Burst\burst_loader()->admin->statistics->get_sql_table( 221 $args['date_start'], 222 $args['date_end'], 223 [ 224 'referrer', 225 'pageviews', 226 ], 227 [], 228 'referrer', 229 'pageviews DESC' 230 ); 231 $refferers_data = $wpdb->get_results( $refferers_sql, ARRAY_A ); 232 233 // max five referrers. 234 $refferers_data = array_slice( $refferers_data, 0, 5 ); 235 236 $referrers = [ 237 'header' => [ __( 'Referrers', 'burst-statistics' ), __( 'Pageviews', 'burst-statistics' ) ], 238 ]; 239 240 foreach ( $refferers_data as $index => $row ) { 241 if ( $row['referrer'] !== 'Direct' ) { 242 $referrers[] = [ $row['referrer'], $row['pageviews'] ]; 243 } 244 } 245 246 update_option( 'burst_last_report_sent', time(), false ); 247 $blocks = [ 248 [ 249 'title' => __( 'Compare', 'burst-statistics' ), 250 'subtitle' => $frequency === 'weekly' ? __( 'vs. previous week', 'burst-statistics' ) : __( 'vs. previous month', 'burst-statistics' ), 251 'table' => self::format_array_as_table( $compare ), 252 'url' => $this->admin_url( 'burst#/statistics' ), 253 ], 254 [ 255 'title' => __( 'Most visited pages', 'burst-statistics' ), 256 'table' => self::format_array_as_table( $urls ), 257 'url' => $this->admin_url( 'burst#/statistics' ), 258 ], 259 [ 260 'title' => __( 'Top referrers', 'burst-statistics' ), 261 'table' => self::format_array_as_table( $referrers ), 262 'url' => $this->admin_url( 'burst#/statistics' ), 263 ], 264 ]; 265 $blocks = apply_filters( 'burst_mail_reports_blocks', $blocks, $args['date_start'], $args['date_end'] ); 266 267 $mailer->blocks = $blocks; 268 $attachment_id = $this->get_option( 'logo_attachment_id' ); 269 if ( (int) $attachment_id > 0 ) { 270 $mailer->logo = wp_get_attachment_url( $attachment_id ); 271 } 272 $mailer->send_mail_queue(); 336 return $compare; 273 337 } 274 338 … … 315 379 * Format an array as an HTML table. 316 380 * 317 * @param array $ table_array The array to format.381 * @param array $input_array The array to format. 318 382 * @return string The formatted HTML table. 319 383 */ 320 public static function format_array_as_table( array $ table_array ): string {384 public static function format_array_as_table( array $input_array ): string { 321 385 $html = ''; 322 if ( isset( $ table_array['header'] ) ) {323 $row = $ table_array['header'];386 if ( isset( $input_array['header'] ) ) { 387 $row = $input_array['header']; 324 388 $html .= '<tr style="line-height: 32px">'; 325 389 $first_row = true; … … 333 397 } 334 398 $html .= '</tr>'; 335 unset( $ table_array['header'] );336 } 337 foreach ( $ table_array as $row ) {399 unset( $input_array['header'] ); 400 } 401 foreach ( $input_array as $row ) { 338 402 $html .= '<tr style="line-height: 32px">'; 339 403 $first_row = true; -
burst-statistics/trunk/src/Admin/Statistics/class-statistics.php
r3296551 r3297409 1635 1635 return 0; 1636 1636 } 1637 1638 1639 1637 1640 1638 /** -
burst-statistics/trunk/src/Admin/class-admin.php
r3296551 r3297409 294 294 do_action( 'burst_activation' ); 295 295 delete_option( 'burst_run_activation' ); 296 $this->tasks->add_initial_tasks();297 296 } 298 297 } … … 403 402 update_option( 'burst_activation_time', time(), false ); 404 403 update_option( 'burst_last_cron_hit', time(), false ); 405 $this->run_table_init_hook(); 404 $this->tasks->add_initial_tasks(); 405 406 406 // tables installed, now set defaults. 407 407 $exclude_roles = $this->get_option( 'user_role_blocklist' ); -
burst-statistics/trunk/src/Frontend/class-frontend.php
r3296551 r3297409 174 174 public function most_visited_posts( 175 175 array $atts = [], 176 string $content = null,176 ?string $content = null, 177 177 string $tag = '' 178 178 ): string { -
burst-statistics/trunk/src/class-burst.php
r3296551 r3297409 53 53 $burst_plugin = implode( '/', $burst_plugin ); 54 54 $debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '#' . time() : ''; 55 define( 'BURST_VERSION', '2.0. 5' . $debug );55 define( 'BURST_VERSION', '2.0.6' . $debug ); 56 56 // deprecated constant. 57 57 //phpcs:ignore
Note: See TracChangeset
for help on using the changeset viewer.