[ Index ]

MailPress 7.1

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-admin/includes/ -> form_templates.php (source)

   1  <?php
   2  
   3  if ( !( function_exists( 'current_user_can' ) && current_user_can( MP_AdminPage::capability ) ) ) die( 'Access denied' );
   4  
   5  $form_templates = new MP_Form_templates();
   6  $templates     = $form_templates->get_all();
   7  $template         = ( isset( MP_AdminPage::$get_['template'] ) ) ? MP_AdminPage::$get_['template'] : reset( $templates );
   8  
   9  $advanced_path = 'advanced/' . get_current_blog_id() . '/forms';
  10  $root  = MP_UPL_ABSPATH . $advanced_path;
  11  $root  = apply_filters( 'MailPress_advanced_forms_root', $root );
  12  $root .= '/templates';
  13  $template_file = "$root/$template.xml";
  14  
  15  if ( !is_file( $template_file ) ) wp_die( sprintf( '<p>%s</p>', __( 'No such file exists! Double check the name and try again.' ) ) );
  16  
  17  $file_status = is_writeable( $template_file );
  18  
  19  $content = file_get_contents( $template_file );
  20  $content = htmlspecialchars( $content );
  21  $codepress_lang = 'html';
  22  
  23  //
  24  // MANAGING H1
  25  //
  26  
  27  $h1 = __( 'Edit Form templates', 'MailPress' );
  28  
  29  //
  30  // MANAGING MESSAGE
  31  //
  32  
  33  $messages[1] = __( 'File edited successfully.', 'MailPress' );
  34  $messages[2] = __( 'Could not save to file.',   'MailPress' );
  35  $messages[3] = __( 'Could not save to file, xml errors',   'MailPress' );
  36  if ( isset( MP_AdminPage::$get_['message'] ) ) $message = $messages[MP_AdminPage::$get_['message']];
  37  
  38  ?>
  39  <div class="wrap">
  40      <h1>
  41          <?php echo esc_html( $h1 ); ?>
  42      </h1>
  43  <?php if ( isset( $message ) ) MP_AdminPage::message( $message ); ?>
  44      <br class="clear" />
  45      <div class="fileedit-sub">
  46          <div class="alignleft">
  47              <big>
  48  <?php echo ( $file_status ) ? sprintf( __( 'Editing <strong>%s</strong>', 'MailPress' ), $template ) : sprintf( __( 'Browsing <strong>%s</strong>', 'MailPress' ), $template ); ?>
  49              </big>
  50          </div>
  51          <div class="alignright">
  52              <form method="post">
  53                  <strong>
  54                      <label for="plugin">
  55                          <?php _e( 'Select template to edit:', 'MailPress' ); ?> 
  56                      </label>
  57                  </strong>
  58                  <input type="hidden" name="action" value="toedit" />
  59                  <select name="template" id="plugin">
  60  <?php MP_AdminPage::select_option( $templates, $template ); ?>
  61                  </select>
  62                  <input type="submit" name="Submit" class="button" value="<?php echo esc_attr( __( 'Select' ) ) ?>" />
  63              </form>
  64          </div>
  65          <br class="clear" />
  66      </div>
  67      <form name="Template" id="Template" method="post">
  68  
  69          <input type="hidden" name="action" value="update" />
  70          <input type="hidden" name="template" value="<?php echo $template; ?>" />
  71          <?php wp_nonce_field( 'edit-mp-template_' . $template ) ?>
  72  
  73          <div class="template">
  74              <textarea name="newcontent" id="newcontent" tabindex="1" class="hidden" rows="30" cols="100"><?php echo $content ?></textarea>
  75          </div>
  76  <?php if ( $file_status ) : ?>
  77          <p class="submit"><input type="submit" name="submit" id="submit_xml" class="button-primary" tabindex="2" value="<?php echo esc_attr( __( 'Update File' ) ); ?>" /></p>
  78  <?php else : ?>
  79          <p><em><?php _e( 'You need to make this file writable before you can save your changes. See <a href="http://codex.wordpress.org/Changing_File_Permissions">the Codex</a> for more information.' ); ?></em></p>
  80  <?php endif; ?>
  81      </form>
  82  <br class="clear" />
  83  </div>


Generated: Mon Mar 11 18:33:33 2019 Cross-referenced by PHPXref 0.7.1