qtranslate / qtranslate-xt

qTranslate-XT (eXTended) - reviving qTranslate-X multilingual plugin for WordPress. A new community-driven plugin soon. Built-in modules for WooCommerce, ACF, slugs and others.
GNU General Public License v2.0
553 stars 104 forks source link

Output RAW Data via Rest API #975

Open JulianCataldo13 opened 3 years ago

JulianCataldo13 commented 3 years ago

Hi there,

I'm using a JAMstack (wordpress is just a CMS, not a front-end at all). From there, I'd like to pull data in a raw form, I'm managing the splitting process myself at the frontend level (static site generation).

Basically I'd like to disable QTranslate for frontend + API but keep it for the back-office.

Is it possible ?

Thanks a lot.

herrvigg commented 3 years ago

Currently that's not possible but for test you can disable the front end execution here: https://github.com/qtranslate/qtranslate-xt/blob/591fb09c426570d1e0fb216d76827671f264ee37/qtranslate_core.php#L124

Replace this with assert(true) or change the if-test to execute admin only when doing_front_end is false. If this works we may add a specific filter to handle this.

herrvigg commented 3 years ago

However the problem is for REST, standard calls will be executed as front requests unless they refer to wp-admin or fall under specific cases.

JulianCataldo13 commented 3 years ago

Thanks @herrvigg. I tried that, and in fact, disabling front-end doesn't disable API calls. wp-admin and gutenberg all relies on REST API at different degrees.

The only thing that is truly decoupled are the php front-end templates (which I do not use at all).

herrvigg commented 3 years ago

To be clear, disabling front-end would certainly not disable the API calls but you might lose the qTranslate features (translations) on those.