| 1 |
<?php |
| 2 |
/** |
| 3 |
* UI: plugins actions class |
| 4 |
* |
| 5 |
* @package Parsely |
| 6 |
* @since 2.6.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
declare(strict_types=1); |
| 10 |
|
| 11 |
namespace Parsely\UI; |
| 12 |
|
| 13 |
use Parsely\Parsely; |
| 14 |
|
| 15 |
use const Parsely\PARSELY_FILE; |
| 16 |
|
| 17 |
/** |
| 18 |
* User Interface changes for the plugins actions. |
| 19 |
* |
| 20 |
* @since 2.6.0 |
| 21 |
*/ |
| 22 |
final class Plugins_Actions { |
| 23 |
|
| 24 |
/** |
| 25 |
* Registers action and filter hook callbacks. |
| 26 |
*/ |
| 27 |
public function run(): void { |
| 28 |
add_filter( 'plugin_action_links_' . plugin_basename( PARSELY_FILE ), array( $this, 'add_plugin_meta_links' ) ); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Adds a 'Settings' action link to the Plugins screen in WP admin. |
| 33 |
* |
| 34 |
* @param array $actions An array of plugin action links. By default, this can include 'activate', |
| 35 |
* 'deactivate', and 'delete'. With Multisite active this can also include |
| 36 |
* 'network_active' and 'network_only' items. |
| 37 |
* @return array |
| 38 |
*/ |
| 39 |
public function add_plugin_meta_links( array $actions ): array { |
| 40 |
if ( is_multisite() && is_plugin_active_for_network( plugin_basename( PARSELY_FILE ) ) ) { |
| 41 |
$actions['siteslist'] = sprintf( |
| 42 |
'<a href="%s">%s</a>', |
| 43 |
esc_url( network_admin_url( 'sites.php' ) ), |
| 44 |
esc_html__( 'Sites', 'wp-parsely' ) |
| 45 |
); |
| 46 |
} |
| 47 |
|
| 48 |
$actions['settings'] = sprintf( |
| 49 |
'<a href="%s">%s</a>', |
| 50 |
esc_url( Parsely::get_settings_url() ), |
| 51 |
esc_html__( 'Settings', 'wp-parsely' ) |
| 52 |
); |
| 53 |
|
| 54 |
$actions['documentation'] = sprintf( |
| 55 |
'<a href="%s">%s</a>', |
| 56 |
'https://www.parse.ly/help/integration/wordpress', |
| 57 |
esc_html__( 'Documentation', 'wp-parsely' ) |
| 58 |
); |
| 59 |
|
| 60 |
return $actions; |
| 61 |
} |
| 62 |
} |
| 63 |
|