-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathclass-admin-footer-text.php
More file actions
89 lines (80 loc) · 2.81 KB
/
Copy pathclass-admin-footer-text.php
File metadata and controls
89 lines (80 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* Filters the admin_footer_text on Accessibility Checker settings pages only.
*
* @package Accessibility_Checker\Admin
*/
namespace EqualizeDigital\AccessibilityChecker\Admin;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Admin_Footer_Text
*
* Handles filtering of admin footer text on Accessibility Checker settings pages.
*
* @since 1.27.0
*/
class Admin_Footer_Text {
/**
* Initialize the admin footer text filter.
*
* @since 1.27.0
* @return void
*/
public function init() {
add_filter( 'admin_footer_text', [ $this, 'filter_footer_text' ] );
}
/**
* Filter the admin footer text on our settings pages only.
*
* @since 1.27.0
* @param string $footer_text The current footer text.
* @return string
*/
public function filter_footer_text( $footer_text ) {
if ( ! $this->is_settings_page() ) {
return $footer_text;
}
if ( $this->is_pro_active() ) {
return sprintf(
/* translators: %1$s: opening link tag, %2$s: closing link tag */
esc_html__( 'Enjoying Accessibility Checker? %1$sPlease leave us a ★★★★★ rating.%2$s We really appreciate your support!', 'accessibility-checker' ),
'<a href="' . esc_url( 'https://wordpress.org/support/plugin/accessibility-checker/reviews/#new-post' ) . '" target="_blank" aria-label="' . esc_attr__( 'Please leave us a five star rating (opens in new window)', 'accessibility-checker' ) . '">',
'</a>'
);
}
$pro_link = edac_link_wrapper( 'https://equalizedigital.com/accessibility-checker/pricing/', 'admin-footer', 'admin-footer-text', false );
return sprintf(
/* translators: %1$s: opening link tag, %2$s: closing link tag */
esc_html__( 'Want to do more with Accessibility Checker? %1$sUnlock Pro Features%2$s', 'accessibility-checker' ),
'<a href="' . esc_url( $pro_link ) . '" target="_blank" aria-label="' . esc_attr__( 'Unlock Pro Features (opens in new window)', 'accessibility-checker' ) . '">',
'</a>'
);
}
/**
* Check if we are on the Accessibility Checker settings page.
*
* @since 1.27.0
* @return bool
*/
protected function is_settings_page() {
// Check if we're on an admin page and have a page parameter.
if ( ! is_admin() || ! isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return false;
}
// Sanitize and check if it's an accessibility checker page.
$page = sanitize_text_field( wp_unslash( $_GET['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return strpos( $page, 'accessibility_checker' ) === 0;
}
/**
* Check if Pro is active with a valid license.
*
* @since 1.27.0
* @return bool
*/
protected function is_pro_active() {
// Pro is active if EDACP_VERSION is defined and license is valid.
return defined( 'EDACP_VERSION' ) && defined( 'EDAC_KEY_VALID' ) && EDAC_KEY_VALID;
}
}