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/clone/wp-conte.../plugins/contact-.../modules/constant...
File: contact-post-request.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class WPCF7_ConstantContact_ContactPostRequest {
[2] Fix | Delete
[3] Fix | Delete
private $email_address;
[4] Fix | Delete
private $first_name;
[5] Fix | Delete
private $last_name;
[6] Fix | Delete
private $job_title;
[7] Fix | Delete
private $company_name;
[8] Fix | Delete
private $create_source;
[9] Fix | Delete
private $birthday_month;
[10] Fix | Delete
private $birthday_day;
[11] Fix | Delete
private $anniversary;
[12] Fix | Delete
private $custom_fields = array();
[13] Fix | Delete
private $phone_numbers = array();
[14] Fix | Delete
private $street_addresses = array();
[15] Fix | Delete
private $list_memberships = array();
[16] Fix | Delete
[17] Fix | Delete
public function __construct() {
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
public function build( WPCF7_Submission $submission ) {
[21] Fix | Delete
$this->set_create_source( 'Contact' );
[22] Fix | Delete
[23] Fix | Delete
$this->set_first_name(
[24] Fix | Delete
$submission->get_posted_string( 'your-first-name' )
[25] Fix | Delete
);
[26] Fix | Delete
[27] Fix | Delete
$this->set_last_name(
[28] Fix | Delete
$submission->get_posted_string( 'your-last-name' )
[29] Fix | Delete
);
[30] Fix | Delete
[31] Fix | Delete
if ( ! ( $this->first_name || $this->last_name )
[32] Fix | Delete
and $your_name = $submission->get_posted_string( 'your-name' ) ) {
[33] Fix | Delete
$your_name = preg_split( '/[\s]+/', $your_name, 2 );
[34] Fix | Delete
$this->set_first_name( array_shift( $your_name ) );
[35] Fix | Delete
$this->set_last_name( array_shift( $your_name ) );
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
$this->set_email_address(
[39] Fix | Delete
$submission->get_posted_string( 'your-email' ),
[40] Fix | Delete
'implicit'
[41] Fix | Delete
);
[42] Fix | Delete
[43] Fix | Delete
$this->set_job_title(
[44] Fix | Delete
$submission->get_posted_string( 'your-job-title' )
[45] Fix | Delete
);
[46] Fix | Delete
[47] Fix | Delete
$this->set_company_name(
[48] Fix | Delete
$submission->get_posted_string( 'your-company-name' )
[49] Fix | Delete
);
[50] Fix | Delete
[51] Fix | Delete
$this->set_birthday(
[52] Fix | Delete
$submission->get_posted_string( 'your-birthday-month' ),
[53] Fix | Delete
$submission->get_posted_string( 'your-birthday-day' )
[54] Fix | Delete
);
[55] Fix | Delete
[56] Fix | Delete
if ( ! ( $this->birthday_month && $this->birthday_day ) ) {
[57] Fix | Delete
$date = $submission->get_posted_string( 'your-birthday' );
[58] Fix | Delete
[59] Fix | Delete
if ( preg_match( '/^(\d{4})-(\d{2})-(\d{2})$/', $date, $matches ) ) {
[60] Fix | Delete
$this->set_birthday( $matches[2], $matches[3] );
[61] Fix | Delete
}
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
$this->set_anniversary(
[65] Fix | Delete
$submission->get_posted_string( 'your-anniversary' )
[66] Fix | Delete
);
[67] Fix | Delete
[68] Fix | Delete
$this->add_phone_number(
[69] Fix | Delete
$submission->get_posted_string( 'your-phone-number' )
[70] Fix | Delete
);
[71] Fix | Delete
[72] Fix | Delete
$this->add_street_address(
[73] Fix | Delete
$submission->get_posted_string( 'your-address-street' ),
[74] Fix | Delete
$submission->get_posted_string( 'your-address-city' ),
[75] Fix | Delete
$submission->get_posted_string( 'your-address-state' ),
[76] Fix | Delete
$submission->get_posted_string( 'your-address-postal-code' ),
[77] Fix | Delete
$submission->get_posted_string( 'your-address-country' )
[78] Fix | Delete
);
[79] Fix | Delete
[80] Fix | Delete
$service_option = (array) WPCF7::get_option( 'constant_contact' );
[81] Fix | Delete
[82] Fix | Delete
$contact_lists = isset( $service_option['contact_lists'] )
[83] Fix | Delete
? $service_option['contact_lists'] : array();
[84] Fix | Delete
[85] Fix | Delete
$contact_form = $submission->get_contact_form();
[86] Fix | Delete
[87] Fix | Delete
$prop = $contact_form->prop( 'constant_contact' );
[88] Fix | Delete
[89] Fix | Delete
if ( ! empty( $prop['enable_contact_list'] )
[90] Fix | Delete
and ! empty( $prop['contact_lists'] ) ) {
[91] Fix | Delete
foreach ( (array) $prop['contact_lists'] as $list_id ) {
[92] Fix | Delete
$this->add_list_membership( $list_id );
[93] Fix | Delete
}
[94] Fix | Delete
}
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
public function is_valid() {
[98] Fix | Delete
return $this->create_source
[99] Fix | Delete
&& ( $this->email_address || $this->first_name || $this->last_name );
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
public function to_array() {
[103] Fix | Delete
$output = array(
[104] Fix | Delete
'email_address' => $this->email_address,
[105] Fix | Delete
'first_name' => $this->first_name,
[106] Fix | Delete
'last_name' => $this->last_name,
[107] Fix | Delete
'job_title' => $this->job_title,
[108] Fix | Delete
'company_name' => $this->company_name,
[109] Fix | Delete
'create_source' => $this->create_source,
[110] Fix | Delete
'birthday_month' => $this->birthday_month,
[111] Fix | Delete
'birthday_day' => $this->birthday_day,
[112] Fix | Delete
'anniversary' => $this->anniversary,
[113] Fix | Delete
'custom_fields' => $this->custom_fields,
[114] Fix | Delete
'phone_numbers' => $this->phone_numbers,
[115] Fix | Delete
'street_addresses' => $this->street_addresses,
[116] Fix | Delete
'list_memberships' => $this->list_memberships,
[117] Fix | Delete
);
[118] Fix | Delete
[119] Fix | Delete
return array_filter( $output );
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
public function get_email_address() {
[123] Fix | Delete
if ( isset( $this->email_address['address'] ) ) {
[124] Fix | Delete
return $this->email_address['address'];
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
return '';
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
public function set_email_address( $address, $permission_to_send = '' ) {
[131] Fix | Delete
if ( ! wpcf7_is_email( $address )
[132] Fix | Delete
or 80 < $this->strlen( $address ) ) {
[133] Fix | Delete
return false;
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
$types_of_permission = array(
[137] Fix | Delete
'implicit', 'explicit', 'deprecate', 'pending',
[138] Fix | Delete
'unsubscribe', 'temp_hold', 'not_set',
[139] Fix | Delete
);
[140] Fix | Delete
[141] Fix | Delete
if ( ! in_array( $permission_to_send, $types_of_permission ) ) {
[142] Fix | Delete
$permission_to_send = 'implicit';
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
return $this->email_address = array(
[146] Fix | Delete
'address' => $address,
[147] Fix | Delete
'permission_to_send' => $permission_to_send,
[148] Fix | Delete
);
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
public function set_first_name( $first_name ) {
[152] Fix | Delete
$first_name = trim( $first_name );
[153] Fix | Delete
[154] Fix | Delete
if ( empty( $first_name )
[155] Fix | Delete
or 50 < $this->strlen( $first_name ) ) {
[156] Fix | Delete
return false;
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
return $this->first_name = $first_name;
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
public function set_last_name( $last_name ) {
[163] Fix | Delete
$last_name = trim( $last_name );
[164] Fix | Delete
[165] Fix | Delete
if ( empty( $last_name )
[166] Fix | Delete
or 50 < $this->strlen( $last_name ) ) {
[167] Fix | Delete
return false;
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
return $this->last_name = $last_name;
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
public function set_job_title( $job_title ) {
[174] Fix | Delete
$job_title = trim( $job_title );
[175] Fix | Delete
[176] Fix | Delete
if ( empty( $job_title )
[177] Fix | Delete
or 50 < $this->strlen( $job_title ) ) {
[178] Fix | Delete
return false;
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
return $this->job_title = $job_title;
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
public function set_company_name( $company_name ) {
[185] Fix | Delete
$company_name = trim( $company_name );
[186] Fix | Delete
[187] Fix | Delete
if ( empty( $company_name )
[188] Fix | Delete
or 50 < $this->strlen( $company_name ) ) {
[189] Fix | Delete
return false;
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
return $this->company_name = $company_name;
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
public function set_create_source( $create_source ) {
[196] Fix | Delete
if ( ! in_array( $create_source, array( 'Contact', 'Account' ) ) ) {
[197] Fix | Delete
return false;
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
return $this->create_source = $create_source;
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
public function set_birthday( $month, $day ) {
[204] Fix | Delete
$month = (int) $month;
[205] Fix | Delete
$day = (int) $day;
[206] Fix | Delete
[207] Fix | Delete
if ( $month < 1 || 12 < $month
[208] Fix | Delete
or $day < 1 || 31 < $day ) {
[209] Fix | Delete
return false;
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
$this->birthday_month = $month;
[213] Fix | Delete
$this->birthday_day = $day;
[214] Fix | Delete
[215] Fix | Delete
return array( $this->birthday_month, $this->birthday_day );
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
public function set_anniversary( $anniversary ) {
[219] Fix | Delete
$pattern = sprintf(
[220] Fix | Delete
'#^(%s)$#',
[221] Fix | Delete
implode( '|', array(
[222] Fix | Delete
'\d{1,2}/\d{1,2}/\d{4}',
[223] Fix | Delete
'\d{4}/\d{1,2}/\d{1,2}',
[224] Fix | Delete
'\d{4}-\d{1,2}-\d{1,2}',
[225] Fix | Delete
'\d{1,2}-\d{1,2}-\d{4}',
[226] Fix | Delete
) )
[227] Fix | Delete
);
[228] Fix | Delete
[229] Fix | Delete
if ( ! preg_match( $pattern, $anniversary ) ) {
[230] Fix | Delete
return false;
[231] Fix | Delete
}
[232] Fix | Delete
[233] Fix | Delete
return $this->anniversary = $anniversary;
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
public function add_custom_field( $custom_field_id, $value ) {
[237] Fix | Delete
$uuid_pattern = '/^[0-9a-f-]+$/i';
[238] Fix | Delete
[239] Fix | Delete
$value = trim( $value );
[240] Fix | Delete
[241] Fix | Delete
if ( 25 <= count( $this->custom_fields )
[242] Fix | Delete
or ! preg_match( $uuid_pattern, $custom_field_id )
[243] Fix | Delete
or 255 < $this->strlen( $value ) ) {
[244] Fix | Delete
return false;
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
return $this->custom_fields[] = array(
[248] Fix | Delete
'custom_field_id' => $custom_field_id,
[249] Fix | Delete
'value' => $value,
[250] Fix | Delete
);
[251] Fix | Delete
}
[252] Fix | Delete
[253] Fix | Delete
public function add_phone_number( $phone_number, $kind = 'home' ) {
[254] Fix | Delete
$phone_number = trim( $phone_number );
[255] Fix | Delete
[256] Fix | Delete
if ( empty( $phone_number )
[257] Fix | Delete
or ! wpcf7_is_tel( $phone_number )
[258] Fix | Delete
or 25 < $this->strlen( $phone_number )
[259] Fix | Delete
or 2 <= count( $this->phone_numbers )
[260] Fix | Delete
or ! in_array( $kind, array( 'home', 'work', 'other' ) ) ) {
[261] Fix | Delete
return false;
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
return $this->phone_numbers[] = array(
[265] Fix | Delete
'phone_number' => $phone_number,
[266] Fix | Delete
'kind' => $kind,
[267] Fix | Delete
);
[268] Fix | Delete
}
[269] Fix | Delete
[270] Fix | Delete
public function add_street_address( $street, $city, $state, $postal_code, $country, $kind = 'home' ) {
[271] Fix | Delete
$street = trim( $street );
[272] Fix | Delete
$city = trim( $city );
[273] Fix | Delete
$state = trim( $state );
[274] Fix | Delete
$postal_code = trim( $postal_code );
[275] Fix | Delete
$country = trim( $country );
[276] Fix | Delete
[277] Fix | Delete
if ( ! ( $street || $city || $state || $postal_code || $country )
[278] Fix | Delete
or 1 <= count( $this->street_addresses )
[279] Fix | Delete
or ! in_array( $kind, array( 'home', 'work', 'other' ) )
[280] Fix | Delete
or 255 < $this->strlen( $street )
[281] Fix | Delete
or 50 < $this->strlen( $city )
[282] Fix | Delete
or 50 < $this->strlen( $state )
[283] Fix | Delete
or 50 < $this->strlen( $postal_code )
[284] Fix | Delete
or 50 < $this->strlen( $country ) ) {
[285] Fix | Delete
return false;
[286] Fix | Delete
}
[287] Fix | Delete
[288] Fix | Delete
return $this->street_addresses[] = array(
[289] Fix | Delete
'kind' => $kind,
[290] Fix | Delete
'street' => $street,
[291] Fix | Delete
'city' => $city,
[292] Fix | Delete
'state' => $state,
[293] Fix | Delete
'postal_code' => $postal_code,
[294] Fix | Delete
'country' => $country,
[295] Fix | Delete
);
[296] Fix | Delete
}
[297] Fix | Delete
[298] Fix | Delete
public function add_list_membership( $list_id ) {
[299] Fix | Delete
$uuid_pattern = '/^[0-9a-f-]+$/i';
[300] Fix | Delete
[301] Fix | Delete
if ( 50 <= count( $this->list_memberships )
[302] Fix | Delete
or ! preg_match( $uuid_pattern, $list_id ) ) {
[303] Fix | Delete
return false;
[304] Fix | Delete
}
[305] Fix | Delete
[306] Fix | Delete
return $this->list_memberships[] = $list_id;
[307] Fix | Delete
}
[308] Fix | Delete
[309] Fix | Delete
protected function strlen( $text ) {
[310] Fix | Delete
return wpcf7_count_code_units( $text );
[311] Fix | Delete
}
[312] Fix | Delete
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function