| 1 |
<?php |
| 2 |
/* |
| 3 |
* Plugin Name: Flamingo |
| 4 |
* Plugin URI: https://contactform7.com/save-submitted-messages-with-flamingo/ |
| 5 |
* Description: A trustworthy message storage plugin for Contact Form 7. |
| 6 |
* Author: Rock Lobster Inc. |
| 7 |
* Author URI: https://github.com/rocklobster-in/ |
| 8 |
* License: GPL v2 or later |
| 9 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 10 |
* Version: 2.6.4 |
| 11 |
* Requires at least: 6.7 |
| 12 |
* Requires PHP: 7.4 |
| 13 |
*/ |
| 14 |
|
| 15 |
define( 'FLAMINGO_VERSION', '2.6.4' ); |
| 16 |
|
| 17 |
define( 'FLAMINGO_PLUGIN', __FILE__ ); |
| 18 |
|
| 19 |
define( 'FLAMINGO_PLUGIN_BASENAME', |
| 20 |
plugin_basename( FLAMINGO_PLUGIN ) |
| 21 |
); |
| 22 |
|
| 23 |
define( 'FLAMINGO_PLUGIN_NAME', |
| 24 |
trim( dirname( FLAMINGO_PLUGIN_BASENAME ), '/' ) |
| 25 |
); |
| 26 |
|
| 27 |
define( 'FLAMINGO_PLUGIN_DIR', |
| 28 |
untrailingslashit( dirname( FLAMINGO_PLUGIN ) ) |
| 29 |
); |
| 30 |
|
| 31 |
if ( ! defined( 'FLAMINGO_MOVE_TRASH_DAYS' ) ) { |
| 32 |
define( 'FLAMINGO_MOVE_TRASH_DAYS', 30 ); |
| 33 |
} |
| 34 |
|
| 35 |
// Deprecated, not used in the plugin core. Use flamingo_plugin_url() instead. |
| 36 |
define( 'FLAMINGO_PLUGIN_URL', |
| 37 |
untrailingslashit( plugins_url( '', FLAMINGO_PLUGIN ) ) |
| 38 |
); |
| 39 |
|
| 40 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/functions.php'; |
| 41 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/formatting.php'; |
| 42 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/csv.php'; |
| 43 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/capabilities.php'; |
| 44 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/class-contact.php'; |
| 45 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/class-inbound-message.php'; |
| 46 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/user.php'; |
| 47 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/comment.php'; |
| 48 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/akismet.php'; |
| 49 |
require_once FLAMINGO_PLUGIN_DIR . '/includes/cron.php'; |
| 50 |
|
| 51 |
if ( is_admin() ) { |
| 52 |
require_once FLAMINGO_PLUGIN_DIR . '/admin/admin.php'; |
| 53 |
} |
| 54 |
|
| 55 |
/* Init */ |
| 56 |
|
| 57 |
add_action( 'init', static function () { |
| 58 |
/* Custom Post Types */ |
| 59 |
Flamingo_Contact::register_post_type(); |
| 60 |
Flamingo_Inbound_Message::register_post_type(); |
| 61 |
|
| 62 |
add_filter( |
| 63 |
'wp_untrash_post_status', |
| 64 |
'flamingo_untrash_post_status', |
| 65 |
10, 3 |
| 66 |
); |
| 67 |
|
| 68 |
do_action( 'flamingo_init' ); |
| 69 |
}, 10, 0 ); |
| 70 |
|
| 71 |
|
| 72 |
function flamingo_untrash_post_status( $new_status, $post_id, $prev_status ) { |
| 73 |
$flamingo_post_types = array( |
| 74 |
Flamingo_Contact::post_type, |
| 75 |
Flamingo_Inbound_Message::post_type, |
| 76 |
); |
| 77 |
|
| 78 |
if ( in_array( get_post_type( $post_id ), $flamingo_post_types, true ) ) { |
| 79 |
return $prev_status; |
| 80 |
} |
| 81 |
|
| 82 |
return $new_status; |
| 83 |
} |
| 84 |
|