PluginProbe
Flipbox / 1.3.0
Flipbox v1.3.0
trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.4.0
flipbox / flipbox.php

flipbox.php in Flipbox 1.3.0, at flipbox.php

130 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: Flipbox
5 * Plugin URI: https://essential-blocks.com
6 * Description: Deliver your content beautifully to grab attention with an animated Flipbox block.
7 * Version: 1.3.0
8 * Author: WPDeveloper
9 * Author URI: https://wpdeveloper.net
10 * License: GPL-2.0-or-later
11 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
12 * Text Domain: flipbox
13 *
14 * @package flipbox
15 */
16
17 /**
18 * Registers all block assets so that they can be enqueued through the block editor
19 * in the corresponding context.
20 *
21 * @see https://developer.wordpress.org/block-editor/tutorials/block-tutorial/applying-styles-with-stylesheets/
22 */
23
24 require_once __DIR__ . '/includes/font-loader.php';
25 require_once __DIR__ . '/includes/post-meta.php';
26 require_once __DIR__ . '/includes/helpers.php';
27 require_once __DIR__ . '/lib/style-handler/style-handler.php';
28
29 function create_block_flipbox_block_init() {
30 define( 'EB_FLIPBOX_BLOCKS_VERSION', "1.3.0" );
31 define( 'EB_FLIPBOX_BLOCKS_ADMIN_URL', plugin_dir_url( __FILE__ ) );
32 define( 'EB_FLIPBOX_BLOCKS_ADMIN_PATH', dirname( __FILE__ ) );
33
34 $script_asset_path = EB_FLIPBOX_BLOCKS_ADMIN_PATH . "/dist/index.asset.php";
35 if ( ! file_exists( $script_asset_path ) ) {
36 throw new Error(
37 'You need to run `npm start` or `npm run build` for the "flipbox/flipbox-block" block first.'
38 );
39 }
40 $index_js = EB_FLIPBOX_BLOCKS_ADMIN_URL . 'dist/index.js';
41 $script_asset = require $script_asset_path;
42 $all_dependencies = array_merge( $script_asset['dependencies'], [
43 'wp-blocks',
44 'wp-i18n',
45 'wp-element',
46 'wp-block-editor',
47 'eb-flipbox-blocks-controls-util',
48 'essential-blocks-eb-animation'
49 ] );
50
51 wp_register_script(
52 'eb-flipbox-block-editor-js',
53 $index_js,
54 $all_dependencies,
55 $script_asset['version']
56 );
57
58 $load_animation_js = EB_FLIPBOX_BLOCKS_ADMIN_URL . 'assets/js/eb-animation-load.js';
59 wp_register_script(
60 'essential-blocks-eb-animation',
61 $load_animation_js,
62 [],
63 EB_FLIPBOX_BLOCKS_VERSION,
64 true
65 );
66
67 $frontend_js = EB_FLIPBOX_BLOCKS_ADMIN_URL . 'dist/frontend/index.js';
68 wp_register_script(
69 'essential-blocks-frontend-js',
70 $frontend_js,
71 ['essential-blocks-eb-animation'],
72 EB_FLIPBOX_BLOCKS_VERSION,
73 true
74 );
75
76 $animate_css = EB_FLIPBOX_BLOCKS_ADMIN_URL . 'assets/css/animate.min.css';
77 wp_register_style(
78 'essential-blocks-animation',
79 $animate_css,
80 [],
81 EB_FLIPBOX_BLOCKS_VERSION
82 );
83
84 $fontpicker_theme = 'assets/css/fonticonpicker.base-theme.react.css';
85 wp_register_style(
86 'fontpicker-default-theme',
87 plugins_url( $fontpicker_theme, __FILE__ ),
88 []
89 );
90
91 $fontpicker_material_theme = 'assets/css/fonticonpicker.material-theme.react.css';
92 wp_register_style(
93 'fontpicker-matetial-theme',
94 plugins_url( $fontpicker_material_theme, __FILE__ ),
95 []
96 );
97
98 $fontawesome_css = 'assets/css/fontawesome/css/all.min.css';
99 wp_register_style(
100 'fontawesome-frontend-css',
101 plugins_url( $fontawesome_css, __FILE__ ),
102 []
103 );
104
105 $style_css = EB_FLIPBOX_BLOCKS_ADMIN_URL . 'dist/style.css';
106 wp_register_style(
107 'eb-flipbox-block-frontend-style',
108 $style_css,
109 ['fontawesome-frontend-css', 'essential-blocks-animation'],
110 filemtime( EB_FLIPBOX_BLOCKS_ADMIN_PATH . '/dist/style.css' )
111 );
112
113 if ( ! WP_Block_Type_Registry::get_instance()->is_registered( 'essential-blocks/flipbox' ) ) {
114 register_block_type(
115 Flipbox_Helper::get_block_register_path( 'flipbox/flipbox-block', EB_FLIPBOX_BLOCKS_ADMIN_PATH ),
116 [
117 'editor_script' => 'eb-flipbox-block-editor-js',
118 'style' => 'eb-flipbox-block-frontend-style',
119 'render_callback' => function ( $attributes, $content ) {
120 if ( ! is_admin() ) {
121 wp_enqueue_script( 'essential-blocks-frontend-js' );
122 }
123 return $content;
124 }
125 ]
126 );
127 }
128 }
129 add_action( 'init', 'create_block_flipbox_block_init', 99 );
130