'replace_dashboard', ], false, 'post_date', 'ASC' ); $doing_toc = false; ?>
toc_widget_content(); ?>
ID ); $incl_edit = ' ✎ ' . __( 'Edit', 'admin-help-docs' ) . ''; } else { $incl_edit = ''; } $post_content = $doc->post_content; ?>

post_title ) ); ?>

'; printf( wp_kses( /* translators: %1$s: URL to the Manage Docs screen. */ __( 'To add content here, create a doc and set its location to "WordPress Dashboard (Replaces Dashboard Entirely)".', 'admin-help-docs' ), [ 'a' => [ 'href' => [] ] ] ), esc_url( $create_doc_url ) ); } ?>

'index.php', ] ); if ( ! empty( $docs ) ) { $user_can_edit = Helpers::user_can_edit(); foreach ( $docs as $doc ) { if ( ! Helpers::user_can_view( $doc->ID ) ) { continue; } if ( $user_can_edit ) { if ( isset( $doc->feed_id ) && $doc->feed_id != '' ) { $post_id = $doc->feed_id; } else { $post_id = $doc->ID; } $url = add_query_arg( [ 'post' => absint( $post_id ), 'action' => 'edit', ], admin_url( 'post.php' ) ); $incl_edit = ' ✎ ' . __( 'Edit', 'admin-help-docs' ) . ' '; } else { $incl_edit = ''; } $title = $doc->post_title . $incl_edit; wp_add_dashboard_widget( 'helpdocs_' . absint( $doc->ID ), $title, [ $this, 'doc_widget_content' ], null, $doc, 'normal', 'high' ); } } } // End doc_widgets() /** * Dashboard content * * @return void */ public function doc_widget_content( $var, $args ) { $doc = $args[ 'args' ]; echo wp_kses_post( $doc->post_content ); } // End doc_widget_content() /** * Table of Contents widget * * @return void */ public function toc_widget() { $view_all_docs_link = ' ' . __( 'View All Docs', 'admin-help-docs' ) . ' '; $title = Helpers::get_menu_title() . ' ' . $view_all_docs_link; if ( Helpers::user_can_view() ) { wp_add_dashboard_widget( Bootstrap::textdomain(), $title, [ $this, 'toc_widget_content' ], null, null, 'normal', 'high' ); } } // End toc_widget() /** * Table of Contents content * * @return void */ public function toc_widget_content() { $docs = Helpers::get_docs( [ 'site_location' => 'main', 'toc' => true, ] ); if ( ! empty( $docs ) ) { usort( $docs, function( $a, $b ) { return strcmp( $a->helpdocs_order, $b->helpdocs_order ) ; } ); $results = '
'; echo wp_kses_post( $results ); } else { echo esc_html__( '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.', 'admin-help-docs' ); } } // End toc_widget_content() /** * Prevent cloning and unserializing */ public function __clone() {} public function __wakeup() {} } WPDashboard::instance();