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

139 lines 4.7 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.3
7 * Author: bPlugins LLC
8 * Author URI: http://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 register_activation_hook( __FILE__, function () {
18 if ( is_plugin_active( 'countdown-time/plugin.php' ) ) {
19 deactivate_plugins( 'countdown-time/plugin.php' );
20 }
21 if ( is_plugin_active( 'countdown-time-pro/plugin.php' ) ) {
22 deactivate_plugins( 'countdown-time-pro/plugin.php' );
23 }
24 } );
25 define( 'CTB_VERSION', ( isset( $_SERVER['HTTP_HOST'] ) && 'localhost' === $_SERVER['HTTP_HOST'] ? time() : '1.2.3' ) );
26 define( 'CTB_DIR_URL', plugin_dir_url( __FILE__ ) );
27 define( 'CTB_DIR_PATH', plugin_dir_path( __FILE__ ) );
28 define( 'CTB_HAS_FREE', 'countdown-time/plugin.php' === plugin_basename( __FILE__ ) );
29 define( 'CTB_HAS_PRO', 'countdown-time-pro/plugin.php' === plugin_basename( __FILE__ ) );
30
31 if ( !function_exists( 'ctb_fs' ) ) {
32 function ctb_fs()
33 {
34 global $ctb_fs ;
35
36 if ( !isset( $ctb_fs ) ) {
37 $fsStartPath = dirname( __FILE__ ) . '/freemius/start.php';
38 $bSDKInitPath = dirname( __FILE__ ) . '/bplugins_sdk/init.php';
39
40 if ( CTB_HAS_PRO && file_exists( $fsStartPath ) ) {
41 require_once $fsStartPath;
42 } else {
43 if ( CTB_HAS_FREE && file_exists( $bSDKInitPath ) ) {
44 require_once $bSDKInitPath;
45 }
46 }
47
48 $ctbConfig = [
49 'id' => '14562',
50 'slug' => 'countdown-time',
51 'premium_slug' => 'countdown-time-pro',
52 'type' => 'plugin',
53 'public_key' => 'pk_7f62446a2a53154c56c36346db2fa',
54 'is_premium' => false,
55 'premium_suffix' => 'Pro',
56 'has_premium_version' => true,
57 'has_addons' => false,
58 'has_paid_plans' => true,
59 'trial' => [
60 'days' => 7,
61 'is_require_payment' => true,
62 ],
63 'menu' => [
64 'slug' => 'edit.php?post_type=ctb',
65 'contact' => false,
66 'support' => false,
67 ],
68 ];
69 $ctb_fs = ( CTB_HAS_PRO && file_exists( $fsStartPath ) ? fs_dynamic_init( $ctbConfig ) : fs_lite_dynamic_init( $ctbConfig ) );
70 }
71
72 return $ctb_fs;
73 }
74
75 ctb_fs();
76 do_action( 'ctb_fs_loaded' );
77 }
78
79 function ctbIsPremium()
80 {
81 return ( CTB_HAS_PRO ? \ctb_fs()->is__premium_only() && \ctb_fs()->can_use_premium_code() : false );
82 }
83
84 require_once CTB_DIR_PATH . '/inc/block.php';
85 require_once CTB_DIR_PATH . '/inc/pattern.php';
86 require_once CTB_DIR_PATH . '/inc/CustomPost.php';
87 require_once CTB_DIR_PATH . '/inc/HelpPage.php';
88 if ( CTB_HAS_FREE ) {
89 require_once CTB_DIR_PATH . '/inc/UpgradePage.php';
90 }
91 class CTBPlugin
92 {
93 function __construct()
94 {
95 add_action( 'wp_ajax_ctbPipeChecker', [ $this, 'ctbPipeChecker' ] );
96 add_action( 'wp_ajax_nopriv_ctbPipeChecker', [ $this, 'ctbPipeChecker' ] );
97 add_action( 'admin_init', [ $this, 'registerSettings' ] );
98 add_action( 'rest_api_init', [ $this, 'registerSettings' ] );
99 add_filter( 'block_categories_all', [ $this, 'blockCategories' ] );
100 }
101
102 function ctbPipeChecker()
103 {
104 $nonce = $_POST['_wpnonce'] ?? null;
105 if ( !wp_verify_nonce( $nonce, 'wp_ajax' ) ) {
106 wp_send_json_error( 'Invalid Request' );
107 }
108 wp_send_json_success( [
109 'isPipe' => ctbIsPremium(),
110 ] );
111 }
112
113 function registerSettings()
114 {
115 register_setting( 'ctbUtils', 'ctbUtils', [
116 'show_in_rest' => [
117 'name' => 'ctbUtils',
118 'schema' => [
119 'type' => 'string',
120 ],
121 ],
122 'type' => 'string',
123 'default' => wp_json_encode( [
124 'nonce' => wp_create_nonce( 'wp_ajax' ),
125 ] ),
126 'sanitize_callback' => 'sanitize_text_field',
127 ] );
128 }
129
130 function blockCategories( $categories )
131 {
132 return array_merge( [ [
133 'slug' => 'CTBlock',
134 'title' => 'Countdown Time',
135 ] ], $categories );
136 }
137
138 }
139 new CTBPlugin();