| @@ -11,22 +11,23 @@ | ||
| 11 | 11 | } |
| 12 | 12 | // Include Freemius SDK. |
| 13 | 13 | require_once dirname( __FILE__ ) . '/freemius/start.php'; |
| 14 | 14 | $passster_fs = fs_dynamic_init( array( |
| 15 | - 'id' => '1938', | |
| 16 | - 'slug' => 'content-protector', | |
| 17 | - 'type' => 'plugin', | |
| 18 | - 'public_key' => 'pk_9d9d6d17bd34372b199f36e37dd4b', | |
| 19 | - 'is_premium' => false, | |
| 20 | - 'premium_suffix' => '', | |
| 21 | - 'has_addons' => false, | |
| 22 | - 'has_paid_plans' => true, | |
| 23 | - 'has_affiliation' => 'selected', | |
| 24 | - 'menu' => array( | |
| 15 | + 'id' => '1938', | |
| 16 | + 'slug' => 'content-protector', | |
| 17 | + 'type' => 'plugin', | |
| 18 | + 'public_key' => 'pk_9d9d6d17bd34372b199f36e37dd4b', | |
| 19 | + 'is_premium' => false, | |
| 20 | + 'premium_suffix' => '', | |
| 21 | + 'has_addons' => false, | |
| 22 | + 'has_paid_plans' => true, | |
| 23 | + 'has_affiliation' => 'selected', | |
| 24 | + 'menu' => array( | |
| 25 | 25 | 'contact' => false, |
| 26 | 26 | 'support' => false, |
| 27 | 27 | ), |
| 28 | - 'is_live' => true, | |
| 28 | + 'is_live' => true, | |
| 29 | + 'is_org_compliant' => true, | |
| 29 | 30 | ) ); |
| 30 | 31 | } |
| 31 | 32 | return $passster_fs; |
| 32 | 33 | } |
| @@ -39,8 +40,11 @@ | ||
| 39 | 40 | function passster_fs_settings_url() { |
| 40 | 41 | return admin_url( 'admin.php?page=passster-settings' ); |
| 41 | 42 | } |
| 42 | 43 | |
| 44 | +if ( !passster_fs()->is_registered() && !passster_fs()->is_anonymous() && !passster_fs()->is_pending_activation() ) { | |
| 45 | + passster_fs()->skip_connection(); | |
| 46 | +} | |
| 43 | 47 | passster_fs()->add_filter( 'connect_url', 'passster_fs_settings_url' ); |
| 44 | 48 | passster_fs()->add_filter( 'after_skip_url', 'passster_fs_settings_url' ); |
| 45 | 49 | passster_fs()->add_filter( 'after_connect_url', 'passster_fs_settings_url' ); |
| 46 | 50 | passster_fs()->add_filter( 'after_pending_connect_url', 'passster_fs_settings_url' ); |
| @@ -46,16 +50,48 @@ | ||
| 46 | 50 | passster_fs()->add_filter( 'after_pending_connect_url', 'passster_fs_settings_url' ); |
| 47 | 51 | passster_fs()->add_filter( 'show_deactivation_subscription_cancellation', '__return_false' ); |
| 48 | 52 | passster_fs()->add_filter( 'show_deactivation_feedback_form', '__return_false' ); |
| 49 | 53 | /** |
| 50 | - * Remove freemius pages. | |
| 54 | + * Hide specific Freemius sticky admin notices. | |
| 51 | 55 | * |
| 56 | + * @param bool $show Whether the notice should be shown. | |
| 57 | + * @param array $notice Notice data, includes 'id'. | |
| 58 | + * | |
| 59 | + * @return bool | |
| 60 | + */ | |
| 61 | +function passster_hide_admin_notices( $show, $notice ) { | |
| 62 | + $hidden_notice_ids = array( | |
| 63 | + 'connect_account', | |
| 64 | + // "We made a few tweaks to the plugin, Opt in to make it better!" | |
| 65 | + 'premium_activated', | |
| 66 | + // "W00t! Premium plugin version was successfully activated." | |
| 67 | + 'plan_upgraded', | |
| 68 | + ); | |
| 69 | + if ( in_array( $notice['id'], $hidden_notice_ids, true ) ) { | |
| 70 | + return false; | |
| 71 | + } | |
| 72 | + return $show; | |
| 73 | +} | |
| 74 | + | |
| 75 | +passster_fs()->add_filter( | |
| 76 | + 'show_admin_notice', | |
| 77 | + 'passster_hide_admin_notices', | |
| 78 | + 10, | |
| 79 | + 2 | |
| 80 | +); | |
| 81 | +/** | |
| 82 | + * Hide freemius submenus except account (for license management). | |
| 83 | + * | |
| 52 | 84 | * @param bool $is_visible indicates if visible or not. |
| 53 | - * @param int $submenu_id current submenu id. | |
| 85 | + * @param string $submenu_id current submenu id. | |
| 54 | 86 | * |
| 55 | 87 | * @return bool |
| 56 | 88 | */ |
| 57 | 89 | function passster_is_submenu_visible( $is_visible, $submenu_id ) { |
| 90 | + // Show account submenu for license activation/management | |
| 91 | + if ( 'account' === $submenu_id ) { | |
| 92 | + return true; | |
| 93 | + } | |
| 58 | 94 | return false; |
| 59 | 95 | } |
| 60 | 96 | |
| 61 | 97 | passster_fs()->add_filter( |