| @@ -1,110 +1,151 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: Float Menu Lite |
| 4 | - * Plugin URI: https://wordpress.org/plugins/float-menu/ | |
| 4 | + * Plugin URI: https://wow-estore.com/item/float-menu-pro/ | |
| 5 | 5 | * Description: Easily create floating menus of varying complexity |
| 6 | - * Version: 4.3 | |
| 6 | + * Version: 7.2.5 | |
| 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 |
| 11 | + * Text Domain: float-menu | |
| 12 | + * Domain Path: /languages | |
| 13 | + * Item ID: 5174 | |
| 14 | + * Store URI: https://wow-estore.com/ | |
| 15 | + * Author Email: hey@wow-company.com | |
| 16 | + * Plugin Menu: Float Menu Lite | |
| 17 | + * Rating URI: https://wordpress.org/support/plugin/float-menu/reviews/ | |
| 18 | + * Support URI: https://wordpress.org/support/plugin/float-menu/ | |
| 19 | + * Item URI: https://wow-estore.com/item/float-menu-pro/ | |
| 20 | + * Documentation: https://wow-estore.com/documentations/float-menu-lite/ | |
| 21 | + * Change URI: https://wordpress.org/plugins/float-menu/#developers | |
| 22 | + * Demo URI: https://demo.wow-estore.com/float-menu-pro/ | |
| 23 | + * | |
| 24 | + * PHP version 7.4 | |
| 25 | + * | |
| 26 | + * @category Wordpress_Plugin | |
| 27 | + * @package Wow_Plugin | |
| 28 | + * @author Dmytro Lobov <dev@wow-company.com>, Wow-Company | |
| 29 | + * @copyright 2024 Dmytro Lobov | |
| 30 | + * @license GPL-2.0+ | |
| 31 | + * | |
| 11 | 32 | */ |
| 12 | 33 | |
| 13 | -// Required set the namespace for plugin. | |
| 14 | -namespace float_menu_free; | |
| 34 | +namespace FloatMenuLite; | |
| 15 | 35 | |
| 16 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 17 | - exit; | |
| 18 | -} | |
| 36 | +use FloatMenuLite\Admin\DBManager; | |
| 37 | +use FloatMenuLite\Update\UpdateDB; | |
| 19 | 38 | |
| 20 | -if ( ! class_exists( 'Wow_Plugin' ) ) : | |
| 39 | +defined( 'ABSPATH' ) || exit; | |
| 21 | 40 | |
| 22 | - /** | |
| 23 | - * Main Wow_Plugin Class. | |
| 24 | - * | |
| 25 | - * @since 1.0 | |
| 26 | - */ | |
| 27 | - final class Wow_Plugin { | |
| 41 | +if ( ! class_exists( 'WOWP_Plugin' ) ) : | |
| 28 | 42 | |
| 29 | - private static $_instance; | |
| 43 | + final class WOWP_Plugin { | |
| 30 | 44 | |
| 31 | - // Set the database name. | |
| 32 | - const PREF = 'fmp'; | |
| 45 | + // Plugin slug | |
| 46 | + public const SLUG = 'float-menu'; | |
| 33 | 47 | |
| 34 | - /** | |
| 35 | - * Main Wow_Plugin Instance. | |
| 36 | - * | |
| 37 | - * Insures that only one instance of Wow_Plugin exists in memory at any one | |
| 38 | - * time. Also prevents needing to define globals all over the place. | |
| 39 | - * | |
| 40 | - * @return object|Wow_Plugin The one true Wow_Plugin for Current plugin | |
| 41 | - * | |
| 42 | - * @uses Wow_Plugin::_includes() Include the required files. | |
| 43 | - * @uses Wow_Plugin::text_domain() load the language files. | |
| 44 | - * @since 1.0 | |
| 45 | - * @static | |
| 46 | - * @staticvar array $instance | |
| 47 | - */ | |
| 48 | - public static function instance() { | |
| 48 | + // Plugin prefix | |
| 49 | + public const PREFIX = 'wow_fmp'; | |
| 49 | 50 | |
| 50 | - if ( ! isset( self::$_instance ) && ! ( self::$_instance instanceof Wow_Plugin ) ) { | |
| 51 | + // Plugin Shortcode | |
| 52 | + public const SHORTCODE = 'Float-Menu'; | |
| 51 | 53 | |
| 52 | - $info = array( | |
| 53 | - 'plugin' => array( | |
| 54 | - 'name' => esc_attr( 'Float Menu Lite' ), // Plugin name | |
| 55 | - 'menu' => esc_attr( 'Float Menu Lite' ), // Plugin name in menu | |
| 56 | - 'author' => 'Wow-Company', // Author | |
| 57 | - 'prefix' => self::PREF, // Prefix for database | |
| 58 | - 'text' => 'float-menu', // Text domain for translate files | |
| 59 | - 'version' => '4.3', // Current version of the plugin | |
| 60 | - 'file' => __FILE__, // Main file of the plugin | |
| 61 | - 'slug' => dirname( plugin_basename( __FILE__ ) ), // Name of the plugin folder | |
| 62 | - 'url' => plugin_dir_url( __FILE__ ), // filesystem directory path for the plugin | |
| 63 | - 'dir' => plugin_dir_path( __FILE__ ), // URL directory path for the plugin | |
| 64 | - 'shortcode' => 'Float-Menu', | |
| 65 | - ), | |
| 66 | - 'url' => array( | |
| 67 | - 'author' => 'https://wow-estore.com/', | |
| 68 | - 'home' => 'https://wordpress.org/plugins/float-menu/', | |
| 69 | - 'support' => 'https://wordpress.org/support/plugin/float-menu/', | |
| 70 | - 'pro' => 'https://wow-estore.com/item/float-menu-pro/', | |
| 71 | - 'facebook' => 'https://www.facebook.com/wowaffect/', | |
| 72 | - ), | |
| 73 | - 'rating' => array( | |
| 74 | - 'website' => esc_attr__( 'WordPress.org' ), // Name site for rating plugin | |
| 75 | - 'url' => 'https://wordpress.org/support/plugin/float-menu/reviews/#new-post', | |
| 76 | - 'wp_url' => 'https://wordpress.org/support/plugin/float-menu/reviews/#new-post', | |
| 77 | - 'wp_home' => 'https://wordpress.org/plugins/float-menu/', | |
| 78 | - 'wp_title' => 'Float menu – awesome floating side menu', | |
| 79 | - ), | |
| 80 | - ); | |
| 54 | + private static $instance; | |
| 81 | 55 | |
| 82 | - self::$_instance = new Wow_Plugin; | |
| 56 | + private WOWP_Admin $admin; | |
| 57 | + private Autoloader $autoloader; | |
| 58 | + private WOWP_Public $public; | |
| 83 | 59 | |
| 84 | - register_activation_hook( __FILE__, array( self::$_instance, 'plugin_activate' ) ); | |
| 85 | - add_action( 'plugins_loaded', array( self::$_instance, 'text_domain' ) ); | |
| 60 | + public static function instance(): WOWP_Plugin { | |
| 61 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) { | |
| 62 | + self::$instance = new self; | |
| 86 | 63 | |
| 87 | - self::$_instance->_includes(); | |
| 88 | - self::$_instance->admin = new Wow_Plugin_Admin( $info ); | |
| 89 | - self::$_instance->public = new Wow_Plugin_Public( $info ); | |
| 64 | + self::$instance->includes(); | |
| 65 | + | |
| 66 | + self::$instance->autoloader = new Autoloader( 'FloatMenuLite' ); | |
| 67 | + self::$instance->admin = new WOWP_Admin(); | |
| 68 | + self::$instance->public = new WOWP_Public(); | |
| 69 | + | |
| 70 | + register_activation_hook( __FILE__, [ self::$instance, 'plugin_activate' ] ); | |
| 71 | + add_action( 'plugins_loaded', [ self::$instance, 'loaded' ] ); | |
| 90 | 72 | } |
| 91 | 73 | |
| 92 | - return self::$_instance; | |
| 74 | + | |
| 75 | + return self::$instance; | |
| 93 | 76 | } |
| 94 | 77 | |
| 78 | + // Plugin Root File. | |
| 79 | + public static function file(): string { | |
| 80 | + return __FILE__; | |
| 81 | + } | |
| 82 | + | |
| 83 | + // Plugin Base Name. | |
| 84 | + public static function basename(): string { | |
| 85 | + return plugin_basename( __FILE__ ); | |
| 86 | + } | |
| 87 | + | |
| 88 | + // Plugin Folder Path. | |
| 89 | + public static function dir(): string { | |
| 90 | + return plugin_dir_path( __FILE__ ); | |
| 91 | + } | |
| 92 | + | |
| 93 | + // Plugin Folder URL. | |
| 94 | + public static function url(): string { | |
| 95 | + return plugin_dir_url( __FILE__ ); | |
| 96 | + } | |
| 97 | + | |
| 98 | + // Get Plugin Info | |
| 99 | + public static function info( $show = '' ): string { | |
| 100 | + $data = [ | |
| 101 | + 'name' => 'Plugin Name', | |
| 102 | + 'version' => 'Version', | |
| 103 | + 'url' => 'Plugin URI', | |
| 104 | + 'author' => 'Author', | |
| 105 | + 'email' => 'Author Email', | |
| 106 | + 'store' => 'Store URI', | |
| 107 | + 'item_id' => 'Item ID', | |
| 108 | + 'menu_title' => 'Plugin Menu', | |
| 109 | + 'rating' => 'Rating URI', | |
| 110 | + 'support' => 'Support URI', | |
| 111 | + 'pro' => 'Item URI', | |
| 112 | + 'demo' => 'Demo URI', | |
| 113 | + 'change' => 'Change URI', | |
| 114 | + 'docs' => 'Documentation', | |
| 115 | + ]; | |
| 116 | + $plugin_data = get_file_data( __FILE__, $data, false ); | |
| 117 | + | |
| 118 | + return $plugin_data[ $show ] ?? ''; | |
| 119 | + } | |
| 120 | + | |
| 95 | 121 | /** |
| 122 | + * Include required files. | |
| 123 | + * | |
| 124 | + * @access private | |
| 125 | + * @since 1.0 | |
| 126 | + */ | |
| 127 | + private function includes(): void { | |
| 128 | + if ( ! class_exists( 'Wow_Company' ) ) { | |
| 129 | + require_once self::dir() . 'includes/class-wow-company.php'; | |
| 130 | + } | |
| 131 | + | |
| 132 | + require_once self::dir() . 'classes/Autoloader.php'; | |
| 133 | + require_once self::dir() . 'admin/class-wowp-admin.php'; | |
| 134 | + require_once self::dir() . 'public/class-wowp-public.php'; | |
| 135 | + } | |
| 136 | + | |
| 137 | + /** | |
| 96 | 138 | * Throw error on object clone. |
| 97 | 139 | * The whole idea of the singleton design pattern is that there is a single |
| 98 | 140 | * object therefore, we don't want the object to be cloned. |
| 99 | 141 | * |
| 100 | 142 | * @return void |
| 101 | - * @since 1.0 | |
| 102 | 143 | * @access protected |
| 103 | 144 | */ |
| 104 | 145 | public function __clone() { |
| 105 | 146 | // Cloning instances of the class is forbidden. |
| 106 | - _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'float-menu' ), '0.1' ); | |
| 147 | + _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'float-menu' ), '1.0' ); | |
| 107 | 148 | } |
| 108 | 149 | |
| 109 | 150 | /** |
| 110 | 151 | * Disable unserializing of the class. |
| @@ -109,79 +150,53 @@ | ||
| 109 | 150 | /** |
| 110 | 151 | * Disable unserializing of the class. |
| 111 | 152 | * |
| 112 | 153 | * @return void |
| 113 | - * @since 1.0 | |
| 114 | 154 | * @access protected |
| 115 | 155 | */ |
| 116 | 156 | public function __wakeup() { |
| 117 | 157 | // Unserializing instances of the class is forbidden. |
| 118 | - _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'float-menu' ), '0.1' ); | |
| 158 | + _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'float-menu' ), '1.0' ); | |
| 119 | 159 | } |
| 120 | 160 | |
| 161 | + public function plugin_activate(): void { | |
| 121 | 162 | |
| 122 | - /** | |
| 123 | - * Include required files. | |
| 124 | - * | |
| 125 | - * @access private | |
| 126 | - * @return void | |
| 127 | - * @since 1.0 | |
| 128 | - */ | |
| 129 | - private function _includes() { | |
| 130 | - if ( ! class_exists( 'Wow_Company' ) ) { | |
| 131 | - include_once 'includes/class-wow-company.php'; | |
| 163 | + if ( is_plugin_active( 'float-menu-pro/float-menu-pro.php' ) ) { | |
| 164 | + deactivate_plugins( 'float-menu-pro/float-menu-pro.php' ); | |
| 132 | 165 | } |
| 133 | - include_once 'admin/class-admin.php'; | |
| 134 | - include_once 'public/class-public.php'; | |
| 135 | - } | |
| 136 | 166 | |
| 137 | - /** | |
| 138 | - * Activate the plugin. | |
| 139 | - * create the database | |
| 140 | - * create the folder in wp-upload | |
| 141 | - * | |
| 142 | - * @access public | |
| 143 | - * @return void | |
| 144 | - * @since 1.0 | |
| 145 | - */ | |
| 146 | - public function plugin_activate() { | |
| 147 | - update_option( 'wow_' . self::PREF . '_notice_action', 'read' ); | |
| 148 | - global $wpdb; | |
| 149 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); | |
| 150 | - $table = $wpdb->prefix . 'wow_' . self::PREF; | |
| 151 | - $sql = "CREATE TABLE " . $table . " ( | |
| 152 | - id mediumint(9) NOT NULL AUTO_INCREMENT, | |
| 153 | - title VARCHAR(200) NOT NULL, | |
| 154 | - param TEXT, | |
| 155 | - UNIQUE KEY id (id) | |
| 156 | - ) DEFAULT CHARSET=utf8;"; | |
| 157 | - dbDelta( $sql ); | |
| 167 | + $columns = " | |
| 168 | + id mediumint(9) NOT NULL AUTO_INCREMENT, | |
| 169 | + title VARCHAR(200), | |
| 170 | + param longtext, | |
| 171 | + status boolean DEFAULT 0 NOT NULL, | |
| 172 | + mode boolean DEFAULT 0 NOT NULL, | |
| 173 | + tag text, | |
| 174 | + PRIMARY KEY (id) | |
| 175 | + "; | |
| 158 | 176 | |
| 159 | - deactivate_plugins( 'float-menu-pro/float-menu-pro.php' ); | |
| 177 | + DBManager::create( $columns ); | |
| 178 | + | |
| 179 | + update_site_option( self::PREFIX . '_db_version', '7.0' ); | |
| 160 | 180 | } |
| 161 | 181 | |
| 162 | 182 | /** |
| 163 | 183 | * Download the folder with languages. |
| 164 | 184 | * |
| 165 | - * @access public | |
| 185 | + * @access Publisher | |
| 166 | 186 | * @return void |
| 167 | - * @since 1.0 | |
| 168 | 187 | */ |
| 169 | - public function text_domain() { | |
| 188 | + public function loaded(): void { | |
| 189 | + UpdateDB::init(); | |
| 170 | 190 | $languages_folder = dirname( plugin_basename( __FILE__ ) ) . '/languages/'; |
| 171 | 191 | load_plugin_textdomain( 'float-menu', false, $languages_folder ); |
| 172 | 192 | } |
| 173 | 193 | } |
| 174 | 194 | |
| 175 | -endif; // End if class_exists check. | |
| 195 | +endif; | |
| 176 | 196 | |
| 177 | -/** | |
| 178 | - * The main function for that returns Wow_Plugin | |
| 179 | - * | |
| 180 | - * @since 1.0 | |
| 181 | - */ | |
| 182 | -function Wow_Plugin_run() { | |
| 183 | - return Wow_Plugin::instance(); | |
| 197 | +function wp_plugin_run(): WOWP_Plugin { | |
| 198 | + return WOWP_Plugin::instance(); | |
| 184 | 199 | } |
| 185 | 200 | |
| 186 | -// Get Running. | |
| 187 | -Wow_Plugin_run(); | |
| 201 | +wp_plugin_run(); | |
| 202 | + | |