← All changes
|
freemius/includes/managers/class-fs-admin-menu-manager.php
+49
-106
8.0.2
→
2.1.2
View file →
| @@ -203,12 +203,11 @@ | ||
| 203 | 203 | // 'page' |
| 204 | 204 | // ) ); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - $first_path = $this->get_option( $menu, 'first-path', false ); | |
| 208 | - | |
| 209 | - if ( ! empty( $first_path ) && is_string( $first_path ) ) { | |
| 210 | - $this->_first_time_path = $first_path; | |
| 207 | + $this->_first_time_path = $this->get_option( $menu, 'first-path', false ); | |
| 208 | + if ( ! empty( $this->_first_time_path ) && is_string( $this->_first_time_path ) ) { | |
| 209 | + $this->_first_time_path = admin_url( $this->_first_time_path, 'admin' ); | |
| 211 | 210 | } |
| 212 | 211 | } |
| 213 | 212 | } |
| 214 | 213 | |
| @@ -236,30 +235,20 @@ | ||
| 236 | 235 | return $this->_is_override_exact; |
| 237 | 236 | } |
| 238 | 237 | |
| 239 | 238 | |
| 240 | - /** | |
| 241 | - * Get the path of the page the user should be forwarded to after first activation. | |
| 242 | - * | |
| 243 | - * @author Vova Feldman (@svovaf) | |
| 244 | - * @since 1.1.3 | |
| 245 | - * | |
| 246 | - * @param bool $is_network Since 2.4.5 | |
| 247 | - * | |
| 248 | - * @return string | |
| 249 | - */ | |
| 250 | - function get_first_time_path( $is_network = false ) { | |
| 251 | - if ( empty ( $this->_first_time_path ) ) { | |
| 252 | - return $this->_first_time_path; | |
| 253 | - } | |
| 239 | + /** | |
| 240 | + * Get the path of the page the user should be forwarded to after first activation. | |
| 241 | + * | |
| 242 | + * @author Vova Feldman (@svovaf) | |
| 243 | + * @since 1.1.3 | |
| 244 | + * | |
| 245 | + * @return string | |
| 246 | + */ | |
| 247 | + function get_first_time_path() { | |
| 248 | + return $this->_first_time_path; | |
| 249 | + } | |
| 254 | 250 | |
| 255 | - if ( $is_network ) { | |
| 256 | - return network_admin_url( $this->_first_time_path ); | |
| 257 | - } else { | |
| 258 | - return admin_url( $this->_first_time_path ); | |
| 259 | - } | |
| 260 | - } | |
| 261 | - | |
| 262 | 251 | /** |
| 263 | 252 | * Check if plugin's menu item is part of a custom top level menu. |
| 264 | 253 | * |
| 265 | 254 | * @author Vova Feldman (@svovaf) |
| @@ -429,65 +418,44 @@ | ||
| 429 | 418 | $this->get_parent_slug() : |
| 430 | 419 | $this->get_raw_slug(); |
| 431 | 420 | } |
| 432 | 421 | |
| 433 | - /** | |
| 434 | - * Is user on plugin's admin activation page. | |
| 435 | - * | |
| 436 | - * @author Vova Feldman (@svovaf) | |
| 437 | - * @since 1.0.8 | |
| 438 | - * | |
| 439 | - * @param bool $show_opt_in_on_themes_page Since 2.3.1 | |
| 440 | - * | |
| 441 | - * @return bool | |
| 442 | - * | |
| 443 | - * @deprecated Please use is_activation_page() instead. | |
| 444 | - */ | |
| 445 | - function is_main_settings_page( $show_opt_in_on_themes_page = false ) { | |
| 446 | - return $this->is_activation_page( $show_opt_in_on_themes_page ); | |
| 447 | - } | |
| 422 | + /** | |
| 423 | + * Is user on plugin's admin activation page. | |
| 424 | + * | |
| 425 | + * @author Vova Feldman (@svovaf) | |
| 426 | + * @since 1.0.8 | |
| 427 | + * | |
| 428 | + * @return bool | |
| 429 | + */ | |
| 430 | + function is_main_settings_page() { | |
| 431 | + if ( $this->_menu_exists && | |
| 432 | + ( fs_is_plugin_page( $this->_menu_slug ) || fs_is_plugin_page( $this->_module_unique_affix ) ) | |
| 433 | + ) { | |
| 434 | + /** | |
| 435 | + * Module has a settings menu and the context page is the main settings page, so assume it's in | |
| 436 | + * activation (doesn't really check if already opted-in/skipped or not). | |
| 437 | + * | |
| 438 | + * @since 1.2.2 | |
| 439 | + */ | |
| 440 | + return true; | |
| 441 | + } | |
| 448 | 442 | |
| 449 | - /** | |
| 450 | - * Is user on product's admin activation page. | |
| 451 | - * | |
| 452 | - * @author Vova Feldman (@svovaf) | |
| 453 | - * @since 2.3.1 | |
| 454 | - * | |
| 455 | - * @param bool $show_opt_in_on_themes_page Since 2.3.1 | |
| 456 | - * | |
| 457 | - * @return bool | |
| 458 | - */ | |
| 459 | - function is_activation_page( $show_opt_in_on_themes_page = false ) { | |
| 460 | - if ( $show_opt_in_on_themes_page ) { | |
| 461 | - /** | |
| 462 | - * In activation only when show_optin query string param is given. | |
| 463 | - * | |
| 464 | - * @since 1.2.2 | |
| 465 | - */ | |
| 466 | - return ( | |
| 467 | - ( WP_FS__MODULE_TYPE_THEME === $this->_module_type ) && | |
| 468 | - Freemius::is_themes_page() && | |
| 469 | - fs_request_get_bool( $this->_module_unique_affix . '_show_optin' ) | |
| 470 | - ); | |
| 471 | - } | |
| 443 | + global $pagenow; | |
| 444 | + if ( ( WP_FS__MODULE_TYPE_THEME === $this->_module_type ) && Freemius::is_themes_page() ) { | |
| 445 | + /** | |
| 446 | + * In activation only when show_optin query string param is given. | |
| 447 | + * | |
| 448 | + * @since 1.2.2 | |
| 449 | + */ | |
| 450 | + return fs_request_get_bool( $this->_module_unique_affix . '_show_optin' ); | |
| 451 | + } | |
| 472 | 452 | |
| 473 | - if ( $this->_menu_exists && | |
| 474 | - ( fs_is_plugin_page( $this->_menu_slug ) || fs_is_plugin_page( $this->_module_unique_affix ) ) | |
| 475 | - ) { | |
| 476 | - /** | |
| 477 | - * Module has a settings menu and the context page is the main settings page, so assume it's in | |
| 478 | - * activation (doesn't really check if already opted-in/skipped or not). | |
| 479 | - * | |
| 480 | - * @since 1.2.2 | |
| 481 | - */ | |
| 482 | - return true; | |
| 483 | - } | |
| 453 | + return false; | |
| 454 | + } | |
| 484 | 455 | |
| 485 | - return false; | |
| 486 | - } | |
| 456 | + #region Submenu Override | |
| 487 | 457 | |
| 488 | - #region Submenu Override | |
| 489 | - | |
| 490 | 458 | /** |
| 491 | 459 | * Override submenu's action. |
| 492 | 460 | * |
| 493 | 461 | * @author Vova Feldman (@svovaf) |
| @@ -698,38 +666,13 @@ | ||
| 698 | 666 | } else { |
| 699 | 667 | $menu = $this->find_main_submenu(); |
| 700 | 668 | } |
| 701 | 669 | |
| 702 | - $menu_slug = $menu['menu'][2]; | |
| 703 | 670 | $parent_slug = isset( $menu['parent_slug'] ) ? |
| 704 | - $menu['parent_slug'] : | |
| 705 | - 'admin.php'; | |
| 671 | + $menu['parent_slug'] : | |
| 672 | + 'admin.php'; | |
| 706 | 673 | |
| 707 | - if ( fs_apply_filter( $this->_module_unique_affix, 'enable_cpt_advanced_menu_logic', false ) ) { | |
| 708 | - $parent_slug = 'admin.php'; | |
| 709 | - | |
| 710 | - /** | |
| 711 | - * This line and the `if` block below it are based on the `menu_page_url()` function of WordPress. | |
| 712 | - * | |
| 713 | - * @author Leo Fajardo (@leorw) | |
| 714 | - * @since 2.10.2 | |
| 715 | - */ | |
| 716 | - global $_parent_pages; | |
| 717 | - | |
| 718 | - if ( ! empty( $_parent_pages[ $menu_slug ] ) ) { | |
| 719 | - $_parent_slug = $_parent_pages[ $menu_slug ]; | |
| 720 | - $parent_slug = isset( $_parent_pages[ $_parent_slug ] ) ? | |
| 721 | - $parent_slug : | |
| 722 | - $menu['parent_slug']; | |
| 723 | - } | |
| 724 | - } | |
| 725 | - | |
| 726 | - return admin_url( | |
| 727 | - $parent_slug . | |
| 728 | - ( false === strpos( $parent_slug, '?' ) ? '?' : '&' ) . | |
| 729 | - 'page=' . | |
| 730 | - $menu_slug | |
| 731 | - ); | |
| 674 | + return admin_url( $parent_slug . '?page=' . $menu['menu'][2] ); | |
| 732 | 675 | } |
| 733 | 676 | |
| 734 | 677 | /** |
| 735 | 678 | * @author Vova Feldman (@svovaf) |