https://github.com/natanrock/polylang-acf-cli
Automate ACF + Polylang Pro translations settings via WP-CLI or one-time script. Supports nested fields, easy to use, perfect for developers and automation.Script for bulk change tranlations
https://github.com/natanrock/polylang-acf-cli
acf acf-pro automation cli developer-tools polylang translations wordpress wp-cli
Last synced: 8 months ago
JSON representation
Automate ACF + Polylang Pro translations settings via WP-CLI or one-time script. Supports nested fields, easy to use, perfect for developers and automation.Script for bulk change tranlations
- Host: GitHub
- URL: https://github.com/natanrock/polylang-acf-cli
- Owner: NatanRock
- Created: 2025-05-05T11:05:54.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-05-05T13:16:08.000Z (8 months ago)
- Last Synced: 2025-05-06T19:16:50.408Z (8 months ago)
- Topics: acf, acf-pro, automation, cli, developer-tools, polylang, translations, wordpress, wp-cli
- Language: PHP
- Homepage:
- Size: 23.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ACF × Polylang CLI Tools


Tools to automate the `Translations` setting in ACF fields when working with **Polylang Pro + ACF Pro**.
No more manually setting "Copy Once", "Ignore" or "Synchronize" for each field. Automate this process and save your time.
## 🚀 Features
| Feature | Description |
| --------------- | --------------------------------------------------------- |
| Bulk update | Update ACF field translation modes via WP-CLI |
| Nested support | Supports groups, repeaters, flexible content |
| **Two methods** | **Use either as a one-time script or as a WP-CLI plugin** |
| Quick script | One-time script for fast changes without CLI command |
## 📦 Installation
| File | Location |
| ---------------- | ------------------------------------------------------------------ |
| `plugin-cli.php` | Place in `wp-content/mu-plugins` (or `plugins`) for WP-CLI usage |
| `script-cli.php` | Anywhere (optional), used with `wp eval-file` for one-time updates |
```bash
git clone https://github.com/your-repo/cli-polylang-acf.git
```
## ✅ WP-CLI Command (recommended)
`plugin-cli.php` registers a custom WP-CLI command:
```bash
wp acf-polylang set --mode=copy_once --type=image
```
### Options
| Option | Description |
| -------- | --------------------------------------------------------------------- |
| `--mode` | ignore / copy\_once / translate / synchronize / translate\_once |
| `--type` | image / text / textarea / wysiwyg / group / repeater / \* (all types) |
### Examples
```bash
# Set all image fields to "Copy Once"
wp acf-polylang set --mode=copy_once --type=image
# Set all text and textarea fields to "Ignore"
wp acf-polylang set --mode=ignore --type=text,textarea
# Set everything to "Synchronize"
wp acf-polylang set --mode=synchronize --type=*
```
## ⚡ One-time Script (quick usage)
For quick changes without installing the CLI command:
```bash
wp eval-file path/to/script-cli.php
```
Before running, edit `script-cli.php` to configure:
```php
$mode = 'copy_once'; // Mode: ignore, copy_once, translate, synchronize
$targetType = 'image'; // Field type (or "*" for all)
```
When executed, all matching ACF fields will be updated recursively.
## 👉 How to choose method
| Use case | Recommended method |
| ------------------------------------------ | ---------------------------------- |
| One-time bulk update | One-time Script (simple and quick) |
| Regular / repeatable updates or automation | WP-CLI Command (recommended) |
| CI/CD or deployment tasks | WP-CLI Command |
| Developers unfamiliar with CLI | One-time Script |
Both methods produce the same result — choose based on your workflow and frequency of use.
## 📌 Notes
| Tip | Info |
| ------------ | ------------------------------------------------------- |
| Backup | Always backup your database before bulk updating fields |
| Sub fields | Supported: group, repeater, flexible content |
| Auto updates | Automatically updates ACF field objects in the database |
| ACF JSON | Run `wp acf sync` or resave field groups after updating |
## 📚 License
MIT — free to use, modify, and share.
---
**Made for developers who don't want to click hundreds of fields manually.**
Enjoy automation and focus on what matters.
---
# 📖 Changelog
## \[v1.0.0] - 2025-05-05
### Added
* Initial stable release.
* WP-CLI command support to bulk update ACF translation modes.
* One-time PHP script for fast non-CLI usage.
* Support for nested fields: Group, Repeater, Flexible Content.
* MIT license.
### Notes
* Make sure to backup the database before using the bulk update scripts.
* Compatible with ACF JSON sync workflows.
---