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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
<?php
namespace WPForms\Lite\Admin;
/** * WPForms admin pages changes and enhancements to educate Lite users on what is available in WPForms Pro. * * @since 1.5.7 */ class Education {
/** * WPForms admin page slug. * * @since 1.5.7 * * @var string */ public $page;
/** * Constructor. * * @since 1.5.7 */ public function __construct() {
$this->hooks(); }
/** * Hooks. * * @since 1.5.7 */ public function hooks() {
if ( ! \wpforms_is_admin_page() && ! \wp_doing_ajax() ) { return; }
if ( ! \apply_filters( 'wpforms_lite_admin_education', true ) ) { return; }
// Admin page slug. $this->page = str_replace( 'wpforms-', '', filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING ) );
\add_action( 'admin_init', array( $this, 'notice_bar_init' ) ); }
/** * Notice bar init. * * @since 1.5.7 */ public function notice_bar_init() {
\add_action( 'admin_enqueue_scripts', array( $this, 'enqueues' ) ); \add_action( 'wpforms_admin_header_before', array( $this, 'notice_bar_display' ) ); \add_action( 'wp_ajax_wpforms_notice_bar_dismiss', array( $this, 'notice_bar_ajax_dismiss' ) ); }
/** * Notice bar display message. * * @since 1.5.7 */ public function notice_bar_display() {
$current_user = \wp_get_current_user(); $dismissed = \get_user_meta( $current_user->ID, 'wpforms_dismissed', true );
if ( ! empty( $dismissed['lite-notice-bar'] ) ) { return; }
$msg = sprintf( /* translators: %s - WPForms.com Upgrade page URL. */ __( 'You’re using WPForms Lite. To unlock more features consider <a href="%s" target="_blank" rel="noopener noreferrer">upgrading to Pro</a>.', 'wpforms-lite' ), \wpforms_admin_upgrade_link( 'notice-bar' ) );
printf( '<div id="wpforms-notice-bar"> <span class="wpforms-notice-bar-message">%s</span> <button type="button" class="dismiss" title="%s" data-page="%s" /> </div>', \wp_kses( $msg, array( 'a' => array( 'href' => array(), 'rel' => array(), 'target' => array(), ), ) ), \esc_attr__( 'Dismiss this message.', 'wpforms-lite' ), \esc_attr( $this->page ) ); }
/** * Ajax handler for dismissing DYK notices. * * @since 1.5.7 */ public function notice_bar_ajax_dismiss() {
// Run a security check. \check_ajax_referer( 'wpforms-admin', 'nonce' );
// Check for permissions. if ( ! \wpforms_current_user_can() ) { \wp_send_json_error( array( 'error' => \esc_html__( 'You do not have permission to perform this action.', 'wpforms-lite' ), ) ); }
$current_user = \wp_get_current_user(); $dismissed = \get_user_meta( $current_user->ID, 'wpforms_dismissed', true );
if ( empty( $dismissed ) ) { $dismissed = array(); }
$dismissed['lite-notice-bar'] = time();
\update_user_meta( $current_user->ID, 'wpforms_dismissed', $dismissed ); \wp_send_json_success(); }
/** * Load enqueues. * * @since 1.5.7 */ public function enqueues() {
$min = \wpforms_get_min_suffix();
\wp_enqueue_script( 'wpforms-lite-admin-education', \WPFORMS_PLUGIN_URL . "lite/assets/js/admin/education{$min}.js", array( 'jquery' ), \WPFORMS_VERSION, false ); } }
|