# countdown-time/1.1.2/plugin.php

Countdown Timer Block – build urgency for events and launches, version 1.1.2. 48 lines.

- Page: https://pluginprobe.com/plugins/countdown-time/1.1.2/code/plugin.php
- Raw: https://pluginprobe.com/plugins/countdown-time/1.1.2/raw/plugin.php
- Modified: 2022-07-28T11:39:12+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/countdown-time/1.1.2/code/plugin.php#L10-L20`.

```php
<?php
/**
 * Plugin Name: Countdown Time - Block
 * Description: Display your events date into a timer to your visitor with countdown time block
 * Version: 1.1.2
 * Author: bPlugins LLC
 * Author URI: http://bplugins.com
 * License: GPLv3
 * License URI: https://www.gnu.org/licenses/gpl-3.0.txt
 * Text Domain: countdown-time
 */

// ABS PATH
if ( !defined( 'ABSPATH' ) ) { exit; }

// Constant
define( 'CTB_PLUGIN_VERSION', isset($_SERVER['HTTP_HOST']) && 'localhost' === $_SERVER['HTTP_HOST'] ? time() : '1.1.2' );
define( 'CTB_ASSETS_DIR', plugin_dir_url( __FILE__ ) . 'assets/' );

// Countdown Time
class CTBCountdownTimeBlock{
	function __construct(){
		add_action( 'init', [$this, 'onInit'] );
	}

	function onInit() {
		wp_register_style( 'ctb-countdown-time-editor-style', plugins_url( 'dist/editor.css', __FILE__ ), [ 'wp-edit-blocks' ], CTB_PLUGIN_VERSION ); // Backend Style
		wp_register_style( 'ctb-countdown-time-style', plugins_url( 'dist/style.css', __FILE__ ), [ 'wp-editor' ], CTB_PLUGIN_VERSION ); // Frontend Style

		register_block_type( __DIR__, [
			'editor_style'		=> 'ctb-countdown-time-editor-style',
			'style'				=> 'ctb-countdown-time-style',
			'render_callback'	=> [$this, 'render']
		] ); // Register Block
		
		wp_set_script_translations( 'ctb-countdown-time-editor-script', 'countdown-time', plugin_dir_path( __FILE__ ) . '/languages' ); // Translate
	}

	function render( $attributes ){
		extract( $attributes );

		ob_start(); ?>
		<div class='wp-block-ctb-countdown-time <?php echo 'align' . esc_attr( $align ); ?>' id='ctbCountdownTime-<?php echo esc_attr( $cId ) ?>' data-attributes='<?php echo esc_attr( wp_json_encode( $attributes ) ); ?>'></div>

		<?php return ob_get_clean();
	} // Render
}
new CTBCountdownTimeBlock;
```
