Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. Custom css for backend editor

Custom css for backend editor

Scheduled Pinned Locked Moved General Discussion
6 Posts 2 Posters 151 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dabu
    wrote on last edited by
    #1

    Some of my custom CSS for the frontend I also need in the backend text editor for it to be clear for the user.

    I noticed that the CSS of the text editor is defined in:

    …/themes/lay/setup/assets/css/tinymce_defaults.css

    Is there a way to add another CSS file to the tinyMCE editor?

    I was able to do it for the Gridder preview with this function:

    function kd_custom_style() {
       wp_enqueue_style('admin-styles', '/wp-content/themes/lay_eigenes/admin-style.css');
    }
    
    add_action('admin_enqueue_scripts', 'kd_custom_style');
    

    But that doesn't work in the tinyMCE editor, because it opens as an iframe. How can I insert the CSS-file to this iframe?

    1 Reply Last reply
    0
    • arminunruhA Online
      arminunruhA Online
      arminunruh
      Global Moderator
      wrote on last edited by arminunruh
      #2

      add_editor_style( Setup::$uri.'/setup/assets/css/tinymce_defaults.css' );

      you can find this line in the code of lay theme by searching for tinymce_defaults.css
      i hope it will lead u into the right direction

      lay theme doesnt support child themes
      its probably better to code a wordpress plugin that inserts your custom code than to use a child theme

      if there is an update one day that is not compatible with your child theme, you will have to activate the original lay theme for the website to work

      or debug your child theme, meaning u'd have to find differences between the child theme and lay theme and then transport all differences from lay theme to ur child theme

      if you dont use a child theme but simply just change the code of a copy of lay theme, this is also not a good idea since every lay theme update will overwrite your code changes

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dabu
        wrote on last edited by
        #3

        Thank you! I'm aware that Lay doesn't support child themes, and I want to avoid changing stuff in the lay theme folder.

        The above mentioned function (function kd_custom_style()) I added with the CodeSnippet Plugin. I was trying to do the same with the tinymce-CSS, but didn't succeed.

        I found your line in the setup.php file, but I didn't find out how I can use it by putting the code in the CodeSnippet that runs in the backend.

        Changing the URL to my file didn't do the job, seems like there needs to be more code. So if you or anybody else can give me more hints, that would be greatly appreciated!

        tinyMCE has some help with the topic, but I didn't manage to make it work. That's what I found:

        tinymce.init({
          selector: 'textarea',  // change this value according to your HTML
          content_css: '/myLayout.css'  // resolved to http://domain.mine/myLayout.css
        });
        
        1 Reply Last reply
        0
        • arminunruhA Online
          arminunruhA Online
          arminunruh
          Global Moderator
          wrote on last edited by
          #4

          https://developer.wordpress.org/reference/functions/add_editor_style/

          it should work

          if it doesnt, i dont know

          1 Reply Last reply
          1
          • D Offline
            D Offline
            dabu
            wrote on last edited by
            #5

            Great, thank you so much Armin!

            It worked with this code:

            function wpdocs_theme_add_editor_styles() {
                add_editor_style( 'https://www.thisismydomain.com/wp-content/themes/lay_eigenes/admin-style.css' );
            }
            add_action( 'admin_init', 'wpdocs_theme_add_editor_styles' );
            

            /themes/lay_eigenes/ is just a folder with my CSS files, no child theme.

            1 Reply Last reply
            0
            • arminunruhA Online
              arminunruhA Online
              arminunruh
              Global Moderator
              wrote on last edited by
              #6

              ok very good

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              I also code custom websites or custom Lay features.
              šŸ’æ Email me here: šŸ’æ
              info@laytheme.com

              Before you post:
              1. When using a WordPress Cache plugin, disable it or clear your cache.
              2. Update Lay Theme and all Lay Theme Addons
              3. Disable all Plugins
              4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

              This often solves issues you might run into

              When you post:
              1. Post a link to where the problem is
              2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
              3. If the problem is difficult to explain, post screenshots / link to a video to explain it
              Online Users
              arminunruhA
              arminunruh
              F
              francesco
              L
              lurchifon
              Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
              laytheme.com
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Recent
              • Tags
              • Popular
              • Users
              • Search