PluginProbe
Progress Bars / 1.2.6
Progress Bars v1.2.6
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.6, at progress-bars.php

115 lines 4.0 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.6
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 $dir = dirname( __FILE__ );
31
32 define( 'PROGRESS_BARS_BLOCKS_VERSION', "1.2.6" );
33 define( 'PROGRESS_BARS_BLOCKS_ADMIN_URL', plugin_dir_url( __FILE__ ) );
34 define( 'PROGRESS_BARS_BLOCKS_ADMIN_PATH', dirname( __FILE__ ) );
35
36 $script_asset_path = PROGRESS_BARS_BLOCKS_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 "progress-bars/progress-bar-block" block first.'
40 );
41 }
42 $index_js = PROGRESS_BARS_BLOCKS_ADMIN_URL . 'dist/index.js';
43 $script_asset = require $script_asset_path;
44 $all_dependencies = array_merge( $script_asset['dependencies'], [
45 'wp-blocks',
46 'wp-i18n',
47 'wp-element',
48 'wp-block-editor',
49 'progress-bars-blocks-controls-util',
50 'essential-blocks-eb-animation'
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 $load_animation_js = PROGRESS_BARS_BLOCKS_ADMIN_URL . 'assets/js/eb-animation-load.js';
61 wp_register_script(
62 'essential-blocks-eb-animation',
63 $load_animation_js,
64 [],
65 PROGRESS_BARS_BLOCKS_VERSION,
66 true
67 );
68
69 $animate_css = PROGRESS_BARS_BLOCKS_ADMIN_URL . 'assets/css/animate.min.css';
70 wp_register_style(
71 'essential-blocks-animation',
72 $animate_css,
73 [],
74 PROGRESS_BARS_BLOCKS_VERSION
75 );
76
77 $style_css = PROGRESS_BARS_BLOCKS_ADMIN_URL . 'dist/style.css';
78 wp_register_style(
79 'progress-bars-block-frontend-style',
80 $style_css,
81 [ 'essential-blocks-animation' ],
82 filemtime( PROGRESS_BARS_BLOCKS_ADMIN_PATH . '/dist/style.css' )
83 );
84
85 $frontend_js_path = include_once dirname( __FILE__ ) . "/dist/frontend/index.asset.php";
86 $frontend_js = "dist/frontend/index.js";
87 wp_register_script(
88 'eb-progress-bar-frontend',
89 plugins_url( $frontend_js, __FILE__ ),
90 $frontend_js_path['dependencies'],
91 $frontend_js_path['version'],
92 true
93 );
94
95 if ( ! WP_Block_Type_Registry::get_instance()->is_registered( 'essential-blocks/progress-bar' ) ) {
96 register_block_type(
97 Progress_Bar_Helper::get_block_register_path( 'progress-bars/progress-bar-block', PROGRESS_BARS_BLOCKS_ADMIN_PATH ),
98 [
99 'editor_script' => 'progress-bars-block-editor-js',
100 'editor_style' => 'progress-bars-block-frontend-style',
101 'style' => 'progress-bars-block-frontend-style',
102 'render_callback' => function ( $attribs, $content ) {
103 if ( ! is_admin() ) {
104 wp_enqueue_script( 'eb-progress-bar-frontend' );
105 wp_enqueue_script( 'essential-blocks-eb-animation' );
106 }
107 return $content;
108 }
109 ]
110 );
111 }
112 }
113
114 add_action( 'init', 'create_block_progress_bar_block_init', 99 );
115