PluginProbe
Infobox / 1.2.4
Infobox v1.2.4
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.4, at infobox.php

141 lines 4.1 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.4
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.4" );
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 $script_asset_path = INFOBOX_ADMIN_PATH . "/dist/index.asset.php";
36 if ( ! file_exists( $script_asset_path ) ) {
37 throw new Error(
38 'You need to run `npm start` or `npm run build` for the "infobox/infobox" block first.'
39 );
40 }
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 'infobox-controls-util',
48 'essential-blocks-eb-animation'
49 ] );
50
51 $index_js = INFOBOX_ADMIN_URL . 'dist/index.js';
52 wp_register_script(
53 'create-block-infobox-block-editor',
54 $index_js,
55 $all_dependencies,
56 $script_asset['version'],
57 true
58 );
59
60 $animate_css = INFOBOX_ADMIN_URL . 'assets/css/animate.min.css';
61 wp_register_style(
62 'essential-blocks-animation',
63 $animate_css,
64 [],
65 INFOBOX_VERSION
66 );
67
68 $style_css = INFOBOX_ADMIN_URL . 'dist/style.css';
69 wp_register_style(
70 'create-block-infobox-block-css',
71 $style_css,
72 [
73 'essential-blocks-hover-css',
74 'essential-blocks-animation',
75 'fontawesome-frontend-css'
76 ],
77 INFOBOX_VERSION,
78 "all"
79 );
80
81 $load_animation_js = INFOBOX_ADMIN_URL . 'assets/js/eb-animation-load.js';
82 wp_register_script(
83 'essential-blocks-eb-animation',
84 $load_animation_js,
85 [],
86 INFOBOX_VERSION,
87 true
88 );
89
90 wp_register_style(
91 'fontpicker-default-theme',
92 INFOBOX_ADMIN_URL . 'assets/css/fonticonpicker.base-theme.react.css',
93 [],
94 INFOBOX_VERSION,
95 "all"
96 );
97
98 wp_register_style(
99 'fontpicker-matetial-theme',
100 INFOBOX_ADMIN_URL . 'assets/css/fonticonpicker.material-theme.react.css',
101 [],
102 INFOBOX_VERSION,
103 "all"
104 );
105
106 wp_register_style(
107 'fontawesome-frontend-css',
108 INFOBOX_ADMIN_URL . 'assets/css/font-awesome5.css',
109 [],
110 INFOBOX_VERSION,
111 "all"
112 );
113
114 wp_register_style(
115 'essential-blocks-hover-css',
116 INFOBOX_ADMIN_URL . 'assets/css/hover-min.css',
117 [],
118 INFOBOX_VERSION,
119 "all"
120 );
121
122 if ( ! WP_Block_Type_Registry::get_instance()->is_registered( 'essential-blocks/infobox' ) ) {
123 register_block_type(
124 Infobox_Helper::get_block_register_path( "infobox/infobox", INFOBOX_ADMIN_PATH ),
125 [
126 'editor_script' => 'create-block-infobox-block-editor',
127 'editor_style' => 'infobox-editor-css',
128 'render_callback' => function ( $attributes, $content ) {
129 if ( ! is_admin() ) {
130 wp_enqueue_style( 'create-block-infobox-block-css' );
131 wp_enqueue_script( 'essential-blocks-eb-animation' );
132 }
133 return $content;
134 }
135 ]
136 );
137 }
138 }
139
140 add_action( 'init', 'create_block_infobox_block_init', 99 );
141