PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 2.0.3
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v2.0.3
3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / includes / admin / class-evf-admin.php
everest-forms / includes / admin Last commit date
builder 2 years ago plugin-updates 8 years ago settings 2 years ago views 2 years ago class-evf-admin-addons.php 4 years ago class-evf-admin-assets.php 2 years ago class-evf-admin-builder.php 7 years ago class-evf-admin-deactivation-feedback.php 3 years ago class-evf-admin-editor.php 4 years ago class-evf-admin-entries-table-list.php 3 years ago class-evf-admin-entries.php 4 years ago class-evf-admin-form-templates.php 3 years ago class-evf-admin-forms-table-list.php 3 years ago class-evf-admin-forms.php 3 years ago class-evf-admin-import-export.php 4 years ago class-evf-admin-menus.php 2 years ago class-evf-admin-notices.php 3 years ago class-evf-admin-settings.php 2 years ago class-evf-admin-tools.php 4 years ago class-evf-admin-welcome.php 2 years ago class-evf-admin.php 2 years ago evf-admin-functions.php 3 years ago
class-evf-admin.php
240 lines
1 <?php
2 /**
3 * EverestForms Admin
4 *
5 * @package EverestForms\Admin
6 * @version 1.0.0
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * EVF_Admin class.
13 */
14 class EVF_Admin {
15
16 /**
17 * Constructor.
18 */
19 public function __construct() {
20 add_action( 'init', array( $this, 'includes' ) );
21 add_action( 'admin_init', array( $this, 'buffer' ), 1 );
22 add_action( 'admin_init', array( $this, 'addon_actions' ) );
23 add_action( 'admin_init', array( $this, 'template_actions' ) );
24 add_action( 'admin_init', array( $this, 'admin_redirects' ) );
25 add_action( 'admin_footer', 'evf_print_js', 25 );
26 add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
27 add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 );
28 }
29
30 /**
31 * Output buffering allows admin screens to make redirects later on.
32 */
33 public function buffer() {
34 ob_start();
35 }
36
37 /**
38 * Include any classes we need within admin.
39 */
40 public function includes() {
41 include_once __DIR__ . '/evf-admin-functions.php';
42 include_once __DIR__ . '/class-evf-admin-menus.php';
43 include_once __DIR__ . '/class-evf-admin-notices.php';
44 include_once __DIR__ . '/class-evf-admin-assets.php';
45 include_once __DIR__ . '/class-evf-admin-editor.php';
46 include_once __DIR__ . '/class-evf-admin-forms.php';
47 include_once __DIR__ . '/class-evf-admin-entries.php';
48 include_once __DIR__ . '/class-evf-admin-import-export.php';
49 include_once __DIR__ . '/class-evf-admin-deactivation-feedback.php';
50
51 // Setup/welcome.
52 if ( ! empty( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
53 switch ( $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification
54 case 'evf-welcome':
55 include_once __DIR__ . '/class-evf-admin-welcome.php';
56 break;
57 }
58 }
59 }
60
61 /**
62 * Handle redirects after addon activate/deactivate.
63 */
64 public function addon_actions() {
65 if ( isset( $_GET['page'], $_REQUEST['action'] ) && 'evf-addons' === $_GET['page'] ) {
66 $action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) );
67 $plugin = isset( $_REQUEST['plugin'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['plugin'] ) ) : false;
68
69 if ( 'evf-addons-refresh' === $action ) {
70 if ( empty( $_GET['evf-addons-nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_GET['evf-addons-nonce'] ) ), 'refresh' ) ) {
71 wp_die( esc_html_e( 'Could not verify nonce', 'everest-forms' ) );
72 }
73
74 foreach ( array( 'evf_pro_license_plan', 'evf_addons_sections', 'evf_extensions_section' ) as $transient ) {
75 delete_transient( $transient );
76 }
77 }
78
79 if ( $plugin && in_array( $action, array( 'activate', 'deactivate' ), true ) ) {
80
81 if ( 'activate' === $action ) {
82 if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
83 wp_die( esc_html__( 'Sorry, you are not allowed to activate this plugin.', 'everest-forms' ) );
84 }
85
86 check_admin_referer( 'activate-plugin_' . $plugin );
87
88 activate_plugin( $plugin );
89 } elseif ( 'deactivate' === $action ) {
90 if ( ! current_user_can( 'deactivate_plugins' ) ) {
91 wp_die( esc_html__( 'Sorry, you are not allowed to deactivate plugins for this site.', 'everest-forms' ) );
92 }
93
94 check_admin_referer( 'deactivate-plugin_' . $plugin );
95
96 deactivate_plugins( $plugin );
97 }
98 }
99
100 // Redirect to the add-ons page.
101 wp_safe_redirect( admin_url( 'admin.php?page=evf-addons' ) );
102 exit;
103 }
104 }
105
106 /**
107 * Handle redirects after template refresh.
108 */
109 public function template_actions() {
110 if ( isset( $_GET['page'], $_REQUEST['action'] ) && 'evf-builder' === $_GET['page'] ) {
111 $action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) );
112 $templates = EVF_Admin_Form_Templates::get_template_data();
113 $templates = is_array( $templates ) ? $templates : array();
114 if ( 'evf-template-refresh' === $action ) {
115 if ( empty( $_GET['evf-template-nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_GET['evf-template-nonce'] ) ), 'refresh' ) ) {
116 wp_die( esc_html_e( 'Could not verify nonce', 'everest-forms' ) );
117 }
118
119 foreach ( array( 'evf_pro_license_plan', 'evf_template_sections', 'evf_template_section', 'evf_template_section_list' ) as $transient ) {
120 delete_transient( $transient );
121 }
122
123 // Redirect to the builder page normally.
124 wp_safe_redirect( admin_url( 'admin.php?page=evf-builder&create-form=1' ) );
125 exit;
126 }
127 }
128 }
129
130 /**
131 * Handle redirects to setup/welcome page after install and updates.
132 *
133 * For setup wizard, transient must be present, the user must have access rights, and we must ignore the network/bulk plugin updaters.
134 */
135 public function admin_redirects() {
136 // Nonced plugin install redirects (whitelisted).
137 if ( ! empty( $_GET['evf-install-plugin-redirect'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
138 $plugin_slug = evf_clean( esc_url_raw( wp_unslash( $_GET['evf-install-plugin-redirect'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.
139
140 $url = admin_url( 'plugin-install.php?tab=search&type=term&s=' . $plugin_slug );
141 wp_safe_redirect( $url );
142 exit;
143 }
144
145 // Setup wizard redirect.
146 if ( get_transient( '_evf_activation_redirect' ) && apply_filters( 'everest_forms_show_welcome_page', true ) ) {
147 $do_redirect = true;
148 $current_page = isset( $_GET['page'] ) ? evf_clean( sanitize_text_field( wp_unslash( $_GET['page'] ) ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification
149
150 // On these pages, or during these events, postpone the redirect.
151 if ( wp_doing_ajax() || is_network_admin() || ! current_user_can( 'manage_everest_forms' ) ) {
152 $do_redirect = false;
153 }
154
155 // On these pages, or during these events, disable the redirect.
156 if ( 'evf-welcome' === $current_page || EVF_Admin_Notices::has_notice( 'install' ) || apply_filters( 'everest_forms_prevent_automatic_wizard_redirect', false ) || isset( $_GET['activate-multi'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
157 delete_transient( '_evf_activation_redirect' );
158 $do_redirect = false;
159 }
160
161 if ( $do_redirect ) {
162 delete_transient( '_evf_activation_redirect' );
163 wp_safe_redirect( admin_url( 'index.php?page=evf-welcome' ) );
164 exit;
165 }
166 }
167 }
168
169 /**
170 * Change the admin footer text on EverestForms admin pages.
171 *
172 * @since 1.0.0
173 * @param string $footer_text Footer text.
174 * @return string
175 */
176 public function admin_footer_text( $footer_text ) {
177 if ( ! current_user_can( 'manage_everest_forms' ) || ! function_exists( 'evf_get_screen_ids' ) ) {
178 return $footer_text;
179 }
180 $current_screen = get_current_screen();
181
182 // Removing footer text from builder page.
183 if ( 'everest-forms_page_evf-builder' === $current_screen->id && isset( $_GET['form_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
184 add_filter(
185 'update_footer',
186 function () {
187 return '';
188 }
189 );
190 return '';
191 }
192
193 $evf_pages = evf_get_screen_ids();
194 // Check to make sure we're on a EverestForms admin page.
195 if ( isset( $current_screen->id ) && apply_filters( 'everest_forms_display_admin_footer_text', in_array( $current_screen->id, $evf_pages, true ) ) ) {
196 // Change the footer text.
197 if ( ! get_option( 'everest_forms_admin_footer_text_rated' ) ) {
198 $footer_text = sprintf(
199 /* translators: 1: EverestForms 2:: five stars */
200 esc_html__( 'If you like %1$s please leave us a %2$s rating. A huge thanks in advance!', 'everest-forms' ),
201 sprintf( '<strong>%s</strong>', esc_html__( 'Everest Forms', 'everest-forms' ) ),
202 '<a href="https://wordpress.org/support/plugin/everest-forms/reviews?rate=5#new-post" target="_blank" class="evf-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'everest-forms' ) . '">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
203 );
204 evf_enqueue_js(
205 "
206 jQuery( 'a.evf-rating-link' ).on( 'click', function() {
207 jQuery.post( '" . evf()->ajax_url() . "', { action: 'everest_forms_rated' } );
208 jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) );
209 });
210 "
211 );
212 } else {
213 $footer_text = esc_html__( 'Thank you for creating with Everest Forms.', 'everest-forms' );
214 }
215 }
216
217 return $footer_text;
218 }
219
220 /**
221 * Add body classes for Everest builder.
222 *
223 * @param array $classes Admin body classes.
224 * @return array
225 */
226 public function admin_body_class( $classes ) {
227 $screen = get_current_screen();
228 $screen_id = $screen ? $screen->id : '';
229
230 // Check to make sure we're on a EverestForms builder page.
231 if ( ( isset( $_GET['form_id'] ) || isset( $_GET['create-form'] ) ) && in_array( $screen_id, array( 'everest-forms_page_evf-builder' ), true ) ) { // phpcs:ignore WordPress.Security.NonceVerification
232 $classes = isset( $_GET['form_id'] ) ? 'everest-forms-builder' : 'everest-forms-builder-setup'; // phpcs:ignore WordPress.Security.NonceVerification
233 }
234
235 return $classes;
236 }
237 }
238
239 return new EVF_Admin();
240