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 +25 -11 3.1.1 → 4.5.2 View file →
@@ -2,15 +2,15 @@
2 2 /**
3 3 * Plugin Name: WP Coder
4 4 * Plugin URI: https://wordpress.org/plugins/wp-coder/
5 5 * Description: Adding custom HTML, CSS, JavaScript and PHP code to your WordPress site.
6 - * Version: 3.1.1
6 + * Version: 4.5.2
7 7 * Author: WPCoder
8 8 * Author URI: https://wpcoder.pro
9 - * Author Email: [email protected]
9 + * Author Email: [email protected]
10 10 * License: GPL-2.0+
11 11 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
12 - * Text Domain: wpcoder
12 + * Text Domain: wp-coder
13 13 * Requires at least: 5.4
14 14 * Requires PHP: 7.4
15 15 */
16 16
@@ -16,8 +16,9 @@
16 16
17 17 namespace WPCoder;
18 18
19 19 // Exit if accessed directly.
20 +use WPCoder\Block\WPCoder_Block;
20 21 use WPCoder\Dashboard\DBManager;
21 22 use WPCoder\Dashboard\FolderManager;
22 23 use WPCoder\Update\UpdateDB;
23 24
@@ -22,9 +23,9 @@
22 23 use WPCoder\Update\UpdateDB;
23 24
24 25 defined( 'ABSPATH' ) || exit;
25 26
26 -if ( ! class_exists( 'WPCoder' ) ) :
27 +if ( ! class_exists( 'wpcoder' ) ) :
27 28
28 29 final class WPCoder {
29 30
30 31 // Plugin slug
@@ -59,9 +60,8 @@
59 60 self::$instance->autoloader = new Autoloader( 'WPCoder' );
60 61 self::$instance->dashboard = new WOWP_Dashboard();
61 62 self::$instance->public = new WOWP_Public();
62 63
63 -
64 64 register_activation_hook( __FILE__, [ self::$instance, 'plugin_activate' ] );
65 65 add_action( 'plugins_loaded', [ self::$instance, 'loaded' ] );
66 66 }
67 67
@@ -89,8 +89,16 @@
89 89 return plugin_dir_url( __FILE__ );
90 90 }
91 91
92 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 +
93 101 // Get Plugin Info
94 102 public static function info( $show = '' ): string {
95 103 $data = [
96 104 'name' => 'Plugin Name',
@@ -99,11 +107,11 @@
99 107 'author' => 'Author',
100 108 'email' => 'Author Email',
101 109 ];
102 110 $plugin_data = get_file_data( __FILE__, $data, false );
111 + $plugin_data['data'] = str_replace( ' ', '-', $plugin_data['name'] );
103 112
104 113 return $plugin_data[ $show ] ?? '';
105 -
106 114 }
107 115
108 116 /**
109 117 * Include required files.
@@ -112,8 +120,9 @@
112 120 * @since 1.0
113 121 */
114 122 private function includes(): void {
115 123 require_once self::dir() . 'includes/safe-mode.php';
124 + require_once self::dir() . 'includes/snippets.php';
116 125 require_once self::dir() . 'classes/Autoloader.php';
117 126 require_once self::dir() . 'includes/class-wowp-dashboard.php';
118 127 require_once self::dir() . 'includes/class-wowp-public.php';
119 128 }
@@ -127,9 +136,9 @@
127 136 * @access protected
128 137 */
129 138 public function __clone() {
130 139 // Cloning instances of the class is forbidden.
131 - _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'wpcoder' ), '1.0' );
140 + _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'wp-coder' ), '1.0' );
132 141 }
133 142
134 143 /**
135 144 * Disable unserializing of the class.
@@ -138,9 +147,9 @@
138 147 * @access protected
139 148 */
140 149 public function __wakeup() {
141 150 // Unserializing instances of the class is forbidden.
142 - _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'wpcoder' ), '1.0' );
151 + _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'wp-coder' ), '1.0' );
143 152 }
144 153
145 154 public function plugin_activate(): void {
146 155 $columns = "
@@ -153,12 +162,17 @@
153 162 param LONGTEXT,
154 163 status BOOLEAN,
155 164 mode BOOLEAN,
156 165 tag TEXT,
157 - UNIQUE KEY id (id)
166 + php_include int(11) NOT NULL DEFAULT '0',
167 + UNIQUE KEY id (id),
168 + INDEX id_index (id)
158 169 ";
170 +
171 +
159 172 DBManager::create( $columns );
160 173 FolderManager::create();
174 + update_option( self::PREFIX . '_db_version', '4.0' );
161 175
162 176 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
163 177 if ( is_plugin_active( 'wp-coder-pro/wp-coder-pro.php' ) ) {
164 178 deactivate_plugins( 'wp-coder-pro/wp-coder-pro.php' );
@@ -165,9 +179,8 @@
165 179 }
166 180 if ( is_plugin_active( 'wpcoderpro/wpcoderpro.php' ) ) {
167 181 deactivate_plugins( 'wpcoderpro/wpcoderpro.php' );
168 182 }
169 -
170 183 }
171 184
172 185 /**
173 186 * Download the folder with languages.
@@ -175,11 +188,12 @@
175 188 * @access Publisher
176 189 * @return void
177 190 */
178 191 public function loaded(): void {
192 + new WPCoder_Block();
179 193 UpdateDB::init();
180 194 $languages_folder = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
181 - load_plugin_textdomain( 'wpcoder', false, $languages_folder );
195 + load_plugin_textdomain( 'wp-coder', false, $languages_folder );
182 196 }
183 197
184 198 }
185 199