Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
URL_Is_Public
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 change_warning_message
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * This logger library uses bh-wp-private-uploads library to ensure the logs directory is not publicly accessible.
4 * i.e. it automatically creates a .htaccess on Apache servers, and shows an admin notice warning for Nginx.
5 *
6 * This class customises the warning message.
7 *
8 * This is not relevant when WooCommerce logger is in use.
9 *
10 * @package brianhenryie/bh-wp-logger
11 */
12
13namespace BrianHenryIE\WP_Logger\Private_Uploads;
14
15/**
16 * Filter the bh-wp-private-uploads admin-notice that is shown when the logs url is public.
17 *
18 * @see \BrianHenryIE\WP_Private_Uploads\Admin\Admin_Notices::admin_notices()
19 */
20class URL_Is_Public {
21
22    /**
23     * Change the warning message to say:
24     * "The logs directory is, and should not be, publicly accessible at the URL: %s. Please update your webserver configuration to block access to that folder."
25     *
26     * @hooked bh_wp_private_uploads_url_is_public_warning_{$this->settings->get_plugin_slug()}._logger
27     *
28     * @param string $message The default message.
29     * @param string $url The publicly accessible URL.
30     *
31     * @return string
32     */
33    public function change_warning_message( string $message, string $url ): string {
34
35        /* translators: %s: The URL where the log files are accessible. */
36        $new_message = sprintf( __( 'The logs directory is, and should not be, publicly accessible at the URL: %s. Please update your webserver configuration to block access to that folder.', 'bh-wp-logger' ), $url );
37
38        return $new_message;
39    }
40}