Support Forum ยป User Profile

Forum Replies Created

Viewing 15 posts - 2,236 through 2,250 (of 3,958 total)
  • Author
    Posts
  • in reply to: Invalid argument supplied... #9320
    Anh TranAnh Tran
    Keymaster

    Hey Kasia, no problem at all. I'm glad you figured it out!

    If you need any help, please let me know.

    in reply to: Prevent terms order being overwritten when updating post #9315
    Anh TranAnh Tran
    Keymaster

    Hi again,

    I think I have resolved this issue. I've just pushed a commit on Github to make it work. Can you please try it.

    This is the code I use to test:

    add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
        $meta_boxes[] = [
            'title'  => 'Test: Taxonomy term order',
            'fields' => [
                [
                    'id'         => 'm_tax',
                    'type'       => 'taxonomy',
                    'taxonomy'   => 'custom-category',
                    'field_type' => 'select_advanced',
                    'multiple'   => true,
                ],
            ],
        ];
        return $meta_boxes;
    } );

    Note that multiple is set to true. It's required to select multiple terms.

    in reply to: Prevent terms order being overwritten when updating post #9312
    Anh TranAnh Tran
    Keymaster

    I understand.

    There's a technical difficulty. The select2, which is the library used for taxonomy field, doesn't support preserving selected order. I'm trying some workarounds posted on that issue to see if I can make it work in WordPress's case.

    in reply to: Can't display select fields #9311
    Anh TranAnh Tran
    Keymaster

    Hi, your select field is just a normal select without clone or multiple, so to get its value, simply remove the foreach loop in your code:

    $value = rwmb_meta( 'scadenza_prodotti_rinnovabili' );
    echo $value;
    Anh TranAnh Tran
    Keymaster

    Hi,

    There are several things in this case:

    1. I see you create 2 groups: 1 group for categories A & B, 1 group for categories C & D. And you put the conditions in each fields of the groups. That's not good for performance because the plugin has to process all fields. Why don't we put the conditions for the groups only? So we need only 2 conditions instead of 10?
    2. The value for the category select actually is the category ID, so we have to use IDs instead of category slug or name.

    3. The category select has a field type checkbox_tree, which means its value is an array. We can't use operator = in this case. Instead, use contains.

    I have adapted your code and made a fix here (please change the categories' IDs to match your case):

    https://pastebin.com/prL8r3Ra

    Here is my test:

    https://imgur.com/yunSkXX

    in reply to: Prevent terms order being overwritten when updating post #9295
    Anh TranAnh Tran
    Keymaster

    Hi,

    Can you please tell me how do you set term order for a post?

    When I go to WP database, I see the term_order is available only for term_relationships table, which stores the connections between posts and terms. And the sooner a term in inserted, the lower order it has.

    When we update a post, Meta Box runs wp_set_object_terms() function to update post terms. This function does these things:

    • Insert new terms relationships for the post
    • Delete old terms relationships
    • Reset the relationships order (term_order)

    The last step causes the problem you have met. You can check the source code of wp_set_object_terms() function to see more details. Here is the screenshot of that part:

    https://imgur.elightup.com/YeYlGhc.png

    The bad thing is this is the only function we can use to set post terms :(.

    Maybe there's another approach to set the order? Have you tried taxonomy_advanced field?

    in reply to: meta-box in the "themes folder" language settings #9294
    Anh TranAnh Tran
    Keymaster

    Yes, that should work. There's no difference where we put the code. It's just the code :D.

    in reply to: Invalid argument supplied... #9293
    Anh TranAnh Tran
    Keymaster

    Hi,

    I've just checked your code and couldn't see the error. Here is my test:

    https://imgur.elightup.com/GBe6C7B.gif

    Probably it's somewhere else. Can you check if there's any meta box that doesn't have any field?

    I see you use glob to include all PHP files in a folder. Maybe there's a PHP file that doesn't contain meta box code?

    in reply to: Invalid argument supplied... #9278
    Anh TranAnh Tran
    Keymaster

    Hello,

    Can you share the code to register meta boxes? I guess there're some things missed there.

    in reply to: Composer #9275
    Anh TranAnh Tran
    Keymaster

    Great post. How couldn't I find it! I'll check it now. Thanks for letting me know.

    in reply to: Composer #9270
    Anh TranAnh Tran
    Keymaster

    Unfortunately, there's no way to create private composer packages that are publicly accessible :(.

    I've tried packagist.com and composer satis, but they work only if you have access to private repos already. So they work for us as an internal team, but not for public.

    in reply to: post_id in hook rwmb_frontend_after_process is missing #9269
    Anh TranAnh Tran
    Keymaster

    Somehow I removed the post id. I've just added in the version 1.3.3, please update the plugin and use the code below:

    add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) {
        if ( 'nuovo-ordine' === $config['id'] ) {
            wp_safe_redirect( '?rwmb-form-submitted=nuovo-ordine&post_id='.$post_id );
            die;
        }
    }, 10, 2 );

    I added the 2nd parameter $post_id to the hook. Please try and let me know how it works.

    in reply to: meta-box in the "themes folder" language settings #9267
    Anh TranAnh Tran
    Keymaster

    Hi,

    The problem with this method is the translation files are not loaded from translate.wordpress.org. It works only with local translation files which are included directly inside the plugin. The translation from translate.wordpress.org is preferred since it allows users to contribute easily and distribute more reliably. Besides, it has a higher priority, meaning if a language is available on both translate.wordpress.org and inside plugin, the file from translate.wordpress.org is loaded.

    For example, this is the translation page for Meta Box in Vietnamese:

    https://translate.wordpress.org/locale/vi/default/wp-plugins/meta-box

    Translation files from translate.wordpress.org are stored in wp-content/languages/plugins/meta-box/ and are regularly updated when new translations available.

    Ideally, I'd love to remove the languages file from the plugin, so only translations from translate.wordpress.org are used. At the moment, some languages are not available on translate.wordpress.org yet.

    In your case, in order to make it work with your theme without modifying the plugin, you can add this line directly into your theme:

    load_textdomain( 'meta-box', plugin_basename( RWMB_DIR ) . '/languages/meta-box-'.get_locale().'.mo' );

    It works the same way ๐Ÿ˜‰

    in reply to: Display media modal values on the front end #9252
    Anh TranAnh Tran
    Keymaster

    Hello,

    The meta info in the media modal which is added by Meta Box is just custom fields of the attachment. You can get it with the helper function rwmb_meta, like this:

    $value = rwmb_meta( 'field_id', '', $attachment_id );

    in reply to: Define validation rules for group #9250
    Anh TranAnh Tran
    Keymaster

    Hi,

    I think your jQuery selector is too generic. It targets .grpsports, which is all element having that class. In the JS code, there's a parameter element that you should use to get its parent group element, and add the error message to that group only. Please try this:

    jQuery('#post').validate({
        errorPlacement: function(error, element) {
            var $group = element.closest('.grpsports');
            if ($group.length) {
                error.insertAfter($group.find('input:text:last'));
            }
        }
    });

    To target the form in both admin/frontend, you can use multiple selector like jQuery('#post, .rwmb-form').

Viewing 15 posts - 2,236 through 2,250 (of 3,958 total)