PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.11.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.11.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.11.0, at includes/admin.php

131 lines 3.9 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 }
43 public function add_white_listed_redirect_hosts( $hosts ) {
44 $hosts[] = 'ablocks.pro';
45 return $hosts;
46 }
47
48 public function conditional_loaded() {
49 $screen = get_current_screen();
50
51 if ( $screen && $screen->id == 'ablocks_page_ablocks-get-pro' ) {
52 $link = add_query_arg(
53 [
54 'utm_source' => 'ablocks-plugin',
55 'utm_medium' => 'admin-dashboard',
56 'utm_campaign' => 'upgrade-to-pro',
57 'utm_content' => 'get-pro-button',
58 'utm_term' => 'free-user',
59 'locale' => get_locale(),
60 ],
61 'https://ablocks.pro/pricing/'
62 );
63
64 wp_safe_redirect( $link );
65 exit;
66 }
67 }
68
69 public function add_plugin_links( $links, $file ) {
70 if ( ABLOCKS_PLUGIN_BASENAME !== $file ) {
71 return $links;
72 }
73
74 $map_block_links = array(
75 'docs' => array(
76 'url' => 'https://ablocks.pro/docs/',
77 'label' => __( 'Docs', 'ablocks' ),
78 'aria-label' => __( 'View aBlocks documentation', 'ablocks' ),
79 ),
80 'video' => array(
81 'url' => 'https://www.youtube.com/@ablocksteam',
82 'label' => __( 'Video Tutorials', 'ablocks' ),
83 'aria-label' => __( 'See Video Tutorials', 'ablocks' ),
84 ),
85 'support' => array(
86 'url' => 'https://wordpress.org/support/plugin/ablocks/',
87 'label' => __( 'Community Support', 'ablocks' ),
88 'aria-label' => __( 'Visit community forums', 'ablocks' ),
89 ),
90 'review' => array(
91 'url' => 'https://wordpress.org/support/plugin/ablocks/reviews/#new-post',
92 'label' => __( 'Rate the plugin �
93
94
95
96
97 ', 'ablocks' ),
98 'aria-label' => __( 'Rate the plugin.', 'ablocks' ),
99 ),
100 );
101
102 foreach ( $map_block_links as $key => $link ) {
103 $links[ $key ] = sprintf(
104 '<a target="_blank" href="%s" aria-label="%s">%s</a>',
105 esc_url( $link['url'] ),
106 esc_attr( $link['aria-label'] ),
107 esc_html( $link['label'] )
108 );
109 }
110
111 return $links;
112 }
113 public function plugin_action_links( $links ) {
114 $settings_link = sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'admin.php?page=ablocks' ), esc_html__( 'Settings', 'ablocks' ) );
115
116 array_unshift( $links, $settings_link );
117
118 if ( ! defined( 'ABLOCKS_PRO_VERSION' ) ) {
119 $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' ) );
120 }
121 return $links;
122 }
123 public function dispatch_activation_redirect() {
124 if ( get_option( 'ablocks_need_activation_redirect', false ) ) {
125 delete_option( 'ablocks_need_activation_redirect' );
126 wp_safe_redirect( admin_url( 'admin.php?page=ablocks' ) );
127 exit;
128 }
129 }
130 }
131