PluginProbe ʕ •ᴥ•ʔ
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin / 3.11.0
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin v3.11.0
4.9.0 0.9.6 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.2 1.7.0 1.7.1 1.8.0 1.8.1 1.9.0 2.0.0 2.0.1 2.1.1 2.2.1 2.3.1 2.4.0 2.5.0 2.5.1 2.6.0 2.7.0 2.8.0 2.9.0 3.0.1 3.0.2 3.0.3 3.1.0 3.10.0 3.11.0 3.11.1 3.2.0 3.2.1 3.3.0 3.4.0 3.5.0 3.5.1 3.5.2 3.6.1 3.7.0 3.8.0 3.8.2 3.9.0 4.0.1 4.1.0 4.1.1 4.2.0 4.3.0 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.8.0 trunk 0.10.0 0.10.1 0.11.1 0.11.2 0.3.1 0.3.2 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.5.2 0.6 0.7 0.8 0.8.2 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 0.9.0 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5
wp-mail-smtp / vendor / woocommerce / action-scheduler / classes / WP_CLI / ProgressBar.php
wp-mail-smtp / vendor / woocommerce / action-scheduler / classes / WP_CLI Last commit date
ActionScheduler_WPCLI_Clean_Command.php 2 years ago ActionScheduler_WPCLI_QueueRunner.php 2 years ago ActionScheduler_WPCLI_Scheduler_command.php 2 years ago Migration_Command.php 2 years ago ProgressBar.php 2 years ago
ProgressBar.php
120 lines
1 <?php
2
3 namespace Action_Scheduler\WP_CLI;
4
5 /**
6 * WP_CLI progress bar for Action Scheduler.
7 */
8
9 /**
10 * Class ProgressBar
11 *
12 * @package Action_Scheduler\WP_CLI
13 *
14 * @since 3.0.0
15 *
16 * @codeCoverageIgnore
17 */
18 class ProgressBar {
19
20 /** @var integer */
21 protected $total_ticks;
22
23 /** @var integer */
24 protected $count;
25
26 /** @var integer */
27 protected $interval;
28
29 /** @var string */
30 protected $message;
31
32 /** @var \cli\progress\Bar */
33 protected $progress_bar;
34
35 /**
36 * ProgressBar constructor.
37 *
38 * @param string $message Text to display before the progress bar.
39 * @param integer $count Total number of ticks to be performed.
40 * @param integer $interval Optional. The interval in milliseconds between updates. Default 100.
41 *
42 * @throws Exception When this is not run within WP CLI
43 */
44 public function __construct( $message, $count, $interval = 100 ) {
45 if ( ! ( defined( 'WP_CLI' ) && WP_CLI ) ) {
46 /* translators: %s php class name */
47 throw new \Exception( sprintf( __( 'The %s class can only be run within WP CLI.', 'action-scheduler' ), __CLASS__ ) );
48 }
49
50 $this->total_ticks = 0;
51 $this->message = $message;
52 $this->count = $count;
53 $this->interval = $interval;
54 }
55
56 /**
57 * Increment the progress bar ticks.
58 */
59 public function tick() {
60 if ( null === $this->progress_bar ) {
61 $this->setup_progress_bar();
62 }
63
64 $this->progress_bar->tick();
65 $this->total_ticks++;
66
67 do_action( 'action_scheduler/progress_tick', $this->total_ticks );
68 }
69
70 /**
71 * Get the progress bar tick count.
72 *
73 * @return int
74 */
75 public function current() {
76 return $this->progress_bar ? $this->progress_bar->current() : 0;
77 }
78
79 /**
80 * Finish the current progress bar.
81 */
82 public function finish() {
83 if ( null !== $this->progress_bar ) {
84 $this->progress_bar->finish();
85 }
86
87 $this->progress_bar = null;
88 }
89
90 /**
91 * Set the message used when creating the progress bar.
92 *
93 * @param string $message The message to be used when the next progress bar is created.
94 */
95 public function set_message( $message ) {
96 $this->message = $message;
97 }
98
99 /**
100 * Set the count for a new progress bar.
101 *
102 * @param integer $count The total number of ticks expected to complete.
103 */
104 public function set_count( $count ) {
105 $this->count = $count;
106 $this->finish();
107 }
108
109 /**
110 * Set up the progress bar.
111 */
112 protected function setup_progress_bar() {
113 $this->progress_bar = \WP_CLI\Utils\make_progress_bar(
114 $this->message,
115 $this->count,
116 $this->interval
117 );
118 }
119 }
120