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

76 lines 2.7 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.7
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.7' );
18 define( 'CTB_ASSETS_DIR', plugin_dir_url( __FILE__ ) . 'assets/' );
19
20 // Countdown Time
21 class CTBCountdownTime{
22 function __construct(){
23 register_activation_hook( __FILE__, [$this, 'onPluginActivate'] );
24
25 if ( version_compare( $GLOBALS['wp_version'], '5.8-alpha-1', '<' ) ) {
26 add_filter( 'block_categories', [$this, 'blockCategories'] );
27 } else { add_filter( 'block_categories_all', [$this, 'blockCategories'] ); }
28
29 add_action( 'init', [$this, 'onInit'] );
30 }
31
32 function onPluginActivate(){
33 if ( is_plugin_active( 'countdown-time-pro/plugin.php' ) ){
34 deactivate_plugins( 'countdown-time-pro/plugin.php' );
35 }
36 } // Deactivate pro if active
37
38 function blockCategories( $categories ){
39 return array_merge( [[
40 'slug' => 'CTBlock',
41 'title' => 'Countdown Time',
42 ] ], $categories );
43 } // Categories
44
45 function onInit() {
46 wp_register_script( 'ctb-countdown-time-script', plugins_url( 'dist/script.js', __FILE__ ), [ 'react', 'react-dom' ], CTB_PLUGIN_VERSION, true ); // Frontend Script
47
48 wp_register_style( 'ctb-countdown-time-style', plugins_url( 'dist/style.css', __FILE__ ), [], CTB_PLUGIN_VERSION ); // Style
49
50 wp_register_style( 'ctb-countdown-time-editor-style', plugins_url( 'dist/editor.css', __FILE__ ), [ 'ctb-countdown-time-style' ], CTB_PLUGIN_VERSION ); // Backend Style
51
52 register_block_type( __DIR__, [
53 'editor_style' => 'ctb-countdown-time-editor-style',
54 'render_callback' => [$this, 'render']
55 ] ); // Register Block
56
57 wp_set_script_translations( 'ctb-countdown-time-editor-script', 'countdown-time', plugin_dir_path( __FILE__ ) . '/languages' ); // Translate
58 }
59
60 function render( $attributes ){
61 extract( $attributes );
62
63 // Enqueue assets where has block
64 wp_enqueue_script( 'ctb-countdown-time-script' );
65 wp_enqueue_style( 'ctb-countdown-time-style' );
66
67 $className = $className ?? '';
68 $blockClassName = "wp-block-ctb-countdown-time $className align$align";
69
70 ob_start(); ?>
71 <div class='<?php echo esc_attr( $blockClassName ); ?>' id='ctbCountdownTime-<?php echo esc_attr( $cId ) ?>' data-attributes='<?php echo esc_attr( wp_json_encode( $attributes ) ); ?>'></div>
72
73 <?php return ob_get_clean();
74 } // Render
75 }
76 new CTBCountdownTime;