Skip to content

Instantly share code, notes, and snippets.

@wpbean
Last active March 14, 2020 07:57
Show Gist options
  • Save wpbean/acd3aa48d0dcbfabaf237f6ef4b44ece to your computer and use it in GitHub Desktop.
Save wpbean/acd3aa48d0dcbfabaf237f6ef4b44ece to your computer and use it in GitHub Desktop.
Rising theme, add custom tab with dynamic content. Theme version required: 2.03 or UP.
<?php
/**
* Add custom meta to the course
*/
add_filter( 'rising_course_options', function( $options ){
$options[] = array(
'id' => 'custom_tab',
'type' => 'wysiwyg',
'title' => esc_html__( 'Course Custom Tab', 'wp-education' ),
'default' => '',
'settings' => array(
'textarea_rows' => 5,
'tinymce' => true,
'media_buttons' => false,
)
);
return $options;
});
/**
* Add Custom Tab
* Add this code to your theme or child theme functions.php file
*/
add_filter( 'learn-press/course-tabs', 'rising_course_tab_customize' );
function rising_course_tab_customize( $tabs ){
$custom_tab = ep_get_post_meta( '_course_side_options', 'custom_tab', '', true, get_the_id() );
if($custom_tab){
$tabs['custom_tab'] = array(
'title' => __( 'Custom Tab', 'wp-education' ),
'priority' => 50,
'callback' => 'rising_learn_press_custom_tab_content'
);
}
return $tabs;
}
// Custom Tab content
if( !function_exists('rising_learn_press_custom_tab_content') ){
function rising_learn_press_custom_tab_content(){
$custom_tab = ep_get_post_meta( '_course_side_options', 'custom_tab', '', true, get_the_id() );
if($custom_tab){
echo wpautop( $custom_tab );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment