Completed
Pull Request — develop (#1698)
by
unknown
01:26
created
src/wordlift/tasks/class-task-single-instance-task-runner.php 2 patches
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -24,196 +24,196 @@
 block discarded – undo
24 24
  */
25 25
 class Task_Single_Instance_Task_Runner {
26 26
 
27
-	/**
28
-	 * Define the transient prefix.
29
-	 *
30
-	 * @since 1.0.0
31
-	 */
32
-	const IS_RUNNING_PREFIX = '_wf_task_runner__';
33
-
34
-	/**
35
-	 * A {@link Wordlift_Log_Service} instance.
36
-	 *
37
-	 * @since 1.0.0
38
-	 * @var Wordlift_Log_Service A {@link Wordlift_Log_Service} instance.
39
-	 * @access private
40
-	 */
41
-	private $log;
42
-
43
-	/**
44
-	 * The {@link Task} to execute.
45
-	 *
46
-	 * @since 1.0.0
47
-	 * @var Task $task The {@link Task} to execute.
48
-	 * @access private
49
-	 */
50
-	private $task;
51
-
52
-	/**
53
-	 * One or more callbacks to call to update about the task progress.
54
-	 *
55
-	 * @since 1.0.0
56
-	 * @var Task_Progress[] $callbacks An array of {@link Wordlift_For_Bungalowparkoverzicht_Progress}.
57
-	 * @access private
58
-	 */
59
-	private $callbacks;
60
-
61
-	/**
62
-	 * Whether to force starting a task even if another instance of the task is already running.
63
-	 *
64
-	 * @since 1.0.0
65
-	 * @var bool $force Whether to force starting a task even if another instance of the task is already running.
66
-	 * @access private
67
-	 */
68
-	private $force;
69
-
70
-	/**
71
-	 * Create a {@link Task_Single_Instance_Task_Runner} instance.
72
-	 *
73
-	 * @param Task  $task The {@link Task} instance.
74
-	 * @param bool  $force Whether to force starting a task even if another instance of the task is already running, default `false`.
75
-	 * @param array $callbacks An array of {@link Wordlift_For_Bungalowparkoverzicht_Progress}.
76
-	 *
77
-	 * @since 1.0.0
78
-	 */
79
-	public function __construct( $task, $force = false, $callbacks = array() ) {
80
-
81
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
82
-
83
-		$this->task      = $task;
84
-		$this->force     = $force;
85
-		$this->callbacks = $callbacks;
86
-
87
-	}
88
-
89
-	/**
90
-	 * Get the transient name for running flag.
91
-	 *
92
-	 * @return string The transient name.
93
-	 * @since 1.0.0
94
-	 */
95
-	private function get_running_transient() {
96
-
97
-		return self::IS_RUNNING_PREFIX . $this->task->get_id();
98
-	}
99
-
100
-	/**
101
-	 * Check whether a task is running.
102
-	 *
103
-	 * @return bool
104
-	 * @since 1.0.0
105
-	 */
106
-	public function is_running() {
107
-		return 'yes' === get_transient( $this->get_running_transient() );
108
-	}
109
-
110
-	/**
111
-	 * Set whether the task is running or not.
112
-	 *
113
-	 * @param bool $value Whether the task is running or not.
114
-	 *
115
-	 * @since 1.0.0
116
-	 */
117
-	public function set_running( $value ) {
118
-		set_transient( $this->get_running_transient(), $value ? 'yes' : 'no' );
119
-	}
120
-
121
-	/**
122
-	 * Start the task.
123
-	 *
124
-	 * @param int $limit The maximum number of items to process.
125
-	 * @param int $offset The starting offset.
126
-	 *
127
-	 * @throws Task_Another_Instance_Is_Running_Exception if the task is already running.
128
-	 * @since 1.0.0
129
-	 */
130
-	public function start( $limit = 0, $offset = 0 ) {
131
-
132
-		// Bail out if the task is already running.
133
-		if ( ! $this->force && $this->is_running() ) {
134
-			throw new Task_Another_Instance_Is_Running_Exception();
135
-		}
136
-
137
-		// Set the task as running.
138
-		$this->set_running( true );
139
-
140
-		// List the chunk of elements to process.
141
-		$items = $this->task->list_items( $limit, $offset );
142
-
143
-		$count = count( $items );
144
-		for ( $i = 0; $i < $count; $i ++ ) {
145
-			// Process the item.
146
-			$this->task->process_item( $items[ $i ] );
147
-
148
-			// Update the progress.
149
-			$this->set_progress( $offset + $i, $items[ $i ] );
150
-		}
151
-
152
-		// Set the total number of elements to process.
153
-		$this->set_count( $this->task->count_items() );
154
-
155
-		// Unset the running flag.
156
-		$this->set_running( false );
157
-
158
-		// Set the task to complete.
159
-		$this->finish();
160
-
161
-	}
162
-
163
-	/**
164
-	 * Set the total number of items to process.
165
-	 *
166
-	 * @param int $value The total number of items to process.
167
-	 *
168
-	 * @since 1.0.0
169
-	 */
170
-	private function set_count( $value ) {
171
-
172
-		if ( empty( $this->callbacks ) ) {
173
-			return;
174
-		}
175
-
176
-		foreach ( $this->callbacks as $callback ) {
177
-			call_user_func( array( $callback, 'set_count' ), $value );
178
-		}
179
-
180
-	}
181
-
182
-	/**
183
-	 * Set the task progress.
184
-	 *
185
-	 * @param int   $index The current item index.
186
-	 * @param mixed $item The current item.
187
-	 *
188
-	 * @since 1.0.0
189
-	 */
190
-	private function set_progress( $index, $item ) {
191
-
192
-		if ( empty( $this->callbacks ) ) {
193
-			return;
194
-		}
195
-
196
-		foreach ( $this->callbacks as $callback ) {
197
-			call_user_func( array( $callback, 'set_progress' ), $index, $item );
198
-		}
199
-
200
-	}
201
-
202
-	/**
203
-	 * Inform the callbacks that the task completed.
204
-	 *
205
-	 * @since 1.0.0
206
-	 */
207
-	private function finish() {
208
-
209
-		if ( empty( $this->callbacks ) ) {
210
-			return;
211
-		}
212
-
213
-		foreach ( $this->callbacks as $callback ) {
214
-			call_user_func( array( $callback, 'finish' ) );
215
-		}
216
-
217
-	}
27
+    /**
28
+     * Define the transient prefix.
29
+     *
30
+     * @since 1.0.0
31
+     */
32
+    const IS_RUNNING_PREFIX = '_wf_task_runner__';
33
+
34
+    /**
35
+     * A {@link Wordlift_Log_Service} instance.
36
+     *
37
+     * @since 1.0.0
38
+     * @var Wordlift_Log_Service A {@link Wordlift_Log_Service} instance.
39
+     * @access private
40
+     */
41
+    private $log;
42
+
43
+    /**
44
+     * The {@link Task} to execute.
45
+     *
46
+     * @since 1.0.0
47
+     * @var Task $task The {@link Task} to execute.
48
+     * @access private
49
+     */
50
+    private $task;
51
+
52
+    /**
53
+     * One or more callbacks to call to update about the task progress.
54
+     *
55
+     * @since 1.0.0
56
+     * @var Task_Progress[] $callbacks An array of {@link Wordlift_For_Bungalowparkoverzicht_Progress}.
57
+     * @access private
58
+     */
59
+    private $callbacks;
60
+
61
+    /**
62
+     * Whether to force starting a task even if another instance of the task is already running.
63
+     *
64
+     * @since 1.0.0
65
+     * @var bool $force Whether to force starting a task even if another instance of the task is already running.
66
+     * @access private
67
+     */
68
+    private $force;
69
+
70
+    /**
71
+     * Create a {@link Task_Single_Instance_Task_Runner} instance.
72
+     *
73
+     * @param Task  $task The {@link Task} instance.
74
+     * @param bool  $force Whether to force starting a task even if another instance of the task is already running, default `false`.
75
+     * @param array $callbacks An array of {@link Wordlift_For_Bungalowparkoverzicht_Progress}.
76
+     *
77
+     * @since 1.0.0
78
+     */
79
+    public function __construct( $task, $force = false, $callbacks = array() ) {
80
+
81
+        $this->log = Wordlift_Log_Service::get_logger( get_class() );
82
+
83
+        $this->task      = $task;
84
+        $this->force     = $force;
85
+        $this->callbacks = $callbacks;
86
+
87
+    }
88
+
89
+    /**
90
+     * Get the transient name for running flag.
91
+     *
92
+     * @return string The transient name.
93
+     * @since 1.0.0
94
+     */
95
+    private function get_running_transient() {
96
+
97
+        return self::IS_RUNNING_PREFIX . $this->task->get_id();
98
+    }
99
+
100
+    /**
101
+     * Check whether a task is running.
102
+     *
103
+     * @return bool
104
+     * @since 1.0.0
105
+     */
106
+    public function is_running() {
107
+        return 'yes' === get_transient( $this->get_running_transient() );
108
+    }
109
+
110
+    /**
111
+     * Set whether the task is running or not.
112
+     *
113
+     * @param bool $value Whether the task is running or not.
114
+     *
115
+     * @since 1.0.0
116
+     */
117
+    public function set_running( $value ) {
118
+        set_transient( $this->get_running_transient(), $value ? 'yes' : 'no' );
119
+    }
120
+
121
+    /**
122
+     * Start the task.
123
+     *
124
+     * @param int $limit The maximum number of items to process.
125
+     * @param int $offset The starting offset.
126
+     *
127
+     * @throws Task_Another_Instance_Is_Running_Exception if the task is already running.
128
+     * @since 1.0.0
129
+     */
130
+    public function start( $limit = 0, $offset = 0 ) {
131
+
132
+        // Bail out if the task is already running.
133
+        if ( ! $this->force && $this->is_running() ) {
134
+            throw new Task_Another_Instance_Is_Running_Exception();
135
+        }
136
+
137
+        // Set the task as running.
138
+        $this->set_running( true );
139
+
140
+        // List the chunk of elements to process.
141
+        $items = $this->task->list_items( $limit, $offset );
142
+
143
+        $count = count( $items );
144
+        for ( $i = 0; $i < $count; $i ++ ) {
145
+            // Process the item.
146
+            $this->task->process_item( $items[ $i ] );
147
+
148
+            // Update the progress.
149
+            $this->set_progress( $offset + $i, $items[ $i ] );
150
+        }
151
+
152
+        // Set the total number of elements to process.
153
+        $this->set_count( $this->task->count_items() );
154
+
155
+        // Unset the running flag.
156
+        $this->set_running( false );
157
+
158
+        // Set the task to complete.
159
+        $this->finish();
160
+
161
+    }
162
+
163
+    /**
164
+     * Set the total number of items to process.
165
+     *
166
+     * @param int $value The total number of items to process.
167
+     *
168
+     * @since 1.0.0
169
+     */
170
+    private function set_count( $value ) {
171
+
172
+        if ( empty( $this->callbacks ) ) {
173
+            return;
174
+        }
175
+
176
+        foreach ( $this->callbacks as $callback ) {
177
+            call_user_func( array( $callback, 'set_count' ), $value );
178
+        }
179
+
180
+    }
181
+
182
+    /**
183
+     * Set the task progress.
184
+     *
185
+     * @param int   $index The current item index.
186
+     * @param mixed $item The current item.
187
+     *
188
+     * @since 1.0.0
189
+     */
190
+    private function set_progress( $index, $item ) {
191
+
192
+        if ( empty( $this->callbacks ) ) {
193
+            return;
194
+        }
195
+
196
+        foreach ( $this->callbacks as $callback ) {
197
+            call_user_func( array( $callback, 'set_progress' ), $index, $item );
198
+        }
199
+
200
+    }
201
+
202
+    /**
203
+     * Inform the callbacks that the task completed.
204
+     *
205
+     * @since 1.0.0
206
+     */
207
+    private function finish() {
208
+
209
+        if ( empty( $this->callbacks ) ) {
210
+            return;
211
+        }
212
+
213
+        foreach ( $this->callbacks as $callback ) {
214
+            call_user_func( array( $callback, 'finish' ) );
215
+        }
216
+
217
+    }
218 218
 
219 219
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @since 1.0.0
78 78
 	 */
79
-	public function __construct( $task, $force = false, $callbacks = array() ) {
79
+	public function __construct($task, $force = false, $callbacks = array()) {
80 80
 
81
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
81
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
82 82
 
83 83
 		$this->task      = $task;
84 84
 		$this->force     = $force;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	private function get_running_transient() {
96 96
 
97
-		return self::IS_RUNNING_PREFIX . $this->task->get_id();
97
+		return self::IS_RUNNING_PREFIX.$this->task->get_id();
98 98
 	}
99 99
 
100 100
 	/**
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @since 1.0.0
105 105
 	 */
106 106
 	public function is_running() {
107
-		return 'yes' === get_transient( $this->get_running_transient() );
107
+		return 'yes' === get_transient($this->get_running_transient());
108 108
 	}
109 109
 
110 110
 	/**
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @since 1.0.0
116 116
 	 */
117
-	public function set_running( $value ) {
118
-		set_transient( $this->get_running_transient(), $value ? 'yes' : 'no' );
117
+	public function set_running($value) {
118
+		set_transient($this->get_running_transient(), $value ? 'yes' : 'no');
119 119
 	}
120 120
 
121 121
 	/**
@@ -127,33 +127,33 @@  discard block
 block discarded – undo
127 127
 	 * @throws Task_Another_Instance_Is_Running_Exception if the task is already running.
128 128
 	 * @since 1.0.0
129 129
 	 */
130
-	public function start( $limit = 0, $offset = 0 ) {
130
+	public function start($limit = 0, $offset = 0) {
131 131
 
132 132
 		// Bail out if the task is already running.
133
-		if ( ! $this->force && $this->is_running() ) {
133
+		if ( ! $this->force && $this->is_running()) {
134 134
 			throw new Task_Another_Instance_Is_Running_Exception();
135 135
 		}
136 136
 
137 137
 		// Set the task as running.
138
-		$this->set_running( true );
138
+		$this->set_running(true);
139 139
 
140 140
 		// List the chunk of elements to process.
141
-		$items = $this->task->list_items( $limit, $offset );
141
+		$items = $this->task->list_items($limit, $offset);
142 142
 
143
-		$count = count( $items );
144
-		for ( $i = 0; $i < $count; $i ++ ) {
143
+		$count = count($items);
144
+		for ($i = 0; $i < $count; $i++) {
145 145
 			// Process the item.
146
-			$this->task->process_item( $items[ $i ] );
146
+			$this->task->process_item($items[$i]);
147 147
 
148 148
 			// Update the progress.
149
-			$this->set_progress( $offset + $i, $items[ $i ] );
149
+			$this->set_progress($offset + $i, $items[$i]);
150 150
 		}
151 151
 
152 152
 		// Set the total number of elements to process.
153
-		$this->set_count( $this->task->count_items() );
153
+		$this->set_count($this->task->count_items());
154 154
 
155 155
 		// Unset the running flag.
156
-		$this->set_running( false );
156
+		$this->set_running(false);
157 157
 
158 158
 		// Set the task to complete.
159 159
 		$this->finish();
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @since 1.0.0
169 169
 	 */
170
-	private function set_count( $value ) {
170
+	private function set_count($value) {
171 171
 
172
-		if ( empty( $this->callbacks ) ) {
172
+		if (empty($this->callbacks)) {
173 173
 			return;
174 174
 		}
175 175
 
176
-		foreach ( $this->callbacks as $callback ) {
177
-			call_user_func( array( $callback, 'set_count' ), $value );
176
+		foreach ($this->callbacks as $callback) {
177
+			call_user_func(array($callback, 'set_count'), $value);
178 178
 		}
179 179
 
180 180
 	}
@@ -187,14 +187,14 @@  discard block
 block discarded – undo
187 187
 	 *
188 188
 	 * @since 1.0.0
189 189
 	 */
190
-	private function set_progress( $index, $item ) {
190
+	private function set_progress($index, $item) {
191 191
 
192
-		if ( empty( $this->callbacks ) ) {
192
+		if (empty($this->callbacks)) {
193 193
 			return;
194 194
 		}
195 195
 
196
-		foreach ( $this->callbacks as $callback ) {
197
-			call_user_func( array( $callback, 'set_progress' ), $index, $item );
196
+		foreach ($this->callbacks as $callback) {
197
+			call_user_func(array($callback, 'set_progress'), $index, $item);
198 198
 		}
199 199
 
200 200
 	}
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	private function finish() {
208 208
 
209
-		if ( empty( $this->callbacks ) ) {
209
+		if (empty($this->callbacks)) {
210 210
 			return;
211 211
 		}
212 212
 
213
-		foreach ( $this->callbacks as $callback ) {
214
-			call_user_func( array( $callback, 'finish' ) );
213
+		foreach ($this->callbacks as $callback) {
214
+			call_user_func(array($callback, 'finish'));
215 215
 		}
216 216
 
217 217
 	}
Please login to merge, or discard this patch.
src/wordlift/tasks/admin/class-tasks-page-base.php 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -17,77 +17,77 @@
 block discarded – undo
17 17
 
18 18
 abstract class Tasks_Page_Base extends Submenu_Page_Base {
19 19
 
20
-	/**
21
-	 * The ID of this admin page.
22
-	 *
23
-	 * @since    1.0.0
24
-	 * @access   private
25
-	 * @var      string $menu_slug The ID of this page.
26
-	 */
27
-	private $menu_slug;
20
+    /**
21
+     * The ID of this admin page.
22
+     *
23
+     * @since    1.0.0
24
+     * @access   private
25
+     * @var      string $menu_slug The ID of this page.
26
+     */
27
+    private $menu_slug;
28 28
 
29
-	/**
30
-	 * @var Task_Ajax_Adapters_Registry
31
-	 */
32
-	private $task_ajax_adapters_registry;
29
+    /**
30
+     * @var Task_Ajax_Adapters_Registry
31
+     */
32
+    private $task_ajax_adapters_registry;
33 33
 
34
-	/**
35
-	 * @var string
36
-	 */
37
-	private $version;
34
+    /**
35
+     * @var string
36
+     */
37
+    private $version;
38 38
 
39
-	/**
40
-	 * Define the {@link Wordlift_Admin_Page} constructor.
41
-	 *
42
-	 * @param Task_Ajax_Adapters_Registry $task_ajax_adapters_registry
43
-	 *
44
-	 * @param string                      $version
45
-	 * @param string                      $menu_slug
46
-	 * @param string                      $page_title
47
-	 * @param string                      $capability
48
-	 * @param string|null                 $parent_slug
49
-	 * @param string|null                 $menu_title
50
-	 *
51
-	 * @since 1.0.0
52
-	 */
53
-	public function __construct( $task_ajax_adapters_registry, $version, $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null ) {
54
-		parent::__construct( $menu_slug, $page_title, $capability, $parent_slug, $menu_title );
39
+    /**
40
+     * Define the {@link Wordlift_Admin_Page} constructor.
41
+     *
42
+     * @param Task_Ajax_Adapters_Registry $task_ajax_adapters_registry
43
+     *
44
+     * @param string                      $version
45
+     * @param string                      $menu_slug
46
+     * @param string                      $page_title
47
+     * @param string                      $capability
48
+     * @param string|null                 $parent_slug
49
+     * @param string|null                 $menu_title
50
+     *
51
+     * @since 1.0.0
52
+     */
53
+    public function __construct( $task_ajax_adapters_registry, $version, $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null ) {
54
+        parent::__construct( $menu_slug, $page_title, $capability, $parent_slug, $menu_title );
55 55
 
56
-		$this->task_ajax_adapters_registry = $task_ajax_adapters_registry;
57
-		$this->version                     = $version;
58
-		$this->menu_slug                   = $menu_slug;
56
+        $this->task_ajax_adapters_registry = $task_ajax_adapters_registry;
57
+        $this->version                     = $version;
58
+        $this->menu_slug                   = $menu_slug;
59 59
 
60
-	}
60
+    }
61 61
 
62
-	/**
63
-	 * Register the stylesheets and scripts for the admin area.
64
-	 *
65
-	 * @since    1.0.0
66
-	 */
67
-	public function enqueue_scripts() {
68
-		wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->version, 'all' );
69
-		wp_enqueue_script(
70
-			$this->menu_slug,
71
-			plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js',
72
-			array(
73
-				'jquery',
74
-				'wp-util',
75
-			),
76
-			$this->version,
77
-			true
78
-		);
79
-	}
62
+    /**
63
+     * Register the stylesheets and scripts for the admin area.
64
+     *
65
+     * @since    1.0.0
66
+     */
67
+    public function enqueue_scripts() {
68
+        wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->version, 'all' );
69
+        wp_enqueue_script(
70
+            $this->menu_slug,
71
+            plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js',
72
+            array(
73
+                'jquery',
74
+                'wp-util',
75
+            ),
76
+            $this->version,
77
+            true
78
+        );
79
+    }
80 80
 
81
-	/**
82
-	 * Render the page.
83
-	 *
84
-	 * @since 1.0.0
85
-	 */
86
-	public function render() {
81
+    /**
82
+     * Render the page.
83
+     *
84
+     * @since 1.0.0
85
+     */
86
+    public function render() {
87 87
 
88
-		// Include the partial.
89
-		include plugin_dir_path( __FILE__ ) . 'assets/tasks-page.php';
88
+        // Include the partial.
89
+        include plugin_dir_path( __FILE__ ) . 'assets/tasks-page.php';
90 90
 
91
-	}
91
+    }
92 92
 
93 93
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @since 1.0.0
52 52
 	 */
53
-	public function __construct( $task_ajax_adapters_registry, $version, $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null ) {
54
-		parent::__construct( $menu_slug, $page_title, $capability, $parent_slug, $menu_title );
53
+	public function __construct($task_ajax_adapters_registry, $version, $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null) {
54
+		parent::__construct($menu_slug, $page_title, $capability, $parent_slug, $menu_title);
55 55
 
56 56
 		$this->task_ajax_adapters_registry = $task_ajax_adapters_registry;
57 57
 		$this->version                     = $version;
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
 	 * @since    1.0.0
66 66
 	 */
67 67
 	public function enqueue_scripts() {
68
-		wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->version, 'all' );
68
+		wp_enqueue_style($this->menu_slug, plugin_dir_url(__FILE__).'assets/tasks-page.css', array(), $this->version, 'all');
69 69
 		wp_enqueue_script(
70 70
 			$this->menu_slug,
71
-			plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js',
71
+			plugin_dir_url(__FILE__).'assets/tasks-page.js',
72 72
 			array(
73 73
 				'jquery',
74 74
 				'wp-util',
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	public function render() {
87 87
 
88 88
 		// Include the partial.
89
-		include plugin_dir_path( __FILE__ ) . 'assets/tasks-page.php';
89
+		include plugin_dir_path(__FILE__).'assets/tasks-page.php';
90 90
 
91 91
 	}
92 92
 
Please login to merge, or discard this patch.
src/wordlift/tasks/admin/assets/tasks-page.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
 
15 15
 	<?php
16 16
     // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
17
-	foreach ( $this->task_ajax_adapters_registry->get_task_ajax_adapters() as $task_ajax_adapter ) {
18
-		$task = $task_ajax_adapter->get_task();
19
-		?>
17
+    foreach ( $this->task_ajax_adapters_registry->get_task_ajax_adapters() as $task_ajax_adapter ) {
18
+        $task = $task_ajax_adapter->get_task();
19
+        ?>
20 20
 		<div class="wl-task">
21 21
 			<h2><?php esc_html( $task->get_label() ); ?></h2>
22 22
 			<div class="wl-task__progress" style="border: 1px solid #23282D; height: 20px; margin: 8px 0;">
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 		</div>
35 35
 		<?php
36
-	}
37
-	?>
36
+    }
37
+    ?>
38 38
 
39 39
 </div>
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@  discard block
 block discarded – undo
10 10
 
11 11
 ?>
12 12
 <div class="wrap">
13
-	<h1><?php esc_html_e( 'Tasks', 'wordlift' ); ?></h1>
13
+	<h1><?php esc_html_e('Tasks', 'wordlift'); ?></h1>
14 14
 
15 15
 	<?php
16 16
     // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
17
-	foreach ( $this->task_ajax_adapters_registry->get_task_ajax_adapters() as $task_ajax_adapter ) {
17
+	foreach ($this->task_ajax_adapters_registry->get_task_ajax_adapters() as $task_ajax_adapter) {
18 18
 		$task = $task_ajax_adapter->get_task();
19 19
 		?>
20 20
 		<div class="wl-task">
21
-			<h2><?php esc_html( $task->get_label() ); ?></h2>
21
+			<h2><?php esc_html($task->get_label()); ?></h2>
22 22
 			<div class="wl-task__progress" style="border: 1px solid #23282D; height: 20px; margin: 8px 0;">
23 23
 				<div class="wl-task__progress__bar"
24 24
 					 style="width:0;background: #0073AA; text-align: center; height: 100%; color: #fff;"></div>
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 			<button
28 28
 				type="button"
29 29
 				class="button button-large button-primary"
30
-				data-action="<?php echo esc_attr( $task->get_id() ); ?>"
31
-				data-nonce="<?php echo esc_attr( wp_create_nonce( $task->get_id() ) ); ?>"
32
-			><?php esc_html_e( 'Start', 'wordlift' ); ?></button>
30
+				data-action="<?php echo esc_attr($task->get_id()); ?>"
31
+				data-nonce="<?php echo esc_attr(wp_create_nonce($task->get_id())); ?>"
32
+			><?php esc_html_e('Start', 'wordlift'); ?></button>
33 33
 
34 34
 		</div>
35 35
 		<?php
Please login to merge, or discard this patch.
src/wordlift/tasks/admin/class-tasks-page.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -17,72 +17,72 @@
 block discarded – undo
17 17
 
18 18
 class Tasks_Page extends Submenu_Page_Base {
19 19
 
20
-	/**
21
-	 * The ID of this admin page.
22
-	 *
23
-	 * @since    1.0.0
24
-	 * @access   private
25
-	 * @var      string $menu_slug The ID of this page.
26
-	 */
27
-	private $menu_slug = 'wl_tasks_page';
20
+    /**
21
+     * The ID of this admin page.
22
+     *
23
+     * @since    1.0.0
24
+     * @access   private
25
+     * @var      string $menu_slug The ID of this page.
26
+     */
27
+    private $menu_slug = 'wl_tasks_page';
28 28
 
29
-	/**
30
-	 * Used when enqueueing styles or scripts as the version string.
31
-	 *
32
-	 * @since  1.0.0
33
-	 * @access private
34
-	 * @var    string
35
-	 */
36
-	private $asset_version = '1.0.0';
29
+    /**
30
+     * Used when enqueueing styles or scripts as the version string.
31
+     *
32
+     * @since  1.0.0
33
+     * @access private
34
+     * @var    string
35
+     */
36
+    private $asset_version = '1.0.0';
37 37
 
38
-	/**
39
-	 * @var Task_Ajax_Adapters_Registry
40
-	 */
41
-	private $task_ajax_adapters_registry;
38
+    /**
39
+     * @var Task_Ajax_Adapters_Registry
40
+     */
41
+    private $task_ajax_adapters_registry;
42 42
 
43
-	/**
44
-	 * Define the {@link Wordlift_Admin_Page} constructor.
45
-	 *
46
-	 * @param Task_Ajax_Adapters_Registry $task_ajax_adapters_registry
47
-	 *
48
-	 * @since 1.0.0
49
-	 */
50
-	public function __construct( $task_ajax_adapters_registry ) {
51
-		parent::__construct( $this->menu_slug, __( 'Tasks', 'wordlift' ), 'manage_options', 'wl_admin_menu', __( 'Tasks', 'wordlift' ) );
43
+    /**
44
+     * Define the {@link Wordlift_Admin_Page} constructor.
45
+     *
46
+     * @param Task_Ajax_Adapters_Registry $task_ajax_adapters_registry
47
+     *
48
+     * @since 1.0.0
49
+     */
50
+    public function __construct( $task_ajax_adapters_registry ) {
51
+        parent::__construct( $this->menu_slug, __( 'Tasks', 'wordlift' ), 'manage_options', 'wl_admin_menu', __( 'Tasks', 'wordlift' ) );
52 52
 
53
-		$this->task_ajax_adapters_registry = $task_ajax_adapters_registry;
53
+        $this->task_ajax_adapters_registry = $task_ajax_adapters_registry;
54 54
 
55
-	}
55
+    }
56 56
 
57
-	/**
58
-	 * Register the stylesheets and scripts for the admin area.
59
-	 *
60
-	 * @since    1.0.0
61
-	 */
62
-	public function enqueue_scripts() {
63
-		wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->asset_version, 'all' );
64
-		wp_enqueue_script(
65
-			$this->menu_slug,
66
-			plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js',
67
-			array(
68
-				'jquery',
69
-				'wp-util',
70
-			),
71
-			$this->asset_version,
72
-			true
73
-		);
74
-	}
57
+    /**
58
+     * Register the stylesheets and scripts for the admin area.
59
+     *
60
+     * @since    1.0.0
61
+     */
62
+    public function enqueue_scripts() {
63
+        wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->asset_version, 'all' );
64
+        wp_enqueue_script(
65
+            $this->menu_slug,
66
+            plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js',
67
+            array(
68
+                'jquery',
69
+                'wp-util',
70
+            ),
71
+            $this->asset_version,
72
+            true
73
+        );
74
+    }
75 75
 
76
-	/**
77
-	 * Render the page.
78
-	 *
79
-	 * @since 1.0.0
80
-	 */
81
-	public function render() {
76
+    /**
77
+     * Render the page.
78
+     *
79
+     * @since 1.0.0
80
+     */
81
+    public function render() {
82 82
 
83
-		// Include the partial.
84
-		include plugin_dir_path( __FILE__ ) . 'assets/tasks-page.php';
83
+        // Include the partial.
84
+        include plugin_dir_path( __FILE__ ) . 'assets/tasks-page.php';
85 85
 
86
-	}
86
+    }
87 87
 
88 88
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	 *
48 48
 	 * @since 1.0.0
49 49
 	 */
50
-	public function __construct( $task_ajax_adapters_registry ) {
51
-		parent::__construct( $this->menu_slug, __( 'Tasks', 'wordlift' ), 'manage_options', 'wl_admin_menu', __( 'Tasks', 'wordlift' ) );
50
+	public function __construct($task_ajax_adapters_registry) {
51
+		parent::__construct($this->menu_slug, __('Tasks', 'wordlift'), 'manage_options', 'wl_admin_menu', __('Tasks', 'wordlift'));
52 52
 
53 53
 		$this->task_ajax_adapters_registry = $task_ajax_adapters_registry;
54 54
 
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
 	 * @since    1.0.0
61 61
 	 */
62 62
 	public function enqueue_scripts() {
63
-		wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->asset_version, 'all' );
63
+		wp_enqueue_style($this->menu_slug, plugin_dir_url(__FILE__).'assets/tasks-page.css', array(), $this->asset_version, 'all');
64 64
 		wp_enqueue_script(
65 65
 			$this->menu_slug,
66
-			plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js',
66
+			plugin_dir_url(__FILE__).'assets/tasks-page.js',
67 67
 			array(
68 68
 				'jquery',
69 69
 				'wp-util',
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	public function render() {
82 82
 
83 83
 		// Include the partial.
84
-		include plugin_dir_path( __FILE__ ) . 'assets/tasks-page.php';
84
+		include plugin_dir_path(__FILE__).'assets/tasks-page.php';
85 85
 
86 86
 	}
87 87
 
Please login to merge, or discard this patch.
src/wordlift/tasks/class-task-runner.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,15 +15,15 @@
 block discarded – undo
15 15
  */
16 16
 interface Task_Runner {
17 17
 
18
-	/**
19
-	 * Start the task.
20
-	 *
21
-	 * @param int $limit The maximum number of items to process.
22
-	 * @param int $offset The starting offset (zero-based).
23
-	 *
24
-	 * @return mixed
25
-	 * @since 1.0.0
26
-	 */
27
-	public function start( $limit = 0, $offset = 0 );
18
+    /**
19
+     * Start the task.
20
+     *
21
+     * @param int $limit The maximum number of items to process.
22
+     * @param int $offset The starting offset (zero-based).
23
+     *
24
+     * @return mixed
25
+     * @since 1.0.0
26
+     */
27
+    public function start( $limit = 0, $offset = 0 );
28 28
 
29 29
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,6 +24,6 @@
 block discarded – undo
24 24
 	 * @return mixed
25 25
 	 * @since 1.0.0
26 26
 	 */
27
-	public function start( $limit = 0, $offset = 0 );
27
+	public function start($limit = 0, $offset = 0);
28 28
 
29 29
 }
Please login to merge, or discard this patch.
src/wordlift/tasks/class-task-progress.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -16,30 +16,30 @@
 block discarded – undo
16 16
  */
17 17
 interface Task_Progress {
18 18
 
19
-	/**
20
-	 * The total number of elements to process.
21
-	 *
22
-	 * @param int $value The total number of elements to process.
23
-	 *
24
-	 * @since 1.0.0
25
-	 */
26
-	public function set_count( $value );
19
+    /**
20
+     * The total number of elements to process.
21
+     *
22
+     * @param int $value The total number of elements to process.
23
+     *
24
+     * @since 1.0.0
25
+     */
26
+    public function set_count( $value );
27 27
 
28
-	/**
29
-	 * Set the current processed item.
30
-	 *
31
-	 * @param int   $counter The current item.
32
-	 * @param mixed $item The current item.
33
-	 *
34
-	 * @since 1.0.0
35
-	 */
36
-	public function set_progress( $counter, $item );
28
+    /**
29
+     * Set the current processed item.
30
+     *
31
+     * @param int   $counter The current item.
32
+     * @param mixed $item The current item.
33
+     *
34
+     * @since 1.0.0
35
+     */
36
+    public function set_progress( $counter, $item );
37 37
 
38
-	/**
39
-	 * Set the operation as complete.
40
-	 *
41
-	 * @since 1.0.0
42
-	 */
43
-	public function finish();
38
+    /**
39
+     * Set the operation as complete.
40
+     *
41
+     * @since 1.0.0
42
+     */
43
+    public function finish();
44 44
 
45 45
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @since 1.0.0
25 25
 	 */
26
-	public function set_count( $value );
26
+	public function set_count($value);
27 27
 
28 28
 	/**
29 29
 	 * Set the current processed item.
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 * @since 1.0.0
35 35
 	 */
36
-	public function set_progress( $counter, $item );
36
+	public function set_progress($counter, $item);
37 37
 
38 38
 	/**
39 39
 	 * Set the operation as complete.
Please login to merge, or discard this patch.
src/wordlift/tasks/class-task-ajax-adapter.php 2 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -16,64 +16,64 @@
 block discarded – undo
16 16
  */
17 17
 class Task_Ajax_Adapter {
18 18
 
19
-	/**
20
-	 * @var Task
21
-	 */
22
-	private $task;
19
+    /**
20
+     * @var Task
21
+     */
22
+    private $task;
23 23
 
24
-	/**
25
-	 * @var string $action_name The action name.
26
-	 */
27
-	private $action_name;
24
+    /**
25
+     * @var string $action_name The action name.
26
+     */
27
+    private $action_name;
28 28
 
29
-	/**
30
-	 * Task_Ajax_Adapter constructor.
31
-	 *
32
-	 * @param Task $task
33
-	 */
34
-	public function __construct( $task ) {
29
+    /**
30
+     * Task_Ajax_Adapter constructor.
31
+     *
32
+     * @param Task $task
33
+     */
34
+    public function __construct( $task ) {
35 35
 
36
-		$this->task = $task;
36
+        $this->task = $task;
37 37
 
38
-		$this->action_name = $task->get_id();
39
-		add_action( 'wp_ajax_' . $this->action_name, array( $this, 'start' ) );
38
+        $this->action_name = $task->get_id();
39
+        add_action( 'wp_ajax_' . $this->action_name, array( $this, 'start' ) );
40 40
 
41
-	}
41
+    }
42 42
 
43
-	public function start() {
43
+    public function start() {
44 44
 
45
-		// First check if there is a valid nonce.
46
-		check_ajax_referer( $this->action_name );
45
+        // First check if there is a valid nonce.
46
+        check_ajax_referer( $this->action_name );
47 47
 
48
-		// Get the offset.
49
-		$offset = filter_input( INPUT_POST, 'offset', FILTER_SANITIZE_NUMBER_INT );
50
-		$offset = $offset ? $offset : 0;
48
+        // Get the offset.
49
+        $offset = filter_input( INPUT_POST, 'offset', FILTER_SANITIZE_NUMBER_INT );
50
+        $offset = $offset ? $offset : 0;
51 51
 
52
-		// Compatibility fix for FacetWP, which somewhere in some filter checks for the $_POST array.
53
-		unset( $_POST['offset'] );
52
+        // Compatibility fix for FacetWP, which somewhere in some filter checks for the $_POST array.
53
+        unset( $_POST['offset'] );
54 54
 
55
-		// Create an AJAX progress. The AJAX progress returns the progress data to the AJAX client, which
56
-		// in turn calls the next batch.
57
-		$ajax_progress = new Task_Ajax_Progress( $this->action_name );
55
+        // Create an AJAX progress. The AJAX progress returns the progress data to the AJAX client, which
56
+        // in turn calls the next batch.
57
+        $ajax_progress = new Task_Ajax_Progress( $this->action_name );
58 58
 
59
-		// Finally create the task runner and start it.
60
-		$task_runner = new Task_Single_Instance_Task_Runner( $this->task, true, array( $ajax_progress ) );
59
+        // Finally create the task runner and start it.
60
+        $task_runner = new Task_Single_Instance_Task_Runner( $this->task, true, array( $ajax_progress ) );
61 61
 
62
-		try {
63
-			// Start the task runner, 1 item at a time.
64
-			$task_runner->start( 1, $offset );
65
-		} catch ( Task_Another_Instance_Is_Running_Exception $e ) {
66
-			wp_send_json_error( 'A task is already running.' );
67
-		}
62
+        try {
63
+            // Start the task runner, 1 item at a time.
64
+            $task_runner->start( 1, $offset );
65
+        } catch ( Task_Another_Instance_Is_Running_Exception $e ) {
66
+            wp_send_json_error( 'A task is already running.' );
67
+        }
68 68
 
69
-	}
69
+    }
70 70
 
71
-	/**
72
-	 * @return Task
73
-	 */
74
-	public function get_task() {
71
+    /**
72
+     * @return Task
73
+     */
74
+    public function get_task() {
75 75
 
76
-		return $this->task;
77
-	}
76
+        return $this->task;
77
+    }
78 78
 
79 79
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -31,39 +31,39 @@
 block discarded – undo
31 31
 	 *
32 32
 	 * @param Task $task
33 33
 	 */
34
-	public function __construct( $task ) {
34
+	public function __construct($task) {
35 35
 
36 36
 		$this->task = $task;
37 37
 
38 38
 		$this->action_name = $task->get_id();
39
-		add_action( 'wp_ajax_' . $this->action_name, array( $this, 'start' ) );
39
+		add_action('wp_ajax_'.$this->action_name, array($this, 'start'));
40 40
 
41 41
 	}
42 42
 
43 43
 	public function start() {
44 44
 
45 45
 		// First check if there is a valid nonce.
46
-		check_ajax_referer( $this->action_name );
46
+		check_ajax_referer($this->action_name);
47 47
 
48 48
 		// Get the offset.
49
-		$offset = filter_input( INPUT_POST, 'offset', FILTER_SANITIZE_NUMBER_INT );
49
+		$offset = filter_input(INPUT_POST, 'offset', FILTER_SANITIZE_NUMBER_INT);
50 50
 		$offset = $offset ? $offset : 0;
51 51
 
52 52
 		// Compatibility fix for FacetWP, which somewhere in some filter checks for the $_POST array.
53
-		unset( $_POST['offset'] );
53
+		unset($_POST['offset']);
54 54
 
55 55
 		// Create an AJAX progress. The AJAX progress returns the progress data to the AJAX client, which
56 56
 		// in turn calls the next batch.
57
-		$ajax_progress = new Task_Ajax_Progress( $this->action_name );
57
+		$ajax_progress = new Task_Ajax_Progress($this->action_name);
58 58
 
59 59
 		// Finally create the task runner and start it.
60
-		$task_runner = new Task_Single_Instance_Task_Runner( $this->task, true, array( $ajax_progress ) );
60
+		$task_runner = new Task_Single_Instance_Task_Runner($this->task, true, array($ajax_progress));
61 61
 
62 62
 		try {
63 63
 			// Start the task runner, 1 item at a time.
64
-			$task_runner->start( 1, $offset );
65
-		} catch ( Task_Another_Instance_Is_Running_Exception $e ) {
66
-			wp_send_json_error( 'A task is already running.' );
64
+			$task_runner->start(1, $offset);
65
+		} catch (Task_Another_Instance_Is_Running_Exception $e) {
66
+			wp_send_json_error('A task is already running.');
67 67
 		}
68 68
 
69 69
 	}
Please login to merge, or discard this patch.
src/wordlift/tasks/class-task-ajax-progress.php 2 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -18,86 +18,86 @@
 block discarded – undo
18 18
  */
19 19
 class Task_Ajax_Progress implements Task_Progress {
20 20
 
21
-	/**
22
-	 * The AJAX action, used to generate new nonces.
23
-	 *
24
-	 * @since 1.0.0
25
-	 * @access private
26
-	 * @var string $action The AJAX action.
27
-	 */
28
-	private $action;
29
-
30
-	/**
31
-	 * The total number of items to process.
32
-	 *
33
-	 * @since 1.0.0
34
-	 * @access private
35
-	 * @var int The total number of items to process.
36
-	 */
37
-	private $count;
38
-
39
-	/**
40
-	 * The current item index.
41
-	 *
42
-	 * @since 1.0.0
43
-	 * @access private
44
-	 * @var int $index The current item index.
45
-	 */
46
-	private $index;
47
-
48
-	/**
49
-	 * @var Wordlift_Log_Service
50
-	 */
51
-	private $log;
52
-
53
-	/**
54
-	 * Create a Task_Ajax_Progress instance with the specified
55
-	 * AJAX action.
56
-	 *
57
-	 * @param string $action The AJAX action.
58
-	 *
59
-	 * @since 1.0.0
60
-	 */
61
-	public function __construct( $action ) {
62
-
63
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
64
-
65
-		$this->action = $action;
66
-
67
-	}
68
-
69
-	/**
70
-	 * {@inheritDoc}
71
-	 */
72
-	public function set_count( $value ) {
73
-
74
-		$this->log->debug( "New count $value for action $this->action..." );
75
-
76
-		$this->count = $value;
77
-
78
-	}
79
-
80
-	/**
81
-	 * {@inheritDoc}
82
-	 */
83
-	// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
84
-	public function set_progress( $index, $item ) {
85
-		$this->index = $index;
86
-	}
87
-
88
-	/**
89
-	 * {@inheritDoc}
90
-	 */
91
-	public function finish() {
92
-		wp_send_json_success(
93
-			array(
94
-				'count'    => $this->count,
95
-				'index'    => $this->index,
96
-				// $this->index is zero based.
97
-				'complete' => $this->index >= $this->count - 1,
98
-				'nonce'    => wp_create_nonce( $this->action ),
99
-			)
100
-		);
101
-	}
21
+    /**
22
+     * The AJAX action, used to generate new nonces.
23
+     *
24
+     * @since 1.0.0
25
+     * @access private
26
+     * @var string $action The AJAX action.
27
+     */
28
+    private $action;
29
+
30
+    /**
31
+     * The total number of items to process.
32
+     *
33
+     * @since 1.0.0
34
+     * @access private
35
+     * @var int The total number of items to process.
36
+     */
37
+    private $count;
38
+
39
+    /**
40
+     * The current item index.
41
+     *
42
+     * @since 1.0.0
43
+     * @access private
44
+     * @var int $index The current item index.
45
+     */
46
+    private $index;
47
+
48
+    /**
49
+     * @var Wordlift_Log_Service
50
+     */
51
+    private $log;
52
+
53
+    /**
54
+     * Create a Task_Ajax_Progress instance with the specified
55
+     * AJAX action.
56
+     *
57
+     * @param string $action The AJAX action.
58
+     *
59
+     * @since 1.0.0
60
+     */
61
+    public function __construct( $action ) {
62
+
63
+        $this->log = Wordlift_Log_Service::get_logger( get_class() );
64
+
65
+        $this->action = $action;
66
+
67
+    }
68
+
69
+    /**
70
+     * {@inheritDoc}
71
+     */
72
+    public function set_count( $value ) {
73
+
74
+        $this->log->debug( "New count $value for action $this->action..." );
75
+
76
+        $this->count = $value;
77
+
78
+    }
79
+
80
+    /**
81
+     * {@inheritDoc}
82
+     */
83
+    // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
84
+    public function set_progress( $index, $item ) {
85
+        $this->index = $index;
86
+    }
87
+
88
+    /**
89
+     * {@inheritDoc}
90
+     */
91
+    public function finish() {
92
+        wp_send_json_success(
93
+            array(
94
+                'count'    => $this->count,
95
+                'index'    => $this->index,
96
+                // $this->index is zero based.
97
+                'complete' => $this->index >= $this->count - 1,
98
+                'nonce'    => wp_create_nonce( $this->action ),
99
+            )
100
+        );
101
+    }
102 102
 
103 103
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @since 1.0.0
60 60
 	 */
61
-	public function __construct( $action ) {
61
+	public function __construct($action) {
62 62
 
63
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
63
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
64 64
 
65 65
 		$this->action = $action;
66 66
 
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	/**
70 70
 	 * {@inheritDoc}
71 71
 	 */
72
-	public function set_count( $value ) {
72
+	public function set_count($value) {
73 73
 
74
-		$this->log->debug( "New count $value for action $this->action..." );
74
+		$this->log->debug("New count $value for action $this->action...");
75 75
 
76 76
 		$this->count = $value;
77 77
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * {@inheritDoc}
82 82
 	 */
83 83
 	// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
84
-	public function set_progress( $index, $item ) {
84
+	public function set_progress($index, $item) {
85 85
 		$this->index = $index;
86 86
 	}
87 87
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 				'index'    => $this->index,
96 96
 				// $this->index is zero based.
97 97
 				'complete' => $this->index >= $this->count - 1,
98
-				'nonce'    => wp_create_nonce( $this->action ),
98
+				'nonce'    => wp_create_nonce($this->action),
99 99
 			)
100 100
 		);
101 101
 	}
Please login to merge, or discard this patch.
src/wordlift/metabox/field/class-wordlift-metabox-field-integer.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
  * @package Wordlift
20 20
  */
21 21
 class Wordlift_Metabox_Field_Integer extends Wl_Metabox_Field {
22
-	/**
23
-	 * @inheritdoc
24
-	 */
25
-	public function html_input( $text ) {
22
+    /**
23
+     * @inheritdoc
24
+     */
25
+    public function html_input( $text ) {
26 26
         // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
27
-		@ob_start();
28
-		?>
27
+        @ob_start();
28
+        ?>
29 29
 			<div class="wl-input-wrapper">
30 30
 				<input
31 31
 					type="number"
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 			</div>
46 46
 
47 47
 		<?php
48
-		$html = ob_get_clean();
48
+        $html = ob_get_clean();
49 49
 
50
-		return $html;
51
-	}
50
+        return $html;
51
+    }
52 52
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,23 +22,23 @@
 block discarded – undo
22 22
 	/**
23 23
 	 * @inheritdoc
24 24
 	 */
25
-	public function html_input( $text ) {
25
+	public function html_input($text) {
26 26
         // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
27 27
 		@ob_start();
28 28
 		?>
29 29
 			<div class="wl-input-wrapper">
30 30
 				<input
31 31
 					type="number"
32
-					id="<?php echo esc_attr( $this->meta_name ); ?>"
33
-					class="<?php echo esc_attr( $this->meta_name ); ?>"
34
-					value="<?php echo esc_attr( $text ); ?>"
35
-					name="wl_metaboxes[<?php echo esc_attr( $this->meta_name ); ?>][]"
32
+					id="<?php echo esc_attr($this->meta_name); ?>"
33
+					class="<?php echo esc_attr($this->meta_name); ?>"
34
+					value="<?php echo esc_attr($text); ?>"
35
+					name="wl_metaboxes[<?php echo esc_attr($this->meta_name); ?>][]"
36 36
 					style="width:88%"
37 37
 					min="0"
38 38
 				/>
39 39
 
40 40
 				<button class="button wl-remove-input wl-button" type="button">
41
-					<?php esc_html_e( 'Remove', 'wordlift' ); ?>
41
+					<?php esc_html_e('Remove', 'wordlift'); ?>
42 42
 				</button>
43 43
 
44 44
 				<div class="wl-input-notice"></div>
Please login to merge, or discard this patch.