Forum Replies Created
-
AuthorPosts
-
webdev
ParticipantYes, correct, the 'copy' setting behaves like that... but the 'translate' setting behaved exactly the same...
As it happens, I've uninstalled Polylang for this project and am using WPML, as there were some errors showing up in Settings forms, so I won't be able to test any more anyway...webdev
ParticipantI have text in the field, eg:
'My text in language 1'
I create a translation:
The text in the field reads:
'My text in language 1' <-- this is correct so far
I change the text in the translation to:
'My text in language 2' <-- create a translation
Save the translation.
When I go back to the original, it reads:
'My text in language 2' <-- showing the translated text where it should show the original
If I change it back to the original text then the translation also changes, ie both the translation and the original are always the same (as in a 'copy')
webdev
Participant+1 for this feature too. It would be really useful
webdev
ParticipantSorted now... my mistake... I'd downloaded the theme from our Git repo and it was zipped up as '[my-them-slug]-main.zip' with a corresponding 'main' folder inside.
When uploaded without the 'main' part added by Git, it all works as expectedwebdev
ParticipantHmm,
It's really weird... On my dev site, the option is saved under that name, but on the live site, that setting does not exist, and if I
var_dump(wp_load_alloptions());(which shows all saved options), there is nothing containing anything like the expected content.
But the content is definitely being saved because if I go to the Customizer, edit the wysiwyg, save and then reload, the content is still there...
Do you have any other ideas? Is it just being saved by MetaBox in a meta field somewhere?
webdev
ParticipantApologies for the late reply...
That seems to work for showing the field in the correct place, but I can't work out how to retrieve the value.I have removed the entire 'mb_settings_pages' filter and function as suggested in the docs you pointed out, so my function is now just this:
<?php add_filter( 'rwmb_meta_boxes', 'wcpp_masthead_field', 1 ); function wcpp_masthead_field( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => __( 'Homepage Intro Text', 'wcpp' ), 'id' => 'homepage-masthead-wysiwyg', 'panel' => '', 'fields' => [ [ 'name' => __( 'Masthead Text', 'wcpp' ), 'id' => $prefix . 'masthead_text', 'type' => 'wysiwyg', 'raw' => false, 'required' => false, 'clone' => false, 'hide_from_rest' => false, 'hide_from_front' => false, 'limit' => 150, 'wpautop' => false, 'limit_type' => 'character', 'options' => [ 'media_buttons' => true, 'teeny' => false, 'tinymce' => [ 'toolbar1' => 'bold,italic,underline,|,bullist,numlist,|,link,unlink', 'toolbar2' => '', 'toolbar3' => '', 'toolbar4' => '', 'toolbar5' => '', 'wpautop' => false, ], 'quicktags' => false, ], ], ], ]; return $meta_boxes; }If I show all options available, then I can see the relevant content under an option called 'theme_mods_[my-theme-slug]' but this only works on ym developemnt machine, presumably because of an old setting, as it is not available on the live version. I can't tell from the docs which is the option name I need to call, or if I'm missing something in the definition of the Customizer panel above.
Thanks for your help.
webdev
ParticipantHi again, I did share admin details with you, but forgot to update here, so perhaps it was missed. But...
UPDATE:
I still haven't managed to get it working linking to a function in 'callback', however if I put the function name in the 'std' field, I can get it to work. I just have to use output buffering, like so:The std field contains the function call, instead of the callback field...
'fields' => [ [ 'name' => __('How to generate some content', 'text-domain'), 'type' => 'custom_html', 'std' => get_help('help_page'), // 'callback' => get_help('help_page'), ],and return the output buffer in get_help()...
function get_help($file){ ob_start(); include ($file.'.php'); return ob_get_clean(); }So this looks like a work-around.
My question now though, is this ok to use?
Could it break in future updates to MB?
In short, is it a good idea 🙂 ?webdev
ParticipantHi,
Thanks, but unfortunately I'm working on a local wp-env installation so you won't be able to get to it...webdev
Participant... and I just tried with it in a standard post instead of a settings page - as before, the content is rendered, but directly after the <body> tag of the html, so in the wrong place. Any ideas please?
webdev
ParticipantHi again,
Apologies for delay in replying to this - Other things have got in the way... I just tried again, and I can get the contents of the included PHP file to be rendered, but they are not in the right place - it seems to render it before any other content (behind the main WordPress backend nav) rather than in the correct place on the screen.
I am trying to do this in a tab on a Settings page (if that makes any difference). I have tried removing the tabs to see if that makes any difference but it doesn't help.webdev
ParticipantOn a settings page, so I have something like this:
'title' => __('General Settings', 'text-domain'), 'id' => 'general-settings', 'settings_pages' => ['some-settings'], 'tab' => 'Settings', 'fields' => [ [ 'name' => __('How to generate some content', 'text-domain'), 'type' => 'custom_html', 'callback' => get_help('help_page'), ],and putting my function name with a paramater in the callback section doesn't work. If I have the callback function as a string, then it does work, but then I don't know how to include a parameter...
webdev
ParticipantHi,
Sorry, I don't think I was clear in the initial question. I'm generating the Settings page using a custom_html field and want to use the 'callback' key for the custom_html field.Adding a parameter to a callback doesn't work for me there.
webdev
ParticipantSame problem here. I'm getting the following error in the console:
<div>Uncaught Error: Syntax error, unrecognized expression: ##type_1:not(.rwmb-clone-template ##type_1)</div>
webdev
ParticipantYeah... strange.
I've just tried updating again, and it works as expected now...
Oh well...
¯\_(ツ)_/¯webdev
ParticipantPS, I know there is the option of 'add_new' => true when defining the field in a fields group, but as this loads the whole backend screen including, description, slug, image, etc, I think it's too confusing for users and the standard WP interface would be far easier.
-
AuthorPosts