post_type = 'help-docs'; // Dashboard widget if ( get_option( HELPDOCS_GO_PF.'dashboard_toc' ) && get_option( HELPDOCS_GO_PF.'dashboard_toc' ) == '1' ) { add_action( 'wp_dashboard_setup', [ $this, 'dashboard_widget' ] ); } } // End __construct() /** * Dashboard widgets * * @return void */ public function dashboard_widget() { // The dashboard widget title $title = helpdocs_title().' [ View All Docs ]'; // Add the widget if ( helpdocs_user_can_view() ) { wp_add_dashboard_widget( HELPDOCS_TEXTDOMAIN, $title, [ $this, 'dashboard_content' ], null, null, 'normal', 'high' ); } } // End dashboard_widget() /** * Dashboard content * * @return void */ public function dashboard_content( $var, $args ) { // Get all the docs that are enabled $args = [ 'posts_per_page' => -1, 'post_status' => 'publish', 'post_type' => $this->post_type, 'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query 'relation' => 'AND', [ 'key' => HELPDOCS_GO_PF.'site_location', 'value' => base64_encode( 'main' ), ], [ 'key' => HELPDOCS_GO_PF.'toc', 'value' => true, ], ] ]; $docs = get_posts( $args ); // Also get the imports $imports = helpdocs_get_imports( $args ); // Merge them together if ( !empty( $imports ) ) { $docs = array_merge( $docs, $imports ); } // Did we find any? if ( !empty( $docs ) ) { // First we sort by the doc order usort( $docs, function( $a, $b ) { return strcmp( $a->helpdocs_order, $b->helpdocs_order ) ; } ); // CSS echo ''; // Start the container $results = '
'; // Return it echo wp_kses_post( $results ); // No docs found } else { echo '
You have not added any help docs. To do so, edit the docs you want to edit and choose "Add to Dashboard Table of Contents" under "Location" settings.'; } } // End dashboard_content() }