PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.1.0
GiveWP – Donation Plugin and Fundraising Platform v4.1.0
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / Log / LogServiceProvider.php

LogServiceProvider.php in GiveWP – Donation Plugin and Fundraising Platform 4.1.0, at src/Log/LogServiceProvider.php

82 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Log;
4
5 use Give\Framework\Migrations\MigrationsRegister;
6 use Give\Helpers\Hooks;
7 use Give\Log\Commands\FlushLogsCommand;
8 use Give\Log\Helpers\Environment;
9 use Give\Log\Migrations\CompleteRemovedLegacyLogMigration;
10 use Give\Log\Migrations\CreateNewLogTable;
11 use Give\Log\Migrations\DeleteOldLogTables;
12 use Give\Log\Migrations\MigrateExistingLogs;
13 use Give\Log\Migrations\RemoveSensitiveLogs;
14 use Give\ServiceProviders\ServiceProvider;
15 use WP_CLI;
16
17 /**
18 * Class LogServiceProvider
19 * @package Give\Log
20 *
21 * @since 2.10.0
22 */
23 class LogServiceProvider implements ServiceProvider
24 {
25 /**
26 * @inheritdoc
27 */
28 public function register()
29 {
30 global $wpdb;
31
32 $wpdb->give_log = "{$wpdb->prefix}give_log";
33
34 give()->singleton(Log::class);
35 give()->singleton(LogRepository::class);
36 }
37
38 /**
39 * @inheritdoc
40 */
41 public function boot()
42 {
43 $this->registerMigrations();
44
45 if (defined('WP_CLI') && WP_CLI) {
46 $this->registerCliCommands();
47 }
48
49 Hooks::addAction('give_register_updates', MigrateExistingLogs::class, 'register');
50
51 // Hook up
52 if (Environment::isLogsPage()) {
53 Hooks::addAction('admin_enqueue_scripts', Assets::class, 'enqueueScripts');
54 }
55 }
56
57 /**
58 * Register migration
59 */
60 private function registerMigrations()
61 {
62 give(MigrationsRegister::class)->addMigrations([
63 CreateNewLogTable::class,
64 RemoveSensitiveLogs::class,
65 CompleteRemovedLegacyLogMigration::class
66 ]);
67
68 // Check if Logs migration batch processing is completed
69 if (give_has_upgrade_completed(MigrateExistingLogs::id())) {
70 give(MigrationsRegister::class)->addMigration(DeleteOldLogTables::class);
71 }
72 }
73
74 /**
75 * Register CLI commands
76 */
77 private function registerCliCommands()
78 {
79 WP_CLI::add_command('give flush-logs', give()->make(FlushLogsCommand::class));
80 }
81 }
82