admin/edit-inbound-form.php 0000666 00000004056 15214117175 0011704 0 ustar 00 id ) ) {
$nonce_action = 'flamingo-update-inbound_' . $post->id;
} else {
$nonce_action = 'flamingo-add-inbound';
}
?>
admin/includes/class-contacts-list-table.php 0000666 00000015525 15214117175 0015152 0 ustar 00 '',
'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;
}
function __construct() {
parent::__construct( array(
'singular' => 'post',
'plural' => 'posts',
'ajax' => false ) );
}
function prepare_items() {
$current_screen = get_current_screen();
$per_page = $this->get_items_per_page( $current_screen->id . '_per_page' );
$this->_column_headers = $this->get_column_info();
$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'] ) && '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::$found_items;
$total_pages = ceil( $total_items / $per_page );
$this->set_pagination_args( array(
'total_items' => $total_items,
'total_pages' => $total_pages,
'per_page' => $per_page ) );
}
function get_columns() {
return get_column_headers( get_current_screen() );
}
function get_sortable_columns() {
$columns = array(
'email' => array( 'email', false ),
'full_name' => array( 'name', false ),
'last_contacted' => array( 'last_contacted', true ) );
return $columns;
}
function get_bulk_actions() {
$actions = array(
'delete' => __( 'Delete', 'flamingo' ) );
return $actions;
}
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 ) && ! is_wp_error( $term ) )
$tag = $term->term_id;
}
?>
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 ) );
submit_button( __( 'Filter', 'flamingo' ),
'secondary', false, false, array( 'id' => 'post-query-submit' ) );
submit_button( __( 'Export', 'flamingo' ), 'secondary', 'export', false );
}
?>
id );
}
function column_cb( $item ) {
return sprintf(
'',
$this->_args['singular'],
$item->id );
}
function column_email( $item ) {
$url = admin_url( 'admin.php?page=flamingo&post=' . absint( $item->id ) );
$edit_link = add_query_arg( array( 'action' => 'edit' ), $url );
$actions = array(
'edit' => '' . __( 'Edit', 'flamingo' ) . '' );
$a = sprintf( '%3$s',
$edit_link,
esc_attr( sprintf( __( 'Edit “%s”', 'flamingo' ), $item->email ) ),
esc_html( $item->email ) );
return '' . $a . ' ' . $this->row_actions( $actions );
}
function column_full_name( $item ) {
return esc_html( $item->name );
}
function column_tags( $item ) {
if ( empty( $item->tags ) )
return __( 'No Tags', 'flamingo' );
$output = '';
foreach ( (array) $item->tags as $tag ) {
$term = get_term_by( 'name', $tag, Flamingo_Contact::contact_tag_taxonomy );
if ( empty( $term ) || is_wp_error( $term ) )
continue;
if ( $output )
$output .= ', ';
$link = admin_url( 'admin.php?page=flamingo&contact_tag_id=' . $term->term_id );
$output .= sprintf( '%3$s',
$link, esc_attr( $term->name ), esc_html( $term->name ) );
}
return $output;
}
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[] = ''
. esc_html( __( 'User', 'flamingo' ) ) . '';
}
// 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( __( 'Comment (%d)', 'flamingo' ), $comment_count ) . '';
}
// Contact channels
$terms = get_terms( Flamingo_Inbound_Message::channel_taxonomy );
if ( ! empty( $terms ) && ! 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::$found_items;
if ( ! $count )
continue;
$link = sprintf( 'admin.php?page=flamingo_inbound&channel=%1$s&s=%2$s',
urlencode( $term->slug ), urlencode( $item->email ) );
$history[] = ''
. sprintf( _x( '%s (%d)', 'contact history', 'flamingo' ), $term->name, $count )
. '';
}
}
$output = '';
foreach ( $history as $item )
$output .= '' . $item . '';
$output = '';
return $output;
}
function column_last_contacted( $item ) {
if ( empty( $item->last_contacted ) )
return '';
$t_time = mysql2date( __( 'Y/m/d g:i:s A', 'flamingo' ), $item->last_contacted, true );
$m_time = $item->last_contacted;
$time = mysql2date( 'G', $item->last_contacted ) - get_option( 'gmt_offset' ) * 3600;
$time_diff = time() - $time;
if ( $time_diff > 0 && $time_diff < 24*60*60 )
$h_time = sprintf( __( '%s ago', 'flamingo' ), human_time_diff( $time ) );
else
$h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
return '' . $h_time . '';
}
}
admin/includes/meta-boxes.php 0000666 00000017532 15214117175 0012237 0 ustar 00
id, $taxonomy->name );
$tag_names = $tag_ids = array();
if ( ! empty( $tags ) && ! 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( Flamingo_Contact::contact_tag_taxonomy, array(
'orderby' => 'count',
'order' => 'DESC',
'number' => 10,
'exclude' => $tag_ids,
'fields' => 'names' ) );
if ( is_wp_error( $most_used_tags ) )
$most_used_tags = array();
?>
fields as $key => $value ) : ?>
|
|
meta as $key => $value ) : ?>
|
|
id ) ) {
if ( ! EMPTY_TRASH_DAYS )
$delete_text = __( 'Delete Permanently', 'flamingo' );
else
$delete_text = __( 'Move to Trash', 'flamingo' );
$delete_link = admin_url(
sprintf( 'admin.php?page=flamingo_outbound&post=%s&action=trash', $post->id ) );
$delete_link = wp_nonce_url( $delete_link, 'flamingo-trash-outbound-message_' . $post->id );
?>
'',
'subject' => __( 'Subject', 'flamingo' ),
'from' => __( 'From', 'flamingo' ),
'channel' => __( 'Channel', 'flamingo' ),
'date' => __( 'Date', 'flamingo' ) );
$columns = apply_filters(
'manage_flamingo_inbound_posts_columns', $columns );
return $columns;
}
function __construct() {
parent::__construct( array(
'singular' => 'post',
'plural' => 'posts',
'ajax' => false ) );
}
function prepare_items() {
$current_screen = get_current_screen();
$per_page = $this->get_items_per_page( $current_screen->id . '_per_page' );
$this->_column_headers = $this->get_column_info();
$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'] ) && '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::$found_items;
$total_pages = ceil( $total_items / $per_page );
$this->set_pagination_args( array(
'total_items' => $total_items,
'total_pages' => $total_pages,
'per_page' => $per_page ) );
}
function get_views() {
$status_links = array();
$post_status = empty( $_REQUEST['post_status'] )
? '' : $_REQUEST['post_status'];
// Inbox
Flamingo_Inbound_Message::find( array( 'post_status' => 'any' ) );
$posts_in_inbox = Flamingo_Inbound_Message::$found_items;
$inbox = sprintf(
_nx( 'Inbox (%s)',
'Inbox (%s)',
$posts_in_inbox, 'posts', 'flamingo' ),
number_format_i18n( $posts_in_inbox ) );
$status_links['inbox'] = sprintf( '%3$s',
admin_url( 'admin.php?page=flamingo_inbound' ),
( $this->is_trash || $this->is_spam ) ? '' : ' class="current"',
$inbox );
// Spam
Flamingo_Inbound_Message::find( array(
'post_status' => Flamingo_Inbound_Message::spam_status ) );
$posts_in_spam = Flamingo_Inbound_Message::$found_items;
$spam = sprintf(
_nx( 'Spam (%s)',
'Spam (%s)',
$posts_in_spam, 'posts', 'flamingo' ),
number_format_i18n( $posts_in_spam ) );
$status_links['spam'] = sprintf( '%3$s',
admin_url( 'admin.php?page=flamingo_inbound&post_status=spam' ),
'spam' == $post_status ? ' class="current"' : '',
$spam );
// Trash
Flamingo_Inbound_Message::find( array( 'post_status' => 'trash' ) );
$posts_in_trash = Flamingo_Inbound_Message::$found_items;
if ( empty( $posts_in_trash ) )
return $status_links;
$trash = sprintf(
_nx( 'Trash (%s)',
'Trash (%s)',
$posts_in_trash, 'posts', 'flamingo' ),
number_format_i18n( $posts_in_trash ) );
$status_links['trash'] = sprintf( '%3$s',
admin_url( 'admin.php?page=flamingo_inbound&post_status=trash' ),
'trash' == $post_status ? ' class="current"' : '',
$trash );
return $status_links;
}
function get_columns() {
return get_column_headers( get_current_screen() );
}
function get_sortable_columns() {
$columns = array(
'subject' => array( 'subject', false ),
'from' => array( 'from', false ),
'date' => array( 'date', true ) );
return $columns;
}
function get_bulk_actions() {
$actions = array();
if ( $this->is_trash ) {
$actions['untrash'] = __( 'Restore', 'flamingo' );
}
if ( $this->is_trash || ! 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;
}
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 ) && ! 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 ) && ! is_wp_error( $term ) )
$channel = $term->term_id;
}
?>
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' => 1,
'hide_empty' => 0,
'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 && ! $this->is_trash ) {
submit_button( __( 'Export', 'flamingo' ),
'secondary', 'export', false );
}
}
if ( $this->is_trash && current_user_can( 'flamingo_delete_inbound_messages' ) ) {
submit_button( __( 'Empty Trash', 'flamingo' ),
'button-secondary apply', 'delete_all', false );
}
?>
id );
}
function column_cb( $item ) {
return sprintf(
'',
$this->_args['singular'],
$item->id );
}
function column_subject( $item ) {
if ( $this->is_trash )
return '' . esc_html( $item->subject ) . '';
$actions = array();
$url = admin_url( 'admin.php?page=flamingo_inbound&post=' . absint( $item->id ) );
$edit_link = add_query_arg( array( 'action' => 'edit' ), $url );
$actions['edit'] = ''
. esc_html( __( 'Edit', 'flamingo' ) ) . '';
if ( $item->spam ) {
$link = add_query_arg( array( 'action' => 'unspam' ), $url );
$link = wp_nonce_url( $link,
'flamingo-unspam-inbound-message_' . $item->id );
$actions['unspam'] = ''
. esc_html( __( 'Not Spam', 'flamingo' ) ) . '';
} else {
$link = add_query_arg( array( 'action' => 'spam' ), $url );
$link = wp_nonce_url( $link, 'flamingo-spam-inbound-message_' . $item->id );
$actions['spam'] = ''
. esc_html( __( 'Spam', 'flamingo' ) ) . '';
}
$a = sprintf( '%3$s',
$edit_link,
esc_attr( sprintf( __( 'Edit “%s”', 'flamingo' ), $item->subject ) ),
esc_html( $item->subject ) );
return '' . $a . ' ' . $this->row_actions( $actions );
}
function column_from( $item ) {
return esc_html( $item->from );
}
function column_channel( $item ) {
if ( empty( $item->channel ) )
return '';
$term = get_term_by( 'slug', $item->channel,
Flamingo_Inbound_Message::channel_taxonomy );
if ( empty( $term ) || 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 ) || is_wp_error( $parent ) )
continue;
$link = admin_url(
'admin.php?page=flamingo_inbound&channel=' . $parent->slug );
$output .= sprintf( '%3$s / ',
$link, esc_attr( $parent->name ), esc_html( $parent->name ) );
}
$link = admin_url( 'admin.php?page=flamingo_inbound&channel=' . $term->slug );
$output .= sprintf( '%3$s',
$link, esc_attr( $term->name ), esc_html( $term->name ) );
return $output;
}
function column_date( $item ) {
$post = get_post( $item->id );
if ( ! $post )
return '';
$t_time = get_the_time( __( 'Y/m/d g:i:s A', 'flamingo' ), $item->id );
$m_time = $post->post_date;
$time = get_post_time( 'G', true, $item->id );
$time_diff = time() - $time;
if ( $time_diff > 0 && $time_diff < 24*60*60 )
$h_time = sprintf( __( '%s ago', 'flamingo' ), human_time_diff( $time ) );
else
$h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
return '' . $h_time . '';
}
}
admin/includes/class-outbound-messages-list-table.php 0000666 00000014021 15214117175 0016766 0 ustar 00 '',
'subject' => __( 'Subject', 'flamingo' ),
'from' => __( 'From', 'flamingo' ),
'date' => __( 'Date', 'flamingo' ) );
$columns = apply_filters(
'manage_flamingo_outbound_posts_columns', $columns );
return $columns;
}
function __construct() {
parent::__construct( array(
'singular' => 'post',
'plural' => 'posts',
'ajax' => false ) );
}
function prepare_items() {
$current_screen = get_current_screen();
$per_page = $this->get_items_per_page( $current_screen->id . '_per_page' );
$this->_column_headers = $this->get_column_info();
$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'] ) && 'asc' == strtolower( $_REQUEST['order'] ) ) {
$args['order'] = 'ASC';
}
if ( ! empty( $_REQUEST['m'] ) ) {
$args['m'] = $_REQUEST['m'];
}
if ( ! empty( $_REQUEST['post_status'] ) ) {
if ( 'trash' == $_REQUEST['post_status'] ) {
$args['post_status'] = 'trash';
$this->is_trash = true;
}
}
$this->items = Flamingo_Outbound_Message::find( $args );
$total_items = Flamingo_Outbound_Message::$found_items;
$total_pages = ceil( $total_items / $per_page );
$this->set_pagination_args( array(
'total_items' => $total_items,
'total_pages' => $total_pages,
'per_page' => $per_page ) );
}
function get_views() {
$status_links = array();
$post_status = empty( $_REQUEST['post_status'] )
? '' : $_REQUEST['post_status'];
// Inbox
Flamingo_Outbound_Message::find( array( 'post_status' => 'any' ) );
$posts_in_inbox = Flamingo_Outbound_Message::$found_items;
$inbox = sprintf(
_nx( 'Inbox (%s)',
'Inbox (%s)',
$posts_in_inbox, 'posts', 'flamingo' ),
number_format_i18n( $posts_in_inbox ) );
$status_links['inbox'] = sprintf( '%3$s',
admin_url( 'admin.php?page=flamingo_outbound' ),
( $this->is_trash ) ? '' : ' class="current"',
$inbox );
// Trash
Flamingo_Outbound_Message::find( array( 'post_status' => 'trash' ) );
$posts_in_trash = Flamingo_Outbound_Message::$found_items;
if ( empty( $posts_in_trash ) )
return $status_links;
$trash = sprintf(
_nx( 'Trash (%s)',
'Trash (%s)',
$posts_in_trash, 'posts', 'flamingo' ),
number_format_i18n( $posts_in_trash ) );
$status_links['trash'] = sprintf( '%3$s',
admin_url( 'admin.php?page=flamingo_outbound&post_status=trash' ),
'trash' == $post_status ? ' class="current"' : '',
$trash );
return $status_links;
}
function get_columns() {
return get_column_headers( get_current_screen() );
}
function get_sortable_columns() {
$columns = array(
'subject' => array( 'subject', false ),
'from' => array( 'from', false ),
'date' => array( 'date', true ) );
return $columns;
}
function get_bulk_actions() {
$actions = array();
if ( $this->is_trash ) {
$actions['untrash'] = __( 'Restore', 'flamingo' );
}
if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) {
$actions['delete'] = __( 'Delete Permanently', 'flamingo' );
} else {
$actions['trash'] = __( 'Move to Trash', 'flamingo' );
}
return $actions;
}
function extra_tablenav( $which ) {
?>
months_dropdown( Flamingo_Outbound_Message::post_type );
submit_button( __( 'Filter', 'flamingo' ),
'secondary', false, false, array( 'id' => 'post-query-submit' ) );
}
if ( $this->is_trash && current_user_can( 'flamingo_delete_outbound_messages' ) ) {
submit_button( __( 'Empty Trash', 'flamingo' ),
'button-secondary apply', 'delete_all', false );
}
?>
id );
}
function column_cb( $item ) {
return sprintf(
'',
$this->_args['singular'],
$item->id );
}
function column_subject( $item ) {
if ( $this->is_trash )
return '' . esc_html( $item->subject ) . '';
$actions = array();
$url = admin_url( 'admin.php?page=flamingo_outbound&post=' . absint( $item->id ) );
$edit_link = add_query_arg( array( 'action' => 'edit' ), $url );
$actions['edit'] = ''
. esc_html( __( 'Edit', 'flamingo' ) ) . '';
$a = sprintf( '%3$s',
$edit_link,
esc_attr( sprintf( __( 'Edit “%s”', 'flamingo' ), $item->subject ) ),
esc_html( $item->subject ) );
return '' . $a . ' ' . $this->row_actions( $actions );
}
function column_from( $item ) {
return esc_html( $item->from );
}
function column_date( $item ) {
$post = get_post( $item->id );
if ( ! $post )
return '';
$t_time = get_the_time( __( 'Y/m/d g:i:s A', 'flamingo' ), $item->id );
$m_time = $post->post_date;
$time = get_post_time( 'G', true, $item->id );
$time_diff = time() - $time;
if ( $time_diff > 0 && $time_diff < 24*60*60 )
$h_time = sprintf( __( '%s ago', 'flamingo' ), human_time_diff( $time ) );
else
$h_time = mysql2date( __( 'Y/m/d', 'flamingo' ), $m_time );
return '' . $h_time . '';
}
}
admin/edit-outbound-form.php 0000666 00000004350 15214117175 0012102 0 ustar 00 id ) ) {
$nonce_action = 'flamingo-update-outbound_' . $post->id;
} else {
$nonce_action = 'flamingo-add-outbound';
}
?>
admin/admin-functions.php 0000666 00000001132 15214117175 0011450 0 ustar 00 posts WHERE post_status = 'trash'"
. $wpdb->prepare( " AND post_type = %s", $post_type );
return $wpdb->get_col( $q );
}
admin/admin.php 0000666 00000051747 15214117175 0007463 0 ustar 00 $current_screen->id ) );
}
/* Updated Message */
add_action( 'flamingo_admin_updated_message', 'flamingo_admin_updated_message' );
function flamingo_admin_updated_message() {
if ( ! empty( $_REQUEST['message'] ) ) {
if ( 'contactupdated' == $_REQUEST['message'] )
$updated_message = esc_html( __( 'Contact updated.', 'flamingo' ) );
elseif ( 'contactdeleted' == $_REQUEST['message'] )
$updated_message = esc_html( __( 'Contact deleted.', 'flamingo' ) );
elseif ( 'inboundtrashed' == $_REQUEST['message'] )
$updated_message = esc_html( __( 'Messages trashed.', 'flamingo' ) );
elseif ( 'inbounduntrashed' == $_REQUEST['message'] )
$updated_message = esc_html( __( 'Messages restored.', 'flamingo' ) );
elseif ( 'inbounddeleted' == $_REQUEST['message'] )
$updated_message = esc_html( __( 'Messages deleted.', 'flamingo' ) );
elseif ( 'inboundspammed' == $_REQUEST['message'] )
$updated_message = esc_html( __( 'Messages got marked as spam.', 'flamingo' ) );
elseif ( 'inboundunspammed' == $_REQUEST['message'] )
$updated_message = esc_html( __( 'Messages got marked as not spam.', 'flamingo' ) );
elseif ( 'outboundupdated' == $_REQUEST['message'] )
$updated_message = esc_html( __( 'Messages updated.', 'flamingo' ) );
else
return;
} else {
return;
}
if ( empty( $updated_message ) ) {
return;
}
?>
id ) ) {
wp_die( __( '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 && ! 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( __( 'You are not allowed to delete this item.', 'flamingo' ) );
}
if ( ! $post->delete() ) {
wp_die( __( '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' );
$sitename = sanitize_key( get_bloginfo( 'name' ) );
$filename = ( empty( $sitename ) ? '' : $sitename . '-' )
. sprintf( 'flamingo-contact-%s.csv', date( 'Y-m-d' ) );
header( 'Content-Description: File Transfer' );
header( "Content-Disposition: attachment; filename=$filename" );
header( 'Content-Type: text/csv; charset=' . get_option( 'blog_charset' ) );
$labels = array(
__( 'Email', 'flamingo' ), __( 'Full name', 'flamingo' ),
__( 'First name', 'flamingo' ), __( 'Last name', 'flamingo' ) );
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'] ) && '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 ) {
$row = array(
$item->email,
$item->get_prop( 'name' ),
$item->get_prop( 'first_name' ),
$item->get_prop( 'last_name' ) );
echo "\r\n" . flamingo_csv_row( $row );
}
exit();
}
if ( ! empty( $_GET['sendmail'] )
&& ! empty( $_REQUEST['contact_tag_id'] ) ) {
$redirect_to = admin_url( 'admin.php?page=flamingo_outbound' );
$redirect_to = add_query_arg( array(
'action' => 'new',
'contact_tag_id' => absint( $_REQUEST['contact_tag_id'] )
), $redirect_to );
wp_safe_redirect( $redirect_to );
exit();
}
$post_id = ! empty( $_REQUEST['post'] ) ? $_REQUEST['post'] : '';
if ( Flamingo_Contact::post_type == get_post_type( $post_id ) ) {
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' ) );
add_screen_option( 'per_page', array(
'label' => __( 'Contacts', 'flamingo' ),
'default' => 20 ) );
}
}
function flamingo_contact_admin_page() {
$action = flamingo_current_action();
$post_id = ! empty( $_REQUEST['post'] ) ? $_REQUEST['post'] : '';
if ( 'edit' == $action
&& Flamingo_Contact::post_type == get_post_type( $post_id ) ) {
flamingo_contact_edit_page();
return;
}
$list_table = new Flamingo_Contacts_List_Table();
$list_table->prepare_items();
?>
'
. __( 'Search results for “%s”', 'flamingo' )
. '', esc_html( $_REQUEST['s'] ) );
}
?>
id ) ) {
wp_die( __( 'You are not allowed to move this item to the Trash.', 'flamingo' ) );
}
if ( ! $post->trash() ) {
wp_die( __( '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 && ! 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( __( 'You are not allowed to restore this item from the Trash.', 'flamingo' ) );
}
if ( ! $post->untrash() ) {
wp_die( __( '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 && ! 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( __( 'You are not allowed to delete this item.', 'flamingo' ) );
}
if ( ! $post->delete() ) {
wp_die( __( '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 && ! 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( __( '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 && ! 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( __( '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' );
$sitename = sanitize_key( get_bloginfo( 'name' ) );
$filename = ( empty( $sitename ) ? '' : $sitename . '-' )
. sprintf( 'flamingo-inbound-%s.csv', date( 'Y-m-d' ) );
header( 'Content-Description: File Transfer' );
header( "Content-Disposition: attachment; filename=$filename" );
header( 'Content-Type: text/csv; charset=' . get_option( 'blog_charset' ) );
$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'] )
&& '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 ) ) {
exit();
}
$labels = array_keys( $items[0]->fields );
$labels[] = __( 'Date', 'flamingo' );
echo flamingo_csv_row( $labels );
foreach ( $items as $item ) {
$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', true, $item->id );
echo "\r\n" . flamingo_csv_row( $row );
}
exit();
}
$post_id = ! empty( $_REQUEST['post'] ) ? $_REQUEST['post'] : '';
if ( Flamingo_Inbound_Message::post_type == get_post_type( $post_id ) ) {
add_meta_box( 'submitdiv', __( 'Save', 'flamingo' ),
'flamingo_inbound_submit_meta_box', null, 'side', 'core' );
add_meta_box( 'inboundfieldsdiv', __( 'Fields', 'flamingo' ),
'flamingo_inbound_fields_meta_box', null, 'normal', 'core' );
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' ) );
add_screen_option( 'per_page', array(
'label' => __( 'Messages', 'flamingo' ),
'default' => 20 ) );
}
}
function flamingo_inbound_admin_page() {
$action = flamingo_current_action();
$post_id = ! empty( $_REQUEST['post'] ) ? $_REQUEST['post'] : '';
if ( 'edit' == $action && Flamingo_Inbound_Message::post_type == get_post_type( $post_id ) ) {
flamingo_inbound_edit_page();
return;
}
$list_table = new Flamingo_Inbound_Messages_List_Table();
$list_table->prepare_items();
?>
'
. __( 'Search results for “%s”', 'flamingo' )
. '', esc_html( $_REQUEST['s'] ) );
}
?>
views(); ?>
save();
$redirect_to = add_query_arg( array(
'action' => 'edit',
//'post' => $post->id,
'message' => 'outboundupdated' ), $redirect_to );
wp_safe_redirect( $redirect_to );
exit();
}
if ( 'new' == $action ) {
add_meta_box( 'submitdiv', __( 'Send', 'flamingo' ),
'flamingo_outbound_submit_meta_box', null, 'side', 'core' );
} else {
if ( ! class_exists( 'Flamingo_Outbound_Messages_List_Table' ) )
require_once FLAMINGO_PLUGIN_DIR . '/admin/includes/class-outbound-messages-list-table.php';
$current_screen = get_current_screen();
add_filter( 'manage_' . $current_screen->id . '_columns',
array( 'Flamingo_Outbound_Messages_List_Table', 'define_columns' ) );
add_screen_option( 'per_page', array(
'label' => __( 'Messages', 'flamingo' ),
'default' => 20 ) );
}
}
function flamingo_outbound_admin_page() {
$action = flamingo_current_action();
$post_id = ! empty( $_REQUEST['post'] ) ? $_REQUEST['post'] : '';
if ( 'new' == $action ) {
flamingo_outbound_edit_page();
return;
}
$list_table = new Flamingo_Outbound_Messages_List_Table();
$list_table->prepare_items();
?>
'
. __( 'Search results for “%s”', 'flamingo' )
. '', esc_html( $_REQUEST['s'] ) );
}
?>
views(); ?>
id ) ) {
$nonce_action = 'flamingo-update-contact_' . $post->id;
} else {
$nonce_action = 'flamingo-add-contact';
}
?>
admin/script.js 0000666 00000000143 15214117175 0007504 0 ustar 00 (function($) {
$(function() {
postboxes.add_postbox_toggles(_flamingo.screenId);
});
})(jQuery); admin/style.css 0000666 00000001301 15214117175 0007511 0 ustar 00 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 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: 1px 8px 0 0;
}
languages/readme.txt 0000666 00000000172 15214117175 0010520 0 ustar 00 Translations have moved to
https://translate.wordpress.org/projects/wp-plugins/flamingo
Thank you for your contribution.
readme.txt 0000666 00000003171 15214117175 0006554 0 ustar 00 === Flamingo ===
Contributors: takayukister, megumithemes
Tags: bird, contact, mail, crm
Requires at least: 4.5
Tested up to: 4.7
Stable tag: 1.5
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
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 are 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](http://contactform7.com/save-submitted-messages-with-flamingo/).
== 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 ==
= 1.5 =
* Tested up to WordPress 4.7.
* Requires WordPress 4.5 or higher.
* count() method added to Flamingo_Inbound_Message class.
* All language files in the languages folder were removed. Translations have moved to translate.wordpress.org.
= 1.4 =
* Tested up to WordPress 4.5.1.
* Requires WordPress 4.4 or higher.
* Added "Meta" meta-box to the Inbound Message screen.
* Language packs for German, Hebrew, and Japanese are removed because those are available from translate.wordpress.org.
includes/class-inbound-message.php 0000666 00000017036 15214117175 0013265 0 ustar 00 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 );
$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' );
}
$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 = '' ) {
$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 = '' ) {
$defaults = array(
'channel' => '',
'subject' => '',
'from' => '',
'from_name' => '',
'from_email' => '',
'fields' => array(),
'meta' => array(),
'akismet' => array(),
'spam' => false );
$args = wp_parse_args( $args, $defaults );
$obj = new self();
$obj->channel = $args['channel'];
$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'];
if ( $args['spam'] ) {
$obj->spam = true;
} else {
$obj->spam = isset( $obj->akismet['spam'] ) && $obj->akismet['spam'];
}
$obj->save();
return $obj;
}
public function __construct( $post = null ) {
if ( ! empty( $post ) && ( $post = get_post( $post ) ) ) {
$this->id = $post->ID;
$this->date = get_the_time( __( 'Y/m/d g:i:s A', 'flamingo' ), $this->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->meta = get_post_meta( $post->ID, '_meta', true );
$this->akismet = get_post_meta( $post->ID, '_akismet', true );
$terms = wp_get_object_terms( $this->id, self::channel_taxonomy );
if ( ! empty( $terms ) && ! 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'];
}
}
}
public function save() {
if ( ! empty( $this->subject ) )
$post_title = $this->subject;
else
$post_title = __( '(No Title)', 'flamingo' );
$fields = flamingo_array_flatten( $this->fields );
$fields = array_filter( array_map( 'trim', $fields ) );
$post_content = implode( "\n", $fields );
$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_id = wp_insert_post( $postarr );
if ( $post_id ) {
$this->id = $post_id;
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 );
if ( term_exists( $this->channel, self::channel_taxonomy ) )
wp_set_object_terms( $this->id, $this->channel, self::channel_taxonomy );
}
return $post_id;
}
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;
return $this->save();
}
public function akismet_submit_spam() {
if ( empty( $this->id ) || empty( $this->akismet ) )
return;
if ( isset( $this->akismet['spam'] ) && $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 ) || empty( $this->akismet ) )
return;
if ( isset( $this->akismet['spam'] ) && ! $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;
}
}
}
includes/user.php 0000666 00000002361 15214117175 0010053 0 ustar 00 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' ) );
}
}
/* Collect contact info from existing users when activating plugin */
add_action( 'activate_' . FLAMINGO_PLUGIN_BASENAME, 'flamingo_collect_contacts_from_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' ) );
}
}
includes/comment.php 0000666 00000002612 15214117175 0010536 0 ustar 00 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 );
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' ) );
}
/* Collect contact info from existing comments when activating plugin */
add_action( 'activate_' . FLAMINGO_PLUGIN_BASENAME,
'flamingo_collect_contacts_from_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' ) );
}
}
includes/capabilities.php 0000666 00000001636 15214117175 0011532 0 ustar 00 'edit_users',
'flamingo_edit_contact' => 'edit_users',
'flamingo_delete_contact' => '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',
'flamingo_edit_outbound_messages' => 'edit_users',
'flamingo_edit_outbound_message' => 'edit_users',
'flamingo_delete_outbound_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;
}
includes/formatting.php 0000666 00000001043 15214117175 0011243 0 ustar 00 ' . flamingo_htmlize( $v ) . '';
}
return '';
}
return wpautop( esc_html( (string) $val ) );
}
function flamingo_csv_row( $inputs = array() ) {
$row = array();
foreach ( $inputs as $input ) {
$input = preg_replace( '/(?