PluginProbe
Countdown Block / 1.2.2
Countdown Block v1.2.2
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1.0 1.1.1 1.1.2 1.1.3 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.2.8 1.5.0
countdown-block / countdown-block.php

countdown-block.php in Countdown Block 1.2.2, at countdown-block.php

117 lines 3.2 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: Countdown Block
5 * Plugin URI: https://essential-blocks.com
6 * Description: Highlight Upcoming Events With Countdown Timer.
7 * Version: 1.2.2
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: countdown-block
13 *
14 * @package countdown-block
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
25 define('COUNTDOWN_VERSION', "1.2.2");
26 define('COUNTDOWN_ADMIN_URL', plugin_dir_url(__FILE__));
27 define('COUNTDOWN_ADMIN_PATH', dirname(__FILE__));
28
29 require_once __DIR__ . '/includes/font-loader.php';
30 require_once __DIR__ . '/includes/post-meta.php';
31 require_once __DIR__ . '/includes/helpers.php';
32 require_once __DIR__ . '/lib/style-handler/style-handler.php';
33
34 function create_block_countdown_block_init()
35 {
36
37 $script_asset_path = COUNTDOWN_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 "countdown-block/countdown" block first.'
41 );
42 }
43 $script_asset = require($script_asset_path);
44 $all_dependencies = array_merge($script_asset['dependencies'], array(
45 'wp-blocks',
46 'wp-i18n',
47 'wp-element',
48 'wp-block-editor',
49 'countdown-controls-util',
50 'essential-blocks-eb-animation'
51 ));
52
53 $index_js = COUNTDOWN_ADMIN_URL . 'dist/index.js';
54 wp_register_script(
55 'create-block-countdown-block-editor',
56 $index_js,
57 $all_dependencies,
58 $script_asset['version'],
59 true
60 );
61
62 $load_animation_js = COUNTDOWN_ADMIN_URL . 'assets/js/eb-animation-load.js';
63 wp_register_script(
64 'essential-blocks-eb-animation',
65 $load_animation_js,
66 array(),
67 COUNTDOWN_VERSION,
68 true
69 );
70
71 $animate_css = COUNTDOWN_ADMIN_URL . 'assets/css/animate.min.css';
72 wp_register_style(
73 'essential-blocks-animation',
74 $animate_css,
75 array(),
76 COUNTDOWN_VERSION
77 );
78
79 $style_css = COUNTDOWN_ADMIN_URL . 'dist/style.css';
80 wp_register_style(
81 'create-block-countdown-block-editor-css',
82 $style_css,
83 array('essential-blocks-animation'),
84 COUNTDOWN_VERSION,
85 "all"
86 );
87
88 $frontend_js = COUNTDOWN_ADMIN_URL . 'dist/frontend/index.js';
89 wp_register_script(
90 'essential-blocks-countdown-frontend',
91 $frontend_js,
92 array(),
93 COUNTDOWN_VERSION,
94 true
95 );
96
97 if (!WP_Block_Type_Registry::get_instance()->is_registered('essential-blocks/countdown')) {
98 register_block_type(
99 Countdown_Helper::get_block_register_path("countdown-block/countdown", COUNTDOWN_ADMIN_PATH),
100 array(
101 'editor_script' => 'create-block-countdown-block-editor',
102 'editor_style' => 'create-block-countdown-block-editor-css',
103 'render_callback' => function ($attributes, $content) {
104 if (!is_admin()) {
105 wp_enqueue_style('create-block-countdown-block-editor-css');
106 wp_enqueue_script('essential-blocks-countdown-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_countdown_block_init', 99);
117