| @@ -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 | |
| 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.3 | |
| 7 | + * Author: WPCoder | |
| 8 | + * Author URI: https://wpcoder.pro | |
| 9 | + * Author Email: hey@wow-company.com | |
| 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 | |
| @@ -21,19 +22,12 @@ | ||
| 21 | 22 | use WPCoder\Update\UpdateDB; |
| 22 | 23 | |
| 23 | 24 | defined( 'ABSPATH' ) || exit; |
| 24 | 25 | |
| 25 | -if ( ! class_exists( 'WOW_Plugin' ) ) : | |
| 26 | +if ( ! class_exists( 'wpcoder' ) ) : | |
| 26 | 27 | |
| 27 | - final class WOW_Plugin { | |
| 28 | + final class WPCoder { | |
| 28 | 29 | |
| 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'; | |
| 35 | - | |
| 36 | 30 | // Plugin slug |
| 37 | 31 | public const SLUG = 'wp-coder'; |
| 38 | 32 | |
| 39 | 33 | // Plugin prefix |
| @@ -40,9 +34,9 @@ | ||
| 40 | 34 | public const PREFIX = 'wow_coder'; |
| 41 | 35 | |
| 42 | 36 | public const FOLDER = 'wp-coder'; |
| 43 | 37 | |
| 44 | - public const SHORTCODE = 'WP-Coder'; | |
| 38 | + public const SHORTCODE = 'wp_code'; | |
| 45 | 39 | |
| 46 | 40 | // Plugin ULR |
| 47 | 41 | public const PluginURL = 'https://wordpress.org/plugins/wp-coder/'; |
| 48 | 42 | |
| @@ -54,11 +48,12 @@ | ||
| 54 | 48 | /** |
| 55 | 49 | * @var Wow_Dashboard |
| 56 | 50 | */ |
| 57 | 51 | private $dashboard; |
| 52 | + private $public; | |
| 58 | 53 | |
| 59 | - public static function instance(): WOW_Plugin { | |
| 60 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WOW_Plugin ) ) { | |
| 54 | + public static function instance(): WPCoder { | |
| 55 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPCoder ) ) { | |
| 61 | 56 | self::$instance = new self; |
| 62 | 57 | |
| 63 | 58 | self::$instance->includes(); |
| 64 | 59 | self::$instance->autoloader = new Autoloader( 'WPCoder' ); |
| @@ -92,8 +87,24 @@ | ||
| 92 | 87 | public static function url(): string { |
| 93 | 88 | return plugin_dir_url( __FILE__ ); |
| 94 | 89 | } |
| 95 | 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 | + $plugin_data['data'] = str_replace( ' ', '-', $plugin_data['name'] ); | |
| 103 | + | |
| 104 | + return $plugin_data[ $show ] ?? ''; | |
| 105 | + } | |
| 106 | + | |
| 96 | 107 | /** |
| 97 | 108 | * Include required files. |
| 98 | 109 | * |
| 99 | 110 | * @access private |
| @@ -99,12 +110,10 @@ | ||
| 99 | 110 | * @access private |
| 100 | 111 | * @since 1.0 |
| 101 | 112 | */ |
| 102 | 113 | private function includes(): void { |
| 103 | - if ( ! class_exists( 'Wow_Company' ) ) { | |
| 104 | - require_once self::dir() . 'includes/class-wow-company.php'; | |
| 105 | - } | |
| 106 | - | |
| 114 | + require_once self::dir() . 'includes/safe-mode.php'; | |
| 115 | + require_once self::dir() . 'includes/snippets.php'; | |
| 107 | 116 | require_once self::dir() . 'classes/Autoloader.php'; |
| 108 | 117 | require_once self::dir() . 'includes/class-wowp-dashboard.php'; |
| 109 | 118 | require_once self::dir() . 'includes/class-wowp-public.php'; |
| 110 | 119 | } |
| @@ -118,9 +127,9 @@ | ||
| 118 | 127 | * @access protected |
| 119 | 128 | */ |
| 120 | 129 | public function __clone() { |
| 121 | 130 | // Cloning instances of the class is forbidden. |
| 122 | - _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'wpcoder' ), '1.0' ); | |
| 131 | + _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'wp-coder' ), '1.0' ); | |
| 123 | 132 | } |
| 124 | 133 | |
| 125 | 134 | /** |
| 126 | 135 | * Disable unserializing of the class. |
| @@ -129,9 +138,9 @@ | ||
| 129 | 138 | * @access protected |
| 130 | 139 | */ |
| 131 | 140 | public function __wakeup() { |
| 132 | 141 | // Unserializing instances of the class is forbidden. |
| 133 | - _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'wpcoder' ), '1.0' ); | |
| 142 | + _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', 'wp-coder' ), '1.0' ); | |
| 134 | 143 | } |
| 135 | 144 | |
| 136 | 145 | public function plugin_activate(): void { |
| 137 | 146 | $columns = " |
| @@ -139,21 +148,30 @@ | ||
| 139 | 148 | title VARCHAR(200) NOT NULL, |
| 140 | 149 | html_code LONGTEXT, |
| 141 | 150 | css_code LONGTEXT, |
| 142 | 151 | js_code LONGTEXT, |
| 152 | + php_code LONGTEXT, | |
| 143 | 153 | param LONGTEXT, |
| 144 | 154 | status BOOLEAN, |
| 145 | 155 | mode BOOLEAN, |
| 146 | 156 | tag TEXT, |
| 147 | - UNIQUE KEY id (id) | |
| 157 | + php_include int(11) NOT NULL DEFAULT '0', | |
| 158 | + UNIQUE KEY id (id), | |
| 159 | + INDEX id_index (id) | |
| 148 | 160 | "; |
| 161 | + | |
| 162 | + | |
| 149 | 163 | DBManager::create( $columns ); |
| 150 | 164 | FolderManager::create(); |
| 165 | + update_option( self::PREFIX . '_db_version', '4.0' ); | |
| 151 | 166 | |
| 152 | 167 | include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 153 | 168 | if ( is_plugin_active( 'wp-coder-pro/wp-coder-pro.php' ) ) { |
| 154 | 169 | deactivate_plugins( 'wp-coder-pro/wp-coder-pro.php' ); |
| 155 | 170 | } |
| 171 | + if ( is_plugin_active( 'wpcoderpro/wpcoderpro.php' ) ) { | |
| 172 | + deactivate_plugins( 'wpcoderpro/wpcoderpro.php' ); | |
| 173 | + } | |
| 156 | 174 | } |
| 157 | 175 | |
| 158 | 176 | /** |
| 159 | 177 | * Download the folder with languages. |
| @@ -163,15 +181,16 @@ | ||
| 163 | 181 | */ |
| 164 | 182 | public function loaded(): void { |
| 165 | 183 | UpdateDB::init(); |
| 166 | 184 | $languages_folder = dirname( plugin_basename( __FILE__ ) ) . '/languages/'; |
| 167 | - load_plugin_textdomain( 'wpcoder', false, $languages_folder ); | |
| 185 | + load_plugin_textdomain( 'wp-coder', false, $languages_folder ); | |
| 168 | 186 | } |
| 187 | + | |
| 169 | 188 | } |
| 170 | 189 | |
| 171 | 190 | endif; |
| 172 | 191 | |
| 173 | -function wow_plugin_run() { | |
| 174 | - return WOW_Plugin::instance(); | |
| 192 | +function wp_coder_run() { | |
| 193 | + return WPCoder::instance(); | |
| 175 | 194 | } |
| 176 | 195 | |
| 177 | -wow_plugin_run(); | |
| 196 | +wp_coder_run(); | |