AutorÃa | Ultima modificación | Ver Log |
<?php
defined('MOODLE_INTERNAL') || die();
// Create a new settings page for inherited settings
$page = new admin_settingpage('theme_universe_child_inherited', get_string('inheritedsettings', 'theme_universe_child'));
// Function to get parent theme settings
function theme_universe_child_get_parent_settings()
{
global $CFG;
$settings = [];
$parent_settings_dir = $CFG->dirroot . '/theme/universe/settings/';
if (is_dir($parent_settings_dir)) {
$files = scandir($parent_settings_dir);
foreach ($files as $file) {
if (pathinfo($file, PATHINFO_EXTENSION) === 'php') {
$settings[] = $file;
}
}
}
return $settings;
}
// Function to apply parent settings to child theme
function theme_universe_child_apply_parent_settings($settings)
{
global $CFG, $page;
foreach ($settings as $setting) {
$parent_setting = $CFG->dirroot . '/theme/universe/settings/' . $setting;
if (file_exists($parent_setting)) {
// Include the parent setting file
require_once($parent_setting);
// Modify the setting names to use child theme prefix
if (isset($setting)) {
$setting->name = str_replace('theme_universe/', 'theme_universe_child/', $setting->name);
}
}
}
}
// Get and apply parent settings
$parent_settings = theme_universe_child_get_parent_settings();
theme_universe_child_apply_parent_settings($parent_settings);
// Add the page to the settings
$settings->add($page);