function column_title($item)
 {
     $url = admin_url('admin.php?page=wpcf7&post=' . absint($item->id()));
     $edit_link = add_query_arg(array('action' => 'edit'), $url);
     $output = sprintf('<a class="row-title" href="%1$s" title="%2$s">%3$s</a>', esc_url($edit_link), esc_attr(sprintf(__('Edit &#8220;%s&#8221;', 'contact-form-7'), $item->title())), esc_html($item->title()));
     $output = sprintf('<strong>%s</strong>', $output);
     if (wpcf7_validate_configuration() && current_user_can('wpcf7_edit_contact_form', $item->id()) && ($config_errors = $item->get_config_errors())) {
         $error_notice = sprintf(_n('%s configuration error found', '%s configuration errors found', count($config_errors), 'contact-form-7'), number_format_i18n(count($config_errors)));
         $output .= sprintf('<div class="config-error">%s</div>', $error_notice);
     }
     $actions = array('edit' => sprintf('<a href="%1$s">%2$s</a>', esc_url($edit_link), esc_html(__('Edit', 'contact-form-7'))));
     if (current_user_can('wpcf7_edit_contact_form', $item->id())) {
         $copy_link = wp_nonce_url(add_query_arg(array('action' => 'copy'), $url), 'wpcf7-copy-contact-form_' . absint($item->id()));
         $actions = array_merge($actions, array('copy' => sprintf('<a href="%1$s">%2$s</a>', esc_url($copy_link), esc_html(__('Duplicate', 'contact-form-7')))));
     }
     $output .= $this->row_actions($actions);
     return $output;
 }
