modal on the Plugins screen. * * @package Zero_Blocks_Given * * Adds a "Settings" action link next to Zero Blocks Given on the Plugins screen. * Clicking it opens a native with radio buttons for the five tiers. * Saves via admin-post.php with nonce + capability gate. * * The settings option (`zeroblg_mode`) sits BELOW the constant in the * resolution chain — `ZEROBLG_MODE` in wp-config.php still wins. When * the constant is defined, the dialog renders the radios as disabled with * a notice explaining the override. */ if ( ! defined( 'ABSPATH' ) ) { exit; } const ZEROBLG_OPTION = 'zeroblg_mode'; const ZEROBLG_NONCE = 'zeroblg_save_mode'; const ZEROBLG_ACTION = 'zeroblg_save_mode'; /** * Bootstrap the admin settings UI. * * Hooks the action link, footer dialog, and POST handler. * * @return void */ function zeroblg_register_admin_settings(): void { $basename = plugin_basename( ZEROBLG_PLUGIN_FILE ); add_filter( "plugin_action_links_{$basename}", 'zeroblg_action_links' ); add_action( 'admin_footer-plugins.php', 'zeroblg_render_dialog' ); add_action( 'admin_enqueue_scripts', 'zeroblg_admin_enqueue' ); add_action( 'admin_post_' . ZEROBLG_ACTION, 'zeroblg_handle_save' ); add_action( 'admin_notices', 'zeroblg_maybe_show_saved_notice' ); } /** * Add "Settings" link to the plugin row on Plugins screen. * * @param array $links Existing action links. * @return array Modified links. */ function zeroblg_action_links( array $links ): array { $button = sprintf( '%s', esc_html__( 'Settings', 'zero-blocks-given' ) ); array_unshift( $links, $button ); return $links; } /** * Render the modal in the Plugins screen footer. * * @return void */ function zeroblg_render_dialog(): void { if ( ! current_user_can( 'manage_options' ) ) { return; } $current = zeroblg_get_effective_mode(); $constant_set = defined( 'ZEROBLG_MODE' ); $tiers = array( 'patterns' => __( 'Kill the BlockPatterns directory scanner. Block UI stays intact.', 'zero-blocks-given' ), 'blocks' => __( 'Above + WC BlockTypesController + Notices + wc-blocks-style handle.', 'zero-blocks-given' ), 'keep-styles' => __( 'Above + Product Filter pattern scan. Keeps global-styles + core block rendering. Pixel-perfect.', 'zero-blocks-given' ), 'all' => __( 'Above + WP global-styles pipeline + theme.json + font-faces + head