Title: Enqueuing editor CSS
Last modified: November 3, 2020

---

# Enqueuing editor CSS

 *  Resolved [Karis](https://wordpress.org/support/users/askel45/)
 * (@askel45)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/enqueuing-editor-css/)
 * Hi. This is some code I got from Tom to enqueue block editor CSS in my custom
   plugin. However, I would like to ask for your help to shorten the URL in a way
   that it does not rely on the `plugin-name` in the case where the plugin name 
   is changed so it does not throw an error. I don’t know how that functions works
   and I saw it in the past but Google has not been fruitful. The style does not
   work without the full path, but I would like to truncate the part shown in the
   code due to the reason stated above. Thanks in advance.
 *     ```
       add_action( 'enqueue_block_editor_assets', function() {
           wp_enqueue_style( 'editor', '/wp-content/plugins/plugin-name/assets/css/editor-style.css', array(), '1.0');
       } );
       ```
   

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Theme Author [Tom](https://wordpress.org/support/users/edge22/)
 * (@edge22)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/enqueuing-editor-css/#post-13616990)
 * Hi there,
 * Just to confirm, you’re wanting to enqueue an asset inside a specific plugin 
   without referencing the path to that plugin?
 *  Thread Starter [Karis](https://wordpress.org/support/users/askel45/)
 * (@askel45)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/enqueuing-editor-css/#post-13617204)
 * Hi Tom. I think that is what I want. Like how the editor styles work straight
   out of the theme without including the theme’s name when enqueuing them. In this
   case, the block editor style CSS file.
 *  Theme Author [Tom](https://wordpress.org/support/users/edge22/)
 * (@edge22)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/enqueuing-editor-css/#post-13617829)
 * The code would need to be in the plugin itself (or the theme) for that to work.
   It’s not possible to enqueue an asset without explicitly providing a URL to enqueue.
   When working inside the plugin or theme, we can use PHP functions to get the 
   URL. From outside the plugin/theme, I don’t believe there’s a way to do it.
 *  Thread Starter [Karis](https://wordpress.org/support/users/askel45/)
 * (@askel45)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/enqueuing-editor-css/#post-13621563)
 * [@edge22](https://wordpress.org/support/users/edge22/) the code is actually inside
   the plugin ([related issue](https://wordpress.org/support/topic/block-editor-styles/)).
   But it does not work unless the full URL is entered (hence the /wp-content/plugin-
   name/ section of the code. But in cases where I might change the plugin’s name
   and I forgot about that code, that might not work. (Sorry I was confusing the
   CSS enqueuing process and the process of including a PHP file which causes an
   error if that file does not exist)
 * Edit: I found it is working this time using `plugins_url( '/assets/css/editor-
   style.css', __FILE__ )` when enqueuing the file. As reported in the related issue,
   I have discovered it was a cache issue and I added `array(), 'insert number here')`
   to the code and it purges the cache when I updated the version number. You can
   ignore this now. Thanks.
 *  Theme Author [Tom](https://wordpress.org/support/users/edge22/)
 * (@edge22)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/enqueuing-editor-css/#post-13626212)
 * Glad you got it sorted 🙂

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Enqueuing editor CSS’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/generatepress/3.6.1/screenshot.
   png)
 * GeneratePress
 * [Support Threads](https://wordpress.org/support/theme/generatepress/)
 * [Active Topics](https://wordpress.org/support/theme/generatepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/generatepress/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/generatepress/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Tom](https://wordpress.org/support/users/edge22/)
 * Last activity: [5 years, 7 months ago](https://wordpress.org/support/topic/enqueuing-editor-css/#post-13626212)
 * Status: resolved