PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 1.6.3
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v1.6.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 6 years ago plugin-updates 8 years ago settings 6 years ago views 6 years ago class-evf-admin-addons.php 6 years ago class-evf-admin-assets.php 6 years ago class-evf-admin-builder.php 7 years ago class-evf-admin-editor.php 6 years ago class-evf-admin-entries-table-list.php 6 years ago class-evf-admin-entries.php 6 years ago class-evf-admin-forms-table-list.php 6 years ago class-evf-admin-forms.php 6 years ago class-evf-admin-import-export.php 6 years ago class-evf-admin-menus.php 6 years ago class-evf-admin-notices.php 6 years ago class-evf-admin-settings.php 6 years ago class-evf-admin-tools.php 6 years ago class-evf-admin-welcome.php 6 years ago class-evf-admin.php 6 years ago evf-admin-functions.php 6 years ago
class-evf-admin.php
228 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 dirname( __FILE__ ) . '/evf-admin-functions.php';
42 include_once dirname( __FILE__ ) . '/class-evf-admin-menus.php';
43 include_once dirname( __FILE__ ) . '/class-evf-admin-notices.php';
44 include_once dirname( __FILE__ ) . '/class-evf-admin-assets.php';
45 include_once dirname( __FILE__ ) . '/class-evf-admin-editor.php';
46 include_once dirname( __FILE__ ) . '/class-evf-admin-forms.php';
47 include_once dirname( __FILE__ ) . '/class-evf-admin-entries.php';
48 include_once dirname( __FILE__ ) . '/class-evf-admin-import-export.php';
49
50 // Setup/welcome.
51 if ( ! empty( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
52 switch ( $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification
53 case 'evf-welcome':
54 include_once dirname( __FILE__ ) . '/class-evf-admin-welcome.php';
55 break;
56 }
57 }
58 }
59
60 /**
61 * Handle redirects after addon activate/deactivate.
62 */
63 public function addon_actions() {
64 if ( isset( $_GET['page'], $_REQUEST['action'] ) && 'evf-addons' === $_GET['page'] ) {
65 $action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) );
66 $plugin = isset( $_REQUEST['plugin'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['plugin'] ) ) : false;
67
68 if ( 'evf-addons-refresh' === $action ) {
69 if ( empty( $_GET['evf-addons-nonce'] ) || ! wp_verify_nonce( wp_unslash( $_GET['evf-addons-nonce'] ), 'refresh' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
70 wp_die( esc_html_e( 'Could not verify nonce', 'everest-forms' ) );
71 }
72
73 foreach ( array( 'evf_pro_license_plan', 'evf_addons_sections', 'evf_extensions_section' ) as $transient ) {
74 delete_transient( $transient );
75 }
76 }
77
78 if ( $plugin && in_array( $action, array( 'activate', 'deactivate' ), true ) ) {
79
80 if ( 'activate' === $action ) {
81 if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
82 wp_die( esc_html__( 'Sorry, you are not allowed to activate this plugin.', 'everest-forms' ) );
83 }
84
85 check_admin_referer( 'activate-plugin_' . $plugin );
86
87 activate_plugin( $plugin );
88 } elseif ( 'deactivate' === $action ) {
89 if ( ! current_user_can( 'deactivate_plugins' ) ) {
90 wp_die( esc_html__( 'Sorry, you are not allowed to deactivate plugins for this site.', 'everest-forms' ) );
91 }
92
93 check_admin_referer( 'deactivate-plugin_' . $plugin );
94
95 deactivate_plugins( $plugin );
96 }
97 }
98
99 // Redirect to the add-ons page.
100 wp_safe_redirect( admin_url( 'admin.php?page=evf-addons' ) );
101 exit;
102 }
103 }
104
105 /**
106 * Handle redirects after template refresh.
107 */
108 public function template_actions() {
109 if ( isset( $_GET['page'], $_REQUEST['action'] ) && 'evf-builder' === $_GET['page'] ) {
110 $action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) );
111 $raw_templates = wp_safe_remote_get( 'https://raw.githubusercontent.com/wpeverest/extensions-json/master/everest-forms/templates/all_templates.json' );
112
113 if ( 'evf-template-refresh' === $action && ! is_wp_error( $raw_templates ) ) {
114 if ( empty( $_GET['evf-template-nonce'] ) || ! wp_verify_nonce( wp_unslash( $_GET['evf-template-nonce'] ), 'refresh' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
115 wp_die( esc_html_e( 'Could not verify nonce', 'everest-forms' ) );
116 }
117
118 foreach ( array( 'evf_pro_license_plan', 'evf_template_sections', 'evf_template_section' ) as $transient ) {
119 delete_transient( $transient );
120 }
121
122 // Redirect to the builder page normally.
123 wp_safe_redirect( admin_url( 'admin.php?page=evf-builder&create-form=1' ) );
124 exit;
125 }
126 }
127 }
128
129 /**
130 * Handle redirects to setup/welcome page after install and updates.
131 *
132 * For setup wizard, transient must be present, the user must have access rights, and we must ignore the network/bulk plugin updaters.
133 */
134 public function admin_redirects() {
135 // Nonced plugin install redirects (whitelisted).
136 if ( ! empty( $_GET['evf-install-plugin-redirect'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
137 $plugin_slug = evf_clean( wp_unslash( $_GET['evf-install-plugin-redirect'] ) ); // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
138
139 $url = admin_url( 'plugin-install.php?tab=search&type=term&s=' . $plugin_slug );
140 wp_safe_redirect( $url );
141 exit;
142 }
143
144 // Setup wizard redirect.
145 if ( get_transient( '_evf_activation_redirect' ) && apply_filters( 'everest_forms_show_welcome_page', true ) ) {
146 $do_redirect = true;
147 $current_page = isset( $_GET['page'] ) ? evf_clean( wp_unslash( $_GET['page'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
148
149 // On these pages, or during these events, postpone the redirect.
150 if ( wp_doing_ajax() || is_network_admin() || ! current_user_can( 'manage_everest_forms' ) ) {
151 $do_redirect = false;
152 }
153
154 // On these pages, or during these events, disable the redirect.
155 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
156 delete_transient( '_evf_activation_redirect' );
157 $do_redirect = false;
158 }
159
160 if ( $do_redirect ) {
161 delete_transient( '_evf_activation_redirect' );
162 wp_safe_redirect( admin_url( 'index.php?page=evf-welcome' ) );
163 exit;
164 }
165 }
166 }
167
168 /**
169 * Change the admin footer text on EverestForms admin pages.
170 *
171 * @since 1.0.0
172 * @param string $footer_text Footer text.
173 * @return string
174 */
175 public function admin_footer_text( $footer_text ) {
176 if ( ! current_user_can( 'manage_everest_forms' ) || ! function_exists( 'evf_get_screen_ids' ) ) {
177 return $footer_text;
178 }
179 $current_screen = get_current_screen();
180 $evf_pages = evf_get_screen_ids();
181
182 // Check to make sure we're on a EverestForms admin page.
183 if ( isset( $current_screen->id ) && apply_filters( 'everest_forms_display_admin_footer_text', in_array( $current_screen->id, $evf_pages, true ) ) ) {
184 // Change the footer text.
185 if ( ! get_option( 'everest_forms_admin_footer_text_rated' ) ) {
186 $footer_text = sprintf(
187 /* translators: 1: EverestForms 2:: five stars */
188 esc_html__( 'If you like %1$s please leave us a %2$s rating. A huge thanks in advance!', 'everest-forms' ),
189 sprintf( '<strong>%s</strong>', esc_html__( 'Everest Forms', 'everest-forms' ) ),
190 '<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>'
191 );
192 evf_enqueue_js(
193 "
194 jQuery( 'a.evf-rating-link' ).click( function() {
195 jQuery.post( '" . evf()->ajax_url() . "', { action: 'everest_forms_rated' } );
196 jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) );
197 });
198 "
199 );
200 } else {
201 $footer_text = esc_html__( 'Thank you for creating with Everest Forms.', 'everest-forms' );
202 }
203 }
204
205 return $footer_text;
206 }
207
208 /**
209 * Add body classes for Everest builder.
210 *
211 * @param array $classes Admin body classes.
212 * @return array
213 */
214 public function admin_body_class( $classes ) {
215 $screen = get_current_screen();
216 $screen_id = $screen ? $screen->id : '';
217
218 // Check to make sure we're on a EverestForms builder page.
219 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
220 $classes = isset( $_GET['form_id'] ) ? 'everest-forms-builder' : 'everest-forms-builder-setup'; // phpcs:ignore WordPress.Security.NonceVerification
221 }
222
223 return $classes;
224 }
225 }
226
227 return new EVF_Admin();
228