Esempio n. 2
0
function wpcf7_editor_panel_messages($post)
{
    $messages = wpcf7_messages();
    if (!wpcf7_use_really_simple_captcha()) {
        unset($messages['captcha_not_match']);
    }
    $do_validate = wpcf7_validate_configuration();
    ?>
<h2><?php 
    echo esc_html(__('Messages', 'contact-form-7'));
    ?>
</h2>
<fieldset>
<legend><?php 
    echo esc_html(__('Edit messages used in the following situations.', 'contact-form-7'));
    ?>
</legend>
<?php 
    foreach ($messages as $key => $arr) {
        $field_name = 'wpcf7-message-' . strtr($key, '_', '-');
        $config_error = $do_validate ? $post->config_error(sprintf('messages.%s', $key)) : '';
        ?>
<p class="description">
<label for="<?php 
        echo $field_name;
        ?>
"><?php 
        echo esc_html($arr['description']);
        ?>
<br />
<input type="text" id="<?php 
        echo $field_name;
        ?>
" name="<?php 
        echo $field_name;
        ?>
" class="large-text" size="70" value="<?php 
        echo esc_attr($post->message($key, false));
        ?>
"<?php 
        echo $config_error ? ' aria-invalid="true"' : '';
        ?>
 />
<?php 
        if ($config_error) {
            echo sprintf('<br /><span role="alert" class="config-error">%s</span>', $config_error);
        }
        ?>
</label>
</p>
<?php 
    }
    ?>
</fieldset>
<?php 
}
Esempio n. 3
0
function wpcf7_notice_bulk_validate_config()
{
    if (!wpcf7_validate_configuration() || !current_user_can('wpcf7_edit_contact_forms')) {
        return;
    }
    if (isset($_GET['page']) && 'wpcf7' == $_GET['page'] && isset($_GET['action']) && 'validate' == $_GET['action']) {
        return;
    }
    if (WPCF7::get_option('bulk_validate')) {
        // already done.
        return;
    }
    $link = add_query_arg(array('action' => 'validate'), menu_page_url('wpcf7', false));
    $link = sprintf('<a href="%s">%s</a>', $link, esc_html(__('Validate Contact Form 7 Configuration', 'contact-form-7')));
    $message = __("Misconfiguration leads to mail delivery failure or other troubles. Validate your contact forms now.", 'contact-form-7');
    echo sprintf('<div class="notice notice-warning"><p>%s &raquo; %s</p></div>', esc_html($message), $link);
}
Esempio n. 4
0
function wpcf7_save_contact_form($post_id = -1)
{
    if (-1 != $post_id) {
        $contact_form = wpcf7_contact_form($post_id);
    }
    if (empty($contact_form)) {
        $contact_form = WPCF7_ContactForm::get_template();
    }
    if (isset($_POST['post_title'])) {
        $contact_form->set_title($_POST['post_title']);
    }
    if (isset($_POST['wpcf7-locale'])) {
        $locale = trim($_POST['wpcf7-locale']);
        if (wpcf7_is_valid_locale($locale)) {
            $contact_form->locale = $locale;
        }
    }
    $properties = $contact_form->get_properties();
    if (isset($_POST['wpcf7-form'])) {
        $properties['form'] = trim($_POST['wpcf7-form']);
    }
    $mail = $properties['mail'];
    if (isset($_POST['wpcf7-mail-subject'])) {
        $mail['subject'] = trim($_POST['wpcf7-mail-subject']);
    }
    if (isset($_POST['wpcf7-mail-sender'])) {
        $mail['sender'] = trim($_POST['wpcf7-mail-sender']);
    }
    if (isset($_POST['wpcf7-mail-body'])) {
        $mail['body'] = trim($_POST['wpcf7-mail-body']);
    }
    if (isset($_POST['wpcf7-mail-recipient'])) {
        $mail['recipient'] = trim($_POST['wpcf7-mail-recipient']);
    }
    if (isset($_POST['wpcf7-mail-additional-headers'])) {
        $headers = '';
        $tempheaders = str_replace("\r\n", "\n", $_POST['wpcf7-mail-additional-headers']);
        $tempheaders = explode("\n", $tempheaders);
        foreach ($tempheaders as $header) {
            $header = trim($header);
            if ('' !== $header) {
                $headers .= $header . "\n";
            }
        }
        $mail['additional_headers'] = trim($headers);
    }
    if (isset($_POST['wpcf7-mail-attachments'])) {
        $mail['attachments'] = trim($_POST['wpcf7-mail-attachments']);
    }
    $mail['use_html'] = !empty($_POST['wpcf7-mail-use-html']);
    $mail['exclude_blank'] = !empty($_POST['wpcf7-mail-exclude-blank']);
    $properties['mail'] = $mail;
    $mail_2 = $properties['mail_2'];
    $mail_2['active'] = !empty($_POST['wpcf7-mail-2-active']);
    if (isset($_POST['wpcf7-mail-2-subject'])) {
        $mail_2['subject'] = trim($_POST['wpcf7-mail-2-subject']);
    }
    if (isset($_POST['wpcf7-mail-2-sender'])) {
        $mail_2['sender'] = trim($_POST['wpcf7-mail-2-sender']);
    }
    if (isset($_POST['wpcf7-mail-2-body'])) {
        $mail_2['body'] = trim($_POST['wpcf7-mail-2-body']);
    }
    if (isset($_POST['wpcf7-mail-2-recipient'])) {
        $mail_2['recipient'] = trim($_POST['wpcf7-mail-2-recipient']);
    }
    if (isset($_POST['wpcf7-mail-2-additional-headers'])) {
        $headers = '';
        $tempheaders = str_replace("\r\n", "\n", $_POST['wpcf7-mail-2-additional-headers']);
        $tempheaders = explode("\n", $tempheaders);
        foreach ($tempheaders as $header) {
            $header = trim($header);
            if ('' !== $header) {
                $headers .= $header . "\n";
            }
        }
        $mail_2['additional_headers'] = trim($headers);
    }
    if (isset($_POST['wpcf7-mail-2-attachments'])) {
        $mail_2['attachments'] = trim($_POST['wpcf7-mail-2-attachments']);
    }
    $mail_2['use_html'] = !empty($_POST['wpcf7-mail-2-use-html']);
    $mail_2['exclude_blank'] = !empty($_POST['wpcf7-mail-2-exclude-blank']);
    $properties['mail_2'] = $mail_2;
    foreach (wpcf7_messages() as $key => $arr) {
        $field_name = 'wpcf7-message-' . strtr($key, '_', '-');
        if (isset($_POST[$field_name])) {
            $properties['messages'][$key] = trim($_POST[$field_name]);
        }
    }
    if (isset($_POST['wpcf7-additional-settings'])) {
        $properties['additional_settings'] = trim($_POST['wpcf7-additional-settings']);
    }
    $contact_form->set_properties($properties);
    do_action('wpcf7_save_contact_form', $contact_form);
    $post_id = $contact_form->save();
    if (wpcf7_validate_configuration()) {
        $contact_form->validate_configuration();
    }
    return $post_id;
}