-
+ 4AC392674019CF0DEFE9FA224484A992DA428D36929C3B838016B560717A8DB6C28644E2F069769FF6633CED67657B054AF9FE4F0CA78BEADB53023999CA739A
mp-wp/wp-admin/plugin-editor.php
(0 . 0)(1 . 164)
54791 <?php
54792 /**
54793 * Edit plugin editor administration panel.
54794 *
54795 * @package WordPress
54796 * @subpackage Administration
54797 */
54798
54799 /** WordPress Administration Bootstrap */
54800 require_once('admin.php');
54801
54802 $title = __("Edit Plugins");
54803 $parent_file = 'plugins.php';
54804
54805 wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file'));
54806
54807 wp_admin_css( 'theme-editor' );
54808
54809 $plugins = get_plugins();
54810 $plugin_files = array_keys($plugins);
54811
54812 if (empty($file))
54813 $file = $plugin_files[0];
54814
54815 $file = validate_file_to_edit($file, $plugin_files);
54816 $real_file = WP_PLUGIN_DIR . '/' . $file;
54817
54818 switch($action) {
54819
54820 case 'update':
54821
54822 check_admin_referer('edit-plugin_' . $file);
54823
54824 if ( !current_user_can('edit_plugins') )
54825 wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');
54826
54827 $newcontent = stripslashes($_POST['newcontent']);
54828 if ( is_writeable($real_file) ) {
54829 $f = fopen($real_file, 'w+');
54830 fwrite($f, $newcontent);
54831 fclose($f);
54832
54833 // Deactivate so we can test it.
54834 if ( is_plugin_active($file) || isset($_POST['phperror']) ) {
54835 if ( is_plugin_active($file) )
54836 deactivate_plugins($file, true);
54837 wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1"));
54838 exit;
54839 }
54840 wp_redirect("plugin-editor.php?file=$file&a=te");
54841 } else {
54842 wp_redirect("plugin-editor.php?file=$file");
54843 }
54844 exit;
54845
54846 break;
54847
54848 default:
54849
54850 if ( !current_user_can('edit_plugins') )
54851 wp_die('<p>'.__('You do not have sufficient permissions to edit plugins for this blog.').'</p>');
54852
54853 if ( isset($_GET['liveupdate']) ) {
54854 check_admin_referer('edit-plugin-test_' . $file);
54855
54856 $error = validate_plugin($file);
54857 if( is_wp_error($error) )
54858 wp_die( $error );
54859
54860 if ( ! is_plugin_active($file) )
54861 activate_plugin($file, "plugin-editor.php?file=$file&phperror=1");// we'll override this later if the plugin can be included without fatal error
54862
54863 wp_redirect("plugin-editor.php?file=$file&a=te");
54864 exit;
54865 }
54866
54867 require_once('admin-header.php');
54868
54869 update_recently_edited(WP_PLUGIN_DIR . '/' . $file);
54870
54871 if ( ! is_file($real_file) )
54872 $error = 1;
54873
54874 if ( ! $error )
54875 $content = htmlspecialchars(file_get_contents($real_file));
54876
54877 ?>
54878 <?php if (isset($_GET['a'])) : ?>
54879 <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
54880 <?php elseif (isset($_GET['phperror'])) : ?>
54881 <div id="message" class="updated fade"><p><?php _e('This plugin has been deactivated because your changes resulted in a <strong>fatal error</strong>.') ?></p>
54882 <?php
54883 if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $file) ) { ?>
54884 <iframe style="border:0" width="100%" height="70px" src="<?php bloginfo('wpurl'); ?>/wp-admin/plugins.php?action=error_scrape&plugin=<?php echo attribute_escape($file); ?>&_wpnonce=<?php echo attribute_escape($_GET['_error_nonce']); ?>"></iframe>
54885 <?php } ?>
54886 </div>
54887 <?php endif; ?>
54888 <div class="wrap">
54889 <?php screen_icon(); ?>
54890 <h2><?php echo wp_specialchars( $title ); ?></h2>
54891
54892 <div class="tablenav">
54893 <div class="alignleft">
54894 <big><?php
54895 if ( is_plugin_active($file) ) {
54896 if ( is_writeable($real_file) )
54897 echo sprintf(__('Editing <strong>%s</strong> (active)'), $file);
54898 else
54899 echo sprintf(__('Browsing <strong>%s</strong> (active)'), $file);
54900 } else {
54901 if ( is_writeable($real_file) )
54902 echo sprintf(__('Editing <strong>%s</strong> (inactive)'), $file);
54903 else
54904 echo sprintf(__('Browsing <strong>%s</strong> (inactive)'), $file);
54905 }
54906 ?></big>
54907 </div>
54908 <br class="clear" />
54909 </div>
54910 <br class="clear" />
54911 <div id="templateside">
54912 <h3 id="bordertitle"><?php _e('Plugin Files'); ?></h3>
54913
54914 <h4><?php _e('Plugins'); ?></h4>
54915 <ul>
54916 <?php foreach($plugin_files as $plugin_file) : ?>
54917 <li><a href="plugin-editor.php?file=<?php echo $plugin_file; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li>
54918 <?php endforeach; ?>
54919 </ul>
54920 </div>
54921 <?php if ( ! $error ) { ?>
54922 <form name="template" id="template" action="plugin-editor.php" method="post">
54923 <?php wp_nonce_field('edit-plugin_' . $file) ?>
54924 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
54925 <input type="hidden" name="action" value="update" />
54926 <input type="hidden" name="file" value="<?php echo $file ?>" />
54927 </div>
54928 <?php if ( is_writeable($real_file) ) : ?>
54929 <?php if ( in_array($file, (array) get_option('active_plugins')) ) { ?>
54930 <p><?php _e('<strong>Warning:</strong> Making changes to active plugins is not recommended. If your changes cause a fatal error, the plugin will be automatically deactivated.'); ?></p>
54931 <?php } ?>
54932 <p class="submit">
54933 <?php
54934 if ( isset($_GET['phperror']) )
54935 echo "<input type='hidden' name='phperror' value='1' /><input type='submit' name='submit' class='button-primary' value='" . __('Update File and Attempt to Reactivate') . "' tabindex='2' />";
54936 else
54937 echo "<input type='submit' name='submit' class='button-primary' value='" . __('Update File') . "' tabindex='2' />";
54938 ?>
54939 </p>
54940 <?php else : ?>
54941 <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>
54942 <?php endif; ?>
54943 </form>
54944 <?php
54945 } else {
54946 echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
54947 }
54948 ?>
54949 <div class="clear">   </div>
54950 </div>
54951 <?php
54952 break;
54953 }
54954 include("admin-footer.php") ?>