PluginProbe
Button Generator – Easily Create Custom Buttons with Icons and Analytics / 2.1
Button Generator – Easily Create Custom Buttons with Icons and Analytics v2.1
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 2.1, at button-generation.php

225 lines 6.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: 2.1
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_generator
12 * Domain Path: /languages
13 *
14 * PHP version 5.3.0
15 *
16 * @category Wordpress_Plugin
17 * @package Wow_Plugin
18 * @author Dmytro Lobov <i@wpbiker.com>
19 * @copyright 2019 Wow-Company
20 * @license GNU Public License
21 * @version 1.0
22 */
23
24 // Required set the namespace for plugin.
25 namespace button_generator;
26
27 if ( ! defined( 'ABSPATH' ) ) {
28 exit;
29 }
30
31
32 if ( ! class_exists( 'Wow_Plugin' ) ) :
33
34 /**
35 * Main Wow_Plugin Class.
36 *
37 * @since 1.0
38 */
39 final class Wow_Plugin {
40
41 private static $_instance;
42
43 // Set the database name.
44 const PREF = 'button_generator';
45
46 /**
47 * Main Wow_Plugin Instance.
48 *
49 * Insures that only one instance of Wow_Plugin exists in memory at any one
50 * time. Also prevents needing to define globals all over the place.
51 *
52 * @return object|Wow_Plugin The one true Wow_Plugin for Current plugin
53 *
54 * @uses Wow_Plugin::_includes() Include the required files.
55 * @uses Wow_Plugin::text_domain() load the language files.
56 * @since 1.0
57 * @static
58 * @staticvar array $instance
59 */
60 public static function instance() {
61
62 if ( ! isset( self::$_instance ) && ! ( self::$_instance instanceof Wow_Plugin ) ) {
63
64 $info = array(
65 'plugin' => array(
66 'name' => esc_attr__( 'Button Generator', 'button_generator' ), // Plugin name
67 'menu' => esc_attr__( 'Button Generator', 'button_generator' ), // Plugin name in menu
68 'author' => 'Wow-Company', // Author
69 'prefix' => self::PREF, // Prefix for database
70 'text' => 'button_generator', // Text domain for translate files
71 'version' => '2.1', // Current version of the plugin
72 'file' => __FILE__, // Main file of the plugin
73 'slug' => dirname( plugin_basename( __FILE__ ) ), // Name of the plugin folder
74 'url' => plugin_dir_url( __FILE__ ), // filesystem directory path for the plugin
75 'dir' => plugin_dir_path( __FILE__ ), // URL directory path for the plugin
76 'shortcode' => 'Button',
77
78 ),
79 'url' => array(
80 'author' => 'https://wow-estore.com/',
81 'pro' => 'https://wow-estore.com/item/button-generator-pro/',
82 'home' => 'https://wordpress.org/plugins/button-generation/',
83 'support' => 'https://wordpress.org/support/plugin/button-generation/',
84 'facebook' => 'https://www.facebook.com/wowaffect/',
85 ),
86 'rating' => array(
87 'website' => esc_attr__( 'WordPress', 'button_generator' ), // Name site for rating plugin
88 'url' => 'https://wordpress.org/support/plugin/button-generation/reviews/?filter=5',
89 ),
90 );
91
92 self::$_instance = new Wow_Plugin;
93
94 register_activation_hook( __FILE__, array( self::$_instance, 'plugin_activate' ) );
95 register_deactivation_hook( __FILE__, array( self::$_instance, 'plugin_deactivate' ) );
96
97 add_action( 'plugins_loaded', array( self::$_instance, 'text_domain' ) );
98 add_action( 'admin_init', array( self::$_instance, 'create_field' ) );
99
100 self::$_instance->_includes();
101 self::$_instance->admin = new Wow_Plugin_Admin( $info );
102 self::$_instance->public = new Wow_Plugin_Public( $info );
103 }
104
105 return self::$_instance;
106 }
107
108 /**
109 * Throw error on object clone.
110 * The whole idea of the singleton design pattern is that there is a single
111 * object therefore, we don't want the object to be cloned.
112 *
113 * @return void
114 * @since 1.0
115 * @access protected
116 */
117 public function __clone() {
118 // Cloning instances of the class is forbidden.
119 _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'button_generator' ), '0.1' );
120 }
121
122 /**
123 * Disable unserializing of the class.
124 *
125 * @return void
126 * @since 1.0
127 * @access protected
128 */
129 public function __wakeup() {
130 // Unserializing instances of the class is forbidden.
131 _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'button_generator' ), '0.1' );
132 }
133
134
135 /**
136 * Include required files.
137 *
138 * @access private
139 * @return void
140 * @since 1.0
141 */
142 private function _includes() {
143 if ( ! class_exists( 'Wow_Company' ) ) {
144 include_once 'includes/class-wow-company.php';
145 }
146
147 include_once 'includes/class-db.php';
148 include_once 'admin/class-admin.php';
149 include_once 'public/class-public.php';
150 }
151
152 /**
153 * Activate the plugin.
154 * create the database
155 * create the folder in wp-upload
156 *
157 * @access public
158 * @return void
159 * @since 1.0
160 */
161 public function plugin_activate() {
162 update_option( 'wow_' . self::PREF . '_notice_action', 'read' );
163 self::create_field();
164 include_once 'includes/plugin-activation.php';
165 }
166
167 /**
168 * Deactivate the plugin.
169 * delete the plugin folder and files from wp-upload
170 *
171 * @access public
172 * @since 1.0
173 */
174 public function plugin_deactivate() {
175 include_once 'includes/plugin-deactivation.php';
176 }
177
178
179 /**
180 * Create the plugin field in wp-upload.
181 * Create the folder when the plugin update
182 *
183 * @access public
184 * @return void
185 * @since 1.0
186 */
187 public function create_field() {
188 $upload = wp_upload_dir();
189 $field = dirname( plugin_basename( __FILE__ ) );
190 $basedir = $upload['basedir'] . '/' . $field . '/';
191 if ( ! file_exists( $basedir ) ) {
192 wp_mkdir_p( $basedir );
193 }
194
195 // Update to the version 2.0
196 require_once plugin_dir_path( __FILE__ ) . 'includes/data-update.php';
197 }
198
199 /**
200 * Download the folder with languages.
201 *
202 * @access public
203 * @return void
204 * @since 1.0
205 */
206 public function text_domain() {
207 $languages_folder = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
208 load_plugin_textdomain( 'button_generator', false, $languages_folder );
209 }
210 }
211
212 endif; // End if class_exists check.
213
214 /**
215 * The main function for that returns Wow_Plugin
216 *
217 * @since 1.0
218 */
219 function Wow_Plugin_run() {
220 return Wow_Plugin::instance();
221 }
222
223 // Get Running.
224 Wow_Plugin_run();
225