Support community for TTG plugins and products.
NOTICE
The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.
This forum is now closed, and exists here as a read-only archive.
You are not logged in.
This is strange. When I'm using the WordPress theme created by my Backlight configuration, the page/post editor view is always forced to text.
I can change the theme to the builtin Twenty SixteenVersion and this doesn't happen.
Normally, if you are editing a page and switch to visual it stays visual. Even when you leave that edit, and then open a new page to edit. It will open in visual mode. So by default WordPress will keep your last setting.
But with the Backlight theme I'm finding it's always being forced to text view. I can change it to visual, and then after updating the page it's switches back to text again.
--Jim
Offline
Yes, it's in the theme. An opinionated move on my part, as the WP visual editor is pretty crap. You're the only person thus far that's raised it as an issue.
My intention was to have the Text editor as default. I didn't realize it would null your preference, though. This is the snippet I'm using:
http://wp-snippets.com/set-default-editor/
I'll have a look at whether I can figure out how to keep the intent, while honoring the user preference. Open to ideas if you solve it before I do.
Offline
I maybe have something. Maybe. Can you test this?
Edit /inc/theme_admin.php
Change:
add_filter("wp_default_editor", create_function("", "return 'html';"));
Replace with:
function set_default_editor() {
$r = 'html';
if ( wp_get_current_user() ) { // look for cookie
$r = get_user_setting('editor', 'html');
}
return $r;
}
add_filter( 'wp_default_editor', 'set_default_editor' );
And what I'm hoping this will accomplish is:
1. Uses 'Text/HTML' editor by default.
2. When a new user is created, the 'Text/HTML' editor is default.
3. When the user changes to the 'Visual' editor as preference, this setting will be preferred.
Offline
My intention was to have the Text editor as default.
I'll add your change and see how it works, then let you know.
I understand your intent of always using the text editor. I think people using WordPress are used to how it normally behaves. A change in the behavior just shows up as "broken."
If you didn't alter the behavior, it works for you since WP will "remember" your preference.
I use both the visual and the text editor. It also works for me since I'm always jumping back and forth, and I'm expecting it to be how it was last time. I even go the extra mile and customize the WP admin css so my visual editor looks close to the actual page.
--Jim
Offline
Like I said, it's an opinionated move on my part. That WP does not remember your personal preference, though, is entirely an unintentional and undesirable side-effect. I only want to softly encourage people to use the text editor. The visual editor, I find, often does stupid things, like leaving being empty <p></p> tags in the markup when a paragraph is removed.
Offline
Nope, that change still has the editor being forced to html/text.
I just deleted the wp_default_editor filter. At least for now it behaves as I'm used to. I know it will get wiped out with the next update.
This would be a good custom option for the theme. So far I see only "google analytics, as set in Backlight" is the only setting. Adding a few more there like the editor preference would be nice.
--Jim
Offline
Odd. The function above seems to be working for me. After selecting the Visual editor and either updating my post, or creating a new one, I then get the visual editor by default.
Did you re-export the theme to Wordpress after making the change?
Offline
Did you re-export the theme to Wordpress after making the change?
D'oh!
Looking at the /inc/theme_admin.php just now I see it had been reset back to the original "opinionated" filter LOL
What I just confirmed is changing a template in Backlight is over-writing the theme_admin.php as well. So changing that file isn't going to work.
That brings up another more general point I was going to ask about.
Is it possible to create a child theme, so Backlight doesn't over-write things like the above?
This also becomes an issue when updating Backlight. Usually I have a child theme and will be safe to change functions.php or other files within the theme.
--Jim
Offline
Have you tried creating a child theme per the WordPress codex?
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Have you tried creating a child theme per the WordPress codex?
I've created them in the past but haven't tried it for Backlight. I wasn't sure it would work.
The Backlight doc page for this MIA.
http://backlight.theturninggate.net/doc … ild_themes
Has anyone done this?
--Jim
Offline
Child themes work with Backlight. Did it for my site.
Daniel Leu | Photography
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com
Offline
Not only do they work, but I have endeavored to make Backlight's themes child-theme-friendly. For example, most functions do a "function_exists" check, allowing child themes to overwrite them. Though not the one we're discussing. I'll maybe have to add these in an update.
The Turning Gate is running on a child-theme, in fact, as I've written some custom taxonomy stuff for our shop pages.
Offline
There's another approach you can use for functions you want to be always available regardless of theme changes.
You can put the functions into a simple plugin - the source I borrowed the idea from called this a "functionality plugin" (I can't recall where I got the idea, as it was a few years ago).
Create a suitably named folder in the WordPress plugins folder, and add your new PHP file in there. It should looks something like this:
<?php
/*
Plugin Name: My Site Functionality Plugin
Description: Repalces functions.php in child theme
Version: 1.0
License: GPL
Author: Your name
Author URI: http://yoursite.com
*/
// Note about the following function
// Your functions here
?>
Once it's saved, it will appear in your plugins list where it can be activated as normal.
I find this handy for various little WordPress tweaks.
Les Bessant
Les Bessant Photography - Backlight site
Losing it - Blog
Twitter: @lesb
Offline
I can confirm that Backlight is child theme friendly, I am a wordpress idiot and even I could easily implement a child theme on my site. ;-)
Charlie
www.stalkinglight.com
Offline
Not only do they work, but I have endeavored to make Backlight's themes child-theme-friendly. For example, most functions do a "function_exists" check, allowing child themes to overwrite them. Though not the one we're discussing.
Got the child theme setup. Added the set_default_editor to functions.php, but that's not working.
Seems the default is still set to 'html' by the parent theme. I didn't see a way to remove that filter, or how to override it.
--Jim
Offline
You could try adding a priority to your filter - a higher number would make it run later, and so more likely to "win".
Les Bessant
Les Bessant Photography - Backlight site
Losing it - Blog
Twitter: @lesb
Offline
You could try adding a priority to your filter - a higher number would make it run later, and so more likely to "win".
Even brute force doesn't seem to do the trick. I added this to my child theme's functions.php
add_filter( 'wp_default_editor', create_function('', 'return "tinymce";'), 1 );
I was thinking I could remove the builtin filter, but Backlight adds the filter without using a function name so I can't remove it. I can alter the original code in the parent theme, and that works until I update a template. Since I'm in the middle of creating the theme it's getting instantly overwritten.
--Jim
Offline
where is the code in the parent theme? the inc/ folder? I ask because if you just put a function in the child theme it might not work unless it's in the same folder as in the parent theme.
For example, if the file with the function is in the "template-parts" folder of the parent, you need to create a folder in the child theme named "template-parts" and place file with the function in that folder.
Found that out after banging my head on the desk for an hour or two while trying to add author information to posts.....
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
As I said, Jim, that particular function is not able to be overwritten by a child theme in the current version. I will change this in the next update. For now, you'll just need to hack the module with your change.
Child themes can override any function existing within a "function_exists" check in the parent.
Offline