Ejemplo n.º 1
0
function wpcf7_default_messages_template()
{
    $messages = array();
    foreach (wpcf7_messages() as $key => $arr) {
        $messages[$key] = $arr['default'];
    }
    return $messages;
}
 public static function messages()
 {
     $messages = array();
     foreach (wpcf7_messages() as $key => $arr) {
         $messages[$key] = $arr['default'];
     }
     return $messages;
 }
Ejemplo n.º 3
0
 private function upgrade()
 {
     $mail = $this->prop('mail');
     if (is_array($mail) && !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;
 }
Ejemplo n.º 4
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 
}
Ejemplo n.º 5
0
 function upgrade()
 {
     if (is_array($this->mail)) {
         if (!isset($this->mail['recipient'])) {
             $this->mail['recipient'] = get_option('admin_email');
         }
     }
     if (is_array($this->messages)) {
         foreach (wpcf7_messages() as $key => $arr) {
             if (!isset($this->messages[$key])) {
                 $this->messages[$key] = $arr['default'];
             }
         }
     }
 }
Ejemplo n.º 6
0
function wpcf7_admin_add_pages()
{
    if (isset($_POST['wpcf7-save']) && wpcf7_admin_has_edit_cap()) {
        $id = $_POST['wpcf7-id'];
        check_admin_referer('wpcf7-save_' . $id);
        if (!($contact_form = wpcf7_contact_form($id))) {
            $contact_form = new WPCF7_ContactForm();
            $contact_form->initial = true;
        }
        $title = trim($_POST['wpcf7-title']);
        $form = trim($_POST['wpcf7-form']);
        $mail = array('subject' => trim($_POST['wpcf7-mail-subject']), 'sender' => trim($_POST['wpcf7-mail-sender']), 'body' => trim($_POST['wpcf7-mail-body']), 'recipient' => trim($_POST['wpcf7-mail-recipient']), 'additional_headers' => trim($_POST['wpcf7-mail-additional-headers']), 'attachments' => trim($_POST['wpcf7-mail-attachments']), 'use_html' => isset($_POST['wpcf7-mail-use-html']) && 1 == $_POST['wpcf7-mail-use-html']);
        $mail_2 = array('active' => isset($_POST['wpcf7-mail-2-active']) && 1 == $_POST['wpcf7-mail-2-active'], 'subject' => trim($_POST['wpcf7-mail-2-subject']), 'sender' => trim($_POST['wpcf7-mail-2-sender']), 'body' => trim($_POST['wpcf7-mail-2-body']), 'recipient' => trim($_POST['wpcf7-mail-2-recipient']), 'additional_headers' => trim($_POST['wpcf7-mail-2-additional-headers']), 'attachments' => trim($_POST['wpcf7-mail-2-attachments']), 'use_html' => isset($_POST['wpcf7-mail-2-use-html']) && 1 == $_POST['wpcf7-mail-2-use-html']);
        $messages = $contact_form->messages;
        foreach (wpcf7_messages() as $key => $arr) {
            $field_name = 'wpcf7-message-' . strtr($key, '_', '-');
            if (isset($_POST[$field_name])) {
                $messages[$key] = trim($_POST[$field_name]);
            }
        }
        $additional_settings = trim($_POST['wpcf7-additional-settings']);
        $query = array();
        $query['message'] = $contact_form->initial ? 'created' : 'saved';
        $contact_form->title = $title;
        $contact_form->form = $form;
        $contact_form->mail = $mail;
        $contact_form->mail_2 = $mail_2;
        $contact_form->messages = $messages;
        $contact_form->additional_settings = $additional_settings;
        $contact_form->save();
        $query['contactform'] = $contact_form->id;
        $redirect_to = wpcf7_admin_url($query);
        wp_redirect($redirect_to);
        exit;
    } elseif (isset($_POST['wpcf7-copy']) && wpcf7_admin_has_edit_cap()) {
        $id = $_POST['wpcf7-id'];
        check_admin_referer('wpcf7-copy_' . $id);
        $query = array();
        if ($contact_form = wpcf7_contact_form($id)) {
            $new_contact_form = $contact_form->copy();
            $new_contact_form->save();
            $query['contactform'] = $new_contact_form->id;
            $query['message'] = 'created';
        } else {
            $query['contactform'] = $contact_form->id;
        }
        $redirect_to = wpcf7_admin_url($query);
        wp_redirect($redirect_to);
        exit;
    } elseif (isset($_POST['wpcf7-delete']) && wpcf7_admin_has_edit_cap()) {
        $id = $_POST['wpcf7-id'];
        check_admin_referer('wpcf7-delete_' . $id);
        if ($contact_form = wpcf7_contact_form($id)) {
            $contact_form->delete();
        }
        $redirect_to = wpcf7_admin_url(array('message' => 'deleted'));
        wp_redirect($redirect_to);
        exit;
    } elseif (isset($_GET['wpcf7-create-table'])) {
        check_admin_referer('wpcf7-create-table');
        $query = array();
        if (!wpcf7_table_exists() && current_user_can('activate_plugins')) {
            wpcf7_install();
            if (wpcf7_table_exists()) {
                $query['message'] = 'table_created';
            } else {
                $query['message'] = 'table_not_created';
            }
        }
        wp_redirect(wpcf7_admin_url($query));
        exit;
    }
    add_menu_page(__('Contact Form 7', 'wpcf7'), __('Contact', 'wpcf7'), WPCF7_ADMIN_READ_CAPABILITY, 'wpcf7', 'wpcf7_admin_management_page');
    add_submenu_page('wpcf7', __('Edit Contact Forms', 'wpcf7'), __('Edit', 'wpcf7'), WPCF7_ADMIN_READ_CAPABILITY, 'wpcf7', 'wpcf7_admin_management_page');
}
Ejemplo n.º 7
0
function wpcf7_messages_meta_box($post)
{
    $updated = isset($_REQUEST['message']) && in_array($_REQUEST['message'], array('saved', 'created'));
    $count = 0;
    $messages = wpcf7_messages();
    foreach ($messages as $key => $arr) {
        $count += 1;
        $field_name = 'wpcf7-message-' . strtr($key, '_', '-');
        ?>
<div class="message-field">
<p class="description"><label for="<?php 
        echo $field_name;
        ?>
"><?php 
        echo esc_html($arr['description']);
        ?>
</label></p>
<input type="text" id="<?php 
        echo $field_name;
        ?>
" name="<?php 
        echo $field_name;
        ?>
" class="wide" size="70" value="<?php 
        echo esc_attr($post->message($key, false));
        ?>
" />
</div>
<?php 
        if (!$updated && 10 <= count($messages)) {
            if (6 == $count) {
                echo '<p><a href="#" id="show-all-messages">' . esc_html(__('Show all messages', 'contact-form-7')) . '</a></p>' . "\n";
                echo '<div class="hide-initially">';
            }
            if (count($messages) == $count) {
                echo '</div>';
            }
        }
    }
}
Ejemplo n.º 8
0
function wpcf7_load_contact_form_admin()
{
    $action = wpcf7_current_action();
    if ('save' == $action) {
        $id = $_POST['post_ID'];
        check_admin_referer('wpcf7-save-contact-form_' . $id);
        if (!current_user_can('wpcf7_edit_contact_form', $id)) {
            wp_die(__('You are not allowed to edit this item.', 'wpcf7'));
        }
        if (!($contact_form = wpcf7_contact_form($id))) {
            $contact_form = new WPCF7_ContactForm();
            $contact_form->initial = true;
        }
        $contact_form->title = trim($_POST['wpcf7-title']);
        $form = trim($_POST['wpcf7-form']);
        $mail = array('subject' => trim($_POST['wpcf7-mail-subject']), 'sender' => trim($_POST['wpcf7-mail-sender']), 'body' => trim($_POST['wpcf7-mail-body']), 'recipient' => trim($_POST['wpcf7-mail-recipient']), 'additional_headers' => trim($_POST['wpcf7-mail-additional-headers']), 'attachments' => trim($_POST['wpcf7-mail-attachments']), 'use_html' => isset($_POST['wpcf7-mail-use-html']) && 1 == $_POST['wpcf7-mail-use-html']);
        $mail_2 = array('active' => isset($_POST['wpcf7-mail-2-active']) && 1 == $_POST['wpcf7-mail-2-active'], 'subject' => trim($_POST['wpcf7-mail-2-subject']), 'sender' => trim($_POST['wpcf7-mail-2-sender']), 'body' => trim($_POST['wpcf7-mail-2-body']), 'recipient' => trim($_POST['wpcf7-mail-2-recipient']), 'additional_headers' => trim($_POST['wpcf7-mail-2-additional-headers']), 'attachments' => trim($_POST['wpcf7-mail-2-attachments']), 'use_html' => isset($_POST['wpcf7-mail-2-use-html']) && 1 == $_POST['wpcf7-mail-2-use-html']);
        $messages = isset($contact_form->messages) ? $contact_form->messages : array();
        foreach (wpcf7_messages() as $key => $arr) {
            $field_name = 'wpcf7-message-' . strtr($key, '_', '-');
            if (isset($_POST[$field_name])) {
                $messages[$key] = trim($_POST[$field_name]);
            }
        }
        $additional_settings = trim($_POST['wpcf7-additional-settings']);
        $props = apply_filters('wpcf7_contact_form_admin_posted_properties', compact('form', 'mail', 'mail_2', 'messages', 'additional_settings'));
        foreach ((array) $props as $key => $prop) {
            $contact_form->{$key} = $prop;
        }
        $query = array();
        $query['message'] = $contact_form->initial ? 'created' : 'saved';
        $contact_form->save();
        $query['post'] = $contact_form->id;
        $redirect_to = add_query_arg($query, menu_page_url('wpcf7', false));
        wp_safe_redirect($redirect_to);
        exit;
    }
    if ('copy' == $action) {
        $id = empty($_POST['post_ID']) ? absint($_REQUEST['post']) : absint($_POST['post_ID']);
        check_admin_referer('wpcf7-copy-contact-form_' . $id);
        if (!current_user_can('wpcf7_edit_contact_form', $id)) {
            wp_die(__('You are not allowed to edit this item.', 'wpcf7'));
        }
        $query = array();
        if ($contact_form = wpcf7_contact_form($id)) {
            $new_contact_form = $contact_form->copy();
            $new_contact_form->save();
            $query['post'] = $new_contact_form->id;
            $query['message'] = 'created';
        } else {
            $query['post'] = $contact_form->id;
        }
        $redirect_to = add_query_arg($query, menu_page_url('wpcf7', false));
        wp_safe_redirect($redirect_to);
        exit;
    }
    if ('delete' == $action) {
        if (!empty($_POST['post_ID'])) {
            check_admin_referer('wpcf7-delete-contact-form_' . $_POST['post_ID']);
        } elseif (!is_array($_REQUEST['post'])) {
            check_admin_referer('wpcf7-delete-contact-form_' . $_REQUEST['post']);
        } else {
            check_admin_referer('bulk-posts');
        }
        $posts = empty($_POST['post_ID']) ? (array) $_REQUEST['post'] : (array) $_POST['post_ID'];
        $deleted = 0;
        foreach ($posts as $post) {
            $post = new WPCF7_ContactForm($post);
            if (empty($post)) {
                continue;
            }
            if (!current_user_can('wpcf7_delete_contact_form', $post->id)) {
                wp_die(__('You are not allowed to delete this item.', 'wpcf7'));
            }
            if (!$post->delete()) {
                wp_die(__('Error in deleting.', 'wpcf7'));
            }
            $deleted += 1;
        }
        $query = array();
        if (!empty($deleted)) {
            $query['message'] = 'deleted';
        }
        $redirect_to = add_query_arg($query, menu_page_url('wpcf7', false));
        wp_safe_redirect($redirect_to);
        exit;
    }
    if (empty($_GET['post'])) {
        $current_screen = get_current_screen();
        if (!class_exists('WPCF7_Contact_Form_List_Table')) {
            require_once WPCF7_PLUGIN_DIR . '/admin/includes/class-contact-forms-list-table.php';
        }
        add_filter('manage_' . $current_screen->id . '_columns', array('WPCF7_Contact_Form_List_Table', 'define_columns'));
        add_screen_option('per_page', array('label' => __('Contact Forms', 'wpcf7'), 'default' => 20, 'option' => 'cfseven_contact_forms_per_page'));
    }
}
function wpcf7_editor_panel_messages($post)
{
    $messages = wpcf7_messages();
    if (!wpcf7_use_really_simple_captcha()) {
        unset($messages['captcha_not_match']);
    }
    ?>
<h3><?php 
    echo esc_html(__('Messages', 'contact-form-7'));
    ?>
</h3>
<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, '_', '-');
        ?>
