| @@ -76,8 +76,28 @@ | ||
| 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 | + | |
| 90 | + public static function is_single_attachment_page(): bool { | |
| 91 | + $current_screen = get_current_screen(); | |
| 92 | + | |
| 93 | + if ( ! $current_screen ) { | |
| 94 | + return false; | |
| 95 | + } | |
| 96 | + | |
| 97 | + return 'attachment' === $current_screen->id && 'post' === $current_screen->base; | |
| 98 | + } | |
| 99 | + | |
| 80 | 100 | public static function is_plugin_page(): bool { |
| 81 | 101 | $current_screen = get_current_screen(); |
| 82 | 102 | |
| 83 | 103 | return str_contains( $current_screen->id, 'image-optimization-' ); |
| @@ -82,8 +102,42 @@ | ||
| 82 | 102 | |
| 83 | 103 | return str_contains( $current_screen->id, 'image-optimization-' ); |
| 84 | 104 | } |
| 85 | 105 | |
| 106 | + public static function is_plugin_settings_page(): bool { | |
| 107 | + $current_screen = get_current_screen(); | |
| 108 | + | |
| 109 | + return str_contains( $current_screen->id, 'image-optimization-settings' ); | |
| 110 | + } | |
| 111 | + | |
| 112 | + public static function is_bulk_optimization_page(): bool { | |
| 113 | + $current_screen = get_current_screen(); | |
| 114 | + | |
| 115 | + return str_contains( $current_screen->id, 'image-optimization-bulk-optimization' ); | |
| 116 | + } | |
| 117 | + | |
| 86 | 118 | public static function user_is_admin(): bool { |
| 87 | 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 ); | |
| 88 | 142 | } |
| 89 | 143 | } |