PluginProbe
Counter Box – Add Countdowns, Timers & Dynamic Counters to WordPress / 2.0
Counter Box – Add Countdowns, Timers & Dynamic Counters to WordPress v2.0
2.0.14 trunk 1.0 1.2 1.2.1 1.2.2 1.2.3 1.2.4 2.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9
counter-box / counter-box.php

counter-box.php in Counter Box – Add Countdowns, Timers & Dynamic Counters to WordPress 2.0, at counter-box.php

194 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Counter Box
4 * Plugin URI: https://wordpress.org/plugins/counter-box/
5 * Description: The most powerful creator of counters, timers and countdowns
6 * Version: 2.0
7 * Author: Wow-Company
8 * Author URI: https://wow-estore.com/
9 * License: GPL-2.0+
10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
11 * Text Domain: counter-box
12 * Domain Path: /languages
13 * Item ID: 45426
14 * Store URI: https://wow-estore.com/
15 * Author Email: hey@wow-company.com
16 * Plugin Menu: Counter Box
17 * Rating URI: https://wordpress.org/support/plugin/counter-box/reviews/?filter=5#new-post
18 * Support URI: https://wordpress.org/support/plugin/counter-box/
19 * Item URI: https://wow-estore.com/item/counter-box-pro/
20 * Documentation: https://wow-estore.com/documentations/counter-box-documentation/
21 *
22 * PHP version 7.4
23 *
24 * @category Wordpress_Plugin
25 * @package Wow_Plugin
26 * @author Dmytro Lobov <dev@wow-company.com>, Wow-Company
27 * @copyright 2024 Dmytro Lobov
28 * @license GPL-2.0+
29 */
30
31 namespace CounterBox;
32
33 use CounterBox\Admin\DBManager;
34 use CounterBox\Update\UpdateDB;
35
36 defined( 'ABSPATH' ) || exit;
37
38 if ( ! class_exists( 'WOWP_Plugin' ) ) :
39
40 final class WOWP_Plugin {
41
42 // Plugin slug
43 public const SLUG = 'counter-box';
44
45 // Plugin prefix
46 public const PREFIX = 'counter_box';
47
48 // Plugin Shortcode
49 public const SHORTCODE = 'Counter-Box';
50
51 private static $instance;
52
53 private WOWP_Admin $admin;
54 private Autoloader $autoloader;
55 private WOWP_Public $public;
56
57 public static function instance(): WOWP_Plugin {
58 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
59 self::$instance = new self;
60
61 self::$instance->includes();
62
63 self::$instance->autoloader = new Autoloader( 'CounterBox' );
64 self::$instance->admin = new WOWP_Admin();
65 self::$instance->public = new WOWP_Public();
66
67 register_activation_hook( __FILE__, [ self::$instance, 'plugin_activate' ] );
68 add_action( 'plugins_loaded', [ self::$instance, 'loaded' ] );
69 }
70
71
72 return self::$instance;
73 }
74
75 // Plugin Root File.
76 public static function file(): string {
77 return __FILE__;
78 }
79
80 // Plugin Base Name.
81 public static function basename(): string {
82 return plugin_basename( __FILE__ );
83 }
84
85 // Plugin Folder Path.
86 public static function dir(): string {
87 return plugin_dir_path( __FILE__ );
88 }
89
90 // Plugin Folder URL.
91 public static function url(): string {
92 return plugin_dir_url( __FILE__ );
93 }
94
95 // Get Plugin Info
96 public static function info( $show = '' ): string {
97 $data = [
98 'name' => 'Plugin Name',
99 'version' => 'Version',
100 'url' => 'Plugin URI',
101 'author' => 'Author',
102 'email' => 'Author Email',
103 'store' => 'Store URI',
104 'item_id' => 'Item ID',
105 'menu_title' => 'Plugin Menu',
106 'rating' => 'Rating URI',
107 'support' => 'Support URI',
108 'pro' => 'Item URI',
109 'docs' => 'Documentation',
110 ];
111 $plugin_data = get_file_data( __FILE__, $data, false );
112
113 return $plugin_data[ $show ] ?? '';
114 }
115
116 /**
117 * Include required files.
118 *
119 * @access private
120 * @since 1.0
121 */
122 private function includes(): void {
123 if ( ! class_exists( 'Wow_Company' ) ) {
124 require_once self::dir() . 'includes/class-wow-company.php';
125 }
126
127 require_once self::dir() . 'classes/Autoloader.php';
128 require_once self::dir() . 'admin/class-wowp-admin.php';
129 require_once self::dir() . 'public/class-wowp-public.php';
130 }
131
132 /**
133 * Throw error on object clone.
134 * The whole idea of the singleton design pattern is that there is a single
135 * object therefore, we don't want the object to be cloned.
136 *
137 * @return void
138 * @access protected
139 */
140 public function __clone() {
141 // Cloning instances of the class is forbidden.
142 _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'counter-box' ), '1.0' );
143 }
144
145 /**
146 * Disable unserializing of the class.
147 *
148 * @return void
149 * @access protected
150 */
151 public function __wakeup() {
152 // Unserializing instances of the class is forbidden.
153 _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'counter-box' ), '1.0' );
154 }
155
156 public function plugin_activate(): void {
157
158 if ( is_plugin_active( 'counter-box-pro/counter-box-pro.php' ) ) {
159 deactivate_plugins( 'counter-box-pro/counter-box-pro.php' );
160 }
161
162 $columns = "
163 id mediumint(9) NOT NULL AUTO_INCREMENT,
164 title VARCHAR(200) DEFAULT '' NOT NULL,
165 param longtext DEFAULT '' NOT NULL,
166 status boolean DEFAULT 0 NOT NULL,
167 mode boolean DEFAULT 0 NOT NULL,
168 tag text DEFAULT '' NOT NULL,
169 PRIMARY KEY (id)
170 ";
171 DBManager::create( $columns );
172 }
173
174 /**
175 * Download the folder with languages.
176 *
177 * @access Publisher
178 * @return void
179 */
180 public function loaded(): void {
181 UpdateDB::init();
182 $languages_folder = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
183 load_plugin_textdomain( 'counter-box', false, $languages_folder );
184 }
185 }
186
187 endif;
188
189 function wp_plugin_run(): WOWP_Plugin {
190 return WOWP_Plugin::instance();
191 }
192
193 wp_plugin_run();
194