Extending Discussion Board

Hooking into the template files

Each template – single-discussion-topics.php and archive-discussion-topics.php – has hooks at the start and end of the file. These hooks can be used to replace the opening and closing HTML tags.

The templates are based on the Twenty Fifteen template files so, using the example of the single-discussion-topics.php file, the tags look like:

<div id="primary" class="content-area">
 <main id="main" class="site-main" role="main">

...

 </main>
</div>

These are inserted into the file through hooks. So to insert your own HTML, you just need to override the plugin, e.g.:

remove_action ( 'ctdb_open_wrapper_single', 'ctdb_open_wrapper_single' );
remove_action ( 'ctdb_close_wrapper_single', 'ctdb_close_wrapper_single' );

add_action ( 'ctdb_open_wrapper_single', 'new_open_wrapper_single' );
add_action ( 'ctdb_close_wrapper_single', 'new_close_wrapper_single' );

// Example only
function new_open_wrapper_single() { ?>
 <div id="primary-id" class="my-content-area">
<?php }

// Example only
function new_close_wrapper_single() { ?>
  </div>
<?php }

You’ll need to replace the markup with suitable markup for your theme.

You can repeat this for the archive-discussion-topics.php template:

remove_action ( 'ctdb_open_wrapper_archive', 'ctdb_open_wrapper_archive' );
remove_action ( 'ctdb_close_wrapper_archive', 'ctdb_close_wrapper_archive' );

add_action ( 'ctdb_open_wrapper_archive', 'new_open_wrapper_archive' );
add_action ( 'ctdb_close_wrapper_archive', 'new_close_wrapper_archive' );

// Example only
function new_open_wrapper_archive() { ?>
 <div id="primary-id" class="my-content-area">
<?php }

// Example only
function new_close_wrapper_archive() { ?>
 </div>
<?php }

Double-check your theme files for the correct markup to use.

Change permitted file types

In the Pro version, it’s possible to allow users to upload an image as the featured image for the topic. By default, only png and jpg file types are permitted. However, you can change this with a filter, e.g.:

function me_change_mime_types( $existing_mimes ) {
  // Add gif as permitted mime type
  $existing_mimes['gif'] = 'image/gif';
  return $existing_mimes;
}
add_filter( 'ctdb_existing_mimes', 'me_change_mime_types' );

Use with care to avoid users uploading potentially malicious files.

Filter wp_editor args

In the Pro version, you can enable wp_editor on the new topic submission form, allowing users to add formatting. To change the parameters, you can add a filter, e.g.:

function me_filter_editor_args( $args ) {
  $args['teeny'] => true;
  return $args;
}
add_action( 'ctdb_editor_args', 'me_filter_editor_args' );