PluginProbe
Content Blocks Builder – Create blocks, repeater blocks with carousel, grid, popup layouts / 2.8.13
Content Blocks Builder – Create blocks, repeater blocks with carousel, grid, popup layouts v2.8.13
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 / includes / freemius-config.php

freemius-config.php in Content Blocks Builder – Create blocks, repeater blocks with carousel, grid, popup layouts 2.8.13, at includes/freemius-config.php

112 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Freemius utilities
4 *
5 * @package BoldBlocks
6 * @author Phi Phan <mrphipv@gmail.com>
7 * @copyright Copyright (c) 2024, Phi Phan
8 */
9
10 namespace BoldBlocks;
11
12 // Exit if accessed directly.
13 defined( 'ABSPATH' ) || exit;
14
15 if ( ! class_exists( FreemiusConfig::class ) ) :
16 /**
17 * The FreemiusConfig class.
18 */
19 class FreemiusConfig extends CoreComponent {
20 /**
21 * Run main hooks
22 *
23 * @return void
24 */
25 public function run() {
26 // Add header left links.
27 add_filter( 'cbb_get_header_left_links', [ $this, 'header_links' ] );
28
29 // Add the settings page link to plugin list screen.
30 add_filter( 'plugin_action_links_' . plugin_basename( BOLDBLOCKS_CBB_ROOT_FILE ), [ $this, 'plugin_settings_links' ] );
31
32 // Redirect to the getting started page.
33 add_action( 'admin_init', [ $this, 'boldblocks_activation_redirect' ] );
34 }
35
36 /**
37 * Add freemius pages
38 *
39 * @param array $links
40 * @return array
41 */
42 public function header_links( $links ) {
43 if ( cbb_fs()->is_not_paying() ) {
44 $links[] = [
45 'url' => 'https://contentblocksbuilder.com/pro/?utm_source=CBB+Free&utm_campaign=CBB+Upgrade&utm_medium=link&utm_content=header',
46 'title' => $this->get_premium_label(),
47 'target' => '_blank',
48 'icon' => '<span class="dashicons dashicons-superhero-alt"></span> ',
49 'class' => 'go-premium',
50 ];
51 } else {
52 $links[] = [
53 'url' => 'https://contentblocksbuilder.com/?utm_source=CBB+Pro&utm_campaign=CBB+visit+site&utm_medium=link&utm_content=header',
54 'title' => __( 'Visit site', 'content-blocks-builder' ),
55 'target' => '_blank',
56 'icon' => '<span class="dashicons dashicons-external"></span> ',
57 'class' => 'go-premium go-site',
58 ];
59 }
60
61 return $links;
62 }
63
64 /**
65 * Add the premium link to the plugin admin screen.
66 *
67 * @param array $links
68 * @return array
69 */
70 public function plugin_settings_links( $links ) {
71 $label = esc_html__( 'Settings', 'content-blocks-builder' );
72 $slug = 'cbb-settings';
73
74 array_unshift( $links, "<a href='edit.php?post_type=boldblocks_block&page={$slug}'>{$label}</a>" );
75
76 if ( cbb_fs()->is_not_paying() ) {
77 $links[] = sprintf( '<a href="%1$s" target="_blank" style="color: #d20962">%2$s</a>', 'https://contentblocksbuilder.com/pro/?utm_source=CBB+Free&utm_campaign=CBB+Upgrade&utm_medium=link&utm_content=action-link', $this->get_premium_label() );
78 }
79
80 return $links;
81 }
82
83 /**
84 * Redirect to the getting started page.
85 *
86 * @return void
87 */
88 public function boldblocks_activation_redirect() {
89 if ( ! cbb_fs()->is_activation_mode() ) {
90 // Make sure it's the correct user.
91 if ( ! wp_doing_ajax() && wp_get_current_user()->ID > 0 && intval( get_option( 'boldblocks_activation_redirect', false ) ) === wp_get_current_user()->ID ) {
92 // Make sure we don't redirect again after this one.
93 delete_option( 'boldblocks_activation_redirect' );
94 if ( ! is_network_admin() ) {
95 wp_safe_redirect( admin_url( '/edit.php?post_type=boldblocks_block&page=cbb-settings&tab=getting-started' ) );
96 exit;
97 }
98 }
99 }
100 }
101
102 /**
103 * Get the labels
104 *
105 * @return string
106 */
107 private function get_premium_label() {
108 return __( 'Go Premium', 'content-blocks-builder' );
109 }
110 }
111 endif;
112