Completed
Push — master ( 58fb4c...ef04cf )
by Mike
02:29
created
uninstall.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,12 +4,12 @@
 block discarded – undo
4 4
 
5 5
 // If uninstall is not called from WordPress, exit
6 6
 if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 // Check if the current user has priveledges to run this method
11 11
 if ( ! current_user_can( 'activate_plugins' ) ){
12
-    return;
12
+	return;
13 13
 }
14 14
 
15 15
 require dirname( __FILE__ ) . '/includes/class-delete.php';
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,16 +3,16 @@
 block discarded – undo
3 3
 use testContent as test;
4 4
 
5 5
 // If uninstall is not called from WordPress, exit
6
-if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
6
+if (!defined('WP_UNINSTALL_PLUGIN')) {
7 7
     exit();
8 8
 }
9 9
 
10 10
 // Check if the current user has priveledges to run this method
11
-if ( ! current_user_can( 'activate_plugins' ) ){
11
+if (!current_user_can('activate_plugins')) {
12 12
     return;
13 13
 }
14 14
 
15
-require dirname( __FILE__ ) . '/includes/class-delete.php';
15
+require dirname(__FILE__).'/includes/class-delete.php';
16 16
 $delete = new test\Delete;
17 17
 
18 18
 // Delete all the things
Please login to merge, or discard this patch.
includes/class-delete.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 		$post_types = get_post_types( array( 'public' => true ), 'objects' );
26 26
 		foreach ( $post_types as $post_type ) :
27 27
 
28
-		    $this->delete_posts( $post_type->name );
28
+			$this->delete_posts( $post_type->name );
29 29
 
30 30
 		endforeach;
31 31
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		$taxonomies = get_taxonomies();
34 34
 		foreach ( $taxonomies as $tax ) :
35 35
 
36
-		    $this->delete_terms( $tax );
36
+			$this->delete_terms( $tax );
37 37
 
38 38
 		endforeach;
39 39
 
@@ -182,14 +182,14 @@  discard block
 block discarded – undo
182 182
 
183 183
 		// Query for our terms
184 184
 		$args = array(
185
-		    'hide_empty' => false,
186
-		    'meta_query' => array(
187
-		        array(
188
-		           'key'       => 'evans_test_content',
189
-		           'value'     => '__test__',
190
-		           'compare'   => '='
191
-		        )
192
-		    )
185
+			'hide_empty' => false,
186
+			'meta_query' => array(
187
+				array(
188
+				   'key'       => 'evans_test_content',
189
+				   'value'     => '__test__',
190
+				   'compare'   => '='
191
+				)
192
+			)
193 193
 		);
194 194
 
195 195
 		$terms = get_terms( $slug, $args );
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -8,32 +8,32 @@  discard block
 block discarded – undo
8 8
  * @subpackage Evans
9 9
  * @author     Old Town Media
10 10
  */
11
-class Delete{
11
+class Delete {
12 12
 
13 13
 	/**
14 14
 	 * Delete all test content created ever.
15 15
 	 *
16 16
 	 * @access private
17 17
 	 */
18
-	public function delete_all_test_data(){
18
+	public function delete_all_test_data() {
19 19
 
20
-		if ( !$this->user_can_delete() ){
20
+		if (!$this->user_can_delete()) {
21 21
 			return;
22 22
 		}
23 23
 
24 24
 		// Loop through all post types and remove any test data
25
-		$post_types = get_post_types( array( 'public' => true ), 'objects' );
26
-		foreach ( $post_types as $post_type ) :
25
+		$post_types = get_post_types(array('public' => true), 'objects');
26
+		foreach ($post_types as $post_type) :
27 27
 
28
-		    $this->delete_posts( $post_type->name );
28
+		    $this->delete_posts($post_type->name);
29 29
 
30 30
 		endforeach;
31 31
 
32 32
 		// Loop through all taxonomies and remove any data
33 33
 		$taxonomies = get_taxonomies();
34
-		foreach ( $taxonomies as $tax ) :
34
+		foreach ($taxonomies as $tax) :
35 35
 
36
-		    $this->delete_terms( $tax );
36
+		    $this->delete_terms($tax);
37 37
 
38 38
 		endforeach;
39 39
 
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
 	 * @param string $slug a custom post type ID.
53 53
 	 * @param boolean $echo Whether or not to echo the result
54 54
 	 */
55
-	public function delete_posts( $slug, $echo = false ){
55
+	public function delete_posts($slug, $echo = false) {
56 56
 
57 57
 		// Make sure that the current user is logged in & has full permissions.
58
-		if ( !$this->user_can_delete() ){
58
+		if (!$this->user_can_delete()) {
59 59
 			return;
60 60
 		}
61 61
 
62 62
 		// Check that $cptslg has a string.
63
-		if ( empty( $slug ) ){
63
+		if (empty($slug)) {
64 64
 			return;
65 65
 		}
66 66
 
@@ -77,39 +77,39 @@  discard block
 block discarded – undo
77 77
 			),
78 78
 		);
79 79
 
80
-		$objects = new \WP_Query( $query );
80
+		$objects = new \WP_Query($query);
81 81
 
82
-		if ( $objects->have_posts() ){
82
+		if ($objects->have_posts()) {
83 83
 
84 84
 			$events = array();
85 85
 
86
-			while ( $objects->have_posts() ) : $objects->the_post();
86
+			while ($objects->have_posts()) : $objects->the_post();
87 87
 
88 88
 				// Find any media associated with the test post and delete it as well
89
-				$this->delete_associated_media( get_the_id() );
89
+				$this->delete_associated_media(get_the_id());
90 90
 
91
-				if ( $echo === true ){
91
+				if ($echo === true) {
92 92
 					$events[] = array(
93 93
 						'type'		=> 'deleted',
94 94
 						'pid'		=> get_the_id(),
95
-						'post_type'	=> get_post_type( get_the_id() ),
95
+						'post_type'	=> get_post_type(get_the_id()),
96 96
 						'link'		=> ''
97 97
 					);
98 98
 				}
99 99
 
100 100
 				// Force delete the post
101
-				wp_delete_post( get_the_id(), true );
101
+				wp_delete_post(get_the_id(), true);
102 102
 
103 103
 			endwhile;
104 104
 
105
-			$obj = get_post_type_object( $slug );
105
+			$obj = get_post_type_object($slug);
106 106
 
107 107
 			$events[] = array(
108 108
 				'type'		=> 'general',
109
-				'message'	=> __( 'Deleted', 'otm-test-content' ) . ' ' . $obj->labels->all_items
109
+				'message'	=> __('Deleted', 'otm-test-content').' '.$obj->labels->all_items
110 110
 			);
111 111
 
112
-			echo \json_encode( $events );
112
+			echo \json_encode($events);
113 113
 
114 114
 		}
115 115
 
@@ -129,26 +129,26 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @param int $pid a custom post type ID.
131 131
 	 */
132
-	private function delete_associated_media( $pid ){
132
+	private function delete_associated_media($pid) {
133 133
 
134 134
 		// Make sure that the current user is logged in & has full permissions.
135
-		if ( !$this->user_can_delete() ){
135
+		if (!$this->user_can_delete()) {
136 136
 			return;
137 137
 		}
138 138
 
139 139
 		// Make sure $pid is, in fact, an ID
140
-		if ( !is_int( $pid ) ){
140
+		if (!is_int($pid)) {
141 141
 			return;
142 142
 		}
143 143
 
144 144
 		// Get our images
145
-		$media = get_attached_media( 'image', $pid );
145
+		$media = get_attached_media('image', $pid);
146 146
 
147
-		if ( !empty( $media ) ){
147
+		if (!empty($media)) {
148 148
 
149 149
 			// Loop through the media & delete each one
150
-			foreach ( $media as $attachment ){
151
-				wp_delete_attachment( $attachment->ID, true );
150
+			foreach ($media as $attachment) {
151
+				wp_delete_attachment($attachment->ID, true);
152 152
 			}
153 153
 
154 154
 		}
@@ -168,15 +168,15 @@  discard block
 block discarded – undo
168 168
 	 * @param string $slug a custom post type ID.
169 169
 	 * @param boolean $echo Whether or not to echo the result
170 170
 	 */
171
-	public function delete_terms( $slug, $echo = false ){
171
+	public function delete_terms($slug, $echo = false) {
172 172
 
173 173
 		// Make sure that the current user is logged in & has full permissions.
174
-		if ( !$this->user_can_delete() ){
174
+		if (!$this->user_can_delete()) {
175 175
 			return;
176 176
 		}
177 177
 
178 178
 		// Check that $cptslg has a string.
179
-		if ( empty( $slug ) ){
179
+		if (empty($slug)) {
180 180
 			return;
181 181
 		}
182 182
 
@@ -192,15 +192,15 @@  discard block
 block discarded – undo
192 192
 		    )
193 193
 		);
194 194
 
195
-		$terms = get_terms( $slug, $args );
195
+		$terms = get_terms($slug, $args);
196 196
 
197
-		if ( !empty( $terms ) ){
197
+		if (!empty($terms)) {
198 198
 
199 199
 			$events = array();
200 200
 
201
-			foreach ( $terms as $term ){
201
+			foreach ($terms as $term) {
202 202
 
203
-				if ( $echo === true ){
203
+				if ($echo === true) {
204 204
 					$events[] = array(
205 205
 						'type'		=> 'deleted',
206 206
 						'pid'		=> $term->term_id,
@@ -210,18 +210,18 @@  discard block
 block discarded – undo
210 210
 				}
211 211
 
212 212
 				// Delete our term
213
-				wp_delete_term( $term->term_id, $slug );
213
+				wp_delete_term($term->term_id, $slug);
214 214
 
215 215
 			}
216 216
 
217
-			$taxonomy = get_taxonomy( $slug );
217
+			$taxonomy = get_taxonomy($slug);
218 218
 
219 219
 			$events[] = array(
220 220
 				'type'		=> 'general',
221
-				'message'	=> __( 'Deleted', 'otm-test-content' ) . ' ' . $taxonomy->labels->name
221
+				'message'	=> __('Deleted', 'otm-test-content').' '.$taxonomy->labels->name
222 222
 			);
223 223
 
224
-			echo \json_encode( $events );
224
+			echo \json_encode($events);
225 225
 
226 226
 		}
227 227
 
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
 	 *
234 234
 	 * @see is_user_logged_in, current_user_can
235 235
 	 */
236
-	private function user_can_delete(){
236
+	private function user_can_delete() {
237 237
 
238 238
 		// User must be logged in
239
-		if ( !is_user_logged_in() ){
239
+		if (!is_user_logged_in()) {
240 240
 			return false;
241 241
 		}
242 242
 
243 243
 		// User must have editor priveledges, at a minimum
244
-		if ( !current_user_can( 'delete_others_posts' ) ){
244
+		if (!current_user_can('delete_others_posts')) {
245 245
 			return false;
246 246
 		}
247 247
 
Please login to merge, or discard this patch.