Skip to content

Instantly share code, notes, and snippets.

@wpmudev-sls
Last active October 3, 2017 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpmudev-sls/f8f2f13e739f370c6d6237d09d32a27a to your computer and use it in GitHub Desktop.
Save wpmudev-sls/f8f2f13e739f370c6d6237d09d32a27a to your computer and use it in GitHub Desktop.
[Incsub Support] - Single ticket template override
<?php
/*
Plugin Name: [Incusb Support] - Upfront template
Plugin URI: https://premium.wpmudev.org/
Description: Overrides default theme for single ticket. Usefull in Upfront themes where there might be an incompatibility with single-ticket.php
Author: Panos Lyrakis @ WPMUDEV
Author URI: https://premium.wpmudev.org/
License: GPLv2 or later
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'WPMUDEV_INC_SUPPORT_TPL_DIR', plugin_dir_path( __FILE__ ) );
//define( 'WPMUDEV_INC_SUPPORT_TPL_URL', plugin_dir_url( __FILE__ ) );
if ( ! class_exists( 'WPMUDEV_INC_Support_UF_Templates' ) ) {
class WPMUDEV_INC_Support_UF_Templates {
private static $_instance = null;
public static function get_instance() {
if( is_null( self::$_instance ) ){
self::$_instance = new WPMUDEV_INC_Support_UF_Templates();
}
return self::$_instance;
}
private function __construct() {
add_filter( 'support_system_templates_locations', array( $this, 'override_templates' ), 0 );
}
public function override_templates( $templates ){
if( incsub_support_is_single_ticket() ){
$templates[0] = WPMUDEV_INC_SUPPORT_TPL_DIR;
}
return $templates;
}
}
add_action( 'plugins_loaded', function(){
$GLOBALS['WPMUDEV_INC_Support_UF_Templates'] = WPMUDEV_INC_Support_UF_Templates::get_instance();
}, 10 );
}
<div id="support-system-single-ticket">
<?php if ( incsub_support_has_tickets() ):
//incsub_support_the_ticket();
?>
<div class="support-system-ticket row <?php echo esc_attr( incsub_support_get_the_ticket_class() ); ?>" id="support-system-ticket-<?php echo incsub_support_get_the_ticket_id(); ?>">
<div class="large-12 columns">
<h1 class="text-center support-system-ticket-title"><?php echo incsub_support_get_the_ticket_title(); ?></h1>
<?php if ( incsub_support_is_ticket_closed( incsub_support_get_the_ticket_id() ) ): ?>
<div data-alert class="alert-box alert">
<?php _e( 'This ticket is closed', INCSUB_SUPPORT_LANG_DOMAIN ); ?>
</div>
<?php endif; ?>
<ul class="row">
<li class="small-3 large-2 columns">
<?php echo get_avatar( incsub_support_get_the_author_id(), 96 ); ?><br/>
</li>
<li class="small-9 large-10 columns">
<ul class="row inline-list support-system-ticket-meta">
<li class="first"><?php echo incsub_support_get_the_author(); ?></li>
<li><?php echo incsub_support_get_the_ticket_date(); ?></li>
</ul>
<div class="row support-system-ticket-message">
<?php echo incsub_support_get_the_ticket_message(); ?>
</div>
<?php $attachments = incsub_support_get_the_ticket_attachments(); ?>
<?php if ( ! empty( $attachments ) ): ?>
<div class="row support-system-ticket-attachments">
<h5><?php _e( 'Attachments', INCSUB_SUPPORT_LANG_DOMAIN ); ?></h5>
<ul>
<?php foreach ( $attachments as $attachment ): ?>
<li><a href="<?php echo esc_url( $attachment ); ?>" title="<?php printf( esc_attr__( 'Download %s attachment', INCSUB_SUPPORT_LANG_DOMAIN ), basename( $attachment ) ); ?>"><?php echo basename( $attachment ); ?></a></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
</li>
</ul>
</div>
</div>
<hr>
<div class="row">
<div class="support-system-ticket-replies large-8 columns">
<?php incsub_support_ticket_replies(); ?>
</div>
<div class="large-4 columns">
<div class="row">
<?php if ( ! incsub_support_is_staff() ): ?>
<?php
echo incsub_support_widget(
array( 'class' => 'panel support-system-ticket-details large-12 columns', 'title' => __( 'Ticket Details', INCSUB_SUPPORT_LANG_DOMAIN ) ),
'incsub_support_the_ticket_details_box'
);
?>
<?php else: ?>
<?php
echo incsub_support_widget(
array( 'class' => 'panel support-system-ticket-details support-system-staff-box large-12 columns', 'title' => __( 'Edit Ticket Details', INCSUB_SUPPORT_LANG_DOMAIN ) ),
'incsub_support_the_staff_box',
array( 'submit_class' => 'button expand' )
);
?>
<?php endif; ?>
<?php if ( incsub_support_current_user_can( 'close_ticket', incsub_support_get_the_ticket_id() ) ): ?>
<?php
echo incsub_support_widget(
array( 'class' => 'panel support-system-close-ticket large-12 columns' ),
'incsub_support_the_open_close_box',
array( 'submit_class' => 'button tiny' )
);
?>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment