Forum Replies Created
-
AuthorPosts
-
Anh Tran
KeymasterHi Ryan,
I've just done a quick test and it works for me. Here is the code I'm using to register a meta box and filter the label:
add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) { $meta_boxes[] = [ 'title' => 'Cloneable Post Field', 'fields' => [ [ 'id' => 'p', 'title' => 'Post', 'type' => 'Post', 'clone' => true, ], ], ]; return $meta_boxes; } ); add_filter( 'rwmb_p_choice_label', function ( $label, $field, $post ) { return "$post->post_type: $post->post_title"; }, 10, 3 );And here is the screenshot:
Anh Tran
KeymasterHi Ryan,
Thanks for your feedback. Let me check that again and will get back to you soon.
Anh Tran
KeymasterAfter debugging, I found a JS bug that doesn't collect correct values from cloneable/group fields. I'll fix it and update the plugin as soon as I can.
Anh Tran
KeymasterThanks for valuable info. I intended to use the latest 2.x version of Twig, but it requires PHP 7.0 which is quite high at the moment. So I decided to use the latest 1.x version only.
Looks like both plugins are using Composer and it doesn't handle the version conflict quite well. The best solution is both plugins should use only stable API from Twig so they don't change across versions. But as you said, 2FAS might use deprecated APIs. I'll take a look at that plugin to see if I can make some hooks to let users choose Twig version or disable bundled Twig in MB Builder.
Anh Tran
KeymasterHi Jose,
For math, please use
{{ (a + b) / 2 }}.Regarding the cloneable fields, let me try it and will get back to you soon.
Anh Tran
KeymasterHi Doug,
Twig is added to MB Builder 3.1.0, which is available in the AIO 1.9.2. I think you might be right about the conflict with the 2FAS Light plugin. Do you see any error if you disable 2FAS Light or MB Builder?
Anh Tran
KeymasterI understand. However, there are some cases where people really want to enter script, like a textarea field for entering header / footer code (in a page settings).
I just want to provide the maximum flexibility to users, while developers still can restrict the content if they want. That's how a library should do. It's the same as the Customizer API where developers still have to define their own sanitize callback.
Anh Tran
KeymasterHi David,
Making a whitelist of HTML tags might be tricky, since there are a lot of them. For example, if you have a textarea/wysiwyg field, then it nearly impossible to define those tags. Besides, I want to offer flexibility to developers and let them decide what need to be sanitized.
I'll add
sanitize_callbackparameter to the field settings. So developers can decide what and how to sanitize value.Anh Tran
KeymasterYes, that's right. If you need to pass the value for the 3rd parameter, you have to pass a value for the 2nd parameter. It's just how params in PHP function work.
Anh Tran
KeymasterHi Rao and David,
The plugin sanitize values for some field types only (file_input, email, url, oembed, checkbox and switch). You can see the code for that here. For other fields, to let users able to enter some HTML, we don't force a sanitize callback. But you can sanitize the value with this code:
add_filter( 'rwmb_text_sanitize', 'sanitize_text_field' ); add_filter( 'rwmb_{$field_type}_sanitize', 'your_sanitize_callback' );August 4, 2019 at 2:47 PM in reply to: ✅Getting post ID from inside the Meta Box Block render_callback #15595Anh Tran
KeymasterOops, I forgot to pass the param to the render callback function. Thanks for your help!
Anh Tran
KeymasterHi, please try the
block_categoriesfilter.Here is the docs:
Here is a good tutorial: https://getwithgutenberg.com/2019/04/creating-a-block-category/
Both resources say about adding categories. I'm not sure if it supports removing core categories. Please just try.
Anh Tran
KeymasterHi Akram,
Sorry to make you feel like that. What I meant is that's the default behavior of the fields.
You still can change the behavior with the plugin action, like this:
add_action( 'rwmb_after_save_post', function( $post_id ) { $group = get_post_meta( $post_id, 'group_id', true ); $terms = $group['terms'] ?? []; wp_set_post_terms( $post_id, $terms, 'your_taxonomy' ); } );Anh Tran
KeymasterHi Akram,
If you want to set post terms, you have to move the taxonomy field outside the group. You can use MB Conditional Logic to hide the field if you want. If you still need to keep it inside a group, then there's no way to achieve that.
Anh Tran
KeymasterHi Alex, this is the screenshot of the email: https://imgur.elightup.com/0muIt7y.png. I sent from [email protected]. Can you check that again?
-
AuthorPosts