Skip to content

Commit 5b1286a

Browse files
authored
Support for Polylang field translation settings (#134)
* Changelog. * Show pll_display_field_instructions. * Translation option for the field. * Allow different layout structures for each language.
1 parent 2fc21a3 commit 5b1286a

File tree

4 files changed

+65
-1
lines changed

4 files changed

+65
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
[Unreleased]
88

9+
## [1.41.5]
10+
11+
### Fixed
12+
- Add support for Polylang version 3.7 field translation settings.
13+
914
## [1.41.4]
1015

1116
### Fixed

plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: ACF Codifier
44
Plugin URI: https://github.com/devgeniem/acf-codifier
55
Description: A helper class to make defining ACF field groups and fields easier in the code.
6-
Version: 1.41.4
6+
Version: 1.41.5
77
Author: Miika Arponen / Geniem Oy
88
Author URI: https://geniem.fi
99
License: GPL-3.0

src/Field.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ abstract class Field {
100100
*/
101101
protected $default_value;
102102

103+
/**
104+
* Translation option for the field.
105+
*
106+
* @var string
107+
*/
108+
protected $translations = 'translate_once';
109+
103110
/**
104111
* Filters and actions to be hooked.
105112
*
@@ -727,6 +734,27 @@ public function get_default_value() {
727734
return $this->default_value;
728735
}
729736

737+
/**
738+
* Set translation for the field.
739+
*
740+
* @param string $translations Type of translation.
741+
* @return self
742+
*/
743+
public function set_translations( string $translations ) {
744+
$this->translations = $translations;
745+
746+
return $this;
747+
}
748+
749+
/**
750+
* Get the translations value of the field.
751+
*
752+
* @return string
753+
*/
754+
public function get_translations() {
755+
return $this->translations;
756+
}
757+
730758
/**
731759
* Hide the field label in the admin side
732760
*

src/Group.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ class Group implements GroupableInterface {
120120
*/
121121
protected $show_in_rest;
122122

123+
/**
124+
* Show polylang field instructions.
125+
*
126+
* @var boolean
127+
*/
128+
protected $pll_display_field_instructions;
129+
123130
/**
124131
* Is field group registered yet
125132
*
@@ -141,6 +148,8 @@ public function __construct( string $title, string $key = null ) {
141148
$this->active = 1;
142149

143150
$this->show_in_rest = 0;
151+
152+
$this->pll_display_field_instructions = 0;
144153
}
145154

146155
/**
@@ -520,6 +529,28 @@ public function hide_in_rest() {
520529
return $this;
521530
}
522531

532+
/**
533+
* Show polylang field instructions.
534+
*
535+
* @return self
536+
*/
537+
public function show_pll_display_field_instructions() {
538+
$this->pll_display_field_instructions = 1;
539+
540+
return $this;
541+
}
542+
543+
/**
544+
* Hide polylang field instructions.
545+
*
546+
* @return self
547+
*/
548+
public function hide_pll_display_field_instructions() {
549+
$this->pll_display_field_instructions = 0;
550+
551+
return $this;
552+
}
553+
523554
/**
524555
* Register the field group to ACF.
525556
*

0 commit comments

Comments
 (0)