enqueue_global_css(); } } /** Forms → Global Styles. */ public static function menu() { $hook = add_submenu_page( Admin::MENU_SLUG, __( 'Global Styles', 'fieldwren' ), __( 'Global Styles', 'fieldwren' ), 'manage_options', self::SLUG, array( __CLASS__, 'page' ) ); add_action( 'load-' . $hook, static function () { add_action( 'admin_enqueue_scripts', static function () { // The framework's kit app only loads on its own page hook; hand it that hook. Kit::instance()->admin_assets( 'toplevel_page_' . Kit::MENU_SLUG ); wp_enqueue_style( 'fwren-admin', FWREN_URL . 'assets/admin/admin.css', array(), FWREN_VERSION ); } ); } ); } /** The framework registers its own top-level "Fieldwren Blocks" menu; forms don't need it. */ public static function remove_framework_menu() { remove_menu_page( Kit::MENU_SLUG ); } /** Page. */ public static function page() { Admin_Dashboard::open( 'styles', __( 'Global styles', 'fieldwren' ) ); echo '
' . esc_html__( 'Colours and typography presets every form block can use: the globe button on colour controls and the "Preset" field on typography controls in the form editor. Change a preset here and every form that uses it updates.', 'fieldwren' ) . '
'; Kit::instance()->render_page(); Admin_Dashboard::close(); } /** * First run (kit never saved): start from the Webangon Block kit when that plugin has * one, so forms match the site; otherwise from a curated forms palette. Saved choices are * never overwritten. */ public static function seed_from_block_kit() { if ( false !== get_option( Kit::OPTION ) ) { return; } $block_kit = get_option( 'wab_bc_kit' ); if ( is_array( $block_kit ) && ( ! empty( $block_kit['colors'] ) || ! empty( $block_kit['typography'] ) ) ) { Kit::instance()->save( $block_kit ); return; } Kit::instance()->save( self::curated() ); } /** @return array Default forms kit: indigo / slate palette, Plus Jakarta Sans + Inter. */ public static function curated() { $kit = Kit::get_defaults(); $typo = static function ( $id, $title, $family, $weight, $min, $max, $lh, $spacing = '' ) { return array( 'id' => $id, 'title' => $title, 'font_family' => $family, 'font_weight' => $weight, 'text_transform' => '', 'font_style' => '', 'text_decoration' => '', 'line_height' => array( 'size' => $lh, 'unit' => 'em' ), 'line_height_min' => '', 'letter_spacing' => array( 'size' => $spacing, 'unit' => 'px' ), 'size_min' => $min, 'size_max' => $max, ); }; $kit['colors'] = array( array( 'id' => 'primary', 'title' => 'Primary', 'color' => '#4F46E5' ), array( 'id' => 'secondary', 'title' => 'Secondary', 'color' => '#0F172A' ), array( 'id' => 'text', 'title' => 'Text', 'color' => '#64748B' ), array( 'id' => 'accent', 'title' => 'Accent', 'color' => '#0EA5E9' ), ); $kit['typography'] = array( $typo( 'primary', 'Primary', 'Plus Jakarta Sans', '700', 24, 34, 1.2, -0.2 ), $typo( 'secondary', 'Secondary', 'Plus Jakarta Sans', '600', 14, 15, 1.4 ), $typo( 'text', 'Text', 'Inter', '400', 15, 16, 1.6 ), $typo( 'accent', 'Accent', 'Plus Jakarta Sans', '600', 15, 16, 1.2, 0.1 ), ); return apply_filters( 'fwren/curated_kit', $kit ); } }