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/class-dashboard-link.php +16 -10 3.2.03.8.4 View file →
@@ -1,10 +1,10 @@
1 1 <?php
2 2 /**
3 - * Parse.ly Dashboard Link utility class.
3 + * Dashboard link utility class
4 4 *
5 5 * @package Parsely
6 - * @since 3.1.0
6 + * @since 3.1.0
7 7 */
8 8
9 9 declare(strict_types=1);
10 10
@@ -10,8 +10,9 @@
10 10
11 11 namespace Parsely;
12 12
13 13 use WP_Post;
14 +use Parsely\Parsely;
14 15
15 16 /**
16 17 * Utility methods to build and generate dashboard links.
17 18 *
@@ -18,20 +19,27 @@
18 19 * @since 3.1.0
19 20 */
20 21 class Dashboard_Link {
21 22 /**
22 - * Generate the Parse.ly dashboard URL for the post. Returns an empty string if the URL could not be generated.
23 + * Generates the Parse.ly dashboard URL for the post. Returns an empty
24 + * string if the URL could not be generated.
23 25 *
24 26 * @since 2.6.0
25 27 * @since 3.1.0 Moved to class-dashboard-link.php. Added source parameter.
26 28 *
27 29 * @param WP_Post $post Which post object or ID to check.
28 - * @param string $apikey API key or empty string.
30 + * @param string $site_id Site ID or empty string.
29 31 * @param string $campaign Campaign name for the `utm_campaign` URL parameter.
30 32 * @param string $source Source name for the `utm_source` URL parameter.
33 + *
31 34 * @return string
32 35 */
33 - public static function generate_url( WP_Post $post, string $apikey, string $campaign, string $source ): string {
36 + public static function generate_url( WP_Post $post, string $site_id, string $campaign, string $source ): string {
37 + /**
38 + * Internal variable.
39 + *
40 + * @var string|false
41 + */
34 42 $permalink = get_permalink( $post );
35 43 if ( ! is_string( $permalink ) ) {
36 44 return '';
37 45 }
@@ -42,15 +50,13 @@
42 50 'utm_source' => $source,
43 51 'utm_medium' => 'wp-parsely',
44 52 );
45 53
46 - $base_url = trailingslashit( 'https://dash.parsely.com/' . $apikey ) . 'find';
47 -
48 - return add_query_arg( $query_args, $base_url );
54 + return add_query_arg( $query_args, Parsely::get_dash_url( $site_id ) );
49 55 }
50 56
51 57 /**
52 - * Determine whether Parse.ly dashboard link should be shown or not.
58 + * Determines whether Parse.ly dashboard link should be shown or not.
53 59 *
54 60 * @since 2.6.0
55 61 * @since 3.1.0 Moved to class-dashboard-link.php. Renamed from `cannot_show_parsely_link`.
56 62 *
@@ -58,7 +64,7 @@
58 64 * @param Parsely $parsely Parsely object.
59 65 * @return bool True if the link can be shown, false otherwise.
60 66 */
61 67 public static function can_show_link( WP_Post $post, Parsely $parsely ): bool {
62 - return Parsely::post_has_trackable_status( $post ) && is_post_type_viewable( $post->post_type ) && ! $parsely->api_key_is_missing();
68 + return Parsely::post_has_trackable_status( $post ) && is_post_type_viewable( $post->post_type ) && ! $parsely->site_id_is_missing();
63 69 }
64 70 }