PluginProbe
Parse.ly / 3.8.4
Parse.ly v3.8.4
3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 3.20.2 3.20.3 All 105 releases
← All changes | src/UI/class-admin-bar.php +28 -15 3.2.03.8.4 View file →
@@ -1,10 +1,12 @@
1 1 <?php
2 2 /**
3 - * Parsely tweaks to WordPress admin bar
3 + * UI: Admin bar class
4 4 *
5 + * Enhances the WordPress admin bar with Parse.ly tweaks.
6 + *
5 7 * @package Parsely
6 - * @since 3.1.0
8 + * @since 3.1.0
7 9 */
8 10
9 11 declare(strict_types=1);
10 12
@@ -9,14 +11,15 @@
9 11 declare(strict_types=1);
10 12
11 13 namespace Parsely\UI;
12 14
15 +use WP_Post;
13 16 use WP_Admin_Bar;
14 17 use Parsely\Parsely;
15 18 use Parsely\Dashboard_Link;
16 19
17 20 /**
18 - * Render Parse.ly related buttons in the WordPress administrator top bar.
21 + * Renders Parse.ly related buttons in the WordPress administrator top bar.
19 22 *
20 23 * @since 3.1.0
21 24 */
22 25 final class Admin_Bar {
@@ -36,17 +39,16 @@
36 39 $this->parsely = $parsely;
37 40 }
38 41
39 42 /**
40 - * Register admin bar buttons.
43 + * Registers admin bar buttons.
41 44 *
42 45 * @since 3.1.0
43 - *
44 - * @return void
45 46 */
46 47 public function run(): void {
47 48 /**
48 - * Filter whether the Open on Parse.ly button is enabled or not on the admin bar menu.
49 + * Filter whether the Open on Parse.ly button is enabled or not on the
50 + * admin bar menu.
49 51 *
50 52 * @since 3.1.2
51 53 *
52 54 * @param bool $enabled True if enabled, false if not.
@@ -57,24 +59,35 @@
57 59 }
58 60 }
59 61
60 62 /**
61 - * Adds the `Parse.ly Stats` button on the admin bar when the current object is a post or a page.
63 + * Adds the `Parse.ly Stats` button on the admin bar when the current object
64 + * is a post or a page.
62 65 *
63 66 * @param WP_Admin_Bar $admin_bar WP_Admin_Bar instance, passed by reference.
64 - *
65 - * @return void
66 67 */
67 68 public function admin_bar_parsely_stats_button( WP_Admin_Bar $admin_bar ): void {
68 - $current_object = $GLOBALS['wp_the_query']->get_queried_object();
69 + /**
70 + * Variable.
71 + *
72 + * @var \WP_Term|\WP_Post_Type|WP_Post|\WP_User|null
73 + */
74 + $queried_object = $GLOBALS['wp_the_query']->get_queried_object();
69 75
70 - if ( null === $current_object || empty( $current_object->post_type ) ) {
76 + if ( null === $queried_object || WP_Post::class !== get_class( $queried_object ) ) {
71 77 return;
72 78 }
73 79
74 - $post_type_object = get_post_type_object( $current_object->post_type );
75 - if ( null !== $post_type_object && $post_type_object->show_in_admin_bar && Dashboard_Link::can_show_link( $current_object, $this->parsely ) ) {
76 - $href = Dashboard_Link::generate_url( $current_object, $this->parsely->get_api_key(), 'wp-page-single', 'admin-bar' );
80 + /**
81 + * Variable.
82 + *
83 + * @var WP_Post
84 + */
85 + $current_post = $queried_object;
86 +
87 + $post_type_object = get_post_type_object( $current_post->post_type );
88 + if ( null !== $post_type_object && $post_type_object->show_in_admin_bar && Dashboard_Link::can_show_link( $current_post, $this->parsely ) ) {
89 + $href = Dashboard_Link::generate_url( $current_post, $this->parsely->get_site_id(), 'wp-page-single', 'admin-bar' );
77 90
78 91 // Not adding the link if there were issues generating the URL.
79 92 if ( '' !== $href ) {
80 93 $admin_bar->add_node(