Created
January 30, 2026 20:44
-
-
Save meyt/9db12861fec94d6483e50ba963f24e26 to your computer and use it in GitHub Desktop.
jfastload.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Plugin Name: jfastload - Disable Elementor editor CDN assets | |
| * Description: Loads Elementor assets from local for air-gapped environment | |
| * Version: 1.0.0 | |
| * Plugin URI: https://yourwebsite.com | |
| * Author: Your Name | |
| * License: GPL v2 or later | |
| * Text Domain: jfastload | |
| */ | |
| // Make sure we don't expose any info if called directly | |
| if (!defined('ABSPATH')) { | |
| exit; | |
| } | |
| // Load very last - just before scripts are printed in footer | |
| add_action('wp_print_scripts', 'jfastload_final_replace', 99999); | |
| function jfastload_final_replace() { | |
| global $wp_scripts; | |
| $base = plugin_dir_url(__FILE__); | |
| $local_assets = [ | |
| // ACE editor assets | |
| // wp-content/plugins/elementor/core/editor/loader/editor-base-loader.php | |
| 'ace' => 'ace-builds-1.43.2/src-min-noconflict/ace.js', | |
| 'ace-language-tools' => 'ace-builds-1.43.2/src-min-noconflict/ext-language_tools.js', | |
| // Prism.js assets | |
| // wp-content/plugins/elementor-pro/modules/code-highlight/module.php | |
| 'prismjs_core' => 'prism-1.23.0/components/prism-core.min.js', | |
| 'prismjs_loader' => 'prism-1.23.0/plugins/autoloader/prism-autoloader.min.js', | |
| 'prismjs_normalize' => 'prism-1.23.0/plugins/normalize-whitespace/prism-normalize-whitespace.min.js', | |
| 'prismjs_line_numbers' => 'prism-1.23.0/plugins/line-numbers/prism-line-numbers.min.js', | |
| 'prismjs_line_highlight' => 'prism-1.23.0/plugins/line-highlight/prism-line-highlight.min.js', | |
| 'prismjs_toolbar' => 'prism-1.23.0/plugins/toolbar/prism-toolbar.min.js', | |
| 'prismjs_copy_to_clipboard' => 'prism-1.23.0/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js', | |
| ]; | |
| // Replace each registered script with its local version | |
| foreach ($local_assets as $handle => $local_path) { | |
| if (isset($wp_scripts->registered[$handle])) { | |
| $wp_scripts->registered[$handle]->src = $base . $local_path; | |
| } | |
| } | |
| } | |
| add_action('wp_enqueue_scripts', 'jfastload_enqueue_early', 1); // Priority 1 = early | |
| function jfastload_enqueue_early() { | |
| // register clipboard js which required by prism-copy-to-clipboard | |
| $base = plugin_dir_url(__FILE__); | |
| wp_enqueue_script('clipboardjs', $base . 'clipboard-2.0.0/clipboard.min.js', [], '2.0.0', true); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment