PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.12
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.12
1.1.12 1.1.11 1.1.10 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 All 36 releases
desktop-mode / includes / first-run / plugin-row.php

plugin-row.php in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 1.1.12, at includes/first-run/plugin-row.php

64 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * OpenStation — the "Turn on" plugin row action.
4 *
5 * One permanent link on OpenStation's row in `plugins.php`. "Plugin
6 * activated" is the moment people read that row, and until now the
7 * row said nothing about the one thing left to do: turn it on for
8 * yourself. While the current user has OpenStation off the link reads
9 * "Turn on OpenStation" and points at the portal, which auto-enables
10 * (through `openstation_portal_auto_enable`) and lands in the shell;
11 * once they are on it reads "Open OpenStation" and points at the
12 * shell screen. The portal's same-origin check accepts a click from
13 * `plugins.php`.
14 *
15 * Not inside the shell. There `plugins.php` is a window, a chromeless
16 * iframe, and both targets are whole-page destinations: followed from
17 * the row they would load the shell screen inside one of its own
18 * windows, which cannot paint there. Someone reading the row in a
19 * window is already where the link goes.
20 *
21 * @package OpenStation
22 */
23
24 defined( 'ABSPATH' ) || exit;
25
26 /**
27 * Prepends the row action.
28 *
29 * Gated on `read`, the toggle's own capability, so the link never
30 * offers what `openstation_ajax_save()` would refuse.
31 *
32 * @param string[] $links Existing row action links (HTML strings).
33 * @return string[]
34 */
35 function openstation_plugin_row_action_links( $links ) {
36 if ( ! is_array( $links ) ) {
37 $links = array();
38 }
39 if ( ! current_user_can( 'read' ) ) {
40 return $links;
41 }
42 if ( openstation_is_chromeless_request() ) {
43 return $links;
44 }
45
46 if ( openstation_is_enabled() ) {
47 $link = sprintf(
48 '<a href="%s">%s</a>',
49 esc_url( openstation_shell_url() ),
50 esc_html__( 'Open OpenStation', 'desktop-mode' )
51 );
52 } else {
53 $link = sprintf(
54 '<a href="%s">%s</a>',
55 esc_url( openstation_portal_url() ),
56 esc_html__( 'Turn on OpenStation', 'desktop-mode' )
57 );
58 }
59
60 return array_merge( array( 'openstation' => $link ), $links );
61 }
62 add_filter( 'plugin_action_links_' . plugin_basename( OPENSTATION_FILE ), 'openstation_plugin_row_action_links' );
63 add_filter( 'network_admin_plugin_action_links_' . plugin_basename( OPENSTATION_FILE ), 'openstation_plugin_row_action_links' );
64