PluginProbe
WP Coder – Insert & Manage Code Snippets / 4.5.2
WP Coder – Insert & Manage Code Snippets v4.5.2
4.5.2 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 All 40 releases
← All changes | wp-coder.php +57 -32 3.0.4 → 4.5.2 View file →
@@ -1,15 +1,16 @@
1 1 <?php
2 2 /**
3 3 * Plugin Name: WP Coder
4 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/
5 + * Description: Adding custom HTML, CSS, JavaScript and PHP code to your WordPress site.
6 + * Version: 4.5.2
7 + * Author: WPCoder
8 + * Author URI: https://wpcoder.pro
9 + * Author Email: [email protected]
9 10 * License: GPL-2.0+
10 11 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11 - * Text Domain: wpcoder
12 + * Text Domain: wp-coder
12 13 * Requires at least: 5.4
13 14 * Requires PHP: 7.4
14 15 */
15 16
@@ -15,8 +16,9 @@
15 16
16 17 namespace WPCoder;
17 18
18 19 // Exit if accessed directly.
20 +use WPCoder\Block\WPCoder_Block;
19 21 use WPCoder\Dashboard\DBManager;
20 22 use WPCoder\Dashboard\FolderManager;
21 23 use WPCoder\Update\UpdateDB;
22 24
@@ -21,19 +23,12 @@
21 23 use WPCoder\Update\UpdateDB;
22 24
23 25 defined( 'ABSPATH' ) || exit;
24 26
25 -if ( ! class_exists( 'WOW_Plugin' ) ) :
27 +if ( ! class_exists( 'wpcoder' ) ) :
26 28
27 - final class WOW_Plugin {
29 + final class WPCoder {
28 30
29 - public const EMAIl = '[email protected]';
30 - // Plugin name
31 - public const NAME = 'WP Coder';
32 -
33 - // Plugin version
34 - public const VERSION = '3.0.4';
35 -
36 31 // Plugin slug
37 32 public const SLUG = 'wp-coder';
38 33
39 34 // Plugin prefix
@@ -40,9 +35,9 @@
40 35 public const PREFIX = 'wow_coder';
41 36
42 37 public const FOLDER = 'wp-coder';
43 38
44 - public const SHORTCODE = 'WP-Coder';
39 + public const SHORTCODE = 'wp_code';
45 40
46 41 // Plugin ULR
47 42 public const PluginURL = 'https://wordpress.org/plugins/wp-coder/';
48 43
@@ -54,11 +49,12 @@
54 49 /**
55 50 * @var Wow_Dashboard
56 51 */
57 52 private $dashboard;
53 + private $public;
58 54
59 - public static function instance(): WOW_Plugin {
60 - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WOW_Plugin ) ) {
55 + public static function instance(): WPCoder {
56 + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPCoder ) ) {
61 57 self::$instance = new self;
62 58
63 59 self::$instance->includes();
64 60 self::$instance->autoloader = new Autoloader( 'WPCoder' );
@@ -66,9 +62,8 @@
66 62 self::$instance->public = new WOWP_Public();
67 63
68 64 register_activation_hook( __FILE__, [ self::$instance, 'plugin_activate' ] );
69 65 add_action( 'plugins_loaded', [ self::$instance, 'loaded' ] );
70 - add_action( 'admin_init', [ self::$instance, 'update'] );
71 66 }
72 67
73 68
74 69 return self::$instance;
@@ -93,8 +88,32 @@
93 88 public static function url(): string {
94 89 return plugin_dir_url( __FILE__ );
95 90 }
96 91
92 +
93 + // Capability required to access the plugin (it can execute PHP, so administrators only).
94 + public const CAPABILITY = 'manage_options';
95 +
96 + // Check if the current user can manage codes. On multisite, unfiltered_html is limited to super admins.
97 + public static function user_can_manage(): bool {
98 + return current_user_can( self::CAPABILITY ) && current_user_can( 'unfiltered_html' );
99 + }
100 +
101 + // Get Plugin Info
102 + public static function info( $show = '' ): string {
103 + $data = [
104 + 'name' => 'Plugin Name',
105 + 'version' => 'Version',
106 + 'url' => 'Plugin URI',
107 + 'author' => 'Author',
108 + 'email' => 'Author Email',
109 + ];
110 + $plugin_data = get_file_data( __FILE__, $data, false );
111 + $plugin_data['data'] = str_replace( ' ', '-', $plugin_data['name'] );
112 +
113 + return $plugin_data[ $show ] ?? '';
114 + }
115 +
97 116 /**
98 117 * Include required files.
99 118 *
100 119 * @access private
@@ -100,12 +119,10 @@
100 119 * @access private
101 120 * @since 1.0
102 121 */
103 122 private function includes(): void {
104 - if ( ! class_exists( 'Wow_Company' ) ) {
105 - require_once self::dir() . 'includes/class-wow-company.php';
106 - }
107 -
123 + require_once self::dir() . 'includes/safe-mode.php';
124 + require_once self::dir() . 'includes/snippets.php';
108 125 require_once self::dir() . 'classes/Autoloader.php';
109 126 require_once self::dir() . 'includes/class-wowp-dashboard.php';
110 127 require_once self::dir() . 'includes/class-wowp-public.php';
111 128 }
@@ -119,9 +136,9 @@
119 136 * @access protected
120 137 */
121 138 public function __clone() {
122 139 // Cloning instances of the class is forbidden.
123 - _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'wpcoder' ), '1.0' );
140 + _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'wp-coder' ), '1.0' );
124 141 }
125 142
126 143 /**
127 144 * Disable unserializing of the class.
@@ -130,9 +147,9 @@
130 147 * @access protected
131 148 */
132 149 public function __wakeup() {
133 150 // Unserializing instances of the class is forbidden.
134 - _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'wpcoder' ), '1.0' );
151 + _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'wp-coder' ), '1.0' );
135 152 }
136 153
137 154 public function plugin_activate(): void {
138 155 $columns = "
@@ -140,21 +157,30 @@
140 157 title VARCHAR(200) NOT NULL,
141 158 html_code LONGTEXT,
142 159 css_code LONGTEXT,
143 160 js_code LONGTEXT,
161 + php_code LONGTEXT,
144 162 param LONGTEXT,
145 163 status BOOLEAN,
146 164 mode BOOLEAN,
147 165 tag TEXT,
148 - UNIQUE KEY id (id)
166 + php_include int(11) NOT NULL DEFAULT '0',
167 + UNIQUE KEY id (id),
168 + INDEX id_index (id)
149 169 ";
170 +
171 +
150 172 DBManager::create( $columns );
151 173 FolderManager::create();
174 + update_option( self::PREFIX . '_db_version', '4.0' );
152 175
153 176 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
154 177 if ( is_plugin_active( 'wp-coder-pro/wp-coder-pro.php' ) ) {
155 178 deactivate_plugins( 'wp-coder-pro/wp-coder-pro.php' );
156 179 }
180 + if ( is_plugin_active( 'wpcoderpro/wpcoderpro.php' ) ) {
181 + deactivate_plugins( 'wpcoderpro/wpcoderpro.php' );
182 + }
157 183 }
158 184
159 185 /**
160 186 * Download the folder with languages.
@@ -162,20 +188,19 @@
162 188 * @access Publisher
163 189 * @return void
164 190 */
165 191 public function loaded(): void {
192 + new WPCoder_Block();
193 + UpdateDB::init();
166 194 $languages_folder = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
167 - load_plugin_textdomain( 'wpcoder', false, $languages_folder );
195 + load_plugin_textdomain( 'wp-coder', false, $languages_folder );
168 196 }
169 197
170 - public function update(): void {
171 - UpdateDB::init();
172 - }
173 198 }
174 199
175 200 endif;
176 201
177 -function wow_plugin_run() {
178 - return WOW_Plugin::instance();
202 +function wp_coder_run() {
203 + return WPCoder::instance();
179 204 }
180 205
181 -wow_plugin_run();
206 +wp_coder_run();