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'); }
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 WPCF8_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' => 1 == $_POST['wpcf7-mail-use-html'] ? true : false); $mail_2 = array('active' => 1 == $_POST['wpcf7-mail-2-active'] ? true : false, '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' => 1 == $_POST['wpcf7-mail-2-use-html'] ? true : false); $messages = array('mail_sent_ok' => trim($_POST['wpcf7-message-mail-sent-ok']), 'mail_sent_ng' => trim($_POST['wpcf7-message-mail-sent-ng']), 'akismet_says_spam' => trim($_POST['wpcf7-message-akismet-says-spam']), 'validation_error' => trim($_POST['wpcf7-message-validation-error']), 'accept_terms' => trim($_POST['wpcf7-message-accept-terms']), 'invalid_email' => trim($_POST['wpcf7-message-invalid-email']), 'invalid_required' => trim($_POST['wpcf7-message-invalid-required']), 'quiz_answer_not_correct' => trim($_POST['wpcf7-message-quiz-answer-not-correct']), 'captcha_not_match' => trim($_POST['wpcf7-message-captcha-not-match']), 'upload_failed' => trim($_POST['wpcf7-message-upload-failed']), 'upload_file_type_invalid' => trim($_POST['wpcf7-message-upload-file-type-invalid']), 'upload_file_too_large' => trim($_POST['wpcf7-message-upload-file-too-large'])); $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('admin.php', $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('admin.php', $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('admin.php', 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('admin.php', $query)); exit; } add_menu_page(__('Contact Form 7', 'wpcf7'), __('Contact', 'wpcf7'), WPCF8_ADMIN_READ_CAPABILITY, __FILE__, 'wpcf7_admin_management_page'); add_submenu_page(__FILE__, __('Edit Contact Forms', 'wpcf7'), __('Edit', 'wpcf7'), WPCF8_ADMIN_READ_CAPABILITY, __FILE__, 'wpcf7_admin_management_page'); }
<input type="submit" name="wpcf7-delete" class="delete" value="<?php echo esc_attr(__('Delete', 'wpcf7')); ?> " <?php echo "onclick=\"if (confirm('" . esc_js(__("You are about to delete this contact form.\n 'Cancel' to stop, 'OK' to delete.", 'wpcf7')) . "')) {this.form._wpnonce.value = '{$delete_nonce}'; return true;} return false;\""; ?> /> </div> <?php } ?> </div> <?php if (wpcf7_admin_has_edit_cap()) { add_meta_box('formdiv', __('Form', 'wpcf7'), 'wpcf7_form_meta_box', 'cfseven', 'form', 'core'); add_meta_box('maildiv', __('Mail', 'wpcf7'), 'wpcf7_mail_meta_box', 'cfseven', 'mail', 'core'); add_meta_box('mail2div', __('Mail (2)', 'wpcf7'), 'wpcf7_mail_meta_box', 'cfseven', 'mail_2', 'core', array('id' => 'wpcf7-mail-2', 'name' => 'mail_2', 'use' => __('Use mail (2)', 'wpcf7'))); add_meta_box('messagesdiv', __('Messages', 'wpcf7'), 'wpcf7_messages_meta_box', 'cfseven', 'messages', 'core'); add_meta_box('additionalsettingsdiv', __('Additional Settings', 'wpcf7'), 'wpcf7_additional_settings_meta_box', 'cfseven', 'additional_settings', 'core'); } do_action_ref_array('wpcf7_admin_after_general_settings', array(&$cf)); do_meta_boxes('cfseven', 'form', $cf); do_action_ref_array('wpcf7_admin_after_form', array(&$cf)); do_meta_boxes('cfseven', 'mail', $cf); do_action_ref_array('wpcf7_admin_after_mail', array(&$cf)); do_meta_boxes('cfseven', 'mail_2', $cf); do_action_ref_array('wpcf7_admin_after_mail_2', array(&$cf)); do_meta_boxes('cfseven', 'messages', $cf); do_action_ref_array('wpcf7_admin_after_messages', array(&$cf));
/** * This is the method in charge to create the metabox for integration with Contact Form 7 * @params none * @since 0.1 * return null * DEPRECATED SINCE 1.4.1 * */ public function add_cf7cloud_meta() { global $wpcf7; if (wpcf7_admin_has_edit_cap()) { add_meta_box('cf7cf7clouddiv', __('Contact Form 7 Integrations by ContactUs.com', 'wpcf7'), array($this, 'wpcf7_cf7cloud_add_contactus_analytics'), 'cf7clouddatabase', 'cf7_cf7cloud', 'core', array('id' => 'wpcf7-cf7-integrations', 'name' => 'cf7_cf7cloud', 'use' => __('Turn On Contact Form 7 Integrations', 'wpcf7'))); } }
static function add_meta_box() { if (wpcf7_admin_has_edit_cap()) { add_meta_box('cf7ctctdiv', __('Constant Contact', 'ctctcf7'), array('CTCTCF7', 'metabox'), 'cfseven', 'cf7_ctct', 'core', array('id' => 'ctctcf7', 'name' => 'cf7_ctct', 'use' => __('Use Constant Contact', 'ctctcf7'))); } }
/** * Add panels in Contact Form 7 4.2+ * * @since 2.1 * * @param array $panels registered tabs in Form Editor * * @return array tabs with CTCTCF7 tab added */ function wpcf7_editor_panels($panels = array()) { if (wpcf7_admin_has_edit_cap()) { $panels['ctctcf7'] = array('title' => __('Constant Contact', 'ctctcf7'), 'callback' => array($this, 'metabox')); } return $panels; }
function wpcf7_admin_management_page() { $contact_forms = get_posts(array('numberposts' => -1, 'orderby' => 'ID', 'order' => 'ASC', 'post_type' => 'wpcf7_contact_form')); $cf = null; $unsaved = false; if (!isset($_GET['contactform'])) { $_GET['contactform'] = ''; } if ('new' == $_GET['contactform'] && wpcf7_admin_has_edit_cap()) { $unsaved = true; $current = -1; $cf = wpcf7_get_contact_form_default_pack(array('locale' => isset($_GET['locale']) ? $_GET['locale'] : '')); } elseif ($cf = wpcf7_contact_form($_GET['contactform'])) { $current = (int) $_GET['contactform']; } else { $first = reset($contact_forms); // Returns first item if ($first) { $current = $first->ID; $cf = wpcf7_contact_form($current); } } require_once WPCF7_PLUGIN_DIR . '/admin/includes/meta-boxes.php'; require_once WPCF7_PLUGIN_DIR . '/admin/edit.php'; }