Support

Account

Home Forums Add-ons Options Page Don't translate option page Reply To: Don't translate option page

  • A little addition, although it’s an older topic.

    I needed this as well, but as @andreasdm mentioned already, it needs to added ‘around’ each option that you retrieve.

    So I made it a bit easier, so you don’t have to add this around each get option field you use. I made a custom function (which needs to be added in functions.php) which returns the original value, based on the field name that is inputted.

    /**
     * Force return default language option value
     *
     * @param bool $field_name
     *
     * @return bool|mixed|null
     */
    function beee_get_filtered_option( $field_name = false ) {
    
        if ( false == $field_name ) {
            return $field_name;
        }
    
        /**
         * Set language to default
         *
         * @return bool|mixed
         */
        function beee_set_default_lang() {
            global $sitepress;
            return $sitepress->get_default_language();
        }
        add_filter( 'acf/settings/current_language', 'beee_set_default_lang' );
    
        // retrieve $field_name option value
        $value = get_field( $field_name, 'option' );
    
        /**
         * Reset to 'real' language
         *
         * @return mixed
         */
        function beee_reset_to_real_lang() {
            return ICL_LANGUAGE_CODE;
        }
        add_filter( 'acf/settings/current_language', 'beee_reset_to_real_lang' );
    
        return $value;
    }
    if ( class_exists( 'acf' ) ) {
        add_action( 'init', 'sd_get_filtered_option' );
    }

    Add this as is. No changes needed.

    Then call each option value like this:
    beee_get_filtered_option( $option_field_name );