| 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 ) ) { |
| 186 | return; |
| 187 | } |
| 188 | |
| 189 | if ( ! empty( $screen->post_type ) ) { |
| 190 | if ( in_array( $screen->post_type, $this->post_types ) |
| 191 | && $explanation = \DevHub\get_explanation( $screen ) |
| 192 | ) { |
| 193 | $post_type = get_post_type_object( $this->exp_post_type ); |
| 194 | |
| 195 | $wp_admin_bar->add_menu( array( |
| 196 | 'id' => 'edit-explanation', |
| 197 | 'title' => $post_type->labels->edit_item, |
| 198 | 'href' => get_edit_post_link( $explanation ) |
| 199 | ) ); |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | /** |