wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
wp_enqueue_code_editor › WordPress Function
Seit4.9.0
Veraltetn/v
› wp_enqueue_code_editor ( $args )
Parameter: |
|
Siehe: |
|
Gibt zurück: |
|
Definiert in: |
|
Codex: |
Enqueues assets needed by the code editor for the given settings.
Ähnliche Funktionen: wp_enqueue_editor, wp_enqueue_media, wp_enqueue_embed_styles, wp_enqueue_script, wp_enqueue_scripts
Quellcode
function wp_enqueue_code_editor( $args ) { if ( is_user_logged_in() && 'false' === wp_get_current_user()->syntax_highlighting ) { return false; } $settings = wp_get_code_editor_settings( $args ); if ( empty( $settings ) || empty( $settings['codemirror'] ) ) { return false; } wp_enqueue_script( 'code-editor' ); wp_enqueue_style( 'code-editor' ); if ( isset( $settings['codemirror']['mode'] ) ) { $mode = $settings['codemirror']['mode']; if ( is_string( $mode ) ) { $mode = array( 'name' => $mode, ); } if ( ! empty( $settings['codemirror']['lint'] ) ) { switch ( $mode['name'] ) { case 'css': case 'text/css': case 'text/x-scss': case 'text/x-less': wp_enqueue_script( 'csslint' ); break; case 'htmlmixed': case 'text/html': case 'php': case 'application/x-httpd-php': case 'text/x-php': wp_enqueue_script( 'htmlhint' ); wp_enqueue_script( 'csslint' ); wp_enqueue_script( 'jshint' ); if ( ! current_user_can( 'unfiltered_html' ) ) { wp_enqueue_script( 'htmlhint-kses' ); } break; case 'javascript': case 'application/ecmascript': case 'application/json': case 'application/javascript': case 'application/ld+json': case 'text/typescript': case 'application/typescript': wp_enqueue_script( 'jshint' ); wp_enqueue_script( 'jsonlint' ); break; } } } wp_add_inline_script( 'code-editor', sprintf( 'jQuery.extend( wp.codeEditor.defaultSettings, %s );', wp_json_encode( $settings ) ) ); /** * Fires when scripts and styles are enqueued for the code editor. * * @since 4.9.0 * * @param array $settings Settings for the enqueued code editor. */ do_action( 'wp_enqueue_code_editor', $settings ); return $settings; }