Exemple #1
0
function wpef7_default_messages_template()
{
    $messages = array();
    foreach (wpef7_messages() as $key => $arr) {
        $messages[$key] = $arr['default'];
    }
    return $messages;
}
Exemple #2
0
    if (wpef7_admin_has_edit_cap()) {
        ?>

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

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

<?php 
        foreach (wpef7_messages() as $key => $arr) {
            $field_name = 'wpef7-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;
Exemple #3
0
function wpef7_admin_add_pages()
{
    if (isset($_POST['wpef7-save']) && wpef7_admin_has_edit_cap()) {
        $id = $_POST['wpef7-id'];
        check_admin_referer('wpef7-save_' . $id);
        if (!($contact_form = wpef7_contact_form($id))) {
            $contact_form = new WPEF7_ContactForm();
            $contact_form->initial = true;
        }
        $title = trim($_POST['wpef7-title']);
        $form = trim($_POST['wpef7-form']);
        $mail = array('subject' => trim($_POST['wpef7-mail-subject']), 'sender' => trim($_POST['wpef7-mail-sender']), 'body' => trim($_POST['wpef7-mail-body']), 'recipient' => trim($_POST['wpef7-mail-recipient']), 'additional_headers' => trim($_POST['wpef7-mail-additional-headers']), 'attachments' => trim($_POST['wpef7-mail-attachments']), 'use_html' => isset($_POST['wpef7-mail-use-html']) && 1 == $_POST['wpef7-mail-use-html']);
        $mail_2 = array('active' => isset($_POST['wpef7-mail-2-active']) && 1 == $_POST['wpef7-mail-2-active'], 'subject' => trim($_POST['wpef7-mail-2-subject']), 'sender' => trim($_POST['wpef7-mail-2-sender']), 'body' => trim($_POST['wpef7-mail-2-body']), 'recipient' => trim($_POST['wpef7-mail-2-recipient']), 'additional_headers' => trim($_POST['wpef7-mail-2-additional-headers']), 'attachments' => trim($_POST['wpef7-mail-2-attachments']), 'use_html' => isset($_POST['wpef7-mail-2-use-html']) && 1 == $_POST['wpef7-mail-2-use-html']);
        $messages = $contact_form->messages;
        foreach (wpef7_messages() as $key => $arr) {
            $field_name = 'wpef7-message-' . strtr($key, '_', '-');
            if (isset($_POST[$field_name])) {
                $messages[$key] = trim($_POST[$field_name]);
            }
        }
        $additional_settings = trim($_POST['wpef7-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 = wpef7_admin_url($query);
        wp_redirect($redirect_to);
        exit;
    } elseif (isset($_POST['wpef7-copy']) && wpef7_admin_has_edit_cap()) {
        $id = $_POST['wpef7-id'];
        check_admin_referer('wpef7-copy_' . $id);
        $query = array();
        if ($contact_form = wpef7_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 = wpef7_admin_url($query);
        wp_redirect($redirect_to);
        exit;
    } elseif (isset($_POST['wpef7-delete']) && wpef7_admin_has_edit_cap()) {
        $id = $_POST['wpef7-id'];
        check_admin_referer('wpef7-delete_' . $id);
        if ($contact_form = wpef7_contact_form($id)) {
            $contact_form->delete();
        }
        $redirect_to = wpef7_admin_url(array('message' => 'deleted'));
        wp_redirect($redirect_to);
        exit;
    } elseif (isset($_GET['wpef7-create-table'])) {
        check_admin_referer('wpef7-create-table');
        $query = array();
        if (!wpef7_table_exists() && current_user_can('activate_plugins')) {
            wpef7_install();
            if (wpef7_table_exists()) {
                $query['message'] = 'table_created';
            } else {
                $query['message'] = 'table_not_created';
            }
        }
        wp_redirect(wpef7_admin_url($query));
        exit;
    }
    add_menu_page(__('Contact Form 7', 'wpef7'), __('Contact', 'wpef7'), WPEF7_ADMIN_READ_CAPABILITY, 'wpef7', 'wpef7_admin_management_page');
    add_submenu_page('wpef7', __('Edit Contact Forms', 'wpef7'), __('Edit', 'wpef7'), WPEF7_ADMIN_READ_CAPABILITY, 'wpef7', 'wpef7_admin_management_page');
}
Exemple #4
0
 function upgrade()
 {
     if (!isset($this->mail['recipient'])) {
         $this->mail['recipient'] = get_option('admin_email');
     }
     if (!is_array($this->messages)) {
         $this->messages = array();
     }
     foreach (wpef7_messages() as $key => $arr) {
         if (!isset($this->messages[$key])) {
             $this->messages[$key] = $arr['default'];
         }
     }
 }