block_name ); $get_gaps_css = $this->get_wrapper_gap_css( $attributes ); $css_generator->add_class_styles( '{{WRAPPER}}.ablocks-block--frontend-dashboard', $get_gaps_css, $this->get_wrapper_gap_css( $attributes, 'Tablet' ), $this->get_wrapper_gap_css( $attributes, 'Mobile' ) ); $get_setting_css = $this->get_setting_css( $attributes ); $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-frontend-dashboard-sidebar', $get_setting_css, $this->get_setting_css( $attributes, 'Tablet' ), $this->get_setting_css( $attributes, 'Mobile' ) ); $get_user_setting_css = $this->get_user_setting_css( $attributes ); $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-frontend-dashboard-user', $get_user_setting_css, $this->get_user_setting_css( $attributes, 'Tablet' ), $this->get_user_setting_css( $attributes, 'Mobile' ) ); $get_menu_list_css = $this->get_menu_list_css( $attributes ); $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-frontend-dashboard-menu__item a', $get_menu_list_css, $this->get_menu_list_css( $attributes, 'Tablet' ), $this->get_menu_list_css( $attributes, 'Mobile' ) ); $get_menu_hover_list_css = $this->get_menu_hover_list_css( $attributes ); $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-frontend-dashboard-menu__item a:hover', $get_menu_hover_list_css, $this->get_menu_hover_list_css( $attributes, 'Tablet' ), $this->get_menu_hover_list_css( $attributes, 'Mobile' ) ); $get_menu_active_list_css = $this->get_menu_active_list_css( $attributes ); $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-frontend-dashboard-menu__item--current > a', $get_menu_active_list_css, $this->get_menu_active_list_css( $attributes, 'Tablet' ), $this->get_menu_active_list_css( $attributes, 'Mobile' ) ); $get_breadcrumb_css = $this->get_breadcrumb_css( $attributes ); $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-frontend-dashboard-breadcrumb li', $get_breadcrumb_css, $this->get_breadcrumb_css( $attributes, 'Tablet' ), $this->get_breadcrumb_css( $attributes, 'Mobile' ) ); $get_breadcrumb_css = $this->get_breadcrumb_css( $attributes ); $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-frontend-dashboard-breadcrumb li + li::before', $get_breadcrumb_css, $this->get_breadcrumb_css( $attributes, 'Tablet' ), $this->get_breadcrumb_css( $attributes, 'Mobile' ) ); $get_content_css = $this->get_content_css( $attributes ); $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-frontend-dashboard-content', $get_content_css, $this->get_content_css( $attributes, 'Tablet' ), $this->get_content_css( $attributes, 'Mobile' ) ); $get_content_hover_css = $this->get_content_hover_css( $attributes ); $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-frontend-dashboard-content:hover', $get_content_hover_css, $this->get_content_hover_css( $attributes, 'Tablet' ), $this->get_content_hover_css( $attributes, 'Mobile' ) ); return $css_generator->generate_css(); } public function get_setting_css( $attributes, $device = '' ) { $css = []; if ( ! empty( $attributes['sidebarBackground'] ) ) { $css['background'] = Color::get_css( isset( $attributes['sidebarBackground'] ) ? $attributes['sidebarBackground'] : ''); } return array_merge( $css, Border::get_css( $attributes['sidebarBorder'] ?? [], '', $device ) ); } public function get_user_setting_css( $attributes, $device = '' ) { $css = []; if ( ! empty( $attributes['userTextColor'] ) ) { $css['color'] = Color::get_css( isset( $attributes['userTextColor'] ) ? $attributes['userTextColor'] : ''); } if ( ! empty( $attributes['sidebarUserBackground'] ) ) { $css['background'] = Color::get_css( isset( $attributes['sidebarUserBackground'] ) ? $attributes['sidebarUserBackground'] : ''); } $userTypographyGlobal = ! empty( $attributes['userTypographyGlobal'] ) ? $attributes['userTypographyGlobal'] : ''; return array_merge( $css, Border::get_css( $attributes['userSidebarBorder'] ?? [], '', $device ), Typography::get_css( $attributes['userTypography'], '', $device, $userTypographyGlobal ), ); } public function get_menu_list_css( $attributes, $device = '' ) { $css = []; if ( ! empty( $attributes['menuListTextColor'] ) ) { $css['color'] = Color::get_css( isset( $attributes['menuListTextColor'] ) ? $attributes['menuListTextColor'] : ''); } if ( ! empty( $attributes['menuListBackground'] ) ) { $css['background'] = Color::get_css( isset( $attributes['menuListBackground'] ) ? $attributes['menuListBackground'] : ''); } $userTypographyGlobal = ! empty( $attributes['userTypographyGlobal'] ) ? $attributes['userTypographyGlobal'] : ''; return array_merge( $css, Border::get_css( $attributes['menuListBorder'] ?? [], '', $device ), Dimensions::get_css( $attributes['menuListPadding'] ?? [], 'padding', $device ), Typography::get_css( $attributes['menuListTypography'] ?? [], '', $device, $userTypographyGlobal ) ); } public function get_menu_hover_list_css( $attributes, $device = '' ) { $css = []; if ( ! empty( $attributes['menuListHoverTextColor'] ) ) { $css['color'] = Color::get_css( isset( $attributes['menuListHoverTextColor'] ) ? $attributes['menuListHoverTextColor'] : ''); } if ( ! empty( $attributes['menuListHoverBackground'] ) ) { $css['background'] = Color::get_css( isset( $attributes['menuListHoverBackground'] ) ? $attributes['menuListHoverBackground'] : ''); } return array_merge( $css, Border::get_hover_css( $attributes['menuListBorder'] ?? [], '', $device ) ); } public function get_menu_active_list_css( $attributes, $device = '' ) { $css = []; if ( ! empty( $attributes['menuListActiveTextColor'] ) ) { $css['color'] = Color::get_css( isset( $attributes['menuListActiveTextColor'] ) ? $attributes['menuListActiveTextColor'] : ''); } if ( ! empty( $attributes['menuListActiveBackground'] ) ) { $css['background'] = Color::get_css( isset( $attributes['menuListActiveBackground'] ) ? $attributes['menuListActiveBackground'] : ''); } return $css; } public function get_content_css( $attributes, $device = '' ) { $css = []; if ( ! empty( $attributes['contentBackground'] ) ) { $css['background'] = Color::get_css( isset( $attributes['contentBackground'] ) ? $attributes['contentBackground'] : ''); } return array_merge( $css, Border::get_css( $attributes['contentBorder'] ?? [], '', $device ), Dimensions::get_css( $attributes['contentPadding'] ?? [], 'padding', $device ), ); } public function get_content_hover_css( $attributes, $device = '' ) { return array_merge( Border::get_hover_css( $attributes['contentBorder'] ?? [], '', $device ), ); } public function get_breadcrumb_css( $attributes, $device = '' ) { $css = []; if ( ! empty( $attributes['breadcrumbColor'] ) ) { $css['color'] = Color::get_css( isset( $attributes['breadcrumbColor'] ) ? $attributes['breadcrumbColor'] : ''); } $breadcrumbtTypographyGlobal = ! empty( $attributes['breadcrumbtTypographyGlobal'] ) ? $attributes['breadcrumbtTypographyGlobal'] : ''; return array_merge( $css, Typography::get_css( $attributes['breadcrumbtTypography'] ?? [], '', $device, $breadcrumbtTypographyGlobal ) ); } public function get_wrapper_gap_css( $attributes, $device = '' ) { $css = []; $css['display'] = 'flex'; if ( $device === 'Tablet' ) { $css['flex-direction'] = 'column'; } elseif ( $device === 'Mobile' ) { $css['flex-direction'] = 'column'; } else { $css['flex-direction'] = 'row'; } if ( ! empty( $attributes['bothGap'] ) ) { $css['gap'] = $attributes['bothGap'] . 'px'; } return array_merge( $css ); } // * Render the block content. public function render_block_content( $attributes, $content, $block_instance ) { global $wp; global $wpdb; $dashboard_page = isset( $attributes['dashboard_page'] ) && ! empty( $attributes['dashboard_page'] ) ? $attributes['dashboard_page'] : 'root'; $dashboard_pages = json_decode( get_option( ABLOCKS_FRONTEND_DASHBOARD_SUB_PAGES_SETTINGS_NAME, '{}' ), true ); // print_r($dashboard_pages); $breadcrumbs = []; $breadcrumbs[] = [ 'label' => __( 'Dashboard', 'ablocks' ), 'url' => $this->get_frontend_dashboard_endpoint_url( '' ), ]; $current_page_slug = get_query_var( 'ablocks_dashboard_page', 'root' ); $current_sub_page_slug = get_query_var( 'ablocks_dashboard_sub_page' ); if ( $current_page_slug !== 'root' ) { $current_slug = empty( $current_sub_page_slug ) ? $current_page_slug : $current_sub_page_slug; // var_dump($current_slug); // Find the current page in the dashboard_pages array foreach ( $dashboard_pages as $page ) { if ( isset( $page['slug'] ) && $page['slug'] === $current_slug ) { $breadcrumbs[] = [ 'label' => $page['label'], 'url' => isset( $page['permalink'] ) ? $page['permalink'] : $this->get_frontend_dashboard_endpoint_url( $page['slug'] ), ]; break; } if ( is_array( $page['children'] ?? '' ) ) { if ( isset( $page['slug'] ) && $page['slug'] === $current_page_slug ) { $breadcrumbs[] = [ 'label' => $page['label'], 'url' => isset( $page['permalink'] ) ? $page['permalink'] : $this->get_frontend_dashboard_endpoint_url( $page['slug'] ), ]; } foreach ( $page['children'] as $sub_page ) { // print_r([$sub_page['slug'], $current_slug]); if ( isset( $sub_page['slug'] ) && $sub_page['slug'] === $current_slug ) { $breadcrumbs[] = [ 'label' => $sub_page['label'], 'url' => isset( $sub_page['permalink'] ) ? $sub_page['permalink'] : $this->get_frontend_dashboard_endpoint_url( $sub_page['slug'] ), ]; break; } } }//end if }//end foreach }//end if ?>