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