| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Retrieves a URL of a file under the Flamingo plugin directory. |
| 5 |
*/ |
| 6 |
function flamingo_plugin_url( $path = '' ) { |
| 7 |
$url = plugins_url( $path, FLAMINGO_PLUGIN ); |
| 8 |
|
| 9 |
if ( is_ssl() and 'http:' === substr( $url, 0, 5 ) ) { |
| 10 |
$url = 'https:' . substr( $url, 5 ); |
| 11 |
} |
| 12 |
|
| 13 |
return $url; |
| 14 |
} |
| 15 |
|
| 16 |
|
| 17 |
/** |
| 18 |
* Converts a multidimensional array to a flat array. |
| 19 |
*/ |
| 20 |
function flamingo_array_flatten( $input ) { |
| 21 |
if ( ! is_array( $input ) ) { |
| 22 |
return array( $input ); |
| 23 |
} |
| 24 |
|
| 25 |
$output = array(); |
| 26 |
|
| 27 |
foreach ( $input as $value ) { |
| 28 |
$output = array_merge( $output, flamingo_array_flatten( $value ) ); |
| 29 |
} |
| 30 |
|
| 31 |
return $output; |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
/** |
| 36 |
* Moves a spam to the Trash. |
| 37 |
* |
| 38 |
* @since 2.1 |
| 39 |
*/ |
| 40 |
function flamingo_schedule_move_trash() { |
| 41 |
|
| 42 |
// abort if FLAMINGO_MOVE_TRASH_DAYS is set to zero or in minus |
| 43 |
if ( (int) FLAMINGO_MOVE_TRASH_DAYS <= 0 ) { |
| 44 |
return true; |
| 45 |
} |
| 46 |
|
| 47 |
$posts_to_move = Flamingo_Inbound_Message::find( array( |
| 48 |
'posts_per_page' => 20, |
| 49 |
'meta_key' => '_spam_meta_time', |
| 50 |
'meta_value' => time() - ( DAY_IN_SECONDS * FLAMINGO_MOVE_TRASH_DAYS ), |
| 51 |
'meta_compare' => '<', |
| 52 |
'orderby' => 'meta_value_num', |
| 53 |
'order' => 'ASC', |
| 54 |
'post_status' => Flamingo_Inbound_Message::spam_status, |
| 55 |
) ); |
| 56 |
|
| 57 |
foreach ( $posts_to_move as $post ) { |
| 58 |
$post->trash(); |
| 59 |
} |
| 60 |
} |
| 61 |
|