| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Desktop Mode — Desktop-theme ZIP installer. | |
| 3 | + * OpenStation — Desktop-theme ZIP installer. | |
| 4 | 4 | * |
| 5 | 5 | * The pipeline, in order, with the staging directory cleaned up on |
| 6 | 6 | * every exit path: |
| 7 | 7 | * |
| @@ -19,9 +19,9 @@ | ||
| 19 | 19 | * 6. Move ONLY the manifest-referenced assets across. Anything the |
| 20 | 20 | * manifest never mentions never reaches the live directory. |
| 21 | 21 | * 7. Compile `theme.css`, write it, update the option index. |
| 22 | 22 | * |
| 23 | - * @package WPDesktopMode | |
| 23 | + * @package OpenStation | |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | 26 | defined( 'ABSPATH' ) || exit; |
| 27 | 27 | |
| @@ -36,11 +36,11 @@ | ||
| 36 | 36 | * |
| 37 | 37 | * @param string $dir Absolute path. |
| 38 | 38 | * @return bool |
| 39 | 39 | */ |
| 40 | -function desktop_mode_desktop_theme_rmdir( $dir ) { | |
| 40 | +function openstation_desktop_theme_rmdir( $dir ) { | |
| 41 | 41 | $dir = (string) $dir; |
| 42 | - $base = realpath( desktop_mode_desktop_themes_dir() ); | |
| 42 | + $base = realpath( openstation_desktop_themes_dir() ); | |
| 43 | 43 | $real = realpath( $dir ); |
| 44 | 44 | if ( false === $base || false === $real ) { |
| 45 | 45 | return false; |
| 46 | 46 | } |
| @@ -64,9 +64,9 @@ | ||
| 64 | 64 | continue; |
| 65 | 65 | } |
| 66 | 66 | $path = $real . '/' . $item; |
| 67 | 67 | if ( is_dir( $path ) && ! is_link( $path ) ) { |
| 68 | - desktop_mode_desktop_theme_rmdir( $path ); | |
| 68 | + openstation_desktop_theme_rmdir( $path ); | |
| 69 | 69 | } else { |
| 70 | 70 | wp_delete_file( $path ); |
| 71 | 71 | } |
| 72 | 72 | } |
| @@ -85,9 +85,9 @@ | ||
| 85 | 85 | * |
| 86 | 86 | * @param string $name Entry name. |
| 87 | 87 | * @return bool |
| 88 | 88 | */ |
| 89 | -function desktop_mode_desktop_theme_zip_entry_ignored( $name ) { | |
| 89 | +function openstation_desktop_theme_zip_entry_ignored( $name ) { | |
| 90 | 90 | if ( 0 === strpos( $name, '__MACOSX/' ) ) { |
| 91 | 91 | return true; |
| 92 | 92 | } |
| 93 | 93 | foreach ( explode( '/', $name ) as $segment ) { |
| @@ -108,12 +108,12 @@ | ||
| 108 | 108 | * @return string|WP_Error The manifest's entry name on success |
| 109 | 109 | * (root-level or one directory deep), |
| 110 | 110 | * `WP_Error` otherwise. |
| 111 | 111 | */ |
| 112 | -function desktop_mode_desktop_theme_validate_zip( $zip_path ) { | |
| 112 | +function openstation_desktop_theme_validate_zip( $zip_path ) { | |
| 113 | 113 | if ( ! class_exists( 'ZipArchive' ) ) { |
| 114 | 114 | return new WP_Error( |
| 115 | - 'desktop_mode_desktop_theme_no_zip_support', | |
| 115 | + 'openstation_desktop_theme_no_zip_support', | |
| 116 | 116 | __( 'This server has no ZipArchive support, so theme uploads are unavailable.', 'desktop-mode' ), |
| 117 | 117 | array( 'status' => 501 ) |
| 118 | 118 | ); |
| 119 | 119 | } |
| @@ -120,15 +120,15 @@ | ||
| 120 | 120 | |
| 121 | 121 | $zip = new ZipArchive(); |
| 122 | 122 | if ( true !== $zip->open( (string) $zip_path ) ) { |
| 123 | 123 | return new WP_Error( |
| 124 | - 'desktop_mode_desktop_theme_bad_zip', | |
| 124 | + 'openstation_desktop_theme_bad_zip', | |
| 125 | 125 | __( 'That file could not be read as a ZIP archive.', 'desktop-mode' ), |
| 126 | 126 | array( 'status' => 400 ) |
| 127 | 127 | ); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $caps = desktop_mode_desktop_theme_zip_caps(); | |
| 130 | + $caps = openstation_desktop_theme_zip_caps(); | |
| 131 | 131 | $extensions = array_flip( $caps['extensions'] ); |
| 132 | 132 | $total = 0; |
| 133 | 133 | $counted = 0; |
| 134 | 134 | $manifests = array(); |
| @@ -137,9 +137,9 @@ | ||
| 137 | 137 | $stat = $zip->statIndex( $i ); |
| 138 | 138 | if ( ! is_array( $stat ) || ! isset( $stat['name'] ) ) { |
| 139 | 139 | $zip->close(); |
| 140 | 140 | return new WP_Error( |
| 141 | - 'desktop_mode_desktop_theme_bad_zip', | |
| 141 | + 'openstation_desktop_theme_bad_zip', | |
| 142 | 142 | __( 'That archive contains an unreadable entry.', 'desktop-mode' ), |
| 143 | 143 | array( 'status' => 400 ) |
| 144 | 144 | ); |
| 145 | 145 | } |
| @@ -148,9 +148,9 @@ | ||
| 148 | 148 | // Hard rejects — these are attacks, not accidents. |
| 149 | 149 | if ( false !== strpos( $name, "\0" ) || false !== strpos( $name, '\\' ) ) { |
| 150 | 150 | $zip->close(); |
| 151 | 151 | return new WP_Error( |
| 152 | - 'desktop_mode_desktop_theme_unsafe_entry', | |
| 152 | + 'openstation_desktop_theme_unsafe_entry', | |
| 153 | 153 | __( 'That archive contains an unsafe file path.', 'desktop-mode' ), |
| 154 | 154 | array( 'status' => 400 ) |
| 155 | 155 | ); |
| 156 | 156 | } |
| @@ -156,9 +156,9 @@ | ||
| 156 | 156 | } |
| 157 | 157 | if ( '' !== $name && ( '/' === $name[0] || preg_match( '~^[a-zA-Z]:~', $name ) ) ) { |
| 158 | 158 | $zip->close(); |
| 159 | 159 | return new WP_Error( |
| 160 | - 'desktop_mode_desktop_theme_unsafe_entry', | |
| 160 | + 'openstation_desktop_theme_unsafe_entry', | |
| 161 | 161 | __( 'That archive contains an absolute file path.', 'desktop-mode' ), |
| 162 | 162 | array( 'status' => 400 ) |
| 163 | 163 | ); |
| 164 | 164 | } |
| @@ -165,9 +165,9 @@ | ||
| 165 | 165 | foreach ( explode( '/', $name ) as $segment ) { |
| 166 | 166 | if ( '..' === $segment ) { |
| 167 | 167 | $zip->close(); |
| 168 | 168 | return new WP_Error( |
| 169 | - 'desktop_mode_desktop_theme_unsafe_entry', | |
| 169 | + 'openstation_desktop_theme_unsafe_entry', | |
| 170 | 170 | __( 'That archive tries to write outside its own folder.', 'desktop-mode' ), |
| 171 | 171 | array( 'status' => 400 ) |
| 172 | 172 | ); |
| 173 | 173 | } |
| @@ -172,9 +172,9 @@ | ||
| 172 | 172 | ); |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if ( desktop_mode_desktop_theme_zip_entry_ignored( $name ) ) { | |
| 176 | + if ( openstation_desktop_theme_zip_entry_ignored( $name ) ) { | |
| 177 | 177 | continue; |
| 178 | 178 | } |
| 179 | 179 | // Directory entry. |
| 180 | 180 | if ( '' === $name || '/' === substr( $name, -1 ) ) { |
| @@ -184,9 +184,9 @@ | ||
| 184 | 184 | ++$counted; |
| 185 | 185 | if ( $counted > $caps['max_entries'] ) { |
| 186 | 186 | $zip->close(); |
| 187 | 187 | return new WP_Error( |
| 188 | - 'desktop_mode_desktop_theme_too_many_entries', | |
| 188 | + 'openstation_desktop_theme_too_many_entries', | |
| 189 | 189 | __( 'That theme archive contains too many files.', 'desktop-mode' ), |
| 190 | 190 | array( 'status' => 400 ) |
| 191 | 191 | ); |
| 192 | 192 | } |
| @@ -194,9 +194,9 @@ | ||
| 194 | 194 | $size = isset( $stat['size'] ) ? (int) $stat['size'] : 0; |
| 195 | 195 | if ( $size > $caps['max_file'] ) { |
| 196 | 196 | $zip->close(); |
| 197 | 197 | return new WP_Error( |
| 198 | - 'desktop_mode_desktop_theme_entry_too_large', | |
| 198 | + 'openstation_desktop_theme_entry_too_large', | |
| 199 | 199 | sprintf( |
| 200 | 200 | /* translators: %s: file name inside the archive. */ |
| 201 | 201 | __( '"%s" is larger than a theme asset is allowed to be.', 'desktop-mode' ), |
| 202 | 202 | $name |
| @@ -207,9 +207,9 @@ | ||
| 207 | 207 | $total += $size; |
| 208 | 208 | if ( $total > $caps['max_uncompressed'] ) { |
| 209 | 209 | $zip->close(); |
| 210 | 210 | return new WP_Error( |
| 211 | - 'desktop_mode_desktop_theme_archive_too_large', | |
| 211 | + 'openstation_desktop_theme_archive_too_large', | |
| 212 | 212 | __( 'That theme archive unpacks to more data than is allowed.', 'desktop-mode' ), |
| 213 | 213 | array( 'status' => 400 ) |
| 214 | 214 | ); |
| 215 | 215 | } |
| @@ -217,9 +217,9 @@ | ||
| 217 | 217 | $ext = strtolower( (string) pathinfo( $name, PATHINFO_EXTENSION ) ); |
| 218 | 218 | if ( ! isset( $extensions[ $ext ] ) ) { |
| 219 | 219 | $zip->close(); |
| 220 | 220 | return new WP_Error( |
| 221 | - 'desktop_mode_desktop_theme_bad_extension', | |
| 221 | + 'openstation_desktop_theme_bad_extension', | |
| 222 | 222 | sprintf( |
| 223 | 223 | /* translators: %s: file name inside the archive. */ |
| 224 | 224 | __( '"%s" is not a file type a desktop theme may contain.', 'desktop-mode' ), |
| 225 | 225 | $name |
| @@ -241,9 +241,9 @@ | ||
| 241 | 241 | $zip->close(); |
| 242 | 242 | |
| 243 | 243 | if ( 1 !== count( $manifests ) ) { |
| 244 | 244 | return new WP_Error( |
| 245 | - 'desktop_mode_desktop_theme_missing_manifest', | |
| 245 | + 'openstation_desktop_theme_missing_manifest', | |
| 246 | 246 | __( 'A theme archive must contain exactly one theme.json, at its root or in a single top-level folder.', 'desktop-mode' ), |
| 247 | 247 | array( 'status' => 400 ) |
| 248 | 248 | ); |
| 249 | 249 | } |
| @@ -265,12 +265,12 @@ | ||
| 265 | 265 | * |
| 266 | 266 | * @param string $file Absolute path of the SVG. |
| 267 | 267 | * @return true|WP_Error |
| 268 | 268 | */ |
| 269 | -function desktop_mode_desktop_theme_sanitize_svg( $file ) { | |
| 269 | +function openstation_desktop_theme_sanitize_svg( $file ) { | |
| 270 | 270 | if ( ! class_exists( 'DOMDocument' ) ) { |
| 271 | 271 | return new WP_Error( |
| 272 | - 'desktop_mode_desktop_theme_no_dom', | |
| 272 | + 'openstation_desktop_theme_no_dom', | |
| 273 | 273 | __( 'This server cannot sanitize SVG files, so SVG icons are not accepted here.', 'desktop-mode' ), |
| 274 | 274 | array( 'status' => 501 ) |
| 275 | 275 | ); |
| 276 | 276 | } |
| @@ -278,9 +278,9 @@ | ||
| 278 | 278 | // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents |
| 279 | 279 | $markup = (string) file_get_contents( $file ); |
| 280 | 280 | if ( '' === trim( $markup ) ) { |
| 281 | 281 | return new WP_Error( |
| 282 | - 'desktop_mode_desktop_theme_bad_svg', | |
| 282 | + 'openstation_desktop_theme_bad_svg', | |
| 283 | 283 | __( 'An SVG in that theme is empty.', 'desktop-mode' ), |
| 284 | 284 | array( 'status' => 400 ) |
| 285 | 285 | ); |
| 286 | 286 | } |
| @@ -287,9 +287,9 @@ | ||
| 287 | 287 | // Refuse doctype / entity declarations before the parser ever |
| 288 | 288 | // sees them — cheapest possible XXE and billion-laughs defence. |
| 289 | 289 | if ( preg_match( '/<!DOCTYPE|<!ENTITY/i', $markup ) ) { |
| 290 | 290 | return new WP_Error( |
| 291 | - 'desktop_mode_desktop_theme_bad_svg', | |
| 291 | + 'openstation_desktop_theme_bad_svg', | |
| 292 | 292 | __( 'An SVG in that theme declares a DOCTYPE or entities, which is not allowed.', 'desktop-mode' ), |
| 293 | 293 | array( 'status' => 400 ) |
| 294 | 294 | ); |
| 295 | 295 | } |
| @@ -301,9 +301,9 @@ | ||
| 301 | 301 | libxml_use_internal_errors( $previous ); |
| 302 | 302 | |
| 303 | 303 | if ( ! $loaded || ! $doc->documentElement || 'svg' !== strtolower( $doc->documentElement->localName ) ) { |
| 304 | 304 | return new WP_Error( |
| 305 | - 'desktop_mode_desktop_theme_bad_svg', | |
| 305 | + 'openstation_desktop_theme_bad_svg', | |
| 306 | 306 | __( 'An SVG in that theme could not be parsed.', 'desktop-mode' ), |
| 307 | 307 | array( 'status' => 400 ) |
| 308 | 308 | ); |
| 309 | 309 | } |
| @@ -368,9 +368,9 @@ | ||
| 368 | 368 | |
| 369 | 369 | $clean = $doc->saveXML(); |
| 370 | 370 | if ( ! is_string( $clean ) || '' === $clean ) { |
| 371 | 371 | return new WP_Error( |
| 372 | - 'desktop_mode_desktop_theme_bad_svg', | |
| 372 | + 'openstation_desktop_theme_bad_svg', | |
| 373 | 373 | __( 'An SVG in that theme could not be re-serialized after sanitization.', 'desktop-mode' ), |
| 374 | 374 | array( 'status' => 400 ) |
| 375 | 375 | ); |
| 376 | 376 | } |
| @@ -404,10 +404,10 @@ | ||
| 404 | 404 | * |
| 405 | 405 | * @param int $max_age Seconds before an orphan is collectable. |
| 406 | 406 | * @return int Number of directories removed. |
| 407 | 407 | */ |
| 408 | -function desktop_mode_desktop_theme_sweep_staging( $max_age = DAY_IN_SECONDS ) { | |
| 409 | - $base = desktop_mode_desktop_themes_dir(); | |
| 408 | +function openstation_desktop_theme_sweep_staging( $max_age = DAY_IN_SECONDS ) { | |
| 409 | + $base = openstation_desktop_themes_dir(); | |
| 410 | 410 | if ( ! is_dir( $base ) ) { |
| 411 | 411 | return 0; |
| 412 | 412 | } |
| 413 | 413 | $max_age = max( 60, (int) $max_age ); |
| @@ -420,9 +420,9 @@ | ||
| 420 | 420 | continue; |
| 421 | 421 | } |
| 422 | 422 | // `_rmdir()` refuses to act outside the themes base dir, so a |
| 423 | 423 | // symlinked or otherwise unexpected path cannot be followed out. |
| 424 | - if ( desktop_mode_desktop_theme_rmdir( $dir ) ) { | |
| 424 | + if ( openstation_desktop_theme_rmdir( $dir ) ) { | |
| 425 | 425 | ++$removed; |
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | |
| @@ -434,19 +434,19 @@ | ||
| 434 | 434 | * |
| 435 | 435 | * @param string $zip_path Absolute path of the uploaded archive. |
| 436 | 436 | * @return array|WP_Error The stored index entry on success. |
| 437 | 437 | */ |
| 438 | -function desktop_mode_desktop_theme_install_from_zip( $zip_path ) { | |
| 438 | +function openstation_desktop_theme_install_from_zip( $zip_path ) { | |
| 439 | 439 | // Collect anything a previously-killed install abandoned. Cheap, |
| 440 | 440 | // and this is the only moment the directory is guaranteed relevant. |
| 441 | - desktop_mode_desktop_theme_sweep_staging(); | |
| 441 | + openstation_desktop_theme_sweep_staging(); | |
| 442 | 442 | |
| 443 | - $manifest_entry = desktop_mode_desktop_theme_validate_zip( $zip_path ); | |
| 443 | + $manifest_entry = openstation_desktop_theme_validate_zip( $zip_path ); | |
| 444 | 444 | if ( is_wp_error( $manifest_entry ) ) { |
| 445 | 445 | return $manifest_entry; |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - $base = desktop_mode_desktop_themes_ensure_dir(); | |
| 448 | + $base = openstation_desktop_themes_ensure_dir(); | |
| 449 | 449 | if ( is_wp_error( $base ) ) { |
| 450 | 450 | return $base; |
| 451 | 451 | } |
| 452 | 452 | |
| @@ -452,9 +452,9 @@ | ||
| 452 | 452 | |
| 453 | 453 | $staging = $base . '/.staging-' . wp_generate_uuid4(); |
| 454 | 454 | if ( ! wp_mkdir_p( $staging ) ) { |
| 455 | 455 | return new WP_Error( |
| 456 | - 'desktop_mode_desktop_theme_mkdir_failed', | |
| 456 | + 'openstation_desktop_theme_mkdir_failed', | |
| 457 | 457 | __( 'Could not create a staging directory for the upload.', 'desktop-mode' ), |
| 458 | 458 | array( 'status' => 500 ) |
| 459 | 459 | ); |
| 460 | 460 | } |
| @@ -460,11 +460,11 @@ | ||
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | require_once ABSPATH . 'wp-admin/includes/file.php'; |
| 463 | 463 | if ( ! WP_Filesystem() ) { |
| 464 | - desktop_mode_desktop_theme_rmdir( $staging ); | |
| 464 | + openstation_desktop_theme_rmdir( $staging ); | |
| 465 | 465 | return new WP_Error( |
| 466 | - 'desktop_mode_desktop_theme_filesystem_unavailable', | |
| 466 | + 'openstation_desktop_theme_filesystem_unavailable', | |
| 467 | 467 | __( 'WordPress could not access the filesystem to unpack the theme.', 'desktop-mode' ), |
| 468 | 468 | array( 'status' => 500 ) |
| 469 | 469 | ); |
| 470 | 470 | } |
| @@ -474,9 +474,9 @@ | ||
| 474 | 474 | global $wp_filesystem; |
| 475 | 475 | |
| 476 | 476 | $unzipped = unzip_file( $zip_path, $staging ); |
| 477 | 477 | if ( is_wp_error( $unzipped ) ) { |
| 478 | - desktop_mode_desktop_theme_rmdir( $staging ); | |
| 478 | + openstation_desktop_theme_rmdir( $staging ); | |
| 479 | 479 | // Surfaced verbatim: on FTP-credentialed filesystems this is |
| 480 | 480 | // the only signal that says WHY, and the generic message we |
| 481 | 481 | // could substitute would be strictly less useful. |
| 482 | 482 | return $unzipped; |
| @@ -488,11 +488,11 @@ | ||
| 488 | 488 | $root = $staging . '/' . dirname( $manifest_entry ); |
| 489 | 489 | } |
| 490 | 490 | $manifest_file = $root . '/theme.json'; |
| 491 | 491 | if ( ! is_file( $manifest_file ) ) { |
| 492 | - desktop_mode_desktop_theme_rmdir( $staging ); | |
| 492 | + openstation_desktop_theme_rmdir( $staging ); | |
| 493 | 493 | return new WP_Error( |
| 494 | - 'desktop_mode_desktop_theme_missing_manifest', | |
| 494 | + 'openstation_desktop_theme_missing_manifest', | |
| 495 | 495 | __( 'The archive unpacked without a theme.json.', 'desktop-mode' ), |
| 496 | 496 | array( 'status' => 400 ) |
| 497 | 497 | ); |
| 498 | 498 | } |
| @@ -499,22 +499,22 @@ | ||
| 499 | 499 | |
| 500 | 500 | // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents |
| 501 | 501 | $decoded = json_decode( (string) file_get_contents( $manifest_file ), true ); |
| 502 | 502 | if ( null === $decoded ) { |
| 503 | - desktop_mode_desktop_theme_rmdir( $staging ); | |
| 503 | + openstation_desktop_theme_rmdir( $staging ); | |
| 504 | 504 | return new WP_Error( |
| 505 | - 'desktop_mode_desktop_theme_bad_json', | |
| 505 | + 'openstation_desktop_theme_bad_json', | |
| 506 | 506 | __( 'theme.json is not valid JSON.', 'desktop-mode' ), |
| 507 | 507 | array( 'status' => 400 ) |
| 508 | 508 | ); |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - $manifest = desktop_mode_sanitize_desktop_theme_manifest( | |
| 511 | + $manifest = openstation_sanitize_desktop_theme_manifest( | |
| 512 | 512 | $decoded, |
| 513 | - desktop_mode_desktop_theme_staging_asset_resolver( $root ) | |
| 513 | + openstation_desktop_theme_staging_asset_resolver( $root ) | |
| 514 | 514 | ); |
| 515 | 515 | if ( is_wp_error( $manifest ) ) { |
| 516 | - desktop_mode_desktop_theme_rmdir( $staging ); | |
| 516 | + openstation_desktop_theme_rmdir( $staging ); | |
| 517 | 517 | return $manifest; |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | $slug = (string) $manifest['slug']; |
| @@ -550,11 +550,11 @@ | ||
| 550 | 550 | foreach ( array_keys( $assets ) as $relative ) { |
| 551 | 551 | if ( 'svg' !== strtolower( (string) pathinfo( $relative, PATHINFO_EXTENSION ) ) ) { |
| 552 | 552 | continue; |
| 553 | 553 | } |
| 554 | - $sanitized = desktop_mode_desktop_theme_sanitize_svg( $root . '/' . $relative ); | |
| 554 | + $sanitized = openstation_desktop_theme_sanitize_svg( $root . '/' . $relative ); | |
| 555 | 555 | if ( is_wp_error( $sanitized ) ) { |
| 556 | - desktop_mode_desktop_theme_rmdir( $staging ); | |
| 556 | + openstation_desktop_theme_rmdir( $staging ); | |
| 557 | 557 | return $sanitized; |
| 558 | 558 | } |
| 559 | 559 | } |
| 560 | 560 | |
| @@ -559,16 +559,16 @@ | ||
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | // Re-upload of the same id is an UPDATE: drop the old directory |
| 562 | 562 | // wholesale so removed assets don't linger. |
| 563 | - $target = desktop_mode_desktop_themes_dir( $slug ); | |
| 563 | + $target = openstation_desktop_themes_dir( $slug ); | |
| 564 | 564 | if ( is_dir( $target ) ) { |
| 565 | - desktop_mode_desktop_theme_rmdir( $target ); | |
| 565 | + openstation_desktop_theme_rmdir( $target ); | |
| 566 | 566 | } |
| 567 | 567 | if ( ! wp_mkdir_p( $target ) ) { |
| 568 | - desktop_mode_desktop_theme_rmdir( $staging ); | |
| 568 | + openstation_desktop_theme_rmdir( $staging ); | |
| 569 | 569 | return new WP_Error( |
| 570 | - 'desktop_mode_desktop_theme_mkdir_failed', | |
| 570 | + 'openstation_desktop_theme_mkdir_failed', | |
| 571 | 571 | __( 'Could not create the theme directory.', 'desktop-mode' ), |
| 572 | 572 | array( 'status' => 500 ) |
| 573 | 573 | ); |
| 574 | 574 | } |
| @@ -576,12 +576,12 @@ | ||
| 576 | 576 | foreach ( array_keys( $assets ) as $relative ) { |
| 577 | 577 | $destination = $target . '/' . $relative; |
| 578 | 578 | $dir = dirname( $destination ); |
| 579 | 579 | if ( ! wp_mkdir_p( $dir ) ) { |
| 580 | - desktop_mode_desktop_theme_rmdir( $staging ); | |
| 581 | - desktop_mode_desktop_theme_rmdir( $target ); | |
| 580 | + openstation_desktop_theme_rmdir( $staging ); | |
| 581 | + openstation_desktop_theme_rmdir( $target ); | |
| 582 | 582 | return new WP_Error( |
| 583 | - 'desktop_mode_desktop_theme_mkdir_failed', | |
| 583 | + 'openstation_desktop_theme_mkdir_failed', | |
| 584 | 584 | __( 'Could not create a theme asset directory.', 'desktop-mode' ), |
| 585 | 585 | array( 'status' => 500 ) |
| 586 | 586 | ); |
| 587 | 587 | } |
| @@ -593,12 +593,12 @@ | ||
| 593 | 593 | // devices is the common case). `true` overwrites — the target |
| 594 | 594 | // directory was just recreated, so nothing should be there, |
| 595 | 595 | // and a stale file must not silently abort the install. |
| 596 | 596 | if ( ! $wp_filesystem->move( $root . '/' . $relative, $destination, true ) ) { |
| 597 | - desktop_mode_desktop_theme_rmdir( $staging ); | |
| 598 | - desktop_mode_desktop_theme_rmdir( $target ); | |
| 597 | + openstation_desktop_theme_rmdir( $staging ); | |
| 598 | + openstation_desktop_theme_rmdir( $target ); | |
| 599 | 599 | return new WP_Error( |
| 600 | - 'desktop_mode_desktop_theme_write_failed', | |
| 600 | + 'openstation_desktop_theme_write_failed', | |
| 601 | 601 | __( 'Could not move a theme asset into place.', 'desktop-mode' ), |
| 602 | 602 | array( 'status' => 500 ) |
| 603 | 603 | ); |
| 604 | 604 | } |
| @@ -618,26 +618,26 @@ | ||
| 618 | 618 | // references, so the two must agree or a re-upload's textures go |
| 619 | 619 | // stale while its CSS refreshes. |
| 620 | 620 | $installed_at = time(); |
| 621 | 621 | |
| 622 | - $css = desktop_mode_desktop_theme_compile_css( | |
| 622 | + $css = openstation_desktop_theme_compile_css( | |
| 623 | 623 | $manifest, |
| 624 | 624 | $slug, |
| 625 | - desktop_mode_desktop_themes_url( $slug ), | |
| 625 | + openstation_desktop_themes_url( $slug ), | |
| 626 | 626 | (string) $installed_at |
| 627 | 627 | ); |
| 628 | 628 | // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents |
| 629 | 629 | if ( false === file_put_contents( $target . '/theme.css', $css ) ) { |
| 630 | - desktop_mode_desktop_theme_rmdir( $staging ); | |
| 631 | - desktop_mode_desktop_theme_rmdir( $target ); | |
| 630 | + openstation_desktop_theme_rmdir( $staging ); | |
| 631 | + openstation_desktop_theme_rmdir( $target ); | |
| 632 | 632 | return new WP_Error( |
| 633 | - 'desktop_mode_desktop_theme_write_failed', | |
| 633 | + 'openstation_desktop_theme_write_failed', | |
| 634 | 634 | __( 'Could not write the compiled theme stylesheet.', 'desktop-mode' ), |
| 635 | 635 | array( 'status' => 500 ) |
| 636 | 636 | ); |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | - desktop_mode_desktop_theme_rmdir( $staging ); | |
| 639 | + openstation_desktop_theme_rmdir( $staging ); | |
| 640 | 640 | |
| 641 | 641 | $entry = array( |
| 642 | 642 | 'slug' => $slug, |
| 643 | 643 | 'manifest' => $manifest, |
| @@ -644,11 +644,11 @@ | ||
| 644 | 644 | 'installedAt' => $installed_at, |
| 645 | 645 | 'installedBy' => get_current_user_id(), |
| 646 | 646 | ); |
| 647 | 647 | |
| 648 | - $index = desktop_mode_desktop_themes_index(); | |
| 648 | + $index = openstation_desktop_themes_index(); | |
| 649 | 649 | $index[ $slug ] = $entry; |
| 650 | - desktop_mode_desktop_themes_put_index( $index ); | |
| 650 | + openstation_desktop_themes_put_index( $index ); | |
| 651 | 651 | |
| 652 | 652 | /** |
| 653 | 653 | * Fires after a desktop theme has been installed or updated. |
| 654 | 654 | * |
| @@ -655,9 +655,9 @@ | ||
| 655 | 655 | * @param string $slug Theme slug. |
| 656 | 656 | * @param array $entry Stored index entry (`slug`, `manifest`, |
| 657 | 657 | * `installedAt`, `installedBy`). |
| 658 | 658 | */ |
| 659 | - do_action( 'desktop_mode_desktop_theme_installed', $slug, $entry ); | |
| 659 | + do_action( 'openstation_desktop_theme_installed', $slug, $entry ); | |
| 660 | 660 | |
| 661 | 661 | return $entry; |
| 662 | 662 | } |
| 663 | 663 | |
| @@ -670,14 +670,14 @@ | ||
| 670 | 670 | * |
| 671 | 671 | * @param string $slug Theme slug. |
| 672 | 672 | * @return true|WP_Error |
| 673 | 673 | */ |
| 674 | -function desktop_mode_desktop_theme_delete( $slug ) { | |
| 674 | +function openstation_desktop_theme_delete( $slug ) { | |
| 675 | 675 | $slug = sanitize_key( (string) $slug ); |
| 676 | - $index = desktop_mode_desktop_themes_index(); | |
| 676 | + $index = openstation_desktop_themes_index(); | |
| 677 | 677 | if ( '' === $slug || ! isset( $index[ $slug ] ) ) { |
| 678 | 678 | return new WP_Error( |
| 679 | - 'desktop_mode_desktop_theme_not_found', | |
| 679 | + 'openstation_desktop_theme_not_found', | |
| 680 | 680 | __( 'That desktop theme is not installed.', 'desktop-mode' ), |
| 681 | 681 | array( 'status' => 404 ) |
| 682 | 682 | ); |
| 683 | 683 | } |
| @@ -682,14 +682,14 @@ | ||
| 682 | 682 | ); |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | $entry = $index[ $slug ]; |
| 686 | - $dir = desktop_mode_desktop_themes_dir( $slug ); | |
| 686 | + $dir = openstation_desktop_themes_dir( $slug ); | |
| 687 | 687 | if ( is_dir( $dir ) ) { |
| 688 | - desktop_mode_desktop_theme_rmdir( $dir ); | |
| 688 | + openstation_desktop_theme_rmdir( $dir ); | |
| 689 | 689 | } |
| 690 | 690 | unset( $index[ $slug ] ); |
| 691 | - desktop_mode_desktop_themes_put_index( $index ); | |
| 691 | + openstation_desktop_themes_put_index( $index ); | |
| 692 | 692 | |
| 693 | 693 | /** |
| 694 | 694 | * Fires after a desktop theme has been deleted. |
| 695 | 695 | * |
| @@ -695,8 +695,8 @@ | ||
| 695 | 695 | * |
| 696 | 696 | * @param string $slug Theme slug. |
| 697 | 697 | * @param array $entry The index entry as it was before removal. |
| 698 | 698 | */ |
| 699 | - do_action( 'desktop_mode_desktop_theme_deleted', $slug, $entry ); | |
| 699 | + do_action( 'openstation_desktop_theme_deleted', $slug, $entry ); | |
| 700 | 700 | |
| 701 | 701 | return true; |
| 702 | 702 | } |