Support

Account

Forum Replies Created

  • I didn’t consider repeater and flexible content fields so yes, this probably won’t work with them. There’s probably a pretty easy way to make them functional though – I’ll look into that once I have some time.

  • We’ve had no trouble so far, but haven’t had the chance to test on a more complex project yet.

    But yes, WPML is pretty bad 🙁
    We are currently testing Polylang which looks like a good alternative so far. Will write a review once we’re done with the project.

  • Hi everyone,

    I believe I have a more or less decent looking workaround for this issue, based on the same idea JoepR had. It allows you to mark any number of options pages as “global”, i.e. they are not translatable and will always display the options in the default language. All other options pages would remain translatable.

    
    /**
     * Create the options page that we will later set "global"
     */
    acf_add_options_page(array(
          'page_title'  => 'Test',
          'menu_title'  => 'Test',
          'menu_slug'   => 'test',
    ));
    
    /**
     * Force ACF to use only the default language on some options pages
     */
    function cl_set_global_options_pages($current_screen) {
    
      // IDs of admin options pages that should be "global"
      $page_ids = array(
        "toplevel_page_acf-options-test"
      );
    
      if (in_array($current_screen->id, $page_ids)) {
        add_filter('acf/settings/current_language', 'cl_acf_set_language', 100);
      }
    }
    add_action( 'current_screen', 'cl_set_global_options_pages' );
    
    function cl_acf_set_language() {
      return acf_get_setting('default_language');
    }
    
    /**
     * Wrapper around get_field() to get the "global" option values.
     * This is the function you'll want to use in your templates instead of get_field() for "global" options.
     */
    function get_global_option($name) {
      add_filter('acf/settings/current_language', 'cl_acf_set_language', 100);
      $option = get_field($name, 'option');
      remove_filter('acf/settings/current_language', 'cl_acf_set_language', 100);
      return $option;
    }
    

    I’d appreciate any feedback on the concept. Couldn’t figure out any scenarios where it would break, but maybe I missed something.

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