From 2bf2ea306aa1e72e9983a920a881dd9a44f517f5 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 29 Nov 2023 15:30:04 +0100 Subject: [PATCH] v 2.62.0 Settings v 0.18.0 : - Fix when fields become multilingual --- inc/WPUBaseSettings/WPUBaseSettings.php | 16 +++++++--------- wpubaseplugin.php | 6 +++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/inc/WPUBaseSettings/WPUBaseSettings.php b/inc/WPUBaseSettings/WPUBaseSettings.php index fe51ae8..3838268 100644 --- a/inc/WPUBaseSettings/WPUBaseSettings.php +++ b/inc/WPUBaseSettings/WPUBaseSettings.php @@ -1,10 +1,10 @@ settings_details['option_id']); - if (!is_array($opt)) { - /* Set default values */ - $opt = $this->get_setting_values(); - update_option($this->settings_details['option_id'], $opt); - } - return $opt; + return $this->get_setting_values(); } public function get_setting($id, $lang = false) { @@ -223,6 +217,7 @@ public function add_settings() { 'id' => $id, 'lang_id' => $lang_id, 'label_for' => $id, + 'translated_from' => isset($this->settings[$id]['translated_from']) ? $this->settings[$id]['translated_from'] : false, 'required' => $this->settings[$id]['required'], 'post_type' => $this->settings[$id]['post_type'], 'datas' => $this->settings[$id]['datas'], @@ -328,6 +323,9 @@ public function render__field($args = array()) { } $id .= $attr; $value = isset($options[$args['id']]) ? $options[$args['id']] : $args['default_value']; + if(!isset($options[$args['id']]) && isset($args['translated_from']) && $args['translated_from'] && isset($options[$args['translated_from']]) && $options[$args['translated_from']]){ + $value = $options[$args['translated_from']]; + } switch ($args['type']) { case 'checkbox': diff --git a/wpubaseplugin.php b/wpubaseplugin.php index 90eb593..606f96e 100644 --- a/wpubaseplugin.php +++ b/wpubaseplugin.php @@ -5,7 +5,7 @@ Plugin URI: https://github.com/WordPressUtilities/wpubaseplugin Update URI: https://github.com/WordPressUtilities/wpubaseplugin Description: A framework for a WordPress plugin -Version: 2.61.1 +Version: 2.62.0 Author: Darklg Author URI: https://darklg.me/ Text Domain: wpubaseplugin @@ -18,7 +18,7 @@ class WPUBasePlugin { - public $version = '2.61.1'; + public $version = '2.62.0'; private $utilities_classes = array( 'messages' => array( @@ -34,7 +34,7 @@ class WPUBasePlugin { 'name' => 'WPUBaseAdminPage' ), 'settings' => array( - 'namespace' => 'wpubasesettings_0_17_6', + 'namespace' => 'wpubasesettings_0_18_0', 'name' => 'WPUBaseSettings' ), 'cron' => array(