Skip to:
Content
Pages
Categories
Search
Top
Bottom

Feature requests

  • To make it possible for other plugins to add buttons to the editors toolbar, please make it possible to run the wp_editor() for posts/replies with the switches ‘tinymce’ => true and ‘teeny’ => false.

    Also, make it please possible to get the posts/replies passing the ‘the_content’ or at least the ‘do_shortcode’ filter. This would enable other plugins to enter their shortcodes into the posts/replies and get them rendered in the final display of the posts/replies.

    For more information why i ask this, please read this ducumentation page of the plugin wp-photo-album-plus.

Viewing 10 replies - 1 through 10 (of 10 total)

  • Robin W
    Moderator

    @robin-w

    thanks for the post

    bbpress includes a version of the wordpress ‘after..parse_args’ which will let you do this so for

    •File …/wp-content/plugins/bbpress/includes/common/template.php line 1735:
    change ‘tinymce’ => false, into ‘tinymce’ => true,
    •File …/wp-content/plugins/bbpress/includes/common/template.php line 1736:
    change ‘teeny’ => true, into ‘teeny’ => false,

    you could put this code into a functions file or plugin

    //editor bbpress
    function rew_enable_visual_editor( $args = array() ) {
        $args['tinymce'] = true;
        $args['teeny'] = false;
        return $args;
    }
    add_filter( 'bbp_after_get_the_content_parse_args', 'rew_enable_visual_editor' );

    and the ability to filter functions so for

    •File …/wp-content/plugins/bbpress/includes/common/template.php line 1858:
    Remove array_push( $buttons, ‘image’ ); to remove the ‘standard’ image insert button that asks for a full url to an image, since we are replacing this by the [photo] shortcode generator.

    use this code in your functions file or plugin

    function rew_remove_image_button ($buttons) {
    	if (($key = array_search('image', $buttons)) !== false) {
    		unset($buttons[$key]);
    	}
    return $buttons ;
    }
    
    add_filter( 'bbp_get_teeny_mce_buttons', 'rew_remove_image_button' );

    The you don’t need to alter bbpress files

    Let me know if I can help further

    Thank you, this works great!

    One thing left: i can not find the filter to filter forum posts/replies, so i could do:

    function my_process_shortcodes($content) {
      return do_shortcodes($content);
    }
    add_filter( '...??...', 'my_process_shortcodes' );
    

    Robin W
    Moderator

    @robin-w

    where do you want that to put something – I presume in the content of a topic/reply? and what doe that shortcode do ?

    Yes, in the content of the topic/reply. It makes from [photo 123] the html to display photo with id=123 from plugin wp-photo-album-plus – instead of a photo from the wp media library – according to the settings in the settings page of that plugin; e.g link to lightbox, subtitle and possible social media buttons to share the image.

    The button that opens the dialog to select the photo, and optionally upload a new one, is now working without mods to bbpress, but it shows ‘[photo 123]’ instead of the picture. If the content would be filtered by the standard wp content filters, it would display the image, like it does in a wp native page or post.

    We see:
    Post with shortcode
    We want to see:
    Post with rendered shortcode

    I think i ggot it:
    Filters ‘bbp_get_topic_content’ and ‘bbp_get_reply_content’. They MUST run after wpautop, so i gave them priority 1000.

    All of my code to get my plugin compatible with bbpress looks now:

    /* We use bbPress */
    // editor bbpress in tinymce mode
    function wppa_enable_visual_editor_in_bbpress( $args = array() ) {
    	
    	if ( wppa_switch( 'photo_on_bbpress' ) ) {
    		$args['tinymce'] = true;
    		$args['teeny'] = false;
    	}
        return $args;
    }
    add_filter( 'bbp_after_get_the_content_parse_args', 'wppa_enable_visual_editor_in_bbpress' );
    
    // remove insert wp image button
    function wppa_remove_image_button_in_bbpress( $buttons ) {
    	
    	if ( wppa_switch( 'photo_on_bbpress' ) ) {
    		if ( ( $key = array_search( 'image', $buttons ) ) !== false ) {
    			unset( $buttons[$key] );
    		}
    	}
    	return $buttons ;
    }
    add_filter( 'bbp_get_teeny_mce_buttons', 'rew_remove_image_button_in_bbpress' );
    
    // enable processing shortcodes
    function wppa_enable_shortcodes_in_bbpress( $content ) {
    
    	if ( wppa_switch( 'photo_on_bbpress' ) ) {
    		$content = do_shortcode( $content );
    	}
    	return $content;
    }
    add_filter( 'bbp_get_topic_content', 'wppa_enable_shortcodes_in_bbpress', 1000 );
    add_filter( 'bbp_get_reply_content', 'wppa_enable_shortcodes_in_bbpress', 1000 );
    

    Pleas be so kind to review this to see if i did it right or did oversee something.


    Robin W
    Moderator

    @robin-w

    From a read through looks ok to me, but just change

    add_filter( ‘bbp_get_teeny_mce_buttons’, ‘rew_remove_image_button_in_bbpress’) ;

    to

    add_filter( ‘bbp_get_teeny_mce_buttons’, ‘wppa_remove_image_button_in_bbpress’) ;

    to run your amended function


    Robin W
    Moderator

    @robin-w

    from a read through all looks ok except

    add_filter( 'bbp_get_teeny_mce_buttons', 'rew_remove_image_button_in_bbpress' );

    should read

    add_filter( 'bbp_get_teeny_mce_buttons', 'wppa_remove_image_button_in_bbpress' );

    Thank you for all your help.
    You may close this topic.


    Robin W
    Moderator

    @robin-w

    no problem, glad I could help 🙂

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Skip to toolbar