title: Right way to make changes in Wordpress Core
body: <p>I recently have removed the excerpt function from Wordpress and made my own so I can allow some HTML to be shown in the excerpt. I made the changes in a child theme functions file.</p>
  <p>It was working fine on the front-end but after that I had problems on the back-end of Wordpress. In <code>/wp-admin/edit.php</code> in an excerpt of posts I get the post excerpt with all the HTML tags so it was really hard to read the actual content of post.</p>
  <p>To fix that I did a change in the Wordpress core file <code>/wp-admin/includes/class-wp-posts-list-table.php</code>.
  I removed content from line 1037.</p>
  <pre><code>echo esc_html( get_the_excerpt() );
  </code></pre>
  <p>the function <code>esc_html</code></p>
  <p>How can I make this change permanent so that after a possible update of Wordpress, the change will not be lost?</p>
  <p>Is this change safe? I will have a lot of users in my back-end of Wordpress.</p>
  <h1>UPDATE MY QUESTION</h1>
  <pre><code>add_filter( 'get_the_excerpt', 'my_clean_excerpt' );
  function wpse_allowedtags() {
      // Add custom tags to this string
          return '&lt;style&gt;,&lt;br&gt;,&lt;em&gt;,&lt;i&gt;,&lt;ul&gt;,&lt;ol&gt;,&lt;li&gt;,&lt;a&gt;,&lt;p&gt;,&lt;img&gt;,&lt;video&gt;,&lt;audio&gt;,&lt;div&gt;,&lt;wbr&gt;'; 
      }
  
  if ( ! function_exists( 'wpse_custom_wp_trim_excerpt' ) ) : 
  
      function wpse_custom_wp_trim_excerpt($wpse_excerpt) {
      $raw_excerpt = $wpse_excerpt;
          if ( '' == $wpse_excerpt ) {
  
              $wpse_excerpt = get_the_content('');
              $wpse_excerpt = strip_shortcodes( $wpse_excerpt );
              $wpse_excerpt = apply_filters('the_content', $wpse_excerpt);
              $wpse_excerpt = str_replace(']]&gt;', ']]&amp;gt;', $wpse_excerpt);
              //$wpse_excerpt = strip_tags($wpse_excerpt, wpse_allowedtags()); /*IF you need to allow just certain tags. Delete if all tags are allowed */
  
              //Set the excerpt word count and only break after sentence is complete.
                  $excerpt_word_count = 75;
                  $excerpt_length = apply_filters('excerpt_length', $excerpt_word_count); 
                  $tokens = array();
                  $excerptOutput = '';
                  $count = 0;
  
                  // Divide the string into tokens; HTML tags, or words, followed by any whitespace
                  preg_match_all('/(&lt;[^&gt;]+&gt;|[^&lt;&gt;\s]+)\s*/u', $wpse_excerpt, $tokens);
  
                  foreach ($tokens[0] as $token) { 
  
                      if ($count &gt;= $excerpt_length &amp;&amp; preg_match('/[\,\;\?\.\!]\s*$/uS', $token)) { 
                      // Limit reached, continue until , ; ? . or ! occur at the end
                          $excerptOutput .= trim($token);
                          break;
                      }
  
                      // Add words to complete sentence
                      $count++;
  
                      // Append what's left of the token
                      $excerptOutput .= $token;
                  }
  
              $wpse_excerpt = trim(force_balance_tags($excerptOutput));
  
                  $excerpt_end = ' &lt;a href=&quot;'. esc_url( get_permalink() ) . '&quot;&gt;' . '&amp;nbsp;&amp;raquo;&amp;nbsp;' . sprintf(__( 'Read more about: %s &amp;nbsp;&amp;raquo;', 'wpse' ), get_the_title()) . '&lt;/a&gt;'; 
                  $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end); 
  
                  //$pos = strrpos($wpse_excerpt, '&lt;/');
                  //if ($pos !== false)
                  // Inside last HTML tag
                  //$wpse_excerpt = substr_replace($wpse_excerpt, $excerpt_end, $pos, 0); /* Add read more next to last word */
                  //else
                  // After the content
                  //$wpse_excerpt .= $excerpt_more; /*Add read more in new paragraph */
              
              // Extra filter to remove the above text from excerpt
              $badwords = array( 
              '&lt; !DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/REC-html40/loose.dtd&quot;&gt;',
              '&lt; ?xml encoding=&quot;utf-8&quot; ?&gt;',
              );
              foreach ( $badwords as $badword ) {
              $wpse_excerpt = str_replace( $badword, '', $wpse_excerpt);
              }
              //End extra filrer
              return $wpse_excerpt;   
  
          }
          return apply_filters('wpse_custom_wp_trim_excerpt', $wpse_excerpt, $raw_excerpt);
      }
  
  endif; 
  
  remove_filter('get_the_excerpt', 'wp_trim_excerpt');
  add_filter('get_the_excerpt', 'wpse_custom_wp_trim_excerpt');
  </code></pre>
  <p>I used this function to add html tags in excerpt.</p>
  <p>I after updated the excerpts in database. And i get the result that i wanted.</p>
  <p>But i get this in backend.
  <a href="https://i.stack.imgur.com/u1dgn.png" rel="nofollow noreferrer">problem backend</a></p>
  <p>So a fast way to get away with the problem was to go to <code>/wp-admin/includes/class-wp-posts-list-table.php</code>  and remove the function <code>esc_html</code> from this line <code>echo esc_html( get_the_excerpt() );</code> where the excerpt is generated for back-end.</p>
  <p>So my question is not about how to allow html tags in excerpt, I already did that, but how to make that change permanent.</p>
  <p>My back-end after that change. <a href="https://i.stack.imgur.com/Mq9oC.png" rel="nofollow noreferrer">Back-end after</a>
  That is what i want to do.</p>