PluginProbe
Plausible Analytics / trunk
Plausible Analytics vtrunk
2.6.1 2.6.0 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 All 52 releases
plausible-analytics / src / Admin / Filters.php

Filters.php in Plausible Analytics trunk, at src/Admin/Filters.php

75 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plausible Analytics | Admin Filters.
4 *
5 * @since 1.0.0
6 * @package WordPress
7 * @subpackage Plausible Analytics
8 */
9
10 namespace Plausible\Analytics\WP\Admin;
11
12 class Filters {
13 /**
14 * Constructor.
15 *
16 * @since 1.0.0
17 * @return void
18 */
19 public function __construct() {
20 add_filter( 'admin_footer_text', [ $this, 'add_admin_footer_text' ] );
21 add_filter( 'plugin_action_links_' . PLAUSIBLE_ANALYTICS_PLUGIN_BASENAME, [ $this, 'add_plugin_action_links' ] );
22 }
23
24 /**
25 * Add rating links to the admin dashboard.
26 *
27 * @param string $footer_text The existing footer text.
28 *
29 * @return string
30 */
31 public function add_admin_footer_text( $footer_text ) {
32 $current_screen = get_current_screen();
33
34 if ( true === stristr( $current_screen->base, 'plausible-analytics' ) ) {
35 return sprintf(
36 /* translators: %s: Link to 5 star rating */ __(
37 'If you like <strong>Plausible Analytics</strong> please leave us a %s rating. It takes a minute and helps a lot. Thanks in advance!',
38 'plausible-analytics'
39 ),
40 '<a href="https://wordpress.org/support/view/plugin-reviews/plausible-analytics?filter=5#postform" target="_blank" class="plausible-analytics-rating-link" style="text-decoration:none;" data-rated="' .
41 esc_attr__( 'Thanks :)', 'plausible-analytics' ) .
42 '">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
43 );
44 }
45
46 return $footer_text;
47 }
48
49 /**
50 * Plugin page action links.
51 *
52 * @since 1.0.0
53 *
54 * @param array $actions An array of plugin action links.
55 *
56 * @return array
57 */
58 public function add_plugin_action_links( $actions ) {
59 $new_actions = [
60 'settings' => sprintf(
61 '<a href="%1$s">%2$s</a>',
62 admin_url( 'admin.php?page=plausible_analytics' ),
63 esc_html__( 'Settings', 'plausible-analytics' )
64 ),
65 'support' => sprintf(
66 '<a target="_blank" href="%1$s">%2$s</a>',
67 esc_url_raw( 'https://wordpress.org/support/plugin/plausible-analytics/' ),
68 esc_html__( 'Support', 'plausible-analytics' )
69 ),
70 ];
71
72 return array_merge( $new_actions, $actions );
73 }
74 }
75