Skip to content

Instantly share code, notes, and snippets.

@lvnilesh
Forked from woogist/x-theme-functions.php
Created September 15, 2016 03:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lvnilesh/63406df19e596dd39a27492f21996235 to your computer and use it in GitHub Desktop.
Save lvnilesh/63406df19e596dd39a27492f21996235 to your computer and use it in GitHub Desktop.
The code below allow for Themeco - X Theme to be integrated with Sensei.
/**
* Declare that your theme now supports Sensei
*/
add_action( 'after_setup_theme', 'sensei_support' );
function sensei_support() {
add_theme_support( 'sensei' );
}
/**
* Remove the default Sensei wrappers
*/
global $woothemes_sensei;
remove_action( 'sensei_before_main_content', array( $woothemes_sensei->frontend, 'sensei_output_content_wrapper' ), 10 );
remove_action( 'sensei_after_main_content', array( $woothemes_sensei->frontend, 'sensei_output_content_wrapper_end' ), 10 );
/**
* Add X Theme by Themeco specific custom Sensei content wrappers
*/
add_action('sensei_before_main_content', 'x_theme_sensei_wrapper_start', 10);
add_action('sensei_after_main_content', 'x_theme_sensei_wrapper_end', 10);
function x_theme_sensei_wrapper_start() {
if ( is_singular( 'course' ) ){
remove_action( 'woocommerce_before_single_product', 'x_woocommerce_before_single_product', 10 );
remove_action( 'woocommerce_after_single_product', 'x_woocommerce_after_single_product', 10 );
}
echo '<div class="x-container max width offset">'.
'<div class="x-main left" role="main">'
.'<div class="entry-wrap"> ';
}
function x_theme_sensei_wrapper_end() {
echo ' </div> <!-- .entry-wrap -->'
. '</div> <!-- end sensei .x-main left-->';
get_sidebar();
echo'</div> <!-- end sensei x-container-fluid -->';
}
/**
* remove default sensei titles
*/
remove_action( 'sensei_course_single_title', array( $woothemes_sensei->frontend , 'sensei_single_title' ), 10 );
remove_action( 'sensei_lesson_single_title', array( $woothemes_sensei->frontend , 'sensei_single_title' ), 10 );
remove_action( 'sensei_quiz_single_title', array( $woothemes_sensei->frontend, 'sensei_single_title' ), 10 );
remove_action( 'sensei_message_single_title', array( $woothemes_sensei->frontend, 'sensei_single_title' ), 10 );
/**
* Add custom theme title:
*/
add_action( 'sensei_course_single_title', 'x_theme_sensei_single_title', 10 );
add_action( 'sensei_lesson_single_title', 'x_theme_sensei_single_title', 10 );
add_action( 'sensei_quiz_single_title', 'x_theme_sensei_single_title', 10 );
add_action( 'sensei_message_single_title', 'x_theme_sensei_single_title' , 10 );
function x_theme_sensei_single_title() {
global $post;
if( is_singular( 'sensei_message' ) ) {
$content_post_id = get_post_meta( $post->ID, '_post', true );
if( $content_post_id ) {
$title = sprintf( __( 'Re: %1$s', 'woothemes-sensei' ), '<a href="' . get_permalink( $content_post_id ) . '">' . get_the_title( $content_post_id ) . '</a>' );
} else {
$title = get_the_title( $post->ID );
}
} else {
$title = get_the_title();
}
?>
<header class="entry-header">
<h1 class="entry-title">
<?php echo $title;?>
</h1>
</header>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment