Completed
Push — develop ( 8d420d...5cacbb )
by David
03:04 queued 13s
created
src/wordlift/images-licenses/admin/class-image-license-page.php 1 patch
Spacing   +55 added lines, -55 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,7 +44,7 @@  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 49
         <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus laudantium nam nihil provident sequi?
50 50
             Alias aliquam, animi debitis distinctio dolores laboriosam modi optio possimus qui, quis suscipit, unde
@@ -52,33 +52,33 @@  discard block
 block discarded – undo
52 52
 
53 53
         <div class="tablenav top">
54 54
             <a class="button"
55
-               href="<?php echo admin_url( 'admin.php?page=wl_images_licenses__reload_data' ); ?>"><?php esc_html_e( 'Reload data', 'wordlift' ); ?></a>
55
+               href="<?php echo admin_url('admin.php?page=wl_images_licenses__reload_data'); ?>"><?php esc_html_e('Reload data', 'wordlift'); ?></a>
56 56
             <a class="button"
57
-               href="<?php echo admin_url( 'admin.php?page=wl_images_licenses__remove_all_images' ); ?>"><?php esc_html_e( 'Remove all images', 'wordlift' ); ?></a>
57
+               href="<?php echo admin_url('admin.php?page=wl_images_licenses__remove_all_images'); ?>"><?php esc_html_e('Remove all images', 'wordlift'); ?></a>
58 58
             <a class="button"
59
-               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>
59
+               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>
60 60
         </div>
61 61
 
62
-        <h2 class="screen-reader-text"><?php esc_html_e( 'Images', 'wordlift' ); ?></h2>
62
+        <h2 class="screen-reader-text"><?php esc_html_e('Images', 'wordlift'); ?></h2>
63 63
 
64 64
         <table class="wp-list-table widefat fixed striped">
65 65
             <thead>
66 66
             <tr>
67
-                <th><?php esc_html_e( 'Thumbnail', 'wordlift' ); ?></th>
68
-                <th><?php esc_html_e( 'Filename', 'wordlift' ); ?></th>
69
-                <th><?php esc_html_e( 'License', 'wordlift' ); ?></th>
70
-                <th><?php esc_html_e( 'Author', 'wordlift' ); ?></th>
71
-                <th><?php esc_html_e( 'Proposed Caption', 'wordlift' ); ?></th>
72
-                <th><?php esc_html_e( 'More Info', 'wordlift' ); ?></th>
73
-                <th><?php esc_html_e( 'Posts', 'wordlift' ); ?></th>
74
-                <th><?php esc_html_e( 'Actions', 'wordlift' ); ?></th>
67
+                <th><?php esc_html_e('Thumbnail', 'wordlift'); ?></th>
68
+                <th><?php esc_html_e('Filename', 'wordlift'); ?></th>
69
+                <th><?php esc_html_e('License', 'wordlift'); ?></th>
70
+                <th><?php esc_html_e('Author', 'wordlift'); ?></th>
71
+                <th><?php esc_html_e('Proposed Caption', 'wordlift'); ?></th>
72
+                <th><?php esc_html_e('More Info', 'wordlift'); ?></th>
73
+                <th><?php esc_html_e('Posts', 'wordlift'); ?></th>
74
+                <th><?php esc_html_e('Actions', 'wordlift'); ?></th>
75 75
             </tr>
76 76
             </thead>
77 77
 			<?php
78 78
 			$images = $this->data;
79 79
 
