Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
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%
7 / 7
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%
7 / 7
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. We will override this, but it is a positional argument in the filter.
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        return sprintf(
36            /* translators: %s: The URL where the log files are accessible. */
37            __(
38                '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.',
39                'bh-wp-logger'
40            ),
41            $url
42        );
43    }
44}