# countdown-time/1.3.2/plugin.php

Countdown Timer Block – build urgency for events and launches, version 1.3.2. 125 lines.

- Page: https://pluginprobe.com/plugins/countdown-time/1.3.2/code/plugin.php
- Raw: https://pluginprobe.com/plugins/countdown-time/1.3.2/raw/plugin.php
- Modified: 2026-03-04T18:05:20+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.3.2/code/plugin.php#L10-L20`.

```php
<?php
/**
 * Plugin Name: Countdown Timer
 * Description: Display your events date into a timer to your visitor with countdown time block
 * Version: 1.3.2
 * Author: bPlugins
 * Author URI: https://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; }

if ( function_exists( 'ctb_fs' ) ) {
	ctb_fs()->set_basename( false, __FILE__ );
}else{
	define( 'CTB_VERSION', isset( $_SERVER['HTTP_HOST'] ) && ( 'localhost' === $_SERVER['HTTP_HOST'] || 'plugins.local' === $_SERVER['HTTP_HOST'] ) ? time() : '1.3.2' );
	define( 'CTB_DIR_URL', plugin_dir_url( __FILE__ ) );
	define( 'CTB_DIR_PATH', plugin_dir_path( __FILE__ ) );
	define( 'CTB_HAS_PRO', file_exists( CTB_DIR_PATH . 'vendor/freemius/start.php' ) );

	if ( CTB_HAS_PRO ) {
		require_once CTB_DIR_PATH . 'includes/fs.php';
		require_once CTB_DIR_PATH . 'includes/admin/CPT.php';
		require_once CTB_DIR_PATH . 'includes/LicenseActivation.php';
	}else{
		require_once CTB_DIR_PATH . 'includes/fs-lite.php';
		require_once CTB_DIR_PATH . 'includes/admin/SubMenu.php';
	}

	require_once CTB_DIR_PATH . 'includes/Patterns.php';

	function ctbIsPremium(){
		return CTB_HAS_PRO ? ctb_fs()->can_use_premium_code() : false;
	}

	if( !class_exists( 'CTBPlugin' ) ){
		class CTBPlugin{
			function __construct(){
				add_action( 'init', [ $this, 'onInit' ] );
				add_filter( 'block_categories_all', [$this, 'blockCategories'] );
				add_action( 'admin_enqueue_scripts', [$this, 'adminEnqueueScripts'] );
				add_action( 'enqueue_block_editor_assets', [$this, 'enqueueBlockEditorAssets'] );

				add_filter( 'plugin_action_links', [$this, 'pluginActionLinks'], 10, 2 );
				add_filter( 'default_title', [$this, 'defaultTitle'], 10, 2 );
				add_filter( 'default_content', [$this, 'defaultContent'], 10, 2 );
			}
			
			function defaultTitle( $title, $post ) {
				if ( 'page' === $post->post_type && isset( $_GET['title'] ) ) {
					$nonce = isset( $_GET['nonce'] ) ? sanitize_text_field( wp_unslash( $_GET['nonce'] ) ) : '';

					if ( wp_verify_nonce( $nonce, 'ctbCreatePage' ) ) {
						return sanitize_text_field( wp_unslash( $_GET['title'] ) );
					}
				}
				return $title;
			}

			function defaultContent( $content, $post ) {
				if ( 'page' === $post->post_type && isset( $_GET['content'] ) ) {
					$nonce = isset( $_GET['nonce'] ) ? sanitize_text_field( wp_unslash( $_GET['nonce'] ) ) : '';

					if ( wp_verify_nonce( $nonce, 'ctbCreatePage' ) ) {
						// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Content is secured by nonce verification and unslashed to preserve Gutenberg block markup.
						return wp_unslash( $_GET['content'] );
					}
				}
				return $content;
			}

			function pluginActionLinks( $links, $file ) {
				if( plugin_basename( __FILE__ ) === $file ) {
					$helpDemosLink = admin_url( CTB_HAS_PRO ? 'edit.php?post_type=ctb&page=countdown-time#/welcome' : 'tools.php?page=countdown-time#/welcome' );

					$links['help-and-demos'] = sprintf( '<a href="%s" style="%s">%s</a>', $helpDemosLink, 'color:#FF7A00;font-weight:bold', __( 'Help & Demos', 'countdown-time' ) );
				}
	
				return $links;
			}

			function onInit(){
				register_block_type( __DIR__ . '/build' );
			}

			function blockCategories( $categories ){
				return array_merge( [ [
					'slug'	=> 'CTBlock',
					'title'	=> 'Countdown Time'
				] ], $categories );
			}

			function adminEnqueueScripts( $hook ) {
				if( strpos( $hook, 'countdown-time' ) ){
					wp_enqueue_style( 'ctb-admin-dashboard', CTB_DIR_URL . 'build/admin/dashboard.css', [], CTB_VERSION );

					$asset_file = include CTB_DIR_PATH . 'build/admin/dashboard.asset.php';
					wp_enqueue_script( 'ctb-admin-dashboard', CTB_DIR_URL . 'build/admin/dashboard.js', array_merge( $asset_file['dependencies'], [ 'wp-util' ] ), CTB_VERSION, true );
					wp_set_script_translations( 'ctb-admin-dashboard', 'countdown-time', CTB_DIR_PATH . 'languages' );
				}
			}

			function enqueueBlockEditorAssets(){
				wp_add_inline_script( 'ctb-countdown-time-editor-script', 'const ctppipecheck = ' . wp_json_encode( ctbIsPremium() ) .'; const ctbpricingurl = "'. admin_url( CTB_HAS_PRO ? 'edit.php?post_type=ctb&page=countdown-time#/pricing' : 'tools.php?page=countdown-time#/pricing' ) .'";', 'before' );
			}

			static function renderDashboard(){ ?>
				<div
					id='ctbDashboard'
					data-info='<?php echo esc_attr( wp_json_encode( [
						'version' => CTB_VERSION,
						'isPremium' => ctbIsPremium(),
						'hasPro' => CTB_HAS_PRO,
						'nonce' => wp_create_nonce( 'ctbCreatePage' ),
						'licenseActiveNonce' => wp_create_nonce( 'bPlLicenseActivation' )
					] ) ); ?>'
				></div>
			<?php }
		}
		new CTBPlugin;
	}
}
```
