PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.5.1
JetFormBuilder — Dynamic Blocks Form Builder v3.6.5.1
3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / vendor / woocommerce / action-scheduler / classes / WP_CLI / ProgressBar.php
jetformbuilder / vendor / woocommerce / action-scheduler / classes / WP_CLI Last commit date
Action 1 month ago ActionScheduler_WPCLI_Clean_Command.php 1 year ago ActionScheduler_WPCLI_QueueRunner.php 1 year ago ActionScheduler_WPCLI_Scheduler_command.php 1 year ago Action_Command.php 1 year ago Migration_Command.php 1 year ago ProgressBar.php 1 year ago System_Command.php 1 month ago
ProgressBar.php
140 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 /**
21 * Current number of ticks.
22 *
23 * @var integer
24 */
25 protected $total_ticks;
26
27 /**
28 * Total number of ticks.
29 *
30 * @var integer
31 */
32 protected $count;
33
34 /**
35 * Progress bar update interval.
36 *
37 * @var integer
38 */
39 protected $interval;
40
41 /**
42 * Progress bar message.
43 *
44 * @var string
45 */
46 protected $message;
47
48 /**
49 * Instance.
50 *
51 * @var \cli\progress\Bar
52 */
53 protected $progress_bar;
54
55 /**
56 * ProgressBar constructor.
57 *
58 * @param string $message Text to display before the progress bar.
59 * @param integer $count Total number of ticks to be performed.
60 * @param integer $interval Optional. The interval in milliseconds between updates. Default 100.
61 *
62 * @throws \Exception When this is not run within WP CLI.
63 */
64 public function __construct( $message, $count, $interval = 100 ) {
65 if ( ! ( defined( 'WP_CLI' ) && WP_CLI ) ) {
66 /* translators: %s php class name */
67 throw new \Exception( sprintf( __( 'The %s class can only be run within WP CLI.', 'action-scheduler' ), __CLASS__ ) );
68 }
69
70 $this->total_ticks = 0;
71 $this->message = $message;
72 $this->count = $count;
73 $this->interval = $interval;
74 }
75
76 /**
77 * Increment the progress bar ticks.
78 */
79 public function tick() {
80 if ( null === $this->progress_bar ) {
81 $this->setup_progress_bar();
82 }
83
84 $this->progress_bar->tick();
85 $this->total_ticks++;
86
87 do_action( 'action_scheduler/progress_tick', $this->total_ticks ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
88 }
89
90 /**
91 * Get the progress bar tick count.
92 *
93 * @return int
94 */
95 public function current() {
96 return $this->progress_bar ? $this->progress_bar->current() : 0;
97 }
98
99 /**
100 * Finish the current progress bar.
101 */
102 public function finish() {
103 if ( null !== $this->progress_bar ) {
104 $this->progress_bar->finish();
105 }
106
107 $this->progress_bar = null;
108 }
109
110 /**
111 * Set the message used when creating the progress bar.
112 *
113 * @param string $message The message to be used when the next progress bar is created.
114 */
115 public function set_message( $message ) {
116 $this->message = $message;
117 }
118
119 /**
120 * Set the count for a new progress bar.
121 *
122 * @param integer $count The total number of ticks expected to complete.
123 */
124 public function set_count( $count ) {
125 $this->count = $count;
126 $this->finish();
127 }
128
129 /**
130 * Set up the progress bar.
131 */
132 protected function setup_progress_bar() {
133 $this->progress_bar = \WP_CLI\Utils\make_progress_bar(
134 $this->message,
135 $this->count,
136 $this->interval
137 );
138 }
139 }
140