WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Rich-text description box doesn't work on event form (7 posts)

  1. magicroundabout
    Member
    Posted 1 year ago #

    Hi folks,

    Using WP v3.4.1, EM v5.2.1 (now - but read on)

    I'm using the event submission form with "Allow anonymous event submissions" option set to yes and "Use visual editor" set to yes as well.

    I was on WP v.3.3.2 and EM v 5.1.6 until today. I noticed that the event submission form didn't have a description field.

    I was doing some maintenance anyway and upgraded WP to the latest 3.4.1 release. After this the description field DID appear.

    I then upgraded EM to v5.2.1 and the description field disappeared again.

    Is there some problem with the call to wp_editor in event-editor.php?

    Thanks

    http://wordpress.org/extend/plugins/events-manager/

  2. magicroundabout
    Member
    Posted 1 year ago #

    Oh, I should add that setting "Use visual editor" to "No" makes the description field appear again, so this only applies when using the visual editor.

    I've checked the generated HTML source and there is some editor markup there, but some of the elements have style="display: none" on them.

    There are no JavaScript errors.

    Thanks

  3. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    are you sure it's not another plugin or your theme?

    http://demo.wp-events-plugin.com/submit-your-event/

    using the latest WP and EM versions, works fine for me

  4. leoloso
    Member
    Posted 1 year ago #

    It is happening also for me. I'm enabling the Event submission in the frontend and the Wp Editor shows no styles.
    After debugging, I found out that the problem happens when applying wp_editor as a hook. Somehow, wp_editor works alright when you print it inside the content (that's why it works alright with [event_form] shortcode, but when you use add_filter('the_content', 'em_content'); to replace CONTENTS and wp_editor is printed inside em_content, somehow, it loses context. For instance, in file class-wp-editor.php it reads:
    if ( self::$editor_buttons_css ) {
    wp_print_styles('editor-buttons');
    self::$editor_buttons_css = false;
    }
    Somehow, when executed as a hook, that condition self::$editor_buttons_css is always false...

    So then, it seems to be a bug from WP...

    I guess a possible dirty fix is to print wp_editor in the content and keep it in a variable, then in the template you leave a wildcard code that you can find and replace again with this variable... horrible, but I guess it should work...

  5. leoloso
    Member
    Posted 1 year ago #

    I implemented my dirty fix and now it works alright:

    1. Copied event-editor.php to my theme and edited: replaced wp_editor call with a code to be replaced
    <?php /* Hack: add a wildcard for wp_editor */ ?>
    <?php echo "__GD_EM_WP_EDITOR_CONTENT__" ?>
    <?php /* wp_editor($EM_Event->post_content, 'em-editor-content', array('textarea_name'=>'content') ); */ ?>

    2. Added to functions.php:
    /* ------------------------------------------------------------------------------------
    * There is a bug in forms/event-editor.php: the wp_editor prints without styles throught hook the_content
    * So instead we generate the content of wp_editor in the content and then replace the wildcard "__GD_EM_WP_EDITOR_CONTENT__" with this content
    * ------------------------------------------------------------------------------------ */

    add_action('wp_head', function() {

    // First, validate we're visiting the Frontend Edit Event Page (these validations copied from em-events.php)
    global $post;
    if( empty($post) ) return;
    $edit_events_page_id = get_option( 'dbem_edit_events_page' );
    if( !($post->ID == $edit_events_page_id) ) return;

    $content = apply_filters('em_content_pre', '', $page_content);
    if( !empty($content) ) return;
    if( !($post->ID == $edit_events_page_id && $edit_events_page_id != 0 )) return;

    // Then, validation as in event-editor.php
    global $EM_Event;

    if( is_object($EM_Event) && !$EM_Event->can_manage('edit_events','edit_others_events') ){
    return;
    }elseif( !is_object($EM_Event) ){
    $EM_Event = new EM_Event();
    }

    if( !empty($_REQUEST['success']) ){
    if(!get_option('dbem_events_form_reshow')) return;
    }
    if( !(get_option('dbem_events_form_editor') && function_exists('wp_editor') )) return;

    // This is the right page, it must show wp_editor. Do it now, and store it in global variable $gd_em_wp_editor_content
    global $gd_em_wp_editor_content;

    ob_start();
    wp_editor($EM_Event->post_content, 'em-editor-content', array('textarea_name'=>'content') );
    $gd_em_wp_editor_content = ob_get_clean();

    });

    // Priority 11: it executes after function em_content
    add_filter('the_content', 'gd_em_wp_editor_content', 11);
    function gd_em_wp_editor_content($content) {

    global $gd_em_wp_editor_content;
    if ($gd_em_wp_editor_content) {

    $content = str_replace("__GD_EM_WP_EDITOR_CONTENT__", $gd_em_wp_editor_content, $content);
    }

    return $content;
    }

    Hope this helps.

  6. leoloso
    Member
    Posted 1 year ago #

    One update:

    Instead of:
    if( empty($_REQUEST['action']) || $_REQUEST['action'] !== 'edit' ) return;

    it must be:
    if( empty($_GET['action']) || $_GET['action'] !== 'edit' ) return;

  7. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    I still can't reproduce this, whether using shortcodes, the_content etc.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic