PluginProbe
AliNext – WooCommerce Dropshipping Plugin for AliExpress / trunk
AliNext – WooCommerce Dropshipping Plugin for AliExpress vtrunk
ali2woo-lite / includes / classes / service / PermanentAlertService.php

PermanentAlertService.php in AliNext – WooCommerce Dropshipping Plugin for AliExpress trunk, at includes/classes/service/PermanentAlertService.php

59 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 /**
4 * Description of PermanentAlert
5 *
6 * @author Ali2Woo Team
7 */
8
9 namespace AliNext_Lite;;
10
11 class PermanentAlertService
12 {
13
14 public function __construct(protected BackgroundProcessFactory $BackgroundProcessFactory)
15 {}
16
17 /**
18 * @return array|PermanentAlert[]
19 */
20 public function getAll(): array
21 {
22 $PermanentAlerts = [];
23
24 foreach ($this->BackgroundProcessFactory->getAll() as $BackgroundProcess) {
25 if ($BackgroundProcess->isQueued()) {
26 $count = $BackgroundProcess->getSize();
27 $helpButtonText = esc_html__('Cancel it', 'ali2woo');
28 $helpButtonHtml = sprintf(
29 /* translators: %s is replaced with a process name */
30 '<a class="cancel-process" data-process="%s" href="#">%s</a>',
31 $BackgroundProcess->getName(),
32 $helpButtonText
33 );
34
35 $pushButtonText = esc_html__('Push manually', 'ali2woo');
36 $pushButtonHtml = sprintf(
37 /* translators: %s is replaced with a process name */
38 '<a class="push-process" data-process="%s" href="#">%s</a>',
39 $BackgroundProcess->getName(),
40 $pushButtonText
41 );
42
43 $content = sprintf(
44 /* translators: %s is replaced with a process name, %d is replaced count of tasks of given process, %s is replaced with cancel button html */
45 'Currently, you have an active and running <strong>%s</strong> process with %d task(s) remaining. Actions: %s | %s',
46 $BackgroundProcess->getTitle(),
47 $count,
48 $pushButtonHtml,
49 $helpButtonHtml
50 );
51
52 $PermanentAlerts[] = new PermanentAlert($content, PermanentAlert::TYPE_INFO);
53 }
54 }
55
56 return apply_filters('a2wl_get_permanent_alerts', $PermanentAlerts);
57 }
58 }
59