Coder Social home page Coder Social logo

Comments (1)

puntonero avatar puntonero commented on July 4, 2024

Hi,
same question from me!
I think that would be useful to have the option to get the raw content of a field.
In my case I'm trying to write a pdf document in a different language than the one displayed in current web page.
I've found a little workaround:
defining and setting the value of a custom qtranslate option $q_config['return_raw'] changing few lines in
acf-qtranslate/src/acf_5/acf.php

  • public function __construct($plugin) { $this->plugin = $plugin; global $q_config; isset($q_config['return_raw']) ? $q_config['return_raw'] : $q_config['return_raw']=0; add_filter('acf/format_value', array($this, 'format_value')); add_action('acf/include_fields', array($this, 'include_fields')); add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); }

and

  • public function format_value($value) { global $q_config; if (is_string($value)) { if($q_config['return_raw'] == 0){ $value = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($value); }else{ $q_config['return_raw'] = 0; // reset to zero to be sure next field will be formatted as usual } } return $value; }

then at the bottom of acf-qtranslate/compatibility/qtranslatexs.php

  • function get_field_raw( $selector, $post_id = false, $format_value = true ) { global $q_config; $q_config['return_raw'] = 1; return get_field( $selector, $post_id , $format_value ); }

Now I can get the raw content of a acf_qtranslate_acf_5_textarea and acf_qtranslate_acf_5_text using the funcion get_field_raw in the same way you use the already provided get_field function, but it doesn't with the acf_qtranslate_acf_5_wysiwyg field.

I can't manage to get the raw data from this field type

Any help would be apreciated.

from acf-qtranslate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.