wpForo Forum Plugin...
 
Notifications
Clear all

wpForo Forum Plugin Snippets

5 Posts
1 Users
0 Reactions
215 Views
Maximus
(@maximus)
Posts: 57
Reputable Member
Topic starter
 

The easiest and best way to add snippets is using the Code Snippets WordPress plugin.

 
Posted : January 22, 2024 12:29
Maximus
(@maximus)
Posts: 57
Reputable Member
Topic starter
 

The default post editor window height, is somehow small. You can increase it, using this CSS :

 

.mce-edit-area.mce-container.mce-panel.mce-stack-layout-item{
   min-height: 150px !important;
}
 
Posted : January 22, 2024 12:31
Maximus
(@maximus)
Posts: 57
Reputable Member
Topic starter
 

This snippet will automatically embed the actual image attachment into your post body.

 

add_filter('wpforo_content_after', function( $content ){
    return preg_replace_callback(
        '#<a[^><]*\sclass=[\'\"](?:[^\'\"]*\s)?wpforo-default-attachment(?:\s[^\'\"]*)?[\'\"][^><]*\shref=[\'\"]([^\"\']+)[\'\"][^><]*>.*?</a>#isu',
        function( $match ){
                $html     = $match[0];
            $file     = $match[1];
            $pathinfo = pathinfo( $file );
            if( wpforo_is_image($pathinfo['extension']) ) {
                $html = sprintf(
                    '<a href="%1$s" target="_blank"><img class="wpforo-default-image-attachment" src="%1$s" alt="%2$s" title="%2$s"></a>',
                    esc_url($file),
                    esc_attr($pathinfo['basename'])
                );
            }
            return $html;
        },
        $content
    );
}, 11);
 
Posted : January 22, 2024 12:31
Maximus
(@maximus)
Posts: 57
Reputable Member
Topic starter
 

Instead of a Youtube link, using this snippet for wpForo will embed the video into the body of the post.

 

add_filter('wpforo_content_after', 'wpforo_custom_video_embed', 10);
function wpforo_custom_video_embed($content)
{
    $paterns = array();
    $paterns[] = "/<a[^><]+>\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i";
    $paterns[] = "/<a[^><]+>\s*[a-zA-Z\/\/:\.]*youtu.be\/([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i";
    $content = preg_replace($paterns, "<iframe width=\"420\" height=\"280\" src=\"//www.youtube.com/embed/$1\" frameborder=\"0\" allowfullscreen></iframe>", $content);
    return $content;
}
 
Posted : January 22, 2024 12:32
Maximus
(@maximus)
Posts: 57
Reputable Member
Topic starter
 

Disable font change toolbar from the editor (TinyMCE).

function wpforo_custom_editor_toolbar( $settings ){
   if( isset($settings['tinymce']['toolbar1']) ){
        $settings['tinymce']['toolbar1'] = 'bold,italic,underline,strikethrough,forecolor,bullist,numlist,hr,alignleft,aligncenter,alignright,alignjustify,link,unlink,blockquote,pre,wpf_spoil,undo,redo,pastetext,source_code,emoticons,fullscreen';
   }
   return $settings;
}
add_filter('wpforo_editor_settings', 'wpforo_custom_editor_toolbar', 12);

 

This post was modified 9 months ago by Maximus
 
Posted : January 22, 2024 12:36