Make WordPress Core

Ticket #31779: first-time-editor-notices.diff

File first-time-editor-notices.diff, 2.3 KB (added by toddnestor, 10 years ago)

Patch that adds the first time user notices for both the plugin and theme editors.

  • src/wp-admin/plugin-editor.php

    diff --git src/wp-admin/plugin-editor.php src/wp-admin/plugin-editor.php
    index 6ffadf6..0326bb3 100644
    default: 
    162162        }
    163163
    164164        $content = esc_textarea( $content );
    165         ?>
    166 <?php if (isset($_GET['a'])) : ?>
     165
     166    $first_time_editing = get_user_meta( get_current_user_id(), 'already_used_wp_plugin_editor', true );
     167    if ( empty( $first_time_editing ) ) : ?>
     168        <div id="message" class="error notice is-dismissible"><p><?php _e( "You are editing the actual plugin files.  Make sure you know what you're doing!<br />If you want to know more about Wordpress plugin development, checkout <a href='https://codex.wordpress.org/Writing_a_Plugin' target='_blank'>Plugin Development on Wordpress</a>." ) ?></p></div>
     169        <?php
     170        update_user_meta( get_current_user_id(), 'already_used_wp_plugin_editor', true );
     171    endif;
     172
     173    if (isset($_GET['a'])) : ?>
    167174 <div id="message" class="updated notice is-dismissible"><p><?php _e('File edited successfully.') ?></p></div>
    168175<?php elseif (isset($_GET['phperror'])) : ?>
    169176 <div id="message" class="updated"><p><?php _e('This plugin has been deactivated because your changes resulted in a <strong>fatal error</strong>.') ?></p>
  • src/wp-admin/theme-editor.php

    diff --git src/wp-admin/theme-editor.php src/wp-admin/theme-editor.php
    index c858c0b..a51effb 100644
    default: 
    125125 <div id="message" class="updated notice is-dismissible"><p><?php _e( 'File edited successfully.' ) ?></p></div>
    126126<?php endif;
    127127
     128    $first_time_editing = get_user_meta( get_current_user_id(), 'already_used_wp_theme_editor', true );
     129    if ( empty( $first_time_editing ) ) : ?>
     130        <div id="message" class="error notice is-dismissible"><p><?php _e( "You are editing the actual theme files.  Make sure you know what you're doing!<br />If you want to know more about Wordpress theme development, checkout <a href='https://codex.wordpress.org/Theme_Development' target='_blank'>Theme Development on Wordpress</a>." ) ?></p></div>
     131        <?php
     132        update_user_meta( get_current_user_id(), 'already_used_wp_theme_editor', true );
     133    endif;
     134
    128135$description = get_file_description( $file );
    129136$file_show = array_search( $file, array_filter( $allowed_files ) );
    130137if ( $description != $file_show )