Completed
Branch master (5a8fbc)
by Mike
02:16
created
includes/class-metabox-values.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage Evans
9 9
  * @author     Old Town Media
10 10
  */
11
-class MetaboxValues{
11
+class MetaboxValues {
12 12
 
13 13
 	/**
14 14
 	 * Assigns the proper testing data to a custom metabox.
@@ -22,16 +22,16 @@  discard block
 block discarded – undo
22 22
 	 * @param int $post_id Single post ID.
23 23
 	 * @param array $cmb custom metabox array from CMB2.
24 24
 	 */
25
-	public function get_values( $post_id, $cmb, $connected ){
25
+	public function get_values( $post_id, $cmb, $connected ) {
26 26
 		$value = '';
27 27
 
28 28
 		// First check that our post ID & cmb array aren't empty
29
-		if ( empty( $cmb ) || empty( $post_id ) || ! is_user_logged_in() ){
29
+		if ( empty( $cmb ) || empty( $post_id ) || ! is_user_logged_in() ) {
30 30
 			return;
31 31
 		}
32 32
 
33 33
 		// Fetch the appropriate type of data and return
34
-		switch( $cmb['type'] ){
34
+		switch ( $cmb[ 'type' ] ) {
35 35
 
36 36
 			case 'text':
37 37
 			case 'text_small':
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
 			case 'checkbox':
122 122
 
123
-				if ( isset( $cmb['source'] ) && 'acf' === $cmb['source'] ){
123
+				if ( isset( $cmb[ 'source' ] ) && 'acf' === $cmb[ 'source' ] ) {
124 124
 					$value = $this->multicheck( $cmb );
125 125
 				} else {
126 126
 					$value = $this->checkbox( $cmb );
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
 		}
159 159
 
160 160
 		// Value must exist to attempt to insert
161
-		if ( ! empty( $value ) && ! is_wp_error( $value ) ){
161
+		if ( ! empty( $value ) && ! is_wp_error( $value ) ) {
162 162
 
163 163
 			$this->update_meta( $post_id, $value, $cmb );
164 164
 
165 165
 		// If we're dealing with a WP Error object, just return the message for debugging
166
-		} elseif ( is_wp_error( $value ) ){
166
+		} elseif ( is_wp_error( $value ) ) {
167 167
 
168 168
 			return $value->get_error_message();
169 169
 
@@ -180,22 +180,22 @@  discard block
 block discarded – undo
180 180
 	 * @param array $cmb Metabox data
181 181
 	 * @return string cmb value
182 182
 	 */
183
-	private function text( $cmb ){
183
+	private function text( $cmb ) {
184 184
 
185 185
 		// If phone is in the id, fetch a phone #
186
-		if ( stripos( $cmb['id'], 'phone' ) ){
186
+		if ( stripos( $cmb[ 'id' ], 'phone' ) ) {
187 187
 			$value = TestContent::phone();
188 188
 
189 189
 		// If email is in the id, fetch an email address
190
-		} elseif ( stripos( $cmb['id'], 'email' ) ){
190
+		} elseif ( stripos( $cmb[ 'id' ], 'email' ) ) {
191 191
 			$value = TestContent::email();
192 192
 
193 193
 		// If time is in the id, fetch a time string
194
-		} elseif ( stripos( $cmb['id'], 'time' ) ){
194
+		} elseif ( stripos( $cmb[ 'id' ], 'time' ) ) {
195 195
 			$value = TestContent::time();
196 196
 
197 197
 		// If company|organization is in the ID, fetch a company name
198
-		} elseif ( stripos( $cmb['id'], 'company' ) || stripos( $cmb['id'], 'organization' ) ){
198
+		} elseif ( stripos( $cmb[ 'id' ], 'company' ) || stripos( $cmb[ 'id' ], 'organization' ) ) {
199 199
 			$value = TestContent::organization();
200 200
 
201 201
 		// Otherwise, just a random text string
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
 			$value = TestContent::title( rand( 10, 50 ) );
204 204
 		}
205 205
 
206
-		if ( 'acf' === $cmb['source'] && !empty( $cmb['extras']->chars ) ){
207
-			$value = substr( $value, 0, $cmb['extras']->chars );
206
+		if ( 'acf' === $cmb[ 'source' ] && ! empty( $cmb[ 'extras' ]->chars ) ) {
207
+			$value = substr( $value, 0, $cmb[ 'extras' ]->chars );
208 208
 		}
209 209
 
210 210
 		return $value;
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @param array $cmb Metabox data
221 221
 	 * @return string cmb value
222 222
 	 */
223
-	private function url( $cmb ){
223
+	private function url( $cmb ) {
224 224
 
225 225
 		return TestContent::link();
226 226
 
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
 	 * @param array $cmb Metabox data
236 236
 	 * @return string cmb value
237 237
 	 */
238
-	private function email( $cmb ){
238
+	private function email( $cmb ) {
239 239
 
240
-		return TestContent::email();;
240
+		return TestContent::email(); ;
241 241
 
242 242
 	}
243 243
 
@@ -248,17 +248,17 @@  discard block
 block discarded – undo
248 248
 	 * @param array $cmb Metabox data
249 249
 	 * @return int cmb value
250 250
 	 */
251
-	private function number( $cmb ){
251
+	private function number( $cmb ) {
252 252
 
253 253
 		$min = 1;
254 254
 		$max = 10000000;
255 255
 
256
-		if ( 'acf' == $cmb['source'] && !empty( $cmb['extras']->min ) ){
257
-			$min = $cmb['extras']->min;
256
+		if ( 'acf' == $cmb[ 'source' ] && ! empty( $cmb[ 'extras' ]->min ) ) {
257
+			$min = $cmb[ 'extras' ]->min;
258 258
 		}
259 259
 
260
-		if ( 'acf' == $cmb['source'] && !empty( $cmb['extras']->max ) ){
261
-			$max = $cmb['extras']->max;
260
+		if ( 'acf' == $cmb[ 'source' ] && ! empty( $cmb[ 'extras' ]->max ) ) {
261
+			$max = $cmb[ 'extras' ]->max;
262 262
 		}
263 263
 
264 264
 		return rand( $min, $max );
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	 * @param array $cmb Metabox data
275 275
 	 * @return string cmb value
276 276
 	 */
277
-	private function time( $cmb ){
277
+	private function time( $cmb ) {
278 278
 
279 279
 		return TestContent::time();
280 280
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 * @param array $cmb Metabox data
290 290
 	 * @return string cmb value
291 291
 	 */
292
-	private function timezone( $cmb ){
292
+	private function timezone( $cmb ) {
293 293
 
294 294
 		return TestContent::timezone();
295 295
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	 * @param array $cmb Metabox data
305 305
 	 * @return string cmb value
306 306
 	 */
307
-	private function date( $cmb ){
307
+	private function date( $cmb ) {
308 308
 
309 309
 		return TestContent::date( 'm/d/Y' );
310 310
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 * @param array $cmb Metabox data
320 320
 	 * @return string cmb value
321 321
 	 */
322
-	private function timestamp( $cmb ){
322
+	private function timestamp( $cmb ) {
323 323
 
324 324
 		return TestContent::date( 'U' );
325 325
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 	 * @param array $cmb Metabox data
333 333
 	 * @return string cmb value
334 334
 	 */
335
-	private function color( $cmb ){
335
+	private function color( $cmb ) {
336 336
 
337 337
 		return '#' . str_pad( dechex( mt_rand( 0, 0xFFFFFF ) ), 6, '0', STR_PAD_LEFT );
338 338
 
@@ -347,12 +347,12 @@  discard block
 block discarded – undo
347 347
 	 * @param array $cmb Metabox data
348 348
 	 * @return string cmb value
349 349
 	 */
350
-	private function textarea( $cmb ){
350
+	private function textarea( $cmb ) {
351 351
 
352 352
 		$value = TestContent::plain_text();
353 353
 
354
-		if ( 'acf' == $cmb['source'] && !empty( $cmb['extras']->chars ) ){
355
-			$value = substr( $value, 0,  $cmb['extras']->chars );
354
+		if ( 'acf' == $cmb[ 'source' ] && ! empty( $cmb[ 'extras' ]->chars ) ) {
355
+			$value = substr( $value, 0, $cmb[ 'extras' ]->chars );
356 356
 		}
357 357
 
358 358
 		return $value;
@@ -368,10 +368,10 @@  discard block
 block discarded – undo
368 368
 	 * @param array $cmb Metabox data
369 369
 	 * @return string cmb value
370 370
 	 */
371
-	private function radio( $cmb ){
371
+	private function radio( $cmb ) {
372 372
 
373 373
 		// Grab a random item out of the array and return the key
374
-		$new_val = array_slice( $cmb['options'], rand( 0, count( $cmb['options'] ) ), 1 );
374
+		$new_val = array_slice( $cmb[ 'options' ], rand( 0, count( $cmb[ 'options' ] ) ), 1 );
375 375
 		$value = key( $new_val );
376 376
 
377 377
 		return $value;
@@ -387,11 +387,11 @@  discard block
 block discarded – undo
387 387
 	 * @param array $cmb Metabox data
388 388
 	 * @return string cmb value
389 389
 	 */
390
-	private function checkbox( $cmb ){
390
+	private function checkbox( $cmb ) {
391 391
 		$value = '';
392 392
 
393 393
 		// 50/50 odds of being turned on
394
-		if ( rand( 0, 1 ) == 1 ){
394
+		if ( rand( 0, 1 ) == 1 ) {
395 395
 			$value = 'on';
396 396
 		}
397 397
 
@@ -408,16 +408,16 @@  discard block
 block discarded – undo
408 408
 	 * @param array $cmb Metabox data
409 409
 	 * @return array cmb value
410 410
 	 */
411
-	private function multicheck( $cmb ){
411
+	private function multicheck( $cmb ) {
412 412
 
413 413
 		$new_option = array();
414 414
 
415 415
 		// Loop through each of our options
416
-		foreach ( $cmb['options'] as $key => $value ){
416
+		foreach ( $cmb[ 'options' ] as $key => $value ) {
417 417
 
418 418
 			// 50/50 chance of being included
419
-			if ( rand( 0, 1 ) ){
420
-				$new_option[] = $key;
419
+			if ( rand( 0, 1 ) ) {
420
+				$new_option[ ] = $key;
421 421
 			}
422 422
 
423 423
 		}
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	 * @param array $cmb Metabox data
436 436
 	 * @return string cmb value
437 437
 	 */
438
-	private function wysiwyg( $cmb ){
438
+	private function wysiwyg( $cmb ) {
439 439
 
440 440
 		return TestContent::paragraphs();
441 441
 
@@ -452,10 +452,10 @@  discard block
 block discarded – undo
452 452
 	 * @param bool $connected Whether we're connected to the Internets or not
453 453
 	 * @return mixed string|object cmb value or WP_Error object
454 454
 	 */
455
-	private function file( $cmb, $post_id, $connected ){
455
+	private function file( $cmb, $post_id, $connected ) {
456 456
 		$value = '';
457 457
 
458
-		if ( true === $connected ){
458
+		if ( true === $connected ) {
459 459
 			$value = TestContent::image( $post_id );
460 460
 		}
461 461
 
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	 * @param array $cmb Metabox data
473 473
 	 * @return string cmb value
474 474
 	 */
475
-	private function oembed( $cmb ){
475
+	private function oembed( $cmb ) {
476 476
 
477 477
 		return TestContent::oembed();
478 478
 
@@ -490,25 +490,25 @@  discard block
 block discarded – undo
490 490
 	 * @param string $value Value to add into the database.
491 491
 	 * @param array $cmb SMB data.
492 492
 	 */
493
-	private function update_meta( $post_id, $value, $cmb ){
493
+	private function update_meta( $post_id, $value, $cmb ) {
494 494
 
495
-		$type 	= $cmb['type'];
496
-		$id		= $cmb['id'];
497
-		$value = apply_filters( "tc_{$type}_metabox", $value );	// Filter by metabox type
495
+		$type 	= $cmb[ 'type' ];
496
+		$id = $cmb[ 'id' ];
497
+		$value = apply_filters( "tc_{$type}_metabox", $value ); // Filter by metabox type
498 498
 		$value = apply_filters( "tc_{$id}_metabox", $value ); // Filter by metabox ID
499 499
 
500 500
 		// Files must be treated separately - they use the attachment ID
501 501
 		// & url of media for separate cmb values. (only in cmb1 & cmb2 though)
502
-		if ( 'file'!== $cmb['type'] || ( 'file' === $cmb['type'] && 'cmb_hm' === $cmb['source'] ) ){
503
-			add_post_meta( $post_id, $cmb['id'], $value, true );
502
+		if ( 'file' !== $cmb[ 'type' ] || ( 'file' === $cmb[ 'type' ] && 'cmb_hm' === $cmb[ 'source' ] ) ) {
503
+			add_post_meta( $post_id, $cmb[ 'id' ], $value, true );
504 504
 		} else {
505
-			add_post_meta( $post_id, $cmb['id'].'_id', $value, true );
506
-			add_post_meta( $post_id, $cmb['id'], wp_get_attachment_url( $value ), true );
505
+			add_post_meta( $post_id, $cmb[ 'id' ] . '_id', $value, true );
506
+			add_post_meta( $post_id, $cmb[ 'id' ], wp_get_attachment_url( $value ), true );
507 507
 		}
508 508
 
509 509
 		// Add extra, redundant meta. Because, why not have two rows for the price of one?
510
-		if ( isset( $cmb['source'] ) && 'acf' === $cmb['source'] ){
511
-			add_post_meta( $post_id, '_' . $cmb['id'], $cmb['key'], true );
510
+		if ( isset( $cmb[ 'source' ] ) && 'acf' === $cmb[ 'source' ] ) {
511
+			add_post_meta( $post_id, '_' . $cmb[ 'id' ], $cmb[ 'key' ], true );
512 512
 		}
513 513
 
514 514
 	}
Please login to merge, or discard this patch.
includes/class-admin-page.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage Evans
9 9
  * @author     Old Town Media
10 10
  */
11
-class AdminPage{
11
+class AdminPage {
12 12
 
13 13
 	/**
14 14
 	 * plugin
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @see admin_menu, wp_ajax actions
47 47
 	 */
48
-	public function hooks(){
48
+	public function hooks() {
49 49
 
50 50
 		$connection = new ConnectionTest;
51
-		$this->definitions	= $this->plugin->get_definitions();
52
-		$this->connected	= $connection->test();
51
+		$this->definitions = $this->plugin->get_definitions();
52
+		$this->connected = $connection->test();
53 53
 
54
-		add_action( 'admin_menu' , array( $this, 'add_menu_item' ) );
55
-		add_filter( 'plugin_action_links_' . $this->definitions->basename , array( $this, 'add_settings_link' ) );
54
+		add_action( 'admin_menu', array( $this, 'add_menu_item' ) );
55
+		add_filter( 'plugin_action_links_' . $this->definitions->basename, array( $this, 'add_settings_link' ) );
56 56
 		add_action( 'admin_notices', array( $this, 'internet_connected_admin_notice' ) );
57 57
 
58 58
 	}
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 	 * Internet, and the test fails displays a notice informing the user that
114 114
 	 * images will not pull into test data.
115 115
 	 */
116
-	public function internet_connected_admin_notice(){
116
+	public function internet_connected_admin_notice() {
117 117
 
118 118
 		// Get the current admin screen & verify that we're on the right one
119 119
 		// before continuing.
120 120
 		$screen = get_current_screen();
121 121
 
122
-		if ( $screen->base != 'tools_page_create-test-data' ){
122
+		if ( $screen->base != 'tools_page_create-test-data' ) {
123 123
 			return;
124 124
 		}
125 125
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		} else {
131 131
 			// We didn't get a reponse so print the notice out
132 132
 			echo '<div class="notice notice-error">';
133
-		        echo '<p>'.__( 'WordPress could not connect to Splashbase and therefore images will not pull into metaboxes/thumbnails. Turn Airplane Mode off or reconnect to the Internet to get images when creating test data.', 'dummybot' ).'</p>';
133
+		        echo '<p>' . __( 'WordPress could not connect to Splashbase and therefore images will not pull into metaboxes/thumbnails. Turn Airplane Mode off or reconnect to the Internet to get images when creating test data.', 'dummybot' ) . '</p>';
134 134
 		    echo '</div>';
135 135
 		}
136 136
 
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
 	/**
141 141
 	 * Load our script in the admin section and serve in data.
142 142
 	 */
143
-	public function load_scripts(){
143
+	public function load_scripts() {
144 144
 
145
-		wp_enqueue_script( 'test-content-js', plugins_url( 'assets/admin.js' , dirname( __FILE__ ) ) );
146
-		wp_enqueue_style( 'test-content-css', plugins_url( 'assets/admin.css' , dirname( __FILE__ ) ) );
145
+		wp_enqueue_script( 'test-content-js', plugins_url( 'assets/admin.js', dirname( __FILE__ ) ) );
146
+		wp_enqueue_style( 'test-content-css', plugins_url( 'assets/admin.css', dirname( __FILE__ ) ) );
147 147
 
148 148
 		$data = array(
149 149
 			'nonce'			=> wp_create_nonce( 'handle-test-data' ),
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 	/**
163 163
 	 * Print out our admin page to control test data.
164 164
 	 */
165
-	public function admin_page(){
165
+	public function admin_page() {
166 166
 		echo '<div class="wrap" id="options_editor">' . "\n";
167 167
 
168
-			echo '<h2>' . __( 'Create Test Data' , 'dummybot' ) . '</h2>' . "\n";
168
+			echo '<h2>' . __( 'Create Test Data', 'dummybot' ) . '</h2>' . "\n";
169 169
 
170 170
 			echo "<div class='nav-tab-wrapper'>";
171 171
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 
180 180
 			echo "";
181 181
 
182
-			echo "<input type='hidden' id='connection-status' value='".$this->connected."'>";
182
+			echo "<input type='hidden' id='connection-status' value='" . $this->connected . "'>";
183 183
 
184 184
 			echo "<pre class='test-data-status-box' id='status-updates'></pre>";
185 185
 
Please login to merge, or discard this patch.
includes/class-test-content.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  * @subpackage Evans
15 15
  * @author     Old Town Media
16 16
  */
17
-class TestContent{
17
+class TestContent {
18 18
 
19 19
 	/**
20 20
 	 * Title function.
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @param int $num_words Number of words to return.
27 27
 	 * @return string Random title string.
28 28
 	 */
29
-	public static function title( $num_words = '' ){
29
+	public static function title( $num_words = '' ) {
30 30
 
31 31
 		$title = '';
32 32
 
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
 		);
68 68
 
69 69
 		// If we didn't choose a count, make one
70
-		if ( empty( $num_words ) ){
70
+		if ( empty( $num_words ) ) {
71 71
 			$num_words = rand( 2, 10 );
72 72
 		}
73 73
 
74 74
 		// Pull random words
75
-		for( $i = 1; $i <= $num_words; $i++ ){
75
+		for ( $i = 1; $i <= $num_words; $i++ ) {
76 76
 			$title .= $random_words[ rand( 0, 31 ) ] . " ";
77 77
 		}
78 78
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @return string Paragraph(s) of text.
91 91
 	 */
92
-	public static function paragraphs(){
92
+	public static function paragraphs() {
93 93
 
94 94
 		$content = '';
95 95
 
@@ -351,17 +351,17 @@  discard block
 block discarded – undo
351 351
 		);
352 352
 
353 353
 		$used_keys = array();
354
-		for( $i = 1; $i < 7; $i++ ){
354
+		for ( $i = 1; $i < 7; $i++ ) {
355 355
 
356 356
 			// Pull a new random key and make sure we're not repeating any elements
357 357
 			$key = rand( 0, 12 );
358
-			while( in_array( $key, $used_keys ) ){
358
+			while ( in_array( $key, $used_keys ) ) {
359 359
 				$key = rand( 0, 12 );
360 360
 			}
361 361
 
362
-			$content .= $random_content_types[$key];
362
+			$content .= $random_content_types[ $key ];
363 363
 
364
-			$used_keys[] = $key;
364
+			$used_keys[ ] = $key;
365 365
 		}
366 366
 
367 367
 		return apply_filters( "tc_paragraphs_data", $content );
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	 *
377 377
 	 * @return string Plain text paragraphs.
378 378
 	 */
379
-	public static function plain_text(){
379
+	public static function plain_text() {
380 380
 
381 381
 		$paragraphs = array(
382 382
 			'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean tincidunt luctus eros, a tincidunt massa aliquet sit amet. Sed faucibus, eros non lacinia porttitor, risus odio efficitur sapien, id porta urna massa ac est. Cras efficitur lacinia magna eget tempus. Fusce ex felis, finibus consectetur mi at, finibus rhoncus augue. In ut tortor lacinia, rutrum mauris vel, maximus tortor. Praesent ac arcu nec eros pharetra tristique. Morbi congue leo sed ipsum fermentum vulputate. Ut nulla eros, porta varius pulvinar eget, bibendum quis dolor. Morbi sed diam eu dui semper ornare nec quis nisl.',
@@ -407,20 +407,20 @@  discard block
 block discarded – undo
407 407
 	 * @param int $post_id Post ID.
408 408
 	 * @return mixed Attachment ID or WP Error.
409 409
 	 */
410
-	public static function image( $post_id ){
410
+	public static function image( $post_id ) {
411 411
 		$file_array = array();
412 412
 
413 413
 		// Get the image from the API
414 414
 		$url = self::get_image_link();
415 415
 
416 416
 		// If the returned string is empty or it's not a string, try again.
417
-		if ( empty( $url ) || !is_string( $url ) ){
417
+		if ( empty( $url ) || ! is_string( $url ) ) {
418 418
 
419 419
 			// Try again
420 420
 			$url = self::get_image_link();
421 421
 
422 422
 			// If it fails again, just give up
423
-			if ( empty( $url ) || !is_string( $url ) ){
423
+			if ( empty( $url ) || ! is_string( $url ) ) {
424 424
 				return;
425 425
 			}
426 426
 
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 
432 432
 	    preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches );
433 433
 
434
-        $file_array['name'] = basename( $matches[0] );
435
-        $file_array['tmp_name'] = $tmp;
434
+        $file_array[ 'name' ] = basename( $matches[ 0 ] );
435
+        $file_array[ 'tmp_name' ] = $tmp;
436 436
 
437 437
 	    // Check for download errors
438 438
 	    if ( is_wp_error( $tmp ) ) {
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 
446 446
 	    // Check for handle sideload errors.
447 447
 	    if ( is_wp_error( $image_id ) ) {
448
-	        unlink( $file_array['tmp_name'] );
448
+	        unlink( $file_array[ 'tmp_name' ] );
449 449
 	        error_log( $image_id->get_error_message() );
450 450
 	    }
451 451
 
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 	 *
462 462
 	 * @return string Image URL.
463 463
 	 */
464
-	private static function get_image_link(){
464
+	private static function get_image_link() {
465 465
 
466 466
 		// cURL an image API for a completely random photo
467 467
 		$curl = curl_init( "http://www.splashbase.co/api/v1/images/random?images_only=true" );
@@ -483,10 +483,10 @@  discard block
 block discarded – undo
483 483
 		$response = json_decode( $curl_response, true );
484 484
 
485 485
 		// Check to make sure that the return contains a valid image extensions
486
-		preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $response['url'], $matches);
486
+		preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $response[ 'url' ], $matches );
487 487
 
488
-		if ( !empty( $matches ) ){
489
-			return $response['url'];
488
+		if ( ! empty( $matches ) ) {
489
+			return $response[ 'url' ];
490 490
 		}
491 491
 
492 492
 	}
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 	 * @param string $format PHP Date format.
501 501
 	 * @return mixed Date in the format requested.
502 502
 	 */
503
-	public static function date( $format ){
503
+	public static function date( $format ) {
504 504
 
505 505
 		$num_days = rand( 1, 60 );
506 506
 		$date = date( $format, strtotime( " +$num_days days" ) );
@@ -517,16 +517,16 @@  discard block
 block discarded – undo
517 517
 	 *
518 518
 	 * @return string Time string
519 519
 	 */
520
-	public static function time(){
520
+	public static function time() {
521 521
 
522 522
 		$times = array(
523 523
 			'8:00 am',
524 524
 			'5:00PM',
525 525
 			'13:00',
526 526
 			'2015',
527
-			date( 'G:i', strtotime( " +".rand( 4, 24 )." hours" ) ),
528
-			date( 'g:i', strtotime( " +".rand( 4, 24 )." hours" ) ),
529
-			date( 'G:i A', strtotime( " +".rand( 4, 24 )." hours" ) )
527
+			date( 'G:i', strtotime( " +" . rand( 4, 24 ) . " hours" ) ),
528
+			date( 'g:i', strtotime( " +" . rand( 4, 24 ) . " hours" ) ),
529
+			date( 'G:i A', strtotime( " +" . rand( 4, 24 ) . " hours" ) )
530 530
 		);
531 531
 
532 532
 		return apply_filters( "tc_time_data", $times[ rand( 0, 6 ) ] );
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 	 *
542 542
 	 * @return string Timezone
543 543
 	 */
544
-	public static function timezone(){
544
+	public static function timezone() {
545 545
 
546 546
 		$timezones = array(
547 547
 			'America/Denver',
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 	 *
573 573
 	 * @return string Phone #.
574 574
 	 */
575
-	public static function phone(){
575
+	public static function phone() {
576 576
 
577 577
 		$phone_numbers = array(
578 578
 			'7203893101',
@@ -600,11 +600,11 @@  discard block
 block discarded – undo
600 600
 	 *
601 601
 	 * @return string Email address.
602 602
 	 */
603
-	public static function email( $superrandom = false ){
603
+	public static function email( $superrandom = false ) {
604 604
 
605 605
 		// In certain situations we need to ensure that the email is never
606 606
 		// duplicated, like in creating new users.
607
-		if ( $superrandom !== false ){
607
+		if ( $superrandom !== false ) {
608 608
 			$user = $domain = '';
609 609
 
610 610
 			$tlds = array(
@@ -622,11 +622,11 @@  discard block
 block discarded – undo
622 622
 			$user_length = mt_rand( 5, 20 );
623 623
 		    $domain_length = mt_rand( 7, 12 );
624 624
 
625
-			for ( $i = 1; $i <= $user_length; $i++ ){
625
+			for ( $i = 1; $i <= $user_length; $i++ ) {
626 626
 				$user .= substr( $char, mt_rand( 0, strlen( $char ) ), 1 );
627 627
 			}
628 628
 
629
-			for ( $i = 1; $i <= $domain_length; $i++ ){
629
+			for ( $i = 1; $i <= $domain_length; $i++ ) {
630 630
 				$domain .= substr( $char, mt_rand( 0, strlen( $char ) ), 1 );
631 631
 			}
632 632
 
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	 *
667 667
 	 * @return string URL.
668 668
 	 */
669
-	public static function link(){
669
+	public static function link() {
670 670
 
671 671
 		$links = array(
672 672
 			'http://google.com',
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 	 *
691 691
 	 * @return string URL.
692 692
 	 */
693
-	public static function oembed(){
693
+	public static function oembed() {
694 694
 
695 695
 		$links = array(
696 696
 			'https://www.youtube.com/watch?v=A85-YQsm6pY',
@@ -715,10 +715,10 @@  discard block
 block discarded – undo
715 715
 	 * @param	string $type Video service to get link from
716 716
 	 * @return	string URL.
717 717
 	 */
718
-	public static function video( $type ){
718
+	public static function video( $type ) {
719 719
 
720 720
 		// Switch through our video types. Expecting to add more in the future
721
-		switch( $type ){
721
+		switch ( $type ) {
722 722
 
723 723
 			// YouTube videos
724 724
 			case 'youtube' :
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
 	 *
771 771
 	 * @return array Randomly strung together name.
772 772
 	 */
773
-	public static function name(){
773
+	public static function name() {
774 774
 
775 775
 		$first_names = array(
776 776
 			'Jacqui',
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 	 *
833 833
 	 * @return	string Organization name.
834 834
 	 */
835
-	public static function organization(){
835
+	public static function organization() {
836 836
 
837 837
 		$orgs = array(
838 838
 			'Red Cross',
Please login to merge, or discard this patch.
includes/class-connection-test.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  * @subpackage Evans
18 18
  * @author     Old Town Media
19 19
  */
20
-class ConnectionTest{
20
+class ConnectionTest {
21 21
 
22 22
 	/**
23 23
 	 * Run all of our connection tests.
@@ -26,33 +26,33 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @return boolean Status of connection to Internet/Splashbase.
28 28
 	 */
29
-	public function test(){
29
+	public function test() {
30 30
 
31 31
 		/*
32 32
 		 * Make sure that we're looking at the correct admin page
33 33
 		 */
34
-		if ( ! $this->check_admin_page() ){
34
+		if ( ! $this->check_admin_page() ) {
35 35
 			return;
36 36
 		}
37 37
 
38 38
 		/*
39 39
 		 * Test #1 - Check for Airplane Mode plugin status
40 40
 		 */
41
-		if ( ! $this->check_airplane_mode() ){
41
+		if ( ! $this->check_airplane_mode() ) {
42 42
 			return false;
43 43
 		}
44 44
 
45 45
 		/*
46 46
 		 * Test #2 - Check Internet connection in general
47 47
 		 */
48
-		if ( ! $this->check_internet() ){
48
+		if ( ! $this->check_internet() ) {
49 49
 			return false;
50 50
 		}
51 51
 
52 52
 		/*
53 53
 		 * Test #3 - Check External URL itself (Splashbase here)
54 54
 		 */
55
-		if ( ! $this->check_external_url( 'http://www.splashbase.co/api/v1/images/' ) ){
55
+		if ( ! $this->check_external_url( 'http://www.splashbase.co/api/v1/images/' ) ) {
56 56
 			return false;
57 57
 		}
58 58
 
@@ -75,22 +75,22 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return boolean Whether or not we're in the right place.
77 77
 	 */
78
-	private function check_admin_page(){
78
+	private function check_admin_page() {
79 79
 		global $current_screen;
80 80
 
81 81
 		// Only run if we're in the admin page
82
-		if ( !is_admin() ){
82
+		if ( ! is_admin() ) {
83 83
 			return false;
84 84
 		}
85 85
 
86 86
 		// Get the current admin screen & verify that we're on the right one
87 87
 		// before continuing.
88
-		if ( isset ( $current_screen ) && 'tools_page_create-test-data' != $current_screen->base ){
88
+		if ( isset ( $current_screen ) && 'tools_page_create-test-data' != $current_screen->base ) {
89 89
 			return false;
90 90
 		}
91 91
 
92
-		$last_uri_bit = explode( '=', $_SERVER['REQUEST_URI'] );
93
-		if ( 'create-test-data' != end( $last_uri_bit ) ){
92
+		$last_uri_bit = explode( '=', $_SERVER[ 'REQUEST_URI' ] );
93
+		if ( 'create-test-data' != end( $last_uri_bit ) ) {
94 94
 			return false;
95 95
 		}
96 96
 
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return boolean Connected or not.
110 110
 	 */
111
-	private function check_airplane_mode(){
111
+	private function check_airplane_mode() {
112 112
 
113
-		if ( class_exists( 'Airplane_Mode_Core' ) ){
113
+		if ( class_exists( 'Airplane_Mode_Core' ) ) {
114 114
 			// Is airplane mode active?
115 115
 			$airplane_mode = get_site_option( 'airplane-mode' );
116 116
 
117
-			if ( $airplane_mode === 'on' ){
117
+			if ( $airplane_mode === 'on' ) {
118 118
 				return false;
119 119
 			}
120 120
 		}
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @return boolean Connected or not.
135 135
 	 */
136
-	private function check_internet(){
136
+	private function check_internet() {
137 137
 
138 138
 		// Attempt to open a socket connection to Google
139 139
 		$connected = @fsockopen( "www.google.com", 80 );
140 140
 
141
-		if ( !$connected ){
141
+		if ( ! $connected ) {
142 142
 			return false;
143 143
 		}
144 144
 
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
 	 * @param string $url External URL to attempt to reach.
161 161
 	 * @return boolean Connected or not.
162 162
 	 */
163
-	private function check_external_url( $url ){
163
+	private function check_external_url( $url ) {
164 164
 
165 165
 		$test_url = esc_url( $url );
166 166
 		$response = wp_remote_get( $test_url );
167 167
 
168
-		if ( !is_array( $response ) ){
168
+		if ( ! is_array( $response ) ) {
169 169
 			return false;
170 170
 		}
171 171
 
Please login to merge, or discard this patch.
includes/class-delete.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -9,25 +9,25 @@  discard block
 block discarded – undo
9 9
  * @subpackage Evans
10 10
  * @author     Old Town Media
11 11
  */
12
-class Delete{
12
+class Delete {
13 13
 
14 14
 	/**
15 15
 	 * Delete all test content created ever.
16 16
 	 *
17 17
 	 * @access private
18 18
 	 */
19
-	public function delete_all_test_data(){
19
+	public function delete_all_test_data() {
20 20
 		$return = '';
21 21
 
22
-		if ( ! $this->user_can_delete() ){
22
+		if ( ! $this->user_can_delete() ) {
23 23
 			return;
24 24
 		}
25 25
 
26 26
 		$types = apply_filters( 'tc-types', array() );
27 27
 
28
-		if ( !empty( $types ) ){
28
+		if ( ! empty( $types ) ) {
29 29
 
30
-			foreach ( $types as $type ){
30
+			foreach ( $types as $type ) {
31 31
 
32 32
 				$class = 'DummyPress\Types\\' . ucwords( $type );
33 33
 				$object = new $class();
@@ -53,19 +53,19 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @param string $data Information about the type.
55 55
 	 */
56
-	public function delete_objects( $data ){
56
+	public function delete_objects( $data ) {
57 57
 
58 58
 		// Make sure that the current user is logged in & has full permissions.
59
-		if ( !$this->user_can_delete() ){
59
+		if ( ! $this->user_can_delete() ) {
60 60
 			return;
61 61
 		}
62 62
 
63
-		if ( empty( $data ) ){
63
+		if ( empty( $data ) ) {
64 64
 			return;
65 65
 		}
66 66
 
67
-		$type = 'DummyPress\Types\\' . ucwords( $data['type'] );
68
-		$slug = $data['slug'];
67
+		$type = 'DummyPress\Types\\' . ucwords( $data[ 'type' ] );
68
+		$slug = $data[ 'slug' ];
69 69
 
70 70
 		$object = new $type();
71 71
 
@@ -79,15 +79,15 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @see is_user_logged_in, current_user_can
81 81
 	 */
82
-	public function user_can_delete(){
82
+	public function user_can_delete() {
83 83
 
84 84
 		// User must be logged in
85
-		if ( !is_user_logged_in() ){
85
+		if ( ! is_user_logged_in() ) {
86 86
 			return false;
87 87
 		}
88 88
 
89 89
 		// User must have editor priveledges, at a minimum
90
-		if ( !current_user_can( 'delete_others_posts' ) ){
90
+		if ( ! current_user_can( 'delete_others_posts' ) ) {
91 91
 			return false;
92 92
 		}
93 93
 
Please login to merge, or discard this patch.
dummybot.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 function dummypress_autoloader( $class ) {
25 25
 	$namespace = explode( '\\', $class );
26 26
 
27
- 	if ( __NAMESPACE__ !== $namespace[0] ){
27
+ 	if ( __NAMESPACE__ !== $namespace[ 0 ] ) {
28 28
  		return;
29 29
  	}
30 30
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 		'Views'
37 37
 	);
38 38
 
39
-	if ( in_array( $namespace[1], $nss ) ){
39
+	if ( in_array( $namespace[ 1 ], $nss ) ) {
40 40
         $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '/\1', $class ) );
41 41
         $class = str_replace( '\\', '', $class );
42 42
      	$file  = dirname( __FILE__ ) . '/' . $class . '.php';
Please login to merge, or discard this patch.
views/various.php 1 patch
Spacing   +5 added lines, -5 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 Various extends Abs\View{
13
+class Various extends Abs\View {
14 14
 
15
-	public function __construct(){
15
+	public function __construct() {
16 16
 
17 17
 		$this->title	= __( 'Various', 'dummybot' );
18 18
 		$this->type		= 'all';
19
-		$this->priority	= 10;
19
+		$this->priority = 10;
20 20
 
21 21
 	}
22 22
 
@@ -28,7 +28,7 @@  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
 		$html .= "<div class='test-data-cpt'>";
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @param string $html Existing HTML content.
55 55
 	 * @return string HTML section content.
56 56
 	 */
57
-	protected function options_section( $html = '' ){
57
+	protected function options_section( $html = '' ) {
58 58
 		return $html;
59 59
 	}
60 60
 
Please login to merge, or discard this patch.
views/posts.php 1 patch
Spacing   +5 added lines, -5 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 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,7 +27,7 @@  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
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
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
 
Please login to merge, or discard this patch.
views/terms.php 1 patch
Spacing   +11 added lines, -11 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 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,7 +28,7 @@  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();
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 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
 
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
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.