PluginProbe
Infobox / trunk
Infobox vtrunk
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 trunk, at infobox.php

162 lines 4.8 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.3.0
8 * Author: WPDeveloper
9 * Author URI: https://wpdeveloper.net
10 * Requires at least: 6.0
11 * Tested up to: 7.0
12 * Requires PHP: 7.4
13 * License: GPL-3.0-or-later
14 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
15 * Text Domain: infobox
16 *
17 * @package infobox
18 */
19
20 // Exit if accessed directly.
21 if ( ! defined( 'ABSPATH' ) ) {
22 exit;
23 }
24
25 /**
26 * Registers all block assets so that they can be enqueued through the block editor
27 * in the corresponding context.
28 *
29 * @see https://developer.wordpress.org/block-editor/tutorials/block-tutorial/applying-styles-with-stylesheets/
30 */
31
32 define( 'INFOBOX_VERSION', "1.3.0" );
33 define( 'INFOBOX_ADMIN_URL', plugin_dir_url( __FILE__ ) );
34 define( 'INFOBOX_ADMIN_PATH', dirname( __FILE__ ) );
35
36 require_once __DIR__ . '/includes/font-loader.php';
37 require_once __DIR__ . '/includes/post-meta.php';
38 require_once __DIR__ . '/includes/helpers.php';
39
40 /**
41 * `lib/style-handler` ships as a git submodule. Guard the include so an
42 * uninitialised submodule degrades gracefully instead of fataling on load.
43 */
44 if ( file_exists( __DIR__ . '/lib/style-handler/style-handler.php' ) ) {
45 require_once __DIR__ . '/lib/style-handler/style-handler.php';
46 }
47
48 if ( ! function_exists( 'create_block_infobox_block_init' ) ) :
49 function create_block_infobox_block_init() {
50
51 $script_asset_path = INFOBOX_ADMIN_PATH . "/dist/index.asset.php";
52 if ( ! file_exists( $script_asset_path ) ) {
53 // Build artefacts are missing (`npm run build` has not been run).
54 // Bail out instead of throwing: `Error` does not exist on PHP < 7 and
55 // an uncaught throw on `init` takes the whole site down.
56 return;
57 }
58 $script_asset = require $script_asset_path;
59 if ( ! is_array( $script_asset ) || ! isset( $script_asset['dependencies'], $script_asset['version'] ) ) {
60 return;
61 }
62 $all_dependencies = array_merge( (array) $script_asset['dependencies'], [
63 'wp-blocks',
64 'wp-i18n',
65 'wp-element',
66 'wp-block-editor',
67 'infobox-controls-util',
68 'essential-blocks-eb-animation'
69 ] );
70
71 $index_js = INFOBOX_ADMIN_URL . 'dist/index.js';
72 wp_register_script(
73 'create-block-infobox-block-editor',
74 $index_js,
75 $all_dependencies,
76 $script_asset['version'],
77 true
78 );
79
80 $animate_css = INFOBOX_ADMIN_URL . 'assets/css/animate.min.css';
81 wp_register_style(
82 'essential-blocks-animation',
83 $animate_css,
84 [],
85 INFOBOX_VERSION
86 );
87
88 $style_css = INFOBOX_ADMIN_URL . 'dist/style.css';
89 wp_register_style(
90 'create-block-infobox-block-css',
91 $style_css,
92 [
93 'essential-blocks-hover-css',
94 'essential-blocks-animation',
95 'fontawesome-frontend-css'
96 ],
97 INFOBOX_VERSION,
98 "all"
99 );
100
101 $load_animation_js = INFOBOX_ADMIN_URL . 'assets/js/eb-animation-load.js';
102 wp_register_script(
103 'essential-blocks-eb-animation',
104 $load_animation_js,
105 [],
106 INFOBOX_VERSION,
107 true
108 );
109
110 wp_register_style(
111 'fontpicker-default-theme',
112 INFOBOX_ADMIN_URL . 'assets/css/fonticonpicker.base-theme.react.css',
113 [],
114 INFOBOX_VERSION,
115 "all"
116 );
117
118 wp_register_style(
119 'fontpicker-matetial-theme',
120 INFOBOX_ADMIN_URL . 'assets/css/fonticonpicker.material-theme.react.css',
121 [],
122 INFOBOX_VERSION,
123 "all"
124 );
125
126 wp_register_style(
127 'fontawesome-frontend-css',
128 INFOBOX_ADMIN_URL . 'assets/css/font-awesome5.css',
129 [],
130 INFOBOX_VERSION,
131 "all"
132 );
133
134 wp_register_style(
135 'essential-blocks-hover-css',
136 INFOBOX_ADMIN_URL . 'assets/css/hover-min.css',
137 [],
138 INFOBOX_VERSION,
139 "all"
140 );
141
142 if ( ! WP_Block_Type_Registry::get_instance()->is_registered( 'essential-blocks/infobox' ) ) {
143 register_block_type(
144 Infobox_Helper::get_block_register_path( "infobox/infobox", INFOBOX_ADMIN_PATH ),
145 [
146 'editor_script' => 'create-block-infobox-block-editor',
147 'editor_style' => 'infobox-editor-css',
148 'render_callback' => function ( $attributes, $content ) {
149 if ( ! is_admin() ) {
150 wp_enqueue_style( 'create-block-infobox-block-css' );
151 wp_enqueue_script( 'essential-blocks-eb-animation' );
152 }
153 return $content;
154 }
155 ]
156 );
157 }
158 }
159 endif;
160
161 add_action( 'init', 'create_block_infobox_block_init', 99 );
162