Beispiel #1
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');
}
Beispiel #2
0
	</div>
	</td>
	</tr>
	</tbody>
	</table>

<?php 
    }
    ?>

<?php 
    do_action_ref_array('wpef7_admin_after_additional_settings', array(&$cf));
    ?>

<?php 
    if (wpef7_admin_has_edit_cap()) {
        ?>

	<table class="widefat" style="margin-top: 1em;">
	<tbody>
	<tr>
	<td scope="col">
	<div class="save-eval-form">
	<input type="submit" class="button button-highlighted" name="wpef7-save" value="<?php 
        echo esc_attr(__('Save', 'wpef7'));
        ?>
" />
	</div>
	</td>
	</tr>
	</tbody>