'array', 'sanitize_callback' => array( 'AccessKit_Sanitize', 'settings' ), 'default' => AccessKit_Defaults::get(), ) ); } /** * Enqueue admin assets — only on this plugin's settings screen. * * @param string $hook Current admin page hook. */ public function enqueue( $hook ) { if ( 'settings_page_' . self::PAGE_SLUG !== $hook ) { return; } wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_script( 'wp-color-picker' ); wp_enqueue_style( 'accesskit-admin', ACCESSKIT_PLUGIN_URL . 'admin/css/admin.css', array(), ACCESSKIT_VERSION ); // Inline JS to init color pickers + tabs + advanced toggle. wp_add_inline_script( 'wp-color-picker', $this->admin_js(), 'after' ); } /** * Inline admin JS — color pickers + tabs + advanced collapse. * * @return string */ private function admin_js() { return <<<'JS' jQuery(function($){ $('.ao-color-field').wpColorPicker(); // Tab switching. $('.ao-tabs a').on('click', function(e){ e.preventDefault(); var target = $(this).data('tab'); $('.ao-tabs a').removeClass('nav-tab-active'); $(this).addClass('nav-tab-active'); $('.ao-panel').hide(); $('#ao-panel-' + target).show(); try { window.localStorage.setItem('ao_active_tab', target); } catch(err) {} }); // Restore last active tab. try { var saved = window.localStorage.getItem('ao_active_tab'); if (saved && $('.ao-tabs a[data-tab="' + saved + '"]').length) { $('.ao-tabs a[data-tab="' + saved + '"]').trigger('click'); } } catch(err) {} }); JS; } /** * Render the settings page. */ public function render_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } $s = AccessKit_Defaults::settings(); ?>
|
|
|
|
|
|
|
|
|
|