PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.8
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.8
1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 0.8.7 0.8.6 All 33 releases
desktop-mode / apps / posts / posts.os.php

posts.os.php in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 1.1.8, at apps/posts/posts.os.php

96 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Posts — the native Posts window, as an OpenStation app.
4 *
5 * Claims the FROZEN window id `desktop-mode-posts` (see AGENTS.md):
6 * the `edit.php` remap in the shell, the OS Settings opt-in and every
7 * session that saved the window keep working unchanged. The dock tile
8 * is WordPress's own Posts entry (`placement none`); the JS-side
9 * remap routes its click here under `nativePostsEnabled`.
10 *
11 * The body is `posts.os.ts`: the toolbar, the `<os-table>` and the
12 * pager as a client view, plus the Categories mind map and the Tags
13 * cloud on their tabs. The list itself is the same `/wp/v2/posts`
14 * request the legacy bundle fetched, run in-process by `data()`
15 * (`parts/query.php`); the taxonomy REST surface is `parts/terms-rest.php`.
16 *
17 * (Header kept short on purpose: Plugin Check's direct-access scan
18 * reads only the first 50 raw lines, and the guard must land inside.)
19 *
20 * @package OpenStation
21 */
22
23 namespace OpenStation\Apps\Posts;
24
25 use OpenStation\App;
26 use OpenStation\App\Os;
27 use OpenStation\App\State;
28
29 // Direct access, unless a standalone host is booting on bare PHP.
30 if ( ! defined( 'ABSPATH' ) ) {
31 defined( 'OPENSTATION_STANDALONE' ) || exit;
32 }
33
34 require_once __DIR__ . '/parts/permissions.php';
35 require_once __DIR__ . '/parts/query.php';
36 require_once __DIR__ . '/parts/terms-rest.php';
37
38 return App::define( 'desktop-mode-posts' )
39 ->title( __( 'Posts', 'desktop-mode' ) )
40 ->icon( 'dashicons-admin-post' )
41 ->size( 1100, 720 )
42 ->min_size( 720, 480 )
43 // No dock or wallpaper tile from this registration: the Posts dock
44 // tile lives in WordPress's `$menu`, and the shell's URL remap
45 // routes it here. A separate tile would be a duplicate entry point.
46 ->placement( 'none' )
47 // Cap-only gate (`edit_posts`, filterable) so flipping the opt-in
48 // mid-session never needs an F5 — the toggle is a runtime check on
49 // the JS-side remap.
50 ->can(
51 static function () {
52 return openstation_posts_window_user_can_register();
53 }
54 )
55 // A closure: resolved when the manifest is built, for the acting
56 // user — not once when this file loads.
57 ->config(
58 static function () {
59 return openstation_posts_app_config( 'posts', 'date', 'desc' );
60 }
61 )
62 ->state( openstation_posts_app_state( 'date', 'desc' ) )
63 ->action(
64 'filter',
65 static function ( State $state ) {
66 openstation_posts_app_filter( $state );
67 }
68 )
69 ->action(
70 'page',
71 static function ( State $state, Os $os, array $args ) {
72 openstation_posts_app_page( $state, $args );
73 }
74 )
75 ->action(
76 'sort',
77 static function ( State $state, Os $os, array $args ) {
78 openstation_posts_app_sort( $state, $args, 'date', 'desc' );
79 }
80 )
81 ->action(
82 'trash',
83 static function ( State $state, Os $os, array $args ) {
84 openstation_posts_app_trash( $os, $args, 'post' );
85 }
86 )
87 // A post trashed, restored or edited anywhere on the desktop
88 // repaints the list — the legacy bundle's `os.post.changed`
89 // subscription.
90 ->watch( 'post' )
91 ->data(
92 static function ( State $state ) {
93 return openstation_posts_app_data( 'wp/v2/posts', openstation_posts_window_default_query_args(), $state );
94 }
95 );
96