PluginProbe
Flamingo / trunk
Flamingo vtrunk
2.6.4 2.6.3 2.6.2 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1 1.1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.1.1 2.2 All 33 releases
flamingo / includes / functions.php

functions.php in Flamingo trunk, at includes/functions.php

61 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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