# desktop-mode/1.1.8/includes/widgets/widget-focus-timer.php

OpenStation: Desktop Windows, Dock &amp; Virtual Desktops for WP Admin, version 1.1.8. 91 lines.

- Page: https://pluginprobe.com/plugins/desktop-mode/1.1.8/code/includes/widgets/widget-focus-timer.php
- Raw: https://pluginprobe.com/plugins/desktop-mode/1.1.8/raw/includes/widgets/widget-focus-timer.php
- Modified: 2026-08-07T20:39:04+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/desktop-mode/1.1.8/code/includes/widgets/widget-focus-timer.php#L10-L20`.

```php
<?php
/**
 * OpenStation — Focus Timer widget PHP registration.
 *
 * Registers the widget's JS bundle + CSS, enqueues the CSS eagerly on
 * shell pages, and announces the widget to OpenStation so it appears in
 * the widget picker. All behaviour lives in the JS
 * (src/plugins/focus-timer-widget/); this file only declares the widget.
 *
 * The timer runs entirely in the browser — no REST routes, no server
 * state, no external services — so the script declares no dependencies.
 *
 * @package OpenStation
 */

defined( 'ABSPATH' ) || exit;

/**
 * Register the Focus Timer widget's script + style handles.
 *
 * @return void
 */
function openstation_register_focus_timer_widget_assets() {
	$suffix  = openstation_asset_suffix();
	$version = defined( 'OPENSTATION_VERSION' ) ? OPENSTATION_VERSION : '0';

	$js_path  = OPENSTATION_DIR . 'assets/js/widget-focus-timer' . $suffix . '.js';
	$css_path = OPENSTATION_DIR . 'assets/js/widget-focus-timer' . $suffix . '.css';

	wp_register_style(
		'os-focus-timer-widget',
		OPENSTATION_URL . 'assets/js/widget-focus-timer' . $suffix . '.css',
		array(),
		file_exists( $css_path ) ? (string) filemtime( $css_path ) : $version
	);

	wp_register_script(
		'os-focus-timer-widget',
		OPENSTATION_URL . 'assets/js/widget-focus-timer' . $suffix . '.js',
		array(),
		file_exists( $js_path ) ? (string) filemtime( $js_path ) : $version,
		true
	);
}
add_action( 'init', 'openstation_register_focus_timer_widget_assets', 5 );

/**
 * Eagerly enqueue the CSS on OpenStation shell pages (avoids a flash of
 * unstyled content before the lazy JS mounts).
 *
 * @return void
 */
function openstation_enqueue_focus_timer_widget_styles() {
	if ( function_exists( 'openstation_is_enabled' ) && ! openstation_is_enabled() ) {
		return;
	}
	if ( function_exists( 'openstation_is_chromeless_request' ) && openstation_is_chromeless_request() ) {
		return;
	}
	wp_enqueue_style( 'os-focus-timer-widget' );
}
add_action( 'admin_enqueue_scripts', 'openstation_enqueue_focus_timer_widget_styles', 20 );

/**
 * Announce the widget to OpenStation.
 *
 * @return void
 */
function openstation_register_focus_timer_widget() {
	if ( ! function_exists( 'openstation_register_widget' ) ) {
		return;
	}

	openstation_register_widget(
		'desktop-mode/focus-timer',
		array(
			'label'          => __( 'Focus Timer', 'desktop-mode' ),
			'description'    => __( 'A focus countdown. Link it to a window and get a shake + alarm when time is up.', 'desktop-mode' ),
			'icon'           => 'dashicons-clock',
			'script'         => 'os-focus-timer-widget',
			'movable'        => true,
			'resizable'      => true,
			'min_width'      => 240,
			'min_height'     => 200,
			'default_width'  => 300,
			'default_height' => 300,
		)
	);
}
add_action( 'init', 'openstation_register_focus_timer_widget', 6 );

```
