PluginProbe
Content Blocks Builder – Create blocks, repeater blocks with carousel, grid, popup layouts / 2.8.2
Content Blocks Builder – Create blocks, repeater blocks with carousel, grid, popup layouts v2.8.2
2.8.14 2.8.13 2.8.12 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.10 2.8.11 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 trunk 1.0.1 1.0.2 1.1.0 1.1.1 All 147 releases
content-blocks-builder / freemius.php

freemius.php in Content Blocks Builder – Create blocks, repeater blocks with carousel, grid, popup layouts 2.8.2, at freemius.php

148 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Freemius functions
5 *
6 * @package BoldBlocks
7 * @author Phi Phan <mrphipv@gmail.com>
8 * @copyright Copyright (c) 2022, Phi Phan
9 */
10 namespace BoldBlocks;
11
12 // Exit if accessed directly.
13 defined( 'ABSPATH' ) || exit;
14 if ( !function_exists( 'cbb_fs' ) ) {
15 // Create a helper function for easy SDK access.
16 function cbb_fs() {
17 global $cbb_fs;
18 if ( !isset( $cbb_fs ) ) {
19 // Activate multisite network integration.
20 if ( !defined( 'WP_FS__PRODUCT_11230_MULTISITE' ) ) {
21 define( 'WP_FS__PRODUCT_11230_MULTISITE', true );
22 }
23 // Include Freemius SDK.
24 require_once dirname( __FILE__ ) . '/vendor/freemius/start.php';
25 $menu = array(
26 'slug' => 'edit.php?post_type=boldblocks_block',
27 'account' => true,
28 );
29 if ( !fs_is_network_admin() ) {
30 $menu['first-path'] = 'edit.php?post_type=boldblocks_block&page=cbb-settings';
31 }
32 $cbb_fs = fs_dynamic_init( array(
33 'id' => '11230',
34 'slug' => 'content-blocks-builder',
35 'type' => 'plugin',
36 'public_key' => 'pk_3cf9ea74cc57ecea98583ead30a34',
37 'is_premium' => false,
38 'has_addons' => false,
39 'has_paid_plans' => true,
40 'menu' => $menu,
41 'is_live' => true,
42 ) );
43 }
44 return $cbb_fs;
45 }
46
47 // Init Freemius.
48 cbb_fs();
49 // Disable some Freemius features.
50 cbb_fs()->add_filter( 'show_deactivation_feedback_form', '__return_false' );
51 cbb_fs()->add_filter( 'hide_freemius_powered_by', '__return_true' );
52 // Disable opt-in option by default.
53 cbb_fs()->add_filter( 'permission_diagnostic_default', '__return_false' );
54 cbb_fs()->add_filter( 'permission_extensions_default', '__return_false' );
55 // Hide annoying notices.
56 cbb_fs()->add_filter(
57 'show_admin_notice',
58 function ( $show, $message ) {
59 if ( in_array( $message['id'], array('license_activated', 'premium_activated', 'connect_account') ) ) {
60 return false;
61 }
62 return $show;
63 },
64 10,
65 2
66 );
67 // Signal that SDK was initiated.
68 do_action( 'cbb_fs_loaded' );
69 }
70 if ( !function_exists( 'cbb_fs_custom_connect_message_on_update' ) ) {
71 /**
72 * Customize the opt-in messages
73 *
74 * @param string $message
75 * @param string $user_first_name
76 * @param string $plugin_title
77 * @param string $user_login
78 * @param string $site_link
79 * @param string $freemius_link
80 * @return string
81 */
82 function cbb_fs_custom_connect_message_on_update(
83 $message,
84 $user_first_name,
85 $plugin_title,
86 $user_login,
87 $site_link,
88 $freemius_link
89 ) {
90 return sprintf(
91 __( 'Hey %1$s', 'content-blocks-builder' ) . ',<br>' . __( 'Thank you for using %2$s. We invite you to help the %2$s community by opting in to share some data about your usage of %2$s with us. This will help us make this plugin more compatible with your site and better at doing what you need it to. You can opt out at any time. And if you skip this, that\'s okay! %2$s will still work just fine.', 'content-blocks-builder' ),
92 $user_first_name,
93 '<b>' . $plugin_title . '</b>',
94 '<b>' . $user_login . '</b>',
95 $site_link,
96 $freemius_link
97 );
98 }
99
100 cbb_fs()->add_filter(
101 'connect_message_on_update',
102 __NAMESPACE__ . '\\cbb_fs_custom_connect_message_on_update',
103 10,
104 6
105 );
106 }
107 if ( !function_exists( 'cbb_uninstall_cleanup' ) ) {
108 /**
109 * Clean up the plugin data
110 *
111 * @return void
112 */
113 function cbb_uninstall_cleanup() {
114 // Delete options.
115 delete_option( 'cbb_deployed_core_blocks' );
116 delete_option( 'cbb_core_blocks_version' );
117 delete_option( 'cbb_current_version' );
118 delete_option( 'cbb_pattern_categories' );
119 delete_option( 'cbb_pattern_categories_all_label' );
120 delete_option( 'cbb_typography' );
121 delete_option( 'cbb_enable_typography' );
122 delete_option( 'cbb_use_bunny_fonts' );
123 delete_option( 'cbb_breakpoints' );
124 delete_option( 'cbb_is_maintenance' );
125 delete_option( 'cbb_maintenance_ignore_slug' );
126 delete_option( 'cbb_maintenance_enable_custom_page' );
127 delete_option( 'cbb_maintenance_page_id' );
128 // Legacy options.
129 delete_option( 'boldblocks_deployed_core_blocks' );
130 delete_option( 'boldblocks_core_blocks_version' );
131 // Keep CBB data.
132 $keep_data_setting = 'cbb_keep_data';
133 if ( !get_option( $keep_data_setting ) ) {
134 // Delete all CBB posts.
135 $posts = get_posts( array(
136 'posts_per_page' => -1,
137 'post_type' => ['boldblocks_block', 'boldblocks_variation', 'boldblocks_pattern'],
138 'post_status' => 'any',
139 ) );
140 foreach ( $posts as $post ) {
141 wp_delete_post( $post->ID, true );
142 }
143 delete_option( $keep_data_setting );
144 }
145 }
146
147 cbb_fs()->add_action( 'after_uninstall', __NAMESPACE__ . '\\cbb_uninstall_cleanup' );
148 }