css
8 years ago
images
11 years ago
includes
8 years ago
js
8 years ago
admin.php
8 years ago
edit-contact-form.php
8 years ago
edit-contact-form.php
285 lines
| 1 | <?php |
| 2 | |
| 3 | // don't load directly |
| 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | die( '-1' ); |
| 6 | } |
| 7 | |
| 8 | function wpcf7_admin_save_button( $post_id ) { |
| 9 | static $button = ''; |
| 10 | |
| 11 | if ( ! empty( $button ) ) { |
| 12 | echo $button; |
| 13 | return; |
| 14 | } |
| 15 | |
| 16 | $nonce = wp_create_nonce( 'wpcf7-save-contact-form_' . $post_id ); |
| 17 | |
| 18 | $onclick = sprintf( |
| 19 | "this.form._wpnonce.value = '%s';" |
| 20 | . " this.form.action.value = 'save';" |
| 21 | . " return true;", |
| 22 | $nonce ); |
| 23 | |
| 24 | $button = sprintf( |
| 25 | '<input type="submit" class="button-primary" name="wpcf7-save" value="%1$s" onclick="%2$s" />', |
| 26 | esc_attr( __( 'Save', 'contact-form-7' ) ), |
| 27 | $onclick ); |
| 28 | |
| 29 | echo $button; |
| 30 | } |
| 31 | |
| 32 | ?><div class="wrap"> |
| 33 | |
| 34 | <h1 class="wp-heading-inline"><?php |
| 35 | if ( $post->initial() ) { |
| 36 | echo esc_html( __( 'Add New Contact Form', 'contact-form-7' ) ); |
| 37 | } else { |
| 38 | echo esc_html( __( 'Edit Contact Form', 'contact-form-7' ) ); |
| 39 | } |
| 40 | ?></h1> |
| 41 | |
| 42 | <?php |
| 43 | if ( ! $post->initial() && current_user_can( 'wpcf7_edit_contact_forms' ) ) { |
| 44 | echo sprintf( '<a href="%1$s" class="add-new-h2">%2$s</a>', |
| 45 | esc_url( menu_page_url( 'wpcf7-new', false ) ), |
| 46 | esc_html( __( 'Add New', 'contact-form-7' ) ) ); |
| 47 | } |
| 48 | ?> |
| 49 | |
| 50 | <hr class="wp-header-end"> |
| 51 | |
| 52 | <?php do_action( 'wpcf7_admin_warnings' ); ?> |
| 53 | <?php do_action( 'wpcf7_admin_notices' ); ?> |
| 54 | |
| 55 | <?php |
| 56 | if ( $post ) : |
| 57 | |
| 58 | if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) { |
| 59 | $disabled = ''; |
| 60 | } else { |
| 61 | $disabled = ' disabled="disabled"'; |
| 62 | } |
| 63 | ?> |
| 64 | |
| 65 | <form method="post" action="<?php echo esc_url( add_query_arg( array( 'post' => $post_id ), menu_page_url( 'wpcf7', false ) ) ); ?>" id="wpcf7-admin-form-element"<?php do_action( 'wpcf7_post_edit_form_tag' ); ?>> |
| 66 | <?php |
| 67 | if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) { |
| 68 | wp_nonce_field( 'wpcf7-save-contact-form_' . $post_id ); |
| 69 | } |
| 70 | ?> |
| 71 | <input type="hidden" id="post_ID" name="post_ID" value="<?php echo (int) $post_id; ?>" /> |
| 72 | <input type="hidden" id="wpcf7-locale" name="wpcf7-locale" value="<?php echo esc_attr( $post->locale() ); ?>" /> |
| 73 | <input type="hidden" id="hiddenaction" name="action" value="save" /> |
| 74 | <input type="hidden" id="active-tab" name="active-tab" value="<?php echo isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : '0'; ?>" /> |
| 75 | |
| 76 | <div id="poststuff"> |
| 77 | <div id="post-body" class="metabox-holder columns-2"> |
| 78 | <div id="post-body-content"> |
| 79 | <div id="titlediv"> |
| 80 | <div id="titlewrap"> |
| 81 | <label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo esc_html( __( 'Enter title here', 'contact-form-7' ) ); ?></label> |
| 82 | <?php |
| 83 | $posttitle_atts = array( |
| 84 | 'type' => 'text', |
| 85 | 'name' => 'post_title', |
| 86 | 'size' => 30, |
| 87 | 'value' => $post->initial() ? '' : $post->title(), |
| 88 | 'id' => 'title', |
| 89 | 'spellcheck' => 'true', |
| 90 | 'autocomplete' => 'off', |
| 91 | 'disabled' => |
| 92 | current_user_can( 'wpcf7_edit_contact_form', $post_id ) ? '' : 'disabled', |
| 93 | ); |
| 94 | |
| 95 | echo sprintf( '<input %s />', wpcf7_format_atts( $posttitle_atts ) ); |
| 96 | ?> |
| 97 | </div><!-- #titlewrap --> |
| 98 | |
| 99 | <div class="inside"> |
| 100 | <?php |
| 101 | if ( ! $post->initial() ) : |
| 102 | ?> |
| 103 | <p class="description"> |
| 104 | <label for="wpcf7-shortcode"><?php echo esc_html( __( "Copy this shortcode and paste it into your post, page, or text widget content:", 'contact-form-7' ) ); ?></label> |
| 105 | <span class="shortcode wp-ui-highlight"><input type="text" id="wpcf7-shortcode" onfocus="this.select();" readonly="readonly" class="large-text code" value="<?php echo esc_attr( $post->shortcode() ); ?>" /></span> |
| 106 | </p> |
| 107 | <?php |
| 108 | if ( $old_shortcode = $post->shortcode( array( 'use_old_format' => true ) ) ) : |
| 109 | ?> |
| 110 | <p class="description"> |
| 111 | <label for="wpcf7-shortcode-old"><?php echo esc_html( __( "You can also use this old-style shortcode:", 'contact-form-7' ) ); ?></label> |
| 112 | <span class="shortcode old"><input type="text" id="wpcf7-shortcode-old" onfocus="this.select();" readonly="readonly" class="large-text code" value="<?php echo esc_attr( $old_shortcode ); ?>" /></span> |
| 113 | </p> |
| 114 | <?php |
| 115 | endif; |
| 116 | endif; |
| 117 | ?> |
| 118 | </div> |
| 119 | </div><!-- #titlediv --> |
| 120 | </div><!-- #post-body-content --> |
| 121 | |
| 122 | <div id="postbox-container-1" class="postbox-container"> |
| 123 | <?php if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) : ?> |
| 124 | <div id="submitdiv" class="postbox"> |
| 125 | <h3><?php echo esc_html( __( 'Status', 'contact-form-7' ) ); ?></h3> |
| 126 | <div class="inside"> |
| 127 | <div class="submitbox" id="submitpost"> |
| 128 | |
| 129 | <div id="minor-publishing-actions"> |
| 130 | |
| 131 | <div class="hidden"> |
| 132 | <input type="submit" class="button-primary" name="wpcf7-save" value="<?php echo esc_attr( __( 'Save', 'contact-form-7' ) ); ?>" /> |
| 133 | </div> |
| 134 | |
| 135 | <?php |
| 136 | if ( ! $post->initial() ) : |
| 137 | $copy_nonce = wp_create_nonce( 'wpcf7-copy-contact-form_' . $post_id ); |
| 138 | ?> |
| 139 | <input type="submit" name="wpcf7-copy" class="copy button" value="<?php echo esc_attr( __( 'Duplicate', 'contact-form-7' ) ); ?>" <?php echo "onclick=\"this.form._wpnonce.value = '$copy_nonce'; this.form.action.value = 'copy'; return true;\""; ?> /> |
| 140 | <?php endif; ?> |
| 141 | </div><!-- #minor-publishing-actions --> |
| 142 | |
| 143 | <div id="misc-publishing-actions"> |
| 144 | <?php do_action( 'wpcf7_admin_misc_pub_section', $post_id ); ?> |
| 145 | </div><!-- #misc-publishing-actions --> |
| 146 | |
| 147 | <div id="major-publishing-actions"> |
| 148 | |
| 149 | <?php |
| 150 | if ( ! $post->initial() ) : |
| 151 | $delete_nonce = wp_create_nonce( 'wpcf7-delete-contact-form_' . $post_id ); |
| 152 | ?> |
| 153 | <div id="delete-action"> |
| 154 | <input type="submit" name="wpcf7-delete" class="delete submitdelete" value="<?php echo esc_attr( __( 'Delete', 'contact-form-7' ) ); ?>" <?php echo "onclick=\"if (confirm('" . esc_js( __( "You are about to delete this contact form.\n 'Cancel' to stop, 'OK' to delete.", 'contact-form-7' ) ) . "')) {this.form._wpnonce.value = '$delete_nonce'; this.form.action.value = 'delete'; return true;} return false;\""; ?> /> |
| 155 | </div><!-- #delete-action --> |
| 156 | <?php endif; ?> |
| 157 | |
| 158 | <div id="publishing-action"> |
| 159 | <span class="spinner"></span> |
| 160 | <?php wpcf7_admin_save_button( $post_id ); ?> |
| 161 | </div> |
| 162 | <div class="clear"></div> |
| 163 | </div><!-- #major-publishing-actions --> |
| 164 | </div><!-- #submitpost --> |
| 165 | </div> |
| 166 | </div><!-- #submitdiv --> |
| 167 | <?php endif; ?> |
| 168 | |
| 169 | <div id="informationdiv" class="postbox"> |
| 170 | <h3><?php echo esc_html( __( "Do you need help?", 'contact-form-7' ) ); ?></h3> |
| 171 | <div class="inside"> |
| 172 | <p><?php echo esc_html( __( "Here are some available options to help solve your problems.", 'contact-form-7' ) ); ?></p> |
| 173 | <ol> |
| 174 | <li><?php echo sprintf( |
| 175 | /* translators: 1: FAQ, 2: Docs ("FAQ & Docs") */ |
| 176 | __( '%1$s & %2$s', 'contact-form-7' ), |
| 177 | wpcf7_link( |
| 178 | __( 'https://contactform7.com/faq/', 'contact-form-7' ), |
| 179 | __( 'FAQ', 'contact-form-7' ) |
| 180 | ), |
| 181 | wpcf7_link( |
| 182 | __( 'https://contactform7.com/docs/', 'contact-form-7' ), |
| 183 | __( 'Docs', 'contact-form-7' ) |
| 184 | ) |
| 185 | ); ?></li> |
| 186 | <li><?php echo wpcf7_link( |
| 187 | __( 'https://wordpress.org/support/plugin/contact-form-7/', 'contact-form-7' ), |
| 188 | __( 'Support Forums', 'contact-form-7' ) |
| 189 | ); ?></li> |
| 190 | <?php if ( 'en_' === substr( get_user_locale(), 0, 3 ) ) : ?> |
| 191 | <li><?php echo wpcf7_link( |
| 192 | __( 'https://contactform7.com/custom-development/', 'contact-form-7' ), |
| 193 | __( 'Professional Services', 'contact-form-7' ) |
| 194 | ); ?></li> |
| 195 | <?php endif; ?> |
| 196 | </ol> |
| 197 | </div> |
| 198 | </div><!-- #informationdiv --> |
| 199 | |
| 200 | </div><!-- #postbox-container-1 --> |
| 201 | |
| 202 | <div id="postbox-container-2" class="postbox-container"> |
| 203 | <div id="contact-form-editor"> |
| 204 | <div class="keyboard-interaction"><?php |
| 205 | echo sprintf( |
| 206 | /* translators: 1: ◀ ▶ dashicon, 2: screen reader text for the dashicon */ |
| 207 | esc_html( __( '%1$s %2$s keys switch panels', 'contact-form-7' ) ), |
| 208 | '<span class="dashicons dashicons-leftright" aria-hidden="true"></span>', |
| 209 | sprintf( |
| 210 | '<span class="screen-reader-text">%s</span>', |
| 211 | /* translators: screen reader text */ |
| 212 | esc_html( __( '(left and right arrow)', 'contact-form-7' ) ) |
| 213 | ) |
| 214 | ); |
| 215 | ?></div> |
| 216 | |
| 217 | <?php |
| 218 | |
| 219 | $editor = new WPCF7_Editor( $post ); |
| 220 | $panels = array(); |
| 221 | |
| 222 | if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) { |
| 223 | $panels = array( |
| 224 | 'form-panel' => array( |
| 225 | 'title' => __( 'Form', 'contact-form-7' ), |
| 226 | 'callback' => 'wpcf7_editor_panel_form', |
| 227 | ), |
| 228 | 'mail-panel' => array( |
| 229 | 'title' => __( 'Mail', 'contact-form-7' ), |
| 230 | 'callback' => 'wpcf7_editor_panel_mail', |
| 231 | ), |
| 232 | 'messages-panel' => array( |
| 233 | 'title' => __( 'Messages', 'contact-form-7' ), |
| 234 | 'callback' => 'wpcf7_editor_panel_messages', |
| 235 | ), |
| 236 | ); |
| 237 | |
| 238 | $additional_settings = trim( $post->prop( 'additional_settings' ) ); |
| 239 | $additional_settings = explode( "\n", $additional_settings ); |
| 240 | $additional_settings = array_filter( $additional_settings ); |
| 241 | $additional_settings = count( $additional_settings ); |
| 242 | |
| 243 | $panels['additional-settings-panel'] = array( |
| 244 | 'title' => $additional_settings |
| 245 | /* translators: %d: number of additional settings */ |
| 246 | ? sprintf( |
| 247 | __( 'Additional Settings (%d)', 'contact-form-7' ), |
| 248 | $additional_settings ) |
| 249 | : __( 'Additional Settings', 'contact-form-7' ), |
| 250 | 'callback' => 'wpcf7_editor_panel_additional_settings', |
| 251 | ); |
| 252 | } |
| 253 | |
| 254 | $panels = apply_filters( 'wpcf7_editor_panels', $panels ); |
| 255 | |
| 256 | foreach ( $panels as $id => $panel ) { |
| 257 | $editor->add_panel( $id, $panel['title'], $panel['callback'] ); |
| 258 | } |
| 259 | |
| 260 | $editor->display(); |
| 261 | ?> |
| 262 | </div><!-- #contact-form-editor --> |
| 263 | |
| 264 | <?php if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) : ?> |
| 265 | <p class="submit"><?php wpcf7_admin_save_button( $post_id ); ?></p> |
| 266 | <?php endif; ?> |
| 267 | |
| 268 | </div><!-- #postbox-container-2 --> |
| 269 | |
| 270 | </div><!-- #post-body --> |
| 271 | <br class="clear" /> |
| 272 | </div><!-- #poststuff --> |
| 273 | </form> |
| 274 | |
| 275 | <?php endif; ?> |
| 276 | |
| 277 | </div><!-- .wrap --> |
| 278 | |
| 279 | <?php |
| 280 | |
| 281 | $tag_generator = WPCF7_TagGenerator::get_instance(); |
| 282 | $tag_generator->print_panels( $post ); |
| 283 | |
| 284 | do_action( 'wpcf7_admin_footer', $post ); |
| 285 |