: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$mailtags = array_values( $mailtags );
return apply_filters( 'wpcf7_collect_mail_tags', $mailtags, $options, $this );
* Prints a mail-tag suggestion list.
* @param string $template_name Optional. Mail template name. Default 'mail'.
public function suggest_mail_tags( $template_name = 'mail' ) {
$mail = wp_parse_args( $this->prop( $template_name ),
'additional_headers' => '',
'exclude_blank' => false,
$mail = array_filter( $mail );
foreach ( (array) $this->collect_mail_tags() as $mail_tag ) {
'/\[(_[a-z]+_)?%s([ \t]+[^]]+)?\]/',
preg_quote( $mail_tag, '/' )
$used = preg_grep( $pattern, $mail );
'<span class="%1$s">[%2$s]</span>',
'mailtag code ' . ( $used ? 'used' : 'unused' ),
* Submits this contact form.
* @param string|array $options Optional. Submission options. Default empty.
* @return array Result of submission.
public function submit( $options = '' ) {
$options = wp_parse_args( $options, array(
|| $this->is_true( 'skip_mail' )
|| ! empty( $this->skip_mail ) ),
if ( $this->is_true( 'subscribers_only' )
and ! current_user_can( 'wpcf7_submit', $this->id() ) ) {
'contact_form_id' => $this->id(),
"This contact form is available only for logged in users.",
$submission = WPCF7_Submission::get_instance( $this, array(
'skip_mail' => $options['skip_mail'],
'contact_form_id' => $this->id(),
$result += $submission->get_result();
if ( $this->in_demo_mode() ) {
$result['demo_mode'] = true;
do_action( 'wpcf7_submit', $this, $result );
* Returns message used for given status.
* @param string $status Status.
* @param bool $filter Optional. Whether filters are applied. Default true.
* @return string Message.
public function message( $status, $filter = true ) {
$messages = $this->prop( 'messages' );
$message = isset( $messages[$status] ) ? $messages[$status] : '';
$message = $this->filter_message( $message, $status );
* @param string $message Message to filter.
* @param string $status Optional. Status. Default empty.
* @return string Filtered message.
public function filter_message( $message, $status = '' ) {
$message = wpcf7_mail_replace_tags( $message );
$message = apply_filters( 'wpcf7_display_message', $message, $status );
$message = wp_strip_all_tags( $message );
* Returns the additional setting value searched by name.
* @param string $name Name of setting.
* @return string Additional setting value.
public function pref( $name ) {
$settings = $this->additional_setting( $name );
* Returns additional setting values searched by name.
* @param string $name Name of setting.
* @param int $max Maximum result item count.
* @return array Additional setting values.
public function additional_setting( $name, $max = 1 ) {
$settings = (array) explode( "\n", $this->prop( 'additional_settings' ) );
$pattern = '/^([a-zA-Z0-9_]+)[\t ]*:(.*)$/';
foreach ( $settings as $setting ) {
if ( preg_match( $pattern, $setting, $matches ) ) {
if ( $matches[1] != $name ) {
if ( ! $max or $count < (int) $max ) {
$values[] = trim( $matches[2] );
* Returns true if the specified setting has a truthy string value.
* @param string $name Name of setting.
* @return bool True if the setting value is 'on', 'true', or '1'.
public function is_true( $name ) {
array( 'on', 'true', '1' ),
* Returns true if this contact form is in the demo mode.
public function in_demo_mode() {
return $this->is_true( 'demo_mode' );
* Returns true if nonce is active for this contact form.
public function nonce_is_active() {
$is_active = WPCF7_VERIFY_NONCE;
if ( $this->is_true( 'subscribers_only' ) ) {
return (bool) apply_filters( 'wpcf7_verify_nonce', $is_active, $this );
* Returns true if the specified setting has a falsey string value.
* @param string $name Name of setting.
* @return bool True if the setting value is 'off', 'false', or '0'.
public function is_false( $name ) {
array( 'off', 'false', '0' ),
* Upgrades this contact form properties.
private function upgrade() {
$mail = $this->prop( 'mail' );
and ! isset( $mail['recipient'] ) ) {
$mail['recipient'] = get_option( 'admin_email' );
$this->properties['mail'] = $mail;
$messages = $this->prop( 'messages' );
if ( is_array( $messages ) ) {
foreach ( wpcf7_messages() as $key => $arr ) {
if ( ! isset( $messages[$key] ) ) {
$messages[$key] = $arr['default'];
$this->properties['messages'] = $messages;
* Stores this contact form properties to the database.
* @return int The post ID on success. The value 0 on failure.
$title = wp_slash( $this->title );
$props = wp_slash( $this->get_properties() );
$post_content = implode( "\n", wpcf7_array_flatten( $props ) );
if ( $this->initial() ) {
$post_id = wp_insert_post( array(
'post_type' => self::post_type,
'post_status' => 'publish',
'post_content' => trim( $post_content ),
$post_id = wp_update_post( array(
'post_status' => 'publish',
'post_content' => trim( $post_content ),
foreach ( $props as $prop => $value ) {
update_post_meta( $post_id, '_' . $prop,
wpcf7_normalize_newline_deep( $value )
if ( wpcf7_is_valid_locale( $this->locale ) ) {
update_post_meta( $post_id, '_locale', $this->locale );
add_post_meta( $post_id, '_hash',
wpcf7_generate_contact_form_hash( $post_id ),
if ( $this->initial() ) {
do_action( 'wpcf7_after_create', $this );
do_action( 'wpcf7_after_update', $this );
do_action( 'wpcf7_after_save', $this );
* Makes a copy of this contact form.
* @return WPCF7_ContactForm New contact form object.
$new->title = $this->title . '_copy';
$new->locale = $this->locale;
$new->properties = $this->properties;
return apply_filters( 'wpcf7_copy', $new, $this );
* Deletes this contact form.
public function delete() {
if ( $this->initial() ) {
if ( wp_delete_post( $this->id, true ) ) {
* Returns a WordPress shortcode for this contact form.
public function shortcode( $options = '' ) {
$options = wp_parse_args( $options, array(
'use_old_format' => false
$title = str_replace( array( '"', '[', ']' ), '', $this->title );
if ( $options['use_old_format'] ) {
$old_unit_id = (int) get_post_meta( $this->id, '_old_cf7_unit_id', true );
'[contact-form %1$d "%2$s"]',
'[contact-form-7 id="%1$s" title="%2$s"]',
return apply_filters( 'wpcf7_contact_form_shortcode',
$shortcode, $options, $this