| @@ -1,15 +1,15 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Desktop Mode — Jazz Quote Widget. | |
| 3 | + * OpenStation — Jazz Quote Widget. | |
| 4 | 4 | * |
| 5 | 5 | * A love letter to WordPress's jazz musician release naming tradition. |
| 6 | 6 | * Shows the current WP version, its jazz musician codename, and a |
| 7 | 7 | * rotating daily quote from that musician. |
| 8 | 8 | * |
| 9 | - * Requires: Desktop Mode 0.18.0+ (desktop_mode_register_widget). | |
| 9 | + * Requires: OpenStation 0.18.0+ (openstation_register_widget). | |
| 10 | 10 | * |
| 11 | - * @package WPDesktopMode | |
| 11 | + * @package OpenStation | |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | defined( 'ABSPATH' ) || exit; |
| 15 | 15 | |
| @@ -15,91 +15,91 @@ | ||
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Register JS + CSS assets. |
| 18 | 18 | */ |
| 19 | -function desktop_mode_register_jazz_quote_widget_assets() { | |
| 20 | - $suffix = desktop_mode_asset_suffix(); | |
| 21 | - $version = defined( 'DESKTOP_MODE_VERSION' ) ? DESKTOP_MODE_VERSION : '0'; | |
| 19 | +function openstation_register_jazz_quote_widget_assets() { | |
| 20 | + $suffix = openstation_asset_suffix(); | |
| 21 | + $version = defined( 'OPENSTATION_VERSION' ) ? OPENSTATION_VERSION : '0'; | |
| 22 | 22 | |
| 23 | - $js_path = DESKTOP_MODE_DIR . 'assets/js/widget-jazz-quote' . $suffix . '.js'; | |
| 24 | - $css_path = DESKTOP_MODE_DIR . 'assets/js/widget-jazz-quote' . $suffix . '.css'; | |
| 23 | + $js_path = OPENSTATION_DIR . 'assets/js/widget-jazz-quote' . $suffix . '.js'; | |
| 24 | + $css_path = OPENSTATION_DIR . 'assets/js/widget-jazz-quote' . $suffix . '.css'; | |
| 25 | 25 | |
| 26 | 26 | wp_register_style( |
| 27 | - 'desktop-mode-jazz-quote-widget', | |
| 28 | - DESKTOP_MODE_URL . 'assets/js/widget-jazz-quote' . $suffix . '.css', | |
| 27 | + 'os-jazz-quote-widget', | |
| 28 | + OPENSTATION_URL . 'assets/js/widget-jazz-quote' . $suffix . '.css', | |
| 29 | 29 | array(), |
| 30 | 30 | file_exists( $css_path ) ? (string) filemtime( $css_path ) : $version |
| 31 | 31 | ); |
| 32 | 32 | |
| 33 | 33 | wp_register_script( |
| 34 | - 'desktop-mode-jazz-quote-widget', | |
| 35 | - DESKTOP_MODE_URL . 'assets/js/widget-jazz-quote' . $suffix . '.js', | |
| 34 | + 'os-jazz-quote-widget', | |
| 35 | + OPENSTATION_URL . 'assets/js/widget-jazz-quote' . $suffix . '.js', | |
| 36 | 36 | array(), |
| 37 | 37 | file_exists( $js_path ) ? (string) filemtime( $js_path ) : $version, |
| 38 | 38 | true |
| 39 | 39 | ); |
| 40 | 40 | } |
| 41 | -add_action( 'init', 'desktop_mode_register_jazz_quote_widget_assets', 5 ); | |
| 41 | +add_action( 'init', 'openstation_register_jazz_quote_widget_assets', 5 ); | |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * Inline the WordPress version on the MAIN desktop shell script. |
| 45 | 45 | * |
| 46 | - * wp_add_inline_script() only outputs when the attached handle is | |
| 46 | + * Note that wp_add_inline_script() only outputs when the attached handle is | |
| 47 | 47 | * actually enqueued. The widget JS loads lazily via the shell's |
| 48 | 48 | * server-sync, so attaching the inline script to the widget handle |
| 49 | 49 | * would mean it never appears. Instead we attach it to the main |
| 50 | 50 | * desktop handle which is always enqueued on shell pages. |
| 51 | 51 | * |
| 52 | - * window.desktopModeJazzQuote is therefore available from page load, | |
| 52 | + * window.openStationJazzQuote is therefore available from page load, | |
| 53 | 53 | * before the widget bundle is ever fetched. |
| 54 | 54 | */ |
| 55 | -function desktop_mode_jazz_quote_inline_version() { | |
| 56 | - if ( ! desktop_mode_is_enabled() ) { | |
| 55 | +function openstation_jazz_quote_inline_version() { | |
| 56 | + if ( ! openstation_is_enabled() ) { | |
| 57 | 57 | return; |
| 58 | 58 | } |
| 59 | - if ( desktop_mode_is_chromeless_request() ) { | |
| 59 | + if ( openstation_is_chromeless_request() ) { | |
| 60 | 60 | return; |
| 61 | 61 | } |
| 62 | 62 | $main_handle = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) |
| 63 | - ? 'desktop-mode' | |
| 64 | - : 'desktop-mode'; | |
| 63 | + ? 'openstation' | |
| 64 | + : 'openstation'; | |
| 65 | 65 | |
| 66 | 66 | wp_add_inline_script( |
| 67 | 67 | $main_handle, |
| 68 | - 'window.desktopModeJazzQuote = { wpVersion: ' . wp_json_encode( get_bloginfo( 'version' ) ) . ' };', | |
| 68 | + 'window.openStationJazzQuote = { wpVersion: ' . wp_json_encode( get_bloginfo( 'version' ) ) . ' };', | |
| 69 | 69 | 'before' |
| 70 | 70 | ); |
| 71 | 71 | } |
| 72 | -add_action( 'admin_enqueue_scripts', 'desktop_mode_jazz_quote_inline_version', 15 ); | |
| 72 | +add_action( 'admin_enqueue_scripts', 'openstation_jazz_quote_inline_version', 15 ); | |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * Eagerly enqueue the CSS on shell pages. |
| 76 | 76 | */ |
| 77 | -function desktop_mode_enqueue_jazz_quote_widget_styles() { | |
| 78 | - if ( function_exists( 'desktop_mode_is_enabled' ) && ! desktop_mode_is_enabled() ) { | |
| 77 | +function openstation_enqueue_jazz_quote_widget_styles() { | |
| 78 | + if ( function_exists( 'openstation_is_enabled' ) && ! openstation_is_enabled() ) { | |
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | - if ( function_exists( 'desktop_mode_is_chromeless_request' ) && desktop_mode_is_chromeless_request() ) { | |
| 81 | + if ( function_exists( 'openstation_is_chromeless_request' ) && openstation_is_chromeless_request() ) { | |
| 82 | 82 | return; |
| 83 | 83 | } |
| 84 | - wp_enqueue_style( 'desktop-mode-jazz-quote-widget' ); | |
| 84 | + wp_enqueue_style( 'os-jazz-quote-widget' ); | |
| 85 | 85 | } |
| 86 | -add_action( 'admin_enqueue_scripts', 'desktop_mode_enqueue_jazz_quote_widget_styles', 20 ); | |
| 86 | +add_action( 'admin_enqueue_scripts', 'openstation_enqueue_jazz_quote_widget_styles', 20 ); | |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Register the widget definition. |
| 90 | 90 | */ |
| 91 | -function desktop_mode_register_jazz_quote_widget() { | |
| 92 | - if ( ! function_exists( 'desktop_mode_register_widget' ) ) { | |
| 91 | +function openstation_register_jazz_quote_widget() { | |
| 92 | + if ( ! function_exists( 'openstation_register_widget' ) ) { | |
| 93 | 93 | return; |
| 94 | 94 | } |
| 95 | - desktop_mode_register_widget( | |
| 95 | + openstation_register_widget( | |
| 96 | 96 | 'desktop-mode/jazz-quote', |
| 97 | 97 | array( |
| 98 | 98 | 'label' => __( 'Jazz Quote', 'desktop-mode' ), |
| 99 | 99 | 'description' => __( 'A daily quote from the jazz musician behind your WordPress version.', 'desktop-mode' ), |
| 100 | 100 | 'icon' => 'dashicons-format-audio', |
| 101 | - 'script' => 'desktop-mode-jazz-quote-widget', | |
| 101 | + 'script' => 'os-jazz-quote-widget', | |
| 102 | 102 | 'movable' => true, |
| 103 | 103 | 'resizable' => true, |
| 104 | 104 | 'min_width' => 220, |
| 105 | 105 | 'min_height' => 160, |
| @@ -107,5 +107,5 @@ | ||
| 107 | 107 | 'default_height' => 220, |
| 108 | 108 | ) |
| 109 | 109 | ); |
| 110 | 110 | } |
| 111 | -add_action( 'init', 'desktop_mode_register_jazz_quote_widget', 6 ); | |
| 111 | +add_action( 'init', 'openstation_register_jazz_quote_widget', 6 ); | |