user_can_richedit example

$required      = $field['required'] ? ' ' . wp_required_field_indicator() : '';
        $required_attr = $field['required'] ? ' required' : '';
        $class         = $id;
        $class        .= $field['required'] ? ' form-required' : '';

        $item .= "\t\t<tr class='$class'>\n\t\t\t<th scope='row' class='label'><label for='$name'><span class='alignleft'>{$field['label']}{$required}</span><br class='clear' /></label></th>\n\t\t\t<td class='field'>";

        if ( ! empty( $field[ $field['input'] ] ) ) {
            $item .= $field[ $field['input'] ];
        } elseif ( 'textarea' === $field['input'] ) {
            if ( 'post_content' === $id && user_can_richedit() ) {
                // Sanitize_post() skips the post_content when user_can_richedit.                 $field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES );
            }
            // Post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit().             $item .= "<textarea id='$name' name='$name'{$required_attr}>" . $field['value'] . '</textarea>';
        } else {
            $item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "'{$required_attr} />";
        }

        if ( ! empty( $field['helps'] ) ) {
            $item .= "<p class='help'>" . implode( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>';
        }
$instance = wp_parse_args(
            (array) $instance,
            array(
                'title' => '',
                'text'  => '',
            )
        );
        ?> <?php if ( ! $this->is_legacy_instance( $instance ) ) : ?> <?php
            if ( user_can_richedit() ) {
                add_filter( 'the_editor_content', 'format_for_editor', 10, 2 );
                $default_editor = 'tinymce';
            } else {
                $default_editor = 'html';
            }

            /** This filter is documented in wp-includes/class-wp-editor.php */
            $text = apply_filters( 'the_editor_content', $instance['text']$default_editor );

            // Reset filter addition.             if ( user_can_richedit() ) {
                

$body_placeholder = apply_filters( 'write_your_story', __( 'Type / to choose a block' )$post );

$editor_settings = array(
    'availableTemplates'   => $available_templates,
    'disablePostFormats'   => ! current_theme_supports( 'post-formats' ),
    /** This filter is documented in wp-admin/edit-form-advanced.php */
    'titlePlaceholder'     => apply_filters( 'enter_title_here', __( 'Add title' )$post ),
    'bodyPlaceholder'      => $body_placeholder,
    'autosaveInterval'     => AUTOSAVE_INTERVAL,
    'richEditingEnabled'   => user_can_richedit(),
    'postLock'             => $lock_details,
    'postLockUtils'        => array(
        'nonce'       => wp_create_nonce( 'lock-post_' . $post->ID ),
        'unlockNonce' => wp_create_nonce( 'update-post_' . $post->ID ),
        'ajaxUrl'     => admin_url( 'admin-ajax.php' ),
    ),
    'supportsLayout'       => wp_theme_has_theme_json(),
    'supportsTemplateMode' => current_theme_supports( 'block-templates' ),

    // Whether or not to load the 'postcustom' meta box is stored as a user meta     // field so that we're not always loading its assets.
/** * Finds out which editor should be displayed by default. * * Works out which of the two editors to display as the current editor for a * user. The 'html' setting is for the "Text" editor tab. * * @since 2.5.0 * * @return string Either 'tinymce', or 'html', or 'test' */
function wp_default_editor() {
    $r = user_can_richedit() ? 'tinymce' : 'html'; // Defaults.     if ( wp_get_current_user() ) { // Look for cookie.         $ed = get_user_setting( 'editor', 'tinymce' );
        $r  = ( in_array( $ed, array( 'tinymce', 'html', 'test' ), true ) ) ? $ed : $r;
    }

    /** * Filters which editor should be displayed by default. * * @since 2.5.0 * * @param string $r Which editor should be displayed by default. Either 'tinymce', 'html', or 'test'. */

            $value = apply_filters( "{$field_no_prefix}_edit_pre", $value$post_id );
        } else {
            $value = apply_filters( "edit_post_{$field}", $value$post_id );
        }

        if ( in_array( $field$format_to_edit, true ) ) {
            if ( 'post_content' === $field ) {
                $value = format_to_edit( $valueuser_can_richedit() );
            } else {
                $value = format_to_edit( $value );
            }
        } else {
            $value = esc_attr( $value );
        }
    } elseif ( 'db' === $context ) {
        if ( $prefixed ) {

            /** * Filters the value of a specific post field before saving. * * The dynamic portion of the hook name, `$field`, refers to the post * field name. * * @since 2.3.0 * * @param mixed $value Value of the post field. */
'tabindex'            => '',
                'tabfocus_elements'   => ':prev,:next',
                'editor_css'          => '',
                'editor_class'        => '',
                'teeny'               => false,
                '_content_editor_dfw' => false,
                'tinymce'             => true,
                'quicktags'           => true,
            )
        );

        self::$this_tinymce = ( $set['tinymce'] && user_can_richedit() );

        if ( self::$this_tinymce ) {
            if ( str_contains( $editor_id, '[' ) ) {
                self::$this_tinymce = false;
                _deprecated_argument( 'wp_editor()', '3.9.0', 'TinyMCE editor IDs cannot have brackets.' );
            }
        }

        self::$this_quicktags = (bool) $set['quicktags'];

        if ( self::$this_tinymce ) {
            
Home | Imprint | This part of the site doesn't use cookies.