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

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

119 lines 3.4 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 * The constructor
22 */
23 public function __construct( $the_plugin_instance ) {
24 parent::__construct( $the_plugin_instance );
25 }
26
27 /**
28 * Run main hooks
29 *
30 * @return void
31 */
32 public function run() {
33 // Add header left links.
34 add_filter( 'content_blocks_builder_get_header_left_links', [ $this, 'header_links' ] );
35
36 // Add the settings page link to plugin list screen.
37 add_filter( 'plugin_action_links_' . plugin_basename( BOLDBLOCKS_CBB_ROOT_FILE ), [ $this, 'plugin_settings_links' ] );
38
39 // Redirect to the getting started page.
40 add_action( 'admin_init', [ $this, 'boldblocks_activation_redirect' ] );
41 }
42
43 /**
44 * Add freemius pages
45 *
46 * @param array $links
47 * @return array
48 */
49 public function header_links( $links ) {
50 if ( cbb_fs()->is_not_paying() ) {
51 $links[] = [
52 'url' => 'https://contentblocksbuilder.com/pro/?utm_source=CBB+Free&utm_campaign=CBB+Upgrade&utm_medium=link&utm_content=header',
53 'title' => $this->get_premium_label(),
54 'target' => '_blank',
55 'icon' => '<span class="dashicons dashicons-superhero-alt"></span> ',
56 'class' => 'go-premium',
57 ];
58 } else {
59 $links[] = [
60 'url' => 'https://contentblocksbuilder.com/?utm_source=CBB+Pro&utm_campaign=CBB+visit+site&utm_medium=link&utm_content=header',
61 'title' => __( 'Visit site', 'content-blocks-builder' ),
62 'target' => '_blank',
63 'icon' => '<span class="dashicons dashicons-external"></span> ',
64 'class' => 'go-premium go-site',
65 ];
66 }
67
68 return $links;
69 }
70
71 /**
72 * Add the premium link to the plugin admin screen.
73 *
74 * @param array $links
75 * @return array
76 */
77 public function plugin_settings_links( $links ) {
78 $label = esc_html__( 'Settings', 'content-blocks-builder' );
79 $slug = 'cbb-settings';
80
81 array_unshift( $links, "<a href='edit.php?post_type=boldblocks_block&page={$slug}'>{$label}</a>" );
82
83 if ( cbb_fs()->is_not_paying() ) {
84 $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() );
85 }
86
87 return $links;
88 }
89
90 /**
91 * Redirect to the getting started page.
92 *
93 * @return void
94 */
95 public function boldblocks_activation_redirect() {
96 if ( ! cbb_fs()->is_activation_mode() ) {
97 // Make sure it's the correct user.
98 if ( ! wp_doing_ajax() && wp_get_current_user()->ID > 0 && intval( get_option( 'boldblocks_activation_redirect', false ) ) === wp_get_current_user()->ID ) {
99 // Make sure we don't redirect again after this one.
100 delete_option( 'boldblocks_activation_redirect' );
101 if ( ! is_network_admin() ) {
102 wp_safe_redirect( admin_url( '/edit.php?post_type=boldblocks_block&page=cbb-settings&tab=getting-started' ) );
103 exit;
104 }
105 }
106 }
107 }
108
109 /**
110 * Get the labels
111 *
112 * @return string
113 */
114 private function get_premium_label() {
115 return __( 'Go Premium', 'display-a-meta-field-as-block' );
116 }
117 }
118 endif;
119