@@ -97,8 +97,10 @@ public function enqueue_scripts() {
9797 * between the defined hooks and the functions defined in this
9898 * class.
9999 */
100-
101- wp_enqueue_script ( $ this ->plugin_name .'-ace-editor-cdn ' ,'https://cdnjs.cloudflare.com/ajax/libs/ace/1.9.6/ace.js ' , array (), $ this ->version , true );
100+ $ aceScript = 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.9.6/ace.js ' ;
101+ if (wp_http_validate_url ($ aceScript )) {
102+ wp_enqueue_script ( $ this ->plugin_name .'-ace-editor-cdn ' ,$ aceScript , array (), $ this ->version , true );
103+ }
102104 wp_enqueue_script ( $ this ->plugin_name , plugin_dir_url ( __FILE__ ) . 'js/custom-css-and-js-editor-admin.js ' , array ( 'jquery ' ), $ this ->version , true );
103105
104106 }
@@ -118,16 +120,24 @@ public function customCSSAndJSEditorSubmenu(){
118120 }
119121 public function customCssAndJSEditorAdmin (){
120122 // Handle form submission
121- if ( isset ( $ _POST ['customCodeEditorNonce ' ] ) && wp_verify_nonce ( $ _POST ['customCodeEditorNonce ' ], 'customCodeEditorSave ' ) ) {
122- // Ensure input is unslashed before sanitization
123- $ custom_css = isset ( $ _POST ['custom_code_editor_css ' ] ) ? wp_unslash ( $ _POST ['custom_code_editor_css ' ] ) : '' ;
124- $ custom_js = isset ( $ _POST ['custom_code_editor_js ' ] ) ? wp_unslash ( $ _POST ['custom_code_editor_js ' ] ) : '' ;
125-
126- // Sanitize inputs before saving
127- update_option ( 'custom_code_editor_css ' , sanitize_textarea_field ( $ custom_css ) );
128- update_option ( 'custom_code_editor_js ' , sanitize_textarea_field ( $ custom_js ) );
129- }
130-
123+ if ( isset ( $ _POST ['customCodeEditorNonce ' ] ) ) {
124+ // Unslash and sanitize nonce
125+ $ customCodeEditorNonce = sanitize_text_field ( wp_unslash ( $ _POST ['customCodeEditorNonce ' ] ) );
126+
127+ // Verify nonce
128+ if ( wp_verify_nonce ( $ customCodeEditorNonce , 'customCodeEditorSave ' ) ) {
129+
130+ // Check if CSS and JS fields exist, then unslash them
131+ $ custom_css = isset ( $ _POST ['custom_code_editor_css ' ] ) ? sanitize_textarea_field (wp_unslash ( $ _POST ['custom_code_editor_css ' ] )) : '' ;
132+ $ custom_js = isset ( $ _POST ['custom_code_editor_js ' ] ) ? sanitize_textarea_field (wp_unslash ( $ _POST ['custom_code_editor_js ' ] )) : '' ;
133+
134+ // Sanitize before saving
135+ update_option ( 'custom_code_editor_css ' , $ custom_css );
136+ update_option ( 'custom_code_editor_js ' , $ custom_js );
137+ } else {
138+ wp_die ( 'Security check failed ' );
139+ }
140+ }
131141 // Retrieve options
132142 $ backendLoadCSS = get_option ( 'custom_code_editor_css ' , '' );
133143 $ backendLoadJS = get_option ( 'custom_code_editor_js ' , '' );
0 commit comments