| 1 |
<?php |
| 2 |
/** |
| 3 |
* Settings module (spec 015-settings-page). |
| 4 |
* |
| 5 |
* The wp-admin Settings submenu page, the settings/update REST endpoint, and the |
| 6 |
* public-page custom-CSS injection. Relocated from includes/Admin/ — behavior |
| 7 |
* byte-identical (same submenu, same route, same wp_head output). |
| 8 |
* |
| 9 |
* @package Templately |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace Templately\Modules\Settings; |
| 13 |
|
| 14 |
use Templately\Core\Module_Base; |
| 15 |
use Templately\Modules\Settings\REST\Preferences as PreferencesEndpoint; |
| 16 |
use Templately\Modules\Settings\REST\Settings as SettingsEndpoint; |
| 17 |
|
| 18 |
class Module extends Module_Base { |
| 19 |
|
| 20 |
public function get_name(): string { |
| 21 |
return 'settings'; |
| 22 |
} |
| 23 |
|
| 24 |
public function get_dependencies(): array { |
| 25 |
// REST/Settings.php calls KitApplier::apply() from modules/elementor-kit-settings |
| 26 |
// (spec 031) when persisting global colors/typography. |
| 27 |
return [ 'elementor-kit-settings' ]; |
| 28 |
} |
| 29 |
|
| 30 |
protected function init_hooks(): void { |
| 31 |
// Registers admin_menu (Settings submenu) + wp_head (custom CSS) — both hooks |
| 32 |
// fire after plugins_loaded, so boot-time registration is timing-identical to |
| 33 |
// the old Plugin-constructor instantiation. |
| 34 |
Settings::get_instance(); |
| 35 |
|
| 36 |
// Core's Admin::scripts() localizes window.templately; the module contributes |
| 37 |
// its per-user pref through the existing filter seam (core never imports us). |
| 38 |
add_filter( 'templately_admin_localized_data', function ( $data ) { |
| 39 |
$data['editor_default_tab'] = Preferences::get_editor_default_tab(); |
| 40 |
|
| 41 |
return $data; |
| 42 |
} ); |
| 43 |
} |
| 44 |
|
| 45 |
public function register_rest_routes(): void { |
| 46 |
SettingsEndpoint::get_instance()->register_routes(); |
| 47 |
PreferencesEndpoint::get_instance()->register_routes(); |
| 48 |
} |
| 49 |
} |
| 50 |
|