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