: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Returns true if WordPress is running on the localhost.
function wpcf7_is_localhost() {
$sitename = wp_parse_url( network_home_url(), PHP_URL_HOST );
return in_array( strtolower( $sitename ), array( 'localhost', '127.0.0.1' ) );
* Marks a function as deprecated and informs when it has been used.
* @param string $function_name The function that was called.
* @param string $version The version of Contact Form 7 that deprecated
* @param string $replacement The function that should have been called.
function wpcf7_deprecated_function( $function_name, $version, $replacement ) {
if ( function_exists( '__' ) ) {
/* translators: 1: PHP function name, 2: version number, 3: alternative function name */
__( 'Function %1$s is <strong>deprecated</strong> since Contact Form 7 version %2$s! Use %3$s instead.', 'contact-form-7' ),
$function_name, $version, $replacement
'Function %1$s is <strong>deprecated</strong> since Contact Form 7 version %2$s! Use %3$s instead.',
$function_name, $version, $replacement
* Fires functions attached to a deprecated filter hook.
* @param string $hook_name The name of the filter hook.
* @param array $args Array of additional function arguments to be
* passed to apply_filters().
* @param string $version The version of Contact Form 7 that deprecated
* @param string $replacement The hook that should have been used.
function wpcf7_apply_filters_deprecated( $hook_name, $args, $version, $replacement = '' ) {
if ( ! has_filter( $hook_name ) ) {
if ( WP_DEBUG and apply_filters( 'deprecated_hook_trigger_error', true ) ) {
/* translators: 1: WordPress hook name, 2: version number, 3: alternative hook name */
__( 'Hook %1$s is <strong>deprecated</strong> since Contact Form 7 version %2$s! Use %3$s instead.', 'contact-form-7' ),
/* translators: 1: WordPress hook name, 2: version number */
__( 'Hook %1$s is <strong>deprecated</strong> since Contact Form 7 version %2$s with no alternative available.', 'contact-form-7' ),
return apply_filters_ref_array( $hook_name, $args );
* Marks something as being incorrectly called.
* @param string $function_name The function that was called.
* @param string $message A message explaining what has been done incorrectly.
* @param string $version The version of Contact Form 7 where the message
function wpcf7_doing_it_wrong( $function_name, $message, $version ) {
if ( function_exists( '__' ) ) {
/* translators: %s: Contact Form 7 version number. */
__( '(This message was added in Contact Form 7 version %s.)', 'contact-form-7' ),
/* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message, 3: Contact Form 7 version number. */
__( 'Function %1$s was called incorrectly. %2$s %3$s', 'contact-form-7' ),
'(This message was added in Contact Form 7 version %s.)',
'Function %1$s was called incorrectly. %2$s %3$s',
* Triggers an error about a remote HTTP request and response.
* @param string $url The resource URL.
* @param array $request Request arguments.
* @param array|WP_Error $response The response or WP_Error on failure.
function wpcf7_log_remote_request( $url, $request, $response ) {
/* translators: 1: response code, 2: message, 3: body, 4: URL */
__( 'HTTP Response: %1$s %2$s %3$s from %4$s', 'contact-form-7' ),
(int) wp_remote_retrieve_response_code( $response ),
wp_remote_retrieve_response_message( $response ),
wp_remote_retrieve_body( $response ),
$log = apply_filters( 'wpcf7_log_remote_request',
$log, $url, $request, $response
* Anonymizes an IP address by masking local part.
* @param string $ip_addr The original IP address.
* @return string|bool Anonymized IP address, or false on failure.
function wpcf7_anonymize_ip_addr( $ip_addr ) {
if ( ! function_exists( 'inet_ntop' )
or ! function_exists( 'inet_pton' ) ) {
$packed = inet_pton( $ip_addr );
if ( false === $packed ) {
if ( 4 == strlen( $packed ) ) { // IPv4
} elseif ( 16 == strlen( $packed ) ) { // IPv6
$mask = 'ffff:ffff:ffff:0000:0000:0000:0000:0000';
return inet_ntop( $packed & inet_pton( $mask ) );