if(!function_exists(‘get_course_data’)) {
/**
* Get course data from database.
*
* @access public
* @param
* @return array
* @since 1.0.0
*/
function get_course_data( $paged, $courses_per_page ){
global $wpdb;
$table_name = $wpdb->prefix . 'course_detail';
$offset = ( $paged - 1 ) * $courses_per_page;
$query = $wpdb->prepare( "SELECT * FROM $table_name LIMIT %d, %d", $offset, $courses_per_page );
$results = $wpdb->get_results($query);
return $results;
}
}
if(!function_exists(‘get_course_count’)) {
/**
* Get course count.
*
* @access public
* @param
* @return string
* @since 1.0.0
*/
function get_course_count(){
global $wpdb;
$table_name = $wpdb->prefix . 'course_detail';
$count_query = "SELECT COUNT(*) FROM $table_name";
return $wpdb->get_var($count_query);
}
}
if(!function_exists(‘get_course_page_slug’)) {
/**
* Get course page slug.
*
* @access public
* @param
* @return string
* @since 1.0.0
*/
function get_course_page_slug(){
$page_id = get_option('add_course_page_id');
if( $page_id ){
$page_slug = get_post_field( 'post_name', $page_id );
return $page_slug;
}
}
}
if(!function_exists(‘get_course_by_ID’)) {
/**
* Get course by id.
*
* @access public
* @param int
* @return array
* @since 1.0.0
*/
function get_course_by_ID($course_id){
global $wpdb;
$course = $wpdb->get_row( $wpdb->prepare("SELECT * FROM {$wpdb->prefix}course_detail WHERE id = %d", $course_id) );
return $course;
}
}