Completed
Push — master ( 9f3eac...f0c1b5 )
by David
02:49 queued 13s
created
src/wordlift/images-licenses/admin/class-image-license-page.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -87,6 +87,7 @@
 block discarded – undo
87 87
 
88 88
 	/**
89 89
 	 * @param array $image
90
+	 * @param integer $idx
90 91
 	 */
91 92
 	private function render_image( $image, $idx ) {
92 93
 
Please login to merge, or discard this patch.
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -9,41 +9,41 @@  discard block
 block discarded – undo
9 9
 
10 10
 class Image_License_Page extends Submenu_Page_Base {
11 11
 
12
-	/**
13
-	 * @var array
14
-	 */
15
-	private $data;
16
-
17
-	/**
18
-	 * @var string
19
-	 */
20
-	private $version;
21
-
22
-	/**
23
-	 * Image_License_Page constructor.
24
-	 *
25
-	 * @param array $data
26
-	 * @param string $version
27
-	 */
28
-	public function __construct( $data, $version ) {
29
-		$count = count( $data );
30
-
31
-		// Display the page in the menu only if there's something to do.
32
-		if ( 0 === $count ) {
33
-			return;
34
-		}
35
-		$menu_title = __( 'License Compliance', 'wordlift' ) .
36
-		              sprintf( '<span class="update-plugins count-%1$d"><span class="license-compliance-count">%1$d</span></span>', $count );
37
-
38
-		parent::__construct( 'wl_image_license_page', __( 'License Compliance', 'wordlift' ), 'manage_options', 'wl_admin_menu', $menu_title );
39
-
40
-		$this->data    = $data;
41
-		$this->version = $version;
42
-
43
-	}
44
-
45
-	public function render() {
46
-		?>
12
+    /**
13
+     * @var array
14
+     */
15
+    private $data;
16
+
17
+    /**
18
+     * @var string
19
+     */
20
+    private $version;
21
+
22
+    /**
23
+     * Image_License_Page constructor.
24
+     *
25
+     * @param array $data
26
+     * @param string $version
27
+     */
28
+    public function __construct( $data, $version ) {
29
+        $count = count( $data );
30
+
31
+        // Display the page in the menu only if there's something to do.
32
+        if ( 0 === $count ) {
33
+            return;
34
+        }
35
+        $menu_title = __( 'License Compliance', 'wordlift' ) .
36
+                        sprintf( '<span class="update-plugins count-%1$d"><span class="license-compliance-count">%1$d</span></span>', $count );
37
+
38
+        parent::__construct( 'wl_image_license_page', __( 'License Compliance', 'wordlift' ), 'manage_options', 'wl_admin_menu', $menu_title );
39
+
40
+        $this->data    = $data;
41
+        $this->version = $version;
42
+
43
+    }
44
+
45
+    public function render() {
46
+        ?>
47 47
         <h1><?php esc_html_e( 'License Compliance', 'wordlift' ); ?></h1>
48 48
 
49 49
         <p><?php esc_html_e( 'By choosing "Remove All Images" you will ', 'wordlift' ); ?>
@@ -79,40 +79,40 @@  discard block
 block discarded – undo
79 79
             </tr>
80 80
             </thead>
81 81
 			<?php
82
-			$images = $this->data;
82
+            $images = $this->data;
83 83
 
84
-			for ( $i = 0; $i < count( $images ); $i ++ ) {
85
-				$this->render_image( $images[ $i ], $i );
86
-			}
87
-			?>
84
+            for ( $i = 0; $i < count( $images ); $i ++ ) {
85
+                $this->render_image( $images[ $i ], $i );
86
+            }
87
+            ?>
88 88
         </table>
89 89
 		<?php
90
-	}
90
+    }
91 91
 
92
-	/**
93
-	 * @param array $image
94
-	 */
95
-	private function render_image( $image, $idx ) {
92
+    /**
93
+     * @param array $image
94
+     */
95
+    private function render_image( $image, $idx ) {
96 96
 
97
-		$attachment_id = $image['attachment_id'];
97
+        $attachment_id = $image['attachment_id'];
98 98
 
99
-		// Skip if the post doesn't exist anymore or has been fixed.
100
-		if ( ! $this->exists( $attachment_id ) ) {
101
-			return;
102
-		}
99
+        // Skip if the post doesn't exist anymore or has been fixed.
100
+        if ( ! $this->exists( $attachment_id ) ) {
101
+            return;
102
+        }
103 103
 
104
-		$author = html_entity_decode( $image['author'] );
104
+        $author = html_entity_decode( $image['author'] );
105 105
 
106
-		$more_info_link_esc = esc_url( $image['more_info_link'] );
106
+        $more_info_link_esc = esc_url( $image['more_info_link'] );
107 107
 
108
-		$is_unknown_license = '#N/A' === $image['license'];
108
+        $is_unknown_license = '#N/A' === $image['license'];
109 109
 
110
-		$caption_builder  = new Caption_Builder( $image );
111
-		$proposed_caption = $caption_builder->build();
110
+        $caption_builder  = new Caption_Builder( $image );
111
+        $proposed_caption = $caption_builder->build();
112 112
 
113
-		$script_id = "wl-image-$idx";
114
-		$row_id    = "wl-row-$idx";
115
-		?>
113
+        $script_id = "wl-image-$idx";
114
+        $row_id    = "wl-row-$idx";
115
+        ?>
116 116
         <tr id="<?php echo $row_id; ?>">
117 117
             <td><?php echo wp_get_attachment_image( $attachment_id, array( 100, ) ); ?></td>
118 118
             <td><?php echo esc_html( $image['filename'] ); ?></td>
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
             </td>
126 126
             <td>
127 127
 				<?php
128
-				$this->partial_used_in_posts( $image['posts_ids_as_featured_image'], __( 'Used as featured image in %d post(s):', 'wordlift' ) );
129
-				$this->partial_used_in_posts( $image['posts_ids_as_embed'], __( 'Embedded in %d post(s):', 'wordlift' ) );
130
-				?>
128
+                $this->partial_used_in_posts( $image['posts_ids_as_featured_image'], __( 'Used as featured image in %d post(s):', 'wordlift' ) );
129
+                $this->partial_used_in_posts( $image['posts_ids_as_embed'], __( 'Embedded in %d post(s):', 'wordlift' ) );
130
+                ?>
131 131
             </td>
132 132
             <td>
133 133
                 <script type="application/json"
@@ -149,44 +149,44 @@  discard block
 block discarded – undo
149 149
             </td>
150 150
         </tr>
151 151
 		<?php
152
-	}
152
+    }
153 153
 
154
-	private function partial_used_in_posts( $data, $label ) {
154
+    private function partial_used_in_posts( $data, $label ) {
155 155
 
156
-		// Bail out if there's not data.
157
-		$count = count( $data );
158
-		if ( 0 === $count ) {
159
-			return;
160
-		}
156
+        // Bail out if there's not data.
157
+        $count = count( $data );
158
+        if ( 0 === $count ) {
159
+            return;
160
+        }
161 161
 
162
-		echo esc_html( sprintf( $label, $count ) );
163
-		foreach ( $data as $post_id ) {
164
-			$post = get_post( $post_id ); ?>
162
+        echo esc_html( sprintf( $label, $count ) );
163
+        foreach ( $data as $post_id ) {
164
+            $post = get_post( $post_id ); ?>
165 165
             <a href="<?php echo get_permalink( $post_id ); ?>"><?php echo esc_html( $post->post_title ); ?></a>
166 166
 			<?php
167
-		}
168
-	}
169
-
170
-	function enqueue_scripts() {
171
-
172
-		wp_enqueue_script( $this->get_menu_slug(), plugin_dir_url( __FILE__ ) . 'assets/image-license.js', array( 'wp-util' ), $this->version, true );
173
-		wp_localize_script( $this->get_menu_slug(), '_wlImageLicensePageSettings', array(
174
-			'_ajax_nonce' => array(
175
-				Add_License_Caption_Or_Remove_Task::MENU_SLUG . '__single' => wp_create_nonce( Add_License_Caption_Or_Remove_Task::MENU_SLUG ),
176
-				Remove_All_Images_Task::MENU_SLUG . '__single'             => wp_create_nonce( Remove_All_Images_Task::MENU_SLUG ),
177
-			),
178
-			'l10n'        => array(
179
-				'Done'              => __( 'Done', 'wordlift' ),
180
-				'An error occurred' => __( 'An error occurred', 'wordlift' ),
181
-			)
182
-		) );
183
-	}
184
-
185
-	private function exists( $attachment_id ) {
186
-		global $wpdb;
187
-
188
-		$sql =
189
-			"
167
+        }
168
+    }
169
+
170
+    function enqueue_scripts() {
171
+
172
+        wp_enqueue_script( $this->get_menu_slug(), plugin_dir_url( __FILE__ ) . 'assets/image-license.js', array( 'wp-util' ), $this->version, true );
173
+        wp_localize_script( $this->get_menu_slug(), '_wlImageLicensePageSettings', array(
174
+            '_ajax_nonce' => array(
175
+                Add_License_Caption_Or_Remove_Task::MENU_SLUG . '__single' => wp_create_nonce( Add_License_Caption_Or_Remove_Task::MENU_SLUG ),
176
+                Remove_All_Images_Task::MENU_SLUG . '__single'             => wp_create_nonce( Remove_All_Images_Task::MENU_SLUG ),
177
+            ),
178
+            'l10n'        => array(
179
+                'Done'              => __( 'Done', 'wordlift' ),
180
+                'An error occurred' => __( 'An error occurred', 'wordlift' ),
181
+            )
182
+        ) );
183
+    }
184
+
185
+    private function exists( $attachment_id ) {
186
+        global $wpdb;
187
+
188
+        $sql =
189
+            "
190 190
             SELECT COUNT( 1 )
191 191
             FROM {$wpdb->postmeta} pm1
192 192
             LEFT OUTER JOIN {$wpdb->postmeta} pm2
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
               AND pm2.meta_value IS NULL
198 198
             ";
199 199
 
200
-		return $wpdb->get_var( $wpdb->prepare(
201
-			$sql,
202
-			'_wl_image_license_fixed',
203
-			$attachment_id,
204
-			'_wp_attached_file'
205
-		) );
206
-	}
200
+        return $wpdb->get_var( $wpdb->prepare(
201
+            $sql,
202
+            '_wl_image_license_fixed',
203
+            $attachment_id,
204
+            '_wp_attached_file'
205
+        ) );
206
+    }
207 207
 
208 208
 }
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@  discard block
 block discarded – undo
25 25
 	 * @param array $data
26 26
 	 * @param string $version
27 27
 	 */
28
-	public function __construct( $data, $version ) {
29
-		$count = count( $data );
28
+	public function __construct($data, $version) {
29
+		$count = count($data);
30 30
 
31 31
 		// Display the page in the menu only if there's something to do.
32
-		if ( 0 === $count ) {
32
+		if (0 === $count) {
33 33
 			return;
34 34
 		}
35
-		$menu_title = __( 'License Compliance', 'wordlift' ) .
36
-		              sprintf( '<span class="update-plugins count-%1$d"><span class="license-compliance-count">%1$d</span></span>', $count );
35
+		$menu_title = __('License Compliance', 'wordlift').
36
+		              sprintf('<span class="update-plugins count-%1$d"><span class="license-compliance-count">%1$d</span></span>', $count);
37 37
 
38
-		parent::__construct( 'wl_image_license_page', __( 'License Compliance', 'wordlift' ), 'manage_options', 'wl_admin_menu', $menu_title );
38
+		parent::__construct('wl_image_license_page', __('License Compliance', 'wordlift'), 'manage_options', 'wl_admin_menu', $menu_title);
39 39
 
40 40
 		$this->data    = $data;
41 41
 		$this->version = $version;
@@ -44,45 +44,45 @@  discard block
 block discarded – undo
44 44
 
45 45
 	public function render() {
46 46
 		?>
47
-        <h1><?php esc_html_e( 'License Compliance', 'wordlift' ); ?></h1>
47
+        <h1><?php esc_html_e('License Compliance', 'wordlift'); ?></h1>
48 48
 
49
-        <p><?php esc_html_e( 'By choosing "Remove All Images" you will ', 'wordlift' ); ?>
50
-            <strong><?php esc_html_e( 'remove from your website all images that do not have a Public Domain or CC0 license', 'wordlift' ); ?></strong>.
51
-			<?php esc_html_e( 'Alternatively, WordLift can write the terms of the detected license in the caption of each image. Make sure
49
+        <p><?php esc_html_e('By choosing "Remove All Images" you will ', 'wordlift'); ?>
50
+            <strong><?php esc_html_e('remove from your website all images that do not have a Public Domain or CC0 license', 'wordlift'); ?></strong>.
51
+			<?php esc_html_e('Alternatively, WordLift can write the terms of the detected license in the caption of each image. Make sure
52 52
             that attribution, when required, is visible to your readers. You can also selectively choose from the list
53
-            of images below if removing or adding the license for each of the images.', 'wordlift' ); ?></p>
54
-        <p><span class="dashicons dashicons-warning"></span> <?php esc_html_e( 'As site owner you are ultimately responsible for the images
55
-            being published on your website.', 'wordlift' ); ?></p>
53
+            of images below if removing or adding the license for each of the images.', 'wordlift'); ?></p>
54
+        <p><span class="dashicons dashicons-warning"></span> <?php esc_html_e('As site owner you are ultimately responsible for the images
55
+            being published on your website.', 'wordlift'); ?></p>
56 56
 
57 57
         <p class="top">
58 58
             <a class="button"
59
-               href="<?php echo admin_url( 'admin.php?page=wl_images_licenses__reload_data' ); ?>"><?php esc_html_e( 'Reload data', 'wordlift' ); ?></a>
59
+               href="<?php echo admin_url('admin.php?page=wl_images_licenses__reload_data'); ?>"><?php esc_html_e('Reload data', 'wordlift'); ?></a>
60 60
             <a class="button"
61
-               href="<?php echo admin_url( 'admin.php?page=wl_images_licenses__remove_all_images' ); ?>"><?php esc_html_e( 'Remove all images', 'wordlift' ); ?></a>
61
+               href="<?php echo admin_url('admin.php?page=wl_images_licenses__remove_all_images'); ?>"><?php esc_html_e('Remove all images', 'wordlift'); ?></a>
62 62
             <a class="button"
63
-               href="<?php echo admin_url( 'admin.php?page=wl_images_licenses__add_license_caption_or_remove' ); ?>"><?php esc_html_e( 'Add license caption to images and remove those with unknown license', 'wordlift' ); ?></a>
63
+               href="<?php echo admin_url('admin.php?page=wl_images_licenses__add_license_caption_or_remove'); ?>"><?php esc_html_e('Add license caption to images and remove those with unknown license', 'wordlift'); ?></a>
64 64
         </p>
65 65
 
66
-        <h2 class="screen-reader-text"><?php esc_html_e( 'Images', 'wordlift' ); ?></h2>
66
+        <h2 class="screen-reader-text"><?php esc_html_e('Images', 'wordlift'); ?></h2>
67 67
 
68 68
         <table class="wp-list-table widefat fixed striped">
69 69
             <thead>
70 70
             <tr>
71
-                <th><?php esc_html_e( 'Thumbnail', 'wordlift' ); ?></th>
72
-                <th><?php esc_html_e( 'Filename', 'wordlift' ); ?></th>
73
-                <th><?php esc_html_e( 'License', 'wordlift' ); ?></th>
74
-                <th><?php esc_html_e( 'Author', 'wordlift' ); ?></th>
75
-                <th><?php esc_html_e( 'Proposed Caption', 'wordlift' ); ?></th>
76
-                <th><?php esc_html_e( 'More Info', 'wordlift' ); ?></th>
77
-                <th><?php esc_html_e( 'Posts', 'wordlift' ); ?></th>
78
-                <th><?php esc_html_e( 'Actions', 'wordlift' ); ?></th>
71
+                <th><?php esc_html_e('Thumbnail', 'wordlift'); ?></th>
72
+                <th><?php esc_html_e('Filename', 'wordlift'); ?></th>
73
+                <th><?php esc_html_e('License', 'wordlift'); ?></th>
74
+                <th><?php esc_html_e('Author', 'wordlift'); ?></th>
75
+                <th><?php esc_html_e('Proposed Caption', 'wordlift'); ?></th>
76
+                <th><?php esc_html_e('More Info', 'wordlift'); ?></th>
77
+                <th><?php esc_html_e('Posts', 'wordlift'); ?></th>
78
+                <th><?php esc_html_e('Actions', 'wordlift'); ?></th>
79 79
             </tr>
80 80
             </thead>
81 81
 			<?php
82 82
 			$images = $this->data;
83 83
 
84
-			for ( $i = 0; $i < count( $images ); $i ++ ) {
85
-				$this->render_image( $images[ $i ], $i );
84
+			for ($i = 0; $i < count($images); $i++) {
85
+				$this->render_image($images[$i], $i);
86 86
 			}
87 87
 			?>
88 88
         </table>
@@ -92,97 +92,97 @@  discard block
 block discarded – undo
92 92
 	/**
93 93
 	 * @param array $image
94 94
 	 */
95
-	private function render_image( $image, $idx ) {
95
+	private function render_image($image, $idx) {
96 96
 
97 97
 		$attachment_id = $image['attachment_id'];
98 98
 
99 99
 		// Skip if the post doesn't exist anymore or has been fixed.
100
-		if ( ! $this->exists( $attachment_id ) ) {
100
+		if ( ! $this->exists($attachment_id)) {
101 101
 			return;
102 102
 		}
103 103
 
104
-		$author = html_entity_decode( $image['author'] );
104
+		$author = html_entity_decode($image['author']);
105 105
 
106
-		$more_info_link_esc = esc_url( $image['more_info_link'] );
106
+		$more_info_link_esc = esc_url($image['more_info_link']);
107 107
 
108 108
 		$is_unknown_license = '#N/A' === $image['license'];
109 109
 
110
-		$caption_builder  = new Caption_Builder( $image );
110
+		$caption_builder  = new Caption_Builder($image);
111 111
 		$proposed_caption = $caption_builder->build();
112 112
 
113 113
 		$script_id = "wl-image-$idx";
114 114
 		$row_id    = "wl-row-$idx";
115 115
 		?>
116 116
         <tr id="<?php echo $row_id; ?>">
117
-            <td><?php echo wp_get_attachment_image( $attachment_id, array( 100, ) ); ?></td>
118
-            <td><?php echo esc_html( $image['filename'] ); ?></td>
119
-            <td><?php echo esc_html( $image['license'] ); ?></td>
117
+            <td><?php echo wp_get_attachment_image($attachment_id, array(100,)); ?></td>
118
+            <td><?php echo esc_html($image['filename']); ?></td>
119
+            <td><?php echo esc_html($image['license']); ?></td>
120 120
             <td><?php echo $author; ?></td>
121 121
             <td><?php echo $proposed_caption; ?></td>
122 122
             <td>
123 123
                 <a href="<?php echo $more_info_link_esc; ?>"
124
-                   target="_blank"><?php esc_html_e( 'More information', 'wordlift' ); ?></a>
124
+                   target="_blank"><?php esc_html_e('More information', 'wordlift'); ?></a>
125 125
             </td>
126 126
             <td>
127 127
 				<?php
128
-				$this->partial_used_in_posts( $image['posts_ids_as_featured_image'], __( 'Used as featured image in %d post(s):', 'wordlift' ) );
129
-				$this->partial_used_in_posts( $image['posts_ids_as_embed'], __( 'Embedded in %d post(s):', 'wordlift' ) );
128
+				$this->partial_used_in_posts($image['posts_ids_as_featured_image'], __('Used as featured image in %d post(s):', 'wordlift'));
129
+				$this->partial_used_in_posts($image['posts_ids_as_embed'], __('Embedded in %d post(s):', 'wordlift'));
130 130
 				?>
131 131
             </td>
132 132
             <td>
133 133
                 <script type="application/json"
134
-                        id="<?php echo $script_id; ?>"><?php echo json_encode( $image ); ?></script>
134
+                        id="<?php echo $script_id; ?>"><?php echo json_encode($image); ?></script>
135 135
                 <button data-id="<?php echo $script_id; ?>"
136 136
                         data-row-id="<?php echo $row_id; ?>"
137 137
                         data-action="wl_remove_all_images_task__single"
138
-                        class="button wl-action-btn"><?php esc_html_e( 'Remove image', 'wordlift' ); ?></button>
139
-				<?php if ( ! $is_unknown_license ) { ?>
138
+                        class="button wl-action-btn"><?php esc_html_e('Remove image', 'wordlift'); ?></button>
139
+				<?php if ( ! $is_unknown_license) { ?>
140 140
                     <button data-id="<?php echo $script_id; ?>"
141 141
                             data-row-id="<?php echo $row_id; ?>"
142 142
                             data-action="wl_add_license_caption_or_remove__single"
143
-                            class="button wl-action-btn"><?php esc_html_e( 'Add license caption', 'wordlift' ); ?></button>
143
+                            class="button wl-action-btn"><?php esc_html_e('Add license caption', 'wordlift'); ?></button>
144 144
 				<?php } ?>
145 145
                 <a class="button"
146
-                   href=" <?php echo get_edit_post_link( $attachment_id ); ?>"
147
-                   target="_blank"><?php esc_html_e( 'Edit image', 'wordlift' ); ?> <span
146
+                   href=" <?php echo get_edit_post_link($attachment_id); ?>"
147
+                   target="_blank"><?php esc_html_e('Edit image', 'wordlift'); ?> <span
148 148
                             class="dashicons dashicons-external"></span></a>
149 149
             </td>
150 150
         </tr>
151 151
 		<?php
152 152
 	}
153 153
 
154
-	private function partial_used_in_posts( $data, $label ) {
154
+	private function partial_used_in_posts($data, $label) {
155 155
 
156 156
 		// Bail out if there's not data.
157
-		$count = count( $data );
158
-		if ( 0 === $count ) {
157
+		$count = count($data);
158
+		if (0 === $count) {
159 159
 			return;
160 160
 		}
161 161
 
162
-		echo esc_html( sprintf( $label, $count ) );
163
-		foreach ( $data as $post_id ) {
164
-			$post = get_post( $post_id ); ?>
165
-            <a href="<?php echo get_permalink( $post_id ); ?>"><?php echo esc_html( $post->post_title ); ?></a>
162
+		echo esc_html(sprintf($label, $count));
163
+		foreach ($data as $post_id) {
164
+			$post = get_post($post_id); ?>
165
+            <a href="<?php echo get_permalink($post_id); ?>"><?php echo esc_html($post->post_title); ?></a>
166 166
 			<?php
167 167
 		}
168 168
 	}
169 169
 
170 170
 	function enqueue_scripts() {
171 171
 
172
-		wp_enqueue_script( $this->get_menu_slug(), plugin_dir_url( __FILE__ ) . 'assets/image-license.js', array( 'wp-util' ), $this->version, true );
173
-		wp_localize_script( $this->get_menu_slug(), '_wlImageLicensePageSettings', array(
172
+		wp_enqueue_script($this->get_menu_slug(), plugin_dir_url(__FILE__).'assets/image-license.js', array('wp-util'), $this->version, true);
173
+		wp_localize_script($this->get_menu_slug(), '_wlImageLicensePageSettings', array(
174 174
 			'_ajax_nonce' => array(
175
-				Add_License_Caption_Or_Remove_Task::MENU_SLUG . '__single' => wp_create_nonce( Add_License_Caption_Or_Remove_Task::MENU_SLUG ),
176
-				Remove_All_Images_Task::MENU_SLUG . '__single'             => wp_create_nonce( Remove_All_Images_Task::MENU_SLUG ),
175
+				Add_License_Caption_Or_Remove_Task::MENU_SLUG.'__single' => wp_create_nonce(Add_License_Caption_Or_Remove_Task::MENU_SLUG),
176
+				Remove_All_Images_Task::MENU_SLUG.'__single'             => wp_create_nonce(Remove_All_Images_Task::MENU_SLUG),
177 177
 			),
178 178
 			'l10n'        => array(
179
-				'Done'              => __( 'Done', 'wordlift' ),
180
-				'An error occurred' => __( 'An error occurred', 'wordlift' ),
179
+				'Done'              => __('Done', 'wordlift'),
180
+				'An error occurred' => __('An error occurred', 'wordlift'),
181 181
 			)
182
-		) );
182
+		));
183 183
 	}
184 184
 
185
-	private function exists( $attachment_id ) {
185
+	private function exists($attachment_id) {
186 186
 		global $wpdb;
187 187
 
188 188
 		$sql =
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
               AND pm2.meta_value IS NULL
198 198
             ";
199 199
 
200
-		return $wpdb->get_var( $wpdb->prepare(
200
+		return $wpdb->get_var($wpdb->prepare(
201 201
 			$sql,
202 202
 			'_wl_image_license_fixed',
203 203
 			$attachment_id,
204 204
 			'_wp_attached_file'
205
-		) );
205
+		));
206 206
 	}
207 207
 
208 208
 }
Please login to merge, or discard this patch.
src/wordlift/images-licenses/class-cached-image-license-service.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@
 block discarded – undo
5 5
 
6 6
 namespace Wordlift\Images_Licenses;
7 7
 
8
-use Wordlift\Api\Api_Service;
9 8
 use Wordlift\Cache\Ttl_Cache;
10 9
 
11 10
 class Cached_Image_License_Service extends Image_License_Service {
Please login to merge, or discard this patch.
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -10,53 +10,53 @@
 block discarded – undo
10 10
 
11 11
 class Cached_Image_License_Service extends Image_License_Service {
12 12
 
13
-	const GET_NON_PUBLIC_DOMAIN_IMAGES = 'get_non_public_domain_images';
14
-
15
-	/**
16
-	 * @var Ttl_Cache
17
-	 */
18
-	private $cache_service;
19
-
20
-	/**
21
-	 * @var Image_License_Service
22
-	 */
23
-	private $image_license_service;
24
-
25
-	/**
26
-	 * Images_Licenses_Service constructor.
27
-	 *
28
-	 * @param Image_License_Service $image_license_service
29
-	 * @param Ttl_Cache $cache_service
30
-	 */
31
-	public function __construct( $image_license_service, $cache_service ) {
32
-
33
-		$this->image_license_service = $image_license_service;
34
-		$this->cache_service         = $cache_service;
35
-
36
-		$that = $this;
37
-		add_action( 'wp_ajax_wl_cached_image_license_service__get_non_public_domain_images', function () use ( $that ) {
38
-			wp_send_json_success( $that->get_non_public_domain_images() );
39
-		} );
40
-
41
-	}
42
-
43
-	/**
44
-	 * @return array
45
-	 */
46
-	public function get_non_public_domain_images() {
47
-
48
-		// Return the cached data if available.
49
-		$cache = $this->cache_service->get( self::GET_NON_PUBLIC_DOMAIN_IMAGES );
50
-		if ( ! is_null( $cache ) ) {
51
-			return $cache;
52
-		}
53
-
54
-		$data = $this->image_license_service->get_non_public_domain_images();
55
-
56
-		// Store the cached data.
57
-		$this->cache_service->put( self::GET_NON_PUBLIC_DOMAIN_IMAGES, $data );
58
-
59
-		return $data;
60
-	}
13
+    const GET_NON_PUBLIC_DOMAIN_IMAGES = 'get_non_public_domain_images';
14
+
15
+    /**
16
+     * @var Ttl_Cache
17
+     */
18
+    private $cache_service;
19
+
20
+    /**
21
+     * @var Image_License_Service
22
+     */
23
+    private $image_license_service;
24
+
25
+    /**
26
+     * Images_Licenses_Service constructor.
27
+     *
28
+     * @param Image_License_Service $image_license_service
29
+     * @param Ttl_Cache $cache_service
30
+     */
31
+    public function __construct( $image_license_service, $cache_service ) {
32
+
33
+        $this->image_license_service = $image_license_service;
34
+        $this->cache_service         = $cache_service;
35
+
36
+        $that = $this;
37
+        add_action( 'wp_ajax_wl_cached_image_license_service__get_non_public_domain_images', function () use ( $that ) {
38
+            wp_send_json_success( $that->get_non_public_domain_images() );
39
+        } );
40
+
41
+    }
42
+
43
+    /**
44
+     * @return array
45
+     */
46
+    public function get_non_public_domain_images() {
47
+
48
+        // Return the cached data if available.
49
+        $cache = $this->cache_service->get( self::GET_NON_PUBLIC_DOMAIN_IMAGES );
50
+        if ( ! is_null( $cache ) ) {
51
+            return $cache;
52
+        }
53
+
54
+        $data = $this->image_license_service->get_non_public_domain_images();
55
+
56
+        // Store the cached data.
57
+        $this->cache_service->put( self::GET_NON_PUBLIC_DOMAIN_IMAGES, $data );
58
+
59
+        return $data;
60
+    }
61 61
 
62 62
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
 	 * @param Image_License_Service $image_license_service
29 29
 	 * @param Ttl_Cache $cache_service
30 30
 	 */
31
-	public function __construct( $image_license_service, $cache_service ) {
31
+	public function __construct($image_license_service, $cache_service) {
32 32
 
33 33
 		$this->image_license_service = $image_license_service;
34 34
 		$this->cache_service         = $cache_service;
35 35
 
36 36
 		$that = $this;
37
-		add_action( 'wp_ajax_wl_cached_image_license_service__get_non_public_domain_images', function () use ( $that ) {
38
-			wp_send_json_success( $that->get_non_public_domain_images() );
37
+		add_action('wp_ajax_wl_cached_image_license_service__get_non_public_domain_images', function() use ($that) {
38
+			wp_send_json_success($that->get_non_public_domain_images());
39 39
 		} );
40 40
 
41 41
 	}
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 	public function get_non_public_domain_images() {
47 47
 
48 48
 		// Return the cached data if available.
49
-		$cache = $this->cache_service->get( self::GET_NON_PUBLIC_DOMAIN_IMAGES );
50
-		if ( ! is_null( $cache ) ) {
49
+		$cache = $this->cache_service->get(self::GET_NON_PUBLIC_DOMAIN_IMAGES);
50
+		if ( ! is_null($cache)) {
51 51
 			return $cache;
52 52
 		}
53 53
 
54 54
 		$data = $this->image_license_service->get_non_public_domain_images();
55 55
 
56 56
 		// Store the cached data.
57
-		$this->cache_service->put( self::GET_NON_PUBLIC_DOMAIN_IMAGES, $data );
57
+		$this->cache_service->put(self::GET_NON_PUBLIC_DOMAIN_IMAGES, $data);
58 58
 
59 59
 		return $data;
60 60
 	}
Please login to merge, or discard this patch.
src/wordlift/tasks/admin/class-tasks-page-base.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,6 @@
 block discarded – undo
14 14
 
15 15
 use Wordlift\Tasks\Task_Ajax_Adapters_Registry;
16 16
 use Wordlift\Wordpress\Submenu_Page_Base;
17
-use Wordlift\Wordpress\Page;
18 17
 
19 18
 abstract class Tasks_Page_Base extends Submenu_Page_Base {
20 19
 
Please login to merge, or discard this patch.
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -18,71 +18,71 @@
 block discarded – undo
18 18
 
19 19
 abstract class Tasks_Page_Base extends Submenu_Page_Base {
20 20
 
21
-	/**
22
-	 * The ID of this admin page.
23
-	 *
24
-	 * @since    1.0.0
25
-	 * @access   private
26
-	 * @var      string $menu_slug The ID of this page.
27
-	 */
28
-	private $menu_slug;
21
+    /**
22
+     * The ID of this admin page.
23
+     *
24
+     * @since    1.0.0
25
+     * @access   private
26
+     * @var      string $menu_slug The ID of this page.
27
+     */
28
+    private $menu_slug;
29 29
 
30
-	/**
31
-	 * @var Task_Ajax_Adapters_Registry
32
-	 */
33
-	private $task_ajax_adapters_registry;
30
+    /**
31
+     * @var Task_Ajax_Adapters_Registry
32
+     */
33
+    private $task_ajax_adapters_registry;
34 34
 
35
-	/**
36
-	 * @var string
37
-	 */
38
-	private $version;
35
+    /**
36
+     * @var string
37
+     */
38
+    private $version;
39 39
 
40
-	/**
41
-	 * Define the {@link Wordlift_Admin_Page} constructor.
42
-	 *
43
-	 * @param Task_Ajax_Adapters_Registry $task_ajax_adapters_registry
44
-	 *
45
-	 * @param string $version
46
-	 * @param string $menu_slug
47
-	 * @param string $page_title
48
-	 * @param string $capability
49
-	 * @param string|null $parent_slug
50
-	 * @param string|null $menu_title
51
-	 *
52
-	 * @since 1.0.0
53
-	 */
54
-	public function __construct( $task_ajax_adapters_registry, $version, $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null ) {
55
-		parent::__construct( $menu_slug, $page_title, $capability, $parent_slug, $menu_title );
40
+    /**
41
+     * Define the {@link Wordlift_Admin_Page} constructor.
42
+     *
43
+     * @param Task_Ajax_Adapters_Registry $task_ajax_adapters_registry
44
+     *
45
+     * @param string $version
46
+     * @param string $menu_slug
47
+     * @param string $page_title
48
+     * @param string $capability
49
+     * @param string|null $parent_slug
50
+     * @param string|null $menu_title
51
+     *
52
+     * @since 1.0.0
53
+     */
54
+    public function __construct( $task_ajax_adapters_registry, $version, $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null ) {
55
+        parent::__construct( $menu_slug, $page_title, $capability, $parent_slug, $menu_title );
56 56
 
57
-		$this->task_ajax_adapters_registry = $task_ajax_adapters_registry;
58
-		$this->version                     = $version;
59
-		$this->menu_slug                   = $menu_slug;
57
+        $this->task_ajax_adapters_registry = $task_ajax_adapters_registry;
58
+        $this->version                     = $version;
59
+        $this->menu_slug                   = $menu_slug;
60 60
 
61
-	}
61
+    }
62 62
 
63
-	/**
64
-	 * Register the stylesheets and scripts for the admin area.
65
-	 *
66
-	 * @since    1.0.0
67
-	 */
68
-	public function enqueue_scripts() {
69
-		wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->version, 'all' );
70
-		wp_enqueue_script( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js', array(
71
-			'jquery',
72
-			'wp-util'
73
-		), $this->version, true );
74
-	}
63
+    /**
64
+     * Register the stylesheets and scripts for the admin area.
65
+     *
66
+     * @since    1.0.0
67
+     */
68
+    public function enqueue_scripts() {
69
+        wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->version, 'all' );
70
+        wp_enqueue_script( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js', array(
71
+            'jquery',
72
+            'wp-util'
73
+        ), $this->version, true );
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   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	 *
52 52
 	 * @since 1.0.0
53 53
 	 */
54
-	public function __construct( $task_ajax_adapters_registry, $version, $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null ) {
55
-		parent::__construct( $menu_slug, $page_title, $capability, $parent_slug, $menu_title );
54
+	public function __construct($task_ajax_adapters_registry, $version, $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null) {
55
+		parent::__construct($menu_slug, $page_title, $capability, $parent_slug, $menu_title);
56 56
 
57 57
 		$this->task_ajax_adapters_registry = $task_ajax_adapters_registry;
58 58
 		$this->version                     = $version;
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 	 * @since    1.0.0
67 67
 	 */
68 68
 	public function enqueue_scripts() {
69
-		wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->version, 'all' );
70
-		wp_enqueue_script( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js', array(
69
+		wp_enqueue_style($this->menu_slug, plugin_dir_url(__FILE__).'assets/tasks-page.css', array(), $this->version, 'all');
70
+		wp_enqueue_script($this->menu_slug, plugin_dir_url(__FILE__).'assets/tasks-page.js', array(
71 71
 			'jquery',
72 72
 			'wp-util'
73
-		), $this->version, true );
73
+		), $this->version, true);
74 74
 	}
75 75
 
76 76
 	/**
@@ -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/admin/class-tasks-page.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,6 @@
 block discarded – undo
14 14
 
15 15
 use Wordlift\Tasks\Task_Ajax_Adapters_Registry;
16 16
 use Wordlift\Wordpress\Submenu_Page_Base;
17
-use Wordlift\Wordpress\Page;
18 17
 
19 18
 class Tasks_Page extends Submenu_Page_Base {
20 19
 
Please login to merge, or discard this patch.
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -18,66 +18,66 @@
 block discarded – undo
18 18
 
19 19
 class Tasks_Page extends Submenu_Page_Base {
20 20
 
21
-	/**
22
-	 * The ID of this admin page.
23
-	 *
24
-	 * @since    1.0.0
25
-	 * @access   private
26
-	 * @var      string $menu_slug The ID of this page.
27
-	 */
28
-	private $menu_slug = 'wl_tasks_page';
21
+    /**
22
+     * The ID of this admin page.
23
+     *
24
+     * @since    1.0.0
25
+     * @access   private
26
+     * @var      string $menu_slug The ID of this page.
27
+     */
28
+    private $menu_slug = 'wl_tasks_page';
29 29
 
30
-	/**
31
-	 * Used when enqueueing styles or scripts as the version string.
32
-	 *
33
-	 * @since  1.0.0
34
-	 * @access private
35
-	 * @var    string
36
-	 */
37
-	private $asset_version = '1.0.0';
30
+    /**
31
+     * Used when enqueueing styles or scripts as the version string.
32
+     *
33
+     * @since  1.0.0
34
+     * @access private
35
+     * @var    string
36
+     */
37
+    private $asset_version = '1.0.0';
38 38
 
39
-	/**
40
-	 * @var Task_Ajax_Adapters_Registry
41
-	 */
42
-	private $task_ajax_adapters_registry;
39
+    /**
40
+     * @var Task_Ajax_Adapters_Registry
41
+     */
42
+    private $task_ajax_adapters_registry;
43 43
 
44
-	/**
45
-	 * Define the {@link Wordlift_Admin_Page} constructor.
46
-	 *
47
-	 * @param Task_Ajax_Adapters_Registry $task_ajax_adapters_registry
48
-	 *
49
-	 * @since 1.0.0
50
-	 */
51
-	public function __construct( $task_ajax_adapters_registry ) {
52
-		parent::__construct( $this->menu_slug, __( 'Tasks', 'wordlift-framework' ), 'manage_options', 'wl_admin_menu', __( 'Tasks', 'wordlift-framework' ) );
44
+    /**
45
+     * Define the {@link Wordlift_Admin_Page} constructor.
46
+     *
47
+     * @param Task_Ajax_Adapters_Registry $task_ajax_adapters_registry
48
+     *
49
+     * @since 1.0.0
50
+     */
51
+    public function __construct( $task_ajax_adapters_registry ) {
52
+        parent::__construct( $this->menu_slug, __( 'Tasks', 'wordlift-framework' ), 'manage_options', 'wl_admin_menu', __( 'Tasks', 'wordlift-framework' ) );
53 53
 
54
-		$this->task_ajax_adapters_registry = $task_ajax_adapters_registry;
54
+        $this->task_ajax_adapters_registry = $task_ajax_adapters_registry;
55 55
 
56
-	}
56
+    }
57 57
 
58
-	/**
59
-	 * Register the stylesheets and scripts for the admin area.
60
-	 *
61
-	 * @since    1.0.0
62
-	 */
63
-	public function enqueue_scripts() {
64
-		wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->asset_version, 'all' );
65
-		wp_enqueue_script( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js', array(
66
-			'jquery',
67
-			'wp-util'
68
-		), $this->asset_version, true );
69
-	}
58
+    /**
59
+     * Register the stylesheets and scripts for the admin area.
60
+     *
61
+     * @since    1.0.0
62
+     */
63
+    public function enqueue_scripts() {
64
+        wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->asset_version, 'all' );
65
+        wp_enqueue_script( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js', array(
66
+            'jquery',
67
+            'wp-util'
68
+        ), $this->asset_version, true );
69
+    }
70 70
 
71
-	/**
72
-	 * Render the page.
73
-	 *
74
-	 * @since 1.0.0
75
-	 */
76
-	public function render() {
71
+    /**
72
+     * Render the page.
73
+     *
74
+     * @since 1.0.0
75
+     */
76
+    public function render() {
77 77
 
78
-		// Include the partial.
79
-		include( plugin_dir_path( __FILE__ ) . 'assets/tasks-page.php' );
78
+        // Include the partial.
79
+        include( plugin_dir_path( __FILE__ ) . 'assets/tasks-page.php' );
80 80
 
81
-	}
81
+    }
82 82
 
83 83
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @since 1.0.0
50 50
 	 */
51
-	public function __construct( $task_ajax_adapters_registry ) {
52
-		parent::__construct( $this->menu_slug, __( 'Tasks', 'wordlift-framework' ), 'manage_options', 'wl_admin_menu', __( 'Tasks', 'wordlift-framework' ) );
51
+	public function __construct($task_ajax_adapters_registry) {
52
+		parent::__construct($this->menu_slug, __('Tasks', 'wordlift-framework'), 'manage_options', 'wl_admin_menu', __('Tasks', 'wordlift-framework'));
53 53
 
54 54
 		$this->task_ajax_adapters_registry = $task_ajax_adapters_registry;
55 55
 
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 	 * @since    1.0.0
62 62
 	 */
63 63
 	public function enqueue_scripts() {
64
-		wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->asset_version, 'all' );
65
-		wp_enqueue_script( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js', array(
64
+		wp_enqueue_style($this->menu_slug, plugin_dir_url(__FILE__).'assets/tasks-page.css', array(), $this->asset_version, 'all');
65
+		wp_enqueue_script($this->menu_slug, plugin_dir_url(__FILE__).'assets/tasks-page.js', array(
66 66
 			'jquery',
67 67
 			'wp-util'
68
-		), $this->asset_version, true );
68
+		), $this->asset_version, true);
69 69
 	}
70 70
 
71 71
 	/**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	public function render() {
77 77
 
78 78
 		// Include the partial.
79
-		include( plugin_dir_path( __FILE__ ) . 'assets/tasks-page.php' );
79
+		include(plugin_dir_path(__FILE__).'assets/tasks-page.php');
80 80
 
81 81
 	}
82 82
 
Please login to merge, or discard this patch.
src/wordlift/tasks/class-task-single-instance-task-runner.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
 	 *
73 73
 	 * @param Task $task The {@link Task} instance.
74 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}.
75
+	 * @param Task_Ajax_Progress[] $callbacks An array of {@link Wordlift_For_Bungalowparkoverzicht_Progress}.
76 76
 	 *
77 77
 	 * @since 1.0.0
78 78
 	 */
Please login to merge, or discard this patch.
Indentation   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -24,195 +24,195 @@
 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
-		for ( $i = 0; $i < count( $items ); $i ++ ) {
144
-			// Process the item.
145
-			$this->task->process_item( $items[ $i ] );
146
-
147
-			// Update the progress.
148
-			$this->set_progress( $offset + $i, $items[ $i ] );
149
-		}
150
-
151
-		// Set the total number of elements to process.
152
-		$this->set_count( $this->task->count_items() );
153
-
154
-		// Unset the running flag.
155
-		$this->set_running( false );
156
-
157
-		// Set the task to complete.
158
-		$this->finish();
159
-
160
-	}
161
-
162
-	/**
163
-	 * Set the total number of items to process.
164
-	 *
165
-	 * @param int $value The total number of items to process.
166
-	 *
167
-	 * @since 1.0.0
168
-	 */
169
-	private function set_count( $value ) {
170
-
171
-		if ( empty( $this->callbacks ) ) {
172
-			return;
173
-		}
174
-
175
-		foreach ( $this->callbacks as $callback ) {
176
-			call_user_func( array( $callback, 'set_count' ), $value );
177
-		}
178
-
179
-	}
180
-
181
-	/**
182
-	 * Set the task progress.
183
-	 *
184
-	 * @param int $index The current item index.
185
-	 * @param mixed $item The current item.
186
-	 *
187
-	 * @since 1.0.0
188
-	 */
189
-	private function set_progress( $index, $item ) {
190
-
191
-		if ( empty( $this->callbacks ) ) {
192
-			return;
193
-		}
194
-
195
-		foreach ( $this->callbacks as $callback ) {
196
-			call_user_func( array( $callback, 'set_progress' ), $index, $item );
197
-		}
198
-
199
-	}
200
-
201
-	/**
202
-	 * Inform the callbacks that the task completed.
203
-	 *
204
-	 * @since 1.0.0
205
-	 */
206
-	private function finish() {
207
-
208
-		if ( empty( $this->callbacks ) ) {
209
-			return;
210
-		}
211
-
212
-		foreach ( $this->callbacks as $callback ) {
213
-			call_user_func( array( $callback, 'finish' ) );
214
-		}
215
-
216
-	}
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
+        for ( $i = 0; $i < count( $items ); $i ++ ) {
144
+            // Process the item.
145
+            $this->task->process_item( $items[ $i ] );
146
+
147
+            // Update the progress.
148
+            $this->set_progress( $offset + $i, $items[ $i ] );
149
+        }
150
+
151
+        // Set the total number of elements to process.
152
+        $this->set_count( $this->task->count_items() );
153
+
154
+        // Unset the running flag.
155
+        $this->set_running( false );
156
+
157
+        // Set the task to complete.
158
+        $this->finish();
159
+
160
+    }
161
+
162
+    /**
163
+     * Set the total number of items to process.
164
+     *
165
+     * @param int $value The total number of items to process.
166
+     *
167
+     * @since 1.0.0
168
+     */
169
+    private function set_count( $value ) {
170
+
171
+        if ( empty( $this->callbacks ) ) {
172
+            return;
173
+        }
174
+
175
+        foreach ( $this->callbacks as $callback ) {
176
+            call_user_func( array( $callback, 'set_count' ), $value );
177
+        }
178
+
179
+    }
180
+
181
+    /**
182
+     * Set the task progress.
183
+     *
184
+     * @param int $index The current item index.
185
+     * @param mixed $item The current item.
186
+     *
187
+     * @since 1.0.0
188
+     */
189
+    private function set_progress( $index, $item ) {
190
+
191
+        if ( empty( $this->callbacks ) ) {
192
+            return;
193
+        }
194
+
195
+        foreach ( $this->callbacks as $callback ) {
196
+            call_user_func( array( $callback, 'set_progress' ), $index, $item );
197
+        }
198
+
199
+    }
200
+
201
+    /**
202
+     * Inform the callbacks that the task completed.
203
+     *
204
+     * @since 1.0.0
205
+     */
206
+    private function finish() {
207
+
208
+        if ( empty( $this->callbacks ) ) {
209
+            return;
210
+        }
211
+
212
+        foreach ( $this->callbacks as $callback ) {
213
+            call_user_func( array( $callback, 'finish' ) );
214
+        }
215
+
216
+    }
217 217
 
218 218
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 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,32 +127,32 @@  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
-		for ( $i = 0; $i < count( $items ); $i ++ ) {
143
+		for ($i = 0; $i < count($items); $i++) {
144 144
 			// Process the item.
145
-			$this->task->process_item( $items[ $i ] );
145
+			$this->task->process_item($items[$i]);
146 146
 
147 147
 			// Update the progress.
148
-			$this->set_progress( $offset + $i, $items[ $i ] );
148
+			$this->set_progress($offset + $i, $items[$i]);
149 149
 		}
150 150
 
151 151
 		// Set the total number of elements to process.
152
-		$this->set_count( $this->task->count_items() );
152
+		$this->set_count($this->task->count_items());
153 153
 
154 154
 		// Unset the running flag.
155
-		$this->set_running( false );
155
+		$this->set_running(false);
156 156
 
157 157
 		// Set the task to complete.
158 158
 		$this->finish();
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @since 1.0.0
168 168
 	 */
169
-	private function set_count( $value ) {
169
+	private function set_count($value) {
170 170
 
171
-		if ( empty( $this->callbacks ) ) {
171
+		if (empty($this->callbacks)) {
172 172
 			return;
173 173
 		}
174 174
 
175
-		foreach ( $this->callbacks as $callback ) {
176
-			call_user_func( array( $callback, 'set_count' ), $value );
175
+		foreach ($this->callbacks as $callback) {
176
+			call_user_func(array($callback, 'set_count'), $value);
177 177
 		}
178 178
 
179 179
 	}
@@ -186,14 +186,14 @@  discard block
 block discarded – undo
186 186
 	 *
187 187
 	 * @since 1.0.0
188 188
 	 */
189
-	private function set_progress( $index, $item ) {
189
+	private function set_progress($index, $item) {
190 190
 
191
-		if ( empty( $this->callbacks ) ) {
191
+		if (empty($this->callbacks)) {
192 192
 			return;
193 193
 		}
194 194
 
195
-		foreach ( $this->callbacks as $callback ) {
196
-			call_user_func( array( $callback, 'set_progress' ), $index, $item );
195
+		foreach ($this->callbacks as $callback) {
196
+			call_user_func(array($callback, 'set_progress'), $index, $item);
197 197
 		}
198 198
 
199 199
 	}
@@ -205,12 +205,12 @@  discard block
 block discarded – undo
205 205
 	 */
206 206
 	private function finish() {
207 207
 
208
-		if ( empty( $this->callbacks ) ) {
208
+		if (empty($this->callbacks)) {
209 209
 			return;
210 210
 		}
211 211
 
212
-		foreach ( $this->callbacks as $callback ) {
213
-			call_user_func( array( $callback, 'finish' ) );
212
+		foreach ($this->callbacks as $callback) {
213
+			call_user_func(array($callback, 'finish'));
214 214
 		}
215 215
 
216 216
 	}
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
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
 	<h1><?php esc_html_e( 'Tasks', 'wordlift-framework' ); ?></h1>
14 14
 
15 15
 	<?php
16
-	foreach ( $this->task_ajax_adapters_registry->get_task_ajax_adapters() as $task_ajax_adapter ) {
17
-		$task = $task_ajax_adapter->get_task();
18
-		?>
16
+    foreach ( $this->task_ajax_adapters_registry->get_task_ajax_adapters() as $task_ajax_adapter ) {
17
+        $task = $task_ajax_adapter->get_task();
18
+        ?>
19 19
 		<div class="wl-task">
20 20
 			<h2><?php esc_html_e( $task->get_label() ); ?></h2>
21 21
 			<div class="wl-task__progress" style="border: 1px solid #23282D; height: 20px; margin: 8px 0;">
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
 		</div>
34 34
 		<?php
35
-	}
36
-	?>
35
+    }
36
+    ?>
37 37
 
38 38
 </div>
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,14 +10,14 @@  discard block
 block discarded – undo
10 10
 
11 11
 ?>
12 12
 <div class="wrap">
13
-	<h1><?php esc_html_e( 'Tasks', 'wordlift-framework' ); ?></h1>
13
+	<h1><?php esc_html_e('Tasks', 'wordlift-framework'); ?></h1>
14 14
 
15 15
 	<?php
16
-	foreach ( $this->task_ajax_adapters_registry->get_task_ajax_adapters() as $task_ajax_adapter ) {
16
+	foreach ($this->task_ajax_adapters_registry->get_task_ajax_adapters() as $task_ajax_adapter) {
17 17
 		$task = $task_ajax_adapter->get_task();
18 18
 		?>
19 19
 		<div class="wl-task">
20
-			<h2><?php esc_html_e( $task->get_label() ); ?></h2>
20
+			<h2><?php esc_html_e($task->get_label()); ?></h2>
21 21
 			<div class="wl-task__progress" style="border: 1px solid #23282D; height: 20px; margin: 8px 0;">
22 22
 				<div class="wl-task__progress__bar"
23 23
 				     style="width:0;background: #0073AA; text-align: center; height: 100%; color: #fff;"></div>
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 			<button
27 27
 				type="button"
28 28
 				class="button button-large button-primary"
29
-				data-action="<?php echo esc_attr( $task->get_id() ); ?>"
30
-				data-nonce="<?php echo esc_attr( wp_create_nonce( $task->get_id() ) ); ?>"
31
-			><?php esc_html_e( 'Start', 'wordlift-framework' ); ?></button>
29
+				data-action="<?php echo esc_attr($task->get_id()); ?>"
30
+				data-nonce="<?php echo esc_attr(wp_create_nonce($task->get_id())); ?>"
31
+			><?php esc_html_e('Start', 'wordlift-framework'); ?></button>
32 32
 
33 33
 		</div>
34 34
 		<?php
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
-	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
+    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
-	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
+    function set_progress( $counter, $item );
37 37
 
38
-	/**
39
-	 * Set the operation as complete.
40
-	 *
41
-	 * @since 1.0.0
42
-	 */
43
-	function finish();
38
+    /**
39
+     * Set the operation as complete.
40
+     *
41
+     * @since 1.0.0
42
+     */
43
+    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
-	function set_count( $value );
26
+	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
-	function set_progress( $counter, $item );
36
+	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-adapters-registry.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -4,29 +4,29 @@
 block discarded – undo
4 4
 
5 5
 class Task_Ajax_Adapters_Registry {
6 6
 
7
-	private $task_ajax_adapters = array();
7
+    private $task_ajax_adapters = array();
8 8
 
9
-	public function __construct( $adapters = array() ) {
9
+    public function __construct( $adapters = array() ) {
10 10
 
11
-		$this->task_ajax_adapters = is_array( $adapters ) ? $adapters : array( $adapters );
11
+        $this->task_ajax_adapters = is_array( $adapters ) ? $adapters : array( $adapters );
12 12
 
13
-	}
13
+    }
14 14
 
15
-	/**
16
-	 * @param Task_Ajax_Adapter $task_ajax_adapter
17
-	 */
18
-	public function register( $task_ajax_adapter ) {
15
+    /**
16
+     * @param Task_Ajax_Adapter $task_ajax_adapter
17
+     */
18
+    public function register( $task_ajax_adapter ) {
19 19
 
20
-		$this->task_ajax_adapters[] = $task_ajax_adapter;
20
+        $this->task_ajax_adapters[] = $task_ajax_adapter;
21 21
 
22
-	}
22
+    }
23 23
 
24
-	/**
25
-	 * @return Task_Ajax_Adapter[]
26
-	 */
27
-	public function get_task_ajax_adapters() {
24
+    /**
25
+     * @return Task_Ajax_Adapter[]
26
+     */
27
+    public function get_task_ajax_adapters() {
28 28
 
29
-		return $this->task_ajax_adapters;
30
-	}
29
+        return $this->task_ajax_adapters;
30
+    }
31 31
 
32 32
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,16 +6,16 @@
 block discarded – undo
6 6
 
7 7
 	private $task_ajax_adapters = array();
8 8
 
9
-	public function __construct( $adapters = array() ) {
9
+	public function __construct($adapters = array()) {
10 10
 
11
-		$this->task_ajax_adapters = is_array( $adapters ) ? $adapters : array( $adapters );
11
+		$this->task_ajax_adapters = is_array($adapters) ? $adapters : array($adapters);
12 12
 
13 13
 	}
14 14
 
15 15
 	/**
16 16
 	 * @param Task_Ajax_Adapter $task_ajax_adapter
17 17
 	 */
18
-	public function register( $task_ajax_adapter ) {
18
+	public function register($task_ajax_adapter) {
19 19
 
20 20
 		$this->task_ajax_adapters[] = $task_ajax_adapter;
21 21
 
Please login to merge, or discard this patch.
src/wordlift/tasks/class-task-ajax-progress.php 2 patches
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -18,84 +18,84 @@
 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
-	 */
62
-	public function __construct( $action ) {
63
-
64
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
65
-
66
-		$this->action = $action;
67
-
68
-	}
69
-
70
-	/**
71
-	 * {@inheritDoc}
72
-	 */
73
-	function set_count( $value ) {
74
-
75
-		$this->log->debug( "New count $value for action $this->action..." );
76
-
77
-		$this->count = $value;
78
-
79
-	}
80
-
81
-	/**
82
-	 * {@inheritDoc}
83
-	 */
84
-	function set_progress( $index, $item ) {
85
-		$this->index = $index;
86
-	}
87
-
88
-	/**
89
-	 * {@inheritDoc}
90
-	 */
91
-	function finish() {
92
-		wp_send_json_success( array(
93
-			'count'    => $this->count,
94
-			'index'    => $this->index,
95
-			// $this->index is zero based.
96
-			'complete' => $this->index >= $this->count - 1,
97
-			'nonce'    => wp_create_nonce( $this->action ),
98
-		) );
99
-	}
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
+     */
62
+    public function __construct( $action ) {
63
+
64
+        $this->log = Wordlift_Log_Service::get_logger( get_class() );
65
+
66
+        $this->action = $action;
67
+
68
+    }
69
+
70
+    /**
71
+     * {@inheritDoc}
72
+     */
73
+    function set_count( $value ) {
74
+
75
+        $this->log->debug( "New count $value for action $this->action..." );
76
+
77
+        $this->count = $value;
78
+
79
+    }
80
+
81
+    /**
82
+     * {@inheritDoc}
83
+     */
84
+    function set_progress( $index, $item ) {
85
+        $this->index = $index;
86
+    }
87
+
88
+    /**
89
+     * {@inheritDoc}
90
+     */
91
+    function finish() {
92
+        wp_send_json_success( array(
93
+            'count'    => $this->count,
94
+            'index'    => $this->index,
95
+            // $this->index is zero based.
96
+            'complete' => $this->index >= $this->count - 1,
97
+            'nonce'    => wp_create_nonce( $this->action ),
98
+        ) );
99
+    }
100 100
 
101 101
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 	 * @since 1.0.0
60 60
 	 *
61 61
 	 */
62
-	public function __construct( $action ) {
62
+	public function __construct($action) {
63 63
 
64
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
64
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
65 65
 
66 66
 		$this->action = $action;
67 67
 
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 	/**
71 71
 	 * {@inheritDoc}
72 72
 	 */
73
-	function set_count( $value ) {
73
+	function set_count($value) {
74 74
 
75
-		$this->log->debug( "New count $value for action $this->action..." );
75
+		$this->log->debug("New count $value for action $this->action...");
76 76
 
77 77
 		$this->count = $value;
78 78
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	/**
82 82
 	 * {@inheritDoc}
83 83
 	 */
84
-	function set_progress( $index, $item ) {
84
+	function set_progress($index, $item) {
85 85
 		$this->index = $index;
86 86
 	}
87 87
 
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 	 * {@inheritDoc}
90 90
 	 */
91 91
 	function finish() {
92
-		wp_send_json_success( array(
92
+		wp_send_json_success(array(
93 93
 			'count'    => $this->count,
94 94
 			'index'    => $this->index,
95 95
 			// $this->index is zero based.
96 96
 			'complete' => $this->index >= $this->count - 1,
97
-			'nonce'    => wp_create_nonce( $this->action ),
98
-		) );
97
+			'nonce'    => wp_create_nonce($this->action),
98
+		));
99 99
 	}
100 100
 
101 101
 }
Please login to merge, or discard this patch.