PageRenderTime 41ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/contact-form-7/admin/includes/editor.php

https://gitlab.com/webkod3r/tripolis
PHP | 245 lines | 207 code | 38 blank | 0 comment | 26 complexity | d6dcf76fb473749a9100698b0855becc MD5 | raw file
  1. <?php
  2. class WPCF7_Editor {
  3. private $contact_form;
  4. private $panels = array();
  5. public function __construct( WPCF7_ContactForm $contact_form ) {
  6. $this->contact_form = $contact_form;
  7. }
  8. public function add_panel( $id, $title, $callback ) {
  9. if ( wpcf7_is_name( $id ) ) {
  10. $this->panels[$id] = array(
  11. 'title' => $title,
  12. 'callback' => $callback );
  13. }
  14. }
  15. public function display() {
  16. if ( empty( $this->panels ) ) {
  17. return;
  18. }
  19. echo '<ul id="contact-form-editor-tabs">';
  20. foreach ( $this->panels as $id => $panel ) {
  21. echo sprintf( '<li id="%1$s-tab"><a href="#%1$s">%2$s</a></li>',
  22. esc_attr( $id ), esc_html( $panel['title'] ) );
  23. }
  24. echo '</ul>';
  25. foreach ( $this->panels as $id => $panel ) {
  26. echo sprintf( '<div class="contact-form-editor-panel" id="%1$s">',
  27. esc_attr( $id ) );
  28. call_user_func( $panel['callback'], $this->contact_form );
  29. echo '</div>';
  30. }
  31. }
  32. }
  33. function wpcf7_editor_panel_form( $post ) {
  34. ?>
  35. <h2><?php echo esc_html( __( 'Form', 'contact-form-7' ) ); ?></h2>
  36. <?php
  37. $tag_generator = WPCF7_TagGenerator::get_instance();
  38. $tag_generator->print_buttons();
  39. ?>
  40. <textarea id="wpcf7-form" name="wpcf7-form" cols="100" rows="24" class="large-text code"><?php echo esc_textarea( $post->prop( 'form' ) ); ?></textarea>
  41. <?php
  42. }
  43. function wpcf7_editor_panel_mail( $post ) {
  44. wpcf7_editor_box_mail( $post );
  45. echo '<br class="clear" />';
  46. wpcf7_editor_box_mail( $post, array(
  47. 'id' => 'wpcf7-mail-2',
  48. 'name' => 'mail_2',
  49. 'title' => __( 'Mail (2)', 'contact-form-7' ),
  50. 'use' => __( 'Use Mail (2)', 'contact-form-7' ) ) );
  51. }
  52. function wpcf7_editor_box_mail( $post, $args = '' ) {
  53. $args = wp_parse_args( $args, array(
  54. 'id' => 'wpcf7-mail',
  55. 'name' => 'mail',
  56. 'title' => __( 'Mail', 'contact-form-7' ),
  57. 'use' => null ) );
  58. $id = esc_attr( $args['id'] );
  59. $mail = wp_parse_args( $post->prop( $args['name'] ), array(
  60. 'active' => false, 'recipient' => '', 'sender' => '',
  61. 'subject' => '', 'body' => '', 'additional_headers' => '',
  62. 'attachments' => '', 'use_html' => false, 'exclude_blank' => false ) );
  63. $do_validate = wpcf7_validate_configuration();
  64. ?>
  65. <div class="contact-form-editor-box-mail" id="<?php echo $id; ?>">
  66. <h2><?php echo esc_html( $args['title'] ); ?></h2>
  67. <?php
  68. if ( ! empty( $args['use'] ) ) :
  69. ?>
  70. <label for="<?php echo $id; ?>-active"><input type="checkbox" id="<?php echo $id; ?>-active" name="<?php echo $id; ?>-active" class="toggle-form-table" value="1"<?php echo ( $mail['active'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( $args['use'] ); ?></label>
  71. <p class="description"><?php echo esc_html( __( "Mail (2) is an additional mail template often used as an autoresponder.", 'contact-form-7' ) ); ?></p>
  72. <?php
  73. endif;
  74. ?>
  75. <fieldset>
  76. <legend><?php echo esc_html( __( "In the following fields, you can use these mail-tags:", 'contact-form-7' ) ); ?><br />
  77. <?php $post->suggest_mail_tags( $args['name'] ); ?></legend>
  78. <table class="form-table">
  79. <tbody>
  80. <tr>
  81. <th scope="row">
  82. <label for="<?php echo $id; ?>-recipient"><?php echo esc_html( __( 'To', 'contact-form-7' ) ); ?></label>
  83. </th>
  84. <td>
  85. <?php $config_error = $post->config_error(
  86. sprintf( '%s.recipient', $args['name'] ) ); ?>
  87. <input type="text" id="<?php echo $id; ?>-recipient" name="<?php echo $id; ?>-recipient" class="large-text code" size="70" value="<?php echo esc_attr( $mail['recipient'] ); ?>"<?php if ( $do_validate && $config_error ) { echo ' aria-invalid="true"'; } ?> />
  88. <?php if ( $do_validate && $config_error ) {
  89. echo sprintf( '<br /><span role="alert" class="config-error">%s</span>', $config_error );
  90. } ?>
  91. </td>
  92. </tr>
  93. <tr>
  94. <th scope="row">
  95. <label for="<?php echo $id; ?>-sender"><?php echo esc_html( __( 'From', 'contact-form-7' ) ); ?></label>
  96. </th>
  97. <td>
  98. <?php $config_error = $post->config_error(
  99. sprintf( '%s.sender', $args['name'] ) ); ?>
  100. <input type="text" id="<?php echo $id; ?>-sender" name="<?php echo $id; ?>-sender" class="large-text code" size="70" value="<?php echo esc_attr( $mail['sender'] ); ?>"<?php if ( $do_validate && $config_error ) { echo ' aria-invalid="true"'; } ?> />
  101. <?php if ( $do_validate && $config_error ) {
  102. echo sprintf( '<br /><span role="alert" class="config-error">%s</span>', $config_error );
  103. } ?>
  104. </td>
  105. </tr>
  106. <tr>
  107. <th scope="row">
  108. <label for="<?php echo $id; ?>-subject"><?php echo esc_html( __( 'Subject', 'contact-form-7' ) ); ?></label>
  109. </th>
  110. <td>
  111. <?php $config_error = $post->config_error(
  112. sprintf( '%s.subject', $args['name'] ) ); ?>
  113. <input type="text" id="<?php echo $id; ?>-subject" name="<?php echo $id; ?>-subject" class="large-text code" size="70" value="<?php echo esc_attr( $mail['subject'] ); ?>"<?php if ( $do_validate && $config_error ) { echo ' aria-invalid="true"'; } ?> />
  114. <?php if ( $do_validate && $config_error ) {
  115. echo sprintf( '<br /><span role="alert" class="config-error">%s</span>', $config_error );
  116. } ?>
  117. </td>
  118. </tr>
  119. <tr>
  120. <th scope="row">
  121. <label for="<?php echo $id; ?>-additional-headers"><?php echo esc_html( __( 'Additional Headers', 'contact-form-7' ) ); ?></label>
  122. </th>
  123. <td>
  124. <?php $config_error = $post->config_error(
  125. sprintf( '%s.additional_headers', $args['name'] ) ); ?>
  126. <textarea id="<?php echo $id; ?>-additional-headers" name="<?php echo $id; ?>-additional-headers" cols="100" rows="4" class="large-text code"<?php if ( $do_validate && $config_error ) { echo ' aria-invalid="true"'; } ?>><?php echo esc_textarea( $mail['additional_headers'] ); ?></textarea>
  127. <?php if ( $do_validate && $config_error ) {
  128. echo sprintf( '<br /><span role="alert" class="config-error">%s</span>', $config_error );
  129. } ?>
  130. </td>
  131. </tr>
  132. <tr>
  133. <th scope="row">
  134. <label for="<?php echo $id; ?>-body"><?php echo esc_html( __( 'Message Body', 'contact-form-7' ) ); ?></label>
  135. </th>
  136. <td>
  137. <?php $config_error = $post->config_error(
  138. sprintf( '%s.body', $args['name'] ) ); ?>
  139. <textarea id="<?php echo $id; ?>-body" name="<?php echo $id; ?>-body" cols="100" rows="18" class="large-text code"<?php if ( $do_validate && $config_error ) { echo ' aria-invalid="true"'; } ?>><?php echo esc_textarea( $mail['body'] ); ?></textarea>
  140. <?php if ( $do_validate && $config_error ) {
  141. echo sprintf( '<br /><span role="alert" class="config-error">%s</span>', $config_error );
  142. } ?>
  143. <p><label for="<?php echo $id; ?>-exclude-blank"><input type="checkbox" id="<?php echo $id; ?>-exclude-blank" name="<?php echo $id; ?>-exclude-blank" value="1"<?php echo ( ! empty( $mail['exclude_blank'] ) ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Exclude lines with blank mail-tags from output', 'contact-form-7' ) ); ?></label></p>
  144. <p><label for="<?php echo $id; ?>-use-html"><input type="checkbox" id="<?php echo $id; ?>-use-html" name="<?php echo $id; ?>-use-html" value="1"<?php echo ( $mail['use_html'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Use HTML content type', 'contact-form-7' ) ); ?></label></p>
  145. </td>
  146. </tr>
  147. <tr>
  148. <th scope="row">
  149. <label for="<?php echo $id; ?>-attachments"><?php echo esc_html( __( 'File Attachments', 'contact-form-7' ) ); ?></label>
  150. </th>
  151. <td>
  152. <textarea id="<?php echo $id; ?>-attachments" name="<?php echo $id; ?>-attachments" cols="100" rows="4" class="large-text code"><?php echo esc_textarea( $mail['attachments'] ); ?></textarea>
  153. </td>
  154. </tr>
  155. </tbody>
  156. </table>
  157. </fieldset>
  158. </div>
  159. <?php
  160. }
  161. function wpcf7_editor_panel_messages( $post ) {
  162. $messages = wpcf7_messages();
  163. if ( isset( $messages['captcha_not_match'] )
  164. && ! wpcf7_use_really_simple_captcha() ) {
  165. unset( $messages['captcha_not_match'] );
  166. }
  167. $do_validate = wpcf7_validate_configuration();
  168. ?>
  169. <h2><?php echo esc_html( __( 'Messages', 'contact-form-7' ) ); ?></h2>
  170. <fieldset>
  171. <legend><?php echo esc_html( __( 'Edit messages used in the following situations.', 'contact-form-7' ) ); ?></legend>
  172. <?php
  173. foreach ( $messages as $key => $arr ) {
  174. $field_name = 'wpcf7-message-' . strtr( $key, '_', '-' );
  175. $config_error = $do_validate
  176. ? $post->config_error( sprintf( 'messages.%s', $key ) ) : '';
  177. ?>
  178. <p class="description">
  179. <label for="<?php echo $field_name; ?>"><?php echo esc_html( $arr['description'] ); ?><br />
  180. <input type="text" id="<?php echo $field_name; ?>" name="<?php echo $field_name; ?>" class="large-text" size="70" value="<?php echo esc_attr( $post->message( $key, false ) ); ?>"<?php echo $config_error ? ' aria-invalid="true"' : ''; ?> />
  181. <?php
  182. if ( $config_error ) {
  183. echo sprintf( '<br /><span role="alert" class="config-error">%s</span>', $config_error );
  184. }
  185. ?>
  186. </label>
  187. </p>
  188. <?php
  189. }
  190. ?>
  191. </fieldset>
  192. <?php
  193. }
  194. function wpcf7_editor_panel_additional_settings( $post ) {
  195. $desc_link = wpcf7_link(
  196. __( 'http://contactform7.com/additional-settings/', 'contact-form-7' ),
  197. __( 'Additional Settings', 'contact-form-7' ) );
  198. $description = __( "You can add customization code snippets here. For details, see %s.", 'contact-form-7' );
  199. $description = sprintf( esc_html( $description ), $desc_link );
  200. ?>
  201. <h2><?php echo esc_html( __( 'Additional Settings', 'contact-form-7' ) ); ?></h2>
  202. <fieldset>
  203. <legend><?php echo $description; ?></legend>
  204. <textarea id="wpcf7-additional-settings" name="wpcf7-additional-settings" cols="100" rows="8" class="large-text"><?php echo esc_textarea( $post->prop( 'additional_settings' ) ); ?></textarea>
  205. </fieldset>
  206. <?php
  207. }