Skip to content

Commit 73a7668

Browse files
committed
docs: fill in missing phpdoc on picker classes and REST helpers
Adds class-property and method-level phpdoc to bring the new picker classes in line with the project's docblock conventions: - MslsTranslationPickerTable: properties ($source_blog_id, $post_type, $search, $taxonomies_cache), constructor, get_columns, get_bulk_actions, prepare_items and no_items - MslsTranslationPickerPage: BASE_SLUG / SCRIPT_HANDLE / PER_PAGE_OPTION / PER_PAGE_DEFAULT constants - MslsPostListActions::init: bootstrap rationale and short-circuits - MslsRestApi: get_list_route_args summary, apply_capability_filter parameter descriptions No behaviour change.
1 parent b9b1859 commit 73a7668

4 files changed

Lines changed: 83 additions & 4 deletions

File tree

includes/MslsPostListActions.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
class MslsPostListActions {
1919

2020
/**
21+
* Bootstraps the button injector on edit.php — short-circuits when MSLS
22+
* is excluded for the current blog, when no post_type is in the request,
23+
* when the current user can't create posts, or when no MSLS-active source
24+
* blogs exist.
25+
*
2126
* @codeCoverageIgnore
2227
*/
2328
public static function init(): void {

includes/MslsRestApi.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ private static function get_route_args(): array {
115115
}
116116

117117
/**
118+
* Argument schema for the GET /untranslated-posts endpoint.
119+
*
118120
* @return array<string, array<string, mixed>>
119121
*/
120122
private static function get_list_route_args(): array {
@@ -221,11 +223,14 @@ public function check_list_permission( \WP_REST_Request $request ): bool {
221223
}
222224

223225
/**
224-
* @param bool $default
225-
* @param int $source_post_id
226+
* Routes the default capability decision through the
227+
* msls_quick_create_capability filter so integrations can override it.
228+
*
229+
* @param bool $default Result of the default capability check.
230+
* @param int $source_post_id Source post id, or 0 for list-style checks.
226231
* @param int $source_blog_id
227232
* @param int $target_blog_id
228-
* @param string $context
233+
* @param string $context 'read' for source-side checks, 'create' for target-side.
229234
*
230235
* @return bool
231236
*/

includes/MslsTranslationPickerPage.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,26 @@
1818
*/
1919
class MslsTranslationPickerPage {
2020

21+
/**
22+
* Base of the per-post-type page slugs. The actual slug appended to the
23+
* URL is BASE_SLUG . '-' . $post_type — see {@see self::page_slug()}.
24+
*/
2125
const BASE_SLUG = 'msls-translation-picker';
2226

27+
/**
28+
* Script handle registered by {@see self::enqueue()} and reused as the
29+
* localization key for the script's bootstrap payload.
30+
*/
2331
const SCRIPT_HANDLE = 'msls-translation-picker';
2432

33+
/**
34+
* User-meta key behind the "Posts per page" Screen Options input.
35+
*/
2536
const PER_PAGE_OPTION = 'msls_tp_per_page';
2637

38+
/**
39+
* Page size used until the user picks a value via Screen Options.
40+
*/
2741
const PER_PAGE_DEFAULT = 20;
2842

2943
/**

includes/MslsTranslationPickerTable.php

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,48 @@
2424
*/
2525
class MslsTranslationPickerTable extends \WP_List_Table {
2626

27+
/**
28+
* Default page size used as a fallback when the user has not picked a
29+
* value via the screen-options dropdown.
30+
*/
2731
const PER_PAGE = 20;
2832

33+
/**
34+
* Source blog the listing queries (the picker reads from this site's
35+
* data while the page itself runs on the target blog).
36+
*
37+
* @var int
38+
*/
2939
protected int $source_blog_id;
3040

41+
/**
42+
* Post type being listed (read from the URL slug).
43+
*
44+
* @var string
45+
*/
3146
protected string $post_type;
3247

48+
/**
49+
* Optional title-search string forwarded to WP_Query as 's'.
50+
*
51+
* @var string
52+
*/
3353
protected string $search;
3454

35-
/** @var array<string, \WP_Taxonomy>|null */
55+
/**
56+
* Per-request memo of the source-blog taxonomies whose admin column is
57+
* enabled. Resolved once and reused for both column headers and item
58+
* rendering.
59+
*
60+
* @var array<string, \WP_Taxonomy>|null
61+
*/
3662
protected ?array $taxonomies_cache = null;
3763

64+
/**
65+
* @param int $source_blog_id Blog to read posts from.
66+
* @param string $post_type Post type to query.
67+
* @param string $search Optional title-search term.
68+
*/
3869
public function __construct( int $source_blog_id, string $post_type, string $search = '' ) {
3970
parent::__construct(
4071
array(
@@ -50,6 +81,13 @@ public function __construct( int $source_blog_id, string $post_type, string $sea
5081
$this->search = $search;
5182
}
5283

84+
/**
85+
* Returns the column map for the table — checkbox, title, author, any
86+
* source-blog taxonomies that opted into show_admin_column, then status
87+
* and date.
88+
*
89+
* @return array<string, string>
90+
*/
5391
public function get_columns(): array {
5492
$cols = array(
5593
'cb' => '<input type="checkbox" />',
@@ -99,12 +137,25 @@ protected function get_admin_column_taxonomies(): array {
99137
return $this->taxonomies_cache;
100138
}
101139

140+
/**
141+
* Registers the bulk action that the picker JS hijacks to create
142+
* drafts for every checked row.
143+
*
144+
* @return array<string, string>
145+
*/
102146
protected function get_bulk_actions(): array {
103147
return array(
104148
'msls_bulk_create' => __( 'Create drafts for selected', 'multisite-language-switcher' ),
105149
);
106150
}
107151

152+
/**
153+
* Loads the source-blog posts for the current page into $this->items.
154+
*
155+
* Honours hidden-column user prefs, the per-page screen option, the
156+
* search term and pagination. Already-translated post IDs are excluded
157+
* via TranslatedPostIdQuery against the target language.
158+
*/
108159
public function prepare_items(): void {
109160
$columns = $this->get_columns();
110161
$hidden = is_object( $this->screen ) ? get_hidden_columns( $this->screen ) : array();
@@ -258,6 +309,10 @@ protected function column_default( $item, $column_name ): string {
258309
return '';
259310
}
260311

312+
/**
313+
* Renders the empty-state message — distinguishes between "search
314+
* returned nothing" and "every source post already has a translation".
315+
*/
261316
public function no_items(): void {
262317
if ( '' !== $this->search ) {
263318
esc_html_e( 'No posts match your search.', 'multisite-language-switcher' );

0 commit comments

Comments
 (0)