beapi / acf-options-for-polylang Goto Github PK
View Code? Open in Web Editor NEWA WordPress plugin for adding ACF options page support for Polylang.
Home Page: https://wordpress.org/plugins/acf-options-for-polylang/
License: Other
A WordPress plugin for adding ACF options page support for Polylang.
Home Page: https://wordpress.org/plugins/acf-options-for-polylang/
License: Other
Hi Maxime,
Awesome plugin ! I'd like to disable the translation functionnality on certain options page. Is it possible with the work you've done ? With a filter perhaps ? I haven't seen anything that could allow me to do so.
Thanks for your feedback,
Olivier
L'appel de la fonction génère l'erreur PHP suivante :
Catchable fatal error: Object of class WP_Post could not be converted to string in /plugins/acf-options-for-polylang/classes/helpers.php on line 16.
Nous avons tenté de désactiver les autres plugins ainsi que nos fonctions perso, mais rien ne change. Nous avons tenté de rétrograder la version de votre plugin et l'erreur disparaît à la version 1.1.3.
Bonjour,
Je tiens d'abord à vous remercier pour ce plugin bien utile !
Je rencontre un problème avec les champs de type "Répéteur".
J'ai deux langues configurées (Anglais et Français). Lorsque je ne renseigne aucune valeur pour mon champ sur ces langues, la valeur de "All languages" n'est pas récupérée.
J'ai pu voir un sujet expliquant ce problème mais il a à priori été corrigé depuis.
Je dois louper quelque chose mais je n'arrive pas à voir quoi.
Hi
After installing the plugin, the frontend of the website displays this:
Fatal error: Uncaught Error: Call to undefined function BEA\ACF_Options_For_Polylang\acf_options_page() in C:\wamp\www\projectname\wp-content\plugins\acf-options-for-polylang\classes\helpers.php on line 75
Backend has no errors but does not work as saving overwrites other language value.
Thanks
Dans le cadre d'une activation sur un site comportant déjà des champs et contenus ACF dans les options, si l'on active en premier Polylang puis ACF-options-for-polylang, on perds les données des options. Il serait bon de garder/copier les données existante dans la langue principale / voir dans les deux langues.
Field have empty value in this language. If content is added and saved, it should appear for the selected language
The content from default language stays in
Effect
No effect. Nothing has changed
For each language (English, French and spanish for example) a specific value is entered in a simple text field located in a option page.
Everything is OK in the WordPress backend.
But when I wanted to display it on frontend by using the "the_field" function nothing is display for the current language
Create a field group with only one simple text field and located in the option page
Enter for each language a different value - in my case "simple_text"
Modify a template of the theme to display this field - <?php the_field('simple_text', 'option') ?>
Enter a value in the simple text field with Polylang language switcher on "Show all languages"
See that for each language that is this value is displayed on frontend
in english
Display the correct value for the current language on frontend
Nothing is displayed for the current language
composer require wpackagist-plugin/acf-options-for-polylang
Uncaught Error: Class 'BEA\ACF_Options_For_Polylang\Admin' not found
classes/admin.php
file when installing via ComposerFailed to download wpackagist-plugin/acf-options-for-polylang from source: Package could not be downloaded,
svn: E170013: Unable to connect to a repository at URL 'https://plugins.svn.wordpress.org/acf-options-for-polylang/trunk'
svn: E230001: Server SSL certificate verification failed: issuer is not trusted
Now trying to download from dist
composer require wpackagist-plugin/acf-options-for-polylang 1.1.7
) then admin.php
is installed and plugin works as expectedHello.
I have Polylang Pro and ACF Pro. I have two languages english and spanish, in the backend I have some text field which displays correctly for each language but in the frontend spanish texts are shown in english HP. why?
To fix the problem I did like that forcing page ID according to the language:
if(get_locale()=='es_PE'){
$pageID = 6;
}else if(get_locale()=='en_US'){
$pageID = 243;
}
otherwise page ID is always 6 also for 'en_US'.
This is not an elegant way to solve but it works
Thanks
Lorsque j’essaie de récupérer un champs “repeater”, j’ai en retour, le nombre d’éléments qu’il contient et non le contenu.
J'ai encodé les valeurs dans "toutes les langues" et non pas dans chacune d'entre elles.
(J'utilise ACF Pro et Polylang Pro à leurs dernières versions).
Bonjour,
Nous rencontrons un soucis lors de l'utilisation du plugin sur notre environnement de développement. En effet, quelque soit la langue sélectionnée, la valeur est sauvegardée pour toute les langues active.
Version des extensions utilisées :
Wordpress : 4.8.2
ACF Pro : 5.6.4
Polylang : 2.2.3
Polylang's ACF Option page : 1.0.1
J'ai réalisé un test en local avec les même versions des plugins ainsi qu'avec les dernières versions disponibles, et le problème persiste. Avez-vous déjà eu écho d'un problème similaire ?
Merci beaucoup.
We have noticed that Options are not properly retrieved in certain languages and I am confident I have narrowed it down to this line:
$_post_id = preg_replace( '/(_[a-z]{2}_[A-Z]{2})/', '', $post_id );
in classes/main.php#61
BEA\ACF_Options_For_Polylang\Main::get_default_reference
Updating the regex to sprintf( '/(_%s)/', pll_current_language( 'locale' ) )
should do the trick. This properly removes the current language, however it also means that the default can only be reached from the current language which might not be ideal...
Display the translated value
All language value is displayed.
Requirements never actually checks requirements on frontend as it's only hooked into admin_init
https://github.com/BeAPI/acf-options-for-polylang/blob/master/classes/requirements.php#L13
Hi there,
Thank you so much for this awesome plugin. One thing though.... I recently added it to an existing site of mine and I came up with an SQL-Script that does two things:
I think this can be very useful for other users too, e.g. if add the plugin to an existing site or you add a new language and don't want to start from 0 with your settings.
Also it cleans up the "All languages"-data, which could be a good solution for Issue #37
If you tell me where and how you would like that information in your Readme, I am very happy to make the changes and open an Pull request for it.
The MySQL:
# Rename current options
UPDATE {YOUR_TABLE_PREFIX}options SET option_name = CONCAT('options_en_GB', TRIM(LEADING 'options' FROM option_name)) WHERE option_name LIKE 'options%';
UPDATE {YOUR_TABLE_PREFIX}options SET option_name = CONCAT('_options_en_GB', TRIM(LEADING '_options' FROM option_name)) WHERE option_name LIKE '_options%';
# Duplicate options
CREATE TEMPORARY TABLE tmptable_1 SELECT * FROM {YOUR_TABLE_PREFIX}options WHERE option_name LIKE 'options%' OR option_name LIKE '_options%';
UPDATE tmptable_1 SET option_id = NULL;
UPDATE tmptable_1 SET option_name = CONCAT('options_de_DE', TRIM(Leading 'options_en_GB' FROM option_name)) WHERE option_name LIKE 'options%';
UPDATE tmptable_1 SET option_name = CONCAT('_options_de_DE', TRIM(Leading '_options_en_GB' FROM option_name)) WHERE option_name LIKE '_options%';
INSERT INTO {YOUR_TABLE_PREFIX}options SELECT * FROM tmptable_1;
DROP TEMPORARY TABLE IF EXISTS tmptable_1;
# Show the results
SELECT * FROM {YOUR_TABLE_PREFIX}options WHERE option_name LIKE 'options%' OR option_name LIKE '_options%';
Thanks,
David
im reporting and issue i recently update my acf pro to v5.8.4 and i noticed that if i have a new entry in options specially field image it only return is the attachment id even i assigned it to array or url.
Please help.
Thanks.
Screenshot explaining the result
Hi, first of all, thank you very much for the much needed plugin that allows ACF Options to be linked with Polylang, I am happily using it on several sites already.
My question/feature request: is there a way to retrieve an option in a different language than the one currently being used on the frontend? Say I am browing the English version of the website, but I need to get an option value of a German version. I could naturally do it via WPDB, but I am hoping there is/could be another way, maybe as a param to a method, where the default value would be the currently used language?
Something along the lines if beapi_get_option($name, $language = pll_current_language()) {}
TO BE FINISHED : https://github.com/BeAPI/acf-options-for-polylang/blob/true-plugin/classes/plugin.php#L22
Check on local env.
Use old main file check.
No error
Filter is deprecated and dont work with acf term field.
Fatal error: Cannot declare class BEA_ACF_For_Polylang, because the name is already in use in /var/www/...../wp-content/plugins/acf-options-for-polylang-master/acf-options-for-polylang.php on line 15
Would be great to have this plugin in the official wordpress repository or on wpackagist.org. We install plugins with PHP composer, this just works from wpackagist.
Salut Maxime -
Merci pour avoir écrit ce plugin!! Pourtant j'ai du mal a charger les options de la langue défaute.
After installing, I have re-entered the site options in the site's default language, 'en', and also in "Show all languages", where the values in the repeater fields were absent. I have not duplicated my options field group in any other lang yet.
I want to be sure ACF (with the BEA plugin) will return the default lang options if none are present in other langs. However, on other langs the usual template tag does not return any stored value:
get_field( 'field_name', 'options' );
Is there a function to get a stored option in a specific lang? Or am i doing it wrong?
It will become a bit confusing to have the All Languages content also required. Can we not set English to the default, and so when All Languages is chosen it shows the English? Same if we choose English. I dont want to have to tell the customer they have to add all English content in both All Languages AND English.
Thanks
Get both field for all languages
Only field "text" appear
If I complete "Google Map" field for a specific language, all is working fine
So I think, the plugin don't get "Google Map" field for all languages
Hi,
I would like to try your plugin but it appear to did'nt work with this plugin
https://wordpress.org/plugins/acf-cpt-options-pages/ which creat option pages for archive cpt...
Could you please check it ?
thank you very much
My old options page should be added upon plugin activation to the new options page. It's possible to fetch them like so:
get_options('name', 'options'); // for the default language
get_options('name_da', 'options'); // for the translated language
We have some quite huge options pages, so would be sweet if this was supported.
Options page is empty. I have to migrate all data manually.
Hi Maxime,
Managed to get the plugin working but it doesn't seem to work when I make a call to the REST API. It only returns the default language data. I'm using the plugin ACF to REST API which is like your plugin : pretty cool !
Have you had any use of make an API call to an multilingual option panel before ?
Any ideas on how to bypass that ?
Thanks for your feedback,
Olivier
i installed it but i don't see any effects
I don't understand how this plugin is supposed to work. Once activated I go to my options page, but I don't see any way to select another language. There's nothing there. The README
mentions: "Once this plugin is activated, you will be able to set a different value for each language, and if none is set, the “All languages” value will be used as default one." I don't see where I'm able to set 'a different value for each language'. What am I missing?
In the screenshot I see that the Publish box has a message that's set by this plugin, but I don't see any way to add another language.
On the README
page you also mention this: "Then to set and contribute your option page, simply use the Polylang's language admin flags ui." I really tried to understand what this means, but I just don't. :) What do you mean by 'contribute'? What is the Polylang's language admin flags ui?
The content that was stored in the options page, wasn't shown on the front-end. Didn't matter which language I would select. I would expect that the default values of my options page would be shown, but that didn't happen. Also, since I wasn't able to add any other languages, I didn't see the values for the other languages I would like to add.
The only 'strange' thing about my setup is that I'm using Timber and that I named my options page differently. Don't expect that to have anything to do with it, but I might as well name it.
You chose the locale
field from Polylang to distinguish option keys (eg. options_fr_FR_my_key
, options_en_US_my_key
, etc.). The problem is that you can store multiple languages with the same locale whereas you can't with the same slug
. Polylang forbids it.
Polylang isn't always used in a multilingual site. It can be used for a multi country site (you could have the same locale for two or more countries and not necessarily use sub locale).
This is of course quite an edge case issue but I think it's worth to be noticed and should be fixed in a future major release because it would introduce a BC issue.
I am a little bit confused, I hope you can help...
We used to use WPML but converted to Polylang. All OK except the Options fields were not showing the other languages in the Admin or on the front end.
So we installed this plugin. The other languages are showing the options fields on the site now, all the values we added when we used WPML.
But in the backend, if I switch to other languages, it shows the English/default for the languages. I tried changing one of them in the German language but this did not change on the german site. It still showed the original german field we entered when using WLML.
Actually I then went to change the default US language and that did not change.
So the front end is showing the correct option fields we added when using WPML. But the backend does not seem to work. It shows original US fields, but changing them does nothing.
Its quite strange!
Quand on est dans un choix de langue (anglais ou français) ça enregistre bien comme il faut
mais quand on est sur "Show all languages" la fonction sauvegarde n'est pas active.
"Toutes langues" les données sont bonnes mais quand on modifie une langue et qu'on sauvegarde, ça sauvegarde les deux
Prérequis :
We have PHP 5.4 and it seems to be working fine.
Hi, I also have a problem with using repeat, it turns out that the plugin takes into account the number of lines added to the repeater and, depending on the number of fields fills all languages with empty values of other fields, here is a video problem : https://cloud.mail.ru/public/J3c7/cQi8FFPxu how to fix???
get_field('text', $post);
It should get the field "text" from the $post provided.
Warning: strpos() expects parameter 1 to be string, object given in /Users/antonfuruholm/sandbox/Frilans/GRAND PUBLIC/Extend/website/wp-content/plugins/acf-options-for-polylang/classes/main.php on line 184
EDIT:
Sorry, for blank input it works. Problem is, that "address" field is array with empty values.
https://github.com/chrisgoddard/acf-address-map-field
EDIT2:
What about some check, if multidimensial array is empty?
if ( ! is_null( $value ) ) {
if ( is_array( $value ) ) {
$empty = true;
array_walk_recursive( $value, function ( $leaf ) use ( &$empty ) {
if ( $leaf === [] || $leaf === '' )
return;
$empty = false;
});
if ( ! $empty )
return $value;
} else {
if ( "" !== $value ) {
// Not an empty string
return $value;
}
}
}
For me, this code change works great :)
Hi, I have option page with several inputs
address - it is global field in all languages
text_* field, which is unique in different languges
I have two languages :
english - primary
svedish
If I switch to language (not "Show all languages") and save, in database there is empty value
options_en_US_address
on frontend in en_US language address is empty, which is problem.
So, it is possible check, if value is empty string and is not "Show all langues", then dont store to database, .
Workaround is several "options" page for, "global" with address,etc. and another page for text string. But if client switch to another language and save on "global" page with not filled input, there is same problem.
Thanks
When calling get_options('name', 'options')
from the REST API the old options page is returned, and not the new one. It looks like the filters is not being applied in the REST API
New options should be returned
Old options was returned
Hi @MaximeCulea and thanks very much for developing this plugin. Very nice.
Let's say I have:
Result seems to be that:
If this is the expected behavior, I would like to update the README as along the lines of:
This plugin creates an additional Options Page field for each field for which there is a translation and displays these fields in the front end instead of the All Languages value for that field. Localized (regional) Options Pages are accessed via the Polylang Admin Flags UI ("Show All Languages") Filter in the WP Admin Bar. The values for the fields will still be stored in the database (as well as displayed in the view of the Options Page), but they will only be displayed in the front end if Localized values are not set.
I think that might be a little clearer than what is there now.
Field Groups
Has that something to do with my wordpress version. Cause you write "Tested up to 4.9.4"?
I just follow this steps.
https://polylang.pro/doc/working-with-acf-pro/
Best Regards
In an English / French WordPress install, English being the default language, I have an ACF repeater field on an option page with items (rows) set for All languages and no items for French. On normal page display when I use get_field
I get the default All languages items. But when I use get_field
during an Ajax request, I get no items.
Looking at the code of acf-options-for-polylang, the get_default_value
(in classes/main.php:78
) is indeed returning immediately if is_admin()
is true, which is the case during an Ajax request. By replacing the first three lines of this function with following code I seem to obtain the needed behavior:
if ( (!acf_is_ajax() && is_admin()) || ! Helpers::is_option_page( $post_id ) ) {
return $value;
}
It’s only a test. I’m absolutely not implying that this change is the way to do it.
Having an English / French WordPress install with an option page. English being default.
I’m expecting the same value from my field during normal page display and during an Ajax request.
I got French empty value during Ajax request, instead of default All languages value.
At beginning, check if the mode is get "All languages" instead.
At the same time, rename the func, because it's not a setter, but more a getter.
Front page fields to be visible.
Front page is empty (the styles load up but no content).
This plugin should not affect normal pages, right? My front page fields are set to be displayed if page type is same as front page (that is selected in general settings) and I have only one repeater on front page.
When var_dumping the field, it returns a string (id, perhaps?). How to proceed?
Advanced Custom Fields and Polylang are required plugins.
All requirements are be matched, so the plugin should activate without any errors.
Error Advanced Custom Fields and Polylang are required plugins.
is thrown in classes/requirements.php
I guess that the requirements are not properly checked.
I will fork this for my own use to solve the issue. Interested in any tipps on how to solve!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.