Changed source root directory

This commit is contained in:
2026-03-05 16:30:11 +01:00
parent dc85447ee1
commit 538f85d7a2
5868 changed files with 749734 additions and 99 deletions

View File

@@ -0,0 +1,791 @@
<?php
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/admin-functions.php';
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/privacy.php';
add_action( 'admin_menu', 'flamingo_admin_menu', 8, 0 );
function flamingo_admin_menu() {
add_menu_page(
__( 'Flamingo Address Book', 'flamingo' ),
__( 'Flamingo', 'flamingo' ),
'flamingo_edit_contacts',
'flamingo',
'flamingo_contact_admin_page',
'dashicons-feedback',
28
);
$contact_admin = add_submenu_page(
'flamingo',
__( 'Flamingo Address Book', 'flamingo' ),
__( 'Address Book', 'flamingo' ),
'flamingo_edit_contacts',
'flamingo',
'flamingo_contact_admin_page'
);
add_action(
'load-' . $contact_admin,
'flamingo_load_contact_admin',
10, 0
);
$inbound_admin = add_submenu_page(
'flamingo',
__( 'Flamingo Inbound Messages', 'flamingo' ),
__( 'Inbound Messages', 'flamingo' ),
'flamingo_edit_inbound_messages',
'flamingo_inbound',
'flamingo_inbound_admin_page'
);
add_action(
'load-' . $inbound_admin,
'flamingo_load_inbound_admin',
10, 0
);
}
add_filter( 'set_screen_option_flamingo_contacts_per_page',
'flamingo_set_screen_options', 10, 3
);
add_filter( 'set_screen_option_flamingo_inbound_messages_per_page',
'flamingo_set_screen_options', 10, 3
);
function flamingo_set_screen_options( $result, $option, $value ) {
$flamingo_screens = array(
'flamingo_contacts_per_page',
'flamingo_inbound_messages_per_page',
);
if ( in_array( $option, $flamingo_screens ) ) {
$result = $value;
}
return $result;
}
add_action( 'admin_enqueue_scripts', 'flamingo_admin_enqueue_scripts', 10, 1 );
function flamingo_admin_enqueue_scripts( $hook_suffix ) {
if ( false === strpos( $hook_suffix, 'flamingo' ) ) {
return;
}
wp_enqueue_style( 'flamingo-admin',
flamingo_plugin_url( 'admin/includes/css/style.css' ),
array(), FLAMINGO_VERSION, 'all'
);
if ( is_rtl() ) {
wp_enqueue_style( 'flamingo-admin-rtl',
flamingo_plugin_url( 'admin/includes/css/style-rtl.css' ),
array(), FLAMINGO_VERSION, 'all'
);
}
$assets = include FLAMINGO_PLUGIN_DIR . '/admin/includes/js/index.asset.php';
$assets = wp_parse_args( $assets, array(
'dependencies' => array(),
'version' => FLAMINGO_VERSION,
) );
wp_enqueue_script( 'flamingo-admin',
flamingo_plugin_url( 'admin/includes/js/index.js' ),
$assets['dependencies'],
$assets['version'],
array( 'in_footer' => true )
);
wp_set_script_translations( 'flamingo-admin', 'flamingo' );
$current_screen = get_current_screen();
wp_add_inline_script( 'flamingo-admin',
sprintf(
'var flamingo = %s;',
wp_json_encode( array(
'screenId' => $current_screen->id,
), JSON_PRETTY_PRINT )
),
'before'
);
}
/* Updated Message */
add_action( 'flamingo_admin_updated_message',
'flamingo_admin_updated_message',
10, 0
);
function flamingo_admin_updated_message() {
if ( empty( $_REQUEST['message'] ) ) {
return;
}
if ( 'contactupdated' === $_REQUEST['message'] ) {
$message = __( 'Contact updated.', 'flamingo' );
} elseif ( 'contactdeleted' === $_REQUEST['message'] ) {
$message = __( 'Contact deleted.', 'flamingo' );
} elseif ( 'inboundupdated' === $_REQUEST['message'] ) {
$message = __( 'Messages updated.', 'flamingo' );
} elseif ( 'inboundtrashed' === $_REQUEST['message'] ) {
$message = __( 'Messages trashed.', 'flamingo' );
} elseif ( 'inbounduntrashed' === $_REQUEST['message'] ) {
$message = __( 'Messages restored.', 'flamingo' );
} elseif ( 'inbounddeleted' === $_REQUEST['message'] ) {
$message = __( 'Messages deleted.', 'flamingo' );
} elseif ( 'inboundspammed' === $_REQUEST['message'] ) {
$message = __( 'Messages got marked as spam.', 'flamingo' );
} elseif ( 'inboundunspammed' === $_REQUEST['message'] ) {
$message = __( 'Messages got marked as not spam.', 'flamingo' );
}
if ( ! empty( $message ) ) {
wp_admin_notice( $message, array(
'type' => 'success',
'dismissible' => true,
) );
}
}
/* Contact */
function flamingo_load_contact_admin() {
$action = flamingo_current_action();
$redirect_to = menu_page_url( 'flamingo', false );
if ( 'save' === $action and ! empty( $_REQUEST['post'] ) ) {
$post = new Flamingo_Contact( $_REQUEST['post'] );
if ( ! empty( $post ) ) {
if ( ! current_user_can( 'flamingo_edit_contact', $post->id() ) ) {
wp_die(
wp_kses_data( __( 'You are not allowed to edit this item.', 'flamingo' ) )
);
}
check_admin_referer( 'flamingo-update-contact_' . $post->id() );
$post->props = (array) $_POST['contact'];
$post->name = trim( $_POST['contact']['name'] );
$post->tags = (
! empty( $_POST['tax_input'][Flamingo_Contact::contact_tag_taxonomy] )
? explode(
',', $_POST['tax_input'][Flamingo_Contact::contact_tag_taxonomy]
)
: array()
);
$post->save();
$redirect_to = add_query_arg(
array(
'action' => 'edit',
'post' => $post->id(),
'message' => 'contactupdated',
), $redirect_to
);
}
wp_safe_redirect( $redirect_to );
exit();
}
if ( 'delete' === $action and ! empty( $_REQUEST['post'] ) ) {
if ( ! is_array( $_REQUEST['post'] ) ) {
check_admin_referer( 'flamingo-delete-contact_' . $_REQUEST['post'] );
} else {
check_admin_referer( 'bulk-posts' );
}
$deleted = 0;
foreach ( (array) $_REQUEST['post'] as $post ) {
$post = new Flamingo_Contact( $post );
if ( empty( $post ) ) {
continue;
}
if ( ! current_user_can( 'flamingo_delete_contact', $post->id() ) ) {
wp_die(
wp_kses_data( __( 'You are not allowed to delete this item.', 'flamingo' ) )
);
}
if ( ! $post->delete() ) {
wp_die(
wp_kses_data( __( 'Error in deleting.', 'flamingo' ) )
);
}
$deleted += 1;
}
if ( ! empty( $deleted ) ) {
$redirect_to = add_query_arg(
array( 'message' => 'contactdeleted' ), $redirect_to
);
}
wp_safe_redirect( $redirect_to );
exit();
}
if ( ! empty( $_GET['export'] ) ) {
check_admin_referer( 'bulk-posts' );
$csv_class = apply_filters( 'flamingo_contact_csv_class',
'Flamingo_Contact_CSV'
);
if ( is_subclass_of( $csv_class, 'Flamingo_CSV' ) ) {
$csv_obj = new $csv_class;
$csv_obj->send_http_headers();
$csv_obj->print_data();
}
exit();
}
if ( 'edit' === $action ) {
$post_id = (int) ( $_REQUEST['post'] ?? '0' );
if ( ! $post_id ) {
wp_safe_redirect( $redirect_to );
exit();
}
if (
! current_user_can( 'flamingo_edit_contact', $post_id ) or
Flamingo_Contact::post_type !== get_post_type( $post_id )
) {
wp_die(
wp_kses_data( __( 'You are not allowed to edit this item.', 'flamingo' ) )
);
}
add_meta_box( 'submitdiv', __( 'Save', 'flamingo' ),
'flamingo_contact_submit_meta_box', null, 'side', 'core'
);
add_meta_box( 'contacttagsdiv', __( 'Tags', 'flamingo' ),
'flamingo_contact_tags_meta_box', null, 'side', 'core'
);
add_meta_box( 'contactnamediv', __( 'Name', 'flamingo' ),
'flamingo_contact_name_meta_box', null, 'normal', 'core'
);
} else {
if ( ! class_exists( 'Flamingo_Contacts_List_Table' ) ) {
require_once FLAMINGO_PLUGIN_DIR
. '/admin/includes/class-contacts-list-table.php';
}
$current_screen = get_current_screen();
add_filter( 'manage_' . $current_screen->id . '_columns',
array( 'Flamingo_Contacts_List_Table', 'define_columns' ),
10, 0
);
add_screen_option( 'per_page', array(
'default' => 20,
'option' => 'flamingo_contacts_per_page',
) );
}
}
function flamingo_contact_admin_page() {
if ( 'edit' === flamingo_current_action() ) {
flamingo_contact_edit_page();
return;
}
$list_table = new Flamingo_Contacts_List_Table();
$list_table->prepare_items();
?>
<div class="wrap">
<h1 class="wp-heading-inline"><?php
echo esc_html( __( 'Flamingo Address Book', 'flamingo' ) );
?></h1>
<?php
if ( isset( $_REQUEST['s'] ) and strlen( $_REQUEST['s'] ) ) {
echo sprintf(
'<span class="subtitle">%s</span>',
wp_kses_data( sprintf(
/* translators: %s: Search query. */
__( 'Search results for: <strong>%s</strong>', 'flamingo' ),
esc_html( $_REQUEST['s'] )
) )
);
}
?>
<hr class="wp-header-end">
<?php do_action( 'flamingo_admin_updated_message' ); ?>
<form method="get" action="">
<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
<?php $list_table->search_box( __( 'Search contacts', 'flamingo' ), 'flamingo-contact' ); ?>
<?php $list_table->display(); ?>
</form>
</div>
<?php
}
function flamingo_contact_edit_page() {
$post = new Flamingo_Contact( $_REQUEST['post'] );
if ( empty( $post ) ) {
return;
}
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/meta-boxes.php';
include FLAMINGO_PLUGIN_DIR . '/admin/edit-contact-form.php';
}
/* Inbound Messages */
function flamingo_load_inbound_admin() {
$action = flamingo_current_action();
$redirect_to = menu_page_url( 'flamingo_inbound', false );
if ( isset( $_GET['post_status'] ) ) {
$redirect_to = add_query_arg(
array(
'post_status' => $_GET['post_status'],
),
$redirect_to
);
}
if ( 'save' === $action and ! empty( $_REQUEST['post'] ) ) {
$post = new Flamingo_Inbound_Message( $_REQUEST['post'] );
if ( ! empty( $post ) ) {
if ( ! current_user_can( 'flamingo_edit_inbound_message', $post->id() ) ) {
wp_die(
wp_kses_data( __( 'You are not allowed to edit this item.', 'flamingo' ) )
);
}
check_admin_referer( 'flamingo-update-inbound_' . $post->id() );
$status = $_POST['inbound']['status'] ?? '';
if ( ! $post->spam and 'spam' === $status ) {
$post->spam();
} elseif ( $post->spam and 'ham' === $status ) {
$post->unspam();
}
$redirect_to = add_query_arg(
array(
'action' => 'edit',
'post' => $post->id(),
'message' => 'inboundupdated',
), $redirect_to
);
}
wp_safe_redirect( $redirect_to );
exit();
}
if ( 'trash' === $action and ! empty( $_REQUEST['post'] ) ) {
if ( ! is_array( $_REQUEST['post'] ) ) {
check_admin_referer(
'flamingo-trash-inbound-message_' . $_REQUEST['post']
);
} else {
check_admin_referer( 'bulk-posts' );
}
$trashed = 0;
foreach ( (array) $_REQUEST['post'] as $post ) {
$post = new Flamingo_Inbound_Message( $post );
if ( empty( $post ) ) {
continue;
}
if ( ! current_user_can(
'flamingo_delete_inbound_message', $post->id() ) ) {
wp_die(
wp_kses_data( __( 'You are not allowed to move this item to the Trash.', 'flamingo' ) )
);
}
if ( ! $post->trash() ) {
wp_die(
wp_kses_data( __( 'Error in moving to Trash.', 'flamingo' ) )
);
}
$trashed += 1;
}
if ( ! empty( $trashed ) ) {
$redirect_to = add_query_arg(
array(
'message' => 'inboundtrashed',
),
$redirect_to
);
}
wp_safe_redirect( $redirect_to );
exit();
}
if ( 'untrash' === $action and ! empty( $_REQUEST['post'] ) ) {
if ( ! is_array( $_REQUEST['post'] ) ) {
check_admin_referer(
'flamingo-untrash-inbound-message_' . $_REQUEST['post']
);
} else {
check_admin_referer( 'bulk-posts' );
}
$untrashed = 0;
foreach ( (array) $_REQUEST['post'] as $post ) {
$post = new Flamingo_Inbound_Message( $post );
if ( empty( $post ) ) {
continue;
}
if (
! current_user_can( 'flamingo_delete_inbound_message', $post->id() )
) {
wp_die(
wp_kses_data( __( 'You are not allowed to restore this item from the Trash.', 'flamingo' ) )
);
}
if ( ! $post->untrash() ) {
wp_die(
wp_kses_data( __( 'Error in restoring from Trash.', 'flamingo' ) )
);
}
$untrashed += 1;
}
if ( ! empty( $untrashed ) ) {
$redirect_to = add_query_arg(
array(
'message' => 'inbounduntrashed',
), $redirect_to
);
}
wp_safe_redirect( $redirect_to );
exit();
}
if ( 'delete_all' === $action ) {
check_admin_referer( 'bulk-posts' );
$_REQUEST['post'] = flamingo_get_all_ids_in_trash(
Flamingo_Inbound_Message::post_type
);
$action = 'delete';
}
if ( 'delete' === $action and ! empty( $_REQUEST['post'] ) ) {
if ( ! is_array( $_REQUEST['post'] ) ) {
check_admin_referer(
'flamingo-delete-inbound-message_' . $_REQUEST['post']
);
} else {
check_admin_referer( 'bulk-posts' );
}
$deleted = 0;
foreach ( (array) $_REQUEST['post'] as $post ) {
$post = new Flamingo_Inbound_Message( $post );
if ( empty( $post ) ) {
continue;
}
if (
! current_user_can( 'flamingo_delete_inbound_message', $post->id() )
) {
wp_die(
wp_kses_data( __( 'You are not allowed to delete this item.', 'flamingo' ) )
);
}
if ( ! $post->delete() ) {
wp_die(
wp_kses_data( __( 'Error in deleting.', 'flamingo' ) )
);
}
$deleted += 1;
}
if ( ! empty( $deleted ) ) {
$redirect_to = add_query_arg(
array(
'message' => 'inbounddeleted',
),
$redirect_to
);
}
wp_safe_redirect( $redirect_to );
exit();
}
if ( 'spam' === $action and ! empty( $_REQUEST['post'] ) ) {
if ( ! is_array( $_REQUEST['post'] ) ) {
check_admin_referer(
'flamingo-spam-inbound-message_' . $_REQUEST['post']
);
} else {
check_admin_referer( 'bulk-posts' );
}
$submitted = 0;
foreach ( (array) $_REQUEST['post'] as $post ) {
$post = new Flamingo_Inbound_Message( $post );
if ( empty( $post ) ) {
continue;
}
if (
! current_user_can( 'flamingo_spam_inbound_message', $post->id() )
) {
wp_die(
wp_kses_data( __( 'You are not allowed to spam this item.', 'flamingo' ) )
);
}
if ( $post->spam() ) {
$submitted += 1;
}
}
if ( ! empty( $submitted ) ) {
$redirect_to = add_query_arg(
array(
'message' => 'inboundspammed',
),
$redirect_to
);
}
wp_safe_redirect( $redirect_to );
exit();
}
if ( 'unspam' === $action and ! empty( $_REQUEST['post'] ) ) {
if ( ! is_array( $_REQUEST['post'] ) ) {
check_admin_referer(
'flamingo-unspam-inbound-message_' . $_REQUEST['post']
);
} else {
check_admin_referer( 'bulk-posts' );
}
$submitted = 0;
foreach ( (array) $_REQUEST['post'] as $post ) {
$post = new Flamingo_Inbound_Message( $post );
if ( empty( $post ) ) {
continue;
}
if (
! current_user_can( 'flamingo_unspam_inbound_message', $post->id() )
) {
wp_die(
wp_kses_data( __( 'You are not allowed to unspam this item.', 'flamingo' ) )
);
}
if ( $post->unspam() ) {
$submitted += 1;
}
}
if ( ! empty( $submitted ) ) {
$redirect_to = add_query_arg(
array(
'message' => 'inboundunspammed',
),
$redirect_to
);
}
wp_safe_redirect( $redirect_to );
exit();
}
if ( ! empty( $_GET['export'] ) ) {
check_admin_referer( 'bulk-posts' );
$csv_class = apply_filters( 'flamingo_inbound_csv_class',
'Flamingo_Inbound_CSV'
);
if ( is_subclass_of( $csv_class, 'Flamingo_CSV' ) ) {
$csv_obj = new $csv_class;
$csv_obj->send_http_headers();
$csv_obj->print_data();
}
exit();
}
if ( 'edit' === $action ) {
$post_id = (int) ( $_REQUEST['post'] ?? '0' );
if ( ! $post_id ) {
wp_safe_redirect( $redirect_to );
exit();
}
if (
! current_user_can( 'flamingo_edit_inbound_message', $post_id ) or
Flamingo_Inbound_Message::post_type !== get_post_type( $post_id )
) {
wp_die(
wp_kses_data( __( 'You are not allowed to edit this item.', 'flamingo' ) )
);
}
$post = new Flamingo_Inbound_Message( $post_id );
add_meta_box( 'submitdiv', __( 'Status', 'flamingo' ),
'flamingo_inbound_submit_meta_box', null, 'side', 'core'
);
if ( ! empty( $post->fields ) ) {
add_meta_box( 'inboundfieldsdiv', __( 'Fields', 'flamingo' ),
'flamingo_inbound_fields_meta_box', null, 'normal', 'core'
);
}
if ( ! empty( $post->consent ) ) {
add_meta_box( 'inboundconsentdiv', __( 'Consent', 'flamingo' ),
'flamingo_inbound_consent_meta_box', null, 'normal', 'core'
);
}
if ( ! empty( $post->recaptcha ) ) {
add_meta_box( 'inboundrecaptchadiv', __( 'reCAPTCHA', 'flamingo' ),
'flamingo_inbound_recaptcha_meta_box', null, 'normal', 'core'
);
}
if ( ! empty( $post->meta ) ) {
add_meta_box( 'inboundmetadiv', __( 'Meta', 'flamingo' ),
'flamingo_inbound_meta_meta_box', null, 'normal', 'core'
);
}
} else {
if ( ! class_exists( 'Flamingo_Inbound_Messages_List_Table' ) ) {
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/class-inbound-messages-list-table.php';
}
$current_screen = get_current_screen();
add_filter( 'manage_' . $current_screen->id . '_columns',
array( 'Flamingo_Inbound_Messages_List_Table', 'define_columns' ),
10, 0
);
add_screen_option( 'per_page', array(
'default' => 20,
'option' => 'flamingo_inbound_messages_per_page',
) );
}
}
function flamingo_inbound_admin_page() {
if ( 'edit' === flamingo_current_action() ) {
flamingo_inbound_edit_page();
return;
}
$list_table = new Flamingo_Inbound_Messages_List_Table();
$list_table->prepare_items();
?>
<div class="wrap">
<h1 class="wp-heading-inline"><?php
echo esc_html( __( 'Inbound Messages', 'flamingo' ) );
?></h1>
<?php
if ( isset( $_REQUEST['s'] ) and strlen( $_REQUEST['s'] ) ) {
echo sprintf(
'<span class="subtitle">%s</span>',
wp_kses_data( sprintf(
/* translators: %s: Search query. */
__( 'Search results for: <strong>%s</strong>', 'flamingo' ),
esc_html( $_REQUEST['s'] )
) )
);
}
?>
<hr class="wp-header-end">
<?php do_action( 'flamingo_admin_updated_message' ); ?>
<?php $list_table->views(); ?>
<form method="get" action="">
<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
<input type="hidden" name="post_status" value="<?php echo isset( $_REQUEST['post_status'] ) ? esc_attr( $_REQUEST['post_status'] ) : ''; ?>" />
<?php $list_table->search_box( __( 'Search messages', 'flamingo' ), 'flamingo-inbound' ); ?>
<?php $list_table->display(); ?>
</form>
</div>
<?php
}
function flamingo_inbound_edit_page() {
$post = new Flamingo_Inbound_Message( $_REQUEST['post'] );
if ( empty( $post ) ) {
return;
}
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/meta-boxes.php';
include FLAMINGO_PLUGIN_DIR . '/admin/edit-inbound-form.php';
}

