PluginProbe
Button Generator – Easily Create Custom Buttons with Icons and Analytics / 3.1.3
Button Generator – Easily Create Custom Buttons with Icons and Analytics v3.1.3
trunk 1.1.1 2.0 2.1 2.2 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 3.0 3.0.1 3.0.2 3.0.3 3.1 3.1.1 3.1.2 3.1.3 3.2 3.2.1 3.2.2 3.2.3 All 28 releases
button-generation / button-generation.php

button-generation.php in Button Generator – Easily Create Custom Buttons with Icons and Analytics 3.1.3, at button-generation.php

195 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: Button Generator
4 * Plugin URI: https://wordpress.org/plugins/button-generation/
5 * Description: Easy generation of custom buttons.
6 * Version: 3.1.3
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: button-generation
12 * Domain Path: /languages
13 * Store URI: https://wow-estore.com/
14 * Author Email: hey@wow-company.com
15 * Plugin Menu: Button Generator
16 * Rating URI: https://wordpress.org/support/plugin/button-generation/reviews/#new-post
17 * Support URI: https://wordpress.org/support/plugin/button-generation/
18 * Item URI: https://wow-estore.com/item/button-generator-pro/
19 * Change URI: https://wordpress.org/plugins/button-generation/#developers
20 *
21 * PHP version 7.4
22 *
23 * @category Wordpress_Plugin
24 * @package Wow_Plugin
25 * @author Dmytro Lobov <dev@wow-company.com>, Wow-Company
26 * @copyright 2024 Dmytro Lobov
27 * @license GPL-2.0+
28 */
29
30 namespace ButtonGenerator;
31
32 use ButtonGenerator\Admin\DBManager;
33 use ButtonGenerator\Update\UpdateDB;
34
35 defined( 'ABSPATH' ) || exit;
36
37 if ( ! class_exists( 'WOWP_Plugin' ) ) :
38
39 final class WOWP_Plugin {
40
41 // Plugin slug
42 public const SLUG = 'button-generation';
43
44 // Plugin prefix
45 public const PREFIX = 'wow_button_generator';
46
47 // Plugin Shortcode
48 public const SHORTCODE = 'Button';
49
50 private static $instance;
51
52 private WOWP_Admin $admin;
53 private Autoloader $autoloader;
54 private WOWP_Public $public;
55 private WOWP_Plugin_Checker $check;
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( 'ButtonGenerator' );
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 'menu_title' => 'Plugin Menu',
105 'rating' => 'Rating URI',
106 'support' => 'Support URI',
107 'pro' => 'Item URI',
108 'change' => 'Change URI',
109 ];
110 $plugin_data = get_file_data( __FILE__, $data, false );
111
112 return $plugin_data[ $show ] ?? '';
113 }
114
115 /**
116 * Include required files.
117 *
118 * @access private
119 * @since 1.0
120 */
121 private function includes(): void {
122 if ( ! class_exists( 'Wow_Company' ) ) {
123 require_once self::dir() . 'includes/class-wow-company.php';
124 }
125
126 require_once self::dir() . 'classes/Autoloader.php';
127 require_once self::dir() . 'admin/class-wowp-admin.php';
128 require_once self::dir() . 'public/class-wowp-public.php';
129 }
130
131 /**
132 * Throw error on object clone.
133 * The whole idea of the singleton design pattern is that there is a single
134 * object therefore, we don't want the object to be cloned.
135 *
136 * @return void
137 * @access protected
138 */
139 public function __clone() {
140 // Cloning instances of the class is forbidden.
141 _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'button-generation' ), '1.0' );
142 }
143
144 /**
145 * Disable unserializing of the class.
146 *
147 * @return void
148 * @access protected
149 */
150 public function __wakeup() {
151 // Unserializing instances of the class is forbidden.
152 _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'button-generation' ), '1.0' );
153 }
154
155 public function plugin_activate(): void {
156
157 if ( is_plugin_active( 'button-generator-pro/button-generator.php' ) ) {
158 deactivate_plugins( 'button-generator-pro/button-generator.php' );
159 }
160
161 $columns = "
162 id mediumint(9) NOT NULL AUTO_INCREMENT,
163 title VARCHAR(200) DEFAULT '' NOT NULL,
164 param longtext,
165 status boolean DEFAULT 0 NOT NULL,
166 mode boolean DEFAULT 0 NOT NULL,
167 tag text,
168 PRIMARY KEY (id)
169 ";
170 DBManager::create( $columns );
171
172 update_site_option( self::PREFIX . '_db_version', '6.0' );
173 }
174
175 /**
176 * Download the folder with languages.
177 *
178 * @access Publisher
179 * @return void
180 */
181 public function loaded(): void {
182 UpdateDB::init();
183 $languages_folder = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
184 load_plugin_textdomain( 'button-generation', false, $languages_folder );
185 }
186 }
187
188 endif;
189
190 function wp_plugin_run(): WOWP_Plugin {
191 return WOWP_Plugin::instance();
192 }
193
194 wp_plugin_run();
195