PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.21.0
GiveWP – Donation Plugin and Fundraising Platform v2.21.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 2.21.0, at src/Log/LogServiceProvider.php

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