PluginProbe
WP Coder – Insert & Manage Code Snippets / 3.0
WP Coder – Insert & Manage Code Snippets v3.0
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 | classes/Dashboard/FolderManager.php +3 -40 3.13.0 View file →
@@ -6,36 +6,30 @@
6 6
7 7 // Exit if accessed directly.
8 8 use WPCoder\Optimization\Obfuscator;
9 9 use WPCoder\Optimization\CSSMinifier;
10 -use WPCoder\WPCoder;
10 +use WPCoder\WOW_Plugin;
11 11
12 12 class FolderManager {
13 13
14 14 public static function create(): void {
15 15 $basedir = self::path_upload_dir();
16 - $index_file = $basedir . 'index.php';
17 16
18 17 if ( ! file_exists( $basedir ) ) {
19 18 wp_mkdir_p( $basedir );
20 19 }
21 -
22 - if ( is_dir( $basedir ) && ! file_exists( $index_file ) ) {
23 - file_put_contents($index_file, '<?php // Silence is golden.');
24 - }
25 20 }
26 21
27 -
28 22 public static function path_upload_dir(): string {
29 23 $upload = wp_upload_dir();
30 24
31 - return $upload['basedir'] . '/' . WPCoder::FOLDER . '/';
25 + return $upload['basedir'] . '/' . WOW_Plugin::FOLDER . '/';
32 26 }
33 27
34 28 public static function path_upload_url(): string {
35 29 $upload = wp_upload_dir();
36 30
37 - return $upload['baseurl'] . '/' . WPCoder::FOLDER . '/';
31 + return $upload['baseurl'] . '/' . WOW_Plugin::FOLDER . '/';
38 32 }
39 33
40 34 public static function get_style_url( $result ): string {
41 35 $path_style = self::path_upload_dir() . 'style-' . $result->id . '.css';
@@ -102,35 +96,8 @@
102 96
103 97 return file_put_contents( $path_js, $js_code );
104 98 }
105 99
106 - public static function code_path( $result ): string {
107 -
108 - $path = self::path_upload_dir() . 'wp-code-' . $result->id . '.php';
109 -
110 - if ( ! file_exists( $path ) ) {
111 - $content = "<?php\n\n defined( 'ABSPATH' ) || exit;\n";
112 - $content .= $result->php_code;
113 - file_put_contents( $path, $content );
114 - }
115 -
116 - return self::path_upload_dir() . 'wp-code-' . $result->id . '.php';
117 - }
118 -
119 - public static function update_code( $data, $id) {
120 -
121 - if ( ! is_numeric( $id ) ) {
122 - return false;
123 - }
124 -
125 - $path = self::path_upload_dir() . 'wp-code-' . $id . '.php';
126 -
127 - $content = "<?php\n\n defined( 'ABSPATH' ) || exit;\n";
128 - $content .= $data['php_code'];
129 -
130 - return file_put_contents( $path, $content );
131 - }
132 -
133 100 public static function update_files( $data, $id ): void {
134 101 if ( ! empty( $data['css_code'] ) ) {
135 102 self::update_style( $data, $id );
136 103 }
@@ -135,11 +102,7 @@
135 102 self::update_style( $data, $id );
136 103 }
137 104 if ( ! empty( $data['js_code'] ) ) {
138 105 self::update_script( $data, $id );
139 - }
140 -
141 - if ( ! empty( $data['php_code'] ) ) {
142 - self::update_code( $data, $id );
143 106 }
144 107 }
145 108 }