Skip to content

Instantly share code, notes, and snippets.

@woogist
Last active March 2, 2018 20:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save woogist/2276a45d0424bef27c90 to your computer and use it in GitHub Desktop.
Save woogist/2276a45d0424bef27c90 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
}
@bigfootybets
Copy link

It outputs 2 headers (h1's) on single course page.

@unaibamir
Copy link

@bigfootybets the reason is sensei has updated its hooks. Hooks mentioned above are deprecated now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment