| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Floating Button Lite |
| 4 |
* Plugin URI: https://wordpress.org/plugins/floating-button/ |
| 5 |
* Description: Easily Generate and manage sticky Floating Buttons. |
| 6 |
* Version: 6.0.1 |
| 7 |
* Author: Wow-Company |
| 8 |
* Author URI: https://wow-estore.com/ |
| 9 |
* Author Email: yoda@wow-company.com |
| 10 |
* Item ID: 25955 |
| 11 |
* Store URI: https://wow-estore.com/ |
| 12 |
* License: GPL-2.0+ |
| 13 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 14 |
* Text Domain: floating-button |
| 15 |
* Domain Path: /languages |
| 16 |
* |
| 17 |
* PHP version 7.4 |
| 18 |
* |
| 19 |
* @category Wordpress_Plugin |
| 20 |
* @package Wow_Plugin |
| 21 |
* @author Wow-Company <yoda@wow-company.com> |
| 22 |
* @copyright 2019 Wow-Company |
| 23 |
* @license GNU Public License |
| 24 |
* @version 1.1 |
| 25 |
*/ |
| 26 |
|
| 27 |
// Required set the namespace for plugin. |
| 28 |
namespace FloatingButton; |
| 29 |
|
| 30 |
// Exit if accessed directly. |
| 31 |
use FloatingButton\Dashboard\DBManager; |
| 32 |
use FloatingButton\Update\Checker; |
| 33 |
use FloatingButton\Update\UpdateDB; |
| 34 |
|
| 35 |
defined( 'ABSPATH' ) || exit; |
| 36 |
|
| 37 |
if ( ! class_exists( 'WOW_Plugin' ) ) : |
| 38 |
|
| 39 |
final class WOW_Plugin { |
| 40 |
|
| 41 |
// Plugin slug |
| 42 |
public const SLUG = 'floating-button'; |
| 43 |
|
| 44 |
// Plugin prefix |
| 45 |
public const PREFIX = 'wow_fbtnp'; |
| 46 |
|
| 47 |
// Plugin Shortcode |
| 48 |
public const SHORTCODE = 'Floating-Button'; |
| 49 |
|
| 50 |
private static $instance; |
| 51 |
/** |
| 52 |
* @var Autoloader |
| 53 |
*/ |
| 54 |
private $autoloader; |
| 55 |
/** |
| 56 |
* @var Wow_Dashboard |
| 57 |
*/ |
| 58 |
private $dashboard; |
| 59 |
private $public; |
| 60 |
|
| 61 |
public static function instance(): WOW_Plugin { |
| 62 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WOW_Plugin ) ) { |
| 63 |
self::$instance = new self; |
| 64 |
|
| 65 |
self::$instance->includes(); |
| 66 |
self::$instance->autoloader = new Autoloader( 'FloatingButton' ); |
| 67 |
self::$instance->dashboard = new WOWP_Dashboard(); |
| 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' ] ); |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
return self::$instance; |
| 76 |
} |
| 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 |
]; |
| 109 |
$plugin_data = get_file_data( __FILE__, $data, false ); |
| 110 |
|
| 111 |
return $plugin_data[ $show ] ?? ''; |
| 112 |
} |
| 113 |
|
| 114 |
/** |
| 115 |
* Include required files. |
| 116 |
* |
| 117 |
* @access private |
| 118 |
* @since 1.0 |
| 119 |
*/ |
| 120 |
private function includes(): void { |
| 121 |
if ( ! class_exists( 'Wow_Company' ) ) { |
| 122 |
require_once self::dir() . 'includes/class-wow-company.php'; |
| 123 |
} |
| 124 |
|
| 125 |
require_once self::dir() . 'classes/Autoloader.php'; |
| 126 |
require_once self::dir() . 'includes/class-wowp-dashboard.php'; |
| 127 |
require_once self::dir() . 'includes/class-wowp-public.php'; |
| 128 |
} |
| 129 |
|
| 130 |
/** |
| 131 |
* Throw error on object clone. |
| 132 |
* The whole idea of the singleton design pattern is that there is a single |
| 133 |
* object therefore, we don't want the object to be cloned. |
| 134 |
* |
| 135 |
* @return void |
| 136 |
* @access protected |
| 137 |
*/ |
| 138 |
public function __clone() { |
| 139 |
// Cloning instances of the class is forbidden. |
| 140 |
_doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'floating-button' ), '1.0' ); |
| 141 |
} |
| 142 |
|
| 143 |
/** |
| 144 |
* Disable unserializing of the class. |
| 145 |
* |
| 146 |
* @return void |
| 147 |
* @access protected |
| 148 |
*/ |
| 149 |
public function __wakeup() { |
| 150 |
// Unserializing instances of the class is forbidden. |
| 151 |
_doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'floating-button' ), '1.0' ); |
| 152 |
} |
| 153 |
|
| 154 |
public function plugin_activate(): void { |
| 155 |
$columns = " |
| 156 |
id mediumint(9) NOT NULL AUTO_INCREMENT, |
| 157 |
title VARCHAR(200) NOT NULL, |
| 158 |
param LONGTEXT, |
| 159 |
status BOOLEAN, |
| 160 |
mode BOOLEAN, |
| 161 |
tag TEXT, |
| 162 |
UNIQUE KEY id (id) |
| 163 |
"; |
| 164 |
DBManager::create( $columns ); |
| 165 |
|
| 166 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 167 |
if ( is_plugin_active( 'floating-button-pro/floating-button-pro.php' ) ) { |
| 168 |
deactivate_plugins( 'floating-button-pro/floating-button-pro.php' ); |
| 169 |
} |
| 170 |
} |
| 171 |
|
| 172 |
/** |
| 173 |
* Download the folder with languages. |
| 174 |
* |
| 175 |
* @access Publisher |
| 176 |
* @return void |
| 177 |
*/ |
| 178 |
public function loaded(): void { |
| 179 |
UpdateDB::init(); |
| 180 |
$languages_folder = dirname( plugin_basename( __FILE__ ) ) . '/languages/'; |
| 181 |
load_plugin_textdomain( 'floating-button', false, $languages_folder ); |
| 182 |
} |
| 183 |
} |
| 184 |
|
| 185 |
endif; |
| 186 |
|
| 187 |
function wow_plugin_run() { |
| 188 |
return WOW_Plugin::instance(); |
| 189 |
} |
| 190 |
|
| 191 |
wow_plugin_run(); |