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

comment.php in Flamingo 2.1, at includes/comment.php

66 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 ** Module for WordPress comment.
4 **/
5
6 add_action( 'wp_insert_comment', 'flamingo_insert_comment' );
7
8 function flamingo_insert_comment( $comment_id ) {
9 $comment = get_comment( $comment_id );
10
11 if ( 1 != (int) $comment->comment_approved ) {
12 return;
13 }
14
15 Flamingo_Contact::add( array(
16 'email' => $comment->comment_author_email,
17 'name' => $comment->comment_author,
18 'channel' => 'comment',
19 ) );
20 }
21
22 add_action( 'transition_comment_status',
23 'flamingo_transition_comment_status', 10, 3 );
24
25 function flamingo_transition_comment_status( $new_status, $old_status, $comment ) {
26 if ( 'approved' != $new_status ) {
27 return;
28 }
29
30 $email = $comment->comment_author_email;
31 $name = $comment->comment_author;
32
33 Flamingo_Contact::add( array(
34 'email' => $email,
35 'name' => $name,
36 'channel' => 'comment',
37 ) );
38 }
39
40 /* Collect contact info from existing comments when activating plugin */
41 add_action( 'activate_' . FLAMINGO_PLUGIN_BASENAME,
42 'flamingo_collect_contacts_from_comments' );
43
44 function flamingo_collect_contacts_from_comments() {
45 $comments = get_comments( array(
46 'status' => 'approve',
47 'type' => 'comment',
48 'number' => 20,
49 ) );
50
51 foreach ( $comments as $comment ) {
52 $email = $comment->comment_author_email;
53 $name = $comment->comment_author;
54
55 if ( empty( $email ) ) {
56 continue;
57 }
58
59 Flamingo_Contact::add( array(
60 'email' => $email,
61 'name' => $name,
62 'channel' => 'comment',
63 ) );
64 }
65 }
66