From ce7f65fdc78b59f34db9677ef7ba2aa7e64243a8 Mon Sep 17 00:00:00 2001 From: Daniel Intrieri <119604034+Twindrillss@users.noreply.github.com> Date: Thu, 22 Feb 2024 18:12:21 +0100 Subject: [PATCH] Update funzioni.php aggiunta feature disattiva --- funzioni.php | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/funzioni.php b/funzioni.php index 61fcca9..84b38a3 100644 --- a/funzioni.php +++ b/funzioni.php @@ -259,6 +259,8 @@ function generajsmodal() { function generahtmlmodal($filepdf){ + if (controllamenu()) { + $cartelle = dirname(__FILE__); $ultimacartella = basename($cartelle); @@ -400,11 +402,15 @@ return ' '; - +} else { + return '
'; +} } function generahtmlmodalridotto($filepdf,$etichetta){ + if (controllamenu()) { + $cartelle = dirname(__FILE__); $ultimacartella = basename($cartelle); @@ -545,5 +551,62 @@ function generahtmlmodalridotto($filepdf,$etichetta){ '; - +} else { + return ''; +} + } + + function controllamenu() { + + $cartelle = dirname(__FILE__); + $ultimacartella = basename($cartelle); + + $target_dir = $_SERVER['DOCUMENT_ROOT']."/wp-content/plugins/".$ultimacartella."/"; + + + $json_data = file_get_contents($target_dir.'settings.json'); + + // Decode the JSON data into a PHP associative array + $settings = json_decode($json_data, true); + + $statomenu = false; + + // Controllo su stato "active" + if (isset($settings['active']) && $settings['active'] === 'yes') { + $statomenu= true; + } + + + return $statomenu; + + + } + + function scrivisujson ($dato) { + + $cartelle = dirname(__FILE__); + $ultimacartella = basename($cartelle); + + $target_dir = $_SERVER['DOCUMENT_ROOT']."/wp-content/plugins/".$ultimacartella."/"; + + + $json_data = file_get_contents($target_dir.'settings.json'); + + // Decode the JSON data into a PHP associative array + $settings = json_decode($json_data, true); + + if ($settings !== null) { + + $settings['active'] = $dato; + + // Encode the modified settings array back to JSON format + $new_json_data = json_encode($settings, JSON_PRETTY_PRINT); + + // Write the updated JSON data back to the settings.json file + file_put_contents($target_dir . 'settings.json', $new_json_data); + + + } + + }