PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 4.3.0
WP STAGING – WordPress Backup, Restore, Migration & Clone v4.3.0
4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Framework / CommonServiceProvider.php
wp-staging / Framework Last commit date
Adapter 11 months ago Analytics 10 months ago Assets 10 months ago BackgroundProcessing 11 months ago CloningProcess 1 year ago Collection 3 years ago Command 5 years ago Component 2 years ago DI 1 year ago Database 11 months ago DependencyResolver 2 years ago Exceptions 2 years ago Facades 1 year ago Filesystem 10 months ago Interfaces 5 years ago Job 10 months ago Language 1 year ago Logger 11 months ago Mails 1 year ago Network 11 months ago Newsfeed 10 months ago Notices 11 months ago Performance 1 year ago Permalinks 11 months ago Queue 1 year ago Rest 1 year ago Security 11 months ago Settings 1 year ago TemplateEngine 11 months ago ThirdParty 1 year ago Traits 10 months ago Utils 10 months ago AnalyticsServiceProvider.php 11 months ago AssetServiceProvider.php 1 year ago CommonServiceProvider.php 11 months ago ErrorHandler.php 2 years ago NoticeServiceProvider.php 11 months ago SettingsServiceProvider.php 2 years ago SiteInfo.php 11 months ago Url.php 3 years ago
CommonServiceProvider.php
93 lines
1 <?php
2
3 namespace WPStaging\Framework;
4
5 use WPStaging\Core\Cron\Cron;
6 use WPStaging\Framework\Analytics\AnalyticsCleanup;
7 use WPStaging\Framework\DI\ServiceProvider;
8 use WPStaging\Framework\Filesystem\DebugLogReader;
9 use WPStaging\Framework\Filesystem\DiskWriteCheck;
10 use WPStaging\Framework\Filesystem\LogCleanup;
11 use WPStaging\Framework\Mails\MailSender;
12 use WPStaging\Framework\Notices\BackupPluginsNotice;
13 use WPStaging\Framework\Performance\MemoryExhaust;
14 use WPStaging\Framework\Security\Otp\Otp;
15 use WPStaging\Framework\Settings\DarkMode;
16 use WPStaging\Framework\Traits\EventLoggerTrait;
17 use WPStaging\Framework\Utils\DBPermissions;
18 use WPStaging\Staging\Ajax\StagingSiteDataChecker;
19
20 /**
21 * Class CommonServiceProvider
22 *
23 * A Service Provider for binds common to both Free and Pro.
24 *
25 * @package WPStaging\Framework
26 */
27 class CommonServiceProvider extends ServiceProvider
28 {
29 use EventLoggerTrait;
30
31 protected function registerClasses()
32 {
33 $this->container->singleton(DiskWriteCheck::class);
34 $this->container->make(DebugLogReader::class)->listenDeleteLogRequest();
35
36 add_action(Cron::ACTION_DAILY_EVENT, [$this, 'cleanupLogs'], 25, 0);
37 add_action(Cron::ACTION_DAILY_EVENT, [$this, 'cleanupAnalytics'], 25, 0);
38 add_action(Cron::ACTION_DAILY_EVENT, [$this, 'cleanupExpiredOtps'], 25, 0);
39 add_action("wp_ajax_wpstg_is_writable_clone_destination_dir", $this->container->callback(StagingSiteDataChecker::class, "ajaxIsWritableCloneDestinationDir")); // phpcs:ignore WPStaging.Security.AuthorizationChecked
40 add_action("wp_ajax_wpstg_check_user_permissions", $this->container->callback(DBPermissions::class, 'ajaxCheckDBPermissions')); // phpcs:ignore WPStaging.Security.AuthorizationChecked
41 add_action("wp_ajax_wpstg_check_user_is_authenticated", [$this, "ajaxIsUserAuthenticated"]);// phpcs:ignore WPStaging.Security.AuthorizationChecked
42 add_action("wp_ajax_nopriv_wpstg_check_user_is_authenticated", [$this, "ajaxIsUserAuthenticated"]);// phpcs:ignore WPStaging.Security.AuthorizationChecked
43 add_action('wp_ajax_wpstg_backup_plugin_notice_close', $this->container->callback(BackupPluginsNotice::class, 'ajaxBackupPluginNoticeClose')); // phpcs:ignore WPStaging.Security.AuthorizationChecked
44 add_action('wp_ajax_wpstg_backup_plugin_notice_remind_me', $this->container->callback(BackupPluginsNotice::class, 'ajaxBackupPluginNoticeRemindMe')); // phpcs:ignore WPStaging.Security.AuthorizationChecked
45 add_action('admin_init', $this->container->callback(DarkMode::class, 'mayBeShowDarkMode'), 10, 1);
46 add_action('wp_ajax_wpstg_set_dark_mode', $this->container->callback(DarkMode::class, 'ajaxEnableDefaultColorMode')); // phpcs:ignore WPStaging.Security.AuthorizationChecked
47 add_action('wp_ajax_wpstg_set_default_os_color_mode', $this->container->callback(DarkMode::class, 'ajaxSetDefaultOsMode')); // phpcs:ignore WPStaging.Security.AuthorizationChecked
48 add_action("wp_ajax_wpstg_log_event_failure", [$this, "ajaxLogEventFailure"]); // phpcs:ignore WPStaging.Security.AuthorizationChecked
49 add_action("wp_ajax_nopriv_wpstg_log_event_failure", [$this, "ajaxLogEventFailure"]); // phpcs:ignore WPStaging.Security.AuthorizationChecked
50 add_action('wp_ajax_wpstg--detect-memory-exhaust', $this->container->callback(MemoryExhaust::class, 'ajaxResponse')); // phpcs:ignore WPStaging.Security.AuthorizationChecked
51 add_action("wp_ajax_wpstg_log_event_success", [$this, "ajaxLogEventSuccess"]); // phpcs:ignore WPStaging.Security.AuthorizationChecked
52 add_action("wp_ajax_nopriv_wpstg_log_event_success", [$this, "ajaxLogEventSuccess"]); // phpcs:ignore WPStaging.Security.AuthorizationChecked
53 add_action('wp_ajax_wpstg_send_mail_notification', $this->container->callback(MailSender::class, 'ajaxSendEmailNotification')); // phpcs:ignore WPStaging.Security.AuthorizationChecked
54 add_action('wp_ajax_nopriv_wpstg_send_mail_notification', $this->container->callback(MailSender::class, 'ajaxSendEmailNotification')); // phpcs:ignore WPStaging.Security.AuthorizationChecked
55 }
56
57 /**
58 * @return void
59 */
60 public function cleanupLogs()
61 {
62 $this->container->make(LogCleanup::class)->cleanOldLogs();
63 }
64
65 /**
66 * @return void
67 */
68 public function cleanupAnalytics()
69 {
70 $this->container->make(AnalyticsCleanup::class)->cleanupOldAnalytics();
71 }
72
73 /**
74 * @return void
75 */
76 public function cleanupExpiredOtps()
77 {
78 $this->container->make(Otp::class)->cleanupExpiredOtps();
79 }
80
81 /**
82 * @return void
83 */
84 public function ajaxIsUserAuthenticated()
85 {
86 if (!is_user_logged_in()) {
87 wp_send_json(['wpAuthCheck' => false, 'redirectUrl' => wp_login_url()]);
88 }
89
90 wp_send_json(['wpAuthCheck' => true]);
91 }
92 }
93