PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.10.8
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.10.8
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / includes / core / classes / class-wpfnl-admin-menus.php

class-wpfnl-admin-menus.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.10.8, at includes/core/classes/class-wpfnl-admin-menus.php

528 lines 14.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin menus
4 *
5 * @package
6 */
7 namespace WPFunnels\Menu;
8
9 use WPFunnels\Admin\SetupWizard;
10 use WPFunnels\Wpfnl;
11 use WPFunnels\Wpfnl_functions;
12
13 /**
14 * Class Wpfnl_Menus
15 *
16 * @package Wpfnl
17 */
18 class Wpfnl_Menus
19 {
20 public function __construct()
21 {
22 add_action('admin_menu', [$this, 'register_plugin_menus']);
23 add_filter('admin_head', [$this, 'remove_submenu'], 10, 2);
24 add_filter('admin_head', [$this, 'remove_notices_from_funnel_window'], 10, 2);
25 add_action('admin_init', [$this, 'disallow_all_step_view']);
26 add_action('admin_footer', [$this, 'doc_link_with_new_page']);
27 add_filter('wpfnl_dashboard_nav_lists', [$this, 'add_store_checkout_nav'], 15, 1);
28
29 if( isset($_GET['page']) && 'edit_funnel' === $_GET['page'] ) {
30 $funnel_id = isset($_GET['id']) ? absint($_GET['id']) : 0;
31 $funnel_type = $funnel_id ? get_post_meta($funnel_id, '_wpfnl_funnel_type', true) : '';
32 if ( 'store_checkout' === $funnel_type ) {
33 add_filter( 'parent_file', function( $parent_file ) {
34 return WPFNL_MAIN_PAGE_SLUG;
35 });
36 add_filter( 'submenu_file', function( $submenu_file ) {
37 return WPFNL_STORE_CHECKOUT_SLUG;
38 });
39 } else {
40 add_filter( "admin_body_class", array($this, 'add_folded_menu_class') );
41 }
42 }
43 }
44
45
46 /**
47 * Register plugin menus and submenus
48 *
49 * @since 1.0.0
50 */
51 public function register_plugin_menus()
52 {
53 $role_permission = Wpfnl_functions::get_general_settings();
54
55 add_menu_page(
56 'WPFunnels',
57 'WPFunnels',
58 Wpfnl_functions::role_permission_to_allow_wpfunnel( $role_permission ),
59 WPFNL_MAIN_PAGE_SLUG,
60 '',
61 WPFNL_DIR_URL . 'admin/assets/images/funnel.svg',
62 6
63 );
64
65
66 // Register dashboard page for WPF
67 add_submenu_page(
68 WPFNL_MAIN_PAGE_SLUG,
69 __('Dashboard', 'wpfnl'),
70 __('Dashboard', 'wpfnl'),
71 'wpf_manage_funnels',
72 WPFNL_MAIN_PAGE_SLUG,
73 [$this, 'render']
74 );
75
76 add_submenu_page(
77 WPFNL_MAIN_PAGE_SLUG,
78 __('Funnels', 'wpfnl'),
79 __('Funnels', 'wpfnl'),
80 Wpfnl_functions::role_permission_to_allow_wpfunnel( $role_permission ),
81 WPFNL_FUNNEL_PAGE_SLUG,
82 [$this, 'render_funnels_page']
83 );
84
85 add_submenu_page(
86 WPFNL_MAIN_PAGE_SLUG,
87 __('Store Checkout', 'wpfnl'),
88 __('Store Checkout', 'wpfnl'),
89 Wpfnl_functions::role_permission_to_allow_wpfunnel( $role_permission ),
90 WPFNL_STORE_CHECKOUT_SLUG,
91 [$this, 'render_store_checkout_page']
92 );
93
94 add_submenu_page(
95 WPFNL_MAIN_PAGE_SLUG,
96 __('Automations', 'wpfnl'),
97 __('Automations', 'wpfnl'),
98 Wpfnl_functions::role_permission_to_allow_wpfunnel( $role_permission ),
99 WPFNL_AUTOMATIONS_SLUG,
100 [$this, 'render_automations_page']
101 );
102
103 $integrations_in_pro = defined( 'WPFNL_PRO_VERSION' ) && version_compare( WPFNL_PRO_VERSION, '2.9.0', '>=' );
104 $legacy_addon_active = is_plugin_active( 'wpfunnels-pro-integrations/wpfunnels-pro-integrations.php' );
105
106 if ( $integrations_in_pro || ! $legacy_addon_active ) {
107 // Pro owns the integrations menu; access is controlled by plan check inside the page renderer.
108 add_submenu_page(
109 WPFNL_MAIN_PAGE_SLUG,
110 __('Integrations', 'wpfnl'),
111 __('Integrations', 'wpfnl'),
112 Wpfnl_functions::role_permission_to_allow_wpfunnel( $role_permission ),
113 WPFNL_INTEGRATIONS_MAIN_PAGE_SLUG,
114 [$this, 'render_integration_page']
115 );
116 } else {
117 /**
118 * After setup menu of WPFunnels.
119 * Legacy fallback for users still running the old addon.
120 *
121 * @since 1.0.0
122 */
123 do_action( 'wpfunnels/after_setup_menu');
124 }
125
126 add_submenu_page(
127 WPFNL_MAIN_PAGE_SLUG,
128 __('Templates', 'wpfnl'),
129 __('Templates', 'wpfnl'),
130 Wpfnl_functions::role_permission_to_allow_wpfunnel( $role_permission ),
131 WPFNL_TEMPLATE_PAGE_SLUG,
132 [$this, 'render_funnel_template_page']
133 );
134
135 // add_submenu_page(
136 // WPFNL_MAIN_PAGE_SLUG,
137 // __('Add-ons', 'wpfnl'),
138 // __('Add-ons', 'wpfnl'),
139 // Wpfnl_functions::role_permission_to_allow_wpfunnel( $role_permission ),
140 // WPFNL_ADDONS_SLUG,
141 // [$this, 'render_addons_page']
142 // );
143
144
145 // Show Integrations menu if WPFunnels Pro Integrations is deactivated
146 if ( ! function_exists( 'is_plugin_active' ) ) {
147 require_once ABSPATH . 'wp-admin/includes/plugin.php';
148 }
149
150 add_submenu_page(
151 WPFNL_MAIN_PAGE_SLUG,
152 __('Settings', 'wpfnl'),
153 __('Settings', 'wpfnl'),
154 Wpfnl_functions::role_permission_to_allow_wpfunnel( $role_permission ),
155 WPFNL_GLOBAL_SETTINGS_SLUG,
156 [$this, 'render_settings_page']
157 );
158
159 // add_submenu_page(
160 // WPFNL_MAIN_PAGE_SLUG,
161 // __('Documentation', 'wpfnl'),
162 // '<span id="wpfnl-documentation">'. __('Documentation', 'wpfnl').'</span>',
163 // Wpfnl_functions::role_permission_to_allow_wpfunnel( $role_permission ),
164 // 'https://getwpfunnels.com/resources/'
165 // );
166
167 add_submenu_page(
168 WPFNL_MAIN_PAGE_SLUG,
169 __('Edit Funnel', 'wpfnl'),
170 __('Edit Funnel', 'wpfnl'),
171 Wpfnl_functions::role_permission_to_allow_wpfunnel( $role_permission ),
172 WPFNL_EDIT_FUNNEL_SLUG,
173 [$this, 'render_edit_funnel_page']
174 );
175
176 add_submenu_page(
177 WPFNL_MAIN_PAGE_SLUG,
178 __('Trash', 'wpfnl'),
179 __('Trash', 'wpfnl'),
180 Wpfnl_functions::role_permission_to_allow_wpfunnel( $role_permission ),
181 WPFNL_TRASH_FUNNEL_SLUG,
182 [$this, 'render_trash_funnel_page']
183 );
184
185 add_submenu_page(
186 WPFNL_MAIN_PAGE_SLUG,
187 __('Request a Feature', 'wpfnl'),
188 '<span id="wpfnl-request-feature">'. __('Request a Feature', 'wpfnl').'</span>',
189 Wpfnl_functions::role_permission_to_allow_wpfunnel( $role_permission ),
190 'https://getwpfunnels.com/ideas/'
191 );
192
193 add_submenu_page(
194 WPFNL_MAIN_PAGE_SLUG,
195 __('Email Builder', 'wpfnl'),
196 __('Email Builder', 'wpfnl'),
197 Wpfnl_functions::role_permission_to_allow_wpfunnel( $role_permission ),
198 'email-builder',
199 [$this, 'render_email_builder_page']
200 );
201
202 // if ( !Wpfnl_functions::is_wpfnl_pro_activated() ) {
203
204 // add_submenu_page(
205 // WPFNL_MAIN_PAGE_SLUG,
206 // __('Free vs Pro', 'wpfnl'),
207 // __('Free vs Pro', 'wpfnl'),
208 // Wpfnl_functions::role_permission_to_allow_wpfunnel( $role_permission ),
209 // 'wpf_feature_comparison',
210 // [$this, 'render_feature_comparison_page']
211 // );
212
213
214 // add_submenu_page(
215 // WPFNL_MAIN_PAGE_SLUG,
216 // __('Go Pro', 'wpfnl'),
217 // '<span id="wpfnl-go-pro" class="dashicons dashicons-star-filled" style="font-size: 17px; color:#1fb3fb;"></span> ' . __('Go Pro', 'wpfnl'),
218 // Wpfnl_functions::role_permission_to_allow_wpfunnel( $role_permission ),
219 // 'https://getwpfunnels.com/pricing/'
220 // );
221 // }
222 }
223
224
225 /**
226 * Render the admin view of WPFunnels
227 *
228 * @since 3.1.7
229 */
230 public function render() {
231 include_once WPFNL_ADMIN_DIR . 'views/base.php';
232 }
233
234
235
236 public function render_email_builder_page() { ?>
237 <div id="email-builder"></div>
238 <?php }
239
240
241
242 /**
243 * Render funnel page
244 *
245 * @since 1.0.0
246 */
247 public function render_funnels_page()
248 {
249 Wpfnl::$instance->module_manager->get_admin_modules('funnels')->get_view();
250 }
251
252
253 /**
254 * Render funnel template page
255 *
256 * @since 1.0.0
257 */
258 public function render_funnel_template_page()
259 {
260 require WPFNL_DIR . '/admin/partials/templates.php';
261 }
262
263
264 /**
265 * Render feature comparison page
266 *
267 * @return void
268 * @since 3.4.13
269 */
270 public function render_feature_comparison_page() {
271 require WPFNL_DIR . '/admin/partials/feature-comparison.php';
272 }
273
274
275 /**
276 * Render edit funnel page.
277 *
278 * @since 1.0.0
279 */
280 public function render_edit_funnel_page()
281 {
282 $funnel_id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_SPECIAL_CHARS);
283 Wpfnl::$instance->module_manager->get_admin_modules('funnel')->init($funnel_id);
284 Wpfnl::$instance->module_manager->get_admin_modules('funnel')->get_view();
285 }
286
287
288 /**
289 * Render trash funnel page.
290 *
291 * @since 3.1.8
292 */
293 public function render_trash_funnel_page()
294 {
295 Wpfnl::$instance->module_manager->get_admin_modules('funnels')->get_view();
296 }
297
298 /**
299 * Render create funnel page
300 *
301 * @since 1.0.0
302 */
303 public function render_create_funnel_page()
304 {
305 Wpfnl::$instance->module_manager->get_admin_modules('create-funnel')->get_view();
306 }
307
308
309 /**
310 * Render settings page
311 *
312 * @since 1.0.0
313 */
314 public function render_settings_page()
315 {
316 Wpfnl::$instance->module_manager->get_admin_modules('settings')->get_view();
317 }
318
319 public function render_automations_page()
320 {
321 Wpfnl::$instance->module_manager->get_admin_modules('automations')->get_view();
322 }
323
324
325 /**
326 * Render addons page
327 *
328 * @since 1.0.0
329 */
330 public function render_addons_page()
331 {
332 require_once WPFNL_DIR . 'admin/modules/addons/view.php';
333 }
334
335
336 /**
337 * Render Store Checkout page
338 *
339 * Since 3.6.0 multiple store checkouts are allowed, so this page always
340 * shows the listing rather than redirecting to a single canvas.
341 *
342 * @since 3.5.0
343 */
344 public function render_store_checkout_page()
345 {
346 require WPFNL_DIR . '/admin/modules/store-checkout/views/store-checkout-listing.php';
347 }
348
349 /**
350 * Render Integration page
351 *
352 * @since 1.0.0
353 */
354 public function render_integration_page()
355 {
356 // Show Integrations page only if WPFunnels Pro Integrations is deactivated
357 if ( ! function_exists( 'is_plugin_active' ) ) {
358 require_once ABSPATH . 'wp-admin/includes/plugin.php';
359 }
360
361 if ( has_action( 'wpfunnels/render_integrations_page' ) ) {
362 // Pro plugin has registered its renderer — delegate (plan gate applied inside).
363 do_action( 'wpfunnels/render_integrations_page' );
364 } elseif ( ! is_plugin_active( 'wpfunnels-pro-integrations/wpfunnels-pro-integrations.php' ) ) {
365 require_once WPFNL_DIR . 'admin/modules/integration/view.php';
366 }
367 }
368
369 /**
370 * Get Store Checkout funnel if exists
371 *
372 * @return WP_Post|false
373 * @since 3.5.0
374 */
375 private function get_store_checkout_funnel()
376 {
377 $args = [
378 'post_type' => WPFNL_FUNNELS_POST_TYPE,
379 'posts_per_page' => 1,
380 'post_status' => ['publish', 'draft'],
381 'meta_query' => [
382 [
383 'key' => '_wpfnl_funnel_type',
384 'value' => 'store_checkout',
385 ],
386 ],
387 ];
388
389 $funnels = get_posts($args);
390 return !empty($funnels) ? $funnels[0] : false;
391 }
392
393
394
395
396 /**
397 * Render license page for funnel
398 *
399 * @since 2.0.0
400 */
401 public function render_license() {
402 require WPFNL_DIR . '/admin/partials/license.php';
403 }
404
405 /**
406 * Remove submenu from plugin menu
407 *
408 * @since 1.0.0
409 */
410 public function remove_submenu()
411 {
412 remove_submenu_page(WPFNL_MAIN_PAGE_SLUG, 'edit_funnel');
413 remove_submenu_page(WPFNL_MAIN_PAGE_SLUG, 'trash_funnels');
414 }
415
416
417 /**
418 * Remove all notices from funnel window
419 *
420 * @since 2.0.0
421 */
422 public function remove_notices_from_funnel_window() {
423 if (empty($_GET['page'])) {
424 return;
425 }
426 if (('edit_funnel' == sanitize_text_field( $_GET['page'] ) )) {
427 remove_all_actions( 'admin_notices' );
428 }
429 if ( 'wp_funnels' == sanitize_text_field( $_GET['page'] ) || 'wpf_templates' == sanitize_text_field( $_GET['page'] ) || 'trash_funnels' == sanitize_text_field( $_GET['page'] ) || 'wpfnl_settings' == sanitize_text_field( $_GET['page'] ) || 'wpf-license' == sanitize_text_field( $_GET['page'] ) ) {
430 add_action('admin_footer', array( $this, 'remove_admin_notices' ));
431 }
432
433 }
434
435
436
437 /**
438 * Force user to visit all steps page
439 *
440 * @since 1.0.0
441 */
442 public function disallow_all_step_view()
443 {
444 global $pagenow;
445 if ('edit.php' === $pagenow && isset($_GET['post_type']) && WPFNL_STEPS_POST_TYPE === sanitize_text_field($_GET['post_type'])) {
446 $funnel_link = add_query_arg(
447 [
448 'page' => WPFNL_MAIN_PAGE_SLUG,
449 ],
450 admin_url('admin.php')
451 );
452 wp_safe_redirect( wp_sanitize_redirect( esc_url_raw( $funnel_link ) ) );
453 exit;
454 }
455 }
456
457 /**
458 * Redirect user to pro url
459 */
460 public function redirect_to_pro()
461 {
462 $url = 'https://getwpfunnels.com/pricing/';
463 wp_safe_redirect( wp_sanitize_redirect( esc_url_raw( $url ) ) );
464 exit();
465 }
466
467
468 /**
469 * Open with new page when documenation is clicked
470 */
471 public function doc_link_with_new_page(){
472 ?>
473 <script type="text/javascript">
474 jQuery(document).ready(function($) {
475 $('#wpfnl-documentation').parent().attr('target','_blank');
476 $('#wpfnl-request-feature').parent().attr('target','_blank');
477 $('#wpfnl-go-pro').parent().attr('target','_blank');
478 });
479 </script>
480 <?php
481 }
482
483
484 public function add_folded_menu_class($classes) {
485 return $classes." folded";
486 }
487
488
489 /**
490 * Remove admin notices
491 */
492 public function remove_admin_notices() {
493 echo '<style>.update-nag, .updated, .error, .is-dismissible, .notice { display: none; } .wpfnl-import-notice {display: block!important; margin: 15px 15px 15px 0px;} .wpfunnels-notice {display: block; margin-left: 0px; margin-right: 25px;}</style>';
494 }
495
496
497 /**
498 * Add Store Checkout to dashboard navigation
499 *
500 * @param array $list Navigation list
501 * @return array Modified navigation list
502 * @since 3.5.0
503 */
504 public function add_store_checkout_nav( $list ) {
505 if ( ! is_array( $list ) ) {
506 return $list;
507 }
508
509 // Insert Store Checkout before settings
510 $new_list = array();
511
512 foreach ( $list as $key => $item ) {
513 // Insert Store Checkout before settings
514 if ( $key === 'settings' ) {
515 $new_list['store_checkout'] = array(
516 'title' => __('Store Checkout', 'wpfnl'),
517 'icon' => 'storewide-checkout-icon',
518 'page' => 'store_checkout',
519 );
520 }
521
522 $new_list[$key] = $item;
523 }
524
525 return $new_list;
526 }
527 }
528