Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/contact-.../modules
File: flamingo.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
** Module for Flamingo plugin.
[2] Fix | Delete
** http://wordpress.org/extend/plugins/flamingo/
[3] Fix | Delete
**/
[4] Fix | Delete
[5] Fix | Delete
add_action( 'wpcf7_submit', 'wpcf7_flamingo_submit', 10, 2 );
[6] Fix | Delete
[7] Fix | Delete
function wpcf7_flamingo_submit( $contact_form, $result ) {
[8] Fix | Delete
if ( ! class_exists( 'Flamingo_Contact' )
[9] Fix | Delete
or ! class_exists( 'Flamingo_Inbound_Message' ) ) {
[10] Fix | Delete
return;
[11] Fix | Delete
}
[12] Fix | Delete
[13] Fix | Delete
if ( $contact_form->in_demo_mode() ) {
[14] Fix | Delete
return;
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
$cases = (array) apply_filters( 'wpcf7_flamingo_submit_if',
[18] Fix | Delete
array( 'spam', 'mail_sent', 'mail_failed' )
[19] Fix | Delete
);
[20] Fix | Delete
[21] Fix | Delete
if ( empty( $result['status'] )
[22] Fix | Delete
or ! in_array( $result['status'], $cases ) ) {
[23] Fix | Delete
return;
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
$submission = WPCF7_Submission::get_instance();
[27] Fix | Delete
[28] Fix | Delete
if ( ! $submission
[29] Fix | Delete
or ! $posted_data = $submission->get_posted_data() ) {
[30] Fix | Delete
return;
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
if ( $submission->get_meta( 'do_not_store' ) ) {
[34] Fix | Delete
return;
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
// Exclude do-not-store form-tag values.
[38] Fix | Delete
$posted_data = array_filter(
[39] Fix | Delete
$posted_data,
[40] Fix | Delete
static function ( $name ) use ( $contact_form ) {
[41] Fix | Delete
return ! $contact_form->scan_form_tags( array(
[42] Fix | Delete
'name' => $name,
[43] Fix | Delete
'feature' => 'do-not-store',
[44] Fix | Delete
) );
[45] Fix | Delete
},
[46] Fix | Delete
ARRAY_FILTER_USE_KEY
[47] Fix | Delete
);
[48] Fix | Delete
[49] Fix | Delete
$email = wpcf7_flamingo_get_value( 'email', $contact_form );
[50] Fix | Delete
$name = wpcf7_flamingo_get_value( 'name', $contact_form );
[51] Fix | Delete
$subject = wpcf7_flamingo_get_value( 'subject', $contact_form );
[52] Fix | Delete
[53] Fix | Delete
$meta = array();
[54] Fix | Delete
[55] Fix | Delete
$special_mail_tags = array( 'serial_number', 'remote_ip',
[56] Fix | Delete
'user_agent', 'url', 'date', 'time', 'post_id', 'post_name',
[57] Fix | Delete
'post_title', 'post_url', 'post_author', 'post_author_email',
[58] Fix | Delete
'site_title', 'site_description', 'site_url', 'site_admin_email',
[59] Fix | Delete
'user_login', 'user_email', 'user_display_name',
[60] Fix | Delete
);
[61] Fix | Delete
[62] Fix | Delete
foreach ( $special_mail_tags as $smt ) {
[63] Fix | Delete
$tagname = sprintf( '_%s', $smt );
[64] Fix | Delete
[65] Fix | Delete
$mail_tag = new WPCF7_MailTag(
[66] Fix | Delete
sprintf( '[%s]', $tagname ),
[67] Fix | Delete
$tagname,
[68] Fix | Delete
''
[69] Fix | Delete
);
[70] Fix | Delete
[71] Fix | Delete
$meta[$smt] = apply_filters( 'wpcf7_special_mail_tags', null,
[72] Fix | Delete
$tagname, false, $mail_tag
[73] Fix | Delete
);
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
$timestamp = $submission->get_meta( 'timestamp' );
[77] Fix | Delete
[78] Fix | Delete
if ( $timestamp and $datetime = date_create( '@' . $timestamp ) ) {
[79] Fix | Delete
$datetime->setTimezone( wp_timezone() );
[80] Fix | Delete
$last_contacted = $datetime->format( 'Y-m-d H:i:s' );
[81] Fix | Delete
} else {
[82] Fix | Delete
$last_contacted = '0000-00-00 00:00:00';
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
if ( 'mail_sent' == $result['status'] ) {
[86] Fix | Delete
$flamingo_contact = Flamingo_Contact::add( array(
[87] Fix | Delete
'email' => $email,
[88] Fix | Delete
'name' => $name,
[89] Fix | Delete
'last_contacted' => $last_contacted,
[90] Fix | Delete
) );
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
$post_meta = get_post_meta( $contact_form->id(), '_flamingo', true );
[94] Fix | Delete
[95] Fix | Delete
$channel_id = isset( $post_meta['channel'] )
[96] Fix | Delete
? (int) $post_meta['channel']
[97] Fix | Delete
: wpcf7_flamingo_add_channel(
[98] Fix | Delete
$contact_form->name(),
[99] Fix | Delete
$contact_form->title()
[100] Fix | Delete
);
[101] Fix | Delete
[102] Fix | Delete
if ( $channel_id ) {
[103] Fix | Delete
if ( ! isset( $post_meta['channel'] )
[104] Fix | Delete
or $post_meta['channel'] !== $channel_id ) {
[105] Fix | Delete
$post_meta = empty( $post_meta ) ? array() : (array) $post_meta;
[106] Fix | Delete
$post_meta = array_merge( $post_meta, array(
[107] Fix | Delete
'channel' => $channel_id,
[108] Fix | Delete
) );
[109] Fix | Delete
[110] Fix | Delete
update_post_meta( $contact_form->id(), '_flamingo', $post_meta );
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
$channel = get_term( $channel_id,
[114] Fix | Delete
Flamingo_Inbound_Message::channel_taxonomy
[115] Fix | Delete
);
[116] Fix | Delete
[117] Fix | Delete
if ( ! $channel or is_wp_error( $channel ) ) {
[118] Fix | Delete
$channel = 'contact-form-7';
[119] Fix | Delete
} else {
[120] Fix | Delete
$channel = $channel->slug;
[121] Fix | Delete
}
[122] Fix | Delete
} else {
[123] Fix | Delete
$channel = 'contact-form-7';
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
$args = array(
[127] Fix | Delete
'channel' => $channel,
[128] Fix | Delete
'status' => $submission->get_status(),
[129] Fix | Delete
'subject' => $subject,
[130] Fix | Delete
'from' => trim( sprintf( '%s <%s>', $name, $email ) ),
[131] Fix | Delete
'from_name' => $name,
[132] Fix | Delete
'from_email' => $email,
[133] Fix | Delete
'fields' => $posted_data,
[134] Fix | Delete
'meta' => $meta,
[135] Fix | Delete
'akismet' => $submission->pull( 'akismet' ),
[136] Fix | Delete
'spam' => ( 'spam' == $result['status'] ),
[137] Fix | Delete
'consent' => $submission->collect_consent(),
[138] Fix | Delete
'timestamp' => $timestamp,
[139] Fix | Delete
'posted_data_hash' => $submission->get_posted_data_hash(),
[140] Fix | Delete
);
[141] Fix | Delete
[142] Fix | Delete
if ( $args['spam'] ) {
[143] Fix | Delete
$args['spam_log'] = $submission->get_spam_log();
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
$args['recaptcha'] = $submission->pull( 'recaptcha' );
[147] Fix | Delete
[148] Fix | Delete
$args = apply_filters( 'wpcf7_flamingo_inbound_message_parameters', $args );
[149] Fix | Delete
[150] Fix | Delete
$flamingo_inbound = Flamingo_Inbound_Message::add( $args );
[151] Fix | Delete
[152] Fix | Delete
if ( empty( $flamingo_contact ) ) {
[153] Fix | Delete
$flamingo_contact_id = 0;
[154] Fix | Delete
} elseif ( method_exists( $flamingo_contact, 'id' ) ) {
[155] Fix | Delete
$flamingo_contact_id = $flamingo_contact->id();
[156] Fix | Delete
} else {
[157] Fix | Delete
$flamingo_contact_id = $flamingo_contact->id;
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
if ( empty( $flamingo_inbound ) ) {
[161] Fix | Delete
$flamingo_inbound_id = 0;
[162] Fix | Delete
} elseif ( method_exists( $flamingo_inbound, 'id' ) ) {
[163] Fix | Delete
$flamingo_inbound_id = $flamingo_inbound->id();
[164] Fix | Delete
} else {
[165] Fix | Delete
$flamingo_inbound_id = $flamingo_inbound->id;
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
$result += array(
[169] Fix | Delete
'flamingo_contact_id' => absint( $flamingo_contact_id ),
[170] Fix | Delete
'flamingo_inbound_id' => absint( $flamingo_inbound_id ),
[171] Fix | Delete
);
[172] Fix | Delete
[173] Fix | Delete
do_action( 'wpcf7_after_flamingo', $result );
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
function wpcf7_flamingo_get_value( $field, $contact_form ) {
[177] Fix | Delete
if ( empty( $field )
[178] Fix | Delete
or empty( $contact_form ) ) {
[179] Fix | Delete
return false;
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
$value = '';
[183] Fix | Delete
[184] Fix | Delete
if ( in_array( $field, array( 'email', 'name', 'subject' ) ) ) {
[185] Fix | Delete
$template = $contact_form->pref( 'flamingo_' . $field );
[186] Fix | Delete
[187] Fix | Delete
if ( null === $template ) {
[188] Fix | Delete
$template = sprintf( '[your-%s]', $field );
[189] Fix | Delete
} else {
[190] Fix | Delete
$template = trim( wpcf7_strip_quote( $template ) );
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
$value = wpcf7_mail_replace_tags( $template );
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
$value = apply_filters( 'wpcf7_flamingo_get_value', $value,
[197] Fix | Delete
$field, $contact_form
[198] Fix | Delete
);
[199] Fix | Delete
[200] Fix | Delete
return $value;
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
function wpcf7_flamingo_add_channel( $slug, $name = '' ) {
[204] Fix | Delete
if ( ! class_exists( 'Flamingo_Inbound_Message' ) ) {
[205] Fix | Delete
return false;
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
$parent = term_exists( 'contact-form-7',
[209] Fix | Delete
Flamingo_Inbound_Message::channel_taxonomy
[210] Fix | Delete
);
[211] Fix | Delete
[212] Fix | Delete
if ( ! $parent ) {
[213] Fix | Delete
$parent = wp_insert_term( __( 'Contact Form 7', 'contact-form-7' ),
[214] Fix | Delete
Flamingo_Inbound_Message::channel_taxonomy,
[215] Fix | Delete
array( 'slug' => 'contact-form-7' )
[216] Fix | Delete
);
[217] Fix | Delete
[218] Fix | Delete
if ( is_wp_error( $parent ) ) {
[219] Fix | Delete
return false;
[220] Fix | Delete
}
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
$parent = (int) $parent['term_id'];
[224] Fix | Delete
[225] Fix | Delete
if ( ! is_taxonomy_hierarchical( Flamingo_Inbound_Message::channel_taxonomy ) ) {
[226] Fix | Delete
// backward compat for Flamingo 1.0.4 and lower
[227] Fix | Delete
return $parent;
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
if ( empty( $name ) ) {
[231] Fix | Delete
$name = $slug;
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
$channel = term_exists( $slug,
[235] Fix | Delete
Flamingo_Inbound_Message::channel_taxonomy,
[236] Fix | Delete
$parent
[237] Fix | Delete
);
[238] Fix | Delete
[239] Fix | Delete
if ( ! $channel ) {
[240] Fix | Delete
$channel = wp_insert_term( $name,
[241] Fix | Delete
Flamingo_Inbound_Message::channel_taxonomy,
[242] Fix | Delete
array( 'slug' => $slug, 'parent' => $parent )
[243] Fix | Delete
);
[244] Fix | Delete
[245] Fix | Delete
if ( is_wp_error( $channel ) ) {
[246] Fix | Delete
return false;
[247] Fix | Delete
}
[248] Fix | Delete
}
[249] Fix | Delete
[250] Fix | Delete
return (int) $channel['term_id'];
[251] Fix | Delete
}
[252] Fix | Delete
[253] Fix | Delete
add_action( 'wpcf7_after_update', 'wpcf7_flamingo_update_channel', 10, 1 );
[254] Fix | Delete
[255] Fix | Delete
function wpcf7_flamingo_update_channel( $contact_form ) {
[256] Fix | Delete
if ( ! class_exists( 'Flamingo_Inbound_Message' ) ) {
[257] Fix | Delete
return false;
[258] Fix | Delete
}
[259] Fix | Delete
[260] Fix | Delete
$post_meta = get_post_meta( $contact_form->id(), '_flamingo', true );
[261] Fix | Delete
[262] Fix | Delete
$channel = isset( $post_meta['channel'] )
[263] Fix | Delete
? get_term( $post_meta['channel'],
[264] Fix | Delete
Flamingo_Inbound_Message::channel_taxonomy
[265] Fix | Delete
)
[266] Fix | Delete
: get_term_by( 'slug', $contact_form->name(),
[267] Fix | Delete
Flamingo_Inbound_Message::channel_taxonomy
[268] Fix | Delete
);
[269] Fix | Delete
[270] Fix | Delete
if ( ! $channel or is_wp_error( $channel ) ) {
[271] Fix | Delete
return;
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
if ( $channel->name !== wp_unslash( $contact_form->title() ) ) {
[275] Fix | Delete
wp_update_term( $channel->term_id,
[276] Fix | Delete
Flamingo_Inbound_Message::channel_taxonomy,
[277] Fix | Delete
array(
[278] Fix | Delete
'name' => $contact_form->title(),
[279] Fix | Delete
'slug' => $contact_form->name(),
[280] Fix | Delete
'parent' => $channel->parent,
[281] Fix | Delete
)
[282] Fix | Delete
);
[283] Fix | Delete
}
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
[287] Fix | Delete
add_filter( 'wpcf7_special_mail_tags', 'wpcf7_flamingo_serial_number', 10, 4 );
[288] Fix | Delete
[289] Fix | Delete
/**
[290] Fix | Delete
* Returns output string of a special mail-tag.
[291] Fix | Delete
*
[292] Fix | Delete
* @param string $output The string to be output.
[293] Fix | Delete
* @param string $name The tag name of the special mail-tag.
[294] Fix | Delete
* @param bool $html Whether the mail-tag is used in an HTML content.
[295] Fix | Delete
* @param WPCF7_MailTag $mail_tag An object representation of the mail-tag.
[296] Fix | Delete
* @return string Output of the given special mail-tag.
[297] Fix | Delete
*/
[298] Fix | Delete
function wpcf7_flamingo_serial_number( $output, $name, $html, $mail_tag = null ) {
[299] Fix | Delete
if ( ! $mail_tag instanceof WPCF7_MailTag ) {
[300] Fix | Delete
wpcf7_doing_it_wrong(
[301] Fix | Delete
sprintf( '%s()', __FUNCTION__ ),
[302] Fix | Delete
__( 'The fourth parameter ($mail_tag) must be an instance of the WPCF7_MailTag class.', 'contact-form-7' ),
[303] Fix | Delete
'5.2.2'
[304] Fix | Delete
);
[305] Fix | Delete
}
[306] Fix | Delete
[307] Fix | Delete
if ( '_serial_number' != $name ) {
[308] Fix | Delete
return $output;
[309] Fix | Delete
}
[310] Fix | Delete
[311] Fix | Delete
if ( ! class_exists( 'Flamingo_Inbound_Message' )
[312] Fix | Delete
or ! method_exists( 'Flamingo_Inbound_Message', 'count' ) ) {
[313] Fix | Delete
return $output;
[314] Fix | Delete
}
[315] Fix | Delete
[316] Fix | Delete
if ( ! $contact_form = WPCF7_ContactForm::get_current() ) {
[317] Fix | Delete
return $output;
[318] Fix | Delete
}
[319] Fix | Delete
[320] Fix | Delete
$post_meta = get_post_meta( $contact_form->id(), '_flamingo', true );
[321] Fix | Delete
[322] Fix | Delete
$channel_id = isset( $post_meta['channel'] )
[323] Fix | Delete
? (int) $post_meta['channel']
[324] Fix | Delete
: wpcf7_flamingo_add_channel(
[325] Fix | Delete
$contact_form->name(), $contact_form->title()
[326] Fix | Delete
);
[327] Fix | Delete
[328] Fix | Delete
if ( $channel_id ) {
[329] Fix | Delete
return 1 + (int) Flamingo_Inbound_Message::count(
[330] Fix | Delete
array( 'channel_id' => $channel_id )
[331] Fix | Delete
);
[332] Fix | Delete
}
[333] Fix | Delete
[334] Fix | Delete
return 0;
[335] Fix | Delete
}
[336] Fix | Delete
[337] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function