PluginProbe
Faust.js / 1.0.2
Faust.js v1.0.2
1.8.12 1.8.11 1.4.1 1.8.0 1.8.8 1.8.9 trunk 0.7.0 0.7.1 0.7.10 0.7.11 0.7.3 0.7.4 0.7.5 0.7.6 0.7.7 0.7.8 0.7.9 0.8.0 0.8.1 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 All 40 releases
← All changes | includes/settings/callbacks.php +46 -8 0.7.91.0.2 View file →
@@ -10,8 +10,46 @@
10 10 if ( ! defined( 'ABSPATH' ) ) {
11 11 exit;
12 12 }
13 13
14 +add_action( 'admin_notices', __NAMESPACE__ . '\\frontend_url_notice' );
15 +/**
16 + * Callback for WordPress 'admin_notices' action.
17 + *
18 + * Show frontend_url missing error if it doesn't exist.
19 + *
20 + * @return void
21 + */
22 +function frontend_url_notice() {
23 + $screen = get_current_screen();
24 +
25 + // Exit if not this plugin's settings page.
26 + if ( 'settings_page_faustwp-settings' !== $screen->id ) {
27 + return;
28 + }
29 +
30 + $frontend_url_setting = faustwp_get_setting( 'frontend_uri' );
31 +
32 + if ( empty( $frontend_url_setting ) ) {
33 + ?>
34 + <div class="notice notice-error is-dismissible" style="background-color: #FFEAE9;">
35 + <p><?php esc_html_e( 'Front-end site URL is required to utilize url rewrites and previews.', 'faustwp' ); ?></p>
36 + <p><?php esc_html_e( 'It is highly recommended that you update it below to avoid unexpected behavior.', 'faustwp' ); ?></p>
37 + <p>
38 + <?php
39 + printf(
40 + /* translators: Link text */
41 + esc_html__( 'See the %1$s Getting Started Documentation%2$s for more details.', 'faustwp' ),
42 + '<a href="https://faustjs.org/docs/getting-started" target="_blank" rel="noopener noreferrer">',
43 + '</a>'
44 + );
45 + ?>
46 + </p>
47 + </div>
48 + <?php
49 + }
50 +}
51 +
14 52 add_action( 'admin_menu', __NAMESPACE__ . '\\register_settings_menu' );
15 53 /**
16 54 * Callback for WordPress 'admin_menu' action.
17 55 *
@@ -24,10 +62,10 @@
24 62 */
25 63 function register_settings_menu() {
26 64 add_submenu_page(
27 65 'options-general.php',
28 - __( 'Headless', 'faustwp' ),
29 - __( 'Headless', 'faustwp' ),
66 + __( 'Faust', 'faustwp' ),
67 + __( 'Faust', 'faustwp' ),
30 68 'manage_options',
31 69 'faustwp-settings',
32 70 __NAMESPACE__ . '\\display_settings_page'
33 71 );
@@ -126,29 +164,29 @@
126 164 }
127 165
128 166 add_filter( 'sanitize_option_faustwp_settings', __NAMESPACE__ . '\\sanitize_faustwp_settings', 10, 2 );
129 167 /**
130 - * Validates and sanitizes FaustWP settings.
168 + * Validates and sanitizes Faust settings.
131 169 *
132 170 * The plugin settings page will display any relevant errors when
133 - * rejecting invalid settings values. Updates to FaustWP settings that
171 + * rejecting invalid settings values. Updates to Faust settings that
134 172 * are not initiated from the plugin settings page will not return or
135 173 * display errors, but will still reject invalid values.
136 174 *
137 175 * Once settings are validated, the sanitized values are returned.
138 176 *
139 - * @param array $settings FaustWP settings array to validate and sanitize.
177 + * @param array $settings Faust settings array to validate and sanitize.
140 178 * @param string $option WP option name where settings are saved.
141 179 * @return array Sanitized settings.
142 180 */
143 181 function sanitize_faustwp_settings( $settings, $option ) {
144 - $errors = null;
145 -
182 + $errors = null;
183 + $protocols = array( 'http', 'https' );
146 184 foreach ( $settings as $name => $value ) {
147 185 switch ( $name ) {
148 186 case 'frontend_uri':
149 187 if ( '' === $value || preg_match( '#http(s?)://(.+)#i', $value ) ) {
150 - $settings[ $name ] = esc_url_raw( $value );
188 + $settings[ $name ] = esc_url_raw( $value, $protocols );
151 189 } else {
152 190 $errors[ $name ] = __( 'The Front-end site URL you entered did not appear to be a valid URL. Please enter a valid URL.', 'faustwp' );
153 191 $settings[ $name ] = faustwp_get_setting( $name );
154 192 }