@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage Evans |
9 | 9 | * @author Old Town Media |
10 | 10 | */ |
11 | -class Metaboxes{ |
|
11 | +class Metaboxes { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Decide which cmb library to try and loop to get our metaboxes. |
@@ -22,26 +22,26 @@ discard block |
||
22 | 22 | * @param string $slug Post Type slug ID. |
23 | 23 | * @return array Fields to fill in for our post object. |
24 | 24 | */ |
25 | - public function get_metaboxes( $slug ){ |
|
25 | + public function get_metaboxes($slug) { |
|
26 | 26 | $cmb2_fields = $cmb_fields = $acf_fields = array(); |
27 | 27 | |
28 | 28 | // CMB2 |
29 | - if ( class_exists( 'CMB2', false ) ) { |
|
30 | - $cmb2_fields = $this->get_cmb2_metaboxes( $slug ); |
|
29 | + if (class_exists('CMB2', false)) { |
|
30 | + $cmb2_fields = $this->get_cmb2_metaboxes($slug); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | // Custom Metaboxes and Fields (CMB1) |
34 | - if ( class_exists( 'cmb_Meta_Box', false ) ) { |
|
35 | - $cmb_fields = $this->get_cmb1_metaboxes( $slug ); |
|
34 | + if (class_exists('cmb_Meta_Box', false)) { |
|
35 | + $cmb_fields = $this->get_cmb1_metaboxes($slug); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // Advanced Custom Fields (ACF Free) |
39 | - if ( class_exists( 'acf', false ) ) { |
|
40 | - $acf_fields = $this->get_acf_free_metaboxes( $slug ); |
|
39 | + if (class_exists('acf', false)) { |
|
40 | + $acf_fields = $this->get_acf_free_metaboxes($slug); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | // Return our array |
44 | - return array_merge( $cmb2_fields, $cmb_fields, $acf_fields ); |
|
44 | + return array_merge($cmb2_fields, $cmb_fields, $acf_fields); |
|
45 | 45 | |
46 | 46 | } |
47 | 47 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param string $slug Post type. |
57 | 57 | * @return array Fields array. |
58 | 58 | */ |
59 | - private function get_acf_free_metaboxes( $slug ){ |
|
59 | + private function get_acf_free_metaboxes($slug) { |
|
60 | 60 | |
61 | 61 | $fields = array(); |
62 | 62 | |
@@ -64,21 +64,21 @@ discard block |
||
64 | 64 | $fieldsets = $this->get_all_acf_field_groups(); |
65 | 65 | |
66 | 66 | // Return empty array if there are no fieldsets at all |
67 | - if ( empty( $fieldsets ) ){ |
|
67 | + if (empty($fieldsets)) { |
|
68 | 68 | return $fields; |
69 | 69 | } |
70 | 70 | |
71 | 71 | // Loop through each fieldset for possible matches |
72 | - foreach ( $fieldsets as $fieldset ){ |
|
72 | + foreach ($fieldsets as $fieldset) { |
|
73 | 73 | |
74 | - if ( $this->is_acf_field_in_post_type( $slug, $fieldset ) ){ |
|
74 | + if ($this->is_acf_field_in_post_type($slug, $fieldset)) { |
|
75 | 75 | |
76 | 76 | // If this is the first group of fields, simply set the value |
77 | 77 | // Else, merge this group with the previous one |
78 | - if ( empty( $fields ) ){ |
|
78 | + if (empty($fields)) { |
|
79 | 79 | $fields = $fieldset->fields; |
80 | 80 | } else { |
81 | - $fields = array_merge( $fields, $fieldset->fields ); |
|
81 | + $fields = array_merge($fields, $fieldset->fields); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | } |
@@ -99,16 +99,16 @@ discard block |
||
99 | 99 | * @param object $fieldset Fieldset group. |
100 | 100 | * @return boolean Whether or not the grouping is assigned to the post type. |
101 | 101 | */ |
102 | - private function is_acf_field_in_post_type( $slug, $fieldset ){ |
|
102 | + private function is_acf_field_in_post_type($slug, $fieldset) { |
|
103 | 103 | |
104 | 104 | // Make sure we have something to parse |
105 | - if ( empty( $fieldset ) ){ |
|
105 | + if (empty($fieldset)) { |
|
106 | 106 | return false; |
107 | 107 | } |
108 | 108 | |
109 | 109 | // Loop through the rules to check for post type matches |
110 | - foreach ( $fieldset->rules as $rule ){ |
|
111 | - if ( $rule['param'] === 'post_type' && $rule['value'] === $slug ){ |
|
110 | + foreach ($fieldset->rules as $rule) { |
|
111 | + if ($rule['param'] === 'post_type' && $rule['value'] === $slug) { |
|
112 | 112 | return true; |
113 | 113 | } |
114 | 114 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @return array All acf fieldsets. |
132 | 132 | */ |
133 | - private function get_all_acf_field_groups(){ |
|
133 | + private function get_all_acf_field_groups() { |
|
134 | 134 | $info = $rules = $fields = array(); |
135 | 135 | |
136 | 136 | $args = array( |
@@ -138,20 +138,20 @@ discard block |
||
138 | 138 | 'posts_per_page'=> 500 |
139 | 139 | ); |
140 | 140 | |
141 | - $objects = new \WP_Query( $args ); |
|
141 | + $objects = new \WP_Query($args); |
|
142 | 142 | |
143 | - if ( $objects->have_posts() ) : |
|
144 | - while ( $objects->have_posts() ) : $objects->the_post(); |
|
143 | + if ($objects->have_posts()) : |
|
144 | + while ($objects->have_posts()) : $objects->the_post(); |
|
145 | 145 | |
146 | - $data = get_metadata( 'post', get_the_id() ); |
|
146 | + $data = get_metadata('post', get_the_id()); |
|
147 | 147 | |
148 | - foreach ( $data['rule'] as $rule ){ |
|
149 | - $rules[] = unserialize( $rule ); |
|
148 | + foreach ($data['rule'] as $rule) { |
|
149 | + $rules[] = unserialize($rule); |
|
150 | 150 | } |
151 | 151 | |
152 | - foreach ( $data as $key => $value ){ |
|
153 | - if ( substr( $key, 0, 6 ) == 'field_' ) : |
|
154 | - $field_detail = unserialize( $value[0] ); |
|
152 | + foreach ($data as $key => $value) { |
|
153 | + if (substr($key, 0, 6) == 'field_') : |
|
154 | + $field_detail = unserialize($value[0]); |
|
155 | 155 | $fields[] = array( |
156 | 156 | 'key' => $field_detail['key'], |
157 | 157 | 'type' => $field_detail['type'], |
@@ -189,55 +189,55 @@ discard block |
||
189 | 189 | * @param string $slug a custom post type ID. |
190 | 190 | * @return array Array of fields. |
191 | 191 | */ |
192 | - private function get_cmb2_metaboxes( $slug ){ |
|
192 | + private function get_cmb2_metaboxes($slug) { |
|
193 | 193 | |
194 | 194 | $fields = array(); |
195 | 195 | |
196 | 196 | // Get all metaboxes from CMB2 library |
197 | - $all_metaboxes = apply_filters( 'cmb2_meta_boxes', array() ); |
|
197 | + $all_metaboxes = apply_filters('cmb2_meta_boxes', array()); |
|
198 | 198 | |
199 | 199 | // Loop through all possible sets of metaboxes added the old way |
200 | - foreach ( $all_metaboxes as $metabox_array ){ |
|
200 | + foreach ($all_metaboxes as $metabox_array) { |
|
201 | 201 | |
202 | 202 | // If the custom post type ID matches this set of fields, set & stop |
203 | - if ( in_array( $slug, $metabox_array['object_types'] ) ) { |
|
203 | + if (in_array($slug, $metabox_array['object_types'])) { |
|
204 | 204 | |
205 | 205 | // If this is the first group of fields, simply set the value |
206 | 206 | // Else, merge this group with the previous one |
207 | - if ( empty( $fields ) ){ |
|
207 | + if (empty($fields)) { |
|
208 | 208 | $fields = $metabox_array['fields']; |
209 | 209 | } else { |
210 | - $fields = array_merge( $fields, $metabox_array['fields'] ); |
|
210 | + $fields = array_merge($fields, $metabox_array['fields']); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
214 | 214 | } |
215 | 215 | |
216 | 216 | // Loop through all metaboxes added the new way |
217 | - foreach ( \CMB2_Boxes::get_all() as $cmb ) { |
|
217 | + foreach (\CMB2_Boxes::get_all() as $cmb) { |
|
218 | 218 | |
219 | 219 | // Create the default |
220 | 220 | $match = false; |
221 | 221 | |
222 | 222 | // Establish correct cmb types |
223 | - if ( is_string( $cmb->meta_box['object_types'] ) ){ |
|
224 | - if ( $cmb->meta_box['object_types'] == $slug ){ |
|
223 | + if (is_string($cmb->meta_box['object_types'])) { |
|
224 | + if ($cmb->meta_box['object_types'] == $slug) { |
|
225 | 225 | $match = true; |
226 | 226 | } |
227 | 227 | } else { |
228 | - if ( in_array( $slug, $cmb->meta_box['object_types'] ) ){ |
|
228 | + if (in_array($slug, $cmb->meta_box['object_types'])) { |
|
229 | 229 | $match = true; |
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
233 | - if ( $match !== true ){ |
|
233 | + if ($match !== true) { |
|
234 | 234 | continue; |
235 | 235 | } |
236 | 236 | |
237 | - if ( empty( $fields ) ){ |
|
237 | + if (empty($fields)) { |
|
238 | 238 | $fields = $cmb->meta_box['fields']; |
239 | 239 | } else { |
240 | - $fields = array_merge( $fields, $cmb->meta_box['fields'] ); |
|
240 | + $fields = array_merge($fields, $cmb->meta_box['fields']); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | } |
@@ -261,25 +261,25 @@ discard block |
||
261 | 261 | * @param string $slug a custom post type ID. |
262 | 262 | * @return array Array of fields. |
263 | 263 | */ |
264 | - private function get_cmb1_metaboxes( $slug ){ |
|
264 | + private function get_cmb1_metaboxes($slug) { |
|
265 | 265 | |
266 | 266 | $fields = array(); |
267 | 267 | |
268 | 268 | // Get all metaboxes from CMB2 library |
269 | - $all_metaboxes = apply_filters( 'cmb_meta_boxes', array() ); |
|
269 | + $all_metaboxes = apply_filters('cmb_meta_boxes', array()); |
|
270 | 270 | |
271 | 271 | // Loop through all possible sets of metaboxes |
272 | - foreach ( $all_metaboxes as $metabox_array ){ |
|
272 | + foreach ($all_metaboxes as $metabox_array) { |
|
273 | 273 | |
274 | 274 | // If the custom post type ID matches this set of fields, set & stop |
275 | - if ( in_array( $slug, $metabox_array['pages'] ) ) { |
|
275 | + if (in_array($slug, $metabox_array['pages'])) { |
|
276 | 276 | |
277 | 277 | // If this is the first group of fields, simply set the value |
278 | 278 | // Else, merge this group with the previous one |
279 | - if ( empty( $fields ) ){ |
|
279 | + if (empty($fields)) { |
|
280 | 280 | $fields = $metabox_array['fields']; |
281 | 281 | } else { |
282 | - $fields = array_merge( $fields, $metabox_array['fields'] ); |
|
282 | + $fields = array_merge($fields, $metabox_array['fields']); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
@@ -302,36 +302,36 @@ discard block |
||
302 | 302 | * @param int $post_id Single post ID. |
303 | 303 | * @param array $cmb custom metabox array from CMB2. |
304 | 304 | */ |
305 | - public function random_metabox_content( $post_id, $cmb, $connected ){ |
|
305 | + public function random_metabox_content($post_id, $cmb, $connected) { |
|
306 | 306 | $value = ''; |
307 | 307 | |
308 | 308 | // First check that our post ID & cmb array aren't empty |
309 | - if ( empty( $cmb ) || empty( $post_id ) ){ |
|
309 | + if (empty($cmb) || empty($post_id)) { |
|
310 | 310 | return; |
311 | 311 | } |
312 | 312 | |
313 | 313 | // Fetch the appropriate type of data and return |
314 | - switch( $cmb['type'] ){ |
|
314 | + switch ($cmb['type']) { |
|
315 | 315 | |
316 | 316 | case 'text': |
317 | 317 | case 'text_small': |
318 | 318 | case 'text_medium': |
319 | 319 | |
320 | 320 | // If phone is in the id, fetch a phone # |
321 | - if ( stripos( $cmb['id'], 'phone' ) ){ |
|
321 | + if (stripos($cmb['id'], 'phone')) { |
|
322 | 322 | $value = TestContent::phone(); |
323 | 323 | |
324 | 324 | // If email is in the id, fetch an email address |
325 | - } elseif ( stripos( $cmb['id'], 'email' ) ){ |
|
325 | + } elseif (stripos($cmb['id'], 'email')) { |
|
326 | 326 | $value = TestContent::email(); |
327 | 327 | |
328 | 328 | // If time is in the id, fetch a time string |
329 | - } elseif ( stripos( $cmb['id'], 'time' ) ){ |
|
329 | + } elseif (stripos($cmb['id'], 'time')) { |
|
330 | 330 | $value = TestContent::time(); |
331 | 331 | |
332 | 332 | // Otherwise, just a random text string |
333 | 333 | } else { |
334 | - $value = TestContent::title( rand( 10, 50 ) ); |
|
334 | + $value = TestContent::title(rand(10, 50)); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | break; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | |
352 | 352 | case 'number' : |
353 | 353 | |
354 | - $value = rand( 1, 10000000 ); |
|
354 | + $value = rand(1, 10000000); |
|
355 | 355 | |
356 | 356 | break; |
357 | 357 | |
@@ -369,14 +369,14 @@ discard block |
||
369 | 369 | |
370 | 370 | case 'text_date': |
371 | 371 | |
372 | - $value = TestContent::date( 'm/d/Y' ); |
|
372 | + $value = TestContent::date('m/d/Y'); |
|
373 | 373 | |
374 | 374 | break; |
375 | 375 | |
376 | 376 | case 'text_date_timestamp': |
377 | 377 | case 'text_datetime_timestamp': |
378 | 378 | |
379 | - $value = TestContent::date( 'U' ); |
|
379 | + $value = TestContent::date('U'); |
|
380 | 380 | |
381 | 381 | break; |
382 | 382 | |
@@ -384,13 +384,13 @@ discard block |
||
384 | 384 | |
385 | 385 | case 'text_money': |
386 | 386 | |
387 | - $value = rand( 0, 100000 ); |
|
387 | + $value = rand(0, 100000); |
|
388 | 388 | |
389 | 389 | break; |
390 | 390 | |
391 | 391 | case 'test_colorpicker': |
392 | 392 | |
393 | - $value = '#' . str_pad( dechex( mt_rand( 0, 0xFFFFFF ) ), 6, '0', STR_PAD_LEFT ); |
|
393 | + $value = '#'.str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT); |
|
394 | 394 | |
395 | 395 | break; |
396 | 396 | |
@@ -407,8 +407,8 @@ discard block |
||
407 | 407 | case 'radio': |
408 | 408 | |
409 | 409 | // Grab a random item out of the array and return the key |
410 | - $new_val = array_slice( $cmb['options'], rand( 0, count( $cmb['options'] ) ), 1 ); |
|
411 | - $value = key( $new_val ); |
|
410 | + $new_val = array_slice($cmb['options'], rand(0, count($cmb['options'])), 1); |
|
411 | + $value = key($new_val); |
|
412 | 412 | |
413 | 413 | break; |
414 | 414 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | case 'checkbox': |
420 | 420 | |
421 | 421 | // 50/50 odds of being turned on |
422 | - if ( rand( 0, 1 ) == 1 ){ |
|
422 | + if (rand(0, 1) == 1) { |
|
423 | 423 | $value = 'on'; |
424 | 424 | } |
425 | 425 | |
@@ -430,10 +430,10 @@ discard block |
||
430 | 430 | $new_option = array(); |
431 | 431 | |
432 | 432 | // Loop through each of our options |
433 | - foreach ( $cmb['options'] as $key => $value ){ |
|
433 | + foreach ($cmb['options'] as $key => $value) { |
|
434 | 434 | |
435 | 435 | // 50/50 chance of being included |
436 | - if ( rand( 0, 1 ) ){ |
|
436 | + if (rand(0, 1)) { |
|
437 | 437 | $new_option[] = $key; |
438 | 438 | } |
439 | 439 | |
@@ -451,8 +451,8 @@ discard block |
||
451 | 451 | |
452 | 452 | case 'file': |
453 | 453 | |
454 | - if ( true == $connected ){ |
|
455 | - $value = TestContent::image( $post_id ); |
|
454 | + if (true == $connected) { |
|
455 | + $value = TestContent::image($post_id); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | break; |
@@ -468,12 +468,12 @@ discard block |
||
468 | 468 | } |
469 | 469 | |
470 | 470 | // Value must exist to attempt to insert |
471 | - if ( ! empty( $value ) && ! is_wp_error( $value ) ){ |
|
471 | + if (!empty($value) && !is_wp_error($value)) { |
|
472 | 472 | |
473 | - $this->update_meta( $post_id, $value, $cmb ); |
|
473 | + $this->update_meta($post_id, $value, $cmb); |
|
474 | 474 | |
475 | 475 | // If we're dealing with a WP Error object, just return the message for debugging |
476 | - } elseif ( is_wp_error( $value ) ){ |
|
476 | + } elseif (is_wp_error($value)) { |
|
477 | 477 | return $value->get_error_message(); |
478 | 478 | } |
479 | 479 | |
@@ -491,25 +491,25 @@ discard block |
||
491 | 491 | * @param string $value Value to add into the database. |
492 | 492 | * @param array $cmb SMB data. |
493 | 493 | */ |
494 | - private function update_meta( $post_id, $value, $cmb ){ |
|
494 | + private function update_meta($post_id, $value, $cmb) { |
|
495 | 495 | |
496 | 496 | $type = $cmb['type']; |
497 | - $id = $cmb['id']; |
|
498 | - $value = apply_filters( "tc_{$type}_metabox", $value ); // Filter by metabox type |
|
499 | - $value = apply_filters( "tc_{$id}_metabox", $value ); // Filter by metabox ID |
|
497 | + $id = $cmb['id']; |
|
498 | + $value = apply_filters("tc_{$type}_metabox", $value); // Filter by metabox type |
|
499 | + $value = apply_filters("tc_{$id}_metabox", $value); // Filter by metabox ID |
|
500 | 500 | |
501 | 501 | // Files must be treated separately - they use the attachment ID |
502 | 502 | // & url of media for separate cmb values. |
503 | - if ( $cmb['type'] != 'file' ){ |
|
504 | - add_post_meta( $post_id, $cmb['id'], $value, true ); |
|
503 | + if ($cmb['type'] != 'file') { |
|
504 | + add_post_meta($post_id, $cmb['id'], $value, true); |
|
505 | 505 | } else { |
506 | - add_post_meta( $post_id, $cmb['id'].'_id', $value, true ); |
|
507 | - add_post_meta( $post_id, $cmb['id'], wp_get_attachment_url( $value ), true ); |
|
506 | + add_post_meta($post_id, $cmb['id'].'_id', $value, true); |
|
507 | + add_post_meta($post_id, $cmb['id'], wp_get_attachment_url($value), true); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | // Add extra, redundant meta. Because, why not have rows for the price of one? |
511 | - if ( isset( $cmb['source'] ) && $cmb['source'] === 'acf' ){ |
|
512 | - add_post_meta( $post_id, '_' . $cmb['id'], $cmb['key'], true ); |
|
511 | + if (isset($cmb['source']) && $cmb['source'] === 'acf') { |
|
512 | + add_post_meta($post_id, '_'.$cmb['id'], $cmb['key'], true); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | } |
@@ -427,29 +427,29 @@ discard block |
||
427 | 427 | } |
428 | 428 | |
429 | 429 | // Download the file |
430 | - $tmp = \download_url( $url ); |
|
430 | + $tmp = \download_url( $url ); |
|
431 | 431 | |
432 | - preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches ); |
|
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 | - // Check for download errors |
|
438 | - if ( is_wp_error( $tmp ) ) { |
|
439 | - unlink( $file_array[ 'tmp_name' ] ); |
|
440 | - error_log( $tmp->get_error_message() ); |
|
441 | - } |
|
437 | + // Check for download errors |
|
438 | + if ( is_wp_error( $tmp ) ) { |
|
439 | + unlink( $file_array[ 'tmp_name' ] ); |
|
440 | + error_log( $tmp->get_error_message() ); |
|
441 | + } |
|
442 | 442 | |
443 | 443 | // Pull the image into the media library |
444 | - $image_id = media_handle_sideload( $file_array, $post_id ); |
|
444 | + $image_id = media_handle_sideload( $file_array, $post_id ); |
|
445 | 445 | |
446 | - // Check for handle sideload errors. |
|
447 | - if ( is_wp_error( $image_id ) ) { |
|
448 | - unlink( $file_array['tmp_name'] ); |
|
449 | - error_log( $image_id->get_error_message() ); |
|
450 | - } |
|
446 | + // Check for handle sideload errors. |
|
447 | + if ( is_wp_error( $image_id ) ) { |
|
448 | + unlink( $file_array['tmp_name'] ); |
|
449 | + error_log( $image_id->get_error_message() ); |
|
450 | + } |
|
451 | 451 | |
452 | - return apply_filters( "tc_image_data", $image_id ); |
|
452 | + return apply_filters( "tc_image_data", $image_id ); |
|
453 | 453 | |
454 | 454 | } |
455 | 455 | |
@@ -472,9 +472,9 @@ discard block |
||
472 | 472 | |
473 | 473 | // If our cURL failed |
474 | 474 | if ( $curl_response === false ) { |
475 | - $info = curl_getinfo( $curl ); |
|
476 | - curl_close( $curl ); |
|
477 | - die( 'error occured during curl exec. Additional info: ' . var_export( $info ) ); |
|
475 | + $info = curl_getinfo( $curl ); |
|
476 | + curl_close( $curl ); |
|
477 | + die( 'error occured during curl exec. Additional info: ' . var_export( $info ) ); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | curl_close( $curl ); |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | $char = "0123456789abcdefghijklmnopqrstuvwxyz"; |
621 | 621 | |
622 | 622 | $user_length = mt_rand( 5, 20 ); |
623 | - $domain_length = mt_rand( 7, 12 ); |
|
623 | + $domain_length = mt_rand( 7, 12 ); |
|
624 | 624 | |
625 | 625 | for ( $i = 1; $i <= $user_length; $i++ ){ |
626 | 626 | $user .= substr( $char, mt_rand( 0, strlen( $char ) ), 1 ); |
@@ -14,7 +14,7 @@ discard block |
||
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 |
||
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,16 +67,16 @@ discard block |
||
67 | 67 | ); |
68 | 68 | |
69 | 69 | // If we didn't choose a count, make one |
70 | - if ( empty( $num_words ) ){ |
|
71 | - $num_words = rand( 2, 10 ); |
|
70 | + if (empty($num_words)) { |
|
71 | + $num_words = rand(2, 10); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // Pull random words |
75 | - for( $i = 1; $i <= $num_words; $i++ ){ |
|
76 | - $title .= $random_words[ rand( 0, 31 ) ] . " "; |
|
75 | + for ($i = 1; $i <= $num_words; $i++) { |
|
76 | + $title .= $random_words[rand(0, 31)]." "; |
|
77 | 77 | } |
78 | 78 | |
79 | - return apply_filters( "tc_title_data", substr( $title, 0, -1 ) ); |
|
79 | + return apply_filters("tc_title_data", substr($title, 0, -1)); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | |
@@ -89,7 +89,7 @@ discard block |
||
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,12 +351,12 @@ discard block |
||
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 | - $key = rand( 0, 12 ); |
|
358 | - while( in_array( $key, $used_keys ) ){ |
|
359 | - $key = rand( 0, 12 ); |
|
357 | + $key = rand(0, 12); |
|
358 | + while (in_array($key, $used_keys)) { |
|
359 | + $key = rand(0, 12); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | $content .= $random_content_types[$key]; |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $used_keys[] = $key; |
365 | 365 | } |
366 | 366 | |
367 | - return apply_filters( "tc_paragraphs_data", $content ); |
|
367 | + return apply_filters("tc_paragraphs_data", $content); |
|
368 | 368 | |
369 | 369 | } |
370 | 370 | |
@@ -376,7 +376,7 @@ discard block |
||
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.', |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | 'Fusce semper erat tortor, at pulvinar risus luctus suscipit. Phasellus quis enim nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas semper dapibus odio, nec pellentesque sem laoreet sit amet. Maecenas ut enim tellus. Fusce malesuada mattis sem, porta interdum ex fermentum quis. Ut eget quam mi. In molestie volutpat feugiat. Nulla vel viverra nunc. Integer lobortis nisl vitae placerat egestas. Curabitur tristique nulla at libero blandit, a eleifend augue tempus.', |
392 | 392 | ); |
393 | 393 | |
394 | - return apply_filters( "tc_plain_text_data", $paragraphs[ rand( 0, 9 ) ] ); |
|
394 | + return apply_filters("tc_plain_text_data", $paragraphs[rand(0, 9)]); |
|
395 | 395 | |
396 | 396 | } |
397 | 397 | |
@@ -407,49 +407,49 @@ discard block |
||
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 | |
427 | 427 | } |
428 | 428 | |
429 | 429 | // Download the file |
430 | - $tmp = \download_url( $url ); |
|
430 | + $tmp = \download_url($url); |
|
431 | 431 | |
432 | - preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches ); |
|
432 | + preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches); |
|
433 | 433 | |
434 | - $file_array['name'] = basename( $matches[0] ); |
|
434 | + $file_array['name'] = basename($matches[0]); |
|
435 | 435 | $file_array['tmp_name'] = $tmp; |
436 | 436 | |
437 | 437 | // Check for download errors |
438 | - if ( is_wp_error( $tmp ) ) { |
|
439 | - unlink( $file_array[ 'tmp_name' ] ); |
|
440 | - error_log( $tmp->get_error_message() ); |
|
438 | + if (is_wp_error($tmp)) { |
|
439 | + unlink($file_array['tmp_name']); |
|
440 | + error_log($tmp->get_error_message()); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | // Pull the image into the media library |
444 | - $image_id = media_handle_sideload( $file_array, $post_id ); |
|
444 | + $image_id = media_handle_sideload($file_array, $post_id); |
|
445 | 445 | |
446 | 446 | // Check for handle sideload errors. |
447 | - if ( is_wp_error( $image_id ) ) { |
|
448 | - unlink( $file_array['tmp_name'] ); |
|
449 | - error_log( $image_id->get_error_message() ); |
|
447 | + if (is_wp_error($image_id)) { |
|
448 | + unlink($file_array['tmp_name']); |
|
449 | + error_log($image_id->get_error_message()); |
|
450 | 450 | } |
451 | 451 | |
452 | - return apply_filters( "tc_image_data", $image_id ); |
|
452 | + return apply_filters("tc_image_data", $image_id); |
|
453 | 453 | |
454 | 454 | } |
455 | 455 | |
@@ -461,31 +461,31 @@ discard block |
||
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 | - $curl = curl_init( "http://www.splashbase.co/api/v1/images/random?images_only=true" ); |
|
467 | + $curl = curl_init("http://www.splashbase.co/api/v1/images/random?images_only=true"); |
|
468 | 468 | |
469 | - curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE ); |
|
469 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); |
|
470 | 470 | |
471 | - $curl_response = curl_exec( $curl ); |
|
471 | + $curl_response = curl_exec($curl); |
|
472 | 472 | |
473 | 473 | // If our cURL failed |
474 | - if ( $curl_response === false ) { |
|
475 | - $info = curl_getinfo( $curl ); |
|
476 | - curl_close( $curl ); |
|
477 | - die( 'error occured during curl exec. Additional info: ' . var_export( $info ) ); |
|
474 | + if ($curl_response === false) { |
|
475 | + $info = curl_getinfo($curl); |
|
476 | + curl_close($curl); |
|
477 | + die('error occured during curl exec. Additional info: '.var_export($info)); |
|
478 | 478 | } |
479 | 479 | |
480 | - curl_close( $curl ); |
|
480 | + curl_close($curl); |
|
481 | 481 | |
482 | 482 | // Decode the data |
483 | - $response = json_decode( $curl_response, true ); |
|
483 | + $response = json_decode($curl_response, true); |
|
484 | 484 | |
485 | 485 | // Check to make sure that the return contains a valid image extensions |
486 | 486 | preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $response['url'], $matches); |
487 | 487 | |
488 | - if ( !empty( $matches ) ){ |
|
488 | + if (!empty($matches)) { |
|
489 | 489 | return $response['url']; |
490 | 490 | } |
491 | 491 | |
@@ -500,12 +500,12 @@ discard block |
||
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 | - $num_days = rand( 1, 60 ); |
|
506 | - $date = date( $format, strtotime( " +$num_days days" ) ); |
|
505 | + $num_days = rand(1, 60); |
|
506 | + $date = date($format, strtotime(" +$num_days days")); |
|
507 | 507 | |
508 | - return apply_filters( "tc_date_data", $date ); |
|
508 | + return apply_filters("tc_date_data", $date); |
|
509 | 509 | |
510 | 510 | } |
511 | 511 | |
@@ -517,19 +517,19 @@ discard block |
||
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 | - return apply_filters( "tc_time_data", $times[ rand( 0, 6 ) ] ); |
|
532 | + return apply_filters("tc_time_data", $times[rand(0, 6)]); |
|
533 | 533 | |
534 | 534 | } |
535 | 535 | |
@@ -541,7 +541,7 @@ discard block |
||
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', |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | 'UTC' |
560 | 560 | ); |
561 | 561 | |
562 | - return apply_filters( "tc_timezone_data", $timezones[ rand( 0, 12 ) ] ); |
|
562 | + return apply_filters("tc_timezone_data", $timezones[rand(0, 12)]); |
|
563 | 563 | |
564 | 564 | } |
565 | 565 | |
@@ -572,7 +572,7 @@ discard block |
||
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', |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | '+43 780 0047112' |
589 | 589 | ); |
590 | 590 | |
591 | - return apply_filters( "tc_phone_data", $phone_numbers[ rand( 0, 10 ) ] ); |
|
591 | + return apply_filters("tc_phone_data", $phone_numbers[rand(0, 10)]); |
|
592 | 592 | |
593 | 593 | } |
594 | 594 | |
@@ -600,11 +600,11 @@ discard block |
||
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( |
@@ -619,20 +619,20 @@ discard block |
||
619 | 619 | |
620 | 620 | $char = "0123456789abcdefghijklmnopqrstuvwxyz"; |
621 | 621 | |
622 | - $user_length = mt_rand( 5, 20 ); |
|
623 | - $domain_length = mt_rand( 7, 12 ); |
|
622 | + $user_length = mt_rand(5, 20); |
|
623 | + $domain_length = mt_rand(7, 12); |
|
624 | 624 | |
625 | - for ( $i = 1; $i <= $user_length; $i++ ){ |
|
626 | - $user .= substr( $char, mt_rand( 0, strlen( $char ) ), 1 ); |
|
625 | + for ($i = 1; $i <= $user_length; $i++) { |
|
626 | + $user .= substr($char, mt_rand(0, strlen($char)), 1); |
|
627 | 627 | } |
628 | 628 | |
629 | - for ( $i = 1; $i <= $domain_length; $i++ ){ |
|
630 | - $domain .= substr( $char, mt_rand( 0, strlen( $char ) ), 1 ); |
|
629 | + for ($i = 1; $i <= $domain_length; $i++) { |
|
630 | + $domain .= substr($char, mt_rand(0, strlen($char)), 1); |
|
631 | 631 | } |
632 | 632 | |
633 | - $tld = $tlds[ mt_rand( 0, ( sizeof( $tlds ) - 1 ) ) ]; |
|
633 | + $tld = $tlds[mt_rand(0, (sizeof($tlds) - 1))]; |
|
634 | 634 | |
635 | - $email = $user . "@" . $domain . '.' . $tld; |
|
635 | + $email = $user."@".$domain.'.'.$tld; |
|
636 | 636 | |
637 | 637 | } else { |
638 | 638 | |
@@ -647,12 +647,12 @@ discard block |
||
647 | 647 | '[email protected]' |
648 | 648 | ); |
649 | 649 | |
650 | - $email = $email_addresses[ rand( 0, 7 ) ]; |
|
650 | + $email = $email_addresses[rand(0, 7)]; |
|
651 | 651 | |
652 | 652 | } |
653 | 653 | |
654 | 654 | |
655 | - return apply_filters( "tc_email_data", $email ); |
|
655 | + return apply_filters("tc_email_data", $email); |
|
656 | 656 | |
657 | 657 | } |
658 | 658 | |
@@ -666,12 +666,12 @@ discard block |
||
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', |
673 | 673 | 'https://www.twitter.com', |
674 | - site_url( '/?iam=anextravariable' ), |
|
674 | + site_url('/?iam=anextravariable'), |
|
675 | 675 | 'github.com', |
676 | 676 | 'http://filebase.com', |
677 | 677 | 'www.oldtownmediainc.com', |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | 'https://www.eff.org' |
680 | 680 | ); |
681 | 681 | |
682 | - return apply_filters( "tc_link_data", $links[ rand( 0, 7 ) ] ); |
|
682 | + return apply_filters("tc_link_data", $links[rand(0, 7)]); |
|
683 | 683 | |
684 | 684 | } |
685 | 685 | |
@@ -690,7 +690,7 @@ discard block |
||
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', |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | 'https://www.instagram.com/p/-eyLo0RMfX', |
702 | 702 | ); |
703 | 703 | |
704 | - return apply_filters( "tc_oembed_data", $links[ rand( 0, 5 ) ] ); |
|
704 | + return apply_filters("tc_oembed_data", $links[rand(0, 5)]); |
|
705 | 705 | |
706 | 706 | } |
707 | 707 | |
@@ -715,10 +715,10 @@ discard block |
||
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' : |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | |
760 | 760 | } |
761 | 761 | |
762 | - return apply_filters( "tc_video_data", $links[ rand( 0, 8 ) ] ); |
|
762 | + return apply_filters("tc_video_data", $links[rand(0, 8)]); |
|
763 | 763 | |
764 | 764 | } |
765 | 765 | |
@@ -770,7 +770,7 @@ discard block |
||
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', |
@@ -819,11 +819,11 @@ discard block |
||
819 | 819 | ); |
820 | 820 | |
821 | 821 | $name = array( |
822 | - 'first' => $first_names[ rand( 0, 19 ) ], |
|
823 | - 'last' => $last_names[ rand( 0, 19 ) ] |
|
822 | + 'first' => $first_names[rand(0, 19)], |
|
823 | + 'last' => $last_names[rand(0, 19)] |
|
824 | 824 | ); |
825 | 825 | |
826 | - return apply_filters( "tc_name_data", $name ); |
|
826 | + return apply_filters("tc_name_data", $name); |
|
827 | 827 | |
828 | 828 | } |
829 | 829 |
@@ -10,16 +10,16 @@ |
||
10 | 10 | * @subpackage Evans |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -class Reporting{ |
|
13 | +class Reporting { |
|
14 | 14 | |
15 | - public function create_report( $data ){ |
|
15 | + public function create_report($data) { |
|
16 | 16 | |
17 | - $cleaned = json_encode( $this->parse_data( $data ) ); |
|
17 | + $cleaned = json_encode($this->parse_data($data)); |
|
18 | 18 | return $cleaned; |
19 | 19 | |
20 | 20 | } |
21 | 21 | |
22 | - private function parse_data( $data ){ |
|
22 | + private function parse_data($data) { |
|
23 | 23 | |
24 | 24 | return $data; |
25 | 25 |
@@ -10,11 +10,11 @@ discard block |
||
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 | 15 | protected $title = 'Various'; |
16 | 16 | protected $type = 'all'; |
17 | - protected $priority = 10; |
|
17 | + protected $priority = 10; |
|
18 | 18 | |
19 | 19 | |
20 | 20 | /** |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return string HTML content. |
26 | 26 | */ |
27 | - protected function actions_section(){ |
|
27 | + protected function actions_section() { |
|
28 | 28 | $html = ''; |
29 | 29 | |
30 | 30 | $html .= "<div class='test-data-cpt'>"; |
31 | 31 | |
32 | 32 | $html .= "<h3>"; |
33 | 33 | |
34 | - $html .= "<span class='label'>" . __( 'Clean Site', 'otm-test-content' ) . "</span>"; |
|
35 | - $html .= $this->build_button( 'delete', 'all', __( 'Delete All Test Data', 'otm-test-content' ) ); |
|
34 | + $html .= "<span class='label'>".__('Clean Site', 'otm-test-content')."</span>"; |
|
35 | + $html .= $this->build_button('delete', 'all', __('Delete All Test Data', 'otm-test-content')); |
|
36 | 36 | |
37 | 37 | $html .= "</h3>"; |
38 | 38 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param string $html Existing HTML content. |
51 | 51 | * @return string HTML section content. |
52 | 52 | */ |
53 | - protected function options_section( $html = '' ){ |
|
53 | + protected function options_section($html = '') { |
|
54 | 54 | return $html; |
55 | 55 | } |
56 | 56 |
@@ -28,7 +28,7 @@ discard block |
||
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', |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | ); |
38 | 38 | |
39 | 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 | - } else { |
|
44 | - $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '-\\1', $class ) ); |
|
45 | - $file = dirname( __FILE__ ) . '/includes/class-' . $class . '.php'; |
|
46 | - } |
|
40 | + $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '/\1', $class ) ); |
|
41 | + $class = str_replace( '\\', '', $class ); |
|
42 | + $file = dirname( __FILE__ ) . '/' . $class . '.php'; |
|
43 | + } else { |
|
44 | + $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '-\\1', $class ) ); |
|
45 | + $file = dirname( __FILE__ ) . '/includes/class-' . $class . '.php'; |
|
46 | + } |
|
47 | 47 | |
48 | 48 | if ( is_readable( $file ) ) { |
49 | 49 | require_once( $file ); |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | // Register hook providers and views. |
83 | 83 | plugin()->register_hooks( new AdminPage() ) |
84 | 84 | ->register_hooks( new Ajax() ) |
85 | - ->register_view( new Views\Posts() ) |
|
86 | - ->register_view( new Views\Terms() ) |
|
85 | + ->register_view( new Views\Posts() ) |
|
86 | + ->register_view( new Views\Terms() ) |
|
87 | 87 | ->register_view( new Views\Various() ) |
88 | 88 | ->register_type( new Types\Post() ) |
89 | 89 | ->register_type( new Types\Term() ); |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param string $class Class name. |
23 | 23 | */ |
24 | -function test_content_autoloader( $class ) { |
|
25 | - $namespace = explode( '\\', $class ); |
|
24 | +function test_content_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 |
||
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__ . '\test_content_autoloader' ); |
|
52 | + spl_autoload_register(__NAMESPACE__.'\test_content_autoloader'); |
|
53 | 53 | |
54 | 54 | |
55 | 55 | |
@@ -61,7 +61,7 @@ discard block |
||
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,22 +71,22 @@ discard block |
||
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\Various() ) |
|
88 | - ->register_type( new Types\Post() ) |
|
89 | - ->register_type( new Types\Term() ); |
|
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\Various()) |
|
88 | + ->register_type(new Types\Post()) |
|
89 | + ->register_type(new Types\Term()); |
|
90 | 90 | |
91 | 91 | // Load textdomain hook |
92 | -add_action( 'plugins_loaded', array( plugin(), 'load_textdomain' ) ); |
|
92 | +add_action('plugins_loaded', array(plugin(), 'load_textdomain')); |
@@ -9,7 +9,7 @@ discard block |
||
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 |
||
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 |
||
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; |
@@ -276,7 +276,7 @@ |
||
276 | 276 | $post_types = get_post_types( array( 'public' => true ), 'objects' ); |
277 | 277 | foreach ( $post_types as $post_type ) : |
278 | 278 | |
279 | - return $this->delete( $post_type->name ); |
|
279 | + return $this->delete( $post_type->name ); |
|
280 | 280 | |
281 | 281 | endforeach; |
282 | 282 |
@@ -13,7 +13,7 @@ discard block |
||
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 | * metaboxes |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @see object |
40 | 40 | */ |
41 | - public function __construct(){ |
|
41 | + public function __construct() { |
|
42 | 42 | |
43 | 43 | $this->metaboxes = new Main\Metaboxes; |
44 | 44 | |
@@ -59,29 +59,29 @@ discard block |
||
59 | 59 | * @param boolean $connection Whether or not we're connected to the Internet. |
60 | 60 | * @param int $num Optional. Number of posts to create. |
61 | 61 | */ |
62 | - public function create_objects( $slug, $connection, $num = '' ){ |
|
62 | + public function create_objects($slug, $connection, $num = '') { |
|
63 | 63 | |
64 | 64 | // If we're missing a custom post type id - don't do anything |
65 | - if ( empty( $slug ) ){ |
|
65 | + if (empty($slug)) { |
|
66 | 66 | return; |
67 | 67 | } |
68 | 68 | |
69 | 69 | // Gather the necessary data to create the posts |
70 | - $supports = $this->get_cpt_supports( $slug ); |
|
71 | - $metaboxes = $this->metaboxes->get_metaboxes( $slug ); |
|
70 | + $supports = $this->get_cpt_supports($slug); |
|
71 | + $metaboxes = $this->metaboxes->get_metaboxes($slug); |
|
72 | 72 | |
73 | 73 | // Set our connection status for the rest of the methods |
74 | 74 | $this->connected = $connection; |
75 | 75 | |
76 | 76 | // If we forgot to put in a quantity, make one for us |
77 | - if ( empty( $num ) ){ |
|
78 | - $num = rand( 5, 30 ); |
|
77 | + if (empty($num)) { |
|
78 | + $num = rand(5, 30); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | // Create test posts |
82 | - for( $i = 0; $i < $num; $i++ ){ |
|
82 | + for ($i = 0; $i < $num; $i++) { |
|
83 | 83 | |
84 | - $return = $this->create_test_object( $slug, $supports, $metaboxes ); |
|
84 | + $return = $this->create_test_object($slug, $supports, $metaboxes); |
|
85 | 85 | |
86 | 86 | return $return; |
87 | 87 | |
@@ -105,15 +105,15 @@ discard block |
||
105 | 105 | * @param array $supports Features that the post type supports. |
106 | 106 | * @param array $supports All CMB2 metaboxes attached to the post type. |
107 | 107 | */ |
108 | - private function create_test_object( $slug, $supports, $metaboxes ){ |
|
108 | + private function create_test_object($slug, $supports, $metaboxes) { |
|
109 | 109 | $return = ''; |
110 | 110 | |
111 | 111 | // Get a random title |
112 | - $title = apply_filters( "tc_{$slug}_post_title", TestContent::title() ); |
|
112 | + $title = apply_filters("tc_{$slug}_post_title", TestContent::title()); |
|
113 | 113 | |
114 | 114 | // First, insert our post |
115 | 115 | $post = array( |
116 | - 'post_name' => sanitize_title( $title ), |
|
116 | + 'post_name' => sanitize_title($title), |
|
117 | 117 | 'post_status' => 'publish', |
118 | 118 | 'post_type' => $slug, |
119 | 119 | 'ping_status' => 'closed', |
@@ -121,57 +121,57 @@ discard block |
||
121 | 121 | ); |
122 | 122 | |
123 | 123 | // Add title if supported |
124 | - if ( $supports['title'] === true ){ |
|
124 | + if ($supports['title'] === true) { |
|
125 | 125 | $post['post_title'] = $title; |
126 | 126 | } |
127 | 127 | |
128 | 128 | // Add main content if supported |
129 | - if ( $supports['editor'] === true ){ |
|
130 | - $post['post_content'] = apply_filters( "tc_{$slug}_post_content", TestContent::paragraphs() ); |
|
129 | + if ($supports['editor'] === true) { |
|
130 | + $post['post_content'] = apply_filters("tc_{$slug}_post_content", TestContent::paragraphs()); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // Add excerpt content if supported |
134 | - if ( $supports['excerpt'] === true ){ |
|
135 | - $post['post_excerpt'] = apply_filters( "tc_{$slug}_post_excerpt", TestContent::plain_text() ); |
|
134 | + if ($supports['excerpt'] === true) { |
|
135 | + $post['post_excerpt'] = apply_filters("tc_{$slug}_post_excerpt", TestContent::plain_text()); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | // Insert then post object |
139 | - $post_id = wp_insert_post( apply_filters( "tc_{$slug}_post_arguments", $post ) ); |
|
139 | + $post_id = wp_insert_post(apply_filters("tc_{$slug}_post_arguments", $post)); |
|
140 | 140 | |
141 | 141 | // Then, set a test content flag on the new post for later deletion |
142 | - add_post_meta( $post_id, 'evans_test_content', '__test__', true ); |
|
142 | + add_post_meta($post_id, 'evans_test_content', '__test__', true); |
|
143 | 143 | |
144 | 144 | // Add thumbnail if supported |
145 | - if ( $this->connected == true && ( $supports['thumbnail'] === true || in_array( $slug, array( 'post', 'page' ) ) ) ){ |
|
146 | - update_post_meta( $post_id, '_thumbnail_id', TestContent::image( $post_id ) ); |
|
145 | + if ($this->connected == true && ($supports['thumbnail'] === true || in_array($slug, array('post', 'page')))) { |
|
146 | + update_post_meta($post_id, '_thumbnail_id', TestContent::image($post_id)); |
|
147 | 147 | } |
148 | 148 | |
149 | - $taxonomies = get_object_taxonomies( $slug ); |
|
149 | + $taxonomies = get_object_taxonomies($slug); |
|
150 | 150 | |
151 | 151 | // Assign the post to terms |
152 | - if ( !empty( $taxonomies ) ){ |
|
153 | - $return .= $this->assign_terms( $post_id, $taxonomies ); |
|
152 | + if (!empty($taxonomies)) { |
|
153 | + $return .= $this->assign_terms($post_id, $taxonomies); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | // Spin up metaboxes |
157 | - if ( !empty( $metaboxes ) ){ |
|
158 | - foreach ( $metaboxes as $cmb ) : |
|
159 | - $return .= $this->metaboxes->random_metabox_content( $post_id, $cmb, $this->connected ); |
|
157 | + if (!empty($metaboxes)) { |
|
158 | + foreach ($metaboxes as $cmb) : |
|
159 | + $return .= $this->metaboxes->random_metabox_content($post_id, $cmb, $this->connected); |
|
160 | 160 | endforeach; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Check if we have errors and return them or created message |
164 | - if ( is_wp_error( $post_id ) ){ |
|
165 | - error_log( $post_id->get_error_message() ); |
|
164 | + if (is_wp_error($post_id)) { |
|
165 | + error_log($post_id->get_error_message()); |
|
166 | 166 | return $post_id; |
167 | 167 | } else { |
168 | 168 | return array( |
169 | 169 | 'action' => 'created', |
170 | 170 | 'object' => 'post', |
171 | 171 | 'oid' => $post_id, |
172 | - 'type' => get_post_type( $post_id ), |
|
173 | - 'link_edit' => admin_url( '/post.php?post='.$post_id.'&action=edit' ), |
|
174 | - 'link_view' => get_permalink( $post_id ), |
|
172 | + 'type' => get_post_type($post_id), |
|
173 | + 'link_edit' => admin_url('/post.php?post='.$post_id.'&action=edit'), |
|
174 | + 'link_view' => get_permalink($post_id), |
|
175 | 175 | ); |
176 | 176 | } |
177 | 177 | |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | * @param string $slug a custom post type ID. |
189 | 189 | * @return array Array of necessary supports booleans. |
190 | 190 | */ |
191 | - private function get_cpt_supports( $slug ){ |
|
191 | + private function get_cpt_supports($slug) { |
|
192 | 192 | |
193 | 193 | $supports = array( |
194 | - 'title' => post_type_supports( $slug, 'title' ), |
|
195 | - 'editor' => post_type_supports( $slug, 'editor' ), |
|
196 | - 'excerpt' => post_type_supports( $slug, 'excerpt' ), |
|
197 | - 'thumbnail' => post_type_supports( $slug, 'thumbnail' ) |
|
194 | + 'title' => post_type_supports($slug, 'title'), |
|
195 | + 'editor' => post_type_supports($slug, 'editor'), |
|
196 | + 'excerpt' => post_type_supports($slug, 'excerpt'), |
|
197 | + 'thumbnail' => post_type_supports($slug, 'thumbnail') |
|
198 | 198 | ); |
199 | 199 | |
200 | 200 | return $supports; |
@@ -215,26 +215,26 @@ discard block |
||
215 | 215 | * @param array $taxonomies taxonomies assigned to this cpt. |
216 | 216 | * @return object WP Error if there is one. |
217 | 217 | */ |
218 | - private function assign_terms( $post_id, $taxonomies ){ |
|
218 | + private function assign_terms($post_id, $taxonomies) { |
|
219 | 219 | |
220 | 220 | // Make sure it's an array & has items |
221 | - if ( empty( $taxonomies ) || !is_array( $taxonomies ) ){ |
|
221 | + if (empty($taxonomies) || !is_array($taxonomies)) { |
|
222 | 222 | return; |
223 | 223 | } |
224 | 224 | |
225 | - foreach ( $taxonomies as $tax ){ |
|
225 | + foreach ($taxonomies as $tax) { |
|
226 | 226 | |
227 | 227 | // Get the individual terms already existing |
228 | - $terms = get_terms( $tax, array( 'hide_empty' => false ) ); |
|
229 | - $count = count( $terms ) - 1; |
|
228 | + $terms = get_terms($tax, array('hide_empty' => false)); |
|
229 | + $count = count($terms) - 1; |
|
230 | 230 | |
231 | 231 | // If there are no terms, skip to the next taxonomy |
232 | - if ( empty( $terms ) ){ |
|
232 | + if (empty($terms)) { |
|
233 | 233 | continue; |
234 | 234 | } |
235 | 235 | |
236 | 236 | // Get a random index to use |
237 | - $index = rand( 0, $count ); |
|
237 | + $index = rand(0, $count); |
|
238 | 238 | |
239 | 239 | // Initialize our array |
240 | 240 | $post_data = array( |
@@ -242,14 +242,14 @@ discard block |
||
242 | 242 | ); |
243 | 243 | |
244 | 244 | // Set the term data to update |
245 | - $post_data['tax_input'][ $tax ] = array( $terms[$index]->term_id ); |
|
245 | + $post_data['tax_input'][$tax] = array($terms[$index]->term_id); |
|
246 | 246 | |
247 | 247 | // Update the post with the taxonomy info |
248 | - $return = wp_update_post( $post_data ); |
|
248 | + $return = wp_update_post($post_data); |
|
249 | 249 | |
250 | 250 | // Return the error if it exists |
251 | - if ( is_wp_error( $return ) ){ |
|
252 | - error_log( $return->get_error_messages() ); |
|
251 | + if (is_wp_error($return)) { |
|
252 | + error_log($return->get_error_messages()); |
|
253 | 253 | return $return->get_error_messages(); |
254 | 254 | } |
255 | 255 | |
@@ -263,20 +263,20 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @see Delete |
265 | 265 | */ |
266 | - public function delete_all(){ |
|
266 | + public function delete_all() { |
|
267 | 267 | |
268 | - $delete = new Delete; |
|
268 | + $delete = new Delete; |
|
269 | 269 | |
270 | 270 | // Make sure that the current user is logged in & has full permissions. |
271 | - if ( ! $delete->user_can_delete() ){ |
|
271 | + if (!$delete->user_can_delete()) { |
|
272 | 272 | return; |
273 | 273 | } |
274 | 274 | |
275 | 275 | // Loop through all post types and remove any test data |
276 | - $post_types = get_post_types( array( 'public' => true ), 'objects' ); |
|
277 | - foreach ( $post_types as $post_type ) : |
|
276 | + $post_types = get_post_types(array('public' => true), 'objects'); |
|
277 | + foreach ($post_types as $post_type) : |
|
278 | 278 | |
279 | - return $this->delete( $post_type->name ); |
|
279 | + return $this->delete($post_type->name); |
|
280 | 280 | |
281 | 281 | endforeach; |
282 | 282 | |
@@ -294,17 +294,17 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @param string $slug a custom post type ID. |
296 | 296 | */ |
297 | - public function delete( $slug ){ |
|
297 | + public function delete($slug) { |
|
298 | 298 | |
299 | - $delete = new Delete; |
|
299 | + $delete = new Delete; |
|
300 | 300 | |
301 | 301 | // Make sure that the current user is logged in & has full permissions. |
302 | - if ( ! $delete->user_can_delete() ){ |
|
302 | + if (!$delete->user_can_delete()) { |
|
303 | 303 | return; |
304 | 304 | } |
305 | 305 | |
306 | 306 | // Check that $cptslg has a string. |
307 | - if ( empty( $slug ) ){ |
|
307 | + if (empty($slug)) { |
|
308 | 308 | return; |
309 | 309 | } |
310 | 310 | |
@@ -321,34 +321,34 @@ discard block |
||
321 | 321 | ), |
322 | 322 | ); |
323 | 323 | |
324 | - $objects = new \WP_Query( $query ); |
|
324 | + $objects = new \WP_Query($query); |
|
325 | 325 | |
326 | - if ( $objects->have_posts() ){ |
|
326 | + if ($objects->have_posts()) { |
|
327 | 327 | |
328 | 328 | $events = array(); |
329 | 329 | |
330 | - while ( $objects->have_posts() ) : $objects->the_post(); |
|
330 | + while ($objects->have_posts()) : $objects->the_post(); |
|
331 | 331 | |
332 | 332 | // Find any media associated with the test post and delete it as well |
333 | - $this->delete_associated_media( get_the_id() ); |
|
333 | + $this->delete_associated_media(get_the_id()); |
|
334 | 334 | |
335 | 335 | $events[] = array( |
336 | 336 | 'action' => 'deleted', |
337 | 337 | 'oid' => get_the_id(), |
338 | - 'type' => get_post_type( get_the_id() ), |
|
338 | + 'type' => get_post_type(get_the_id()), |
|
339 | 339 | 'link' => '' |
340 | 340 | ); |
341 | 341 | |
342 | 342 | // Force delete the post |
343 | - wp_delete_post( get_the_id(), true ); |
|
343 | + wp_delete_post(get_the_id(), true); |
|
344 | 344 | |
345 | 345 | endwhile; |
346 | 346 | |
347 | - $obj = get_post_type_object( $slug ); |
|
347 | + $obj = get_post_type_object($slug); |
|
348 | 348 | |
349 | 349 | $events[] = array( |
350 | 350 | 'action' => 'general', |
351 | - 'message' => __( 'Deleted', 'otm-test-content' ) . ' ' . $obj->labels->all_items |
|
351 | + 'message' => __('Deleted', 'otm-test-content').' '.$obj->labels->all_items |
|
352 | 352 | ); |
353 | 353 | |
354 | 354 | return $events; |
@@ -371,28 +371,28 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @param int $pid a custom post type ID. |
373 | 373 | */ |
374 | - private function delete_associated_media( $pid ){ |
|
374 | + private function delete_associated_media($pid) { |
|
375 | 375 | |
376 | - $delete = new Delete; |
|
376 | + $delete = new Delete; |
|
377 | 377 | |
378 | 378 | // Make sure that the current user is logged in & has full permissions. |
379 | - if ( !$delete->user_can_delete() ){ |
|
379 | + if (!$delete->user_can_delete()) { |
|
380 | 380 | return; |
381 | 381 | } |
382 | 382 | |
383 | 383 | // Make sure $pid is, in fact, an ID |
384 | - if ( !is_int( $pid ) ){ |
|
384 | + if (!is_int($pid)) { |
|
385 | 385 | return; |
386 | 386 | } |
387 | 387 | |
388 | 388 | // Get our images |
389 | - $media = get_attached_media( 'image', $pid ); |
|
389 | + $media = get_attached_media('image', $pid); |
|
390 | 390 | |
391 | - if ( !empty( $media ) ){ |
|
391 | + if (!empty($media)) { |
|
392 | 392 | |
393 | 393 | // Loop through the media & delete each one |
394 | - foreach ( $media as $attachment ){ |
|
395 | - wp_delete_attachment( $attachment->ID, true ); |
|
394 | + foreach ($media as $attachment) { |
|
395 | + wp_delete_attachment($attachment->ID, true); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | } |