Repository navigation
Expand file tree
/
Copy pathotter-blocks.php
More file actions
186 lines (163 loc) · 6 KB
/
Copy pathotter-blocks.php
File metadata and controls
186 lines (163 loc) · 6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
/**
* Main file.
*
* @package OtterBlocks
*
* Plugin Name: Otter – Page Builder Blocks & Extensions for Gutenberg
* Plugin URI: https://themeisle.com/plugins/otter-blocks
* Description: Create beautiful and attracting posts, pages, and landing pages with Otter – Page Builder Blocks & Extensions for Gutenberg. Otter comes with dozens of Gutenberg blocks that are all you need to build beautiful pages.
* Version: 3.2.12
* Author: ThemeIsle
* Author URI: https://themeisle.com
* Requires at least: 6.6
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: otter-blocks
* Domain Path: /languages
* WordPress Available: yes
* Requires License: no
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
define( 'OTTER_BLOCKS_BASEFILE', __FILE__ );
define( 'OTTER_BLOCKS_URL', plugins_url( '/', __FILE__ ) );
define( 'OTTER_BLOCKS_PATH', __DIR__ );
define( 'OTTER_BLOCKS_VERSION', '3.2.12' );
define( 'OTTER_BLOCKS_PRO_SUPPORT', true );
define( 'OTTER_BLOCKS_SHOW_NOTICES', false );
define( 'OTTER_PRODUCT_SLUG', basename( OTTER_BLOCKS_PATH ) );
$vendor_file = OTTER_BLOCKS_PATH . '/vendor/autoload.php';
if ( is_readable( $vendor_file ) ) {
require_once $vendor_file;
}
if ( class_exists( '\ThemeIsle\GutenbergBlocks\Base_CSS' ) ) {
\ThemeIsle\GutenbergBlocks\Base_CSS::isolate_bundled_parser();
}
$loader_file = OTTER_BLOCKS_PATH . '/inc/class-loader.php';
$loader_available = class_exists( '\ThemeIsle\GutenbergBlocks\Loader', false );
if ( ! $loader_available ) {
if ( ! is_file( $loader_file ) ) {
error_log( '[Otter Blocks] Not starting: ' . $loader_file . ' is missing.' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
} elseif ( ! is_readable( $loader_file ) ) {
error_log( '[Otter Blocks] Not starting: ' . $loader_file . ' is not readable.' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
} else {
try {
require_once $loader_file;
$loader_available = class_exists( '\ThemeIsle\GutenbergBlocks\Loader', false );
if ( ! $loader_available ) {
error_log( '[Otter Blocks] Not starting: ' . $loader_file . ' does not declare ThemeIsle\GutenbergBlocks\Loader.' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
}
} catch ( \Throwable $e ) {
error_log( '[Otter Blocks] Not starting: ' . $loader_file . ' failed to load: ' . $e->getMessage() . '.' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
}
}
}
// Everything downstream runs from Main, so boot it through Loader's throwable boundary.
if ( $loader_available ) {
\ThemeIsle\GutenbergBlocks\Loader::boot_singleton( '\ThemeIsle\GutenbergBlocks\Main' );
}
add_filter(
'themeisle_sdk_products',
function ( $products ) {
$products[] = __FILE__;
return $products;
}
);
add_filter(
'otter_blocks_welcome_metadata',
function () {
return [
'is_enabled' => ! defined( 'OTTER_PRO_VERSION' ),
'pro_name' => __( 'Otter Blocks Pro', 'otter-blocks' ),
'logo' => OTTER_BLOCKS_URL . '/assets/images/logo-alt.png',
'cta_link' => tsdk_translate_link( tsdk_utmify( 'https://themeisle.com/plugins/otter-blocks/upgrade/?discount=LOYALUSER583&dvalue=60#pricing', 'otter-welcome', 'notice' ) ),
];
}
);
/*
* Opts into the SDK Support Hub: one Help button on Otter's screens and the
* deactivation window. The dashboard and Form Submissions screens already fire
* `themeisle_internal_page`, so no `pages` list is needed.
*/
add_filter(
'otter_blocks_support_hub_metadata',
function () {
return array(
// The SDK reads this while loading Otter, before Otter Pro's Licenser adds the
// product_otter_license_status filter, so read the stored license directly.
'is_pro' => defined( 'OTTER_PRO_BASEFILE' ) && class_exists( '\ThemeisleSDK\Modules\Licenser' ) && \ThemeisleSDK\Modules\Licenser::is_valid( OTTER_PRO_BASEFILE ),
'links' => array(
array(
'icon' => 'book-alt',
'text' => __( 'Documentation', 'otter-blocks' ),
'url' => \ThemeIsle\GutenbergBlocks\Pro::get_docs_url(),
),
array(
'icon' => 'groups',
'text' => __( 'Community Forum', 'otter-blocks' ),
'url' => 'https://wordpress.org/support/plugin/otter-blocks/',
),
),
);
}
);
/*
* Otter also fires `themeisle_internal_page` in the block editor, which would put
* the Help button on every post, site and widget editor. Keep it to Otter's screens.
*/
add_filter(
'otter_blocks_hide_support_hub',
function ( $hide ) {
global $pagenow;
return $hide || in_array( $pagenow, array( 'post.php', 'post-new.php', 'site-editor.php', 'widgets.php' ), true );
}
);
add_filter(
'themeisle_sdk_compatibilities/' . basename( OTTER_BLOCKS_PATH ),
function ( $compatibilities ) {
$compatibilities['OtterBlocksPRO'] = array(
'basefile' => defined( 'OTTER_PRO_BASEFILE' ) ? OTTER_PRO_BASEFILE : '',
'required' => '2.0',
'tested_up' => OTTER_BLOCKS_VERSION,
);
return $compatibilities;
}
);
add_action(
'plugin_action_links_' . plugin_basename( __FILE__ ),
function ( $links ) {
array_unshift(
$links,
sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=otter' ), __( 'Settings', 'otter-blocks' ) )
);
return $links;
}
);
add_filter( 'themeisle_sdk_enable_telemetry', '__return_true' );
add_filter(
'themeisle_sdk_telemetry_products',
function ( $products ) {
$already_registered = false;
$license = apply_filters( 'product_otter_license_key', 'free' );
$track_hash = 'free' === $license ? 'free' : wp_hash( $license );
foreach ( $products as &$product ) {
if ( strstr( $product['slug'], 'otter' ) !== false ) {
$already_registered = true;
$product['trackHash'] = $track_hash;
}
}
if ( $already_registered ) {
return $products;
}
// Add Otter Blocks to the list of products to track the usage of AI Block.
$products[] = array(
'slug' => 'otter',
'consent' => false,
'trackHash' => $track_hash,
);
return $products;
}
);