<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));
        ?>
" />
</label>
</p>
<?php 
    }
    ?>
</fieldset>
<?php 
}
Ejemplo n.º 10
0
function wpcf7_messages_meta_box($post)
{
    foreach (wpcf7_messages() as $key => $arr) {
        $field_name = 'wpcf7-message-' . strtr($key, '_', '-');
        ?>
<div class="message-field">
<label for="<?php 
        echo $field_name;
        ?>
"><em># <?php 
        echo esc_html($arr['description']);
        ?>
</em></label><br />
<input type="text" id="<?php 
        echo $field_name;
        ?>
" name="<?php 
        echo $field_name;
        ?>
" class="wide" size="70" value="<?php 
        echo esc_attr($post->messages[$key]);
        ?>
" />
</div>
<?php 
    }
}
Ejemplo n.º 11
0
    if (wpcf7_admin_has_edit_cap()) {
        ?>

	<table class="widefat" style="margin-top: 1em;">
	<thead><tr><th scope="col"><?php 
        echo esc_html(__('Messages', 'wpcf7'));
        ?>
 <span id="message-fields-toggle-switch"></span></th></tr></thead>

	<tbody>
	<tr>
	<td scope="col">
	<div id="message-fields">

<?php 
        foreach (wpcf7_messages() as $key => $arr) {
            $field_name = 'wpcf7-message-' . strtr($key, '_', '-');
            ?>
	<div class="message-field">
	<label for="<?php 
            echo $field_name;
            ?>
"><em># <?php 
            echo esc_html($arr['description']);
            ?>
</em></label><br />
	<input type="text" id="<?php 
            echo $field_name;
            ?>
" name="<?php 
            echo $field_name;
Ejemplo n.º 12
-1
function wpcf7_admin_init()
{
    if (!wpcf7_admin_has_edit_cap()) {
        return;
    }
    if (isset($_POST['wpcf7-save'])) {
        $id = $_POST['post_ID'];
        check_admin_referer('wpcf7-save_' . $id);
        if (!($contact_form = wpcf7_contact_form($id))) {
            $contact_form = new WPCF7_ContactForm();
            $contact_form->initial = true;
        }
        $contact_form->title = trim($_POST['wpcf7-title']);
        $form = trim($_POST['wpcf7-form']);
        $mail = array('subject' => trim($_POST['wpcf7-mail-subject']), 'sender' => trim($_POST['wpcf7-mail-sender']), 'body' => trim($_POST['wpcf7-mail-body']), 'recipient' => trim($_POST['wpcf7-mail-recipient']), 'additional_headers' => trim($_POST['wpcf7-mail-additional-headers']), 'attachments' => trim($_POST['wpcf7-mail-attachments']), 'use_html' => isset($_POST['wpcf7-mail-use-html']) && 1 == $_POST['wpcf7-mail-use-html']);
        $mail_2 = array('active' => isset($_POST['wpcf7-mail-2-active']) && 1 == $_POST['wpcf7-mail-2-active'], 'subject' => trim($_POST['wpcf7-mail-2-subject']), 'sender' => trim($_POST['wpcf7-mail-2-sender']), 'body' => trim($_POST['wpcf7-mail-2-body']), 'recipient' => trim($_POST['wpcf7-mail-2-recipient']), 'additional_headers' => trim($_POST['wpcf7-mail-2-additional-headers']), 'attachments' => trim($_POST['wpcf7-mail-2-attachments']), 'use_html' => isset($_POST['wpcf7-mail-2-use-html']) && 1 == $_POST['wpcf7-mail-2-use-html']);
        $messages = isset($contact_form->messages) ? $contact_form->messages : array();
        foreach (wpcf7_messages() as $key => $arr) {
            $field_name = 'wpcf7-message-' . strtr($key, '_', '-');
            if (isset($_POST[$field_name])) {
                $messages[$key] = trim($_POST[$field_name]);
            }
        }
        $additional_settings = trim($_POST['wpcf7-additional-settings']);
        $props = apply_filters('wpcf7_contact_form_admin_posted_properties', compact('form', 'mail', 'mail_2', 'messages', 'additional_settings'));
        foreach ((array) $props as $key => $prop) {
            $contact_form->{$key} = $prop;
        }
        $query = array();
        $query['message'] = $contact_form->initial ? 'created' : 'saved';
        $contact_form->save();
        $query['contactform'] = $contact_form->id;
        $redirect_to = wpcf7_admin_url($query);
        wp_safe_redirect($redirect_to);
        exit;
    }
    if (isset($_POST['wpcf7-copy'])) {
        $id = $_POST['post_ID'];
        check_admin_referer('wpcf7-copy_' . $id);
        $query = array();
        if ($contact_form = wpcf7_contact_form($id)) {
            $new_contact_form = $contact_form->copy();
            $new_contact_form->save();
            $query['contactform'] = $new_contact_form->id;
            $query['message'] = 'created';
        } else {
            $query['contactform'] = $contact_form->id;
        }
        $redirect_to = wpcf7_admin_url($query);
        wp_safe_redirect($redirect_to);
        exit;
    }
    if (isset($_POST['wpcf7-delete'])) {
        $id = $_POST['post_ID'];
        check_admin_referer('wpcf7-delete_' . $id);
        if ($contact_form = wpcf7_contact_form($id)) {
            $contact_form->delete();
        }
        $redirect_to = wpcf7_admin_url(array('message' => 'deleted'));
        wp_safe_redirect($redirect_to);
        exit;
    }
}
Ejemplo n.º 13
-1
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'])) {
        $mail['additional_headers'] = trim($_POST['wpcf7-mail-additional-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'])) {
        $mail_2['additional_headers'] = trim($_POST['wpcf7-mail-2-additional-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);
    return $contact_form->save();
}