PluginProbe
Snow Monkey Blocks / 25.0.2
Snow Monkey Blocks v25.0.2
26.0.2 26.0.0 26.0.1 25.0.3 25.0.2 25.0.1 25.0.0 20.3.4 20.3.5 20.4.0 20.4.1 20.4.2 20.4.3 20.5.0 20.5.1 20.5.2 20.5.3 20.5.4 20.5.5 21.0.0 21.0.1 21.0.2 21.0.3 21.0.4 21.0.5 All 331 releases
snow-monkey-blocks / snow-monkey-blocks.php

snow-monkey-blocks.php in Snow Monkey Blocks 25.0.2, at snow-monkey-blocks.php

281 lines 9.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin name: Snow Monkey Blocks
4 * Version: 25.0.2
5 * Description: Gutenberg blocks collection made by MonkeyWrench.
6 * Author: inc2734
7 * Author URI: https://2inc.org
8 * License: GPL2 or later
9 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
10 * Text Domain: snow-monkey-blocks
11 *
12 * @package snow-monkey-blocks
13 * @author inc2734
14 * @license GPL-2.0+
15 */
16
17 namespace Snow_Monkey\Plugin\Blocks;
18
19 use FilesystemIterator;
20 use RecursiveDirectoryIterator;
21 use RecursiveIteratorIterator;
22
23 class Bootstrap {
24
25 /**
26 * constructor
27 */
28 public function __construct() {
29 add_action( 'plugins_loaded', array( $this, '_bootstrap' ) );
30 }
31
32 /**
33 * bootstrap
34 */
35 public function _bootstrap() {
36 new App\Setup\TextDomain();
37 new App\Setup\Assets();
38 new App\Setup\Blocks();
39 new App\Setup\JsonLd();
40 new App\Controller\Manager();
41
42 add_filter( 'block_categories_all', array( $this, '_block_categories_all' ) );
43 add_action( 'init', array( $this, '_register_blocks' ) );
44 add_action( 'add_meta_boxes', array( $this, '_add_pr_meta_box' ) );
45 }
46
47 /**
48 * Add block categories.
49 *
50 * @param array $categories Array of block categories.
51 * @return array
52 */
53 public function _block_categories_all( $categories ) {
54 $slugs = array_column( $categories, 'slug' );
55
56 if ( ! in_array( 'smb', $slugs, true ) ) {
57 $categories[] = array(
58 'slug' => 'smb',
59 'title' => __( 'Snow Monkey Blocks', 'snow-monkey-blocks' )
60 . ' '
61 . __( '[Common]', 'snow-monkey-blocks' ),
62 );
63 }
64
65 if ( ! in_array( 'smb-section', $slugs, true ) ) {
66 $categories[] = array(
67 'slug' => 'smb-section',
68 'title' => __( 'Snow Monkey Blocks', 'snow-monkey-blocks' )
69 . ' '
70 . __( '[Sections]', 'snow-monkey-blocks' ),
71 );
72 }
73
74 if ( ! in_array( 'smb-layout', $slugs, true ) ) {
75 $categories[] = array(
76 'slug' => 'smb-layout',
77 'title' => __( 'Snow Monkey Blocks', 'snow-monkey-blocks' )
78 . ' '
79 . __( '[Layout]', 'snow-monkey-blocks' ),
80 );
81 }
82
83 if ( ! in_array( 'smb-deprecated', $slugs, true ) ) {
84 $categories[] = array(
85 'slug' => 'smb-deprecated',
86 'title' => __( 'Snow Monkey Blocks', 'snow-monkey-blocks' )
87 . ' '
88 . __( '[Deprecated]', 'snow-monkey-blocks' ),
89 );
90 }
91
92 return $categories;
93 }
94
95 /**
96 * Register blocks.
97 * Organize your load order taking dependencies into account.
98 */
99 public function _register_blocks() {
100 include_once __DIR__ . '/dist/blocks/accordion/index.php';
101 include_once __DIR__ . '/dist/blocks/accordion/item/index.php';
102 include_once __DIR__ . '/dist/blocks/alert/index.php';
103 include_once __DIR__ . '/dist/blocks/balloon/index.php';
104 include_once __DIR__ . '/dist/blocks/box/index.php';
105 include_once __DIR__ . '/dist/blocks/btn/index.php';
106 include_once __DIR__ . '/dist/blocks/btn-box/index.php';
107 include_once __DIR__ . '/dist/blocks/buttons/index.php';
108 include_once __DIR__ . '/dist/blocks/categories-list/index.php';
109 include_once __DIR__ . '/dist/blocks/child-pages/index.php';
110 include_once __DIR__ . '/dist/blocks/container/index.php';
111 include_once __DIR__ . '/dist/blocks/contents-outline/index.php';
112 include_once __DIR__ . '/dist/blocks/countdown/index.php';
113 include_once __DIR__ . '/dist/blocks/custom-field/index.php';
114 include_once __DIR__ . '/dist/blocks/directory-structure/index.php';
115 include_once __DIR__ . '/dist/blocks/directory-structure/item/directory/index.php';
116 include_once __DIR__ . '/dist/blocks/directory-structure/item/file/index.php';
117 include_once __DIR__ . '/dist/blocks/evaluation-star/index.php';
118 include_once __DIR__ . '/dist/blocks/faq/index.php';
119 include_once __DIR__ . '/dist/blocks/faq/item/index.php';
120 include_once __DIR__ . '/dist/blocks/flex/index.php';
121 include_once __DIR__ . '/dist/blocks/grid/index.php';
122 include_once __DIR__ . '/dist/blocks/hero-header/index.php';
123 include_once __DIR__ . '/dist/blocks/information/index.php';
124 include_once __DIR__ . '/dist/blocks/information/item/index.php';
125 include_once __DIR__ . '/dist/blocks/items/index.php';
126 include_once __DIR__ . '/dist/blocks/items/item/free/index.php';
127 include_once __DIR__ . '/dist/blocks/items/item/standard/index.php';
128 include_once __DIR__ . '/dist/blocks/items/item/banner/index.php';
129 include_once __DIR__ . '/dist/blocks/items/item/item/index.php';
130 include_once __DIR__ . '/dist/blocks/items/item/block-link/index.php';
131 include_once __DIR__ . '/dist/blocks/like-me-box/index.php';
132 include_once __DIR__ . '/dist/blocks/limited-datetime/index.php';
133 include_once __DIR__ . '/dist/blocks/list/index.php';
134 include_once __DIR__ . '/dist/blocks/media-text/index.php';
135 include_once __DIR__ . '/dist/blocks/panels/index.php';
136 include_once __DIR__ . '/dist/blocks/panels/item/free/index.php';
137 include_once __DIR__ . '/dist/blocks/panels/item/horizontal/index.php';
138 include_once __DIR__ . '/dist/blocks/panels/item/vertical/index.php';
139 include_once __DIR__ . '/dist/blocks/panels/item/block-link/index.php';
140 include_once __DIR__ . '/dist/blocks/pattern-inserter/index.php';
141 include_once __DIR__ . '/dist/blocks/pickup-slider/index.php';
142 include_once __DIR__ . '/dist/blocks/price-menu/index.php';
143 include_once __DIR__ . '/dist/blocks/price-menu/item/index.php';
144 include_once __DIR__ . '/dist/blocks/pricing-table/index.php';
145 include_once __DIR__ . '/dist/blocks/pricing-table/item/index.php';
146 include_once __DIR__ . '/dist/blocks/rating-box/index.php';
147 include_once __DIR__ . '/dist/blocks/rating-box/item/index.php';
148 include_once __DIR__ . '/dist/blocks/read-more-box/index.php';
149 include_once __DIR__ . '/dist/blocks/recent-posts/index.php';
150 include_once __DIR__ . '/dist/blocks/rss/index.php';
151 include_once __DIR__ . '/dist/blocks/section/index.php';
152 include_once __DIR__ . '/dist/blocks/section-break-the-grid/index.php';
153 include_once __DIR__ . '/dist/blocks/section-side-heading/index.php';
154 include_once __DIR__ . '/dist/blocks/section-with-bgimage/index.php';
155 include_once __DIR__ . '/dist/blocks/section-with-bgvideo/index.php';
156 include_once __DIR__ . '/dist/blocks/slider/index.php';
157 include_once __DIR__ . '/dist/blocks/slider/item/index.php';
158 include_once __DIR__ . '/dist/blocks/spider-slider/index.php';
159 include_once __DIR__ . '/dist/blocks/spider-pickup-slider/index.php';
160 include_once __DIR__ . '/dist/blocks/spider-contents-slider/index.php';
161 include_once __DIR__ . '/dist/blocks/spider-contents-slider/item/index.php';
162 include_once __DIR__ . '/dist/blocks/step/index.php';
163 include_once __DIR__ . '/dist/blocks/step/item/free/index.php';
164 include_once __DIR__ . '/dist/blocks/step/item/standard/index.php';
165 include_once __DIR__ . '/dist/blocks/tabs/index.php';
166 include_once __DIR__ . '/dist/blocks/tabs/tab-panel/index.php';
167 include_once __DIR__ . '/dist/blocks/taxonomy-posts/index.php';
168 include_once __DIR__ . '/dist/blocks/taxonomy-terms/index.php';
169 include_once __DIR__ . '/dist/blocks/testimonial/index.php';
170 include_once __DIR__ . '/dist/blocks/testimonial/item/index.php';
171 include_once __DIR__ . '/dist/blocks/thumbnail-gallery/index.php';
172 include_once __DIR__ . '/dist/blocks/thumbnail-gallery/item/index.php';
173 }
174
175 /**
176 * Add meta box for the Snow Monkey PR when the Gutenberg page or not using the Snow Monkey.
177 *
178 * @param string $post_type The post type.
179 * @return void
180 */
181 public function _add_pr_meta_box( $post_type ) {
182 if ( ! is_block_editor() || is_pro() ) {
183 return;
184 }
185
186 add_meta_box(
187 'snow-monkey-pr',
188 __( '[ PR ] Premium WordPress Theme Snow Monkey', 'snow-monkey-blocks' ),
189 array( $this, '_pr_meta_box_html' ),
190 $post_type,
191 'normal'
192 );
193 }
194
195 /**
196 * Display Snow Monkey PR meta box html.
197 *
198 * @return void
199 */
200 public function _pr_meta_box_html() {
201 ?>
202 <p>
203 <?php
204 printf(
205 // translators: %1$s: Start a tag, %2$s: End a tag.
206 esc_html__( 'Snow Monkey Blocks is optimized for the %1$sSnow Monkey%2$s theme, but it can also be used with other themes.', 'snow-monkey-blocks' ),
207 '<a href="https://snow-monkey.2inc.org/" target="_blank">',
208 '</a>'
209 );
210 printf(
211 // translators: %1$s: Start a tag, %2$s: End a tag.
212 esc_html__( 'When used together with the %1$sSnow Monkey%2$s theme, it can be displayed with the most beautiful balance, and it is displayed on the edit screen with the same design as the front screen.', 'snow-monkey-blocks' ),
213 '<a href="https://snow-monkey.2inc.org/" target="_blank">',
214 '</a>'
215 );
216 ?>
217 </p>
218 <?php
219 }
220 }
221
222 require_once __DIR__ . '/vendor/autoload.php';
223
224 /**
225 * Main file path of this plugin.
226 *
227 * @var string
228 */
229 define( 'SNOW_MONKEY_BLOCKS_MAIN_FILE_PATH', __FILE__ );
230
231 /**
232 * Directory url of this plugin.
233 *
234 * @var string
235 */
236 define( 'SNOW_MONKEY_BLOCKS_DIR_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
237
238 /**
239 * Directory path of this plugin.
240 *
241 * @var string
242 */
243 define( 'SNOW_MONKEY_BLOCKS_DIR_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
244
245 /**
246 * Whether pro edition.
247 *
248 * @return boolean
249 */
250 function is_pro() {
251 $is_pro = 'snow-monkey' === get_template() || 'snow-monkey/resources' === get_template();
252 return apply_filters( 'snow_monkey_blocks_pro', $is_pro );
253 }
254
255 /**
256 * Return true when active the Gutenberg plugin.
257 *
258 * @return boolean
259 */
260 function is_gutenberg_page() {
261 $post = get_post();
262 if ( ! $post ) {
263 return false;
264 }
265
266 return function_exists( '\is_gutenberg_page' ) && \is_gutenberg_page();
267 }
268
269 /**
270 * Return true when the page has block editor.
271 *
272 * @return boolean
273 */
274 function is_block_editor() {
275 return is_gutenberg_page()
276 || ( function_exists( '\use_block_editor_for_post' )
277 && \use_block_editor_for_post( get_post() ) );
278 }
279
280 new \Snow_Monkey\Plugin\Blocks\Bootstrap();
281