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

149 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 ) );
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 // translators: %s: the first name of the current user.
92 __( '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' ),
93 $user_first_name,
94 '<b>' . $plugin_title . '</b>',
95 '<b>' . $user_login . '</b>',
96 $site_link,
97 $freemius_link
98 );
99 }
100
101 cbb_fs()->add_filter(
102 'connect_message_on_update',
103 __NAMESPACE__ . '\\cbb_fs_custom_connect_message_on_update',
104 10,
105 6
106 );
107 }
108 if ( !function_exists( 'cbb_uninstall_cleanup' ) ) {
109 /**
110 * Clean up the plugin data
111 *
112 * @return void
113 */
114 function cbb_uninstall_cleanup() {
115 // Delete options.
116 delete_option( 'cbb_deployed_core_blocks' );
117 delete_option( 'cbb_core_blocks_version' );
118 delete_option( 'cbb_current_version' );
119 delete_option( 'cbb_pattern_categories' );
120 delete_option( 'cbb_pattern_categories_all_label' );
121 delete_option( 'cbb_typography' );
122 delete_option( 'cbb_enable_typography' );
123 delete_option( 'cbb_use_bunny_fonts' );
124 delete_option( 'cbb_breakpoints' );
125 delete_option( 'cbb_is_maintenance' );
126 delete_option( 'cbb_maintenance_ignore_slug' );
127 delete_option( 'cbb_maintenance_enable_custom_page' );
128 delete_option( 'cbb_maintenance_page_id' );
129 // Legacy options.
130 delete_option( 'boldblocks_deployed_core_blocks' );
131 delete_option( 'boldblocks_core_blocks_version' );
132 // Keep CBB data.
133 $keep_data_setting = 'cbb_keep_data';
134 if ( !get_option( $keep_data_setting ) ) {
135 // Delete all CBB posts.
136 $posts = get_posts( array(
137 'posts_per_page' => -1,
138 'post_type' => ['boldblocks_block', 'boldblocks_variation', 'boldblocks_pattern'],
139 'post_status' => 'any',
140 ) );
141 foreach ( $posts as $post ) {
142 wp_delete_post( $post->ID, true );
143 }
144 delete_option( $keep_data_setting );
145 }
146 }
147
148 cbb_fs()->add_action( 'after_uninstall', __NAMESPACE__ . '\\cbb_uninstall_cleanup' );
149 }