| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Desktop Mode — Desktop-theme wallpapers. | |
| 3 | + * OpenStation — Desktop-theme wallpapers. | |
| 4 | 4 | * |
| 5 | 5 | * A theme may declare any number of wallpapers in its manifest. Each |
| 6 | 6 | * is published into the ordinary wallpaper registry as a pickable |
| 7 | 7 | * entry labelled `<name> - (theme)`, alongside the built-in gradients |
| @@ -25,9 +25,9 @@ | ||
| 25 | 25 | * Note this is separate from the `DESKTOP` texture slot. That slot |
| 26 | 26 | * layers over whatever wallpaper is active and follows the theme; |
| 27 | 27 | * this is a wallpaper in its own right that the user selects. |
| 28 | 28 | * |
| 29 | - * @package WPDesktopMode | |
| 29 | + * @package OpenStation | |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | 32 | defined( 'ABSPATH' ) || exit; |
| 33 | 33 | |
| @@ -36,9 +36,9 @@ | ||
| 36 | 36 | * |
| 37 | 37 | * Namespaced so a theme's wallpaper can never collide with a |
| 38 | 38 | * built-in or with a plugin's own registration. |
| 39 | 39 | */ |
| 40 | -const DESKTOP_MODE_DESKTOP_THEME_WALLPAPER_PREFIX = 'desktop-theme/'; | |
| 40 | +const OPENSTATION_DESKTOP_THEME_WALLPAPER_PREFIX = 'desktop-theme/'; | |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Build the CSS `background` value for a theme's wallpaper. |
| 44 | 44 | * |
| @@ -53,19 +53,19 @@ | ||
| 53 | 53 | * whose paths are absolute already). |
| 54 | 54 | * @param string $version Cache-buster for relative paths. |
| 55 | 55 | * @return string CSS value, or `''` when unusable. |
| 56 | 56 | */ |
| 57 | -function desktop_mode_desktop_theme_wallpaper_css( $wallpaper, $base_url = '', $version = '' ) { | |
| 57 | +function openstation_desktop_theme_wallpaper_css( $wallpaper, $base_url = '', $version = '' ) { | |
| 58 | 58 | if ( ! is_array( $wallpaper ) || empty( $wallpaper['path'] ) ) { |
| 59 | 59 | return ''; |
| 60 | 60 | } |
| 61 | - $url = desktop_mode_desktop_theme_asset_url( $wallpaper['path'], $base_url, $version ); | |
| 61 | + $url = openstation_desktop_theme_asset_url( $wallpaper['path'], $base_url, $version ); | |
| 62 | 62 | if ( '' === $url ) { |
| 63 | 63 | return ''; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // `<image> <position> / <size> <repeat>` — a background shorthand, |
| 67 | - // which is what `--desktop-mode-bg` is assigned to. Defaults cover | |
| 67 | + // which is what `--os-bg` is assigned to. Defaults cover | |
| 68 | 68 | // the overwhelmingly common case (a photo filling the desk); the |
| 69 | 69 | // manifest can override each part through the same grammar the |
| 70 | 70 | // texture slots use. |
| 71 | 71 | $position = ! empty( $wallpaper['position'] ) ? (string) $wallpaper['position'] : 'center center'; |
| @@ -71,9 +71,9 @@ | ||
| 71 | 71 | $position = ! empty( $wallpaper['position'] ) ? (string) $wallpaper['position'] : 'center center'; |
| 72 | 72 | $size = ! empty( $wallpaper['size'] ) ? (string) $wallpaper['size'] : 'cover'; |
| 73 | 73 | $repeat = ! empty( $wallpaper['repeat'] ) ? (string) $wallpaper['repeat'] : 'no-repeat'; |
| 74 | 74 | |
| 75 | - return desktop_mode_desktop_theme_css_url( $url ) . ' ' . $position . ' / ' . $size . ' ' . $repeat; | |
| 75 | + return openstation_desktop_theme_css_url( $url ) . ' ' . $position . ' / ' . $size . ' ' . $repeat; | |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * Picker label for a theme's wallpaper. |
| @@ -79,9 +79,9 @@ | ||
| 79 | 79 | * Picker label for a theme's wallpaper. |
| 80 | 80 | * |
| 81 | 81 | * The theme `name` reaching this function has already been through |
| 82 | 82 | * `sanitize_text_field()` in the manifest sanitizer, and |
| 83 | - * `desktop_mode_register_wallpaper()` sanitizes the finished label | |
| 83 | + * `openstation_register_wallpaper()` sanitizes the finished label | |
| 84 | 84 | * again on the way into the registry. Both are belt-and-braces: the |
| 85 | 85 | * shell paints wallpaper labels through the `html` tagged template, |
| 86 | 86 | * whose text slots are built with `createTextNode()`, so a label is |
| 87 | 87 | * never parsed as markup. |
| @@ -90,9 +90,9 @@ | ||
| 90 | 90 | * @param string $slug Theme slug. |
| 91 | 91 | * @param string $own_label The wallpaper's own label, or `''`. |
| 92 | 92 | * @return string |
| 93 | 93 | */ |
| 94 | -function desktop_mode_desktop_theme_wallpaper_label( $name, $slug, $own_label = '' ) { | |
| 94 | +function openstation_desktop_theme_wallpaper_label( $name, $slug, $own_label = '' ) { | |
| 95 | 95 | $own_label = (string) $own_label; |
| 96 | 96 | if ( '' === $own_label ) { |
| 97 | 97 | $label = sprintf( |
| 98 | 98 | /* translators: %s: desktop theme name. Marks a wallpaper that came from a theme. */ |
| @@ -117,9 +117,9 @@ | ||
| 117 | 117 | * @param string $slug Theme slug. |
| 118 | 118 | * @param string $own_label The wallpaper's own label, or `''`. |
| 119 | 119 | */ |
| 120 | 120 | return (string) apply_filters( |
| 121 | - 'desktop_mode_desktop_theme_wallpaper_label', | |
| 121 | + 'openstation_desktop_theme_wallpaper_label', | |
| 122 | 122 | $label, |
| 123 | 123 | $name, |
| 124 | 124 | $slug, |
| 125 | 125 | $own_label |
| @@ -139,21 +139,21 @@ | ||
| 139 | 139 | * you are wearing the theme it came from. |
| 140 | 140 | * |
| 141 | 141 | * @return void |
| 142 | 142 | */ |
| 143 | -function desktop_mode_register_desktop_theme_wallpapers() { | |
| 143 | +function openstation_register_desktop_theme_wallpapers() { | |
| 144 | 144 | $sources = array(); |
| 145 | 145 | |
| 146 | - foreach ( desktop_mode_desktop_theme_registry() as $slug => $entry ) { | |
| 146 | + foreach ( openstation_desktop_theme_registry() as $slug => $entry ) { | |
| 147 | 147 | $sources[ $slug ] = array( $entry, '', '' ); |
| 148 | 148 | } |
| 149 | 149 | // Uploaded themes win on a slug collision, matching the payload |
| 150 | 150 | // builder's precedence. |
| 151 | - foreach ( desktop_mode_desktop_themes_index() as $slug => $entry ) { | |
| 152 | - $installed_at = isset( $entry['installedAt'] ) ? (int) $entry['installedAt'] : 0; | |
| 151 | + foreach ( openstation_desktop_themes_index() as $slug => $entry ) { | |
| 152 | + $installed_at = isset( $entry['installedAt'] ) ? (int) $entry['installedAt'] : 0; | |
| 153 | 153 | $sources[ $slug ] = array( |
| 154 | 154 | $entry, |
| 155 | - desktop_mode_desktop_themes_url( $slug ), | |
| 155 | + openstation_desktop_themes_url( $slug ), | |
| 156 | 156 | $installed_at > 0 ? (string) $installed_at : '', |
| 157 | 157 | ); |
| 158 | 158 | } |
| 159 | 159 | |
| @@ -168,9 +168,9 @@ | ||
| 168 | 168 | } |
| 169 | 169 | $name = isset( $manifest['name'] ) ? (string) $manifest['name'] : $slug; |
| 170 | 170 | |
| 171 | 171 | foreach ( $manifest['wallpapers'] as $wallpaper ) { |
| 172 | - $value = desktop_mode_desktop_theme_wallpaper_css( $wallpaper, $base_url, $version ); | |
| 172 | + $value = openstation_desktop_theme_wallpaper_css( $wallpaper, $base_url, $version ); | |
| 173 | 173 | if ( '' === $value ) { |
| 174 | 174 | continue; |
| 175 | 175 | } |
| 176 | 176 | // `<theme-slug>/<wallpaper-id>` — the wallpaper id is |
| @@ -175,14 +175,14 @@ | ||
| 175 | 175 | } |
| 176 | 176 | // `<theme-slug>/<wallpaper-id>` — the wallpaper id is |
| 177 | 177 | // derived from something stable (see the sanitizer), so a |
| 178 | 178 | // user's stored selection survives a re-upload. |
| 179 | - $id = DESKTOP_MODE_DESKTOP_THEME_WALLPAPER_PREFIX . $slug . '/' . $wallpaper['id']; | |
| 179 | + $id = OPENSTATION_DESKTOP_THEME_WALLPAPER_PREFIX . $slug . '/' . $wallpaper['id']; | |
| 180 | 180 | |
| 181 | - desktop_mode_register_wallpaper( | |
| 181 | + openstation_register_wallpaper( | |
| 182 | 182 | $id, |
| 183 | 183 | array( |
| 184 | - 'label' => desktop_mode_desktop_theme_wallpaper_label( | |
| 184 | + 'label' => openstation_desktop_theme_wallpaper_label( | |
| 185 | 185 | $name, |
| 186 | 186 | $slug, |
| 187 | 187 | isset( $wallpaper['label'] ) ? (string) $wallpaper['label'] : '' |
| 188 | 188 | ), |
| @@ -200,5 +200,5 @@ | ||
| 200 | 200 | ); |
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | -add_action( 'init', 'desktop_mode_register_desktop_theme_wallpapers', 20 ); | |
| 204 | +add_action( 'init', 'openstation_register_desktop_theme_wallpapers', 20 ); | |