| 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 |
'">★★★★★</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 |
|