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

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

81 lines 2.8 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 Timer
4 * Description: Display your events date into a timer to your visitor with countdown time block
5 * Version: 1.3.1
6 * Author: bPlugins
7 * Author URI: https://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 if ( function_exists( 'ctb_fs' ) ) {
17 ctb_fs()->set_basename( false, __FILE__ );
18 }else{
19 define( 'CTB_VERSION', isset( $_SERVER['HTTP_HOST'] ) && ( 'localhost' === $_SERVER['HTTP_HOST'] || 'plugins.local' === $_SERVER['HTTP_HOST'] ) ? time() : '1.3.1' );
20 define( 'CTB_DIR_URL', plugin_dir_url( __FILE__ ) );
21 define( 'CTB_DIR_PATH', plugin_dir_path( __FILE__ ) );
22 define( 'CTB_HAS_PRO', file_exists( CTB_DIR_PATH . 'vendor/freemius/start.php' ) );
23
24 if ( CTB_HAS_PRO ) {
25 require_once CTB_DIR_PATH . 'includes/fs.php';
26 require_once CTB_DIR_PATH . 'includes/admin/CPT.php';
27 }else{
28 require_once CTB_DIR_PATH . 'includes/fs-lite.php';
29 require_once CTB_DIR_PATH . 'includes/admin/SubMenu.php';
30 }
31
32 require_once CTB_DIR_PATH . 'includes/Patterns.php';
33
34 function ctbIsPremium(){
35 return CTB_HAS_PRO ? ctb_fs()->can_use_premium_code() : false;
36 }
37
38 class CTBPlugin{
39 function __construct(){
40 add_action( 'init', [ $this, 'onInit' ] );
41 add_filter( 'block_categories_all', [$this, 'blockCategories'] );
42 add_action( 'admin_enqueue_scripts', [$this, 'adminEnqueueScripts'] );
43 add_action( 'enqueue_block_editor_assets', [$this, 'enqueueBlockEditorAssets'] );
44 }
45
46 function onInit(){
47 register_block_type( __DIR__ . '/build' );
48 }
49
50 function blockCategories( $categories ){
51 return array_merge( [ [
52 'slug' => 'CTBlock',
53 'title' => 'Countdown Time'
54 ] ], $categories );
55 }
56
57 function adminEnqueueScripts( $hook ) {
58 if( strpos( $hook, 'countdown-time' ) ){
59 wp_enqueue_style( 'ctb-admin-dashboard', CTB_DIR_URL . 'build/admin/dashboard.css', [], CTB_VERSION );
60 wp_enqueue_script( 'ctb-admin-dashboard', CTB_DIR_URL . 'build/admin/dashboard.js', [ 'react', 'react-dom' ], CTB_VERSION, true );
61 wp_set_script_translations( 'ctb-admin-dashboard', 'countdown-time', CTB_DIR_PATH . 'languages' );
62 }
63 }
64
65 function enqueueBlockEditorAssets(){
66 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' );
67 }
68
69 static function renderDashboard(){ ?>
70 <div
71 id='ctbDashboard'
72 data-info='<?php echo esc_attr( wp_json_encode( [
73 'version' => CTB_VERSION,
74 'isPremium' => ctbIsPremium(),
75 'hasPro' => CTB_HAS_PRO
76 ] ) ); ?>'
77 ></div>
78 <?php }
79 }
80 new CTBPlugin;
81 }