58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace RomhackPlaza\Extenders\Admin\Pages;
|
||
|
|
use RomhackPlaza\Format;
|
||
|
|
use RomhackPlaza\Script;
|
||
|
|
use RomhackPlaza\Script_Type;
|
||
|
|
use Timber\Timber;
|
||
|
|
|
||
|
|
defined( 'ABSPATH' ) || exit;
|
||
|
|
|
||
|
|
class Admin_Scripts extends Abstract_Page {
|
||
|
|
|
||
|
|
public function __construct() {
|
||
|
|
|
||
|
|
parent::__construct(
|
||
|
|
__( 'Admin Scripts', 'romhackplaza' ),
|
||
|
|
__( 'Admin Scripts', 'romhackplaza' ),
|
||
|
|
'romhackplaza-admin-scripts',
|
||
|
|
'manage_options',
|
||
|
|
'tools.php'
|
||
|
|
);
|
||
|
|
|
||
|
|
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
|
||
|
|
}
|
||
|
|
|
||
|
|
public function enqueue_scripts( $hook ) {
|
||
|
|
|
||
|
|
if( $hook !== 'tools_page_' . $this->page_slug )
|
||
|
|
return;
|
||
|
|
|
||
|
|
new Script(
|
||
|
|
Script_Type::JS,
|
||
|
|
'romhackplaza-admin-scripts',
|
||
|
|
ROMHACKPLAZA_PLUGIN_URI . '/assets/js/admin/admin-scripts.js',
|
||
|
|
[],
|
||
|
|
'20260105',
|
||
|
|
args: [ 'defer' => true, 'in_footer' => true ]
|
||
|
|
)
|
||
|
|
->enqueue()
|
||
|
|
->add_localize(
|
||
|
|
'_romhackplaza_admin_scripts',
|
||
|
|
[
|
||
|
|
'execute_url' => admin_url( 'admin-ajax.php' ),
|
||
|
|
'execute_nonce' => wp_create_nonce( Format::format_nonce_name( 'load_admin_script' ) )
|
||
|
|
]
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function content( mixed $data = [] ): void {
|
||
|
|
|
||
|
|
$context = Timber::context();
|
||
|
|
$context['scripts'] = \RomhackPlaza\Extenders\Admin_Scripts::get_scripts();
|
||
|
|
|
||
|
|
Timber::render( '@plugin/admin/pages/admin-scripts.twig', $context );
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|