PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.3
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.3
6.3 6.2.3 6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 All 157 releases
mainwp / pages / page-mainwp-control.php

page-mainwp-control.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 6.3, at pages/page-mainwp-control.php

205 lines 15.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Control landing page.
4 *
5 * @package MainWP\Dashboard
6 */
7
8 namespace MainWP\Dashboard;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 }
13
14 /**
15 * MainWP Control page controller.
16 */
17 class MainWP_Control {
18
19 /**
20 * Register the MainWP Control page and AI submenu item.
21 *
22 * @return void
23 */
24 public static function init_menu() {
25 if ( ! MainWP_System_Utility::is_admin() || true !== MainWP_Abilities_Util::check_rest_api_permission() || MainWP_Menu::is_disable_menu_item( 2, 'ai' ) ) {
26 return;
27 }
28
29 $page = add_submenu_page(
30 'mainwp_tab',
31 esc_html__( 'MainWP Control', 'mainwp' ),
32 '<span id="mainwp-control">' . esc_html__( 'MainWP Control', 'mainwp' ) . '</span>',
33 'manage_options',
34 'mainwp-control',
35 array( static::class, 'render' )
36 );
37
38 add_action( 'load-' . $page, array( static::class, 'enqueue_scripts' ) );
39
40 MainWP_Menu::add_left_menu(
41 array(
42 'title' => esc_html__( 'MainWP Control', 'mainwp' ),
43 'parent_key' => 'ai',
44 'slug' => 'mainwp-control',
45 'href' => 'admin.php?page=mainwp-control',
46 'leftsub_order_level2' => 3,
47 ),
48 2
49 );
50 }
51
52 /**
53 * Enqueue scripts used by the MainWP Control page.
54 *
55 * @return void
56 */
57 public static function enqueue_scripts() {
58 wp_enqueue_script( 'mainwp-code-copy', MAINWP_PLUGIN_URL . 'assets/js/mainwp-code-copy.js', array( 'jquery', 'clipboard' ), MAINWP_VERSION, true );
59 wp_enqueue_script( 'mainwp-control', MAINWP_PLUGIN_URL . 'assets/js/mainwp-control.js', array( 'jquery' ), MAINWP_VERSION, true );
60 }
61
62 /**
63 * Render the MainWP Control landing page.
64 *
65 * @return void
66 */
67 public static function render() {
68 if ( ! MainWP_System_Utility::is_admin() || true !== MainWP_Abilities_Util::check_rest_api_permission() ) {
69 echo '<div class="ui message">' . esc_html__( 'You do not have permission to access this page.', 'mainwp' ) . '</div>';
70 return;
71 }
72
73 MainWP_UI::render_top_header( array( 'title' => esc_html__( 'MainWP Control', 'mainwp' ) ) );
74 ?>
75 <div id="mainwp-control-page" class="ui padded segment">
76 <h2 class="ui header">
77 <?php esc_html_e( 'Automate MainWP from the command line', 'mainwp' ); ?>
78 <span class="sub header">
79 <?php esc_html_e( 'Run repeatable site maintenance from your terminal, shell scripts, cron jobs, and CI/CD pipelines.', 'mainwp' ); ?>
80 <a href="https://github.com/mainwp/mainwp-control" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'View MainWP Control on GitHub.', 'mainwp' ); ?></a>
81 </span>
82 </h2>
83
84 <div class="ui section divider mainwp-control-section-divider"></div>
85
86 <div id="mainwp-control-steps" class="ui circular ordered stackable fluid steps" role="tablist" aria-label="<?php esc_attr_e( 'MainWP Control setup steps', 'mainwp' ); ?>">
87 <div id="mainwp-control-step-tab-1" class="active step" role="tab" tabindex="0" aria-selected="true" aria-current="step" aria-controls="mainwp-control-step-panel-1" data-step-index="0">
88 <div class="content">
89 <div class="title"><?php esc_html_e( 'Credentials', 'mainwp' ); ?></div>
90 <div class="description"><?php esc_html_e( 'Create an Application Password', 'mainwp' ); ?></div>
91 </div>
92 </div>
93 <div id="mainwp-control-step-tab-2" class="step" role="tab" tabindex="-1" aria-selected="false" aria-controls="mainwp-control-step-panel-2" data-step-index="1">
94 <div class="content">
95 <div class="title"><?php esc_html_e( 'Install', 'mainwp' ); ?></div>
96 <div class="description"><?php esc_html_e( 'Install and sign in', 'mainwp' ); ?></div>
97 </div>
98 </div>
99 <div id="mainwp-control-step-tab-3" class="step" role="tab" tabindex="-1" aria-selected="false" aria-controls="mainwp-control-step-panel-3" data-step-index="2">
100 <div class="content">
101 <div class="title"><?php esc_html_e( 'Test', 'mainwp' ); ?></div>
102 <div class="description"><?php esc_html_e( 'Run your first commands', 'mainwp' ); ?></div>
103 </div>
104 </div>
105 <div id="mainwp-control-step-tab-4" class="step" role="tab" tabindex="-1" aria-selected="false" aria-controls="mainwp-control-step-panel-4" data-step-index="3">
106 <div class="content">
107 <div class="title"><?php esc_html_e( 'Finish', 'mainwp' ); ?></div>
108 <div class="description"><?php esc_html_e( 'Review features and safeguards', 'mainwp' ); ?></div>
109 </div>
110 </div>
111 </div>
112
113 <div id="mainwp-control-step-panels">
114 <div id="mainwp-control-step-panel-1" class="ui basic segment mainwp-control-step-panel" role="tabpanel" aria-labelledby="mainwp-control-step-tab-1" data-step-panel="0">
115 <h3 class="ui header"><?php esc_html_e( 'Create an Application Password', 'mainwp' ); ?></h3>
116 <p class="mainwp-control-step-intro">
117 <?php esc_html_e( 'Create a separate, revocable credential for MainWP Control. A dedicated WordPress administrator account keeps the audit trail separate from your everyday login.', 'mainwp' ); ?>
118 <a href="https://docs.mainwp.com/api-reference/rest-api/application-passwords" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Learn more about Application Passwords.', 'mainwp' ); ?></a>
119 </p>
120 <?php MainWP_Rest_Api_Page::render_inline_application_password_creator( esc_html__( 'MainWP Control', 'mainwp' ) ); ?>
121 <div class="ui divider mainwp-control-step-navigation-divider"></div>
122 <div class="mainwp-control-step-navigation-actions">
123 <a href="#mainwp-control-step-panel-2" class="mainwp-control-step-navigation mainwp-control-next-step" data-step-index="1" aria-controls="mainwp-control-step-panel-2"><span class="ui grey text"><?php esc_html_e( 'Next Step', 'mainwp' ); ?><i class="ui grey chevron right icon"></i></span></a>
124 </div>
125 </div>
126
127 <div id="mainwp-control-step-panel-2" class="ui basic segment mainwp-control-step-panel" role="tabpanel" aria-labelledby="mainwp-control-step-tab-2" data-step-panel="1" hidden>
128 <h3 class="ui header"><?php esc_html_e( 'Install MainWP Control and log in', 'mainwp' ); ?></h3>
129 <p class="mainwp-control-step-intro">
130 <?php esc_html_e( 'Install Node.js 20.18.1 or later on the computer or server where you will run the CLI. Login asks for your Dashboard URL, username, and Application Password, then stores the credential in your operating system keychain.', 'mainwp' ); ?>
131 <a href="https://docs.mainwp.com/api-reference/mainwp-control" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Read the installation guide.', 'mainwp' ); ?></a>
132 </p>
133 <textarea id="mainwp-control-install-commands" class="mainwp-copyable-code mainwp-control-code-editor" rows="5" spellcheck="false" aria-label="<?php esc_attr_e( 'Editable MainWP Control installation commands', 'mainwp' ); ?>">npm install -g @mainwp/control
134
135 mainwpcontrol login</textarea>
136 <div class="mainwp-control-step-action">
137 <button type="button" class="ui small green button mainwp-code-copy-button" data-clipboard-target="#mainwp-control-install-commands" data-copy-success="<?php esc_attr_e( 'Copied!', 'mainwp' ); ?>" data-copy-error="<?php esc_attr_e( 'Copy failed', 'mainwp' ); ?>" aria-label="<?php esc_attr_e( 'Copy MainWP Control installation commands to clipboard', 'mainwp' ); ?>">
138 <i class="copy outline icon"></i>
139 <?php esc_html_e( 'Copy to clipboard', 'mainwp' ); ?>
140 </button>
141 </div>
142 <div class="ui divider mainwp-control-step-navigation-divider"></div>
143 <div class="mainwp-control-step-navigation-actions">
144 <a href="#mainwp-control-step-panel-1" class="mainwp-control-step-navigation" data-step-index="0" aria-controls="mainwp-control-step-panel-1"><span class="ui grey text"><i class="ui grey chevron left icon"></i><?php esc_html_e( 'Previous Step', 'mainwp' ); ?></span></a>
145 <a href="#mainwp-control-step-panel-3" class="mainwp-control-step-navigation mainwp-control-next-step" data-step-index="2" aria-controls="mainwp-control-step-panel-3"><span class="ui grey text"><?php esc_html_e( 'Next Step', 'mainwp' ); ?><i class="ui grey chevron right icon"></i></span></a>
146 </div>
147 </div>
148
149 <div id="mainwp-control-step-panel-3" class="ui basic segment mainwp-control-step-panel" role="tabpanel" aria-labelledby="mainwp-control-step-tab-3" data-step-panel="2" hidden>
150 <h3 class="ui header"><?php esc_html_e( 'Discover abilities and run your first command', 'mainwp' ); ?></h3>
151 <p class="mainwp-control-step-intro"><?php esc_html_e( 'MainWP Control discovers the abilities available on your Dashboard at runtime. Start by listing them, then try a read-only site request.', 'mainwp' ); ?></p>
152 <textarea id="mainwp-control-first-commands" class="mainwp-copyable-code mainwp-control-code-editor" rows="5" spellcheck="false" aria-label="<?php esc_attr_e( 'Editable MainWP Control starter commands', 'mainwp' ); ?>">mainwpcontrol abilities list
153
154 mainwpcontrol abilities run list-sites-v1 --json</textarea>
155 <div class="mainwp-control-step-action">
156 <button type="button" class="ui small green button mainwp-code-copy-button" data-clipboard-target="#mainwp-control-first-commands" data-copy-success="<?php esc_attr_e( 'Copied!', 'mainwp' ); ?>" data-copy-error="<?php esc_attr_e( 'Copy failed', 'mainwp' ); ?>" aria-label="<?php esc_attr_e( 'Copy MainWP Control starter commands to clipboard', 'mainwp' ); ?>">
157 <i class="copy outline icon"></i>
158 <?php esc_html_e( 'Copy to clipboard', 'mainwp' ); ?>
159 </button>
160 </div>
161 <div class="ui divider mainwp-control-step-navigation-divider"></div>
162 <div class="mainwp-control-step-navigation-actions">
163 <a href="#mainwp-control-step-panel-2" class="mainwp-control-step-navigation" data-step-index="1" aria-controls="mainwp-control-step-panel-2"><span class="ui grey text"><i class="ui grey chevron left icon"></i><?php esc_html_e( 'Previous Step', 'mainwp' ); ?></span></a>
164 <a href="#mainwp-control-step-panel-4" class="mainwp-control-step-navigation mainwp-control-next-step" data-step-index="3" aria-controls="mainwp-control-step-panel-4"><span class="ui grey text"><?php esc_html_e( 'Next Step', 'mainwp' ); ?><i class="ui grey chevron right icon"></i></span></a>
165 </div>
166 </div>
167
168 <div id="mainwp-control-step-panel-4" class="ui basic segment mainwp-control-step-panel" role="tabpanel" aria-labelledby="mainwp-control-step-tab-4" data-step-panel="3" hidden>
169 <h3 class="ui header"><?php esc_html_e( 'You are ready to use MainWP Control', 'mainwp' ); ?></h3>
170 <p class="mainwp-control-step-intro">
171 <?php esc_html_e( 'MainWP Control is ready for explicit commands, repeatable automation, and structured output. Use the features and safeguards below as a quick reference.', 'mainwp' ); ?>
172 <a href="https://docs.mainwp.com/api-reference/mainwp-control" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Read the full documentation.', 'mainwp' ); ?></a>
173 <a href="https://mainwp.com/mainwp-tools/mainwp-control/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Explore MainWP Control.', 'mainwp' ); ?></a>
174 </p>
175
176 <h4 class="ui header"><?php esc_html_e( 'Why use MainWP Control', 'mainwp' ); ?></h4>
177 <div class="ui relaxed list">
178 <div class="item"><div class="content"><strong><?php esc_html_e( 'Automation-ready output', 'mainwp' ); ?></strong> — <?php esc_html_e( 'use JSON and reliable exit codes in scripts, reports, and monitoring.', 'mainwp' ); ?></div></div>
179 <div class="item"><div class="content"><strong><?php esc_html_e( 'Durable batch operations', 'mainwp' ); ?></strong> — <?php esc_html_e( 'wait for queued jobs or return later using their job ID.', 'mainwp' ); ?></div></div>
180 <div class="item"><div class="content"><strong><?php esc_html_e( 'Multiple Dashboards', 'mainwp' ); ?></strong> — <?php esc_html_e( 'keep named profiles and select one globally or per command.', 'mainwp' ); ?></div></div>
181 <div class="item"><div class="content"><strong><?php esc_html_e( 'Optional chat mode', 'mainwp' ); ?></strong> — <?php esc_html_e( 'use your own LLM API key for plain-language commands with the same safety gates.', 'mainwp' ); ?></div></div>
182 </div>
183
184 <div class="ui hidden divider"></div>
185
186 <h4 class="ui header"><?php esc_html_e( 'Built-in safeguards', 'mainwp' ); ?></h4>
187 <div class="ui relaxed list">
188 <div class="item"><div class="content"><?php esc_html_e( 'Destructive operations require a successful dry-run preview before execution.', 'mainwp' ); ?></div></div>
189 <div class="item"><div class="content"><?php esc_html_e( 'Execution requires an explicit confirmation; automation must opt in per command.', 'mainwp' ); ?></div></div>
190 <div class="item"><div class="content"><?php esc_html_e( 'Confirmed destructive commands are recorded in a local audit log.', 'mainwp' ); ?></div></div>
191 <div class="item"><div class="content"><?php esc_html_e( 'Interactive credentials stay in your operating system keychain; CI can use protected environment variables.', 'mainwp' ); ?></div></div>
192 </div>
193 <div class="ui divider mainwp-control-step-navigation-divider"></div>
194 <div class="mainwp-control-step-navigation-actions">
195 <a href="#mainwp-control-step-panel-3" class="mainwp-control-step-navigation" data-step-index="2" aria-controls="mainwp-control-step-panel-3"><span class="ui grey text"><i class="ui grey chevron left icon"></i><?php esc_html_e( 'Previous Step', 'mainwp' ); ?></span></a>
196 </div>
197 </div>
198 </div>
199 </div>
200 <?php
201 // The shared header opens the page container, as on the Tags page.
202 echo '</div>';
203 }
204 }
205