PluginProbe
Countdown Timer Block – build urgency for events and launches / 1.1.5
Countdown Timer Block – build urgency for events and launches v1.1.5
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 / plugin.php

plugin.php in Countdown Timer Block – build urgency for events and launches 1.1.5, at plugin.php

69 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Countdown Time - Block
4 * Description: Display your events date into a timer to your visitor with countdown time block
5 * Version: 1.1.5
6 * Author: bPlugins LLC
7 * Author URI: http://bplugins.com
8 * License: GPLv3
9 * License URI: https://www.gnu.org/licenses/gpl-3.0.txt
10 * Text Domain: countdown-time
11 */
12
13 // ABS PATH
14 if ( !defined( 'ABSPATH' ) ) { exit; }
15
16 // Constant
17 define( 'CTB_PLUGIN_VERSION', isset($_SERVER['HTTP_HOST']) && 'localhost' === $_SERVER['HTTP_HOST'] ? time() : '1.1.5' );
18 define( 'CTB_ASSETS_DIR', plugin_dir_url( __FILE__ ) . 'assets/' );
19
20 // Countdown Time
21 class CTBCountdownTime{
22 function __construct(){
23 add_action( 'init', [$this, 'onInit'] );
24 register_activation_hook( __FILE__, [$this, 'onPluginActivate'] );
25
26 if ( version_compare( $GLOBALS['wp_version'], '5.8-alpha-1', '<' ) ) {
27 add_filter( 'block_categories', [$this, 'blockCategories'] );
28 } else { add_filter( 'block_categories_all', [$this, 'blockCategories'] ); }
29 }
30
31 function onPluginActivate(){
32 if ( is_plugin_active( 'countdown-time-pro/plugin.php' ) ){
33 deactivate_plugins( 'countdown-time-pro/plugin.php' );
34 }
35 }
36
37 function blockCategories( $categories ){
38 return array_merge( [[
39 'slug' => 'CTBlock',
40 'title' => 'Countdown Time',
41 ] ], $categories );
42 } // Categories
43
44 function onInit() {
45 wp_register_style( 'ctb-countdown-time-editor-style', plugins_url( 'dist/editor.css', __FILE__ ), [ 'wp-edit-blocks' ], CTB_PLUGIN_VERSION ); // Backend Style
46 wp_register_style( 'ctb-countdown-time-style', plugins_url( 'dist/style.css', __FILE__ ), [ 'wp-editor' ], CTB_PLUGIN_VERSION ); // Frontend Style
47
48 register_block_type( __DIR__, [
49 'editor_style' => 'ctb-countdown-time-editor-style',
50 'style' => 'ctb-countdown-time-style',
51 'render_callback' => [$this, 'render']
52 ] ); // Register Block
53
54 wp_set_script_translations( 'ctb-countdown-time-editor-script', 'countdown-time', plugin_dir_path( __FILE__ ) . '/languages' ); // Translate
55 }
56
57 function render( $attributes ){
58 extract( $attributes );
59
60 $className = $className ?? '';
61 $ctbBlockClassName = 'wp-block-ctb-countdown-time ' . $className . ' align' . $align;
62
63 ob_start(); ?>
64 <div class='<?php echo esc_attr( $ctbBlockClassName ); ?>' id='ctbCountdownTime-<?php echo esc_attr( $cId ) ?>' data-attributes='<?php echo esc_attr( wp_json_encode( $attributes ) ); ?>'></div>
65
66 <?php return ob_get_clean();
67 } // Render
68 }
69 new CTBCountdownTime;