PluginProbe
Content Blocks Builder – Create blocks, repeater blocks with carousel, grid, popup layouts / 2.8.10
Content Blocks Builder – Create blocks, repeater blocks with carousel, grid, popup layouts v2.8.10
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.10, at freemius.php

150 lines 5.4 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 __DIR__ . '/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 'is_org_compliant' => true,
43 ) );
44 }
45 return $cbb_fs;
46 }
47
48 // Init Freemius.
49 cbb_fs();
50 // Disable some Freemius features.
51 cbb_fs()->add_filter( 'show_deactivation_feedback_form', '__return_false' );
52 cbb_fs()->add_filter( 'hide_freemius_powered_by', '__return_true' );
53 // Disable opt-in option by default.
54 cbb_fs()->add_filter( 'permission_diagnostic_default', '__return_false' );
55 cbb_fs()->add_filter( 'permission_extensions_default', '__return_false' );
56 // Hide annoying notices.
57 cbb_fs()->add_filter(
58 'show_admin_notice',
59 function ( $show, $message ) {
60 if ( in_array( $message['id'], array('license_activated', 'premium_activated', 'connect_account') ) ) {
61 return false;
62 }
63 return $show;
64 },
65 10,
66 2
67 );
68 // Signal that SDK was initiated.
69 do_action( 'cbb_fs_loaded' );
70 }
71 if ( !function_exists( 'cbb_fs_custom_connect_message_on_update' ) ) {
72 /**
73 * Customize the opt-in messages
74 *
75 * @param string $message
76 * @param string $user_first_name
77 * @param string $plugin_title
78 * @param string $user_login
79 * @param string $site_link
80 * @param string $freemius_link
81 * @return string
82 */
83 function cbb_fs_custom_connect_message_on_update(
84 $message,
85 $user_first_name,
86 $plugin_title,
87 $user_login,
88 $site_link,
89 $freemius_link
90 ) {
91 return sprintf(
92 // translators: %s: the first name of the current user.
93 __( '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' ),
94 $user_first_name,
95 '<b>' . $plugin_title . '</b>',
96 '<b>' . $user_login . '</b>',
97 $site_link,
98 $freemius_link
99 );
100 }
101
102 cbb_fs()->add_filter(
103 'connect_message_on_update',
104 __NAMESPACE__ . '\\cbb_fs_custom_connect_message_on_update',
105 10,
106 6
107 );
108 }
109 if ( !function_exists( 'cbb_uninstall_cleanup' ) ) {
110 /**
111 * Clean up the plugin data
112 *
113 * @return void
114 */
115 function cbb_uninstall_cleanup() {
116 // Delete options.
117 delete_option( 'cbb_deployed_core_blocks' );
118 delete_option( 'cbb_core_blocks_version' );
119 delete_option( 'cbb_current_version' );
120 delete_option( 'cbb_pattern_categories' );
121 delete_option( 'cbb_pattern_categories_all_label' );
122 delete_option( 'cbb_typography' );
123 delete_option( 'cbb_enable_typography' );
124 delete_option( 'cbb_use_bunny_fonts' );
125 delete_option( 'cbb_breakpoints' );
126 delete_option( 'cbb_is_maintenance' );
127 delete_option( 'cbb_maintenance_ignore_slug' );
128 delete_option( 'cbb_maintenance_enable_custom_page' );
129 delete_option( 'cbb_maintenance_page_id' );
130 // Legacy options.
131 delete_option( 'boldblocks_deployed_core_blocks' );
132 delete_option( 'boldblocks_core_blocks_version' );
133 // Keep CBB data.
134 $keep_data_setting = 'cbb_keep_data';
135 if ( !get_option( $keep_data_setting ) ) {
136 // Delete all CBB posts.
137 $posts = get_posts( array(
138 'posts_per_page' => -1,
139 'post_type' => ['boldblocks_block', 'boldblocks_variation', 'boldblocks_pattern'],
140 'post_status' => 'any',
141 ) );
142 foreach ( $posts as $post ) {
143 wp_delete_post( $post->ID, true );
144 }
145 delete_option( $keep_data_setting );
146 }
147 }
148
149 cbb_fs()->add_action( 'after_uninstall', __NAMESPACE__ . '\\cbb_uninstall_cleanup' );
150 }