/admin/edit-contact-form.php

  1. <?php 
  2.  
  3. // don't load directly 
  4. if ( ! defined( 'ABSPATH' ) ) { 
  5. die( '-1' ); 
  6.  
  7. function wpcf7_admin_save_button( $post_id ) { 
  8. static $button = ''; 
  9.  
  10. if ( ! empty( $button ) ) { 
  11. echo $button; 
  12. return; 
  13.  
  14. $nonce = wp_create_nonce( 'wpcf7-save-contact-form_' . $post_id ); 
  15.  
  16. $onclick = sprintf( 
  17. "this.form._wpnonce.value = '%s';" 
  18. . " this.form.action.value = 'save';" 
  19. . " return true;",  
  20. $nonce ); 
  21.  
  22. $button = sprintf( 
  23. '<input type="submit" class="button-primary" name="wpcf7-save" value="%1$s" onclick="%2$s" />',  
  24. esc_attr( __( 'Save', 'contact-form-7' ) ),  
  25. $onclick ); 
  26.  
  27. echo $button; 
  28.  
  29. ?><div class="wrap"> 
  30.  
  31. <h1><?php 
  32. if ( $post->initial() ) { 
  33. echo esc_html( __( 'Add New Contact Form', 'contact-form-7' ) ); 
  34. } else { 
  35. echo esc_html( __( 'Edit Contact Form', 'contact-form-7' ) ); 
  36.  
  37. if ( current_user_can( 'wpcf7_edit_contact_forms' ) ) { 
  38. echo ' <a href="' . esc_url( menu_page_url( 'wpcf7-new', false ) ) . '" class="add-new-h2">' . esc_html( __( 'Add New', 'contact-form-7' ) ) . '</a>'; 
  39. ?></h1> 
  40.  
  41. <?php do_action( 'wpcf7_admin_warnings' ); ?> 
  42. <?php do_action( 'wpcf7_admin_notices' ); ?> 
  43.  
  44. <?php 
  45. if ( $post ) : 
  46.  
  47. if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) { 
  48. $disabled = ''; 
  49. } else { 
  50. $disabled = ' disabled="disabled"'; 
  51. ?> 
  52.  
  53. <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' ); ?>> 
  54. <?php 
  55. if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) { 
  56. wp_nonce_field( 'wpcf7-save-contact-form_' . $post_id ); 
  57. ?> 
  58. <input type="hidden" id="post_ID" name="post_ID" value="<?php echo (int) $post_id; ?>" /> 
  59. <input type="hidden" id="wpcf7-locale" name="wpcf7-locale" value="<?php echo esc_attr( $post->locale() ); ?>" /> 
  60. <input type="hidden" id="hiddenaction" name="action" value="save" /> 
  61. <input type="hidden" id="active-tab" name="active-tab" value="<?php echo isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : '0'; ?>" /> 
  62.  
  63. <div id="poststuff"> 
  64. <div id="post-body" class="metabox-holder columns-2"> 
  65. <div id="post-body-content"> 
  66. <div id="titlediv"> 
  67. <div id="titlewrap"> 
  68. <label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo esc_html( __( 'Enter title here', 'contact-form-7' ) ); ?></label> 
  69. <?php 
  70. $posttitle_atts = array( 
  71. 'type' => 'text',  
  72. 'name' => 'post_title',  
  73. 'size' => 30,  
  74. 'value' => $post->initial() ? '' : $post->title(),  
  75. 'id' => 'title',  
  76. 'spellcheck' => 'true',  
  77. 'autocomplete' => 'off',  
  78. 'disabled' => current_user_can( 'wpcf7_edit_contact_form', $post_id ) 
  79. ? '' : 'disabled' ); 
  80.  
  81. echo sprintf( '<input %s />', wpcf7_format_atts( $posttitle_atts ) ); 
  82. ?> 
  83. </div><!-- #titlewrap --> 
  84.  
  85. <div class="inside"> 
  86. <?php 
  87. if ( ! $post->initial() ) : 
  88. ?> 
  89. <p class="description"> 
  90. <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> 
  91. <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> 
  92. </p> 
  93. <?php 
  94. if ( $old_shortcode = $post->shortcode( array( 'use_old_format' => true ) ) ) : 
  95. ?> 
  96. <p class="description"> 
  97. <label for="wpcf7-shortcode-old"><?php echo esc_html( __( "You can also use this old-style shortcode:", 'contact-form-7' ) ); ?></label> 
  98. <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> 
  99. </p> 
  100. <?php 
  101. endif; 
  102. endif; 
  103. ?> 
  104. </div> 
  105. </div><!-- #titlediv --> 
  106. </div><!-- #post-body-content --> 
  107.  
  108. <div id="postbox-container-1" class="postbox-container"> 
  109. <?php if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) : ?> 
  110. <div id="submitdiv" class="postbox"> 
  111. <h3><?php echo esc_html( __( 'Status', 'contact-form-7' ) ); ?></h3> 
  112. <div class="inside"> 
  113. <div class="submitbox" id="submitpost"> 
  114.  
  115. <div id="minor-publishing-actions"> 
  116.  
  117. <div class="hidden"> 
  118. <input type="submit" class="button-primary" name="wpcf7-save" value="<?php echo esc_attr( __( 'Save', 'contact-form-7' ) ); ?>" /> 
  119. </div> 
  120.  
  121. <?php 
  122. if ( ! $post->initial() ) : 
  123. $copy_nonce = wp_create_nonce( 'wpcf7-copy-contact-form_' . $post_id ); 
  124. ?> 
  125. <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;\""; ?> /> 
  126. <?php endif; ?> 
  127. </div><!-- #minor-publishing-actions --> 
  128.  
  129. <div id="misc-publishing-actions"> 
  130. <?php do_action( 'wpcf7_admin_misc_pub_section', $post_id ); ?> 
  131. </div><!-- #misc-publishing-actions --> 
  132.  
  133. <div id="major-publishing-actions"> 
  134.  
  135. <?php 
  136. if ( ! $post->initial() ) : 
  137. $delete_nonce = wp_create_nonce( 'wpcf7-delete-contact-form_' . $post_id ); 
  138. ?> 
  139. <div id="delete-action"> 
  140. <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;\""; ?> /> 
  141. </div><!-- #delete-action --> 
  142. <?php endif; ?> 
  143.  
  144. <div id="publishing-action"> 
  145. <span class="spinner"></span> 
  146. <?php wpcf7_admin_save_button( $post_id ); ?> 
  147. </div> 
  148. <div class="clear"></div> 
  149. </div><!-- #major-publishing-actions --> 
  150. </div><!-- #submitpost --> 
  151. </div> 
  152. </div><!-- #submitdiv --> 
  153. <?php endif; ?> 
  154.  
  155. <div id="informationdiv" class="postbox"> 
  156. <h3><?php echo esc_html( __( 'Information', 'contact-form-7' ) ); ?></h3> 
  157. <div class="inside"> 
  158. <ul> 
  159. <li><?php echo wpcf7_link( __( 'https://contactform7.com/docs/', 'contact-form-7' ), __( 'Docs', 'contact-form-7' ) ); ?></li> 
  160. <li><?php echo wpcf7_link( __( 'https://contactform7.com/faq/', 'contact-form-7' ), __( 'FAQ', 'contact-form-7' ) ); ?></li> 
  161. <li><?php echo wpcf7_link( __( 'https://contactform7.com/support/', 'contact-form-7' ), __( 'Support', 'contact-form-7' ) ); ?></li> 
  162. </ul> 
  163. </div> 
  164. </div><!-- #informationdiv --> 
  165.  
  166. </div><!-- #postbox-container-1 --> 
  167.  
  168. <div id="postbox-container-2" class="postbox-container"> 
  169. <div id="contact-form-editor"> 
  170. <div class="keyboard-interaction"><?php echo sprintf( esc_html( __( '%s keys switch panels', 'contact-form-7' ) ), '<span class="dashicons dashicons-leftright"></span>' ); ?></div> 
  171.  
  172. <?php 
  173.  
  174. $editor = new WPCF7_Editor( $post ); 
  175. $panels = array(); 
  176.  
  177. if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) { 
  178. $panels = array( 
  179. 'form-panel' => array( 
  180. 'title' => __( 'Form', 'contact-form-7' ),  
  181. 'callback' => 'wpcf7_editor_panel_form' ),  
  182. 'mail-panel' => array( 
  183. 'title' => __( 'Mail', 'contact-form-7' ),  
  184. 'callback' => 'wpcf7_editor_panel_mail' ),  
  185. 'messages-panel' => array( 
  186. 'title' => __( 'Messages', 'contact-form-7' ),  
  187. 'callback' => 'wpcf7_editor_panel_messages' ) ); 
  188.  
  189. $additional_settings = trim( $post->prop( 'additional_settings' ) ); 
  190. $additional_settings = explode( "\n", $additional_settings ); 
  191. $additional_settings = array_filter( $additional_settings ); 
  192. $additional_settings = count( $additional_settings ); 
  193.  
  194. $panels['additional-settings-panel'] = array( 
  195. 'title' => $additional_settings 
  196. ? sprintf( 
  197. __( 'Additional Settings (%d)', 'contact-form-7' ),  
  198. $additional_settings ) 
  199. : __( 'Additional Settings', 'contact-form-7' ),  
  200. 'callback' => 'wpcf7_editor_panel_additional_settings' ); 
  201.  
  202. $panels = apply_filters( 'wpcf7_editor_panels', $panels ); 
  203.  
  204. foreach ( $panels as $id => $panel ) { 
  205. $editor->add_panel( $id, $panel['title'], $panel['callback'] ); 
  206.  
  207. $editor->display(); 
  208. ?> 
  209. </div><!-- #contact-form-editor --> 
  210.  
  211. <?php if ( current_user_can( 'wpcf7_edit_contact_form', $post_id ) ) : ?> 
  212. <p class="submit"><?php wpcf7_admin_save_button( $post_id ); ?></p> 
  213. <?php endif; ?> 
  214.  
  215. </div><!-- #postbox-container-2 --> 
  216.  
  217. </div><!-- #post-body --> 
  218. <br class="clear" /> 
  219. </div><!-- #poststuff --> 
  220. </form> 
  221.  
  222. <?php endif; ?> 
  223.  
  224. </div><!-- .wrap --> 
  225.  
  226. <?php 
  227.  
  228. $tag_generator = WPCF7_TagGenerator::get_instance(); 
  229. $tag_generator->print_panels( $post ); 
  230.  
  231. do_action( 'wpcf7_admin_footer', $post ); 
.