| 1 |
<?php |
| 2 |
/** |
| 3 |
* Pages — the native Pages window, as an OpenStation app. |
| 4 |
* |
| 5 |
* Claims the FROZEN window id `desktop-mode-pages` (see AGENTS.md). |
| 6 |
* The Posts app's twin over `/wp/v2/pages`: hierarchical (a Parent |
| 7 |
* column, `menu_order` by default), a Template / Slug / Comments |
| 8 |
* column set, front-page and posts-page badges, and no taxonomy tabs. |
| 9 |
* The list machinery is shared with the Posts app — this entry |
| 10 |
* requires `apps/posts/parts/query.php` and `pages.os.ts` composes the |
| 11 |
* same client parts (sanctioned cross-app reuse, noted in both). |
| 12 |
* |
| 13 |
* (Header kept short on purpose: Plugin Check's direct-access scan |
| 14 |
* reads only the first 50 raw lines, and the guard must land inside.) |
| 15 |
* |
| 16 |
* @package OpenStation |
| 17 |
*/ |
| 18 |
|
| 19 |
namespace OpenStation\Apps\Pages; |
| 20 |
|
| 21 |
use OpenStation\App; |
| 22 |
use OpenStation\App\Os; |
| 23 |
use OpenStation\App\State; |
| 24 |
|
| 25 |
// Direct access, unless a standalone host is booting on bare PHP. |
| 26 |
if ( ! defined( 'ABSPATH' ) ) { |
| 27 |
defined( 'OPENSTATION_STANDALONE' ) || exit; |
| 28 |
} |
| 29 |
|
| 30 |
require_once __DIR__ . '/parts/permissions.php'; |
| 31 |
require_once __DIR__ . '/parts/query.php'; |
| 32 |
require_once dirname( __DIR__ ) . '/posts/parts/query.php'; |
| 33 |
|
| 34 |
return App::define( 'desktop-mode-pages' ) |
| 35 |
->title( __( 'Pages', 'desktop-mode' ) ) |
| 36 |
->icon( 'dashicons-admin-page' ) |
| 37 |
->size( 1100, 720 ) |
| 38 |
->min_size( 720, 480 ) |
| 39 |
// The Pages dock tile is WordPress's own; the shell's URL remap |
| 40 |
// routes `edit.php?post_type=page` here under `nativePagesEnabled`. |
| 41 |
->placement( 'none' ) |
| 42 |
->can( |
| 43 |
static function () { |
| 44 |
return openstation_pages_window_user_can_register(); |
| 45 |
} |
| 46 |
) |
| 47 |
->config( |
| 48 |
static function () { |
| 49 |
return openstation_pages_app_config(); |
| 50 |
} |
| 51 |
) |
| 52 |
->state( openstation_posts_app_state( 'menu_order', 'asc' ) ) |
| 53 |
->action( |
| 54 |
'filter', |
| 55 |
static function ( State $state ) { |
| 56 |
openstation_posts_app_filter( $state ); |
| 57 |
} |
| 58 |
) |
| 59 |
->action( |
| 60 |
'page', |
| 61 |
static function ( State $state, Os $os, array $args ) { |
| 62 |
openstation_posts_app_page( $state, $args ); |
| 63 |
} |
| 64 |
) |
| 65 |
->action( |
| 66 |
'sort', |
| 67 |
static function ( State $state, Os $os, array $args ) { |
| 68 |
openstation_posts_app_sort( $state, $args, 'menu_order', 'asc' ); |
| 69 |
} |
| 70 |
) |
| 71 |
->action( |
| 72 |
'trash', |
| 73 |
static function ( State $state, Os $os, array $args ) { |
| 74 |
openstation_posts_app_trash( $os, $args, 'page' ); |
| 75 |
} |
| 76 |
) |
| 77 |
->watch( 'page' ) |
| 78 |
->data( |
| 79 |
static function ( State $state ) { |
| 80 |
return openstation_posts_app_data( 'wp/v2/pages', openstation_pages_window_default_query_args(), $state ); |
| 81 |
} |
| 82 |
); |
| 83 |
|