1 | <a href="https://beapi.fr">![Be API Github Banner](.wordpress.org/banner-github.png)</a> |
---|
2 | |
---|
3 | # BEA - ACF Options For Polylang |
---|
4 | |
---|
5 | [![CodeFactor](https://www.codefactor.io/repository/github/beapi/acf-options-for-polylang/badge)](https://www.codefactor.io/repository/github/beapi/acf-options-for-polylang) |
---|
6 | |
---|
7 | You are using Advanced Custom Fields for creating option pages and you have Polylang installed for awsome multilingual site ? |
---|
8 | |
---|
9 | Sadly, Polylang is not handling ACF's Option Pages. Which means values will be the same for all languages you have set. |
---|
10 | |
---|
11 | We are here to save your life ! 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. |
---|
12 | |
---|
13 | # How ? |
---|
14 | |
---|
15 | This plugin will store a value for each language into database. Then Polylang's languages are used to get the values from the DB. <b>That means at activation, all existing data will not be anymore available, but still in database. You will retrieve it ad plugin deactivation.</b> |
---|
16 | |
---|
17 | Then to set and contribute your option page, simply use the Polylang's language admin flags ui. |
---|
18 | |
---|
19 | # Requirements |
---|
20 | |
---|
21 | - Require [WordPress](https://wordpress.org/) 4.7+ / Tested up to 5.2 |
---|
22 | - Require PHP 5.6 |
---|
23 | - [Advanced Custom Fields](https://www.advancedcustomfields.com/pro) 5.6.0+ |
---|
24 | - [Polylang](https://polylang.pro/) |
---|
25 | |
---|
26 | # Installation |
---|
27 | |
---|
28 | First activate and configure Polylang in you site. |
---|
29 | Then activate ACF Options For Polylang to handle ACF Options in setted Polylang's languages. |
---|
30 | |
---|
31 | ## WordPress |
---|
32 | |
---|
33 | - Download and install using the built-in WordPress plugin installer. |
---|
34 | - Site activate in the "Plugins" area of the admin. |
---|
35 | - Optionally drop the entire `acf-options-for-polylang` directory into mu-plugins. |
---|
36 | - Nothing more, this plugin is ready to use ! |
---|
37 | |
---|
38 | ## [Composer](http://composer.rarst.net/) |
---|
39 | |
---|
40 | - Add repository source : `{ "type": "vcs", "url": "https://github.com/BeAPI/acf-options-for-polylang" }`. |
---|
41 | - Include `"bea/acf-options-for-polylang": "dev-master"` in your composer file for last master's commits or a tag released. |
---|
42 | - Nothing more, this plugin is ready to use ! |
---|
43 | |
---|
44 | # What ? |
---|
45 | |
---|
46 | ## Features |
---|
47 | |
---|
48 | - Almost simple fields (text, textarea, links, etc) |
---|
49 | - Repeater fields (with simple fields) |
---|
50 | |
---|
51 | ## More features to come |
---|
52 | |
---|
53 | As you can see, some [issues](../../issues?q=is%3Aissue+is%3Aopen+label%3Aquestion) are feature requests : |
---|
54 | - Migration of data for using plugin : at activation, all data will not be anymore available, but still in database. |
---|
55 | - Migration of data for not using plugin anymore |
---|
56 | |
---|
57 | ## Next Roadmap |
---|
58 | - Fixing [#41] : repeater issue when need to get all languages one. |
---|
59 | |
---|
60 | ## Contributing |
---|
61 | |
---|
62 | Please refer to the [contributing guidelines](.github/CONTRIBUTING.md) to increase the chance of your pull request to be merged and/or receive the best support for your issue. |
---|
63 | |
---|
64 | ### Issues & features request / proposal |
---|
65 | |
---|
66 | If you identify any errors or have an idea for improving the plugin, feel free to open an [issue](../../issues/new). Please provide as much info as needed in order to help us resolving / approve your request. |
---|
67 | |
---|
68 | ## For developers |
---|
69 | |
---|
70 | ## Using fields |
---|
71 | |
---|
72 | Nothing change, we have made all the hooks for you, so no need to prefix your fields with a lang or something else. |
---|
73 | Only use ACF's helpers to get and show the fields as you did before with [get_field()](https://www.advancedcustomfields.com/resources/get_field/) or the_field() : |
---|
74 | |
---|
75 | `get_field( 'footer_disclaimer', 'options' );` |
---|
76 | |
---|
77 | ## Default values (with "All languages") |
---|
78 | |
---|
79 | The plugin is designed to get the Polylang "All languages" value if the current lang one is empty. But if you are not interested about this behaviour, you can programmatically deactivate it using the following filter by setting to false. |
---|
80 | |
---|
81 | ### For all ACF Options pages |
---|
82 | |
---|
83 | ``` |
---|
84 | <?php add_filter( 'bea.aofp.get_default', '__return_false' ); |
---|
85 | ``` |
---|
86 | |
---|
87 | ### For just one ACF Options page |
---|
88 | |
---|
89 | ``` |
---|
90 | <?php add_filter( 'bea.aofp.get_default', function( $show_default, $post_id ) { |
---|
91 | if ( 'my_custom_acf_option_post_id' === $post_id ) { |
---|
92 | // Custom condition for the wanted post id ACF Option page |
---|
93 | return false; |
---|
94 | } |
---|
95 | |
---|
96 | return $show_default; |
---|
97 | }, 10, 2 ); |
---|
98 | ``` |
---|
99 | |
---|
100 | # Who ? |
---|
101 | |
---|
102 | Created by [Be API](https://beapi.fr), the French WordPress leader agency since 2009. Based in Paris, we are more than 30 people and always [hiring](https://beapi.workable.com) some fun and talented guys. So we will be pleased to work with you. |
---|
103 | |
---|
104 | This plugin is only maintained, which means we do not guarantee some free support. Consider reporting an [issue](#issues--features-request--proposal) and be patient. |
---|
105 | |
---|
106 | If you really like what we do or want to thank us for our quick work, feel free to [donate](https://www.paypal.me/BeAPI) as much as you want / can, even 1€ is a great gift for buying cofee :) |
---|
107 | |
---|
108 | ## License |
---|
109 | |
---|
110 | BEA - ACF Options for Polylang is licensed under the [GPLv2 or later](LICENSE.md). |
---|