Skip to content
This repository has been archived by the owner on Oct 29, 2020. It is now read-only.

Register strings only in admin and even only on the polylang settings… #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions class_GF_PLL.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,16 @@ private function iterate_form(&$value, $key, $callback = null) {

public function register_strings() {

if(!class_exists('GFAPI') || !function_exists('pll_register_string')) return;
if(!preg_match('/^mlang/', $_GET['page']) || !class_exists('GFAPI') || !function_exists('pll_register_string')) return;

$forms = GFAPI::get_forms();
foreach ($forms as $form) {
$this->form = $form;
$this->registered_strings = array();
$this->iterate_form($form, function($value, $key) {
$name = ''; // todo: suitable naming
$name = 'gfpll'; // todo: suitable naming
$group = "Form #{$this->form['id']}: {$this->form['title']}";

pll_register_string($name, $value, $group);
$this->registered_strings[] = $value;
});
Expand Down
2 changes: 1 addition & 1 deletion gf_pll.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function translate_strings($form) {
}
}

add_action('init', array('GF_PLL_Initialize', 'register_strings'), 100);
add_action('admin_init', array('GF_PLL_Initialize', 'register_strings'), 100);
add_filter('gform_pre_render', array('GF_PLL_Initialize', 'translate_strings'));
add_filter('gform_pre_process', array('GF_PLL_Initialize', 'translate_strings'));

Expand Down