Completed
Branch master (885fbd)
by Mike
03:08
created
types/user.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @subpackage Evans
14 14
  * @author     Old Town Media
15 15
  */
16
-class User extends Abs\Type{
16
+class User extends Abs\Type {
17 17
 
18 18
 	/**
19 19
 	 * type
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
 	 * @param boolean $connection Whether or not we're connected to the Internet.
40 40
 	 * @param int $num Optional. Number of posts to create.
41 41
 	 */
42
-	public function create_objects( $slug, $connection, $num = '' ){
42
+	public function create_objects($slug, $connection, $num = '') {
43 43
 
44 44
 		// If we're missing a custom post type id - don't do anything
45
-		if ( empty( $slug ) ){
45
+		if (empty($slug)) {
46 46
 			return;
47 47
 		}
48 48
 
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 		$this->connected = $connection;
51 51
 
52 52
 		// If we forgot to put in a quantity, make one for us
53
-		if ( empty( $num ) ){
54
-			$num = rand( 5, 30 );
53
+		if (empty($num)) {
54
+			$num = rand(5, 30);
55 55
 		}
56 56
 
57 57
 		// Create test posts
58
-		for( $i = 0; $i < $num; $i++ ){
58
+		for ($i = 0; $i < $num; $i++) {
59 59
 
60
-			$return = $this->create_test_object( $slug );
60
+			$return = $this->create_test_object($slug);
61 61
 
62 62
 			return $return;
63 63
 
@@ -79,36 +79,36 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @param string $slug a custom post type ID.
81 81
 	 */
82
-	private function create_test_object( $slug ){
82
+	private function create_test_object($slug) {
83 83
 
84
-		if ( !is_user_logged_in() ){
84
+		if (!is_user_logged_in()) {
85 85
 			return false;
86 86
 		}
87 87
 
88
-		$name = apply_filters( "tc_{$slug}_user_name", TestContent::name() );
88
+		$name = apply_filters("tc_{$slug}_user_name", TestContent::name());
89 89
 
90 90
 		// First, insert our post
91 91
 		$userdata = array(
92
-			'user_pass'			=> wp_generate_password( 12, true, true ),
93
-			'user_login'		=> strtolower( $name['first'] . $name['last'] ) . rand( 10, 100 ),
94
-			'user_email'		=> apply_filters( "tc_{$slug}_user_email", TestContent::email( true ) ),
95
-			'display_name'		=> strtolower( $name['first'] . $name['last'] ),
92
+			'user_pass'			=> wp_generate_password(12, true, true),
93
+			'user_login'		=> strtolower($name['first'] . $name['last']) . rand(10, 100),
94
+			'user_email'		=> apply_filters("tc_{$slug}_user_email", TestContent::email(true)),
95
+			'display_name'		=> strtolower($name['first'] . $name['last']),
96 96
 			'first_name'		=> $name['first'],
97 97
 			'last_name'			=> $name['last'],
98 98
 			'description'		=> TestContent::title(),
99
-			'user_registered'	=> date( 'Y-m-d H:i:s' ),
99
+			'user_registered'	=> date('Y-m-d H:i:s'),
100 100
 			'role'				=> $slug,
101 101
 		);
102 102
 
103 103
 		// Insert the user
104
-		$user_id = wp_insert_user( apply_filters( "tc_{$slug}_user_arguments", $userdata ) );
104
+		$user_id = wp_insert_user(apply_filters("tc_{$slug}_user_arguments", $userdata));
105 105
 
106 106
 		// Then, set a test content flag on the new post for later deletion
107
-		add_user_meta( $user_id, 'dummypress_test_data', '__test__', true );
107
+		add_user_meta($user_id, 'dummypress_test_data', '__test__', true);
108 108
 
109 109
 		// Check if we have errors and return them or created message
110
-		if ( is_wp_error( $user_id ) ){
111
-			error_log( $user_id->get_error_message() );
110
+		if (is_wp_error($user_id)) {
111
+			error_log($user_id->get_error_message());
112 112
 			return $user_id;
113 113
 		} else {
114 114
 			return array(
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
 				'object'	=> 'user',
117 117
 				'oid'		=> $user_id,
118 118
 				'type'		=> $slug,
119
-				'link_edit'	=> admin_url( '/user-edit.php?user_id=' . $user_id ),
120
-				'link_view' => get_author_posts_url( $user_id )
119
+				'link_edit'	=> admin_url('/user-edit.php?user_id=' . $user_id),
120
+				'link_view' => get_author_posts_url($user_id)
121 121
 			);
122 122
 		}
123 123
 
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @return array Array of roles for use in creation and deletion
135 135
 	 */
136
-	public function get_roles(){
136
+	public function get_roles() {
137 137
 		global $wp_roles;
138 138
 		$clean_roles = array();
139 139
 
140 140
 	    $role_names = $wp_roles->get_names();
141
-		$flipped = array_flip( $role_names );
141
+		$flipped = array_flip($role_names);
142 142
 
143 143
 		// Loop through all available roles
144 144
 		$roles = get_editable_roles();
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
 			'Administrator'
148 148
 		);
149 149
 
150
-		foreach ( $roles as $role ){
150
+		foreach ($roles as $role) {
151 151
 
152
-			if ( in_array( $role['name'], $skipped_roles ) ){
152
+			if (in_array($role['name'], $skipped_roles)) {
153 153
 				continue;
154 154
 			}
155 155
 
156 156
 			$clean_roles[] = array(
157 157
 				'name'	=> $role['name'],
158
-				'slug'	=> $flipped[ $role['name'] ]
158
+				'slug'	=> $flipped[$role['name']]
159 159
 			);
160 160
 
161 161
 		}
@@ -170,27 +170,27 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @see Delete
172 172
 	 */
173
-	public function delete_all(){
173
+	public function delete_all() {
174 174
 
175
-		$delete =  new Delete;
175
+		$delete = new Delete;
176 176
 
177 177
 		// Make sure that the current user is logged in & has full permissions.
178
-		if ( ! $delete->user_can_delete() ){
178
+		if (!$delete->user_can_delete()) {
179 179
 			return;
180 180
 		}
181 181
 
182 182
 		// Loop through all post types and remove any test data
183
-		$post_types = get_post_types( array( 'public' => true ), 'objects' );
184
-		foreach ( $post_types as $post_type ) :
183
+		$post_types = get_post_types(array('public' => true), 'objects');
184
+		foreach ($post_types as $post_type) :
185 185
 
186
-		    $this->delete( $post_type->name );
186
+		    $this->delete($post_type->name);
187 187
 
188 188
 		endforeach;
189 189
 
190 190
 		// Loop through all user roles and remove any data
191
-		foreach ( $this->get_roles() as $role ) :
191
+		foreach ($this->get_roles() as $role) :
192 192
 
193
-			$this->delete( $role['slug'] );
193
+			$this->delete($role['slug']);
194 194
 
195 195
 		endforeach;
196 196
 
@@ -208,17 +208,17 @@  discard block
 block discarded – undo
208 208
 	 *
209 209
 	 * @param string $slug a custom post type ID.
210 210
 	 */
211
-	public function delete( $slug ){
211
+	public function delete($slug) {
212 212
 
213 213
 		$delete = new Delete;
214 214
 
215 215
 		// Make sure that the current user is logged in & has full permissions.
216
-		if ( !$delete->user_can_delete() ){
216
+		if (!$delete->user_can_delete()) {
217 217
 			return;
218 218
 		}
219 219
 
220 220
 		// Check that $cptslg has a string.
221
-		if ( empty( $slug ) ){
221
+		if (empty($slug)) {
222 222
 			return;
223 223
 		}
224 224
 
@@ -241,22 +241,22 @@  discard block
 block discarded – undo
241 241
 			),
242 242
 		);
243 243
 
244
-		$objects = new \WP_User_Query( $query );
245
-		$users	 = $objects->get_results();
244
+		$objects = new \WP_User_Query($query);
245
+		$users = $objects->get_results();
246 246
 
247
-		if ( !empty( $users ) ){
247
+		if (!empty($users)) {
248 248
 
249 249
 			$events = array();
250 250
 
251
-			foreach ( $users as $user ){
251
+			foreach ($users as $user) {
252 252
 
253 253
 				// Make sure we can't delete ourselves by accident
254
-				if ( $user->ID == get_current_user_id() ){
254
+				if ($user->ID == get_current_user_id()) {
255 255
 					continue;
256 256
 				}
257 257
 
258 258
 				// Double check our set user meta value
259
-				if ( '__test__' != get_user_meta( $user->ID, 'dummypress_test_data', true ) && '__test__' != get_user_meta( $user->ID, 'evans_test_content', true ) ){
259
+				if ('__test__' != get_user_meta($user->ID, 'dummypress_test_data', true) && '__test__' != get_user_meta($user->ID, 'evans_test_content', true)) {
260 260
 					continue;
261 261
 				}
262 262
 
@@ -268,13 +268,13 @@  discard block
 block discarded – undo
268 268
 				);
269 269
 
270 270
 				// Force delete the user
271
-				wp_delete_user( $user->ID );
271
+				wp_delete_user($user->ID);
272 272
 
273 273
 			}
274 274
 
275 275
 			$events[] = array(
276 276
 				'action'	=> 'general',
277
-				'message'	=> __( 'Deleted', 'dummybot' ) . ' ' . $slug
277
+				'message'	=> __('Deleted', 'dummybot') . ' ' . $slug
278 278
 			);
279 279
 
280 280
 			return $events;
Please login to merge, or discard this patch.
types/post.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @subpackage Evans
14 14
  * @author     Old Town Media
15 15
  */
16
-class Post extends Abs\Type{
16
+class Post extends Abs\Type {
17 17
 
18 18
 	/**
19 19
 	 * metabox_types
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 *
48 48
 	 * @see MetaboxTypes, MetaboxValues
49 49
 	 */
50
-	public function __construct(){
50
+	public function __construct() {
51 51
 
52 52
 		$this->metabox_types = new Main\MetaboxTypes;
53 53
 		$this->metabox_values = new Main\MetaboxValues;
@@ -69,29 +69,29 @@  discard block
 block discarded – undo
69 69
 	 * @param boolean $connection Whether or not we're connected to the Internet.
70 70
 	 * @param int $num Optional. Number of posts to create.
71 71
 	 */
72
-	public function create_objects( $slug, $connection, $num = '' ){
72
+	public function create_objects($slug, $connection, $num = '') {
73 73
 
74 74
 		// If we're missing a custom post type id - don't do anything
75
-		if ( empty( $slug ) ){
75
+		if (empty($slug)) {
76 76
 			return;
77 77
 		}
78 78
 
79 79
 		// Gather the necessary data to create the posts
80
-		$supports 	= $this->get_cpt_supports( $slug );
81
-		$metaboxes	= $this->metabox_types->get_metaboxes( $slug );
80
+		$supports 	= $this->get_cpt_supports($slug);
81
+		$metaboxes	= $this->metabox_types->get_metaboxes($slug);
82 82
 
83 83
 		// Set our connection status for the rest of the methods
84 84
 		$this->connected = $connection;
85 85
 
86 86
 		// If we forgot to put in a quantity, make one for us
87
-		if ( empty( $num ) ){
88
-			$num = rand( 5, 30 );
87
+		if (empty($num)) {
88
+			$num = rand(5, 30);
89 89
 		}
90 90
 
91 91
 		// Create test posts
92
-		for( $i = 0; $i < $num; $i++ ){
92
+		for ($i = 0; $i < $num; $i++) {
93 93
 
94
-			$return = $this->create_test_object( $slug, $supports, $metaboxes );
94
+			$return = $this->create_test_object($slug, $supports, $metaboxes);
95 95
 
96 96
 			return $return;
97 97
 
@@ -115,15 +115,15 @@  discard block
 block discarded – undo
115 115
 	 * @param array $supports Features that the post type supports.
116 116
 	 * @param array $supports All CMB2 metaboxes attached to the post type.
117 117
 	 */
118
-	private function create_test_object( $slug, $supports, $metaboxes ){
118
+	private function create_test_object($slug, $supports, $metaboxes) {
119 119
 		$return = '';
120 120
 
121 121
 		// Get a random title
122
-		$title = apply_filters( "tc_{$slug}_post_title", TestContent::title() );
122
+		$title = apply_filters("tc_{$slug}_post_title", TestContent::title());
123 123
 
124 124
 		// First, insert our post
125 125
 		$post = array(
126
-		  'post_name'      => sanitize_title( $title ),
126
+		  'post_name'      => sanitize_title($title),
127 127
 		  'post_status'    => 'publish',
128 128
 		  'post_type'      => $slug,
129 129
 		  'ping_status'    => 'closed',
@@ -131,57 +131,57 @@  discard block
 block discarded – undo
131 131
 		);
132 132
 
133 133
 		// Add title if supported
134
-		if ( $supports['title'] === true ){
134
+		if ($supports['title'] === true) {
135 135
 			$post['post_title'] = $title;
136 136
 		}
137 137
 
138 138
 		// Add main content if supported
139
-		if ( $supports['editor'] === true ){
140
-			$post['post_content'] = apply_filters( "tc_{$slug}_post_content", TestContent::paragraphs() );
139
+		if ($supports['editor'] === true) {
140
+			$post['post_content'] = apply_filters("tc_{$slug}_post_content", TestContent::paragraphs());
141 141
 		}
142 142
 
143 143
 		// Add excerpt content if supported
144
-		if ( $supports['excerpt'] === true ){
145
-			$post['post_excerpt'] = apply_filters( "tc_{$slug}_post_excerpt", TestContent::plain_text() );
144
+		if ($supports['excerpt'] === true) {
145
+			$post['post_excerpt'] = apply_filters("tc_{$slug}_post_excerpt", TestContent::plain_text());
146 146
 		}
147 147
 
148 148
 		// Insert then post object
149
-		$post_id = wp_insert_post( apply_filters( "tc_{$slug}_post_arguments", $post ) );
149
+		$post_id = wp_insert_post(apply_filters("tc_{$slug}_post_arguments", $post));
150 150
 
151 151
 		// Then, set a test content flag on the new post for later deletion
152
-		add_post_meta( $post_id, 'dummypress_test_data', '__test__', true );
152
+		add_post_meta($post_id, 'dummypress_test_data', '__test__', true);
153 153
 
154 154
 		// Add thumbnail if supported
155
-		if ( $this->connected == true && ( $supports['thumbnail'] === true || in_array( $slug, array( 'post', 'page' ) ) ) ){
156
-			 update_post_meta( $post_id, '_thumbnail_id', TestContent::image( $post_id ) );
155
+		if ($this->connected == true && ($supports['thumbnail'] === true || in_array($slug, array('post', 'page')))) {
156
+			 update_post_meta($post_id, '_thumbnail_id', TestContent::image($post_id));
157 157
 		}
158 158
 
159
-		$taxonomies = get_object_taxonomies( $slug );
159
+		$taxonomies = get_object_taxonomies($slug);
160 160
 
161 161
 		// Assign the post to terms
162
-		if ( !empty( $taxonomies ) ){
163
-			$return .= $this->assign_terms( $post_id, $taxonomies );
162
+		if (!empty($taxonomies)) {
163
+			$return .= $this->assign_terms($post_id, $taxonomies);
164 164
 		}
165 165
 
166 166
 		// Spin up metaboxes
167
-		if ( !empty( $metaboxes ) ){
168
-			foreach ( $metaboxes as $cmb ) :
169
-				$return .= $this->metabox_values->get_values( $post_id, $cmb, $this->connected );
167
+		if (!empty($metaboxes)) {
168
+			foreach ($metaboxes as $cmb) :
169
+				$return .= $this->metabox_values->get_values($post_id, $cmb, $this->connected);
170 170
 			endforeach;
171 171
 		}
172 172
 
173 173
 		// Check if we have errors and return them or created message
174
-		if ( is_wp_error( $post_id ) ){
175
-			error_log( $post_id->get_error_message() );
174
+		if (is_wp_error($post_id)) {
175
+			error_log($post_id->get_error_message());
176 176
 			return $post_id;
177 177
 		} else {
178 178
 			return array(
179 179
 				'action'	=> 'created',
180 180
 				'object'	=> 'post',
181 181
 				'oid'		=> $post_id,
182
-				'type'		=> get_post_type( $post_id ),
183
-				'link_edit'	=> admin_url( '/post.php?post='.$post_id.'&action=edit' ),
184
-				'link_view'	=> get_permalink( $post_id ),
182
+				'type'		=> get_post_type($post_id),
183
+				'link_edit'	=> admin_url('/post.php?post=' . $post_id . '&action=edit'),
184
+				'link_view'	=> get_permalink($post_id),
185 185
 			);
186 186
 		}
187 187
 
@@ -198,13 +198,13 @@  discard block
 block discarded – undo
198 198
 	 * @param string $slug a custom post type ID.
199 199
 	 * @return array Array of necessary supports booleans.
200 200
 	 */
201
-	private function get_cpt_supports( $slug ){
201
+	private function get_cpt_supports($slug) {
202 202
 
203 203
 		$supports = array(
204
-			'title'		=> post_type_supports( $slug, 'title' ),
205
-			'editor'	=> post_type_supports( $slug, 'editor' ),
206
-			'excerpt'	=> post_type_supports( $slug, 'excerpt' ),
207
-			'thumbnail'	=> post_type_supports( $slug, 'thumbnail' ),
204
+			'title'		=> post_type_supports($slug, 'title'),
205
+			'editor'	=> post_type_supports($slug, 'editor'),
206
+			'excerpt'	=> post_type_supports($slug, 'excerpt'),
207
+			'thumbnail'	=> post_type_supports($slug, 'thumbnail'),
208 208
 		);
209 209
 
210 210
 		return $supports;
@@ -225,26 +225,26 @@  discard block
 block discarded – undo
225 225
 	 * @param array $taxonomies taxonomies assigned to this cpt.
226 226
 	 * @return object WP Error if there is one.
227 227
 	 */
228
-	private function assign_terms( $post_id, $taxonomies ){
228
+	private function assign_terms($post_id, $taxonomies) {
229 229
 
230 230
 		// Make sure it's an array & has items
231
-		if ( empty( $taxonomies ) || !is_array( $taxonomies ) ){
231
+		if (empty($taxonomies) || !is_array($taxonomies)) {
232 232
 			return;
233 233
 		}
234 234
 
235
-		foreach ( $taxonomies as $tax ){
235
+		foreach ($taxonomies as $tax) {
236 236
 
237 237
 			// Get the individual terms already existing
238
-			$terms = get_terms( $tax, array( 'hide_empty'	=> false ) );
239
-			$count = count( $terms ) - 1;
238
+			$terms = get_terms($tax, array('hide_empty'	=> false));
239
+			$count = count($terms) - 1;
240 240
 
241 241
 			// If there are no terms, skip to the next taxonomy
242
-			if ( empty( $terms ) ){
242
+			if (empty($terms)) {
243 243
 				continue;
244 244
 			}
245 245
 
246 246
 			// Get a random index to use
247
-			$index = rand( 0, $count );
247
+			$index = rand(0, $count);
248 248
 
249 249
 			// Initialize our array
250 250
 			$post_data = array(
@@ -252,14 +252,14 @@  discard block
 block discarded – undo
252 252
 			);
253 253
 
254 254
 			// Set the term data to update
255
-			$post_data['tax_input'][ $tax ] = array( $terms[$index]->term_id );
255
+			$post_data['tax_input'][$tax] = array($terms[$index]->term_id);
256 256
 
257 257
 			// Update the post with the taxonomy info
258
-			$return = wp_update_post( $post_data );
258
+			$return = wp_update_post($post_data);
259 259
 
260 260
 			// Return the error if it exists
261
-			if ( is_wp_error( $return ) ){
262
-				error_log( $return->get_error_messages() );
261
+			if (is_wp_error($return)) {
262
+				error_log($return->get_error_messages());
263 263
 				return $return->get_error_messages();
264 264
 			}
265 265
 
@@ -273,20 +273,20 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @see Delete
275 275
 	 */
276
-	public function delete_all(){
276
+	public function delete_all() {
277 277
 
278
-		$delete =  new Delete;
278
+		$delete = new Delete;
279 279
 
280 280
 		// Make sure that the current user is logged in & has full permissions.
281
-		if ( ! $delete->user_can_delete() ){
281
+		if (!$delete->user_can_delete()) {
282 282
 			return;
283 283
 		}
284 284
 
285 285
 		// Loop through all post types and remove any test data
286
-		$post_types = get_post_types( array( 'public' => true ), 'objects' );
287
-		foreach ( $post_types as $post_type ) :
286
+		$post_types = get_post_types(array('public' => true), 'objects');
287
+		foreach ($post_types as $post_type) :
288 288
 
289
-		    return $this->delete( $post_type->name );
289
+		    return $this->delete($post_type->name);
290 290
 
291 291
 		endforeach;
292 292
 
@@ -304,17 +304,17 @@  discard block
 block discarded – undo
304 304
 	 *
305 305
 	 * @param string $slug a custom post type ID.
306 306
 	 */
307
-	public function delete( $slug ){
307
+	public function delete($slug) {
308 308
 
309
-		$delete =  new Delete;
309
+		$delete = new Delete;
310 310
 
311 311
 		// Make sure that the current user is logged in & has full permissions.
312
-		if ( ! $delete->user_can_delete() ){
312
+		if (!$delete->user_can_delete()) {
313 313
 			return;
314 314
 		}
315 315
 
316 316
 		// Check that $cptslg has a string.
317
-		if ( empty( $slug ) ){
317
+		if (empty($slug)) {
318 318
 			return;
319 319
 		}
320 320
 
@@ -337,39 +337,39 @@  discard block
 block discarded – undo
337 337
 			),
338 338
 		);
339 339
 
340
-		$objects = new \WP_Query( $query );
340
+		$objects = new \WP_Query($query);
341 341
 
342
-		if ( $objects->have_posts() ){
342
+		if ($objects->have_posts()) {
343 343
 
344 344
 			$events = array();
345 345
 
346
-			while ( $objects->have_posts() ) : $objects->the_post();
346
+			while ($objects->have_posts()) : $objects->the_post();
347 347
 
348 348
 				// Find any media associated with the test post and delete it as well
349
-				$this->delete_associated_media( get_the_id() );
349
+				$this->delete_associated_media(get_the_id());
350 350
 
351 351
 				// Double check our set user meta value
352
-				if ( '__test__' != get_post_meta( get_the_id(), 'dummypress_test_data', true ) && '__test__' != get_post_meta( get_the_id(), 'evans_test_content', true ) ){
352
+				if ('__test__' != get_post_meta(get_the_id(), 'dummypress_test_data', true) && '__test__' != get_post_meta(get_the_id(), 'evans_test_content', true)) {
353 353
 					continue;
354 354
 				}
355 355
 
356 356
 				$events[] = array(
357 357
 					'action'	=> 'deleted',
358 358
 					'oid'		=> get_the_id(),
359
-					'type'		=> get_post_type( get_the_id() ),
359
+					'type'		=> get_post_type(get_the_id()),
360 360
 					'link'		=> ''
361 361
 				);
362 362
 
363 363
 				// Force delete the post
364
-				wp_delete_post( get_the_id(), true );
364
+				wp_delete_post(get_the_id(), true);
365 365
 
366 366
 			endwhile;
367 367
 
368
-			$obj = get_post_type_object( $slug );
368
+			$obj = get_post_type_object($slug);
369 369
 
370 370
 			$events[] = array(
371 371
 				'action'	=> 'general',
372
-				'message'	=> __( 'Deleted', 'dummybot' ) . ' ' . $obj->labels->all_items
372
+				'message'	=> __('Deleted', 'dummybot') . ' ' . $obj->labels->all_items
373 373
 			);
374 374
 
375 375
 			return $events;
@@ -392,28 +392,28 @@  discard block
 block discarded – undo
392 392
 	 *
393 393
 	 * @param int $pid a custom post type ID.
394 394
 	 */
395
-	private function delete_associated_media( $pid ){
395
+	private function delete_associated_media($pid) {
396 396
 
397
-		$delete =  new Delete;
397
+		$delete = new Delete;
398 398
 
399 399
 		// Make sure that the current user is logged in & has full permissions.
400
-		if ( !$delete->user_can_delete() ){
400
+		if (!$delete->user_can_delete()) {
401 401
 			return;
402 402
 		}
403 403
 
404 404
 		// Make sure $pid is, in fact, an ID
405
-		if ( !is_int( $pid ) ){
405
+		if (!is_int($pid)) {
406 406
 			return;
407 407
 		}
408 408
 
409 409
 		// Get our images
410
-		$media = get_attached_media( 'image', $pid );
410
+		$media = get_attached_media('image', $pid);
411 411
 
412
-		if ( !empty( $media ) ){
412
+		if (!empty($media)) {
413 413
 
414 414
 			// Loop through the media & delete each one
415
-			foreach ( $media as $attachment ){
416
-				wp_delete_attachment( $attachment->ID, true );
415
+			foreach ($media as $attachment) {
416
+				wp_delete_attachment($attachment->ID, true);
417 417
 			}
418 418
 
419 419
 		}
Please login to merge, or discard this patch.
dummybot.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @param string $class Class name.
23 23
  */
24
-function dummypress_autoloader( $class ) {
25
-	$namespace = explode( '\\', $class );
24
+function dummypress_autoloader($class) {
25
+	$namespace = explode('\\', $class);
26 26
 
27
- 	if ( __NAMESPACE__ !== $namespace[0] ){
27
+ 	if (__NAMESPACE__ !== $namespace[0]) {
28 28
  		return;
29 29
  	}
30 30
 
31
-    $class = str_replace( __NAMESPACE__ . '\\', '', $class );
31
+    $class = str_replace(__NAMESPACE__ . '\\', '', $class);
32 32
 
33 33
 	$nss = array(
34 34
 		'Abstracts',
@@ -36,20 +36,20 @@  discard block
 block discarded – undo
36 36
 		'Views'
37 37
 	);
38 38
 
39
-	if ( in_array( $namespace[1], $nss ) ){
40
-        $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '/\1', $class ) );
41
-        $class = str_replace( '\\', '', $class );
42
-     	$file  = dirname( __FILE__ ) . '/' . $class . '.php';
39
+	if (in_array($namespace[1], $nss)) {
40
+        $class = strtolower(preg_replace('/(?<!^)([A-Z])/', '/\1', $class));
41
+        $class = str_replace('\\', '', $class);
42
+     	$file  = dirname(__FILE__) . '/' . $class . '.php';
43 43
     } else {
44
-        $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '-\\1', $class ) );
45
-     	$file  = dirname( __FILE__ ) . '/includes/class-' . $class . '.php';
44
+        $class = strtolower(preg_replace('/(?<!^)([A-Z])/', '-\\1', $class));
45
+     	$file  = dirname(__FILE__) . '/includes/class-' . $class . '.php';
46 46
     }
47 47
 
48
- 	if ( is_readable( $file ) ) {
49
- 		require_once( $file );
48
+ 	if (is_readable($file)) {
49
+ 		require_once($file);
50 50
  	}
51 51
  }
52
- spl_autoload_register( __NAMESPACE__ . '\dummypress_autoloader' );
52
+ spl_autoload_register(__NAMESPACE__ . '\dummypress_autoloader');
53 53
 
54 54
 
55 55
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
  function plugin() {
62 62
  	static $instance;
63 63
 
64
- 	if ( null === $instance ) {
64
+ 	if (null === $instance) {
65 65
  		$instance = new Plugin();
66 66
  	}
67 67
 
@@ -71,24 +71,24 @@  discard block
 block discarded – undo
71 71
 // Set our definitions for later use
72 72
  plugin()->set_definitions(
73 73
 	(object) array(
74
-		'basename'	=> plugin_basename( __FILE__ ),
75
-		'directory'	=> plugin_dir_path( __FILE__ ),
74
+		'basename'	=> plugin_basename(__FILE__),
75
+		'directory'	=> plugin_dir_path(__FILE__),
76 76
 		'file'		=> __FILE__,
77 77
 		'slug' 		=> 'test-content',
78
-		'url'		=> plugin_dir_url( __FILE__ )
78
+		'url'		=> plugin_dir_url(__FILE__)
79 79
 	)
80 80
 );
81 81
 
82 82
  // Register hook providers and views.
83
- plugin()->register_hooks( new AdminPage() )
84
- 		 ->register_hooks( new Ajax() )
85
-         ->register_view( new Views\Posts() )
86
-         ->register_view( new Views\Terms() )
87
-		 ->register_view( new Views\Users() )
88
-		 ->register_view( new Views\Various() )
89
-		 ->register_type( new Types\Post() )
90
-		 ->register_type( new Types\Term() )
91
-		 ->register_type( new Types\User() );
83
+ plugin()->register_hooks(new AdminPage())
84
+ 		 ->register_hooks(new Ajax())
85
+         ->register_view(new Views\Posts())
86
+         ->register_view(new Views\Terms())
87
+		 ->register_view(new Views\Users())
88
+		 ->register_view(new Views\Various())
89
+		 ->register_type(new Types\Post())
90
+		 ->register_type(new Types\Term())
91
+		 ->register_type(new Types\User());
92 92
 
93 93
 // Load textdomain hook
94
-add_action( 'plugins_loaded', array( plugin(), 'load_textdomain' ) );
94
+add_action('plugins_loaded', array(plugin(), 'load_textdomain'));
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,16 +3,16 @@
 block discarded – undo
3 3
 use DummyPress 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.
abstracts/type.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @subpackage Test Content
10 10
  * @author     Old Town Media
11 11
  */
12
-abstract class Type{
12
+abstract class Type {
13 13
 
14 14
 	/**
15 15
 	 * type
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * Registers the type with the rest of the plugin
35 35
 	 */
36
-	public function register_type(){
36
+	public function register_type() {
37 37
 
38
-		add_filter( 'tc-types', array( $this, 'set_type' ) );
38
+		add_filter('tc-types', array($this, 'set_type'));
39 39
 
40 40
 	}
41 41
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * @param array $types Original types array
47 47
 	 * @return array Modified types array with our current type
48 48
 	 */
49
-	public function set_type( $types ){
49
+	public function set_type($types) {
50 50
 
51 51
 		$types[] = $this->type;
52 52
 		return $types;
Please login to merge, or discard this patch.
abstracts/view.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @subpackage Test Content
11 11
  * @author     Old Town Media
12 12
  */
13
-abstract class View{
13
+abstract class View {
14 14
 
15 15
 	/**
16 16
 	 * title
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 	 *
45 45
 	 * @see tab, view
46 46
 	 */
47
-	public function register_view(){
47
+	public function register_view() {
48 48
 
49
-		add_action( 'tc-admin-tabs', array( $this, 'tab' ), $this->priority );
50
-		add_action( 'tc-admin-sections', array( $this, 'view' ), $this->priority );
49
+		add_action('tc-admin-tabs', array($this, 'tab'), $this->priority);
50
+		add_action('tc-admin-sections', array($this, 'view'), $this->priority);
51 51
 
52 52
 	}
53 53
 
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 	 * Each view has a tab and tab navigation - this function compiles our
59 59
 	 * navigation tab. Rarely extended.
60 60
 	 */
61
-	public function tab(){
61
+	public function tab() {
62 62
 		$html = "";
63 63
 
64
-		$html .= "<a class='nav-tab' data-type='".sanitize_title( $this->title )."' href='javascript:void(0)'>";
64
+		$html .= "<a class='nav-tab' data-type='" . sanitize_title($this->title) . "' href='javascript:void(0)'>";
65 65
 			$html .= $this->title;
66 66
 		$html .= "</a>";
67 67
 
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @see actions_section, options_section
80 80
 	 */
81
-	public function view(){
81
+	public function view() {
82 82
 		$html = '';
83 83
 
84
-		$html .= "<section class='test-content-tab' data-type='".sanitize_title( $this->title )."'>";
84
+		$html .= "<section class='test-content-tab' data-type='" . sanitize_title($this->title) . "'>";
85 85
 			$html .= $this->actions_section();
86 86
 			$html .= $this->options_section();
87 87
 		$html .= "</section>";
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return string HTML content.
100 100
 	 */
101
-	protected function actions_section(){
101
+	protected function actions_section() {
102 102
 		$html = '';
103 103
 		return $html;
104 104
 	}
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 	 * @param string $html Existing HTML content.
116 116
 	 * @return string HTML section content.
117 117
 	 */
118
-	protected function options_section( $html = '' ){
118
+	protected function options_section($html = '') {
119 119
 		$html .= "<hr>";
120 120
 
121 121
 		$html .= "<div class='test-data-cpt'>";
122 122
 			$html .= "<h3>";
123
-				$html .= "<span class='label'>".__( 'Quantity', 'dummybot' )."</span>";
124
-				$html .= "<input type='number' value='0' class='quantity-adjustment' for='".$this->type."' > ";
123
+				$html .= "<span class='label'>" . __('Quantity', 'dummybot') . "</span>";
124
+				$html .= "<input type='number' value='0' class='quantity-adjustment' for='" . $this->type . "' > ";
125 125
 			$html .= "</h3>";
126 126
 		$html .= "</div>";
127 127
 
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
 	 * @param string $text Text to display in the button.
140 140
 	 * @return string HTML.
141 141
 	 */
142
-	protected function build_button( $action, $slug, $text ){
142
+	protected function build_button($action, $slug, $text) {
143 143
 		$html = $dashicon = '';
144 144
 
145
-		if ( $action == 'create' ){
145
+		if ($action == 'create') {
146 146
 			$dashicon = 'dashicons-plus';
147
-		} elseif ( $action == 'delete' ){
147
+		} elseif ($action == 'delete') {
148 148
 			$dashicon = 'dashicons-trash';
149 149
 		}
150 150
 
Please login to merge, or discard this patch.
views/posts.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
  * @subpackage Test Content
11 11
  * @author     Old Town Media
12 12
  */
13
-class Posts extends Abs\View{
13
+class Posts extends Abs\View {
14 14
 
15
-	public function __construct(){
15
+	public function __construct() {
16 16
 
17
-		$this->title	= __( 'Posts', 'dummybot' );
17
+		$this->title	= __('Posts', 'dummybot');
18 18
 		$this->type		= 'post';
19
-		$this->priority	= 1;
19
+		$this->priority = 1;
20 20
 
21 21
 	}
22 22
 
@@ -27,20 +27,20 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @return string HTML content.
29 29
 	 */
30
-	protected function actions_section(){
30
+	protected function actions_section() {
31 31
 		$html = '';
32 32
 
33 33
 		// Loop through every post type available on the site
34
-		$post_types = get_post_types( array( 'public' => true ), 'objects' );
34
+		$post_types = get_post_types(array('public' => true), 'objects');
35 35
 
36
-		foreach ( $post_types as $post_type ) :
36
+		foreach ($post_types as $post_type) :
37 37
 
38 38
 			$skipped_cpts = array(
39 39
 				'attachment'
40 40
 			);
41 41
 
42 42
 			// Skip banned cpts
43
-			if ( in_array( $post_type->name, $skipped_cpts ) ){
43
+			if (in_array($post_type->name, $skipped_cpts)) {
44 44
 				continue;
45 45
 			}
46 46
 
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 				$html .= "<h3>";
50 50
 
51 51
 					$html .= "<span class='label'>" . $post_type->labels->name . "</span>";
52
-					$html .= $this->build_button( 'create', $post_type->name, __( 'Create Test Data', 'dummybot' ) );
53
-					$html .= $this->build_button( 'delete', $post_type->name, __( 'Delete Test Data', 'dummybot' ) );
52
+					$html .= $this->build_button('create', $post_type->name, __('Create Test Data', 'dummybot'));
53
+					$html .= $this->build_button('delete', $post_type->name, __('Delete Test Data', 'dummybot'));
54 54
 
55 55
 				$html .= "</h3>";
56 56
 
Please login to merge, or discard this patch.
views/terms.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
  * @subpackage Test Content
11 11
  * @author     Old Town Media
12 12
  */
13
-class Terms extends Abs\View{
13
+class Terms extends Abs\View {
14 14
 
15
-	public function __construct(){
15
+	public function __construct() {
16 16
 
17
-		$this->title	= __( 'Terms', 'dummybot' );
17
+		$this->title	= __('Terms', 'dummybot');
18 18
 		$this->type		= 'term';
19
-		$this->priority	= 2;
19
+		$this->priority = 2;
20 20
 
21 21
 	}
22 22
 
@@ -28,34 +28,34 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @return string HTML content.
30 30
 	 */
31
-	protected function actions_section(){
31
+	protected function actions_section() {
32 32
 		$html = '';
33 33
 
34 34
 		$taxonomies = get_taxonomies();
35 35
 
36
-		foreach ( $taxonomies as $tax ) :
36
+		foreach ($taxonomies as $tax) :
37 37
 
38 38
 			$skipped_taxonomies = array(
39
-				'post_format',				// We shouldn't be making random post format classes
40
-				'product_shipping_class',	// These aren't used visually and are therefore skipped
41
-				'nav_menu',					// Menus are handled seperately of taxonomies
39
+				'post_format', // We shouldn't be making random post format classes
40
+				'product_shipping_class', // These aren't used visually and are therefore skipped
41
+				'nav_menu', // Menus are handled seperately of taxonomies
42 42
 			);
43 43
 
44 44
 			// Skip banned taxonomies
45
-			if ( in_array( $tax, $skipped_taxonomies ) ){
45
+			if (in_array($tax, $skipped_taxonomies)) {
46 46
 				continue;
47 47
 			}
48 48
 
49
-			$taxonomy = get_taxonomy( $tax );
49
+			$taxonomy = get_taxonomy($tax);
50 50
 
51 51
 			$html .= "<div class='test-data-cpt'>";
52 52
 
53 53
 				$html .= "<h3>";
54 54
 
55
-				$html .= "<span class='label'>".$taxonomy->labels->name."</span>";
55
+				$html .= "<span class='label'>" . $taxonomy->labels->name . "</span>";
56 56
 
57
-				$html .= $this->build_button( 'create', $tax, __( 'Create', 'dummybot' )." ".$taxonomy->labels->name );
58
-				$html .= $this->build_button( 'delete', $tax, __( 'Delete', 'dummybot' )." ".$taxonomy->labels->name );
57
+				$html .= $this->build_button('create', $tax, __('Create', 'dummybot') . " " . $taxonomy->labels->name);
58
+				$html .= $this->build_button('delete', $tax, __('Delete', 'dummybot') . " " . $taxonomy->labels->name);
59 59
 
60 60
 				$html .= "</h3>";
61 61
 
Please login to merge, or discard this patch.
views/users.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
  * @subpackage Test Content
12 12
  * @author     Old Town Media
13 13
  */
14
-class Users extends Abs\View{
14
+class Users extends Abs\View {
15 15
 
16
-	public function __construct(){
16
+	public function __construct() {
17 17
 
18
-		$this->title	= __( 'Users', 'dummybot' );
18
+		$this->title	= __('Users', 'dummybot');
19 19
 		$this->type		= 'user';
20
-		$this->priority	= 4;
20
+		$this->priority = 4;
21 21
 
22 22
 	}
23 23
 
@@ -28,21 +28,21 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @return string HTML content.
30 30
 	 */
31
-	protected function actions_section(){
31
+	protected function actions_section() {
32 32
 		$html = '';
33 33
 
34 34
 		$user_class = new Type\User;
35 35
 		$roles = $user_class->get_roles();
36 36
 
37
-		foreach ( $roles as $role ) :
37
+		foreach ($roles as $role) :
38 38
 
39 39
 			$html .= "<div class='test-data-cpt'>";
40 40
 
41 41
 				$html .= "<h3>";
42 42
 
43 43
 					$html .= "<span class='label'>" . $role['name'] . "</span>";
44
-					$html .= $this->build_button( 'create', $role['slug'], __( 'Create Users', 'dummybot' ) );
45
-					$html .= $this->build_button( 'delete', $role['slug'], __( 'Delete Users', 'dummybot' ) );
44
+					$html .= $this->build_button('create', $role['slug'], __('Create Users', 'dummybot'));
45
+					$html .= $this->build_button('delete', $role['slug'], __('Delete Users', 'dummybot'));
46 46
 
47 47
 				$html .= "</h3>";
48 48
 
Please login to merge, or discard this patch.