PluginProbe ʕ •ᴥ•ʔ
Admin Help Docs / trunk
Admin Help Docs vtrunk
2.0.1.1 trunk 1.4.3.2 2.0.0 2.0.0.1 2.0.0.2 2.0.1
admin-help-docs / inc / plugins-page.php
admin-help-docs / inc Last commit date
css 1 month ago docs 3 months ago img 3 months ago js 3 months ago tabs 3 months ago api.php 3 months ago cleanup.php 3 months ago colors.php 1 month ago deprecated.php 3 months ago header.php 3 months ago helpers.php 1 month ago index.php 3 months ago menu.php 3 months ago plugins-page.php 3 months ago post-type-help-doc-imports.php 3 months ago post-type-help-docs.php 1 month ago shortcodes.php 1 month ago taxonomy-folders.php 3 months ago
plugins-page.php
92 lines
1 <?php
2 /**
3 * Plugins Page
4 */
5
6 namespace PluginRx\AdminHelpDocs;
7
8 if ( ! defined( 'ABSPATH' ) ) exit;
9
10 class PluginsPage {
11
12 /**
13 * @var string Path to the main plugin file for metadata retrieval
14 */
15 private $plugin_file = 'admin-help-docs/admin-help-docs.php';
16
17
18 /**
19 * Constructor
20 */
21 public function __construct() {
22 add_filter( 'plugin_action_links_' . $this->plugin_file, [ $this, 'settings_link' ] );
23 add_filter( 'plugin_row_meta', [ $this, 'meta_links' ], 10, 2 );
24 } // End __construct()
25
26
27 /**
28 * Add a "Settings" link to the plugin's action links on the Plugins page.
29 *
30 * @param array $links Existing action links for the plugin.
31 * @return array Modified action links with the "Settings" link added.
32 */
33 public function settings_link( $links ) {
34 $url = Bootstrap::tab_url( 'settings' );
35
36 $settings_link = sprintf(
37 '<a href="%s">%s</a>',
38 esc_url( $url ),
39 esc_html__( 'Settings', 'admin-help-docs' )
40 );
41
42 array_unshift( $links, $settings_link );
43
44 return $links;
45 } // End settings_link()
46
47
48 /**
49 * Add links to plugin row
50 *
51 * @param array $links
52 * @return array
53 */
54 public function meta_links( $links, $file ) {
55 if ( $this->plugin_file == $file ) {
56 $text_domain = Bootstrap::textdomain();
57 $plugin_name = Bootstrap::name();
58 $base_url = Bootstrap::author_uri();
59
60 $our_links = [
61 'guide' => [
62 'label' => __( 'How-To Guide', 'admin-help-docs' ),
63 'url' => "{$base_url}guide/plugin/{$text_domain}",
64 ],
65 'docs' => [
66 'label' => __( 'Developer Docs', 'admin-help-docs' ),
67 'url' => "{$base_url}docs/plugin/{$text_domain}",
68 ],
69 'support' => [
70 'label' => __( 'Support', 'admin-help-docs' ),
71 'url' => "{$base_url}support/plugin/{$text_domain}",
72 ],
73 ];
74
75 foreach ( $our_links as $key => $link ) {
76 $aria_label = sprintf(
77 // translators: %1$s: Link label, %2$s: Plugin name
78 __( '%1$s for %2$s', 'admin-help-docs' ),
79 $link[ 'label' ],
80 $plugin_name
81 );
82 $links[ $key ] = '<a href="' . esc_url( $link[ 'url' ] ) . '" target="_blank" aria-label="' . esc_attr( $aria_label ) . '">' . esc_html( $link[ 'label' ] ) . '</a>';
83 }
84 }
85
86 return (array) $links;
87 } // End meta()
88
89 }
90
91
92 new PluginsPage();