PluginProbe ʕ •ᴥ•ʔ
Admin Help Docs / 2.0.3
Admin Help Docs v2.0.3
2.0.3 2.0.2 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 18 hours ago docs 18 hours ago img 18 hours ago js 18 hours ago tabs 18 hours ago api.php 18 hours ago cleanup.php 18 hours ago colors.php 18 hours ago deprecated.php 18 hours ago header.php 18 hours ago helpers.php 18 hours ago index.php 18 hours ago menu.php 18 hours ago plugins-page.php 18 hours ago post-type-help-doc-imports.php 18 hours ago post-type-help-docs.php 18 hours ago shortcodes.php 18 hours ago taxonomy-folders.php 18 hours 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();