PluginProbe
Infobox / 1.2.1
Infobox v1.2.1
trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0
infobox / infobox.php

infobox.php in Infobox 1.2.1, at infobox.php

143 lines 3.5 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: Infobox
5 * Plugin URI: https://essential-blocks.com
6 * Description: Highlight Your Key Features & Hold Audience Attention with Info Box Block.
7 * Version: 1.2.1
8 * Author: WPDeveloper
9 * Author URI: https://wpdeveloper.net
10 * License: GPL-3.0-or-later
11 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
12 * Text Domain: infobox
13 *
14 * @package infobox
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 define('INFOBOX_VERSION', "1.2.1");
25 define('INFOBOX_ADMIN_URL', plugin_dir_url(__FILE__));
26 define('INFOBOX_ADMIN_PATH', dirname(__FILE__));
27
28 require_once __DIR__ . '/includes/font-loader.php';
29 require_once __DIR__ . '/includes/post-meta.php';
30 require_once __DIR__ . '/includes/helpers.php';
31 require_once __DIR__ . '/lib/style-handler/style-handler.php';
32
33 function create_block_infobox_block_init()
34 {
35
36 $script_asset_path = INFOBOX_ADMIN_PATH . "/dist/index.asset.php";
37 if (!file_exists($script_asset_path)) {
38 throw new Error(
39 'You need to run `npm start` or `npm run build` for the "infobox/infobox" block first.'
40 );
41 }
42 $script_asset = require($script_asset_path);
43 $all_dependencies = array_merge($script_asset['dependencies'], array(
44 'wp-blocks',
45 'wp-i18n',
46 'wp-element',
47 'wp-block-editor',
48 'infobox-controls-util',
49 'essential-blocks-eb-animation'
50 ));
51
52 $index_js = INFOBOX_ADMIN_URL . 'dist/index.js';
53 wp_register_script(
54 'create-block-infobox-block-editor',
55 $index_js,
56 $all_dependencies,
57 $script_asset['version'],
58 true
59 );
60
61 $animate_css = INFOBOX_ADMIN_URL . 'assets/css/animate.min.css';
62 wp_register_style(
63 'essential-blocks-animation',
64 $animate_css,
65 array(),
66 INFOBOX_VERSION
67 );
68
69 $style_css = INFOBOX_ADMIN_URL . 'dist/style.css';
70 wp_register_style(
71 'create-block-infobox-block-css',
72 $style_css,
73 array(
74 'essential-blocks-hover-css',
75 'essential-blocks-animation',
76 'fontawesome-frontend-css',
77 ),
78 INFOBOX_VERSION,
79 "all"
80 );
81
82 $load_animation_js = INFOBOX_ADMIN_URL . 'assets/js/eb-animation-load.js';
83 wp_register_script(
84 'essential-blocks-eb-animation',
85 $load_animation_js,
86 array(),
87 INFOBOX_VERSION,
88 true
89 );
90
91 wp_register_style(
92 'fontpicker-default-theme',
93 INFOBOX_ADMIN_URL . 'assets/css/fonticonpicker.base-theme.react.css',
94 array(),
95 INFOBOX_VERSION,
96 "all"
97 );
98
99 wp_register_style(
100 'fontpicker-matetial-theme',
101 INFOBOX_ADMIN_URL . 'assets/css/fonticonpicker.material-theme.react.css',
102 array(),
103 INFOBOX_VERSION,
104 "all"
105 );
106
107 wp_register_style(
108 'fontawesome-frontend-css',
109 INFOBOX_ADMIN_URL . 'assets/css/font-awesome5.css',
110 array(),
111 INFOBOX_VERSION,
112 "all"
113 );
114
115
116 wp_register_style(
117 'essential-blocks-hover-css',
118 INFOBOX_ADMIN_URL . 'assets/css/hover-min.css',
119 array(),
120 INFOBOX_VERSION,
121 "all"
122 );
123
124 if (!WP_Block_Type_Registry::get_instance()->is_registered('essential-blocks/infobox')) {
125 register_block_type(
126 Infobox_Helper::get_block_register_path("infobox/infobox", INFOBOX_ADMIN_PATH),
127 array(
128 'editor_script' => 'create-block-infobox-block-editor',
129 'editor_style' => 'infobox-editor-css',
130 'render_callback' => function ($attributes, $content) {
131 if (!is_admin()) {
132 wp_enqueue_style('create-block-infobox-block-css');
133 wp_enqueue_script('essential-blocks-eb-animation');
134 }
135 return $content;
136 }
137 )
138 );
139 }
140 }
141
142 add_action('init', 'create_block_infobox_block_init', 99);
143