PluginProbe
Progress Bars / 1.2.1
Progress Bars v1.2.1
trunk 1.0.0 1.0.1 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0
progress-bars / progress-bars.php

progress-bars.php in Progress Bars 1.2.1, at progress-bars.php

98 lines 2.9 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: Progress Bar
5 * Plugin URI: https://essential-blocks.com
6 * Description: Make your website interactive with stunning progress bar
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: progress-bars
13 *
14 * @package progress-bars
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_progress_bar_block_init()
30 {
31 $dir = dirname(__FILE__);
32
33 define('PROGRESS_BARS_BLOCKS_VERSION', "1.2.1");
34 define('PROGRESS_BARS_BLOCKS_ADMIN_URL', plugin_dir_url(__FILE__));
35 define('PROGRESS_BARS_BLOCKS_ADMIN_PATH', dirname(__FILE__));
36
37 $script_asset_path = PROGRESS_BARS_BLOCKS_ADMIN_PATH . "/dist/index.asset.php";
38 if (!file_exists($script_asset_path)) {
39 throw new Error(
40 'You need to run `npm start` or `npm run build` for the "progress-bars/progress-bar-block" block first.'
41 );
42 }
43 $index_js = PROGRESS_BARS_BLOCKS_ADMIN_URL . 'dist/index.js';
44 $script_asset = require($script_asset_path);
45 $all_dependencies = array_merge($script_asset['dependencies'], array(
46 'wp-blocks',
47 'wp-i18n',
48 'wp-element',
49 'wp-block-editor',
50 'progress-bars-blocks-controls-util'
51 ));
52
53 wp_register_script(
54 'progress-bars-block-editor-js',
55 $index_js,
56 $all_dependencies,
57 $script_asset['version']
58 );
59
60 $style_css = PROGRESS_BARS_BLOCKS_ADMIN_URL . 'dist/style.css';
61 wp_register_style(
62 'progress-bars-block-frontend-style',
63 $style_css,
64 array(),
65 filemtime(PROGRESS_BARS_BLOCKS_ADMIN_PATH . '/dist/style.css')
66 );
67
68 $frontend_js_path = include_once dirname(__FILE__) . "/dist/frontend/index.asset.php";
69 $frontend_js = "dist/frontend/index.js";
70 wp_register_script(
71 'eb-progress-bar-frontend',
72 plugins_url($frontend_js, __FILE__),
73 $frontend_js_path['dependencies'],
74 $frontend_js_path['version'],
75 true
76 );
77
78
79 if (!WP_Block_Type_Registry::get_instance()->is_registered('essential-blocks/progress-bar')) {
80 register_block_type(
81 Progress_Bar_Helper::get_block_register_path('progress-bars/progress-bar-block', PROGRESS_BARS_BLOCKS_ADMIN_PATH),
82 array(
83 'editor_script' => 'progress-bars-block-editor-js',
84 'editor_style' => 'progress-bars-block-frontend-style',
85 'style' => 'progress-bars-block-frontend-style',
86 'render_callback' => function ($attribs, $content) {
87 if (!is_admin()) {
88 wp_enqueue_script('eb-progress-bar-frontend');
89 }
90 return $content;
91 }
92 )
93 );
94 }
95 }
96
97 add_action('init', 'create_block_progress_bar_block_init');
98