Support

Account

Forum Replies Created

  • After some quality reverse engineering time, I found out I need to use filter “acf/load_field_groups”, in which I go group by group and set settings I need – https://ibb.co/M1T6HXM.

    For some reason “acf/load_field_group” and “acf/validate_field_group” does not work.

  • I tried to do this, but it won’t show up.

    1) https://ibb.co/mNy3QD9 (it works, it adds correctly to array)
    2) see here dump of $field_group https://ibb.co/wsL8dss
    3) it even correctly shows up when editing ACF https://ibb.co/DC7ZYPh

    But when I am in product, fields won’t show up. Any guess what’s wrong?

  • Well, for anyone wondering, I found a “solution”.

    public function add_more_layouts( $field ) {
        $add_layouts = array();
    
        $default_layouts = acf_get_field( 'default_layouts' );
    
        if( ! empty( $default_layouts[ 'layouts' ] ) ) {
            $add_layouts = $this->merge_blocks_correctly( $add_layouts, $default_layouts[ 'layouts' ] );
        }
        
        $user_layouts = acf_get_field( 'user_layouts' );
    
        if( ! empty( $user_layouts[ 'layouts' ] ) ) {
            $add_layouts = $this->merge_blocks_correctly( $add_layouts, $user_layouts[ 'layouts' ] );
        }
        
        $global_layouts = acf_get_field( 'global_layouts' );
    
        if( ! empty( $global_layouts[ 'layouts' ] ) ) {
            $add_layouts = $this->merge_blocks_correctly( $add_layouts, $global_layouts[ 'layouts' ] );
        }
    
        $field[ 'layouts' ] = $add_layouts;
        return $field;
    }
    
    public function merge_blocks_correctly( $layouts_start, $layouts_new ) {
        foreach( (array) $layouts_new as $layout_key => $layout_data ) {
            if( array_key_exists( $layout_key, $layouts_start ) ) {
                unset( $layouts_start[ $layout_key ] );
            }
        }
    
        $merge = array_merge( $layouts_start, $layouts_new );
        return $merge;
    }

    How it works:
    1) I get all default layouts from EMPTY (except first dummy layout) Flexible Content field

    2) Then I proceed to load “user” layouts (another Flexible Content field)

    3) These I merge BUT remove anything that was previously setup (duplicates)

    4) I add more layouts (repetitive point 2 and 3)

    5) Overwrite (return) layouts from EMPTY Flexible Content. Each is in seperate Field Group

    This way I can modify multiple Flexible Fields separately and they load to the “empty” one.

  • I kinda did that, BUT it’s saving to JSON … which should be preventable?

    Code for other:

    add_filter( 'acf/load_field/name=blocks_content', array( $this, 'add_more_layouts' ), 10, 1 );
    
    public function add_more_layouts( $field ) {
        $add_layouts = array();
    
        $more_layouts = acf_get_field( 'more_layouts' );
        if( ! empty( $more_layouts[ 'layouts' ] ) ) {
            $add_layouts = array_merge( $add_layouts, $more_layouts[ 'layouts' ] );
        }
    
        if( ! empty( $add_layouts ) ) {
            $field[ 'layouts' ] = array_merge( $field[ 'layouts' ], $add_layouts );
        }
    
        return $field;
    }
  • Only thing I did is:
    – acf_add_options_page with “redirect: false”
    – and then “add_submenu_page()” which negates the redirect and makes it “true” basically

    Why? Because I have ACF Option Page ad main where I have settings. It’s for my plugin. After that I need custom pages (mosty currently used to hide CPT my plugin creates).

    So when I click on the “first” item I see Option Page but there is submenu with more subpages I need.

    Correct me if I am wrong, but why should I use “acf_add_options_sub_page” to link to CPT or show custom content (not related to ACF)? This function does not support that, so I use default WordPress way

    PS: I managed to have it working (add acf subpage and the main option page is redirecting to it).

  • Yes, you are totally right. After further testing I already found out, that CPT are better for this type of job ๐Ÿ™‚

  • Yes, I tried this, but as support told me yesterday, it’s kinda impossible to do in current stage of development.

    My point was, that every user see option page based on “user_login”. Which works, but than there pre_get_posts problem, admin can’t edit it etc.

  • Hopefully, there is options how to solve this manually. Just switch to “code editor” in right corner (three vertical dots) and copy HTML to new page (in page again switch to code editor).

    It’ll copy content in correct way. It’s better than nothing …

  • I already contacted the support. They replicated the issue and DEV told me:

    Interesting issue. It looks to me that the duplicator plugins are causing the post_content data to become corrupt in some way when the post is copied.
    This may not be a specific issue in the duplicator plugins themselves, but may be an issue with one of the WP post_content filters being run when the post is inserted into the DB.

    I’ll add this to my list of issues to fix, but won’t be able to provide you with an ETA on a fix just yet.

    It would be great if you could perform some more investigation to determine if there are some use-cases when the duplicator plugins do work.
    For example, create a new block type with a very simple field group (one text field). Try to replicate the issue on a new post, adding only one of this block type. If this works, try adding two blocks. If this works, try adding more complex field types to the block, etc

    I plan to try some investigation this weekend and anyone else can too ๐Ÿ™‚

  • So i.e. I have my footer.php file, how I manage to load everything from my sub-option page in admin called “footer”?

    In ACF PRO I have set two fields, “footer-left”, “footer-right”. I am loading it under sub-page in admin footer.

    Now, what is the best code option, to load everything from my “sub-page”?

Viewing 11 posts - 1 through 11 (of 11 total)