PluginProbe
Progress Bars / 1.2.4
Progress Bars v1.2.4
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.4, at progress-bars.php

117 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: Progress Bar
5 * Plugin URI: https://essential-blocks.com
6 * Description: Make your website interactive with stunning progress bar
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: 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.4");
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 'essential-blocks-eb-animation'
52 ));
53
54 wp_register_script(
55 'progress-bars-block-editor-js',
56 $index_js,
57 $all_dependencies,
58 $script_asset['version']
59 );
60
61 $load_animation_js = PROGRESS_BARS_BLOCKS_ADMIN_URL . 'assets/js/eb-animation-load.js';
62 wp_register_script(
63 'essential-blocks-eb-animation',
64 $load_animation_js,
65 array(),
66 PROGRESS_BARS_BLOCKS_VERSION,
67 true
68 );
69
70 $animate_css = PROGRESS_BARS_BLOCKS_ADMIN_URL . 'assets/css/animate.min.css';
71 wp_register_style(
72 'essential-blocks-animation',
73 $animate_css,
74 array(),
75 PROGRESS_BARS_BLOCKS_VERSION
76 );
77
78 $style_css = PROGRESS_BARS_BLOCKS_ADMIN_URL . 'dist/style.css';
79 wp_register_style(
80 'progress-bars-block-frontend-style',
81 $style_css,
82 array('essential-blocks-animation'),
83 filemtime(PROGRESS_BARS_BLOCKS_ADMIN_PATH . '/dist/style.css')
84 );
85
86 $frontend_js_path = include_once dirname(__FILE__) . "/dist/frontend/index.asset.php";
87 $frontend_js = "dist/frontend/index.js";
88 wp_register_script(
89 'eb-progress-bar-frontend',
90 plugins_url($frontend_js, __FILE__),
91 $frontend_js_path['dependencies'],
92 $frontend_js_path['version'],
93 true
94 );
95
96
97 if (!WP_Block_Type_Registry::get_instance()->is_registered('essential-blocks/progress-bar')) {
98 register_block_type(
99 Progress_Bar_Helper::get_block_register_path('progress-bars/progress-bar-block', PROGRESS_BARS_BLOCKS_ADMIN_PATH),
100 array(
101 'editor_script' => 'progress-bars-block-editor-js',
102 'editor_style' => 'progress-bars-block-frontend-style',
103 'style' => 'progress-bars-block-frontend-style',
104 'render_callback' => function ($attribs, $content) {
105 if (!is_admin()) {
106 wp_enqueue_script('eb-progress-bar-frontend');
107 wp_enqueue_script('essential-blocks-eb-animation');
108 }
109 return $content;
110 }
111 )
112 );
113 }
114 }
115
116 add_action('init', 'create_block_progress_bar_block_init', 99);
117