PluginProbe
WP Coder – Insert & Manage Code Snippets / 4.0.3
WP Coder – Insert & Manage Code Snippets v4.0.3
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 4.0.3, at wp-coder.php

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