PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.9.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.9.0
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
ablocks / includes / admin.php

admin.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.9.0, at includes/admin.php

170 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 class Admin {
9 public static function init() {
10 $self = new self();
11 $self->dispatch_hooks();
12
13 add_filter( 'upload_mimes', [ $self, 'allow_lottie_json_uploads' ] );
14 add_filter( 'wp_check_filetype_and_ext', function ( $data, $file, $filename ) {
15 $ext = pathinfo( $filename, PATHINFO_EXTENSION );
16
17 if ( 'json' === $ext ) {
18 $data['ext'] = 'json';
19 $data['type'] = 'application/json';
20 }
21
22 return $data;
23 }, 10, 3 );
24 }
25
26 function allow_lottie_json_uploads( $mimes ) {
27 $mimes['json'] = 'application/json';
28 $mimes['lottie'] = 'application/json';
29 return $mimes;
30 }
31
32 public function dispatch_hooks() {
33 Admin\Menu::init();
34 \ABlocks\CreatePage\page\ShowPageState::init();
35 Admin\Export::init();
36 Admin\Notice::init();
37 add_filter( 'allowed_redirect_hosts', array( $this, 'add_white_listed_redirect_hosts' ) );
38 add_action( 'current_screen', array( $this, 'conditional_loaded' ) );
39 add_filter( 'plugin_action_links_' . ABLOCKS_PLUGIN_BASENAME, array( $this, 'plugin_action_links' ) );
40 add_filter( 'plugin_row_meta', array( $this, 'add_plugin_links' ), 10, 2 );
41 add_action( 'admin_init', array( $this, 'dispatch_activation_redirect' ), 99 );
42 $this->dispatch_insights();
43 }
44 public function add_white_listed_redirect_hosts( $hosts ) {
45 $hosts[] = 'ablocks.pro';
46 return $hosts;
47 }
48
49 public function conditional_loaded() {
50 $screen = get_current_screen();
51
52 if ( $screen && $screen->id == 'ablocks_page_ablocks-get-pro' ) {
53 $link = add_query_arg(
54 [
55 'utm_source' => 'ablocks-plugin',
56 'utm_medium' => 'admin-dashboard',
57 'utm_campaign' => 'upgrade-to-pro',
58 'utm_content' => 'get-pro-button',
59 'utm_term' => 'free-user',
60 'locale' => get_locale(),
61 ],
62 'https://ablocks.pro/pricing/'
63 );
64
65 wp_safe_redirect( $link );
66 exit;
67 }
68 }
69
70 public function add_plugin_links( $links, $file ) {
71 if ( ABLOCKS_PLUGIN_BASENAME !== $file ) {
72 return $links;
73 }
74
75 $map_block_links = array(
76 'docs' => array(
77 'url' => 'https://ablocks.pro/docs/',
78 'label' => __( 'Docs', 'ablocks' ),
79 'aria-label' => __( 'View aBlocks documentation', 'ablocks' ),
80 ),
81 'video' => array(
82 'url' => 'https://www.youtube.com/@ablocksteam',
83 'label' => __( 'Video Tutorials', 'ablocks' ),
84 'aria-label' => __( 'See Video Tutorials', 'ablocks' ),
85 ),
86 'support' => array(
87 'url' => 'https://wordpress.org/support/plugin/ablocks/',
88 'label' => __( 'Community Support', 'ablocks' ),
89 'aria-label' => __( 'Visit community forums', 'ablocks' ),
90 ),
91 'review' => array(
92 'url' => 'https://wordpress.org/support/plugin/ablocks/reviews/#new-post',
93 'label' => __( 'Rate the plugin �
94
95
96
97
98 ', 'ablocks' ),
99 'aria-label' => __( 'Rate the plugin.', 'ablocks' ),
100 ),
101 );
102
103 foreach ( $map_block_links as $key => $link ) {
104 $links[ $key ] = sprintf(
105 '<a target="_blank" href="%s" aria-label="%s">%s</a>',
106 esc_url( $link['url'] ),
107 esc_attr( $link['aria-label'] ),
108 esc_html( $link['label'] )
109 );
110 }
111
112 return $links;
113 }
114 public function plugin_action_links( $links ) {
115 $settings_link = sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'admin.php?page=ablocks' ), esc_html__( 'Settings', 'ablocks' ) );
116
117 array_unshift( $links, $settings_link );
118
119 if ( ! defined( 'ABLOCKS_PRO_VERSION' ) ) {
120 $links['go_pro'] = sprintf( '<a href="%1$s" target="_blank" class="academy-plugins-gopro" style="color: #7b68ee; font-weight: bold;">%2$s</a>', 'https://ablocks.pro/pricing/', esc_html__( 'Get aBlocks Pro', 'ablocks' ) );
121 }
122 return $links;
123 }
124 public function dispatch_activation_redirect() {
125 if ( get_option( 'ablocks_need_activation_redirect', false ) ) {
126 delete_option( 'ablocks_need_activation_redirect' );
127 wp_safe_redirect( admin_url( 'admin.php?page=ablocks' ) );
128 exit;
129 }
130 }
131 public function dispatch_insights() {
132 Admin\Insights::init(
133 'https://kodezen.com',
134 ABLOCKS_PLUGIN_SLUG,
135 'plugin',
136 ABLOCKS_VERSION,
137 [
138 'logo' => ABLOCKS_ASSETS_URL . 'images/logo-shape.svg', // default logo URL
139 'optin_message' => 'Help improve aBlocks LMS! Allow anonymous usage tracking?',
140 'deactivation_message' => 'If you have a moment, please share why you are deactivating aBlocks:',
141 'deactivation_reasons' => [
142 'no_longer_needed' => [
143 'label' => 'I no longer need the plugin',
144 ],
145 'found_a_better_plugin' => [
146 'label' => 'I found a better plugin',
147 'has_custom_reason' => true,
148 'custom_reason_placeholder' => 'Please share which plugin',
149 ],
150 'couldnt_get_the_plugin_to_work' => [
151 'label' => 'I couldn\'t get the plugin to work',
152 ],
153 'temporary_deactivation' => [
154 'label' => 'It\'s a temporary deactivation',
155 ],
156 'have_academy_pro' => [
157 'label' => 'I have aBlocks Pro',
158 'toggle_text' => 'Wait! Don\'t deactivate aBlocks. You have to activate both aBlocks and aBlocks Pro in order for the plugin to work.',
159 ],
160 'other' => [
161 'label' => 'Other',
162 'has_custom_reason' => true,
163 'custom_reason_placeholder' => 'Please share the reason',
164 ],
165 ],
166 ]
167 );
168 }
169 }
170