| @@ -117,5 +117,27 @@ | ||
| 117 | 117 | |
| 118 | 118 | public static function user_is_admin(): bool { |
| 119 | 119 | return current_user_can( 'manage_options' ); |
| 120 | 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 ); | |
| 142 | + } | |
| 121 | 143 | } |