View File

@@ -0,0 +1,70 @@
<?php
// don't load directly
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
if ( ! empty( $post->id() ) ) {
$nonce_action = 'flamingo-update-contact_' . $post->id();
} else {
$nonce_action = 'flamingo-add-contact';
}
?>
<div class="wrap">
<h1><?php echo esc_html( __( 'Edit Contact', 'flamingo' ) ); ?></h1>
<?php do_action( 'flamingo_admin_updated_message', $post ); ?>
<form name="editcontact" id="editcontact" method="post" action="<?php echo esc_url( add_query_arg( array( 'post' => $post->id() ), menu_page_url( 'flamingo', false ) ) ); ?>">
<?php
wp_nonce_field( $nonce_action );
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
?>
<div id="poststuff">
<div id="post-body" class="metabox-holder columns-2">
<div id="post-body-content">
<div id="titlediv">
<div id="titlewrap">
<?php if ( ! empty( $post->id() ) ) : ?>
<input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr( $post->email ); ?>" id="title" disabled="disabled" />
<?php else : ?>
<label class="hide-if-no-js" style="visibility:hidden" id="title-prompt-text" for="title"><?php echo esc_html( __( 'Enter email here', 'flamingo' ) ); ?></label>
<input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr( $post->email ); ?>" id="title" autocomplete="off" />
<?php endif; ?>
</div>
</div>
</div><!-- #post-body-content -->
<div id="postbox-container-1" class="postbox-container">
<?php
do_meta_boxes( null, 'side', $post );
?>
</div><!-- #postbox-container-1 -->
<div id="postbox-container-2" class="postbox-container">
<?php
do_meta_boxes( null, 'normal', $post );
do_meta_boxes( null, 'advanced', $post );
?>
</div><!-- #postbox-container-2 -->
</div><!-- #post-body -->
<br class="clear" />
</div><!-- #poststuff -->
<?php if ( $post->id() ) : ?>
<input type="hidden" name="action" value="save" />
<input type="hidden" name="post" value="<?php echo (int) $post->id(); ?>" />
<?php else: ?>
<input type="hidden" name="action" value="add" />
<?php endif; ?>
</form>
</div><!-- .wrap -->

View File

@@ -0,0 +1,82 @@
<?php
// don't load directly
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
if ( ! empty( $post->id() ) ) {
$nonce_action = 'flamingo-update-inbound_' . $post->id();
} else {
$nonce_action = 'flamingo-add-inbound';
}
?>
<div class="wrap">
<h1><?php echo esc_html( __( 'Inbound Message', 'flamingo' ) ); ?></h1>
<?php do_action( 'flamingo_admin_updated_message', $post ); ?>
<form name="editinbound" id="editinbound" method="post" action="<?php echo esc_url( add_query_arg( array( 'post' => $post->id() ), menu_page_url( 'flamingo_inbound', false ) ) ); ?>">
<?php
wp_nonce_field( $nonce_action );
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
?>
<div id="poststuff">
<div id="post-body" class="metabox-holder columns-2">
<div id="post-body-content">
<table class="message-main-fields">
<tbody>
<tr class="message-subject">
<th><?php echo esc_html( __( 'Subject', 'flamingo' ) ); ?>:</th>
<td><?php echo esc_html( $post->subject ); ?></td>
</tr>
<tr class="message-from">
<th><?php echo esc_html( __( 'From', 'flamingo' ) ); ?>:</th>
<td><?php if ( ! empty( $post->from_email ) ) { ?><a href="<?php
echo esc_url( add_query_arg(
array(
's' => $post->from_email,
),
menu_page_url( 'flamingo', false )
) );
?>" aria-label="<?php echo esc_attr( $post->from ); ?>"><?php echo esc_html( $post->from ); ?></a><?php } else { echo esc_html( $post->from ); } ?></td>
</tr>
</tbody>
</table>
</div><!-- #post-body-content -->
<div id="postbox-container-1" class="postbox-container">
<?php
do_meta_boxes( null, 'side', $post );
?>
</div><!-- #postbox-container-1 -->
<div id="postbox-container-2" class="postbox-container">
<?php
do_meta_boxes( null, 'normal', $post );
do_meta_boxes( null, 'advanced', $post );
?>
</div><!-- #postbox-container-2 -->
</div><!-- #post-body -->
<br class="clear" />
</div><!-- #poststuff -->
<?php if ( $post->id() ) : ?>
<input type="hidden" name="action" value="save" />
<input type="hidden" name="post" value="<?php echo (int) $post->id(); ?>" />
<?php else: ?>
<input type="hidden" name="action" value="add" />
<?php endif; ?>
</form>
</div><!-- .wrap -->

View File

@@ -0,0 +1,27 @@
<?php
function flamingo_current_action() {
if ( isset( $_REQUEST['delete_all'] ) or isset( $_REQUEST['delete_all2'] ) ) {
return 'delete_all';
}
if ( isset( $_REQUEST['action'] ) and -1 !== $_REQUEST['action'] ) {
return $_REQUEST['action'];
}
if ( isset( $_REQUEST['action2'] ) and -1 !== $_REQUEST['action2'] ) {
return $_REQUEST['action2'];
}
return false;
}
function flamingo_get_all_ids_in_trash( $post_type ) {
global $wpdb;
return $wpdb->get_col( $wpdb->prepare(
"SELECT ID FROM %i WHERE post_status = 'trash' AND post_type = %s",
$wpdb->posts,
$post_type
) );
}

View File

@@ -0,0 +1,356 @@
<?php
if ( ! class_exists( 'WP_List_Table' ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
class Flamingo_Contacts_List_Table extends WP_List_Table {
public static function define_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'email' => __( 'Email', 'flamingo' ),
'full_name' => __( 'Name', 'flamingo' ),
'tags' => __( 'Tags', 'flamingo' ),
'history' => __( 'History', 'flamingo' ),
'last_contacted' => __( 'Last contact', 'flamingo' ),
);
$columns = apply_filters(
'manage_flamingo_contact_posts_columns', $columns
);
return $columns;
}
public function __construct() {
parent::__construct( array(
'singular' => 'post',
'plural' => 'posts',
'ajax' => false,
) );
}
public function prepare_items() {
$per_page = $this->get_items_per_page(
'flamingo_contacts_per_page'
);
$args = array(
'posts_per_page' => $per_page,
'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
'orderby' => 'meta_value',
'order' => 'DESC',
'meta_key' => '_last_contacted',
);
if ( ! empty( $_REQUEST['s'] ) ) {
$args['s'] = $_REQUEST['s'];
}
if ( ! empty( $_REQUEST['orderby'] ) ) {
if ( 'email' === $_REQUEST['orderby'] ) {
$args['meta_key'] = '_email';
} elseif ( 'name' === $_REQUEST['orderby'] ) {
$args['meta_key'] = '_name';
}
}
if (
! empty( $_REQUEST['order'] ) and
'asc' === strtolower( $_REQUEST['order'] )
) {
$args['order'] = 'ASC';
}
if ( ! empty( $_REQUEST['contact_tag_id'] ) ) {
$args['contact_tag_id'] = explode( ',', $_REQUEST['contact_tag_id'] );
}
$this->items = Flamingo_Contact::find( $args );
$total_items = Flamingo_Contact::count();
$total_pages = ceil( $total_items / $per_page );
$this->set_pagination_args( array(
'total_items' => $total_items,
'total_pages' => $total_pages,
'per_page' => $per_page,
) );
}
public function get_columns() {
return get_column_headers( get_current_screen() );
}
protected function get_sortable_columns() {
$columns = array(
'email' => array( 'email', false ),
'full_name' => array( 'name', false ),
'last_contacted' => array( 'last_contacted', true ),
);
return $columns;
}
protected function get_bulk_actions() {
$actions = array(
'delete' => __( 'Delete', 'flamingo' ),
);
return $actions;
}
protected function extra_tablenav( $which ) {
$tag = 0;
if ( ! empty( $_REQUEST['contact_tag_id'] ) ) {
$tag_id = explode( ',', $_REQUEST['contact_tag_id'] );
$term = get_term( $tag_id[0], Flamingo_Contact::contact_tag_taxonomy );
if ( ! empty( $term ) and ! is_wp_error( $term ) ) {
$tag = $term->term_id;
}
}
?>
<div class="alignleft actions">
<?php
if ( 'top' == $which ) {
$filters = array();
$filters[] = wp_dropdown_categories( array(
'taxonomy' => Flamingo_Contact::contact_tag_taxonomy,
'name' => 'contact_tag_id',
'show_option_all' => __( 'View all tags', 'flamingo' ),
'hide_empty' => 1,
'hide_if_empty' => 1,
'orderby' => 'name',
'selected' => $tag,
) );
if ( array_filter( $filters ) ) {
submit_button( __( 'Filter', 'flamingo' ),
'secondary', false, false, array( 'id' => 'post-query-submit' )
);
}
submit_button( __( 'Export', 'flamingo' ), 'secondary', 'export', false );
}
?>
</div>
<?php
}
protected function column_default( $item, $column_name ) {
do_action( 'manage_flamingo_contact_posts_custom_column',
$column_name, $item->id()
);
}
protected function column_cb( $item ) {
return sprintf(
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
$this->_args['singular'],
$item->id()
);
}
protected function column_email( $item ) {
$edit_link = add_query_arg( array(
'post' => $item->id(),
'action' => 'edit',
), menu_page_url( 'flamingo', false ) );
if ( current_user_can( 'flamingo_edit_contact', $item->id() ) ) {
return sprintf(
'<strong><a class="row-title" href="%1$s" aria-label="%2$s">%3$s</a></strong>',
esc_url( $edit_link ),
esc_attr( sprintf(
/* translators: %s: Item title. */
__( '&#8220;%s&#8221; (Edit)', 'flamingo' ),
$item->email
) ),
esc_html( $item->email )
);
} else {
return sprintf(
'<strong>%1$s</strong>',
esc_html( $item->email )
);
}
}
protected function handle_row_actions( $item, $column_name, $primary ) {
if ( $column_name !== $primary ) {
return '';
}
$actions = array();
$link = add_query_arg( array(
'post' => $item->id(),
'action' => 'edit',
), menu_page_url( 'flamingo', false ) );
if ( current_user_can( 'flamingo_edit_contact', $item->id() ) ) {
$actions['edit'] = sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( $link ),
esc_html( __( 'Edit', 'flamingo' ) )
);
}
return $this->row_actions( $actions );
}
protected function column_full_name( $item ) {
return esc_html( $item->name );
}
protected function column_tags( $item ) {
if ( empty( $item->tags ) ) {
return esc_html( __( 'No tags', 'flamingo' ) );
}
$output = '';
foreach ( (array) $item->tags as $tag ) {
$term = get_term_by( 'name', $tag,
Flamingo_Contact::contact_tag_taxonomy
);
if ( empty( $term ) or is_wp_error( $term ) ) {
continue;
}
if ( $output ) {
$output .= ', ';
}
$link = add_query_arg( array(
'contact_tag_id' => $term->term_id,
), menu_page_url( 'flamingo', false ) );
$output .= sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>',
esc_url( $link ),
esc_attr( $term->name ),
esc_html( $term->name )
);
}
return $output;
}
protected function column_history( $item ) {
$history = array();
// User
if ( $user = get_user_by( 'email', $item->email ) ) {
$link = sprintf( 'user-edit.php?user_id=%d', $user->ID );
$history[] = sprintf(
'<a href="%2$s">%1$s</a>',
esc_html( __( 'User', 'flamingo' ) ),
admin_url( $link )
);
}
// Comment
$comment_count = (int) get_comments( array(
'count' => true,
'author_email' => $item->email,
'status' => 'approve',
'type' => 'comment',
) );
if ( 0 < $comment_count ) {
$link = sprintf( 'edit-comments.php?s=%s', urlencode( $item->email ) );
$history[] = sprintf(
'<a href="%2$s">%1$s</a>',
esc_html( sprintf(
/* translators: %d: Number of comments. */
__( 'Comment (%d)', 'flamingo' ),
$comment_count
) ),
admin_url( $link )
);
}
// Contact channels
$terms = get_terms( array(
'taxonomy' => Flamingo_Inbound_Message::channel_taxonomy,
) );
if ( ! empty( $terms ) and ! is_wp_error( $terms ) ) {
foreach ( (array) $terms as $term ) {
Flamingo_Inbound_Message::find( array(
'channel' => $term->slug,
's' => $item->email,
) );
$count = (int) Flamingo_Inbound_Message::count();
if ( ! $count ) {
continue;
}
$link = add_query_arg( array(
'channel' => $term->slug,
's' => $item->email,
), menu_page_url( 'flamingo_inbound', false ) );
$history[] = sprintf(
'<a href="%2$s">%1$s</a>',
esc_html( sprintf(
/* translators: 1: contact channel name, 2: contact count */
_x( '%1$s (%2$d)', 'contact history', 'flamingo' ),
$term->name,
$count
) ),
esc_url( $link )
);
}
}
$output = '';
foreach ( $history as $item ) {
$output .= sprintf( '<li>%s</li>', $item );
}
return sprintf( '<ul class="contact-history">%s</ul>', $output );
}
protected function column_last_contacted( $item ) {
if (
empty( $item->last_contacted ) or
'0000-00-00 00:00:00' === $item->last_contacted
) {
return '';
}
$datetime = date_create_immutable_from_format(
'Y-m-d H:i:s',
$item->last_contacted,
wp_timezone()
);
if ( false === $datetime ) {
return '';
}
$t_time = sprintf(
/* translators: 1: date, 2: time */
__( '%1$s at %2$s', 'flamingo' ),
/* translators: date format, see https://www.php.net/date */
$datetime->format( __( 'Y/m/d', 'flamingo' ) ),
/* translators: time format, see https://www.php.net/date */
$datetime->format( __( 'g:i a', 'flamingo' ) )
);
return $t_time;
}
}

View File

@@ -0,0 +1,455 @@
<?php
if ( ! class_exists( 'WP_List_Table' ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
class Flamingo_Inbound_Messages_List_Table extends WP_List_Table {
private $is_trash = false;
private $is_spam = false;
public static function define_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'subject' => __( 'Subject', 'flamingo' ),
'from' => __( 'From', 'flamingo' ),
'channel' => __( 'Channel', 'flamingo' ),
'date' => __( 'Date', 'flamingo' ),
);
$columns = apply_filters(
'manage_flamingo_inbound_posts_columns', $columns
);
return $columns;
}
public function __construct() {
parent::__construct( array(
'singular' => 'post',
'plural' => 'posts',
'ajax' => false,
) );
}
public function prepare_items() {
$per_page = $this->get_items_per_page(
'flamingo_inbound_messages_per_page'
);
$args = array(
'posts_per_page' => $per_page,
'offset' => ( $this->get_pagenum() - 1 ) * $per_page,
'orderby' => 'date',
'order' => 'DESC',
);
if ( ! empty( $_REQUEST['s'] ) ) {
$args['s'] = $_REQUEST['s'];
}
if ( ! empty( $_REQUEST['orderby'] ) ) {
if ( 'subject' === $_REQUEST['orderby'] ) {
$args['meta_key'] = '_subject';
$args['orderby'] = 'meta_value';
} elseif ( 'from' === $_REQUEST['orderby'] ) {
$args['meta_key'] = '_from';
$args['orderby'] = 'meta_value';
}
}
if (
! empty( $_REQUEST['order'] ) and
'asc' === strtolower( $_REQUEST['order'] )
) {
$args['order'] = 'ASC';
}
if ( ! empty( $_REQUEST['m'] ) ) {
$args['m'] = $_REQUEST['m'];
}
if ( ! empty( $_REQUEST['channel_id'] ) ) {
$args['channel_id'] = $_REQUEST['channel_id'];
}
if ( ! empty( $_REQUEST['channel'] ) ) {
$args['channel'] = $_REQUEST['channel'];
}
if ( ! empty( $_REQUEST['post_status'] ) ) {
if ( 'trash' === $_REQUEST['post_status'] ) {
$args['post_status'] = 'trash';
$this->is_trash = true;
} elseif ( 'spam' === $_REQUEST['post_status'] ) {
$args['post_status'] = Flamingo_Inbound_Message::spam_status;
$this->is_spam = true;
}
}
$this->items = Flamingo_Inbound_Message::find( $args );
$total_items = Flamingo_Inbound_Message::count();
$total_pages = ceil( $total_items / $per_page );
$this->set_pagination_args( array(
'total_items' => $total_items,
'total_pages' => $total_pages,
'per_page' => $per_page,
) );
}
protected function get_views() {
$base_url = menu_page_url( 'flamingo_inbound', false );
$link_data = array();
// Inbox
Flamingo_Inbound_Message::find( array(
'post_status' => 'any',
) );
$posts_in_inbox = Flamingo_Inbound_Message::count();
$inbox = sprintf(
/* translators: %s: Number of items. */
_nx(
'Inbox <span class="count">(%s)</span>',
'Inbox <span class="count">(%s)</span>',
$posts_in_inbox, 'posts', 'flamingo'
),
number_format_i18n( $posts_in_inbox )
);
$link_data['inbox'] = array(
'url' => $base_url,
'label' => $inbox,
'current' => ! $this->is_trash && ! $this->is_spam,
);
// Spam
Flamingo_Inbound_Message::find( array(
'post_status' => Flamingo_Inbound_Message::spam_status,
) );
$posts_in_spam = Flamingo_Inbound_Message::count();
$spam = sprintf(
/* translators: %s: Number of items. */
_nx(
'Spam <span class="count">(%s)</span>',
'Spam <span class="count">(%s)</span>',
$posts_in_spam, 'posts', 'flamingo'
),
number_format_i18n( $posts_in_spam )
);
$link_data['spam'] = array(
'url' => add_query_arg( 'post_status', 'spam', $base_url ),
'label' => $spam,
'current' => $this->is_spam,
);
// Trash
Flamingo_Inbound_Message::find( array(
'post_status' => 'trash',
) );
$posts_in_trash = Flamingo_Inbound_Message::count();
if ( $posts_in_trash ) {
$trash = sprintf(
/* translators: %s: Number of items. */
_nx(
'Trash <span class="count">(%s)</span>',
'Trash <span class="count">(%s)</span>',
$posts_in_trash, 'posts', 'flamingo'
),
number_format_i18n( $posts_in_trash )
);
$link_data['trash'] = array(
'url' => add_query_arg( 'post_status', 'trash', $base_url ),
'label' => $trash,
'current' => $this->is_trash,
);
}
return $this->get_views_links( $link_data );
}
public function get_columns() {
return get_column_headers( get_current_screen() );
}
protected function get_sortable_columns() {
$columns = array(
'subject' => array( 'subject', false ),
'from' => array( 'from', false ),
'date' => array( 'date', true ),
);
return $columns;
}
protected function get_bulk_actions() {
$actions = array();
if ( $this->is_trash ) {
$actions['untrash'] = __( 'Restore', 'flamingo' );
}
if ( $this->is_trash or ! EMPTY_TRASH_DAYS ) {
$actions['delete'] = __( 'Delete permanently', 'flamingo' );
} else {
$actions['trash'] = __( 'Move to trash', 'flamingo' );
}
if ( $this->is_spam ) {
$actions['unspam'] = __( 'Not spam', 'flamingo' );
} else {
$actions['spam'] = __( 'Mark as spam', 'flamingo' );
}
return $actions;
}
protected function extra_tablenav( $which ) {
$channel = 0;
if ( ! empty( $_REQUEST['channel_id'] ) ) {
$term = get_term( $_REQUEST['channel_id'],
Flamingo_Inbound_Message::channel_taxonomy
);
if ( ! empty( $term ) and ! is_wp_error( $term ) ) {
$channel = $term->term_id;
}
} elseif ( ! empty( $_REQUEST['channel'] ) ) {
$term = get_term_by( 'slug', $_REQUEST['channel'],
Flamingo_Inbound_Message::channel_taxonomy
);
if ( ! empty( $term ) and ! is_wp_error( $term ) ) {
$channel = $term->term_id;
}
}
?>
<div class="alignleft actions">
<?php
if ( 'top' == $which ) {
$this->months_dropdown( Flamingo_Inbound_Message::post_type );
wp_dropdown_categories( array(
'taxonomy' => Flamingo_Inbound_Message::channel_taxonomy,
'name' => 'channel_id',
'show_option_all' => __( 'View all channels', 'flamingo' ),
'show_count' => 0,
'hide_empty' => 1,
'hide_if_empty' => 1,
'orderby' => 'name',
'hierarchical' => 1,
'selected' => $channel,
) );
submit_button( __( 'Filter', 'flamingo' ),
'secondary', false, false, array( 'id' => 'post-query-submit' )
);
if ( ! $this->is_spam and ! $this->is_trash ) {
submit_button( __( 'Export', 'flamingo' ),
'secondary', 'export', false
);
}
}
if (
$this->is_trash and
current_user_can( 'flamingo_delete_inbound_messages' )
) {
submit_button( __( 'Empty trash', 'flamingo' ),
'button-secondary apply', 'delete_all', false
);
}
?>
</div>
<?php
}
protected function column_default( $item, $column_name ) {
do_action( 'manage_flamingo_inbound_posts_custom_column',
$column_name, $item->id()
);
}
protected function column_cb( $item ) {
return sprintf(
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
$this->_args['singular'],
$item->id()
);
}
protected function column_subject( $item ) {
if ( $this->is_trash ) {
return sprintf( '<strong>%s</strong>', esc_html( $item->subject ) );
}
if ( current_user_can( 'flamingo_edit_inbound_message', $item->id() ) ) {
$edit_link = add_query_arg( array(
'post' => $item->id(),
'action' => 'edit',
), menu_page_url( 'flamingo_inbound', false ) );
return sprintf(
'<strong><a class="row-title" href="%1$s" aria-label="%2$s">%3$s</a></strong>',
esc_url( $edit_link ),
esc_attr( sprintf(
/* translators: %s: Item title. */
__( '&#8220;%s&#8221; (Edit)', 'flamingo' ),
$item->subject
) ),
esc_html( $item->subject )
);
}
return sprintf( '<strong>%1$s</strong>',
esc_html( $item->subject )
);
}
protected function handle_row_actions( $item, $column_name, $primary ) {
if ( $column_name !== $primary ) {
return '';
}
$actions = array();
if ( current_user_can( 'flamingo_edit_inbound_message', $item->id() ) ) {
$link = add_query_arg( array(
'post' => $item->id(),
'action' => 'edit',
), menu_page_url( 'flamingo_inbound', false ) );
$actions['edit'] = sprintf( '<a href="%1$s">%2$s</a>',
esc_url( $link ),
esc_html( __( 'View', 'flamingo' ) )
);
}
if (
$item->spam and
current_user_can( 'flamingo_unspam_inbound_message', $item->id() )
) {
$link = add_query_arg( array(
'post' => $item->id(),
'action' => 'unspam',
), menu_page_url( 'flamingo_inbound', false ) );
$link = wp_nonce_url( $link,
'flamingo-unspam-inbound-message_' . $item->id()
);
$actions['unspam'] = sprintf( '<a href="%1$s">%2$s</a>',
esc_url( $link ),
esc_html( __( 'Not spam', 'flamingo' ) )
);
}
if (
! $item->spam and
current_user_can( 'flamingo_spam_inbound_message', $item->id() )
) {
$link = add_query_arg( array(
'post' => $item->id(),
'action' => 'spam',
), menu_page_url( 'flamingo_inbound', false ) );
$link = wp_nonce_url( $link,
'flamingo-spam-inbound-message_' . $item->id()
);
$actions['spam'] = sprintf( '<a href="%1$s">%2$s</a>',
esc_url( $link ),
esc_html( __( 'Spam', 'flamingo' ) )
);
}
return $this->row_actions( $actions );
}
protected function column_from( $item ) {
return esc_html( $item->from );
}
protected function column_channel( $item ) {
if ( empty( $item->channel ) ) {
return '';
}
$term = get_term_by( 'slug', $item->channel,
Flamingo_Inbound_Message::channel_taxonomy
);
if ( empty( $term ) or is_wp_error( $term ) ) {
return $item->channel;
}
$output = '';
$ancestors = (array) get_ancestors( $term->term_id,
Flamingo_Inbound_Message::channel_taxonomy
);
while ( $parent = array_pop( $ancestors ) ) {
$parent = get_term( $parent, Flamingo_Inbound_Message::channel_taxonomy );
if ( empty( $parent ) or is_wp_error( $parent ) ) {
continue;
}
$link = add_query_arg( array(
'channel' => $parent->slug,
), menu_page_url( 'flamingo_inbound', false ) );
$output .= sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a> / ',
esc_url( $link ),
esc_attr( $parent->name ),
esc_html( $parent->name )
);
}
$link = add_query_arg( array(
'channel' => $term->slug,
), menu_page_url( 'flamingo_inbound', false ) );
$output .= sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>',
esc_url( $link ),
esc_attr( $term->name ),
esc_html( $term->name )
);
return $output;
}
protected function column_date( $item ) {
$datetime = get_post_datetime( $item->id() );
if ( false === $datetime ) {
return '';
}
$t_time = sprintf(
/* translators: 1: date, 2: time */
__( '%1$s at %2$s', 'flamingo' ),
/* translators: date format, see https://www.php.net/date */
$datetime->format( __( 'Y/m/d', 'flamingo' ) ),
/* translators: time format, see https://www.php.net/date */
$datetime->format( __( 'g:i a', 'flamingo' ) )
);
return $t_time;
}
}

View File

@@ -0,0 +1,20 @@
table.message-main-fields th, table.message-main-fields td {
text-align: right;
}
table.message-fields td {
padding: 4px 7px 2px 14px;
}
table.message-fields td.field-value li {
margin-right: 1em;
}
.tablenav .actions input.button {
margin: 0 0 0 8px;
}
#misc-publishing-actions .spam-log .dashicons-before::before {
margin: 0 -1px 0 0;
padding: 0 0 0 3px;
}

View File

@@ -0,0 +1,62 @@
ul.contact-history {
margin: 0;
}
#poststuff #submitdiv .inside {
margin: 0;
padding: 0;
}
#poststuff table.form-table tr.contact-prop th {
width: 25%;
}
table.message-main-fields th, table.message-main-fields td {
font-size: 15px;
text-align: left;
padding: 8px 4px;
}
table.message-main-fields th {
width: 20%;
color: #555;
}
table.message-fields td {
padding: 4px 14px 2px 7px;
}
table.message-fields td.field-title {
font-weight: bold;
width: 24%;
}
table.message-fields td.field-value p {
overflow-wrap: anywhere;
}
table.message-fields td.field-value ul {
margin: 0;
}
table.message-fields td.field-value li {
list-style: disc;
margin-left: 1em;
}
.tagsdiv {
margin-top: inherit;
}
.tablenav .actions input.button {
margin: 0 8px 0 0;
}
#misc-publishing-actions .dashicons-before::before {
position: relative;
top: -1px;
margin-left: -1px;
padding-right: 3px;
vertical-align: top;
color: #82878c;
}

View File

@@ -0,0 +1,8 @@
<?php
return array(
'dependencies' => array(
'wp-i18n',
),
'version' => FLAMINGO_VERSION,
);

View File

