PluginProbe
Countdown Block / 1.2.7
Countdown Block v1.2.7
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.7, at countdown-block.php

115 lines 3.6 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.7
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 define( 'COUNTDOWN_VERSION', "1.2.7" );
25 define( 'COUNTDOWN_ADMIN_URL', plugin_dir_url( __FILE__ ) );
26 define( 'COUNTDOWN_ADMIN_PATH', dirname( __FILE__ ) );
27
28 require_once __DIR__ . '/includes/font-loader.php';
29 require_once __DIR__ . '/includes/post-meta.php';
30 require_once __DIR__ . '/includes/helpers.php';
31 require_once __DIR__ . '/lib/style-handler/style-handler.php';
32
33 function create_block_countdown_block_init() {
34
35 $script_asset_path = COUNTDOWN_ADMIN_PATH . "/dist/index.asset.php";
36 if ( ! file_exists( $script_asset_path ) ) {
37 throw new Error(
38 'You need to run `npm start` or `npm run build` for the "countdown-block/countdown" block first.'
39 );
40 }
41 $script_asset = require $script_asset_path;
42 $all_dependencies = array_merge( $script_asset['dependencies'], [
43 'wp-blocks',
44 'wp-i18n',
45 'wp-element',
46 'wp-block-editor',
47 'countdown-controls-util',
48 'essential-blocks-eb-animation'
49 ] );
50
51 $index_js = COUNTDOWN_ADMIN_URL . 'dist/index.js';
52 wp_register_script(
53 'create-block-countdown-block-editor',
54 $index_js,
55 $all_dependencies,
56 $script_asset['version'],
57 true
58 );
59
60 $load_animation_js = COUNTDOWN_ADMIN_URL . 'assets/js/eb-animation-load.js';
61 wp_register_script(
62 'essential-blocks-eb-animation',
63 $load_animation_js,
64 [],
65 COUNTDOWN_VERSION,
66 true
67 );
68
69 $animate_css = COUNTDOWN_ADMIN_URL . 'assets/css/animate.min.css';
70 wp_register_style(
71 'essential-blocks-animation',
72 $animate_css,
73 [],
74 COUNTDOWN_VERSION
75 );
76
77 $style_css = COUNTDOWN_ADMIN_URL . 'dist/style.css';
78 wp_register_style(
79 'create-block-countdown-block-editor-css',
80 $style_css,
81 ['essential-blocks-animation'],
82 COUNTDOWN_VERSION,
83 "all"
84 );
85
86 $frontend_js = COUNTDOWN_ADMIN_URL . 'dist/frontend/index.js';
87 wp_register_script(
88 'essential-blocks-countdown-frontend',
89 $frontend_js,
90 [],
91 COUNTDOWN_VERSION,
92 true
93 );
94
95 if ( ! WP_Block_Type_Registry::get_instance()->is_registered( 'essential-blocks/countdown' ) ) {
96 register_block_type(
97 Countdown_Helper::get_block_register_path( "countdown-block/countdown", COUNTDOWN_ADMIN_PATH ),
98 [
99 'editor_script' => 'create-block-countdown-block-editor',
100 'editor_style' => 'create-block-countdown-block-editor-css',
101 'render_callback' => function ( $attributes, $content ) {
102 if ( ! is_admin() ) {
103 wp_enqueue_style( 'create-block-countdown-block-editor-css' );
104 wp_enqueue_script( 'essential-blocks-countdown-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_countdown_block_init', 99 );
115