%s', esc_url( add_query_arg( 'page', 'isc-settings', get_admin_url() . 'options-general.php' ) ), __( 'Settings', 'image-source-control-isc' ) ); return $links; } /** * Disable the WPML language switcher on ISC pages * * @param bool $state current state. * * @return bool */ public function disable_wpml_admin_lang_switcher( $state ): bool { // needs to run before plugins_loaded with prio 1, so our own `is_isc_page` function is not available here global $pagenow; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( ! isset( $_GET['page'] ) ) { return $state; } // settings page if ( $pagenow === 'options-general.php' // phpcs:ignore WordPress.Security.NonceVerification.Recommended && in_array( $_GET['page'], [ 'isc-settings' ], true ) ) { $state = false; } // media pages if ( $pagenow === 'upload.php' // phpcs:ignore WordPress.Security.NonceVerification.Recommended && in_array( $_GET['page'], [ 'isc-unused-images', 'isc-images' ], true ) ) { $state = false; } return $state; } /** * Add an ISC branded header to plugin pages */ public static function branded_admin_header() { $screen = get_current_screen(); $screen_id = $screen->id ?? null; if ( ! Admin_Utils::is_isc_page() ) { return; } switch ( $screen_id ) { case 'settings_page_isc-settings': $title = __( 'Settings', 'image-source-control-isc' ); break; case 'media_page_isc-sources': $title = __( 'Tools', 'image-source-control-isc' ); break; default: $title = get_admin_page_title(); } include ISCPATH . 'admin/templates/header.php'; } /** * Actions to perform when an attachment is removed */ public function clear_unused_images_stats() { // remove the transient with the unused image numbers delete_transient( 'isc-unused-attachments-stats' ); } }