PluginProbe
Elementor Website Builder – more than just a page builder / 3.2.5
Elementor Website Builder – more than just a page builder v3.2.5
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | core/files/manager.php +19 -137 4.2.43.2.5 View file →
@@ -1,14 +1,14 @@
1 1 <?php
2 2 namespace Elementor\Core\Files;
3 3
4 -use Elementor\Core\Base\Document as Document_Base;
5 -use Elementor\Core\Base\Elements_Iteration_Actions\Assets;
6 4 use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
5 +use Elementor\Core\Files\Assets\Files_Upload_Handler;
6 +use Elementor\Core\Files\Assets\Json\Json_Handler;
7 +use Elementor\Core\Files\Assets\Svg\Svg_Handler;
8 +use Elementor\Core\Files\CSS\Global_CSS;
7 9 use Elementor\Core\Files\CSS\Post as Post_CSS;
8 -use Elementor\Core\Page_Assets\Data_Managers\Base as Page_Assets_Data_Manager;
9 10 use Elementor\Core\Responsive\Files\Frontend;
10 -use Elementor\Plugin;
11 11 use Elementor\Utils;
12 12
13 13 if ( ! defined( 'ABSPATH' ) ) {
14 14 exit; // Exit if accessed directly.
@@ -34,16 +34,19 @@
34 34 * @access public
35 35 */
36 36 public function __construct() {
37 37 $this->register_actions();
38 +
39 + new Svg_Handler();
40 + new Json_Handler();
38 41 }
39 42
40 - public function get( $class_name, $args ) {
41 - $id = $class_name . '-' . wp_json_encode( $args );
43 + public function get( $class, $args ) {
44 + $id = $class . '-' . wp_json_encode( $args );
42 45
43 46 if ( ! isset( $this->files[ $id ] ) ) {
44 47 // Create an instance from dynamic args length.
45 - $reflection_class = new \ReflectionClass( $class_name );
48 + $reflection_class = new \ReflectionClass( $class );
46 49 $this->files[ $id ] = $reflection_class->newInstanceArgs( $args );
47 50 }
48 51
49 52 return $this->files[ $id ];
@@ -112,15 +115,12 @@
112 115 unlink( $file_path );
113 116 }
114 117
115 118 delete_post_meta_by_key( Post_CSS::META_KEY );
116 - delete_post_meta_by_key( Document_Base::CACHE_META_KEY );
117 - delete_post_meta_by_key( Assets::ASSETS_META_KEY );
118 119
120 + delete_option( Global_CSS::META_KEY );
119 121 delete_option( Frontend::META_KEY );
120 122
121 - $this->reset_assets_data();
122 -
123 123 /**
124 124 * Elementor clear files.
125 125 *
126 126 * Fires after Elementor clears files
@@ -129,49 +129,18 @@
129 129 */
130 130 do_action( 'elementor/core/files/clear_cache' );
131 131 }
132 132
133 - public function clear_custom_image_sizes() {
134 - if ( ! defined( 'BFITHUMB_UPLOAD_DIR' ) ) {
135 - return;
136 - }
137 -
138 - $upload_info = wp_upload_dir();
139 - $upload_dir = $upload_info['basedir'] . '/' . BFITHUMB_UPLOAD_DIR;
140 -
141 - $path = $upload_dir . '/*';
142 -
143 - foreach ( glob( $path ) as $file_path ) {
144 - unlink( $file_path );
145 - }
146 - }
147 -
148 - /**
149 - * Register Ajax Actions
150 - *
151 - * Deprecated - use the Uploads Manager instead.
152 - *
153 - * @deprecated 3.5.0
154 - *
155 - * @param Ajax $ajax
156 - */
157 133 public function register_ajax_actions( Ajax $ajax ) {
158 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0' );
159 -
160 - Plugin::$instance->uploads_manager->register_ajax_actions( $ajax );
134 + $ajax->register_ajax_action( 'enable_unfiltered_files_upload', [ $this, 'ajax_unfiltered_files_upload' ] );
161 135 }
162 136
163 - /**
164 - * Ajax Unfiltered Files Upload
165 - *
166 - * Deprecated - use the Uploads Manager instead.
167 - *
168 - * @deprecated 3.5.0
169 - */
170 137 public function ajax_unfiltered_files_upload() {
171 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0' );
138 + if ( ! current_user_can( 'manage_options' ) ) {
139 + return;
140 + }
172 141
173 - Plugin::$instance->uploads_manager->enable_unfiltered_files_upload();
142 + update_option( Files_Upload_Handler::OPTION_KEY, 1 );
174 143 }
175 144
176 145 /**
177 146 * Register actions.
@@ -183,97 +152,10 @@
183 152 */
184 153 private function register_actions() {
185 154 add_action( 'deleted_post', [ $this, 'on_delete_post' ] );
186 155
156 + // Ajax.
157 + add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] );
158 +
187 159 add_filter( 'wxr_export_skip_postmeta', [ $this, 'on_export_post_meta' ], 10, 2 );
188 -
189 - add_action( 'update_option_home', function () {
190 - $this->reset_assets_data();
191 - } );
192 -
193 - add_action( 'update_option_siteurl', function () {
194 - $this->reset_assets_data();
195 - } );
196 -
197 - add_action( 'rest_api_init', [ $this, 'register_endpoints' ] );
198 - }
199 -
200 - /**
201 - * Reset Assets Data.
202 - *
203 - * Reset the page assets data.
204 - *
205 - * @since 3.3.0
206 - * @access private
207 - */
208 - private function reset_assets_data() {
209 - delete_option( Page_Assets_Data_Manager::ASSETS_DATA_KEY );
210 - }
211 -
212 - /**
213 - * Generate CSS.
214 - *
215 - * Generates CSS for all posts built with Elementor.
216 - *
217 - * @since 3.25.0
218 - * @access public
219 - */
220 - public function generate_css() {
221 - $batch_size = apply_filters( 'elementor/core/files/generate_css/batch_size', 100 );
222 - $processed_posts = 0;
223 -
224 - while ( true ) {
225 - $args = [
226 - 'post_type' => get_post_types(),
227 - 'posts_per_page' => $batch_size,
228 - 'meta_query' => [
229 - [
230 - 'key' => Document_Base::BUILT_WITH_ELEMENTOR_META_KEY,
231 - 'compare' => 'EXISTS',
232 - ],
233 - ],
234 - 'offset' => $processed_posts,
235 - 'fields' => 'ids',
236 - ];
237 -
238 - $query = new \WP_Query( $args );
239 -
240 - if ( empty( $query->posts ) ) {
241 - break;
242 - }
243 -
244 - foreach ( $query->posts as $post_id ) {
245 - $document = Plugin::$instance->documents->get_doc_for_frontend( $post_id );
246 -
247 - if ( $document ) {
248 - $css_file = Post_CSS::create( $post_id );
249 - $css_file->update();
250 - }
251 - }
252 -
253 - $processed_posts += $batch_size;
254 - }
255 -
256 - /**
257 - * Elementor Generate CSS files.
258 - *
259 - * Fires after Elementor generates new CSS files
260 - *
261 - * @since 3.25.0
262 - */
263 - do_action( 'elementor/core/files/after_generate_css' );
264 - }
265 -
266 - public function register_endpoints() {
267 - register_rest_route(
268 - 'elementor/v1',
269 - '/cache',
270 - [
271 - 'methods' => \WP_REST_Server::DELETABLE,
272 - 'callback' => [ $this, 'clear_cache' ],
273 - 'permission_callback' => function() {
274 - return current_user_can( 'manage_options' );
275 - },
276 - ]
277 - );
278 160 }
279 161 }