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(); } } add_action( 'admin_menu', 'wpcf7_admin_menu', 9 ); function wpcf7_admin_menu() { add_menu_page( __( 'Contact Form 7', 'wpcf7' ), __( 'Contact', 'wpcf7' ), WPCF7_ADMIN_READ_CAPABILITY, 'wpcf7', 'wpcf7_admin_management_page', wpcf7_plugin_url( 'admin/images/menu-icon.png' ) ); add_submenu_page( 'wpcf7', __( 'Edit Contact Forms', 'wpcf7' ), __( 'Edit', 'wpcf7' ), WPCF7_ADMIN_READ_CAPABILITY, 'wpcf7', 'wpcf7_admin_management_page' ); } add_action( 'admin_enqueue_scripts', 'wpcf7_admin_enqueue_styles' ); function wpcf7_admin_enqueue_styles() { global $plugin_page; if ( ! isset( $plugin_page ) || 'wpcf7' != $plugin_page ) return; wp_enqueue_style( 'thickbox' ); wp_enqueue_style( 'contact-form-7-admin', wpcf7_plugin_url( 'admin/styles.css' ), array(), WPCF7_VERSION, 'all' ); if ( wpcf7_is_rtl() ) { wp_enqueue_style( 'contact-form-7-admin-rtl', wpcf7_plugin_url( 'admin/styles-rtl.css' ), array(), WPCF7_VERSION, 'all' ); } } add_action( 'admin_enqueue_scripts', 'wpcf7_admin_enqueue_scripts' ); function wpcf7_admin_enqueue_scripts() { global $plugin_page, $wpcf7_tag_generators; if ( ! isset( $plugin_page ) || 'wpcf7' != $plugin_page ) return; wp_enqueue_script( 'thickbox' ); wp_enqueue_script( 'postbox' ); wp_enqueue_script( 'wpcf7-admin-taggenerator', wpcf7_plugin_url( 'admin/taggenerator.js' ), array( 'jquery' ), WPCF7_VERSION, true ); wp_enqueue_script( 'wpcf7-admin', wpcf7_plugin_url( 'admin/scripts.js' ), array( 'jquery', 'wpcf7-admin-taggenerator' ), WPCF7_VERSION, true ); $taggenerators = array(); foreach ( (array) $wpcf7_tag_generators as $name => $tg ) { $taggenerators[$name] = array_merge( (array) $tg['options'], array( 'title' => $tg['title'], 'content' => $tg['content'] ) ); } wp_localize_script( 'wpcf7-admin', '_wpcf7', array( 'generateTag' => __( 'Generate Tag', 'wpcf7' ), 'pluginUrl' => wpcf7_plugin_url(), 'tagGenerators' => $taggenerators ) ); } 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'; } /* Misc */ add_filter( 'plugin_action_links', 'wpcf7_plugin_action_links', 10, 2 ); function wpcf7_plugin_action_links( $links, $file ) { if ( $file != WPCF7_PLUGIN_BASENAME ) return $links; $url = wpcf7_admin_url(); $settings_link = '' . esc_html( __( 'Settings', 'wpcf7' ) ) . ''; array_unshift( $links, $settings_link ); return $links; } add_action( 'wpcf7_admin_before_subsubsub', 'wpcf7_cf7com_links', 9 ); function wpcf7_cf7com_links( &$contact_form ) { $links = '
Contact Form 7 %1$s requires WordPress %2$s or higher. Please update WordPress first.', 'wpcf7' ), WPCF7_VERSION, WPCF7_REQUIRED_WP_VERSION, admin_url( 'update-core.php' ) ); ?>