| 174 | * Adds an 'Edit Explanation' link to the Toolbar on parsed post type single pages. |
| 175 | * |
| 176 | * @access public |
| 177 | * |
| 178 | * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance. |
| 179 | */ |
| 180 | public function toolbar_edit_link( $wp_admin_bar ) { |
| 181 | global $wp_the_query; |
| 182 | |
| 183 | $screen = $wp_the_query->get_queried_object(); |
| 184 | |
| 185 | if ( is_admin() || empty( $screen ) || ! is_singular( $this->post_types ) ) { |
| 186 | return; |
| 187 | } |
| 188 | |
| 189 | if ( ! empty( $screen->post_type ) ) { |
| 190 | // Proceed only if there's an explanation for the current reference post type. |
| 191 | if ( $explanation = \DevHub\get_explanation( $screen ) ) { |
| 192 | $post_type = get_post_type_object( $this->exp_post_type ); |
| 193 | |
| 194 | $wp_admin_bar->add_menu( array( |
| 195 | 'id' => 'edit-explanation', |
| 196 | 'title' => $post_type->labels->edit_item, |
| 197 | 'href' => get_edit_post_link( $explanation ) |
| 198 | ) ); |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | /** |