Plugin Directory

source: codepress-admin-columns/trunk/classes/PluginActionLinks.php @ 2293580

Last change on this file since 2293580 was 2293580, checked in by tschutter, 5 years ago

trunk

File size: 1.2 KB
Line 
1<?php
2
3namespace AC;
4
5use AC\Admin\Page\Columns;
6
7class PluginActionLinks implements Registrable {
8
9        /**
10         * @var string
11         */
12        private $basename;
13
14        public function __construct( $basename ) {
15                $this->basename = $basename;
16        }
17
18        public function register() {
19                add_filter( 'plugin_action_links', [ $this, 'add_settings_link' ], 1, 2 );
20                add_filter( 'network_admin_plugin_action_links', [ $this, 'add_settings_link' ], 1, 2 );
21        }
22
23        /**
24         * Add a settings link to the Admin Columns entry in the plugin overview screen
25         *
26         * @param array  $links
27         * @param string $file
28         *
29         * @return array
30         * @see   filter:plugin_action_links
31         * @since 1.0
32         */
33        public function add_settings_link( $links, $file ) {
34                if ( $file !== $this->basename ) {
35                        return $links;
36                }
37
38                array_unshift( $links, sprintf( '<a href="%s">%s</a>', esc_url( ac_get_admin_url( Columns::NAME ) ), __( 'Settings', 'codepress-admin-columns' ) ) );
39
40                if ( ! ac_is_pro_active() ) {
41                        $links[] = sprintf(
42                                '<a href="%s" target="_blank">%s</a>',
43                                esc_url( ac_get_site_utm_url( 'admin-columns-pro', 'upgrade' ) ),
44                                sprintf(
45                                        '<span style="font-weight: bold;">%s</span>',
46                                        __( 'Go Pro', 'codepress-admin-columns' )
47                                )
48                        );
49                }
50
51                return $links;
52        }
53
54}
Note: See TracBrowser for help on using the repository browser.