Dashboard
Source
File: classes/Dashboard.php
class Dashboard { public function __construct() { /** * Load Select 2 */ add_filter( 'dozent_load_select2', [ $this, 'load_select2' ] ); add_action( 'wp_ajax_dozent_dashboard_sidebar_toggle', [ $this, 'dozent_dashboard_sidebar_toggle' ] ); add_filter( 'document_title_parts', [ $this, 'change_document_title' ] ); //Filter dashboard menu items add_filter( 'dozent/dashboard/permalinks', [ $this, 'dashboard_permalinks' ] ); } public function load_select2( $bool ){ $page = dozent_get_dashboard_url_segment(); if ( $page === 'my-courses/create-course' ){ return true; } return $bool; } /** * Dashboard Sidebar On Off Toggle * * @since DozentLMS 1.0.0 */ public function dozent_dashboard_sidebar_toggle() { $status = dozent_input_text( 'status' ); dozent_user_data()->update( 'dashboard_sidebar_status', $status ); } /** * Set document title for dashboard page * * @since DozentLMS 1.0.0 * * * @param $title * * @return mixed */ function change_document_title( $title ) { if ( is_dozent_dashboard() ) { $dashboard_links = dozent_dashboard_permalinks(); $links_key_value = array_column( call_user_func_array( 'array_merge', $dashboard_links ), 'title', 'id' ); $segment = dozent_get_dashboard_url_segment(); if ( strpos( $segment, '/' ) !== false ) { $segment = explode( '/', $segment ); $segment = dozent_array_get( 0, $segment ); } $link_title = dozent_array_get( $segment, $links_key_value ); if ( $link_title && isset( $title['title'] ) ) { $title['title'] = $link_title; } } return $title; } public function dashboard_permalinks( $permalinks ) { if ( dozent_count( $permalinks ) ) { foreach ( $permalinks as $group_key => $menu_group ) { $enable_dozent_earning = (bool) dozent_get_option( 'enable_dozent_earning' ); if ( ! $enable_dozent_earning ) { if ( ! empty( $permalinks[ $group_key ]['earning'] ) ) { unset( $permalinks[ $group_key ]['earning'] ); } if ( ! empty( $permalinks[ $group_key ]['withdraw'] ) ) { unset( $permalinks[ $group_key ]['withdraw'] ); } } } } return $permalinks; } }
Methods
- __construct
- change_document_title — Set document title for dashboard page
- dashboard_permalinks
- dozent_dashboard_sidebar_toggle — Dashboard Sidebar On Off Toggle
- load_select2