@@ -0,0 +1 @@
(()=>{"use strict";const e=window.wp.i18n;document.addEventListener("DOMContentLoaded",t=>{document.querySelectorAll(".submitdelete").forEach(t=>{t.addEventListener("click",t=>{if(window.confirm((0,e.__)("You are about to delete this item.\n 'Cancel' to stop, 'OK' to delete.","flamingo")))return!0;t.preventDefault()})}),postboxes.add_postbox_toggles(flamingo.screenId)})})();

View File

@@ -0,0 +1,330 @@
<?php
function flamingo_contact_submit_meta_box( $post ) {
?>
<div class="submitbox" id="submitlink">
<div id="major-publishing-actions">
<div id="delete-action">
<?php
if ( current_user_can( 'flamingo_delete_contact', $post->id() ) ) {
$delete_link = wp_nonce_url(
add_query_arg(
array(
'post' => $post->id(),
'action' => 'delete',
),
menu_page_url( 'flamingo', false )
),
'flamingo-delete-contact_' . $post->id()
);
echo sprintf(
'<a class="submitdelete deletion" href="%1$s">%2$s</a>',
esc_url( $delete_link ),
esc_html( __( 'Delete', 'flamingo' ) )
);
}
?>
</div>
<div id="publishing-action">
<span class="spinner"></span>
<?php if ( ! empty( $post->id() ) ) : ?>
<input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php echo esc_attr( __( 'Update contact', 'flamingo' ) ); ?>" />
<?php else : ?>
<input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php echo esc_attr( __( 'Add contact', 'flamingo' ) ); ?>" />
<?php endif; ?>
</div>
<div class="clear"></div>
</div><!-- #major-publishing-actions -->
<div class="clear"></div>
</div>
<?php
}
function flamingo_contact_tags_meta_box( $post ) {
$taxonomy = get_taxonomy( Flamingo_Contact::contact_tag_taxonomy );
if ( ! $taxonomy ) {
return;
}
$tags = wp_get_post_terms( $post->id(), $taxonomy->name );
$tag_names = $tag_ids = array();
if ( ! empty( $tags ) and ! is_wp_error( $tags ) ) {
foreach( $tags as $tag ) {
$tag_names[] = $tag->name;
$tag_ids[] = $tag->term_id;
}
}
$tag_names = implode( ', ', $tag_names );
$most_used_tags = get_terms( array(
'taxonomy' => Flamingo_Contact::contact_tag_taxonomy,
'orderby' => 'count',
'order' => 'DESC',
'number' => 10,
'exclude' => $tag_ids,
'fields' => 'names',
) );
if ( is_wp_error( $most_used_tags ) ) {
$most_used_tags = array();
}
?>
<div class="tagsdiv" id="<?php echo esc_attr( $taxonomy->name ); ?>">
<textarea name="<?php echo esc_attr( "tax_input[{$taxonomy->name}]" ); ?>" rows="3" cols="20" class="the-tags" id="<?php echo esc_attr( "tax-input-{$taxonomy->name}" ); ?>"><?php echo esc_textarea( $tag_names ); ?></textarea>
<p class="howto"><?php echo esc_html( __( 'Separate tags with commas', 'flamingo' ) ); ?></p>
<?php if ( $most_used_tags ) : ?>
<p class="howto"><?php echo esc_html( __( 'Choose from the most used tags', 'flamingo' ) ); ?>
<br />
<?php foreach ( $most_used_tags as $tag ) {
echo '<a href="#" class="append-this-to-contact-tags" onclick="appendTag( this.text )">' . esc_html( $tag ) . '</a> ';
} ?>
</p>
<script>
const appendTag = ( tag ) => {
const tagsInput = document.querySelector(
'#tax-input-<?php echo esc_js( $taxonomy->name ); ?>'
);
const tags = tagsInput.value.split( /\s*,\s*/ );
tags.push( tag );
tagsInput.value = tags.filter( tag => '' !== tag ).join( ', ' );
return false;
};
</script>
<?php endif; ?>
</div>
<?php
}
function flamingo_inbound_submit_meta_box( $post ) {
?>
<div class="submitbox" id="submitinbound">
<div id="minor-publishing">
<div id="misc-publishing-actions">
<fieldset class="misc-pub-section" id="comment-status-radio">
<legend class="screen-reader-text"><?php echo esc_html( __( 'Inbound message status', 'flamingo' ) ); ?></legend>
<label><input type="radio"<?php checked( $post->spam, true ); ?> name="inbound[status]" value="spam" /><?php echo esc_html( __( 'Spam', 'flamingo' ) ); ?></label><br />
<label><input type="radio"<?php checked( $post->spam, false ); ?> name="inbound[status]" value="ham" /><?php echo esc_html( __( 'Not spam', 'flamingo' ) ); ?></label>
</fieldset>
<div class="misc-pub-section curtime misc-pub-curtime">
<span class="dashicons-before dashicons-calendar">
<?php
$submitted_timestamp = get_post_timestamp( $post->id() );
$submitted_on = sprintf(
/* translators: Publish box date string. 1: Date, 2: Time. */
__( '%1$s at %2$s', 'flamingo' ),
wp_date(
/* translators: Publish box date format, see https://www.php.net/date */
_x( 'M j, Y', 'publish box date format', 'flamingo' ),
$submitted_timestamp
),
wp_date(
/* translators: Publish box time format, see https://www.php.net/date */
_x( 'H:i', 'publish box time format', 'flamingo' ),
$submitted_timestamp
)
);
echo wp_kses_data( sprintf(
/* translators: %s: Message submission date. */
__( 'Submitted on: <b>%s</b>', 'flamingo' ),
$submitted_on
) );
?>
</span>
</div>
<?php
if ( ! empty( $post->submission_status ) ) {
echo '<div class="misc-pub-section submission-status">', "\n";
echo sprintf(
'<span class="dashicons-before %1$s"> %2$s</span>',
in_array( $post->submission_status, array( 'mail_failed', 'spam' ) )
? 'dashicons-no' : 'dashicons-yes',
wp_kses_data( sprintf(
/* translators: %s: Result of the submission. */
__( 'Submission result: <b>%s</b>', 'flamingo' ),
$post->submission_status
) )
);
echo '</div>', "\n";
}
foreach ( (array) $post->spam_log as $log ) {
echo '<div class="misc-pub-section spam-log">';
echo sprintf(
'<span class="dashicons-before dashicons-shield %1$s"> %2$s</span>',
esc_attr( $log['agent'] ?? '' ),
wp_kses_data( sprintf(
/* translators: %s: reason why this message is regarded as spam */
__( 'Spam log: %s', 'flamingo' ),
$log['reason'] ?? ''
) )
);
echo '</div>';
}
?>
</div><!-- #misc-publishing-actions -->
<div class="clear"></div>
</div><!-- #minor-publishing -->
<div id="major-publishing-actions">
<div id="delete-action">
<?php
if ( current_user_can( 'flamingo_delete_inbound_message', $post->id() ) ) {
if ( ! EMPTY_TRASH_DAYS ) {
$delete_text = __( 'Delete permanently', 'flamingo' );
} else {
$delete_text = __( 'Move to trash', 'flamingo' );
}
$delete_link = add_query_arg(
array(
'post' => $post->id(),
'action' => 'trash',
),
menu_page_url( 'flamingo_inbound', false )
);
$delete_link = wp_nonce_url(
$delete_link,
'flamingo-trash-inbound-message_' . $post->id()
);
echo sprintf( '<a href="%1$s" class="submitdelete deletion">%2$s</a>',
esc_url( $delete_link ),
esc_html( $delete_text )
);
}
?>
</div>
<div id="publishing-action">
<?php
submit_button( __( 'Update', 'flamingo' ), 'primary large', 'save', false );
?>
</div>
<div class="clear"></div>
</div><!-- #major-publishing-actions -->
</div>
<?php
}
function flamingo_contact_name_meta_box( $post ) {
?>
<table class="form-table">
<tbody>
<tr class="contact-prop">
<th><label for="contact_name"><?php echo esc_attr( __( 'Full name', 'flamingo' ) ); ?></th>
<td><input type="text" name="contact[name]" id="contact_name" value="<?php echo esc_attr( $post->get_prop( 'name' ) ); ?>" class="widefat" /></td>
</tr>
<tr class="contact-prop">
<th><label for="contact_first_name"><?php echo esc_attr( __( 'First name', 'flamingo' ) ); ?></th>
<td><input type="text" name="contact[first_name]" id="contact_first_name" value="<?php echo esc_attr( $post->get_prop( 'first_name' ) ); ?>" class="widefat" /></td>
</tr>
<tr class="contact-prop">
<th><label for="contact_last_name"><?php echo esc_attr( __( 'Last name', 'flamingo' ) ); ?></th>
<td><input type="text" name="contact[last_name]" id="contact_last_name" value="<?php echo esc_attr( $post->get_prop( 'last_name' ) ); ?>" class="widefat" /></td>
</tr>
</tbody>
</table>
<?php
}
function flamingo_inbound_fields_meta_box( $post ) {
?>
<table class="widefat message-fields striped">
<tbody>
<?php foreach ( (array) $post->fields as $key => $value ) : ?>
<tr>
<td class="field-title"><?php echo esc_html( $key ); ?></td>
<td class="field-value"><?php echo wp_kses_post( flamingo_htmlize( $value ) ); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
}
function flamingo_inbound_consent_meta_box( $post ) {
$consent = $post->consent;
if ( empty( $consent ) ) {
return;
}
?>
<table class="widefat message-fields striped">
<tbody>
<?php foreach ( (array) $consent as $key => $value ) : ?>
<tr>
<td class="field-title"><?php echo esc_html( $key ); ?></td>
<td class="field-value"><?php echo wp_kses( $value, wp_kses_allowed_html( 'data' ) ); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
}
function flamingo_inbound_recaptcha_meta_box( $post ) {
?>
<table class="widefat message-fields striped">
<tbody>
<?php foreach ( (array) $post->recaptcha as $key => $value ) : ?>
<tr>
<td class="field-title"><?php echo esc_html( $key ); ?></td>
<td class="field-value"><?php echo esc_html( wp_json_encode( $value, JSON_PRETTY_PRINT ) ); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
}
function flamingo_inbound_meta_meta_box( $post ) {
?>
<table class="widefat message-fields striped">
<tbody>
<?php foreach ( (array) $post->meta as $key => $value ) : ?>
<tr>
<td class="field-title"><?php echo esc_html( $key ); ?></td>
<td class="field-value"><?php echo wp_kses_post( flamingo_htmlize( $value ) ); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
}

View File

@@ -0,0 +1,120 @@
<?php
/**
* Support for personal data eraser tool
*
* @link https://developer.wordpress.org/plugins/privacy/adding-the-personal-data-eraser-to-your-plugin/
*/
add_filter( 'wp_privacy_personal_data_erasers',
'flamingo_privacy_register_personal_data_erasers',
10, 1
);
/**
* Registers callback functions.
*/
function flamingo_privacy_register_personal_data_erasers( $erasers ) {
return array_merge( (array) $erasers, array(
'flamingo-contact' => array(
'eraser_friendly_name' => __( 'Flamingo Address Book', 'flamingo' ),
'callback' => 'flamingo_privacy_contact_eraser',
),
'flamingo-inbound' => array(
'eraser_friendly_name' => __( 'Flamingo Inbound Messages', 'flamingo' ),
'callback' => 'flamingo_privacy_inbound_eraser',
),
) );
}
/**
* Callback for the contact data.
*/
function flamingo_privacy_contact_eraser( $email_address, $page = 1 ) {
$number = 100;
$posts = Flamingo_Contact::find( array(
'meta_key' => '_email',
'meta_value' => $email_address,
'posts_per_page' => $number,
'paged' => (int) $page,
) );
$items_removed = false;
$items_retained = false;
$messages = array();
foreach ( (array) $posts as $post ) {
if ( ! current_user_can( 'flamingo_delete_contact', $post->id() ) ) {
$items_retained = true;
$messages = array(
__( 'Flamingo Address Book: You are not allowed to delete contact data.', 'flamingo' ),
);
continue;
}
if ( $post->delete() ) {
$items_removed = true;
} else {
$items_retained = true;
}
}
$done = Flamingo_Contact::count() < $number;
return array(
'items_removed' => $items_removed,
'items_retained' => $items_retained,
'messages' => array_map( 'esc_html', (array) $messages ),
'done' => $done,
);
}
/**
* Callback for the inbound messages data.
*/
function flamingo_privacy_inbound_eraser( $email_address, $page = 1 ) {
$number = 100;
$posts = Flamingo_Inbound_Message::find( array(
'meta_key' => '_from_email',
'meta_value' => $email_address,
'posts_per_page' => $number,
'paged' => (int) $page,
) );
$items_removed = false;
$items_retained = false;
$messages = array();
foreach ( (array) $posts as $post ) {
if ( ! current_user_can( 'flamingo_delete_inbound_message', $post->id() ) ) {
$items_retained = true;
$messages = array(
__( 'Flamingo Inbound Messages: You are not allowed to delete inbound messages.', 'flamingo' ),
);
continue;
}
if ( $post->delete() ) {
$items_removed = true;
} else {
$items_retained = true;
}
}
$done = Flamingo_Inbound_Message::count() < $number;
return array(
'items_removed' => $items_removed,
'items_retained' => $items_retained,
'messages' => array_map( 'esc_html', (array) $messages ),
'done' => $done,
);
}

View File

@@ -0,0 +1,83 @@
<?php
/*
* Plugin Name: Flamingo
* Plugin URI: https://contactform7.com/save-submitted-messages-with-flamingo/
* Description: A trustworthy message storage plugin for Contact Form 7.
* Author: Rock Lobster Inc.
* Author URI: https://github.com/rocklobster-in/
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Version: 2.6.1
* Requires at least: 6.7
* Requires PHP: 7.4
*/
define( 'FLAMINGO_VERSION', '2.6.1' );
define( 'FLAMINGO_PLUGIN', __FILE__ );
define( 'FLAMINGO_PLUGIN_BASENAME',
plugin_basename( FLAMINGO_PLUGIN )
);
define( 'FLAMINGO_PLUGIN_NAME',
trim( dirname( FLAMINGO_PLUGIN_BASENAME ), '/' )
);
define( 'FLAMINGO_PLUGIN_DIR',
untrailingslashit( dirname( FLAMINGO_PLUGIN ) )
);
if ( ! defined( 'FLAMINGO_MOVE_TRASH_DAYS' ) ) {
define( 'FLAMINGO_MOVE_TRASH_DAYS', 30 );
}
// Deprecated, not used in the plugin core. Use flamingo_plugin_url() instead.
define( 'FLAMINGO_PLUGIN_URL',
untrailingslashit( plugins_url( '', FLAMINGO_PLUGIN ) )
);
require_once FLAMINGO_PLUGIN_DIR . '/includes/functions.php';
require_once FLAMINGO_PLUGIN_DIR . '/includes/formatting.php';
require_once FLAMINGO_PLUGIN_DIR . '/includes/csv.php';
require_once FLAMINGO_PLUGIN_DIR . '/includes/capabilities.php';
require_once FLAMINGO_PLUGIN_DIR . '/includes/class-contact.php';
require_once FLAMINGO_PLUGIN_DIR . '/includes/class-inbound-message.php';
require_once FLAMINGO_PLUGIN_DIR . '/includes/user.php';
require_once FLAMINGO_PLUGIN_DIR . '/includes/comment.php';
require_once FLAMINGO_PLUGIN_DIR . '/includes/akismet.php';
require_once FLAMINGO_PLUGIN_DIR . '/includes/cron.php';
if ( is_admin() ) {
require_once FLAMINGO_PLUGIN_DIR . '/admin/admin.php';
}
/* Init */
add_action( 'init', static function () {
/* Custom Post Types */
Flamingo_Contact::register_post_type();
Flamingo_Inbound_Message::register_post_type();
add_filter(
'wp_untrash_post_status',
'flamingo_untrash_post_status',
10, 3
);
do_action( 'flamingo_init' );
}, 10, 0 );
function flamingo_untrash_post_status( $new_status, $post_id, $prev_status ) {
$flamingo_post_types = array(
Flamingo_Contact::post_type,
Flamingo_Inbound_Message::post_type,
);
if ( in_array( get_post_type( $post_id ), $flamingo_post_types, true ) ) {
return $prev_status;
}
return $new_status;
}

View File

@@ -0,0 +1,38 @@
<?php
function flamingo_akismet_submit_spam( $comment ) {
return flamingo_akismet_submit( $comment, 'spam' );
}
function flamingo_akismet_submit_ham( $comment ) {
return flamingo_akismet_submit( $comment, 'ham' );
}
function flamingo_akismet_submit( $comment, $spam_or_ham = 'spam' ) {
if ( ! flamingo_akismet_is_active() ) {
return false;
}
if ( ! in_array( $spam_or_ham, array( 'spam', 'ham' ) ) ) {
return false;
}
$query_string = '';
foreach ( (array) $comment as $key => $data ) {
$query_string .=
$key . '=' . urlencode( wp_unslash( (string) $data ) ) . '&';
}
$response = Akismet::http_post( $query_string, 'submit-' . $spam_or_ham );
return (bool) $response[1];
}
function flamingo_akismet_is_active() {
if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) {
return (bool) Akismet::get_api_key();
}
return false;
}

View File

@@ -0,0 +1,27 @@
<?php
add_filter( 'map_meta_cap', 'flamingo_map_meta_cap', 10, 4 );
function flamingo_map_meta_cap( $caps, $cap, $user_id, $args ) {
$meta_caps = array(
'flamingo_edit_contact' => 'edit_users',
'flamingo_edit_contacts' => 'edit_users',
'flamingo_delete_contact' => 'edit_users',
'flamingo_edit_inbound_message' => 'edit_users',
'flamingo_edit_inbound_messages' => 'edit_users',
'flamingo_delete_inbound_message' => 'edit_users',
'flamingo_delete_inbound_messages' => 'edit_users',
'flamingo_spam_inbound_message' => 'edit_users',
'flamingo_unspam_inbound_message' => 'edit_users',
);
$meta_caps = apply_filters( 'flamingo_map_meta_cap', $meta_caps );
$caps = array_diff( $caps, array_keys( $meta_caps ) );
if ( isset( $meta_caps[$cap] ) ) {
$caps[] = $meta_caps[$cap];
}
return $caps;
}

View File

@@ -0,0 +1,228 @@
<?php
class Flamingo_Contact {
const post_type = 'flamingo_contact';
const contact_tag_taxonomy = 'flamingo_contact_tag';
private static $found_items = 0;
private $id;
public $email;
public $name;
public $props = array();
public $tags = array();
public $last_contacted;
public static function register_post_type() {
register_post_type( self::post_type, array(
'labels' => array(
'name' => __( 'Flamingo Contacts', 'flamingo' ),
'singular_name' => __( 'Flamingo Contact', 'flamingo' ),
),
'rewrite' => false,
'query_var' => false,
) );
register_taxonomy( self::contact_tag_taxonomy, self::post_type, array(
'labels' => array(
'name' => __( 'Flamingo Contact Tags', 'flamingo' ),
'singular_name' => __( 'Flamingo Contact Tag', 'flamingo' ),
),
'public' => false,
'rewrite' => false,
'query_var' => false,
) );
}
public static function find( $args = '' ) {
$defaults = array(
'posts_per_page' => 10,
'offset' => 0,
'orderby' => 'ID',
'order' => 'ASC',
'meta_key' => '',
'meta_value' => '',
'post_status' => 'any',
'tax_query' => array(),
'contact_tag_id' => '',
);
$args = wp_parse_args( $args, $defaults );
$args['post_type'] = self::post_type;
if ( ! empty( $args['contact_tag_id'] ) ) {
$args['tax_query'][] = array(
'taxonomy' => self::contact_tag_taxonomy,
'terms' => $args['contact_tag_id'],
'field' => 'term_id',
);
}
$q = new WP_Query();
$posts = $q->query( $args );
self::$found_items = $q->found_posts;
$objs = array();
foreach ( (array) $posts as $post ) {
$objs[] = new self( $post );
}
return $objs;
}
public static function count( $args = '' ) {
if ( $args ) {
$args = wp_parse_args( $args, array(
'offset' => 0,
'post_status' => 'publish',
) );
self::find( $args );
}
return absint( self::$found_items );
}
public static function search_by_email( $email ) {
$objs = self::find( array(
'posts_per_page' => 1,
'orderby' => 'ID',
'meta_key' => '_email',
'meta_value' => $email,
) );
if ( empty( $objs ) ) {
return null;
}
return $objs[0];
}
public static function add( $args = '' ) {
$args = wp_parse_args( $args, array(
'email' => '',
'name' => '',
'props' => array(),
'last_contacted' => '0000-00-00 00:00:00',
) );
$args = apply_filters( 'flamingo_add_contact', $args );
if ( empty( $args['email'] ) or ! is_email( $args['email'] ) ) {
return;
}
$obj = self::search_by_email( $args['email'] );
if ( ! $obj ) {
$obj = new self();
$obj->email = $args['email'];
$obj->name = $args['name'];
$obj->props = (array) $args['props'];
}
if ( '0000-00-00 00:00:00' !== $args['last_contacted'] ) {
$obj->last_contacted = $args['last_contacted'];
} elseif ( $datetime = date_create_immutable( 'now', wp_timezone() ) ) {
$obj->last_contacted = $datetime->format( 'Y-m-d H:i:s' );
}
$obj->save();
return $obj;
}
public function __construct( $post = null ) {
if ( ! empty( $post ) and $post = get_post( $post ) ) {
$this->id = $post->ID;
$this->email = get_post_meta( $post->ID, '_email', true );
$this->name = get_post_meta( $post->ID, '_name', true );
$this->props = get_post_meta( $post->ID, '_props', true );
$this->last_contacted =
get_post_meta( $post->ID, '_last_contacted', true );
$terms = wp_get_object_terms( $this->id, self::contact_tag_taxonomy );
if ( ! empty( $terms ) and ! is_wp_error( $terms ) ) {
foreach ( $terms as $term ) {
$this->tags[] = $term->name;
}
}
}
}
public function __get( $name ) {
if ( 'id' === $name ) {
return $this->id;
}
}
public function id() {
return $this->id;
}
public function save() {
$post_title = $this->email;
$post_name = strtr( $this->email, '@', '-' );
$fields = flamingo_array_flatten( $this->props );
$fields = array_merge( $fields, array( $this->email, $this->name ) );
$fields = array_filter( array_map( 'trim', $fields ) );
$fields = array_unique( $fields );
$post_content = implode( "\n", $fields );
$postarr = array(
'ID' => absint( $this->id ),
'post_type' => self::post_type,
'post_status' => 'publish',
'post_title' => $post_title,
'post_name' => $post_name,
'post_content' => $post_content,
);
$post_id = wp_insert_post( $postarr );
if ( $post_id ) {
$this->id = $post_id;
update_post_meta( $post_id, '_email', $this->email );
update_post_meta( $post_id, '_name', $this->name );
update_post_meta( $post_id, '_props', $this->props );
update_post_meta( $post_id, '_last_contacted', $this->last_contacted );
wp_set_object_terms( $this->id, $this->tags, self::contact_tag_taxonomy );
}
return $post_id;
}
public function get_prop( $name ) {
if ( 'name' == $name ) {
return $this->name;
}
if ( isset( $this->props[$name] ) ) {
return $this->props[$name];
}
return '';
}
public function delete() {
if ( empty( $this->id ) ) {
return;
}
if ( $post = wp_delete_post( $this->id, true ) ) {
$this->id = 0;
}
return (bool) $post;
}
}

View File

@@ -0,0 +1,452 @@
<?php
class Flamingo_Inbound_Message {
const post_type = 'flamingo_inbound';
const spam_status = 'flamingo-spam';
const channel_taxonomy = 'flamingo_inbound_channel';
private static $found_items = 0;
private $id;
public $channel;
public $submission_status;
public $subject;
public $from;
public $from_name;
public $from_email;
public $fields;
public $meta;
public $akismet;
public $recaptcha;
public $spam;
public $spam_log;
public $consent;
private $timestamp = null;
private $hash = null;
public static function register_post_type() {
register_post_type( self::post_type, array(
'labels' => array(
'name' => __( 'Flamingo Inbound Messages', 'flamingo' ),
'singular_name' => __( 'Flamingo Inbound Message', 'flamingo' ),
),
'rewrite' => false,
'query_var' => false,
) );
register_post_status( self::spam_status, array(
'label' => __( 'Spam', 'flamingo' ),
'public' => false,
'exclude_from_search' => true,
'show_in_admin_all_list' => false,
'show_in_admin_status_list' => true,
) );
register_taxonomy( self::channel_taxonomy, self::post_type, array(
'labels' => array(
'name' => __( 'Flamingo Inbound Message Channels', 'flamingo' ),
'singular_name' => __( 'Flamingo Inbound Message Channel', 'flamingo' ),
),
'public' => false,
'hierarchical' => true,
'rewrite' => false,
'query_var' => false,
) );
}
public static function find( $args = '' ) {
$defaults = array(
'posts_per_page' => 10,
'offset' => 0,
'orderby' => 'ID',
'order' => 'ASC',
'meta_key' => '',
'meta_value' => '',
'post_status' => 'any',
'tax_query' => array(),
'channel' => '',
'channel_id' => 0,
'hash' => '',
);
$args = wp_parse_args( $args, $defaults );
$args['post_type'] = self::post_type;
if ( ! empty( $args['channel_id'] ) ) {
$args['tax_query'][] = array(
'taxonomy' => self::channel_taxonomy,
'terms' => absint( $args['channel_id'] ),
'field' => 'term_id',
);
}
if ( ! empty( $args['channel'] ) ) {
$args['tax_query'][] = array(
'taxonomy' => self::channel_taxonomy,
'terms' => $args['channel'],
'field' => 'slug',
);
}
if ( ! empty( $args['hash'] ) ) {
$args['meta_query'][] = array(
'key' => '_hash',
'value' => $args['hash'],
);
}
$q = new WP_Query();
$posts = $q->query( $args );
self::$found_items = $q->found_posts;
$objs = array();
foreach ( (array) $posts as $post ) {
$objs[] = new self( $post );
}
return $objs;
}
public static function count( $args = '' ) {
if ( $args ) {
$args = wp_parse_args( $args, array(
'offset' => 0,
'channel' => '',
'channel_id' => 0,
'post_status' => 'publish',
) );
self::find( $args );
}
return absint( self::$found_items );
}
public static function add( $args = '' ) {
$args = wp_parse_args( $args, array(
'channel' => '',
'status' => '',
'subject' => '',
'from' => '',
'from_name' => '',
'from_email' => '',
'fields' => array(),
'meta' => array(),
'akismet' => array(),
'recaptcha' => array(),
'spam' => false,
'spam_log' => array(),
'consent' => array(),
'timestamp' => null,
'posted_data_hash' => null,
) );
$args = apply_filters( 'flamingo_add_inbound', $args );
$obj = new self();
$obj->channel = $args['channel'];
$obj->submission_status = $args['status'];
$obj->subject = $args['subject'];
$obj->from = $args['from'];
$obj->from_name = $args['from_name'];
$obj->from_email = $args['from_email'];
$obj->fields = $args['fields'];
$obj->meta = $args['meta'];
$obj->akismet = $args['akismet'];
$obj->recaptcha = $args['recaptcha'];
$obj->spam = $args['spam'];
$obj->spam_log = $args['spam_log'];
$obj->consent = $args['consent'];
if ( $args['timestamp'] ) {
$obj->timestamp = $args['timestamp'];
}
if ( $args['posted_data_hash'] ) {
$obj->hash = $args['posted_data_hash'];
}
$obj->save();
return $obj;
}
public function __construct( $post = null ) {
if ( ! empty( $post ) and $post = get_post( $post ) ) {
$this->id = $post->ID;
$this->subject = get_post_meta( $post->ID, '_subject', true );
$this->from = get_post_meta( $post->ID, '_from', true );
$this->from_name = get_post_meta( $post->ID, '_from_name', true );
$this->from_email = get_post_meta( $post->ID, '_from_email', true );
$this->fields = get_post_meta( $post->ID, '_fields', true );
if ( ! empty( $this->fields ) ) {
foreach ( (array) $this->fields as $key => $value ) {
$meta_key = sanitize_key( '_field_' . $key );
if ( metadata_exists( 'post', $post->ID, $meta_key ) ) {
$value = get_post_meta( $post->ID, $meta_key, true );
$this->fields[$key] = $value;
}
}
}
$this->submission_status = get_post_meta( $post->ID,
'_submission_status', true
);
$this->meta = get_post_meta( $post->ID, '_meta', true );
$this->akismet = get_post_meta( $post->ID, '_akismet', true );
$this->recaptcha = get_post_meta( $post->ID, '_recaptcha', true );
$this->spam_log = get_post_meta( $post->ID, '_spam_log', true );
$this->consent = get_post_meta( $post->ID, '_consent', true );
$terms = wp_get_object_terms( $this->id, self::channel_taxonomy );
if ( ! empty( $terms ) and ! is_wp_error( $terms ) ) {
$this->channel = $terms[0]->slug;
}
if ( self::spam_status == get_post_status( $post ) ) {
$this->spam = true;
} else {
$this->spam = isset( $this->akismet['spam'] ) && $this->akismet['spam'];
}
$this->hash = get_post_meta( $post->ID, '_hash', true );
}
}
public function __get( $name ) {
if ( 'id' === $name ) {
return $this->id;
}
}
public function id() {
return $this->id;
}
public function save() {
if ( ! empty( $this->subject ) ) {
$post_title = $this->subject;
} else {
$post_title = __( '(No Title)', 'flamingo' );
}
$post_content = array_merge(
(array) $this->fields,
(array) $this->consent,
(array) $this->meta
);
$post_content = flamingo_array_flatten( $post_content );
$post_content = array_filter( array_map( 'trim', $post_content ) );
$post_content = implode( "\n", $post_content );
$post_status = $this->spam ? self::spam_status : 'publish';
$postarr = array(
'ID' => absint( $this->id ),
'post_type' => self::post_type,
'post_status' => $post_status,
'post_title' => $post_title,
'post_content' => $post_content,
'post_date' => $this->get_post_date(),
);
if (
$this->timestamp and
$datetime = date_create( '@' . $this->timestamp )
) {
$datetime->setTimezone( wp_timezone() );
$postarr['post_date'] = $datetime->format( 'Y-m-d H:i:s' );
}
$post_id = wp_insert_post( $postarr );
if ( $post_id ) {
$this->id = $post_id;
switch ( $post_status ) {
case self::spam_status:
update_post_meta( $post_id, '_spam_meta_time', time() );
break;
case 'trash':
// Do nothing.
break;
default:
delete_post_meta( $post_id, '_spam_meta_time' );
}
update_post_meta( $post_id, '_submission_status',
$this->submission_status
);
update_post_meta( $post_id, '_subject', $this->subject );
update_post_meta( $post_id, '_from', $this->from );
update_post_meta( $post_id, '_from_name', $this->from_name );
update_post_meta( $post_id, '_from_email', $this->from_email );
foreach ( $this->fields as $key => $value ) {
$meta_key = sanitize_key( '_field_' . $key );
update_post_meta( $post_id, $meta_key, $value );
$this->fields[$key] = null;
}
update_post_meta( $post_id, '_fields', $this->fields );
update_post_meta( $post_id, '_meta', $this->meta );
update_post_meta( $post_id, '_akismet', $this->akismet );
update_post_meta( $post_id, '_recaptcha', $this->recaptcha );
update_post_meta( $post_id, '_spam_log', $this->spam_log );
update_post_meta( $post_id, '_consent', $this->consent );
update_post_meta( $post_id, '_hash', $this->hash );
if ( term_exists( $this->channel, self::channel_taxonomy ) ) {
wp_set_object_terms(
$this->id,
$this->channel,
self::channel_taxonomy
);
}
}
return $post_id;
}
private function get_post_date() {
if ( empty( $this->id ) ) {
return false;
}
$post = get_post( $this->id );
if ( ! $post ) {
return false;
}
return $post->post_date;
}
public function trash() {
if ( empty( $this->id ) ) {
return;
}
if ( ! EMPTY_TRASH_DAYS ) {
return $this->delete();
}
$post = wp_trash_post( $this->id );
return (bool) $post;
}
public function untrash() {
if ( empty( $this->id ) ) {
return;
}
$post = wp_untrash_post( $this->id );
return (bool) $post;
}
public function delete() {
if ( empty( $this->id ) ) {
return;
}
if ( $post = wp_delete_post( $this->id, true ) ) {
$this->id = 0;
}
return (bool) $post;
}
public function spam() {
if ( $this->spam ) {
return;
}
$this->akismet_submit_spam();
$this->spam = true;
$user_name = get_user_option( 'user_login' );
if ( false === $user_name ) {
$user_name = __( 'Unknown', 'flamingo' );
}
if ( empty( $this->spam_log ) ) {
$this->spam_log = array();
}
$this->spam_log[] = array(
'agent' => 'flamingo',
'reason' => sprintf(
/* translators: %s: WordPress user name */
__( '%s has marked this message as spam.', 'flamingo' ),
$user_name
),
);
return $this->save();
}
public function akismet_submit_spam() {
if ( empty( $this->id ) or empty( $this->akismet ) ) {
return;
}
if ( isset( $this->akismet['spam'] ) and $this->akismet['spam'] ) {
return;
}
if ( empty( $this->akismet['comment'] ) ) {
return;
}
if ( flamingo_akismet_submit_spam( $this->akismet['comment'] ) ) {
$this->akismet['spam'] = true;
update_post_meta( $this->id, '_akismet', $this->akismet );
return true;
}
}
public function unspam() {
if ( ! $this->spam ) {
return;
}
$this->akismet_submit_ham();
$this->spam = false;
return $this->save();
}
public function akismet_submit_ham() {
if ( empty( $this->id ) or empty( $this->akismet ) ) {
return;
}
if ( isset( $this->akismet['spam'] ) and ! $this->akismet['spam'] ) {
return;
}
if ( empty( $this->akismet['comment'] ) ) {
return;
}
if ( flamingo_akismet_submit_ham( $this->akismet['comment'] ) ) {
$this->akismet['spam'] = false;
update_post_meta( $this->id, '_akismet', $this->akismet );
return true;
}
}
}

View File

@@ -0,0 +1,79 @@
<?php
/**
* Module for WordPress comments handling
*/
add_action( 'wp_insert_comment', 'flamingo_insert_comment', 10, 1 );
/**
* Creates a Flamingo_Contact record for the given comment.
*/
function flamingo_insert_comment( $comment_id ) {
$comment = get_comment( $comment_id );
if ( 1 !== (int) $comment->comment_approved ) {
return;
}
Flamingo_Contact::add( array(
'email' => $comment->comment_author_email,
'name' => $comment->comment_author,
'channel' => 'comment',
) );
}
add_action( 'transition_comment_status',
'flamingo_transition_comment_status',
10, 3
);
/**
* Creates a Flamingo_Contact record when the comment status changes.
*/
function flamingo_transition_comment_status( $new_status, $old_status, $comment ) {
if ( 'approved' !== $new_status ) {
return;
}
$email = $comment->comment_author_email;
$name = $comment->comment_author;
Flamingo_Contact::add( array(
'email' => $email,
'name' => $name,
'channel' => 'comment',
) );
}
add_action( 'activate_' . FLAMINGO_PLUGIN_BASENAME,
'flamingo_collect_contacts_from_comments',
10, 0
);
/**
* Creates Flamingo_Contact records for existing comments.
*/
function flamingo_collect_contacts_from_comments() {
$comments = get_comments( array(
'status' => 'approve',
'type' => 'comment',
'number' => 20,
) );
foreach ( $comments as $comment ) {
$email = $comment->comment_author_email;
$name = $comment->comment_author;
if ( empty( $email ) ) {
continue;
}
Flamingo_Contact::add( array(
'email' => $email,
'name' => $name,
'channel' => 'comment',
) );
}
}

View File

@@ -0,0 +1,46 @@
<?php
/**
* Cron job functionality
*
* @since 2.1
*/
add_action( 'admin_init', 'flamingo_schedule_activation', 10, 0 );
/**
* Creates a scheduled event, if it does not exist.
*
* @since 2.1
*/
function flamingo_schedule_activation() {
if ( ! wp_next_scheduled( 'flamingo_hourly_cron_job' ) ) {
wp_schedule_event( time(), 'hourly', 'flamingo_hourly_cron_job' );
}
}
add_action( 'flamingo_hourly_cron_job', 'flamingo_schedule_function', 10, 0 );
/**
* The cron job.
*
* @since 2.1
*/
function flamingo_schedule_function() {
flamingo_schedule_move_trash();
}
// Unscheduling cron jobs on plugin deactivation.
register_deactivation_hook( FLAMINGO_PLUGIN, 'flamingo_schedule_deactivate' );
/**
* Unschedules cron jobs.
*
* @since 2.1
*/
function flamingo_schedule_deactivate() {
wp_clear_scheduled_hook( 'flamingo_hourly_cron_job' );
wp_clear_scheduled_hook( 'flamingo_daily_cron_job' );
}

View File

@@ -0,0 +1,243 @@
<?php
abstract class Flamingo_CSV {
public function get_file_name() {
return 'flamingo.csv';
}
public function send_http_headers() {
$filename = $this->get_file_name();
$charset = get_option( 'blog_charset' );
header( "Content-Description: File Transfer" );
header( "Content-Disposition: attachment; filename=$filename" );
header( "Content-Type: text/csv; charset=$charset" );
}
public function print_data() {
echo '';
}
}
class Flamingo_Contact_CSV extends Flamingo_CSV {
public function get_file_name() {
return sprintf(
'%1$s-flamingo-contact-%2$s.csv',
sanitize_key( get_bloginfo( 'name' ) ),
wp_date( 'Y-m-d' )
);
}
public function print_data() {
$labels = array(
__( 'Email', 'flamingo' ),
__( 'Full name', 'flamingo' ),
__( 'First name', 'flamingo' ),
__( 'Last name', 'flamingo' ),
);
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo flamingo_csv_row( $labels );
$args = array(
'posts_per_page' => -1,
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_key' => '_email',
);
if ( ! empty( $_GET['s'] ) ) {
$args['s'] = $_GET['s'];
}
if ( ! empty( $_GET['orderby'] ) ) {
if ( 'email' === $_GET['orderby'] ) {
$args['meta_key'] = '_email';
} elseif ( 'name' === $_GET['orderby'] ) {
$args['meta_key'] = '_name';
}
}
if (
! empty( $_GET['order'] ) and
'asc' === strtolower( $_GET['order'] )
) {
$args['order'] = 'ASC';
}
if ( ! empty( $_GET['contact_tag_id'] ) ) {
$args['contact_tag_id'] = explode( ',', $_GET['contact_tag_id'] );
}
$items = Flamingo_Contact::find( $args );
foreach ( $items as $item ) {
echo "\r\n";
$row = array(
$item->email,
$item->get_prop( 'name' ),
$item->get_prop( 'first_name' ),
$item->get_prop( 'last_name' ),
);
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo flamingo_csv_row( $row );
}
}
}
class Flamingo_Inbound_CSV extends Flamingo_CSV {
public function get_file_name() {
return sprintf(
'%1$s-flamingo-inbound-%2$s.csv',
sanitize_key( get_bloginfo( 'name' ) ),
wp_date( 'Y-m-d' )
);
}
public function print_data() {
$args = array(
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'DESC',
);
if ( ! empty( $_REQUEST['s'] ) ) {
$args['s'] = $_REQUEST['s'];
}
if ( ! empty( $_REQUEST['orderby'] ) ) {
if ( 'subject' === $_REQUEST['orderby'] ) {
$args['meta_key'] = '_subject';
$args['orderby'] = 'meta_value';
} elseif ( 'from' === $_REQUEST['orderby'] ) {
$args['meta_key'] = '_from';
$args['orderby'] = 'meta_value';
}
}
if (
! empty( $_REQUEST['order'] ) and
'asc' === strtolower( $_REQUEST['order'] )
) {
$args['order'] = 'ASC';
}
if ( ! empty( $_REQUEST['m'] ) ) {
$args['m'] = $_REQUEST['m'];
}
if ( ! empty( $_REQUEST['channel_id'] ) ) {
$args['channel_id'] = $_REQUEST['channel_id'];
}
if ( ! empty( $_REQUEST['channel'] ) ) {
$args['channel'] = $_REQUEST['channel'];
}
$items = Flamingo_Inbound_Message::find( $args );
if ( empty( $items ) ) {
return;
}
$labels = array_keys( $items[0]->fields );
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo flamingo_csv_row(
array_merge( $labels, array( __( 'Date', 'flamingo' ) ) )
);
foreach ( $items as $item ) {
echo "\r\n";
$row = array();
foreach ( $labels as $label ) {
$col = isset( $item->fields[$label] ) ? $item->fields[$label] : '';
if ( is_array( $col ) ) {
$col = flamingo_array_flatten( $col );
$col = array_filter( array_map( 'trim', $col ) );
$col = implode( ', ', $col );
}
$row[] = $col;
}
$row[] = get_post_time( 'c', false, $item->id() ); // Date
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo flamingo_csv_row( $row );
}
}
}
/**
* Retrieves text that represents a CSV row.
*/
function flamingo_csv_row( $inputs = array() ) {
$row = array();
foreach ( $inputs as $input ) {
$row[] = apply_filters( 'flamingo_csv_quotation', $input );
}
$separator = apply_filters( 'flamingo_csv_value_separator', ',' );
return implode( $separator, $row );
}
add_filter( 'flamingo_csv_quotation', 'flamingo_csv_quote', 10, 1 );
/**
* Retrieves text that represents a CSV cell with quotation.
*/
function flamingo_csv_quote( $input ) {
$prefix = apply_filters( 'flamingo_csv_field_prefix', '', $input );
$input = trim( sprintf( '%1$s %2$s', $prefix, $input ) );
return sprintf( '"%s"', str_replace( '"', '""', $input ) );
}
add_filter( 'flamingo_csv_field_prefix',
'flamingo_csv_field_prefix_text',
10, 2
);
/**
* Adds a security alert at the head of a cell.
*
* @see https://contactform7.com/2020/01/15/heads-up-about-spreadsheet-vulnerabilities/
*/
function flamingo_csv_field_prefix_text( $prefix, $input ) {
$formula_triggers = array( '=', '+', '-', '@' );
if ( in_array( substr( $input, 0, 1 ), $formula_triggers, true ) ) {
/* translators: %s: URL */
$prefix = __( '(Security Alert: Suspicious content is detected. See %s for details.)', 'flamingo' );
if ( in_array( substr( $prefix, 0, 1 ), $formula_triggers, true ) ) {
$prefix = '\'' . $prefix;
}
$prefix = sprintf(
$prefix,
esc_url( __( 'https://contactform7.com/heads-up-about-spreadsheet-vulnerabilities', 'flamingo' ) )
);
}
return $prefix;
}

View File

@@ -0,0 +1,17 @@
<?php
function flamingo_htmlize( $val ) {
$result = '';
if ( is_array( $val ) ) {
foreach ( $val as $v ) {
$result .= sprintf( '<li>%s</li>', flamingo_htmlize( $v ) );
}
$result = sprintf( '<ul>%s</ul>', $result );
} else {
$result = wpautop( esc_html( (string) $val ) );
}
return apply_filters( 'flamingo_htmlize', $result, $val );
}

View File

@@ -0,0 +1,60 @@
<?php
/**
* Retrieves a URL of a file under the Flamingo plugin directory.
*/
function flamingo_plugin_url( $path = '' ) {
$url = plugins_url( $path, FLAMINGO_PLUGIN );
if ( is_ssl() and 'http:' === substr( $url, 0, 5 ) ) {
$url = 'https:' . substr( $url, 5 );
}
return $url;
}
/**
* Converts a multidimensional array to a flat array.
*/
function flamingo_array_flatten( $input ) {
if ( ! is_array( $input ) ) {
return array( $input );
}
$output = array();
foreach ( $input as $value ) {
$output = array_merge( $output, flamingo_array_flatten( $value ) );
}
return $output;
}
/**
* Moves a spam to the Trash.
*
* @since 2.1
*/
function flamingo_schedule_move_trash() {
// abort if FLAMINGO_MOVE_TRASH_DAYS is set to zero or in minus
if ( (int) FLAMINGO_MOVE_TRASH_DAYS <= 0 ) {
return true;
}
$posts_to_move = Flamingo_Inbound_Message::find( array(
'posts_per_page' => 20,
'meta_key' => '_spam_meta_time',
'meta_value' => time() - ( DAY_IN_SECONDS * FLAMINGO_MOVE_TRASH_DAYS ),
'meta_compare' => '<',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'post_status' => Flamingo_Inbound_Message::spam_status,
) );
foreach ( $posts_to_move as $post ) {
$post->trash();
}
}

View File

@@ -0,0 +1,68 @@
<?php
/**
* Module for WordPress users handling
*/
add_action( 'profile_update', 'flamingo_user_profile_update', 10, 1 );
add_action( 'user_register', 'flamingo_user_profile_update', 10, 1 );
/**
* Creates a Flamingo_Contact record for the given user.
*/
function flamingo_user_profile_update( $user_id ) {
$user = new WP_User( $user_id );
$email = $user->user_email;
$name = $user->display_name;
$props = array(
'first_name' => $user->first_name,
'last_name' => $user->last_name,
);
if ( ! empty( $email ) ) {
Flamingo_Contact::add( array(
'email' => $email,
'name' => $name,
'props' => $props,
'channel' => 'user',
) );
}
}
add_action( 'activate_' . FLAMINGO_PLUGIN_BASENAME,
'flamingo_collect_contacts_from_users',
10, 0
);
/**
* Creates Flamingo_Contact records for existing users.
*/
function flamingo_collect_contacts_from_users() {
$users = get_users( array(
'number' => 20,
) );
foreach ( $users as $user ) {
$email = $user->user_email;
$name = $user->display_name;
if ( empty( $email ) ) {
continue;
}
$props = array(
'first_name' => empty( $user->first_name ) ? '' : $user->first_name,
'last_name' => empty( $user->last_name ) ? '' : $user->last_name,
);
Flamingo_Contact::add( array(
'email' => $email,
'name' => $name,
'props' => $props,
'channel' => 'user',
) );
}
}

View File

@@ -0,0 +1,4 @@
Translations have moved to
https://translate.wordpress.org/projects/wp-plugins/flamingo
Thank you for your contribution.

View File

@@ -0,0 +1,360 @@
Flamingo WordPress Plugin
Copyright (C) 2012-2025 Takayuki Miyoshi 2025 Rock Lobster Inc.
Flamingo is distributed under the terms of the GNU GPL
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@@ -0,0 +1,53 @@
=== Flamingo ===
Contributors: rocklobsterinc, takayukister, megumithemes, itpixelz
Tags: bird, contact, mail, crm
Requires at least: 6.7
Tested up to: 6.9
Stable tag: 2.6.1
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Donate link: https://contactform7.com/donate/
A trustworthy message storage plugin for Contact Form 7.
== Description ==
Flamingo is a message storage plugin originally created for [Contact Form 7](https://wordpress.org/plugins/contact-form-7/), which doesn't store submitted messages.
After activation of the plugin, you'll find **Flamingo** on the WordPress admin screen menu. All messages through contact forms are listed there and are searchable. With Flamingo, you no longer need to worry about losing important messages due to mail server issues or misconfiguration in mail setup.
For more detailed information, please refer to the [Contact Form 7 documentation page](https://contactform7.com/save-submitted-messages-with-flamingo/).
= Privacy Notices =
This plugin stores submission data collected through contact forms, which may include the submitters' personal information, in the database on the server that hosts the website.
== Installation ==
1. Upload the entire `flamingo` folder to the `/wp-content/plugins/` directory.
1. Activate the plugin through the 'Plugins' menu in WordPress.
== Frequently Asked Questions ==
== Screenshots ==
== Changelog ==
= 2.6.1 =
* Updates Node modules.
* Confirmed WordPress 6.9 compatibility.
= 2.6 =
* Bumps up the minimum required WordPress version to 6.7.
* Fixes errors reported by PCP.
* Performs a tune-up for the cron job scheduling.
= 2.5 =
* Bumps up the minimum required WordPress version to 6.4.
* Uses `wp_json_encode()` instead of `json_encode()`.
* Uses `get_views_links()`.
* Uses null coalescing operators.