PluginProbe
Counter Box – Add Countdowns, Timers & Dynamic Counters to WordPress / 1.2
Counter Box – Add Countdowns, Timers & Dynamic Counters to WordPress v1.2
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 1.2, at counter-box.php

203 lines 5.6 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: 1.2
7 * Author: Wow-Company
8 * Author URI: https://wow-estore.com
9 * License: GPL-2.0+
10 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11 * Text Domain: counter-box
12 */
13
14 namespace counter_box;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20
21 if ( ! class_exists( 'WP_Plugin' ) ) :
22
23 /**
24 * Main WP_Plugin Class.
25 *
26 * @since 1.0
27 */
28 final class WP_Plugin {
29
30 private static $_instance;
31
32 /**
33 * Wow Plugin information
34 *
35 * All information which need for correctly plugin working
36 *
37 * @return array
38 * @static
39 */
40 private static function _plugin_info() {
41
42 $info = array(
43 'plugin' => array(
44 'name' => 'Counter Box', // Plugin name
45 'menu' => 'Counter Box', // Plugin name in menu
46 'author' => 'Wow-Company', // Author
47 'prefix' => 'counter_box', // Prefix for database
48 'text' => 'counter-box', // Text domain for translate files
49 'version' => '1.2', // Current version of the plugin
50 'file' => __FILE__, // Main file of the plugin
51 'slug' => 'counter-box', // Name of the plugin folder
52 'url' => plugin_dir_url( __FILE__ ), // filesystem directory path for the plugin
53 'dir' => plugin_dir_path( __FILE__ ), // URL directory path for the plugin
54 'shortcode' => 'Counter-Box',
55 ),
56 'url' => array(
57 'author' => 'https://wow-estore.com',
58 'home' => 'https://wordpress.org/plugins/counter-box/',
59 'support' => 'https://wordpress.org/support/plugin/counter-box/',
60 'facebook' => 'https://www.facebook.com/wowaffect/',
61 ),
62 'rating' => array(
63 'website' => 'WordPress.org',
64 'url' => 'https://wordpress.org/support/plugin/counter-box/reviews/#new-post',
65 'wp_url' => 'https://wordpress.org/support/plugin/counter-box/reviews/#new-post',
66 'wp_home' => 'https://wordpress.org/plugins/counter-box/',
67 'wp_title' => 'Counter Box – most powerful creator of counters, timers and countdowns',
68 ),
69 );
70
71 return $info;
72
73 }
74
75 /**
76 * Main WP_Plugin Instance.
77 *
78 * Insures that only one instance of WP_Plugin exists in memory at any one
79 * time. Also prevents needing to define globals all over the place.
80 *
81 * @return object|WP_Plugin The one true WP_Plugin for Current plugin
82 *
83 * @uses WP_Plugin::_includes() Include the required files.
84 * @uses WP_Plugin::text_domain() load the language files.
85 * @since 1.0
86 * @static
87 * @staticvar array $_instance
88 */
89 public static function instance() {
90
91 if ( ! isset( self::$_instance ) && ! ( self::$_instance instanceof WP_Plugin ) ) {
92
93 $info = self::_plugin_info();
94
95 self::$_instance = new WP_Plugin;
96
97 register_activation_hook( __FILE__, array( self::$_instance, 'plugin_activate' ) );
98 add_action( 'plugins_loaded', array( self::$_instance, 'text_domain' ) );
99
100 self::$_instance->_includes();
101 self::$_instance->admin = new WP_Plugin_Admin( $info );
102 self::$_instance->public = new WP_Plugin_Public( $info );
103
104 }
105
106 return self::$_instance;
107 }
108
109 /**
110 * Throw error on object clone.
111 * The whole idea of the singleton design pattern is that there is a single
112 * object therefore, we don't want the object to be cloned.
113 *
114 * @return void
115 * @since 1.0
116 * @access protected
117 */
118 public function __clone() {
119 // Cloning instances of the class is forbidden.
120 _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'counter_box' ), '1.0' );
121 }
122
123 /**
124 * Disable unserializing of the class.
125 *
126 * @return void
127 * @since 1.0
128 * @access protected
129 */
130 public function __wakeup() {
131 // Unserializing instances of the class is forbidden.
132 _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'counter_box' ), '1.0' );
133 }
134
135
136 /**
137 * Include required files.
138 *
139 * @access private
140 * @return void
141 * @since 1.0
142 */
143 private function _includes() {
144 include_once 'admin/class-admin.php';
145 include_once 'public/class-public.php';
146 }
147
148 /**
149 * Activate the plugin.
150 * create the database
151 * create the folder in wp-upload
152 *
153 * @access public
154 * @return void
155 * @since 1.0
156 */
157 public function plugin_activate() {
158 deactivate_plugins( 'counter-box-pro/counter-box-pro.php' );
159 $info = self::_plugin_info();
160 $prefix = $info['plugin']['prefix'];
161 global $wpdb;
162 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
163 // Create the database for plugin
164 $table = $wpdb->prefix . $prefix;
165 $sql = "CREATE TABLE " . $table . " (
166 id mediumint(9) NOT NULL AUTO_INCREMENT,
167 title VARCHAR(200) NOT NULL,
168 param TEXT,
169 status INT,
170 UNIQUE KEY id (id)
171 )
172 DEFAULT CHARSET=utf8;";
173 dbDelta( $sql );
174 }
175
176 /**
177 * Download the folder with languages.
178 *
179 * @access public
180 * @return void
181 * @since 1.0
182 */
183 public function text_domain() {
184 $languages_folder = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
185 load_plugin_textdomain( 'counter_box', false, $languages_folder );
186 }
187
188 }
189
190 endif; // End if class_exists check.
191
192 /**
193 * The main function for that returns WP_Plugin
194 *
195 * @since 1.0
196 */
197 function WP_Plugin_run() {
198 return WP_Plugin::instance();
199 }
200
201 // Get Running.
202 WP_Plugin_run();
203