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

151 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: Countdown Time - Block
5 * Description: Display your events date into a timer to your visitor with countdown time block
6 * Version: 1.2.4
7 * Author: bPlugins
8 * Author URI: https://bplugins.com
9 * License: GPLv3
10 * License URI: https://www.gnu.org/licenses/gpl-3.0.txt
11 * Text Domain: countdown-time
12 */
13 // ABS PATH
14 if ( !defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 if ( function_exists( 'ctb_fs' ) ) {
19 register_activation_hook( __FILE__, function () {
20 if ( is_plugin_active( 'countdown-time/plugin.php' ) ) {
21 deactivate_plugins( 'countdown-time/plugin.php' );
22 }
23 if ( is_plugin_active( 'countdown-time-pro/plugin.php' ) ) {
24 deactivate_plugins( 'countdown-time-pro/plugin.php' );
25 }
26 } );
27 } else {
28 define( 'CTB_VERSION', ( isset( $_SERVER['HTTP_HOST'] ) && 'localhost' === $_SERVER['HTTP_HOST'] ? time() : '1.2.4' ) );
29 define( 'CTB_DIR_URL', plugin_dir_url( __FILE__ ) );
30 define( 'CTB_DIR_PATH', plugin_dir_path( __FILE__ ) );
31 define( 'CTB_HAS_FREE', 'countdown-time/plugin.php' === plugin_basename( __FILE__ ) );
32 define( 'CTB_HAS_PRO', 'countdown-time-pro/plugin.php' === plugin_basename( __FILE__ ) );
33
34 if ( !function_exists( 'ctb_fs' ) ) {
35 function ctb_fs()
36 {
37 global $ctb_fs ;
38
39 if ( !isset( $ctb_fs ) ) {
40 $fsStartPath = dirname( __FILE__ ) . '/freemius/start.php';
41 $bSDKInitPath = dirname( __FILE__ ) . '/bplugins_sdk/init.php';
42
43 if ( CTB_HAS_PRO && file_exists( $fsStartPath ) ) {
44 require_once $fsStartPath;
45 } else {
46 if ( CTB_HAS_FREE && file_exists( $bSDKInitPath ) ) {
47 require_once $bSDKInitPath;
48 }
49 }
50
51 $ctbConfig = [
52 'id' => '14562',
53 'slug' => 'countdown-time',
54 'premium_slug' => 'countdown-time-pro',
55 'type' => 'plugin',
56 'public_key' => 'pk_7f62446a2a53154c56c36346db2fa',
57 'is_premium' => false,
58 'premium_suffix' => 'Pro',
59 'has_premium_version' => true,
60 'has_addons' => false,
61 'has_paid_plans' => true,
62 'trial' => [
63 'days' => 7,
64 'is_require_payment' => true,
65 ],
66 'menu' => [
67 'slug' => 'edit.php?post_type=ctb',
68 'contact' => false,
69 'support' => false,
70 ],
71 ];
72 $ctb_fs = ( CTB_HAS_PRO && file_exists( $fsStartPath ) ? fs_dynamic_init( $ctbConfig ) : fs_lite_dynamic_init( $ctbConfig ) );
73 }
74
75 return $ctb_fs;
76 }
77
78 ctb_fs();
79 do_action( 'ctb_fs_loaded' );
80 }
81
82 if ( CTB_HAS_PRO ) {
83 if ( function_exists( 'ctb_fs' ) ) {
84 ctb_fs()->add_filter( 'freemius_pricing_js_path', function () {
85 return CTB_DIR_PATH . 'inc/freemius-pricing/freemius-pricing.js';
86 } );
87 }
88 }
89 function ctbIsPremium()
90 {
91 return ( CTB_HAS_PRO ? ctb_fs()->can_use_premium_code() : false );
92 }
93
94 require_once CTB_DIR_PATH . '/inc/block.php';
95 require_once CTB_DIR_PATH . '/inc/pattern.php';
96 require_once CTB_DIR_PATH . '/inc/CustomPost.php';
97 require_once CTB_DIR_PATH . '/inc/HelpPage.php';
98 if ( CTB_HAS_FREE ) {
99 require_once CTB_DIR_PATH . '/inc/UpgradePage.php';
100 }
101 class CTBPlugin
102 {
103 function __construct()
104 {
105 add_action( 'wp_ajax_ctbPipeChecker', [ $this, 'ctbPipeChecker' ] );
106 add_action( 'wp_ajax_nopriv_ctbPipeChecker', [ $this, 'ctbPipeChecker' ] );
107 add_action( 'admin_init', [ $this, 'registerSettings' ] );
108 add_action( 'rest_api_init', [ $this, 'registerSettings' ] );
109 add_filter( 'block_categories_all', [ $this, 'blockCategories' ] );
110 }
111
112 function ctbPipeChecker()
113 {
114 $nonce = $_POST['_wpnonce'] ?? null;
115 if ( !wp_verify_nonce( $nonce, 'wp_ajax' ) ) {
116 wp_send_json_error( 'Invalid Request' );
117 }
118 wp_send_json_success( [
119 'isPipe' => ctbIsPremium(),
120 ] );
121 }
122
123 function registerSettings()
124 {
125 register_setting( 'ctbUtils', 'ctbUtils', [
126 'show_in_rest' => [
127 'name' => 'ctbUtils',
128 'schema' => [
129 'type' => 'string',
130 ],
131 ],
132 'type' => 'string',
133 'default' => wp_json_encode( [
134 'nonce' => wp_create_nonce( 'wp_ajax' ),
135 ] ),
136 'sanitize_callback' => 'sanitize_text_field',
137 ] );
138 }
139
140 function blockCategories( $categories )
141 {
142 return array_merge( [ [
143 'slug' => 'CTBlock',
144 'title' => 'Countdown Time',
145 ] ], $categories );
146 }
147
148 }
149 new CTBPlugin();
150 }
151