PluginProbe
Passster – Password Protect Pages and Content / 4.3.9
Passster – Password Protect Pages and Content v4.3.9
4.3.15 4.3.14 4.3.12 4.3.13 4.3.11 4.3.10 4.3.9 4.3.8 4.3.7 4.3.6 4.3.5 trunk 3.5.4 3.5.5.2 3.5.5.8 3.5.5.9 4.0 4.1.4 4.2.10 4.2.11 4.2.12 4.2.13 4.2.14 4.2.15 4.2.16 All 47 releases
content-protector / inc / freemius-setup.php

freemius-setup.php in Passster – Password Protect Pages and Content 4.3.9, at inc/freemius-setup.php

130 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( !function_exists( 'passster_fs' ) ) {
4 // Create a helper function for easy SDK access.
5 function passster_fs() {
6 global $passster_fs;
7 if ( !isset( $passster_fs ) ) {
8 // Activate multisite network integration.
9 if ( !defined( 'WP_FS__PRODUCT_1938_MULTISITE' ) ) {
10 define( 'WP_FS__PRODUCT_1938_MULTISITE', true );
11 }
12 // Include Freemius SDK.
13 require_once dirname( __FILE__ ) . '/freemius/start.php';
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(
25 'contact' => false,
26 'support' => false,
27 ),
28 'is_live' => true,
29 'is_org_compliant' => true,
30 ) );
31 }
32 return $passster_fs;
33 }
34
35 // Init Freemius.
36 passster_fs();
37 // Signal that SDK was initiated.
38 do_action( 'passster_fs_loaded' );
39 }
40 function passster_fs_settings_url() {
41 return admin_url( 'admin.php?page=passster-settings' );
42 }
43
44 if ( !passster_fs()->is_registered() && !passster_fs()->is_anonymous() && !passster_fs()->is_pending_activation() ) {
45 passster_fs()->skip_connection();
46 }
47 passster_fs()->add_filter( 'connect_url', 'passster_fs_settings_url' );
48 passster_fs()->add_filter( 'after_skip_url', 'passster_fs_settings_url' );
49 passster_fs()->add_filter( 'after_connect_url', 'passster_fs_settings_url' );
50 passster_fs()->add_filter( 'after_pending_connect_url', 'passster_fs_settings_url' );
51 passster_fs()->add_filter( 'show_deactivation_subscription_cancellation', '__return_false' );
52 passster_fs()->add_filter( 'show_deactivation_feedback_form', '__return_false' );
53 /**
54 * Hide specific Freemius sticky admin notices.
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 *
84 * @param bool $is_visible indicates if visible or not.
85 * @param string $submenu_id current submenu id.
86 *
87 * @return bool
88 */
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 }
94 return false;
95 }
96
97 passster_fs()->add_filter(
98 'is_submenu_visible',
99 'passster_is_submenu_visible',
100 10,
101 2
102 );
103 /**
104 * Add custom icon for Freemius.
105 *
106 * @return string
107 */
108 passster_fs()->add_filter( 'plugin_icon', function () {
109 return PASSSTER_PATH . '/assets/admin/passster-icon.png';
110 } );
111 passster_fs()->add_action( 'after_uninstall', function () {
112 global $wpdb;
113 // Delete option.
114 if ( is_multisite() ) {
115 delete_site_option( 'passster' );
116 } else {
117 delete_option( 'passster' );
118 }
119 // Delete tables.
120 $tables = [$wpdb->prefix . "passster_concurrent_logins", $wpdb->prefix . "passster_statistics"];
121 foreach ( $tables as $table ) {
122 $wpdb->query( "DROP TABLE IF EXISTS {$table}" );
123 }
124 // Delete all password lists.
125 $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type='password_lists'" );
126 // Delete all protected areas.
127 $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type='protected_areas'" );
128 // Delete all assigned meta
129 $wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE 'passster_%'" );
130 } );