1010/**
1111 * Add tasks to disable comments.
1212 */
13- class Disable_Comment_Pagination extends Tasks {
13+ class Disable_Comment_Pagination extends Tasks_Interactive {
1414
1515 /**
1616 * Whether the task is an onboarding task.
@@ -26,6 +26,43 @@ class Disable_Comment_Pagination extends Tasks {
2626 */
2727 protected const PROVIDER_ID = 'disable-comment-pagination ' ;
2828
29+ /**
30+ * The popover ID.
31+ *
32+ * @var string
33+ */
34+ const POPOVER_ID = 'disable-comment-pagination ' ;
35+
36+ /**
37+ * Initialize the task.
38+ *
39+ * @return void
40+ */
41+ public function init () {
42+ \add_action ( 'rest_api_init ' , [ $ this , 'register_setting_with_rest ' ] );
43+ }
44+
45+ /**
46+ * Register the setting with the REST API.
47+ *
48+ * @return void
49+ */
50+ public function register_setting_with_rest () {
51+ register_setting (
52+ 'discussion ' ,
53+ 'page_comments ' ,
54+ [
55+ 'type ' => 'string ' ,
56+ 'label ' => __ ( 'Break comments into pages ' , 'progress-planner ' ),
57+ 'show_in_rest ' => [
58+ 'schema ' => [
59+ 'enum ' => [ '1 ' , '' ],
60+ ],
61+ ],
62+ ]
63+ );
64+ }
65+
2966 /**
3067 * Get the task URL.
3168 *
@@ -85,4 +122,28 @@ public function should_add_task() {
85122 public function is_task_completed ( $ task_id = '' ) {
86123 return ! \get_option ( 'page_comments ' );
87124 }
125+
126+ /**
127+ * Get the popover instructions.
128+ *
129+ * @return void
130+ */
131+ public function print_popover_instructions () {
132+ ?>
133+ <p><?php \esc_html_e ( 'Comment pagination is enabled by default. This means that comments are split into multiple pages. This can be disabled to make the comments easier to read. ' , 'progress-planner ' ); ?> </p>
134+ <?php
135+ }
136+
137+ /**
138+ * Print the popover input field for the form.
139+ *
140+ * @return void
141+ */
142+ public function print_popover_form_contents () {
143+ ?>
144+ <button type="submit" class="prpl-button prpl-button-primary" style="color: #fff;">
145+ <?php \esc_html_e ( 'Disable comment pagination ' , 'progress-planner ' ); ?>
146+ </button>
147+ <?php
148+ }
88149}
0 commit comments