PluginProbe
WP Coder – Insert & Manage Code Snippets / 3.3
WP Coder – Insert & Manage Code Snippets v3.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
← All changes | wp-coder.php +180 -120 2.5.13.3 View file →
@@ -1,120 +1,180 @@
1 -<?php
2 -/**
3 - * Plugin Name: WP Coder
4 - * Plugin URI: https://wordpress.org/plugins/wp-coder/
5 - * Description: Add custom CSS, HTML, JavaScript on your website page
6 - * Version: 2.5.1
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 - */
13 -
14 -namespace wpcoder;
15 -
16 -if ( ! defined( 'ABSPATH' ) ) {
17 - exit;
18 -}
19 -
20 -
21 -if ( ! class_exists( 'Wow_Plugin_Class' ) ) {
22 -
23 - final class Wow_Plugin_Class {
24 -
25 - private static $instance;
26 -
27 - const PREF = 'coder';
28 -
29 - public static function instance() {
30 -
31 - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Wow_Plugin_Class ) ) {
32 -
33 - $info = array(
34 - 'plugin_name' => 'WP Coder',
35 - 'plugin_menu' => 'WP Coder',
36 - 'plugin_home_url' => 'https://wordpress.org/plugins/wp-coder/',
37 - 'plugin_version' => '2.5.1',
38 - 'plugin_file' => basename( __FILE__ ),
39 - 'plugin_slug' => dirname( plugin_basename( __FILE__ ) ),
40 - 'plugin_dir' => plugin_dir_path( __FILE__ ),
41 - 'plugin_url' => plugin_dir_url( __FILE__ ),
42 - 'plugin_pref' => self::PREF,
43 - 'author_url' => 'https://wow-estore.com',
44 - 'pro_url' => 'https://wow-estore.com/item/wp-coder-extension/',
45 - 'shortcode' => 'WP-Coder',
46 - );
47 -
48 - self::$instance = new Wow_Plugin_Class;
49 -
50 - register_activation_hook( __FILE__, array( self::$instance, 'plugin_activate' ) );
51 - register_deactivation_hook( __FILE__, array( self::$instance, 'plugin_deactivate' ) );
52 -
53 - add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) );
54 -
55 - add_action( 'admin_init', array( self::$instance, 'create_field' ) );
56 -
57 - self::$instance->includes();
58 -
59 - self::$instance->admin = new Wow_Admin_Class( $info );
60 - self::$instance->public = new Wow_Public_Class( $info );
61 -
62 -
63 - }
64 -
65 - return self::$instance;
66 - }
67 -
68 - public function __clone() {
69 - // Cloning instances of the class is forbidden.
70 - _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'wpcoder' ), '1.0' );
71 - }
72 -
73 - public function __wakeup() {
74 - // Unserializing instances of the class is forbidden.
75 - _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'wpcoder' ), '1.0' );
76 - }
77 -
78 -
79 - private function includes() {
80 - require_once plugin_dir_path( __FILE__ ) . 'includes/class-js-packer.php';
81 - require_once plugin_dir_path( __FILE__ ) . 'includes/class-db-update.php';
82 - require_once plugin_dir_path( __FILE__ ) . 'admin/class-admin.php';
83 - require_once plugin_dir_path( __FILE__ ) . 'public/class-public.php';
84 - }
85 -
86 - public function plugin_activate() {
87 - $field = dirname( plugin_basename( __FILE__ ) );
88 - require_once plugin_dir_path( __FILE__ ) . 'includes/activator.php';
89 - }
90 -
91 - public function plugin_deactivate() {
92 - require_once plugin_dir_path( __FILE__ ) . 'includes/deactivator.php';
93 - }
94 -
95 - public function create_field() {
96 - if ( get_option( 'wp_coder_create_field' ) === false ) {
97 - $upload = wp_upload_dir();
98 - $field = dirname( plugin_basename( __FILE__ ) );
99 - $basedir = $upload['basedir'] . '/' . $field . '/';
100 - if ( ! file_exists( $basedir ) ) {
101 - wp_mkdir_p( $basedir );
102 - }
103 - update_option( 'wp_coder_create_field', '2.0' );
104 - }
105 - }
106 -
107 - public function load_textdomain() {
108 - load_plugin_textdomain( self::PREF, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
109 - }
110 -
111 - }
112 -
113 -}
114 -
115 -function wow_plugin_run() {
116 - return Wow_Plugin_Class::instance();
117 -}
118 -
119 -// Get Running.
120 -wow_plugin_run();
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: 3.3
7 + * Author: WPCoder
8 + * Author URI: https://wpcoder.pro
9 + * Author Email: dev@wpcoder.pro
10 + * License: GPL-2.0+
11 + * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
12 + * Text Domain: wpcoder
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 +
64 + register_activation_hook( __FILE__, [ self::$instance, 'plugin_activate' ] );
65 + add_action( 'plugins_loaded', [ self::$instance, 'loaded' ] );
66 + }
67 +
68 +
69 + return self::$instance;
70 + }
71 +
72 + // Plugin Root File.
73 + public static function file(): string {
74 + return __FILE__;
75 + }
76 +
77 + // Plugin Base Name.
78 + public static function basename(): string {
79 + return plugin_basename( __FILE__ );
80 + }
81 +
82 + // Plugin Folder Path.
83 + public static function dir(): string {
84 + return plugin_dir_path( __FILE__ );
85 + }
86 +
87 + // Plugin Folder URL.
88 + public static function url(): string {
89 + return plugin_dir_url( __FILE__ );
90 + }
91 +
92 +
93 + // Get Plugin Info
94 + public static function info( $show = '' ): string {
95 + $data = [
96 + 'name' => 'Plugin Name',
97 + 'version' => 'Version',
98 + 'url' => 'Plugin URI',
99 + 'author' => 'Author',
100 + 'email' => 'Author Email',
101 + ];
102 + $plugin_data = get_file_data( __FILE__, $data, false );
103 +
104 + return $plugin_data[ $show ] ?? '';
105 +
106 + }
107 +
108 + /**
109 + * Include required files.
110 + *
111 + * @access private
112 + * @since 1.0
113 + */
114 + private function includes(): void {
115 + require_once self::dir() . 'includes/safe-mode.php';
116 + require_once self::dir() . 'classes/Autoloader.php';
117 + require_once self::dir() . 'includes/class-wowp-dashboard.php';
118 + require_once self::dir() . 'includes/class-wowp-public.php';
119 + }
120 +
121 + /**
122 + * Throw error on object clone.
123 + * The whole idea of the singleton design pattern is that there is a single
124 + * object therefore, we don't want the object to be cloned.
125 + *
126 + * @return void
127 + * @access protected
128 + */
129 + public function __clone() {
130 + // Cloning instances of the class is forbidden.
131 + _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'wpcoder' ), '1.0' );
132 + }
133 +
134 + /**
135 + * Disable unserializing of the class.
136 + *
137 + * @return void
138 + * @access protected
139 + */
140 + public function __wakeup() {
141 + // Unserializing instances of the class is forbidden.
142 + _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'wpcoder' ), '1.0' );
143 + }
144 +
145 + public function plugin_activate(): void {
146 + DBManager::create();
147 + FolderManager::create();
148 + update_option( self::PREFIX . '_db_version', '3.2' );
149 +
150 + include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
151 + if ( is_plugin_active( 'wp-coder-pro/wp-coder-pro.php' ) ) {
152 + deactivate_plugins( 'wp-coder-pro/wp-coder-pro.php' );
153 + }
154 + if ( is_plugin_active( 'wpcoderpro/wpcoderpro.php' ) ) {
155 + deactivate_plugins( 'wpcoderpro/wpcoderpro.php' );
156 + }
157 +
158 + }
159 +
160 + /**
161 + * Download the folder with languages.
162 + *
163 + * @access Publisher
164 + * @return void
165 + */
166 + public function loaded(): void {
167 + UpdateDB::init();
168 + $languages_folder = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
169 + load_plugin_textdomain( 'wpcoder', false, $languages_folder );
170 + }
171 +
172 + }
173 +
174 +endif;
175 +
176 +function wp_coder_run() {
177 + return WPCoder::instance();
178 +}
179 +
180 +wp_coder_run();