80
-			for ( $i = 0; $i < count( $images ); $i ++ ) {
81
-				$this->render_image( $images[ $i ], $i );
80
+			for ($i = 0; $i < count($images); $i++) {
81
+				$this->render_image($images[$i], $i);
82 82
 			}
83 83
 			?>
84 84
         </table>
@@ -88,97 +88,97 @@  discard block
 block discarded – undo
88 88
 	/**
89 89
 	 * @param array $image
90 90
 	 */
91
-	private function render_image( $image, $idx ) {
91
+	private function render_image($image, $idx) {
92 92
 
93 93
 		$attachment_id = $image['attachment_id'];
94 94
 
95 95
 		// Skip if the post doesn't exist anymore or has been fixed.
96
-		if ( ! $this->exists( $attachment_id ) ) {
96
+		if ( ! $this->exists($attachment_id)) {
97 97
 			return;
98 98
 		}
99 99
 
100
-		$author = html_entity_decode( $image['author'] );
100
+		$author = html_entity_decode($image['author']);
101 101
 
102
-		$more_info_link_esc = esc_url( $image['more_info_link'] );
102
+		$more_info_link_esc = esc_url($image['more_info_link']);
103 103
 
104 104
 		$is_unknown_license = '#N/A' === $image['license'];
105 105
 
106
-		$caption_builder  = new Caption_Builder( $image );
106
+		$caption_builder  = new Caption_Builder($image);
107 107
 		$proposed_caption = $caption_builder->build();
108 108
 
109 109
 		$script_id = "wl-image-$idx";
110 110
 		$row_id    = "wl-row-$idx";
111 111
 		?>
112 112
         <tr id="<?php echo $row_id; ?>">
113
-            <td><?php echo wp_get_attachment_image( $attachment_id, array( 100, ) ); ?></td>
114
-            <td><?php echo esc_html( $image['filename'] ); ?></td>
115
-            <td><?php echo esc_html( $image['license'] ); ?></td>
113
+            <td><?php echo wp_get_attachment_image($attachment_id, array(100,)); ?></td>
114
+            <td><?php echo esc_html($image['filename']); ?></td>
115
+            <td><?php echo esc_html($image['license']); ?></td>
116 116
             <td><?php echo $author; ?></td>
117 117
             <td><?php echo $proposed_caption; ?></td>
118 118
             <td>
119 119
                 <a href="<?php echo $more_info_link_esc; ?>"
120
-                   target="_blank"><?php esc_html_e( 'More information', 'wordlift' ); ?></a>
120
+                   target="_blank"><?php esc_html_e('More information', 'wordlift'); ?></a>
121 121
             </td>
122 122
             <td>
123 123
 				<?php
124
-				$this->partial_used_in_posts( $image['posts_ids_as_featured_image'], __( 'Used as featured image in %d post(s):', 'wordlift' ) );
125
-				$this->partial_used_in_posts( $image['posts_ids_as_embed'], __( 'Embedded in %d post(s):', 'wordlift' ) );
124
+				$this->partial_used_in_posts($image['posts_ids_as_featured_image'], __('Used as featured image in %d post(s):', 'wordlift'));
125
+				$this->partial_used_in_posts($image['posts_ids_as_embed'], __('Embedded in %d post(s):', 'wordlift'));
126 126
 				?>
127 127
             </td>
128 128
             <td>
129 129
                 <script type="application/json"
130
-                        id="<?php echo $script_id; ?>"><?php echo json_encode( $image ); ?></script>
130
+                        id="<?php echo $script_id; ?>"><?php echo json_encode($image); ?></script>
131 131
                 <button data-id="<?php echo $script_id; ?>"
132 132
                         data-row-id="<?php echo $row_id; ?>"
133 133
                         data-action="wl_remove_all_images_task__single"
134
-                        class="button wl-action-btn"><?php esc_html_e( 'Remove image', 'wordlift' ); ?></button>
135
-				<?php if ( ! $is_unknown_license ) { ?>
134
+                        class="button wl-action-btn"><?php esc_html_e('Remove image', 'wordlift'); ?></button>
135
+				<?php if ( ! $is_unknown_license) { ?>
136 136
                     <button data-id="<?php echo $script_id; ?>"
137 137
                             data-row-id="<?php echo $row_id; ?>"
138 138
                             data-action="wl_add_license_caption_or_remove__single"
139
-                            class="button wl-action-btn"><?php esc_html_e( 'Add license caption', 'wordlift' ); ?></button>
139
+                            class="button wl-action-btn"><?php esc_html_e('Add license caption', 'wordlift'); ?></button>
140 140
 				<?php } ?>
141 141
                 <a class="button"
142
-                   href=" <?php echo get_edit_post_link( $attachment_id ); ?>"
143
-                   target="_blank"><?php esc_html_e( 'Edit image', 'wordlift' ); ?> <span
142
+                   href=" <?php echo get_edit_post_link($attachment_id); ?>"
143
+                   target="_blank"><?php esc_html_e('Edit image', 'wordlift'); ?> <span
144 144
                             class="dashicons dashicons-external"></span></a>
145 145
             </td>
146 146
         </tr>
147 147
 		<?php
148 148
 	}
149 149
 
150
-	private function partial_used_in_posts( $data, $label ) {
150
+	private function partial_used_in_posts($data, $label) {
151 151
 
152 152
 		// Bail out if there's not data.
153
-		$count = count( $data );
154
-		if ( 0 === $count ) {
153
+		$count = count($data);
154
+		if (0 === $count) {
155 155
 			return;
156 156
 		}
157 157
 
158
-		echo esc_html( sprintf( $label, $count ) );
159
-		foreach ( $data as $post_id ) {
160
-			$post = get_post( $post_id ); ?>
161
-            <a href="<?php echo get_permalink( $post_id ); ?>"><?php echo esc_html( $post->post_title ); ?></a>
158
+		echo esc_html(sprintf($label, $count));
159
+		foreach ($data as $post_id) {
160
+			$post = get_post($post_id); ?>
161
+            <a href="<?php echo get_permalink($post_id); ?>"><?php echo esc_html($post->post_title); ?></a>
162 162
 			<?php
163 163
 		}
164 164
 	}
165 165
 
166 166
 	function enqueue_scripts() {
167 167
 
168
-		wp_enqueue_script( $this->get_menu_slug(), plugin_dir_url( __FILE__ ) . 'assets/image-license.js', array( 'wp-util' ), $this->version, true );
169
-		wp_localize_script( $this->get_menu_slug(), '_wlImageLicensePageSettings', array(
168
+		wp_enqueue_script($this->get_menu_slug(), plugin_dir_url(__FILE__).'assets/image-license.js', array('wp-util'), $this->version, true);
169
+		wp_localize_script($this->get_menu_slug(), '_wlImageLicensePageSettings', array(
170 170
 			'_ajax_nonce' => array(
171
-				Add_License_Caption_Or_Remove_Task::MENU_SLUG => wp_create_nonce( Add_License_Caption_Or_Remove_Task::MENU_SLUG ),
172
-				Remove_All_Images_Task::MENU_SLUG             => wp_create_nonce( Remove_All_Images_Task::MENU_SLUG ),
171
+				Add_License_Caption_Or_Remove_Task::MENU_SLUG => wp_create_nonce(Add_License_Caption_Or_Remove_Task::MENU_SLUG),
172
+				Remove_All_Images_Task::MENU_SLUG             => wp_create_nonce(Remove_All_Images_Task::MENU_SLUG),
173 173
 			),
174 174
 			'l10n'        => array(
175
-				'Done'              => __( 'Done', 'wordlift' ),
176
-				'An error occurred' => __( 'An error occurred', 'wordlift' ),
175
+				'Done'              => __('Done', 'wordlift'),
176
+				'An error occurred' => __('An error occurred', 'wordlift'),
177 177
 			)
178
-		) );
178
+		));
179 179
 	}
180 180
 
181
-	private function exists( $attachment_id ) {
181
+	private function exists($attachment_id) {
182 182
 		global $wpdb;
183 183
 
184 184
 		$sql =
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
               AND pm2.meta_value IS NULL
194 194
             ";
195 195
 
196
-		return $wpdb->get_var( $wpdb->prepare(
196
+		return $wpdb->get_var($wpdb->prepare(
197 197
 			$sql,
198 198
 			'_wl_image_license_fixed',
199 199
 			$attachment_id,
200 200
 			'_wp_attached_file'
201
-		) );
201
+		));
202 202
 	}
203 203
 
204 204
 }
Please login to merge, or discard this patch.
wordlift/images-licenses/tasks/class-add-license-caption-or-remove-task.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -7,114 +7,114 @@
 block discarded – undo
7 7
 
8 8
 class Add_License_Caption_Or_Remove_Task extends Remove_All_Images_Task {
9 9
 
10
-	const MENU_SLUG = 'wl_add_license_caption_or_remove';
10
+    const MENU_SLUG = 'wl_add_license_caption_or_remove';
11 11
 
12
-	/**
13
-	 * @var Image_License_Service
14
-	 */
15
-	private $image_license_service;
12
+    /**
13
+     * @var Image_License_Service
14
+     */
15
+    private $image_license_service;
16 16
 
17
-	/**
18
-	 * Remove_All_Images_Task constructor.
19
-	 *
20
-	 * @param Image_License_Service $image_license_service
21
-	 */
22
-	public function __construct( $image_license_service ) {
23
-		parent::__construct( $image_license_service );
17
+    /**
18
+     * Remove_All_Images_Task constructor.
19
+     *
20
+     * @param Image_License_Service $image_license_service
21
+     */
22
+    public function __construct( $image_license_service ) {
23
+        parent::__construct( $image_license_service );
24 24
 
25
-		$this->image_license_service = $image_license_service;
25
+        $this->image_license_service = $image_license_service;
26 26
 
27
-		add_action( 'wp_ajax_' . $this->get_id() . '__single', array( $this, 'ajax', ) );
27
+        add_action( 'wp_ajax_' . $this->get_id() . '__single', array( $this, 'ajax', ) );
28 28
 
29
-	}
29
+    }
30 30
 
31
-	public function ajax() {
31
+    public function ajax() {
32 32
 
33
-		check_ajax_referer( $this->get_id() );
33
+        check_ajax_referer( $this->get_id() );
34 34
 
35
-		$this->process_item( $_POST );
35
+        $this->process_item( $_POST );
36 36
 
37
-		wp_send_json_success();
37
+        wp_send_json_success();
38 38
 
39
-	}
39
+    }
40 40
 
41
-	/**
42
-	 * @inheritDoc
43
-	 */
44
-	function get_id() {
41
+    /**
42
+     * @inheritDoc
43
+     */
44
+    function get_id() {
45 45
 
46
-		return self::MENU_SLUG;
47
-	}
46
+        return self::MENU_SLUG;
47
+    }
48 48
 
49
-	function get_label() {
49
+    function get_label() {
50 50
 
51
-		return __( 'Add license caption to images and remove those with unknown license', 'wordlift' );
52
-	}
51
+        return __( 'Add license caption to images and remove those with unknown license', 'wordlift' );
52
+    }
53 53
 
54
-	/**
55
-	 * @inheritDoc
56
-	 */
57
-	function process_item( $item ) {
54
+    /**
55
+     * @inheritDoc
56
+     */
57
+    function process_item( $item ) {
58 58
 
59
-		$is_unknown_license = '#N/A' === $item['license'];
59
+        $is_unknown_license = '#N/A' === $item['license'];
60 60
 
61
-		// If the license is unknown, delete the attachment.
62
-		if ( $is_unknown_license ) {
63
-			parent::process_item( $item );
61
+        // If the license is unknown, delete the attachment.
62
+        if ( $is_unknown_license ) {
63
+            parent::process_item( $item );
64 64
 
65
-			return;
66
-		}
65
+            return;
66
+        }
67 67
 
68
-		$caption_builder = new Caption_Builder( $item );
69
-		$caption         = $caption_builder->build();
68
+        $caption_builder = new Caption_Builder( $item );
69
+        $caption         = $caption_builder->build();
70 70
 
71
-		wp_update_post( array(
72
-			'ID'           => $item['attachment_id'],
73
-			'post_excerpt' => $caption
74
-		) );
71
+        wp_update_post( array(
72
+            'ID'           => $item['attachment_id'],
73
+            'post_excerpt' => $caption
74
+        ) );
75 75
 
76
-		// Avoid running the regex on post content more than once.
77
-		$fixed = get_post_meta( $item['attachment_id'], '_wl_image_license_fixed', true );
78
-		if ( ! empty( $fixed ) ) {
79
-			return;
80
-		}
76
+        // Avoid running the regex on post content more than once.
77
+        $fixed = get_post_meta( $item['attachment_id'], '_wl_image_license_fixed', true );
78
+        if ( ! empty( $fixed ) ) {
79
+            return;
80
+        }
81 81
 
82
-		if ( ! isset( $item['posts_ids_as_embed'] ) ) {
83
-			foreach ( $item['posts_ids_as_embed'] as $post_id ) {
82
+        if ( ! isset( $item['posts_ids_as_embed'] ) ) {
83
+            foreach ( $item['posts_ids_as_embed'] as $post_id ) {
84 84
 
85
-				$figure = sprintf(
86
-					'
85
+                $figure = sprintf(
86
+                    '
87 87
 				<figure>
88 88
 					$0
89 89
 					<figcaption>%s</figcaption>
90 90
 				</figure>
91 91
 				', $caption );
92 92
 
93
-				/**
94
-				 * <figure>
95
-				 * <img src="/media/examples/elephant-660-480.jpg"
96
-				 * alt="Elephant at sunset">
97
-				 * <figcaption>An elephant at sunset</figcaption>
98
-				 * </figure>
99
-				 */
93
+                /**
94
+                 * <figure>
95
+                 * <img src="/media/examples/elephant-660-480.jpg"
96
+                 * alt="Elephant at sunset">
97
+                 * <figcaption>An elephant at sunset</figcaption>
98
+                 * </figure>
99
+                 */
100 100
 
101
-				$filename       = $item['filename'];
102
-				$filename_quote = preg_quote( $filename );
103
-				$post           = get_post( $post_id );
104
-				$pattern        = '@<img[^>]*src="[^"]+wl/[^"]+' . $filename_quote . '"[^>]*>@';
105
-				$post_content   = preg_replace( $pattern, $figure, $post->post_content );
101
+                $filename       = $item['filename'];
102
+                $filename_quote = preg_quote( $filename );
103
+                $post           = get_post( $post_id );
104
+                $pattern        = '@<img[^>]*src="[^"]+wl/[^"]+' . $filename_quote . '"[^>]*>@';
105
+                $post_content   = preg_replace( $pattern, $figure, $post->post_content );
106 106
 
107
-				wp_update_post( array(
108
-					'ID'           => $post_id,
109
-					'post_content' => $post_content,
110
-				) );
107
+                wp_update_post( array(
108
+                    'ID'           => $post_id,
109
+                    'post_content' => $post_content,
110
+                ) );
111 111
 
112
-			}
113
-		}
112
+            }
113
+        }
114 114
 
115
-		// Set the attachment as fixed.
116
-		update_post_meta( $item['attachment_id'], '_wl_image_license_fixed', time() );
115
+        // Set the attachment as fixed.
116
+        update_post_meta( $item['attachment_id'], '_wl_image_license_fixed', time() );
117 117
 
118
-	}
118
+    }
119 119
 
120 120
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -19,20 +19,20 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @param Image_License_Service $image_license_service
21 21
 	 */
22
-	public function __construct( $image_license_service ) {
23
-		parent::__construct( $image_license_service );
22
+	public function __construct($image_license_service) {
23
+		parent::__construct($image_license_service);
24 24
 
25 25
 		$this->image_license_service = $image_license_service;
26 26
 
27
-		add_action( 'wp_ajax_' . $this->get_id() . '__single', array( $this, 'ajax', ) );
27
+		add_action('wp_ajax_'.$this->get_id().'__single', array($this, 'ajax',));
28 28
 
29 29
 	}
30 30
 
31 31
 	public function ajax() {
32 32
 
33
-		check_ajax_referer( $this->get_id() );
33
+		check_ajax_referer($this->get_id());
34 34
 
35
-		$this->process_item( $_POST );
35
+		$this->process_item($_POST);
36 36
 
37 37
 		wp_send_json_success();
38 38
 
@@ -48,39 +48,39 @@  discard block
 block discarded – undo
48 48
 
49 49
 	function get_label() {
50 50
 
51
-		return __( 'Add license caption to images and remove those with unknown license', 'wordlift' );
51
+		return __('Add license caption to images and remove those with unknown license', 'wordlift');
52 52
 	}
53 53
 
54 54
 	/**
55 55
 	 * @inheritDoc
56 56
 	 */
57
-	function process_item( $item ) {
57
+	function process_item($item) {
58 58
 
59 59
 		$is_unknown_license = '#N/A' === $item['license'];
60 60
 
61 61
 		// If the license is unknown, delete the attachment.
62
-		if ( $is_unknown_license ) {
63
-			parent::process_item( $item );
62
+		if ($is_unknown_license) {
63
+			parent::process_item($item);
64 64
 
65 65
 			return;
66 66
 		}
67 67
 
68
-		$caption_builder = new Caption_Builder( $item );
68
+		$caption_builder = new Caption_Builder($item);
69 69
 		$caption         = $caption_builder->build();
70 70
 
71
-		wp_update_post( array(
71
+		wp_update_post(array(
72 72
 			'ID'           => $item['attachment_id'],
73 73
 			'post_excerpt' => $caption
74
-		) );
74
+		));
75 75
 
76 76
 		// Avoid running the regex on post content more than once.
77
-		$fixed = get_post_meta( $item['attachment_id'], '_wl_image_license_fixed', true );
78
-		if ( ! empty( $fixed ) ) {
77
+		$fixed = get_post_meta($item['attachment_id'], '_wl_image_license_fixed', true);
78
+		if ( ! empty($fixed)) {
79 79
 			return;
80 80
 		}
81 81
 
82
-		if ( ! isset( $item['posts_ids_as_embed'] ) ) {
83
-			foreach ( $item['posts_ids_as_embed'] as $post_id ) {
82
+		if ( ! isset($item['posts_ids_as_embed'])) {
83
+			foreach ($item['posts_ids_as_embed'] as $post_id) {
84 84
 
85 85
 				$figure = sprintf(
86 86
 					'
@@ -99,21 +99,21 @@  discard block
 block discarded – undo
99 99
 				 */
100 100
 
101 101
 				$filename       = $item['filename'];
102
-				$filename_quote = preg_quote( $filename );
103
-				$post           = get_post( $post_id );
104
-				$pattern        = '@<img[^>]*src="[^"]+wl/[^"]+' . $filename_quote . '"[^>]*>@';
105
-				$post_content   = preg_replace( $pattern, $figure, $post->post_content );
102
+				$filename_quote = preg_quote($filename);
103
+				$post           = get_post($post_id);
104
+				$pattern        = '@<img[^>]*src="[^"]+wl/[^"]+'.$filename_quote.'"[^>]*>@';
105
+				$post_content   = preg_replace($pattern, $figure, $post->post_content);
106 106
 
107
-				wp_update_post( array(
107
+				wp_update_post(array(
108 108
 					'ID'           => $post_id,
109 109
 					'post_content' => $post_content,
110
-				) );
110
+				));
111 111
 
112 112
 			}
113 113
 		}
114 114
 
115 115
 		// Set the attachment as fixed.
116
-		update_post_meta( $item['attachment_id'], '_wl_image_license_fixed', time() );
116
+		update_post_meta($item['attachment_id'], '_wl_image_license_fixed', time());
117 117
 
118 118
 	}
119 119
 
Please login to merge, or discard this patch.
src/wordlift/images-licenses/tasks/class-remove-all-images-task.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -7,104 +7,104 @@
 block discarded – undo
7 7
 
8 8
 class Remove_All_Images_Task implements Task {
9 9
 
10
-	const MENU_SLUG = 'wl_remove_all_images_task';
10
+    const MENU_SLUG = 'wl_remove_all_images_task';
11 11
 
12
-	/**
13
-	 * @var Image_License_Service
14
-	 */
15
-	private $image_license_service;
12
+    /**
13
+     * @var Image_License_Service
14
+     */
15
+    private $image_license_service;
16 16
 
17
-	/**
18
-	 * Remove_All_Images_Task constructor.
19
-	 *
20
-	 * @param Image_License_Service $image_license_service
21
-	 */
22
-	public function __construct( $image_license_service ) {
17
+    /**
18
+     * Remove_All_Images_Task constructor.
19
+     *
20
+     * @param Image_License_Service $image_license_service
21
+     */
22
+    public function __construct( $image_license_service ) {
23 23
 
24
-		$this->image_license_service = $image_license_service;
24
+        $this->image_license_service = $image_license_service;
25 25
 
26 26
 
27
-		add_action( 'wp_ajax_' . $this->get_id() . '__single', array( $this, 'ajax', ) );
27
+        add_action( 'wp_ajax_' . $this->get_id() . '__single', array( $this, 'ajax', ) );
28 28
 
29
-	}
29
+    }
30 30
 
31
-	public function ajax() {
31
+    public function ajax() {
32 32
 
33
-		check_ajax_referer( $this->get_id() );
33
+        check_ajax_referer( $this->get_id() );
34 34
 
35
-		$this->process_item( $_POST );
35
+        $this->process_item( $_POST );
36 36
 
37
-		wp_send_json_success();
37
+        wp_send_json_success();
38 38
 
39
-	}
39
+    }
40 40
 
41
-	/**
42
-	 * @inheritDoc
43
-	 */
44
-	function get_id() {
41
+    /**
42
+     * @inheritDoc
43
+     */
44
+    function get_id() {
45 45
 
46
-		return self::MENU_SLUG;
47
-	}
46
+        return self::MENU_SLUG;
47
+    }
48 48
 
49
-	function get_label() {
49
+    function get_label() {
50 50
 
51
-		return __( 'Remove all images', 'wordlift' );
52
-	}
51
+        return __( 'Remove all images', 'wordlift' );
52
+    }
53 53
 
54
-	/**
55
-	 * @inheritDoc
56
-	 */
57
-	function list_items( $limit = 10, $offset = 0 ) {
54
+    /**
55
+     * @inheritDoc
56
+     */
57
+    function list_items( $limit = 10, $offset = 0 ) {
58 58
 
59
-		$data = $this->image_license_service->get_non_public_domain_images();
59
+        $data = $this->image_license_service->get_non_public_domain_images();
60 60
 
61
-		return array_slice( $data, $offset, $limit );
62
-	}
61
+        return array_slice( $data, $offset, $limit );
62
+    }
63 63
 
64
-	/**
65
-	 * @inheritDoc
66
-	 */
67
-	function count_items() {
64
+    /**
65
+     * @inheritDoc
66
+     */
67
+    function count_items() {
68 68
 
69
-		$data = $this->image_license_service->get_non_public_domain_images();
69
+        $data = $this->image_license_service->get_non_public_domain_images();
70 70
 
71
-		return count( $data );
72
-	}
71
+        return count( $data );
72
+    }
73 73
 
74
-	/**
75
-	 * @inheritDoc
76
-	 */
77
-	function process_item( $item ) {
74
+    /**
75
+     * @inheritDoc
76
+     */
77
+    function process_item( $item ) {
78 78
 
79
-		// Avoid deleting images that have been marked as fixed.
80
-		$fixed = get_post_meta( $item['attachment_id'], '_wl_image_license_fixed', true );
81
-		if ( ! empty( $fixed ) ) {
82
-			return;
83
-		}
79
+        // Avoid deleting images that have been marked as fixed.
80
+        $fixed = get_post_meta( $item['attachment_id'], '_wl_image_license_fixed', true );
81
+        if ( ! empty( $fixed ) ) {
82
+            return;
83
+        }
84 84
 
85
-		if ( ! isset( $item['posts_ids_as_embed'] ) ) {
86
-			foreach ( $item['posts_ids_as_embed'] as $post_id ) {
85
+        if ( ! isset( $item['posts_ids_as_embed'] ) ) {
86
+            foreach ( $item['posts_ids_as_embed'] as $post_id ) {
87 87
 
88
-				$filename       = $item['filename'];
89
-				$filename_quote = preg_quote( $filename );
90
-				$post           = get_post( $post_id );
91
-				$search         = array(
92
-					'@<a[^>]*href="[^"]+wl/[^"]+' . $filename_quote . '"[^>]*>(.+?)<\/a>@',
93
-					'@<img[^>]*src="[^"]+wl/[^"]+' . $filename_quote . '"[^>]*>@',
94
-				);
95
-				$replace        = array( '$1', '', );
96
-				$post_content   = preg_replace( $search, $replace, $post->post_content );
88
+                $filename       = $item['filename'];
89
+                $filename_quote = preg_quote( $filename );
90
+                $post           = get_post( $post_id );
91
+                $search         = array(
92
+                    '@<a[^>]*href="[^"]+wl/[^"]+' . $filename_quote . '"[^>]*>(.+?)<\/a>@',
93
+                    '@<img[^>]*src="[^"]+wl/[^"]+' . $filename_quote . '"[^>]*>@',
94
+                );
95
+                $replace        = array( '$1', '', );
96
+                $post_content   = preg_replace( $search, $replace, $post->post_content );
97 97
 
98
-				wp_update_post( array(
99
-					'ID'           => $post_id,
100
-					'post_content' => $post_content,
101
-				) );
98
+                wp_update_post( array(
99
+                    'ID'           => $post_id,
100
+                    'post_content' => $post_content,
101
+                ) );
102 102
 
103
-			}
103
+            }
104 104
 
105
-			wp_delete_attachment( $item['attachment_id'], true );
106
-		}
105
+            wp_delete_attachment( $item['attachment_id'], true );
106
+        }
107 107
 
108
-	}
108
+    }
109 109
 
110 110
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -19,20 +19,20 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @param Image_License_Service $image_license_service
21 21
 	 */
22
-	public function __construct( $image_license_service ) {
22
+	public function __construct($image_license_service) {
23 23
 
24 24
 		$this->image_license_service = $image_license_service;
25 25
 
26 26
 
27
-		add_action( 'wp_ajax_' . $this->get_id() . '__single', array( $this, 'ajax', ) );
27
+		add_action('wp_ajax_'.$this->get_id().'__single', array($this, 'ajax',));
28 28
 
29 29
 	}
30 30
 
31 31
 	public function ajax() {
32 32
 
33
-		check_ajax_referer( $this->get_id() );
33
+		check_ajax_referer($this->get_id());
34 34
 
35
-		$this->process_item( $_POST );
35
+		$this->process_item($_POST);
36 36
 
37 37
 		wp_send_json_success();
38 38
 
@@ -48,17 +48,17 @@  discard block
 block discarded – undo
48 48
 
49 49
 	function get_label() {
50 50
 
51
-		return __( 'Remove all images', 'wordlift' );
51
+		return __('Remove all images', 'wordlift');
52 52
 	}
53 53
 
54 54
 	/**
55 55
 	 * @inheritDoc
56 56
 	 */
57
-	function list_items( $limit = 10, $offset = 0 ) {
57
+	function list_items($limit = 10, $offset = 0) {
58 58
 
59 59
 		$data = $this->image_license_service->get_non_public_domain_images();
60 60
 
61
-		return array_slice( $data, $offset, $limit );
61
+		return array_slice($data, $offset, $limit);
62 62
 	}
63 63
 
64 64
 	/**
@@ -68,41 +68,41 @@  discard block
 block discarded – undo
68 68
 
69 69
 		$data = $this->image_license_service->get_non_public_domain_images();
70 70
 
71
-		return count( $data );
71
+		return count($data);
72 72
 	}
73 73
 
74 74
 	/**
75 75
 	 * @inheritDoc
76 76
 	 */
77
-	function process_item( $item ) {
77
+	function process_item($item) {
78 78
 
79 79
 		// Avoid deleting images that have been marked as fixed.
80
-		$fixed = get_post_meta( $item['attachment_id'], '_wl_image_license_fixed', true );
81
-		if ( ! empty( $fixed ) ) {
80
+		$fixed = get_post_meta($item['attachment_id'], '_wl_image_license_fixed', true);
81
+		if ( ! empty($fixed)) {
82 82
 			return;
83 83
 		}
84 84
 
85
-		if ( ! isset( $item['posts_ids_as_embed'] ) ) {
86
-			foreach ( $item['posts_ids_as_embed'] as $post_id ) {
85
+		if ( ! isset($item['posts_ids_as_embed'])) {
86
+			foreach ($item['posts_ids_as_embed'] as $post_id) {
87 87
 
88 88
 				$filename       = $item['filename'];
89
-				$filename_quote = preg_quote( $filename );
90
-				$post           = get_post( $post_id );
89
+				$filename_quote = preg_quote($filename);
90
+				$post           = get_post($post_id);
91 91
 				$search         = array(
92
-					'@<a[^>]*href="[^"]+wl/[^"]+' . $filename_quote . '"[^>]*>(.+?)<\/a>@',
93
-					'@<img[^>]*src="[^"]+wl/[^"]+' . $filename_quote . '"[^>]*>@',
92
+					'@<a[^>]*href="[^"]+wl/[^"]+'.$filename_quote.'"[^>]*>(.+?)<\/a>@',
93
+					'@<img[^>]*src="[^"]+wl/[^"]+'.$filename_quote.'"[^>]*>@',
94 94
 				);
95
-				$replace        = array( '$1', '', );
96
-				$post_content   = preg_replace( $search, $replace, $post->post_content );
95
+				$replace        = array('$1', '',);
96
+				$post_content   = preg_replace($search, $replace, $post->post_content);
97 97
 
98
-				wp_update_post( array(
98
+				wp_update_post(array(
99 99
 					'ID'           => $post_id,
100 100
 					'post_content' => $post_content,
101
-				) );
101
+				));
102 102
 
103 103
 			}
104 104
 
105
-			wp_delete_attachment( $item['attachment_id'], true );
105
+			wp_delete_attachment($item['attachment_id'], true);
106 106
 		}
107 107
 
108 108
 	}
Please login to merge, or discard this patch.