PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.0.12
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.0.12
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | classes/Visualizer/Module.php +50 -0 3.0.93.0.12 View file →
@@ -394,5 +394,55 @@
394 394 }
395 395 return reset( $array );
396 396 }
397 397
398 + /**
399 + * Gets/creates the JS where user-specific customizations can be/have been added.
400 + */
401 + protected function get_user_customization_js() {
402 + // use this as the JS file in case we are not able to create the file in uploads.
403 + $default = VISUALIZER_ABSURL . 'js/customization.js';
404 +
405 + $uploads = wp_get_upload_dir();
406 + $specific = $uploads['baseurl'] . '/visualizer/customization.js';
407 +
408 + // for testing on user sites (before we send them the correctly customized file).
409 + if ( VISUALIZER_TEST_JS_CUSTOMIZATION ) {
410 + return $default;
411 + }
412 +
413 + require_once( ABSPATH . 'wp-admin/includes/file.php' );
414 + WP_Filesystem();
415 + global $wp_filesystem;
416 +
417 + $dir = $wp_filesystem->wp_content_dir() . 'uploads/visualizer';
418 + $file = $wp_filesystem->wp_content_dir() . 'uploads/visualizer/customization.js';
419 +
420 + if ( $wp_filesystem->is_readable( $file ) ) {
421 + return $specific;
422 + }
423 +
424 + if ( $wp_filesystem->exists( $file ) && ! $wp_filesystem->is_readable( $file ) ) {
425 + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Unable to read file %s', $file ), 'error', __FILE__, __LINE__ );
426 + return $default;
427 + }
428 +
429 + if ( ! $wp_filesystem->exists( $dir ) ) {
430 + if ( ( $done = $wp_filesystem->mkdir( $dir ) ) === false ) {
431 + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Unable to create directory %s', $dir ), 'error', __FILE__, __LINE__ );
432 + return $default;
433 + }
434 + }
435 +
436 + // if file does not exist, copy.
437 + if ( ! $wp_filesystem->exists( $file ) ) {
438 + $src = str_replace( ABSPATH, $wp_filesystem->abspath(), VISUALIZER_ABSPATH . '/js/customization.js' );
439 + if ( ( $done = $wp_filesystem->copy( $src, $file ) ) === false ) {
440 + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Unable to copy file %s to %s', $src, $file ), 'error', __FILE__, __LINE__ );
441 + return $default;
442 + }
443 + }
444 +
445 + return $specific;
446 + }
447 +
398 448 }