file ), array( 'code-snippets-editor' ), $plugin->version ); } } // Enqueue the menu scripts wp_enqueue_script( 'code-snippets-settings-menu', plugins_url( 'js/min/settings.js', $plugin->file ), array( 'code-snippets-editor' ), $plugin->version, true ); // Extract the CodeMirror-specific editor settings $setting_fields = code_snippets_get_settings_fields(); $editor_fields = array(); foreach ( $setting_fields['editor'] as $name => $field ) { if ( empty( $field['codemirror'] ) ) { continue; } $editor_fields[] = array( 'name' => $name, 'type' => $field['type'], 'codemirror' => addslashes( $field['codemirror'] ), ); } // Pass the saved options to the external JavaScript file $inline_script = 'var code_snippets_editor_atts = ' . code_snippets_get_editor_atts( array(), true ) . ';'; $inline_script .= "\n" . 'var code_snippets_editor_settings = ' . wp_json_encode( $editor_fields ) . ';'; wp_add_inline_script( 'code-snippets-settings-menu', $inline_script, 'before' ); } /** * Render a theme select field * * @param array $atts */ function code_snippets_codemirror_theme_select_field( $atts ) { $saved_value = code_snippets_get_setting( $atts['section'], $atts['id'] ); echo ''; } /** * Render the editor preview setting */ function code_snippets_settings_editor_preview() { echo '
'; }