• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress core a2z

WordPress core a2z

WordPress core only

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / _WP_Editors::editor() – Outputs the HTML for a single instance of the editor.

You appear to be a bot. Output may be restricted

Description

Outputs the HTML for a single instance of the editor.

Usage

_WP_Editors::editor( $content, $editor_id, $settings );

Parameters

$content
( string ) required – Initial content for the editor.
$editor_id
( string ) required – HTML ID for the textarea and TinyMCE and Quicktags instances. Should not contain square brackets.
$settings
( array ) optional – See _WP_Editors::parse_settings() for description.

Returns

void

Source

File name: wordpress/wp-includes/class-wp-editor.php
Lines:

1 to 100 of 153
  public static function editor( $content, $editor_id, $settings = array() ) {
    $set            = self::parse_settings( $editor_id, $settings );
    $editor_class   = ' class="' . trim( esc_attr( $set['editor_class'] ) . ' wp-editor-area' ) . '"';
    $tabindex       = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : '';
    $default_editor = 'html';
    $buttons        = '';
    $autocomplete   = '';
    $editor_id_attr = esc_attr( $editor_id );

    if ( $set['drag_drop_upload'] ) {
      self::$drag_drop_upload = true;
    }

    if ( ! empty( $set['editor_height'] ) ) {
      $height = ' style="height: ' . (int) $set['editor_height'] . 'px"';
    } else {
      $height = ' rows="' . (int) $set['textarea_rows'] . '"';
    }

    if ( ! current_user_can( 'upload_files' ) ) {
      $set['media_buttons'] = false;
    }

    if ( self::$this_tinymce ) {
      $autocomplete = ' autocomplete="off"';

      if ( self::$this_quicktags ) {
        $default_editor = $set['default_editor'] ? $set['default_editor'] : wp_default_editor();
        // 'html' is used for the "Text" editor tab.
        if ( 'html' !== $default_editor ) {
          $default_editor = 'tinymce';
        }

        $buttons .= '<button type="button" id="' . $editor_id_attr . '-tmce" class="wp-switch-editor switch-tmce"' .
          ' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Visual', 'Name for the Visual editor tab' ) . "</button>\n";
        $buttons .= '<button type="button" id="' . $editor_id_attr . '-html" class="wp-switch-editor switch-html"' .
          ' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Text', 'Name for the Text editor tab (formerly HTML)' ) . "</button>\n";
      } else {
        $default_editor = 'tinymce';
      }
    }

    $switch_class = 'html' === $default_editor ? 'html-active' : 'tmce-active';
    $wrap_class   = 'wp-core-ui wp-editor-wrap ' . $switch_class;

    if ( $set['_content_editor_dfw'] ) {
      $wrap_class .= ' has-dfw';
    }

    echo '<div id="wp-' . $editor_id_attr . '-wrap" class="' . $wrap_class . '">';

    if ( self::$editor_buttons_css ) {
      wp_print_styles( 'editor-buttons' );
      self::$editor_buttons_css = false;
    }

    if ( ! empty( $set['editor_css'] ) ) {
      echo $set['editor_css'] . "\n";
    }

    if ( ! empty( $buttons ) || $set['media_buttons'] ) {
      echo '<div id="wp-' . $editor_id_attr . '-editor-tools" class="wp-editor-tools hide-if-no-js">';

      if ( $set['media_buttons'] ) {
        self::$has_medialib = true;

        if ( ! function_exists( 'media_buttons' ) ) {
          require ABSPATH . 'wp-admin/includes/media.php';
        }

        echo '<div id="wp-' . $editor_id_attr . '-media-buttons" class="wp-media-buttons">';

        
/**
 * Fires after the default media button(s) are displayed.
 *
 * @since 2.5.0
 *
 * @param string $editor_id Unique editor identifier, e.g. 'content'.
 */
        do_action( 'media_buttons', $editor_id );
        echo "</div>\n";
      }

      echo '<div class="wp-editor-tabs">' . $buttons . "</div>\n";
      echo "</div>\n";
    }

    $quicktags_toolbar = '';

    if ( self::$this_quicktags ) {
      if ( 'content' === $editor_id && ! empty( $GLOBALS['current_screen'] ) && 'post' === $GLOBALS['current_screen']->base ) {
        $toolbar_id = 'ed_toolbar';
      } else {
        $toolbar_id = 'qt_' . $editor_id_attr . '_toolbar';
      }

      $quicktags_toolbar = '<div id="' . $toolbar_id . '" class="quicktags-toolbar"></div>';
    }

    
/**
 
[1] [2] Next »

 View on GitHub View on Trac

Published: 25th November 2019 | Last updated: 2nd April 2020

Primary Sidebar

Information

Function name: _WP_Editors::editor
Class ref: _WP_Editors
Plugin ref: WordPress
Version: 5.6
Sourcefile: wp-includes/class-wp-editor.php
File ref: wp-includes/class-wp-editor.php
API type: private
Deprecated?: No
API Letters: _,E,W

Footer

WP-a2z
WordPress core a2z
WordPress core only
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  core.wp-a2z.org
© Copyright WP-a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites