PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / trunk
Image Optimizer – Compress Images and Convert to WebP or AVIF vtrunk
1.7.7 1.7.6 1.7.5 1.7.4 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 All 33 releases
← All changes | classes/utils.php +32 -0 1.2.1 → trunk View file →
@@ -76,8 +76,18 @@
76 76
77 77 return 'upload' === $current_screen->id && 'attachment' === $current_screen->post_type;
78 78 }
79 79
80 + public static function is_media_upload_page(): bool {
81 + $current_screen = get_current_screen();
82 +
83 + if ( ! $current_screen ) {
84 + return false;
85 + }
86 +
87 + return 'media' === $current_screen->id && 'add' === $current_screen->action;
88 + }
89 +
80 90 public static function is_single_attachment_page(): bool {
81 91 $current_screen = get_current_screen();
82 92
83 93 if ( ! $current_screen ) {
@@ -106,6 +116,28 @@
106 116 }
107 117
108 118 public static function user_is_admin(): bool {
109 119 return current_user_can( 'manage_options' );
120 + }
121 +
122 + public static function is_wp_dashboard_page(): bool {
123 + $current_screen = get_current_screen();
124 +
125 + return str_contains( $current_screen->id, 'dashboard' );
126 + }
127 +
128 + public static function is_wp_updates_page(): bool {
129 + $current_screen = get_current_screen();
130 +
131 + return str_contains( $current_screen->id, 'update' );
132 + }
133 +
134 + public static function get_upgrade_link( $link ): string {
135 + $subscription_id = get_option( 'image_optimizer_subscription_id' );
136 +
137 + if ( ! $subscription_id ) {
138 + return $link;
139 + }
140 +
141 + return add_query_arg( 'subscription_id', $subscription_id, $link );
110 142 }
111 143 }