PluginProbe
WP Coder – Insert & Manage Code Snippets / 3.0.4
WP Coder – Insert & Manage Code Snippets v3.0.4
4.5.1 1.1 2.3.1 2.3.2 2.4.1 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 3.2 3.2.1 3.3 3.4 3.5 3.5.1 All 39 releases
wp-coder / wp-coder.php

wp-coder.php in WP Coder – Insert & Manage Code Snippets 3.0.4, at wp-coder.php

181 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: WP Coder
4 * Plugin URI: https://wordpress.org/plugins/wp-coder/
5 * Description: Adding custom HTML, CSS, and JavaScript code to your WordPress site.
6 * Version: 3.0.4
7 * Author: Wow-Company
8 * Author URI: https://wow-estore.com/
9 * License: GPL-2.0+
10 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11 * Text Domain: wpcoder
12 * Requires at least: 5.4
13 * Requires PHP: 7.4
14 */
15
16 namespace WPCoder;
17
18 // Exit if accessed directly.
19 use WPCoder\Dashboard\DBManager;
20 use WPCoder\Dashboard\FolderManager;
21 use WPCoder\Update\UpdateDB;
22
23 defined( 'ABSPATH' ) || exit;
24
25 if ( ! class_exists( 'WOW_Plugin' ) ) :
26
27 final class WOW_Plugin {
28
29 public const EMAIl = 'yoda@wow-company.com';
30 // Plugin name
31 public const NAME = 'WP Coder';
32
33 // Plugin version
34 public const VERSION = '3.0.4';
35
36 // Plugin slug
37 public const SLUG = 'wp-coder';
38
39 // Plugin prefix
40 public const PREFIX = 'wow_coder';
41
42 public const FOLDER = 'wp-coder';
43
44 public const SHORTCODE = 'WP-Coder';
45
46 // Plugin ULR
47 public const PluginURL = 'https://wordpress.org/plugins/wp-coder/';
48
49 private static $instance;
50 /**
51 * @var Autoloader
52 */
53 private $autoloader;
54 /**
55 * @var Wow_Dashboard
56 */
57 private $dashboard;
58
59 public static function instance(): WOW_Plugin {
60 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WOW_Plugin ) ) {
61 self::$instance = new self;
62
63 self::$instance->includes();
64 self::$instance->autoloader = new Autoloader( 'WPCoder' );
65 self::$instance->dashboard = new WOWP_Dashboard();
66 self::$instance->public = new WOWP_Public();
67
68 register_activation_hook( __FILE__, [ self::$instance, 'plugin_activate' ] );
69 add_action( 'plugins_loaded', [ self::$instance, 'loaded' ] );
70 add_action( 'admin_init', [ self::$instance, 'update'] );
71 }
72
73
74 return self::$instance;
75 }
76
77 // Plugin Root File.
78 public static function file(): string {
79 return __FILE__;
80 }
81
82 // Plugin Base Name.
83 public static function basename(): string {
84 return plugin_basename( __FILE__ );
85 }
86
87 // Plugin Folder Path.
88 public static function dir(): string {
89 return plugin_dir_path( __FILE__ );
90 }
91
92 // Plugin Folder URL.
93 public static function url(): string {
94 return plugin_dir_url( __FILE__ );
95 }
96
97 /**
98 * Include required files.
99 *
100 * @access private
101 * @since 1.0
102 */
103 private function includes(): void {
104 if ( ! class_exists( 'Wow_Company' ) ) {
105 require_once self::dir() . 'includes/class-wow-company.php';
106 }
107
108 require_once self::dir() . 'classes/Autoloader.php';
109 require_once self::dir() . 'includes/class-wowp-dashboard.php';
110 require_once self::dir() . 'includes/class-wowp-public.php';
111 }
112
113 /**
114 * Throw error on object clone.
115 * The whole idea of the singleton design pattern is that there is a single
116 * object therefore, we don't want the object to be cloned.
117 *
118 * @return void
119 * @access protected
120 */
121 public function __clone() {
122 // Cloning instances of the class is forbidden.
123 _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'wpcoder' ), '1.0' );
124 }
125
126 /**
127 * Disable unserializing of the class.
128 *
129 * @return void
130 * @access protected
131 */
132 public function __wakeup() {
133 // Unserializing instances of the class is forbidden.
134 _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'wpcoder' ), '1.0' );
135 }
136
137 public function plugin_activate(): void {
138 $columns = "
139 id mediumint(9) NOT NULL AUTO_INCREMENT,
140 title VARCHAR(200) NOT NULL,
141 html_code LONGTEXT,
142 css_code LONGTEXT,
143 js_code LONGTEXT,
144 param LONGTEXT,
145 status BOOLEAN,
146 mode BOOLEAN,
147 tag TEXT,
148 UNIQUE KEY id (id)
149 ";
150 DBManager::create( $columns );
151 FolderManager::create();
152
153 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
154 if ( is_plugin_active( 'wp-coder-pro/wp-coder-pro.php' ) ) {
155 deactivate_plugins( 'wp-coder-pro/wp-coder-pro.php' );
156 }
157 }
158
159 /**
160 * Download the folder with languages.
161 *
162 * @access Publisher
163 * @return void
164 */
165 public function loaded(): void {
166 $languages_folder = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
167 load_plugin_textdomain( 'wpcoder', false, $languages_folder );
168 }
169
170 public function update(): void {
171 UpdateDB::init();
172 }
173 }
174
175 endif;
176
177 function wow_plugin_run() {
178 return WOW_Plugin::instance();
179 }
180
181 wow_plugin_run();