标签: wp-editor

WP编辑器 - wp_editor()在ajax调用上没有正确显示

我正在创建一个WordPress插件.它具有在通过AJAX添加产品时显示编辑器的功能,但编辑器显示不正确.

用户可以根据需要添加任意数量的产品,因此请记住,将有多个wp_editor()

请参阅随附的屏幕截图:

在此输入图像描述

我使用了以下代码:

PHP

public function add_product() {

        // Get product id
        $prod_id = filter_input(INPUT_POST, 'pid');

        // WordPress WYSIWYG Editor
        wp_editor("Test Content", "textarea" . $prod_id, array('textarea_name' => 'text'));
        wp_die();
}
Run Code Online (Sandbox Code Playgroud)

JQUERY

$('.add-prod').live('click', function () {

        var prod_id = $('.prod-id').val();
        var data = {
            action: 'add_prod',
            pid: prod_id
        };
        $('#update-msg').show();

        $.post(ajaxurl, data, function (result) {
            $('#the-list').append(result);
            $('#update-msg').hide();
        });

        return false;
});
Run Code Online (Sandbox Code Playgroud)

我使用过互联网的解决方案但其部分工作并不完全.使用以下代码:

PHP

wp_editor($product->prod_desc, $textarea_id, array('textarea_name' => 'text'));
\_WP_Editors::enqueue_scripts();
print_footer_scripts();
\_WP_Editors::editor_js();
Run Code Online (Sandbox Code Playgroud)

JQUERY

var eid = '#item-list';
switchEditors.go(eid, 'tmce')
quicktags({id: eid}); …
Run Code Online (Sandbox Code Playgroud)

php ajax wordpress jquery wp-editor

12
推荐指数
1
解决办法
1348
查看次数

如何使用Jquery加载wp_editor?

我想在我的自定义插件中使用jquery动态添加WordPress编辑器,如下所示:

 <?php

  $content = '';

  $editor_id = 'mycustomeditor';      

?>

 $('#container').append('<?php wp_editor( $content, $editor_id );?>');
Run Code Online (Sandbox Code Playgroud)

我收到错误:

参数列表后面的SyntaxError:missing)

...-active"><link rel='stylesheet' id='editor-buttons-css'  href='http://localhost 
Run Code Online (Sandbox Code Playgroud)

我也尝试过波纹管代码(这里我用单引号代替双引号):

  <?php

     $content = '';

     $editor_id = 'mycustomeditor';      

  ?>

  $('#container').append("<?php wp_editor( $content, $editor_id );?>");
Run Code Online (Sandbox Code Playgroud)

我收到错误:

 SyntaxError: missing ) after argument list   


$('#container').append("<div id="wp-mycustomeditor-wrap" class="wp-core-ui wp-ed...
Run Code Online (Sandbox Code Playgroud)

如果您有任何解决方案,请告诉我.

提前致谢

jquery wordpress-plugin wp-editor

9
推荐指数
1
解决办法
1475
查看次数

如何将自定义属性添加到Wordpress wp_editor文本区域?

如何向Wordpress wp_editor textarea字段添加自定义属性?

在官方文档中,没有办法做到这一点.我需要将客户端验证属性(data-bvalidator ="required")添加到由WordPress 的wp_editor方法生成的文本区域.

有什么建议 ?

wordpress wp-editor

7
推荐指数
1
解决办法
682
查看次数

Wordpress wp.media特色图片ID

如何在单击"设置特色图像"按钮时挂钩到现有的wp.media对象并获​​取附件ID?

我一直在看的wp.media教程似乎都是从创建一个新的wp.media框架开始的,但我只是想监听来自现有的事件(由wp_editor()函数呈现),特别是"Set"特色图片"活动.

javascript wordpress wp-editor

6
推荐指数
1
解决办法
906
查看次数

WordPress wp_editor删除html标签 - 如何阻止它?

为什么wp_editor会删除我的所有html标签?

这是我的代码:

/**
 * Outputs the content of the meta box.
 */
function prfx_meta_callback( $post ) {
    // echo 'This is a meta box';
    wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );
    $prfx_stored_meta = get_post_meta( $post->ID );

    $field_value = get_post_meta( $post->ID, 'meta-textarea', false );

    // Settings that we'll pass to wp_editor
    $args = array (
        'textarea_rows' => 4,
        'teeny'         => true,
        // 'media_buttons' => false,
    );
    ?>

    <p>
        <label for="meta-text" class="prfx-row-title"><?php _e( 'Example Text Input', 'prfx-textdomain' )?></label>
        <input type="text" name="meta-text" id="meta-text" value="<?php …
Run Code Online (Sandbox Code Playgroud)

html wordpress tinymce wp-editor

4
推荐指数
1
解决办法
2373
查看次数

WordPress 使用设置 API 保存 wp_editor 内容

我正在创建一个带有管理设置页面的插件,并且我想使用设置 API。

我可以保存文本字段和复选框,但是当我添加带有 a 的设置字段时,wp_editor它不会保存..?

我曾经使用 来执行此操作get_option,但现在我想使用设置类和register_setting()方法。

这是我的代码:

public function register_settings() {
    register_setting( 'eman_setting', 'eman_setting', array( $this, 'eman_validate_settings' ) );

    add_settings_field(
        'eman_dashboard_welcome',                      
        __( "", 'emanlang' ),                           
        array( $this, 'eman_dashboard_welcome_callback' ),   
        'management-settings',                          
        'eman_settings_section'         
    );  

}

public function eman_dashboard_welcome_callback() {
    //$content = 'Empty';
    $editor_id = 'textareadashboardwelcome';    
    $args = array('textarea_name' => 'eman_dashboard_welcome');

    if(! empty( $this->eman_setting['eman_dashboard_welcome'] ) ) {
        $content = $this->eman_setting['eman_dashboard_welcome'];
    } else {
        $content = 'The field is empty';
    }

    wp_editor( $content, $editor_id, $args );

    /** …
Run Code Online (Sandbox Code Playgroud)

wordpress wp-editor

3
推荐指数
1
解决办法
2855
查看次数

如何禁用某些帖子类型的古腾堡/块编辑器?

WordPress 在其第5版中添加了Gutenberg /块编辑器,默认情况下已启用Post和Page post类型。

默认情况下,可能会在不久的将来为所有自定义帖子类型启用此功能,因此作为WordPress开发人员,我想知道如何针对我自己的自定义帖子类型禁用此编辑器?我想保留我从插件或主题中注册的帖子类型的经典编辑器。

php wordpress wp-editor wordpress-gutenberg

2
推荐指数
1
解决办法
2849
查看次数

如何获取wp_editor()的textarea的值

所以我试图有一个自定义文本区域,用户可以在其中执行粗体文本、添加 ul、链接标签等操作。对于所有这些,我在 WordPress 中使用wp_editor()函数,如下所示。

 $content = "";
 $editor_id = "e_id";
 $editor_settings = array(
                         'teeny' => true,
                         'editor_height' => 160,
                         'quicktags' => array( 'buttons' => 'strong,em,del,close' ),
                         'media_buttons' => false );

 wp_editor( $content, $editor_id ,$editor_settings ); 
Run Code Online (Sandbox Code Playgroud)

因此,诸如添加链接、粗体文本等一切都可以正常工作。

我的问题是访问刚刚输入该字段的文本。我尝试使用 JQuery 访问文本,通过提醒 textarea/contenteditable 区域的值,如下所示...

  alert($("#e_id").val());
Run Code Online (Sandbox Code Playgroud)

但每次结果始终是一个空字符串,而不是新输入的文本。

如何获取新输入的文本

php wordpress tinymce wp-editor

2
推荐指数
1
解决办法
3639
查看次数