PluginProbe
Countdown Timer Block – build urgency for events and launches / 1.2.1
Countdown Timer Block – build urgency for events and launches v1.2.1
1.3.3 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 32 releases
countdown-time / inc / block.php

block.php in Countdown Timer Block – build urgency for events and launches 1.2.1, at inc/block.php

42 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class CTBBlock{
3 function __construct(){
4 add_action( 'init', [$this, 'onInit'] );
5 }
6
7 function onInit() {
8 wp_register_style( 'ctb-countdown-time-style', CTB_DIR_URL . 'dist/style.css', [], CTB_VERSION );
9 wp_register_style( 'ctb-countdown-time-editor-style', CTB_DIR_URL . 'dist/editor.css', [ 'ctb-countdown-time-style' ], CTB_VERSION );
10
11 register_block_type( __DIR__, [
12 'editor_style' => 'ctb-countdown-time-editor-style',
13 'render_callback' => [$this, 'render']
14 ] );
15
16 wp_set_script_translations( 'ctb-countdown-time-editor-script', 'countdown-time', CTB_DIR_PATH . '/languages' );
17 }
18
19 function render( $attributes, $content ){
20 extract( $attributes );
21
22 wp_enqueue_style( 'ctb-countdown-time-style' );
23 wp_enqueue_script( 'ctb-countdown-time-script', CTB_DIR_URL . 'dist/script.js', [ 'react', 'react-dom' ], CTB_VERSION, true );
24 wp_set_script_translations( 'ctb-countdown-time-script', 'countdown-time', CTB_DIR_PATH . '/languages' );
25
26 $className = $className ?? '';
27 $extraClass = ctbIsPremium() ? 'premium' : 'free';
28 $blockClassName = "wp-block-ctb-countdown-time $extraClass $className align$align";
29
30 ob_start(); ?>
31 <div
32 class='<?php echo esc_attr( $blockClassName ); ?>'
33 id='ctbCountdownTime-<?php echo esc_attr( $cId ) ?>'
34 data-nonce='<?php echo esc_attr( wp_json_encode( wp_create_nonce( 'wp_ajax' ) ) ); ?>'
35 data-attributes='<?php echo esc_attr( wp_json_encode( $attributes ) ); ?>'
36 data-content='<?php echo esc_attr( wp_json_encode( $content ) ); ?>'
37 ></div>
38
39 <?php return ob_get_clean();
40 } // Render
41 }
42 new CTBBlock;