PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.2.3.1
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.2.3.1
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / classes / Admin / AdminSubscriber.php

AdminSubscriber.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 2.2.3.1, at classes/Admin/AdminSubscriber.php

68 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 declare(strict_types=1);
3
4 namespace Imagify\Admin;
5
6 use Imagify\EventManagement\SubscriberInterface;
7 use Imagify\User\User;
8
9 /**
10 * Admin Subscriber
11 */
12 class AdminSubscriber implements SubscriberInterface {
13
14 /**
15 * User instance.
16 *
17 * @var User
18 */
19 protected $user;
20
21 /**
22 * Instantiate the class
23 *
24 * @param User $user User instance.
25 */
26 public function __construct( User $user ) {
27 $this->user = $user;
28 }
29
30 /**
31 * Returns an array of events this subscriber listens to
32 *
33 * @return array
34 */
35 public static function get_subscribed_events() {
36 $basename = plugin_basename( IMAGIFY_FILE );
37
38 return [
39 'plugin_action_links_' . $basename => 'plugin_action_links',
40 'network_admin_plugin_action_links_' . $basename => 'plugin_action_links',
41 ];
42 }
43
44 /**
45 * Add links to the plugin row in the plugins list.
46 *
47 * @since 1.7
48 *
49 * @param array $actions An array of action links.
50 * @return array
51 */
52 public function plugin_action_links( $actions ) {
53 $text = 1 !== $this->user->plan_id ? __( 'Documentation', 'imagify' ) : __( 'Upgrade', 'imagify' );
54 $url = 1 !== $this->user->plan_id ? 'documentation' : 'subscription';
55 $class = 1 !== $this->user->plan_id ? '' : ' class="imagify-plugin-upgrade"';
56
57 array_unshift( $actions, sprintf( '<a href="%s" target="_blank"%s>%s</a>',
58 esc_url( imagify_get_external_url( $url ) ),
59 $class,
60 $text
61 ) );
62
63 array_unshift( $actions, sprintf( '<a href="%s">%s</a>', esc_url( get_imagify_admin_url( 'bulk-optimization' ) ), __( 'Bulk Optimization', 'imagify' ) ) );
64 array_unshift( $actions, sprintf( '<a href="%s">%s</a>', esc_url( get_imagify_admin_url() ), __( 'Settings', 'imagify' ) ) );
65 return $actions;
66 }
67 }
68